[Freeciv-commits] r33565 - in /branches/S2_6/common: actions.c actions.h aicore/caravan.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 05:43:28 2016
New Revision: 33565

URL: http://svn.gna.org/viewcvs/freeciv?rev=33565&view=rev
Log:
Made AI caravans able to plan trade routes over longer distances than one tile.

See bug #24947

Modified:
branches/S2_6/common/actions.c
branches/S2_6/common/actions.h
branches/S2_6/common/aicore/caravan.c

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=33565&r1=33564&r2=33565&view=diff
==
--- branches/S2_6/common/actions.c  (original)
+++ branches/S2_6/common/actions.c  Thu Aug 11 05:43:28 2016
@@ -492,7 +492,8 @@
   const struct output_type *target_output,
const struct specialist *target_specialist,
const bool omniscient,
-   const struct city *homecity)
+   const struct city *homecity,
+   bool ignore_dist)
 {
   fc_assert_msg((action_get_target_kind(wanted_action) == ATK_CITY
  && target_city != NULL)
@@ -500,7 +501,7 @@
 && target_unit != NULL),
 "Missing target!");
 
-  if (action_get_actor_kind(wanted_action) == AAK_UNIT) {
+  if (!ignore_dist && action_get_actor_kind(wanted_action) == AAK_UNIT) {
 /* The Freeciv code for all actions controlled by enablers assumes that
  * an acting unit is on the same tile as its target or on the tile next
  * to it. */
@@ -718,7 +719,7 @@
  const struct unit_type *target_unittype,
  const struct output_type *target_output,
  const struct specialist *target_specialist,
-  const struct city *homecity)
+  const struct city *homecity, bool ignore_dist)
 {
   if (!is_action_possible(wanted_action,
   actor_player, actor_city,
@@ -729,7 +730,7 @@
   target_building, target_tile,
   target_unit, target_unittype,
   target_output, target_specialist,
-  TRUE, homecity)) {
+  TRUE, homecity, ignore_dist)) {
 /* The action enablers are irrelevant since the action it self is
  * impossible. */
 return FALSE;
@@ -764,7 +765,8 @@
 {
   return is_action_enabled_unit_on_city_full(wanted_action, actor_unit,
  target_city,
- 
game_city_by_number(actor_unit->homecity));
+ 
game_city_by_number(actor_unit->homecity),
+ FALSE);
 }
 
 /**
@@ -776,7 +778,8 @@
 bool is_action_enabled_unit_on_city_full(const enum gen_action wanted_action,
  const struct unit *actor_unit,
  const struct city *target_city,
- const struct city *homecity)
+ const struct city *homecity,
+ bool ignore_dist)
 {
   struct tile *actor_tile = unit_tile(actor_unit);
 
@@ -811,7 +814,7 @@
NULL, NULL,
city_owner(target_city), target_city, NULL,
city_tile(target_city), NULL, NULL, NULL, NULL,
-   homecity);
+   homecity, ignore_dist);
 }
 
 /**
@@ -861,7 +864,8 @@
unit_tile(target_unit),
target_unit, unit_type_get(target_unit),
NULL, NULL,
-   game_city_by_number(actor_unit->homecity));
+   game_city_by_number(actor_unit->homecity),
+   FALSE);
 }
 
 /**
@@ -1160,7 +1164,7 @@
   target_building, target_tile,
   target_unit, target_unittype,
   target_output, target_specialist,
-  FALSE, homecity)) {
+  FALSE, homecity, FALSE)) {
 /* The action enablers are irrelevant since the action it self is
  * impossible. */
 return ACTPROB_IMPOSSIBLE;

Modified: branches/S2_6/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.h?rev=33565&r1=33564&r2=33565&view=diff
==
--- branches/S2_6/common/actions.h  (ori

[Freeciv-commits] r33564 - in /trunk/common: actions.c actions.h aicore/caravan.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 05:43:22 2016
New Revision: 33564

URL: http://svn.gna.org/viewcvs/freeciv?rev=33564&view=rev
Log:
Made AI caravans able to plan trade routes over longer distances than one tile.

See bug #24947

Modified:
trunk/common/actions.c
trunk/common/actions.h
trunk/common/aicore/caravan.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33564&r1=33563&r2=33564&view=diff
==
--- trunk/common/actions.c  (original)
+++ trunk/common/actions.c  Thu Aug 11 05:43:22 2016
@@ -1251,7 +1251,8 @@
const struct output_type *target_output,
const struct specialist *target_specialist,
const bool omniscient,
-   const struct city *homecity)
+   const struct city *homecity,
+   bool ignore_dist)
 {
   bool can_see_tgt_unit;
   bool can_see_tgt_tile;
@@ -1283,14 +1284,13 @@
   || plr_sees_tile(actor_player, target_tile));
 
   /* Info leak: The player knows where his unit is. */
-  if (action_get_target_kind(wanted_action) != ATK_SELF) {
-if (!action_id_distance_accepted(wanted_action,
-real_map_distance(actor_tile,
-  target_tile))) {
-  /* The distance between the actor and the target isn't inside the
-   * action's accepted range. */
-  return TRI_NO;
-}
+  if (!ignore_dist && action_get_target_kind(wanted_action) != ATK_SELF
+  && !action_id_distance_accepted(wanted_action,
+  real_map_distance(actor_tile,
+target_tile))) {
+/* The distance between the actor and the target isn't inside the
+ * action's accepted range. */
+return TRI_NO;
   }
 
   if (action_get_target_kind(wanted_action) == ATK_UNIT) {
@@ -1717,7 +1717,7 @@
  const struct unit_type *target_unittype,
  const struct output_type *target_output,
  const struct specialist *target_specialist,
-  const struct city *homecity)
+  const struct city *homecity, bool ignore_dist)
 {
   enum fc_tristate possible;
 
@@ -1730,7 +1730,7 @@
 target_building, target_tile,
 target_unit, target_unittype,
 target_output, target_specialist,
-TRUE, homecity);
+TRUE, homecity, ignore_dist);
 
   if (possible != TRI_YES) {
 /* This context is omniscient. Should be yes or no. */
@@ -1771,7 +1771,8 @@
 {
   return is_action_enabled_unit_on_city_full(wanted_action, actor_unit,
  target_city,
- 
game_city_by_number(actor_unit->homecity));
+ 
game_city_by_number(actor_unit->homecity),
+ FALSE);
 }
 
 /**
@@ -1783,7 +1784,8 @@
 bool is_action_enabled_unit_on_city_full(const enum gen_action wanted_action,
  const struct unit *actor_unit,
  const struct city *target_city,
- const struct city *homecity)
+ const struct city *homecity,
+ bool ignore_dist)
 {
   struct tile *actor_tile = unit_tile(actor_unit);
   struct impr_type *target_building;
@@ -1823,7 +1825,8 @@
NULL, NULL,
city_owner(target_city), target_city,
target_building, city_tile(target_city),
-   NULL, target_utype, NULL, NULL, homecity);
+   NULL, target_utype, NULL, NULL, homecity,
+   ignore_dist);
 }
 
 /**
@@ -1872,7 +1875,8 @@
unit_tile(target_unit),
target_unit, unit_type_get(target_unit),
NULL, NULL,
-   game_city_by_number(actor_unit->homecity));
+   game_city_by_number(actor_unit->homecity),
+   FALSE);
 }
 
 /**
@@ -1925,7 +1929,7 @@
tile_city(unit_tile(target_unit)), NULL,
unit_tile(target_unit),
target_unit, unit_type_get(target_unit),
-

[Freeciv-commits] r33563 - in /branches/S2_5: common/city.c common/vision.c server/cityturn.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 04:52:10 2016
New Revision: 33563

URL: http://svn.gna.org/viewcvs/freeciv?rev=33563&view=rev
Log:
Fixed compiler warnings about comparisons of unsigned type 'citizen' against 
negative values.

See bug #24948

Modified:
branches/S2_5/common/city.c
branches/S2_5/common/vision.c
branches/S2_5/server/cityturn.c

Modified: branches/S2_5/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/city.c?rev=33563&r1=33562&r2=33563&view=diff
==
--- branches/S2_5/common/city.c (original)
+++ branches/S2_5/common/city.c Thu Aug 11 04:52:10 2016
@@ -2221,7 +2221,6 @@
* specialists or angry are unhappy. This is changed by luxuries and 
* buildings later. */
   *unhappy = (size - specialist_count - *content - *angry);
-  fc_assert_action(*unhappy >= 0, *unhappy = 0);
 
   /* No one is born happy. */
   *happy = 0;

Modified: branches/S2_5/common/vision.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/vision.c?rev=33563&r1=33562&r2=33563&view=diff
==
--- branches/S2_5/common/vision.c   (original)
+++ branches/S2_5/common/vision.c   Thu Aug 11 04:52:10 2016
@@ -134,7 +134,6 @@
 void vision_site_size_set(struct vision_site *psite, citizens size)
 {
   fc_assert_ret(psite != NULL);
-  fc_assert_ret(size <= MAX_CITY_SIZE);
 
   psite->size = size;
 }

Modified: branches/S2_5/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/cityturn.c?rev=33563&r1=33562&r2=33563&view=diff
==
--- branches/S2_5/server/cityturn.c (original)
+++ branches/S2_5/server/cityturn.c Thu Aug 11 04:52:10 2016
@@ -890,7 +890,7 @@
 bool city_change_size(struct city *pcity, citizens size,
   struct player *nationality)
 {
-  fc_assert_ret_val(size >= 0 && size <= MAX_CITY_SIZE, TRUE);
+  fc_assert_ret_val(size <= MAX_CITY_SIZE, TRUE);
 
   if (size > city_size_get(pcity)) {
 /* Increase city size until size reached, or increase fails */


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33562 - in /branches/S2_6: common/city.c common/vision.c server/cityturn.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 04:52:05 2016
New Revision: 33562

URL: http://svn.gna.org/viewcvs/freeciv?rev=33562&view=rev
Log:
Fixed compiler warnings about comparisons of unsigned type 'citizen' against 
negative values.

See bug #24948

Modified:
branches/S2_6/common/city.c
branches/S2_6/common/vision.c
branches/S2_6/server/cityturn.c

Modified: branches/S2_6/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/city.c?rev=33562&r1=33561&r2=33562&view=diff
==
--- branches/S2_6/common/city.c (original)
+++ branches/S2_6/common/city.c Thu Aug 11 04:52:05 2016
@@ -2185,7 +2185,6 @@
* specialists or angry are unhappy. This is changed by luxuries and 
* buildings later. */
   *unhappy = (size - spes - *content - *angry);
-  fc_assert_action(*unhappy >= 0, *unhappy = 0);
 
   /* No one is born happy. */
   *happy = 0;

Modified: branches/S2_6/common/vision.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/vision.c?rev=33562&r1=33561&r2=33562&view=diff
==
--- branches/S2_6/common/vision.c   (original)
+++ branches/S2_6/common/vision.c   Thu Aug 11 04:52:05 2016
@@ -134,7 +134,6 @@
 void vision_site_size_set(struct vision_site *psite, citizens size)
 {
   fc_assert_ret(psite != NULL);
-  fc_assert_ret(size <= MAX_CITY_SIZE);
 
   psite->size = size;
 }

Modified: branches/S2_6/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/cityturn.c?rev=33562&r1=33561&r2=33562&view=diff
==
--- branches/S2_6/server/cityturn.c (original)
+++ branches/S2_6/server/cityturn.c Thu Aug 11 04:52:05 2016
@@ -915,7 +915,7 @@
 {
   int change = size - city_size_get(pcity);
 
-  fc_assert_ret_val(size >= 0 && size <= MAX_CITY_SIZE, TRUE);
+  fc_assert_ret_val(size <= MAX_CITY_SIZE, TRUE);
 
   if (change != 0 && reason != NULL) {
 script_server_signal_emit("city_size_change", 3,


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33561 - in /trunk: common/city.c common/vision.c server/cityturn.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 04:51:59 2016
New Revision: 33561

URL: http://svn.gna.org/viewcvs/freeciv?rev=33561&view=rev
Log:
Fixed compiler warnings about comparisons of unsigned type 'citizen' against 
negative values.

See bug #24948

Modified:
trunk/common/city.c
trunk/common/vision.c
trunk/server/cityturn.c

Modified: trunk/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/city.c?rev=33561&r1=33560&r2=33561&view=diff
==
--- trunk/common/city.c (original)
+++ trunk/common/city.c Thu Aug 11 04:51:59 2016
@@ -2336,7 +2336,6 @@
* specialists or angry are unhappy. This is changed by luxuries and 
* buildings later. */
   *unhappy = (size - spes - *content - *angry);
-  fc_assert_action(*unhappy >= 0, *unhappy = 0);
 
   /* No one is born happy. */
   *happy = 0;

Modified: trunk/common/vision.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/vision.c?rev=33561&r1=33560&r2=33561&view=diff
==
--- trunk/common/vision.c   (original)
+++ trunk/common/vision.c   Thu Aug 11 04:51:59 2016
@@ -134,7 +134,6 @@
 void vision_site_size_set(struct vision_site *psite, citizens size)
 {
   fc_assert_ret(psite != NULL);
-  fc_assert_ret(size <= MAX_CITY_SIZE);
 
   psite->size = size;
 }

Modified: trunk/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=33561&r1=33560&r2=33561&view=diff
==
--- trunk/server/cityturn.c (original)
+++ trunk/server/cityturn.c Thu Aug 11 04:51:59 2016
@@ -962,7 +962,7 @@
 {
   int change = size - city_size_get(pcity);
 
-  fc_assert_ret_val(size >= 0 && size <= MAX_CITY_SIZE, TRUE);
+  fc_assert_ret_val(size <= MAX_CITY_SIZE, TRUE);
 
   if (change != 0 && reason != NULL) {
 script_server_signal_emit("city_size_change", 3,


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33559 - /branches/S2_6/client/gui-qt/menu.cpp

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:24:40 2016
New Revision: 33559

URL: http://svn.gna.org/viewcvs/freeciv?rev=33559&view=rev
Log:
Qt client: ask for target for "Do..."

Change "Do..." to always ask the player for a target tile. A 2nd call (like
pressing "d" twice) will call the old "Do..." against own tile like it used
to do.

See patch #7579

Modified:
branches/S2_6/client/gui-qt/menu.cpp

Modified: branches/S2_6/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/menu.cpp?rev=33559&r1=33558&r2=33559&view=diff
==
--- branches/S2_6/client/gui-qt/menu.cpp(original)
+++ branches/S2_6/client/gui-qt/menu.cppThu Aug 11 02:24:40 2016
@@ -1917,7 +1917,7 @@
 break;
 
   case ORDER_DIPLOMAT_DLG:
-if (can_units_act_against_own_tile(punits)) {
+if (units_can_do_action(punits, ACTION_ANY, TRUE)) {
   i.value()->setEnabled(true);
 }
 break;
@@ -2147,7 +2147,7 @@
 ***/
 void mr_menu::slot_action()
 {
-  key_unit_action_select();
+  key_unit_action_select_tgt();
 }
 
 


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33560 - /branches/S2_6/server/unittools.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:24:48 2016
New Revision: 33560

URL: http://svn.gna.org/viewcvs/freeciv?rev=33560&view=rev
Log:
Forbid paradropping to same tile.

Forbid paradropping to the tile where the unit already is.

See patch #7581

Modified:
branches/S2_6/server/unittools.c

Modified: branches/S2_6/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=33560&r1=33559&r2=33560&view=diff
==
--- branches/S2_6/server/unittools.c(original)
+++ branches/S2_6/server/unittools.cThu Aug 11 02:24:48 2016
@@ -2694,6 +2694,10 @@
 "is greater than the unit's range (%i)."),
   distance, range);
 return FALSE;
+  } else if (distance < 1) {
+notify_player(pplayer, ptile, E_BAD_COMMAND, ftc_server,
+  _("Already here."));
+return FALSE;
   }
 
   if (map_is_known_and_seen(ptile, pplayer, V_MAIN)) {


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33558 - in /branches/S2_6: client/control.c data/helpdata.txt

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:24:30 2016
New Revision: 33558

URL: http://svn.gna.org/viewcvs/freeciv?rev=33558&view=rev
Log:
2nd targeted "Do..." means target own tile.

Change key_unit_action_select_tgt() so it targets the actor's own tile the
2nd time it is called. Targeting its own tile is the traditional behavior.

This makes using key_unit_action_select_tgt() to handle the "d" key press
less confusing and annoying for old players.

A user with an existing habit of pressing "d" to act against a target on
the same tile as the actor is likely to press it again if the first key press
doesn't work. If he selected the menu item he will notice that the mouse
pointer turns into a selector.

Pressing "d" twice doesn't slow down acting against a target on the same
tile as the actor too much. No mouse is required.

See patch #7578

Modified:
branches/S2_6/client/control.c
branches/S2_6/data/helpdata.txt

Modified: branches/S2_6/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.c?rev=33558&r1=33557&r2=33558&view=diff
==
--- branches/S2_6/client/control.c  (original)
+++ branches/S2_6/client/control.c  Thu Aug 11 02:24:30 2016
@@ -2960,10 +2960,25 @@
 /**
   Have the user select what action the unit(s) in focus should perform to
   the targets at the tile the user will specify by clicking on it.
+
+  Will stop asking for a target tile and have each actor unit act against
+  its own tile if called twice.
 **/
 void key_unit_action_select_tgt(void)
 {
   struct unit_list *punits = get_units_in_focus();
+
+  if (hover_state == HOVER_ACT_SEL_TGT) {
+/* The 2nd key press means that the actor should target its own
+ * tile. */
+key_unit_action_select();
+
+/* Target tile selected. Clean up hover state. */
+set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, NULL, ORDER_LAST);
+update_unit_info_label(punits);
+
+return;
+  }
 
   set_hover_state(punits, HOVER_ACT_SEL_TGT, ACTIVITY_LAST, NULL,
   ORDER_LAST);

Modified: branches/S2_6/data/helpdata.txt
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/helpdata.txt?rev=33558&r1=33557&r2=33558&view=diff
==
--- branches/S2_6/data/helpdata.txt (original)
+++ branches/S2_6/data/helpdata.txt Thu Aug 11 02:24:30 2016
@@ -1584,7 +1584,7 @@
   b: (b)uild city  (settler units)\n\
   b: help (b)uild wonder  (caravan units)\n\
   B: go to and (B)uild city on target tile  (settler units)\n\
-  d: (d)o an action to a target on this tile.\n\
+  d: (d)o an action to the selected tile (press twice to target own tile)\n\
   D: (D)isband unit\n\
   E: build airbas(e)  (airbase units)\n\
   f: (f)ortify unit  (military units)\n\


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33555 - /trunk/server/unithand.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:20:35 2016
New Revision: 33555

URL: http://svn.gna.org/viewcvs/freeciv?rev=33555&view=rev
Log:
Action not enabled explain actor tgt distance.

Explain when an action fails because the actor was too near or too far away
from the target.

See patch #7582

Modified:
trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=33555&r1=33554&r2=33555&view=diff
==
--- trunk/server/unithand.c (original)
+++ trunk/server/unithand.c Thu Aug 11 02:20:35 2016
@@ -110,6 +110,10 @@
   ANEK_TGT_IS_CLAIMED,
   /* Explanation: can't be done to unclaimed target tiles. */
   ANEK_TGT_IS_UNCLAIMED,
+  /* Explanation: can't be done because target is too near. */
+  ANEK_DISTANCE_NEAR,
+  /* Explanation: can't be done because target is too far away. */
+  ANEK_DISTANCE_FAR,
   /* Explanation: actor can't reach unit at target. */
   ANEK_TGT_UNREACHABLE,
   /* Explanation: the action is disabled in this scenario. */
@@ -147,6 +151,9 @@
 
 /* The action that blocks the action. */
 struct action *blocker;
+
+/* The required distance. */
+int distance;
   };
 };
 
@@ -942,6 +949,34 @@
  CITYT_CLAIMED,
  FALSE)) {
 explnat->kind = ANEK_TGT_IS_UNCLAIMED;
+  } else if (action_id_is_valid(action_id) && punit
+ && ((target_tile
+  && real_map_distance(unit_tile(punit), target_tile)
+  > action_by_number(action_id)->max_distance)
+ || (target_city
+ && real_map_distance(unit_tile(punit),
+  city_tile(target_city))
+> action_by_number(action_id)->max_distance)
+ || (target_unit
+ && real_map_distance(unit_tile(punit),
+  unit_tile(target_unit))
+> action_by_number(action_id)->max_distance))) {
+explnat->kind = ANEK_DISTANCE_FAR;
+explnat->distance = action_by_number(action_id)->max_distance;
+  } else if (action_id_is_valid(action_id) && punit
+ && ((target_tile
+  && real_map_distance(unit_tile(punit), target_tile)
+  < action_by_number(action_id)->min_distance)
+ || (target_city
+ && real_map_distance(unit_tile(punit),
+  city_tile(target_city))
+< action_by_number(action_id)->min_distance)
+ || (target_unit
+ && real_map_distance(unit_tile(punit),
+  unit_tile(target_unit))
+< action_by_number(action_id)->min_distance))) {
+explnat->kind = ANEK_DISTANCE_NEAR;
+explnat->distance = action_by_number(action_id)->min_distance;
   } else if (target_city
  && (action_id == ACTION_JOIN_CITY
  && action_actor_utype_hard_reqs_ok(ACTION_JOIN_CITY,
@@ -1122,6 +1157,14 @@
 notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
   _("This unit cannot act against unclaimed tiles."));
 break;
+  case ANEK_DISTANCE_NEAR:
+notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+  _("This unit is to near its target to act."));
+break;
+  case ANEK_DISTANCE_FAR:
+notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+  _("This unit is to far away from its target to act."));
+break;
   case ANEK_SCENARIO_DISABLED:
 notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
   _("Can't perform any action this scenario permits."));
@@ -1511,6 +1554,26 @@
   event, ftc_server,
   _("Your %s can't do %s to unclaimed tiles."),
   unit_name_translation(actor),
+  action_get_ui_name(stopped_action));
+break;
+  case ANEK_DISTANCE_NEAR:
+notify_player(pplayer, unit_tile(actor),
+  event, ftc_server,
+  PL_("Your %s must be at least %d tile away to do %s.",
+  "Your %s must be at least %d tiles away to do %s.",
+  explnat->distance),
+  unit_name_translation(actor),
+  explnat->distance,
+  action_get_ui_name(stopped_action));
+break;
+  case ANEK_DISTANCE_FAR:
+notify_player(pplayer, unit_tile(actor),
+  event, ftc_server,
+  PL_("Your %s can't be more than %d tile away to do %s.",
+  "Your %s can't be more than %d tiles away to do %s.",
+  explnat->distance),
+  unit_name_translation(actor),
+  expln

[Freeciv-commits] r33556 - in /trunk: common/actions.c doc/README.actions

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:20:42 2016
New Revision: 33556

URL: http://svn.gna.org/viewcvs/freeciv?rev=33556&view=rev
Log:
Forbid paradropping to same tile.

Forbid paradropping to the tile where the unit already is.

See patch #7581

Modified:
trunk/common/actions.c
trunk/doc/README.actions

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33556&r1=33555&r2=33556&view=diff
==
--- trunk/common/actions.c  (original)
+++ trunk/common/actions.c  Thu Aug 11 02:20:42 2016
@@ -225,7 +225,7 @@
   actions[ACTION_PARADROP] =
   action_new(ACTION_PARADROP, ATK_TILE,
  FALSE, FALSE, TRUE,
- 0, UNIT_MAX_PARADROP_RANGE);
+ 1, UNIT_MAX_PARADROP_RANGE);
   actions[ACTION_AIRLIFT] =
   action_new(ACTION_AIRLIFT, ATK_CITY,
  FALSE, FALSE, TRUE,

Modified: trunk/doc/README.actions
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.actions?rev=33556&r1=33555&r2=33556&view=diff
==
--- trunk/doc/README.actions(original)
+++ trunk/doc/README.actionsThu Aug 11 02:20:42 2016
@@ -342,7 +342,7 @@
 
 "Paradrop Unit"
  * UI name can be set using ui_paradrop_unit
- * the distance between actor and target is paratroopers_range or less
+ * the distance between actor and target is from 1 to paratroopers_range
  * the actor unit hasn't paradropped this turn
  * the actor unit has paratroopers_mr_req moves left
  * the actor unit isn't transporting another unit (!)


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33554 - /trunk/client/gui-qt/dialogs.cpp

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:20:27 2016
New Revision: 33554

URL: http://svn.gna.org/viewcvs/freeciv?rev=33554&view=rev
Log:
Qt client: act sel dlg paradrop and airlift.

Support the actions "Paradrop Unit" and "Airlift Unit" in the action
selection dialog.

See patch #7580

Modified:
trunk/client/gui-qt/dialogs.cpp

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=33554&r1=33553&r2=33554&view=diff
==
--- trunk/client/gui-qt/dialogs.cpp (original)
+++ trunk/client/gui-qt/dialogs.cpp Thu Aug 11 02:20:27 2016
@@ -89,9 +89,11 @@
 static void found_city(QVariant data1, QVariant data2);
 static void nuke(QVariant data1, QVariant data2);
 static void attack(QVariant data1, QVariant data2);
+static void paradrop(QVariant data1, QVariant data2);
 static void disband_unit(QVariant data1, QVariant data2);
 static void join_city(QVariant data1, QVariant data2);
 static void unit_home_city(QVariant data1, QVariant data2);
+static void airlift(QVariant data1, QVariant data2);
 static void keep_moving(QVariant data1, QVariant data2);
 static void pillage_something(QVariant data1, QVariant data2);
 static void action_entry(choice_dialog *cd,
@@ -142,6 +144,7 @@
   action_function[ACTION_DESTROY_CITY] = destroy_city;
   action_function[ACTION_RECYCLE_UNIT] = unit_recycle;
   action_function[ACTION_HOME_CITY] = unit_home_city;
+  action_function[ACTION_AIRLIFT] = airlift;
 
   /* Unit acting against a unit target. */
   action_function[ACTION_SPY_BRIBE_UNIT] = diplomat_bribe;
@@ -155,6 +158,7 @@
   /* Unit acting against a tile. */
   action_function[ACTION_FOUND_CITY] = found_city;
   action_function[ACTION_NUKE] = nuke;
+  action_function[ACTION_PARADROP] = paradrop;
   action_function[ACTION_ATTACK] = attack;
 
   /* Unit acting with no target except itself. */
@@ -1262,6 +1266,21 @@
 }
 
 /***
+  Action "Airlift Unit" for choice dialog
+***/
+static void airlift(QVariant data1, QVariant data2)
+{
+  int actor_id = data1.toInt();
+  int tgt_city_id = data2.toInt();
+
+  if (NULL != game_unit_by_number(actor_id)
+  && NULL != game_city_by_number(tgt_city_id)) {
+request_do_action(ACTION_AIRLIFT,
+  actor_id, tgt_city_id, 0, "");
+  }
+}
+
+/***
   Delay selection of what action to take.
 ***/
 static void act_sel_wait(QVariant data1, QVariant data2)
@@ -1758,6 +1777,21 @@
 }
 
 /**
+  Action "Paradrop Unit" for choice dialog
+**/
+static void paradrop(QVariant data1, QVariant data2)
+{
+  int actor_id = data1.toInt();
+  int target_id = data2.toInt();
+
+  if (NULL != game_unit_by_number(actor_id)
+  && NULL != index_to_tile(target_id)) {
+request_do_action(ACTION_PARADROP,
+  actor_id, target_id, 0, "");
+  }
+}
+
+/**
   Action join city for choice dialog
 **/
 static void join_city(QVariant data1, QVariant data2)


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33557 - /trunk/data/webperimental/game.ruleset

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:20:50 2016
New Revision: 33557

URL: http://svn.gna.org/viewcvs/freeciv?rev=33557&view=rev
Log:
webperimental: set default citymindist to 3.

See patch #7584

Modified:
trunk/data/webperimental/game.ruleset

Modified: trunk/data/webperimental/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/webperimental/game.ruleset?rev=33557&r1=33556&r2=33557&view=diff
==
--- trunk/data/webperimental/game.ruleset   (original)
+++ trunk/data/webperimental/game.ruleset   Thu Aug 11 02:20:50 2016
@@ -66,6 +66,7 @@
 in the source and in the destination city.\n\
 - Cities that know Flight can airlift one (light weight) unit per turn. An \
 Airport allows a city to airlift one more unit per turn.\n\
+- Default minimum distance between cities is 3.\n\
 \n\
 This ruleset is still in development. If playing it makes you think that \
 a rule should change go to the Freeciv-web board at \
@@ -1066,4 +1067,5 @@
 "maxplayers", 32, TRUE
 "startunits", "ccwwxk", FALSE
 "killstack", "disabled", FALSE
+"citymindist", 3, FALSE
   }


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33553 - /trunk/client/gui-qt/menu.cpp

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:20:19 2016
New Revision: 33553

URL: http://svn.gna.org/viewcvs/freeciv?rev=33553&view=rev
Log:
Qt client: ask for target for "Do..."

Change "Do..." to always ask the player for a target tile. A 2nd call (like
pressing "d" twice) will call the old "Do..." against own tile like it used
to do.

See patch #7579

Modified:
trunk/client/gui-qt/menu.cpp

Modified: trunk/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.cpp?rev=33553&r1=33552&r2=33553&view=diff
==
--- trunk/client/gui-qt/menu.cpp(original)
+++ trunk/client/gui-qt/menu.cppThu Aug 11 02:20:19 2016
@@ -2104,7 +2104,7 @@
 break;
 
   case ORDER_DIPLOMAT_DLG:
-if (can_units_act_against_own_tile(punits)) {
+if (units_can_do_action(punits, ACTION_ANY, TRUE)) {
   i.value()->setEnabled(true);
 }
 break;
@@ -2335,7 +2335,7 @@
 ***/
 void mr_menu::slot_action()
 {
-  key_unit_action_select();
+  key_unit_action_select_tgt();
 }
 
 /***


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33552 - in /trunk: client/control.c data/helpdata.txt

2016-08-10 Thread sveinung84
Author: sveinung
Date: Thu Aug 11 02:20:06 2016
New Revision: 33552

URL: http://svn.gna.org/viewcvs/freeciv?rev=33552&view=rev
Log:
2nd targeted "Do..." means target own tile.

Change key_unit_action_select_tgt() so it targets the actor's own tile the
2nd time it is called. Targeting its own tile is the traditional behavior.

This makes using key_unit_action_select_tgt() to handle the "d" key press
less confusing and annoying for old players.

A user with an existing habit of pressing "d" to act against a target on
the same tile as the actor is likely to press it again if the first key press
doesn't work. If he selected the menu item he will notice that the mouse
pointer turns into a selector.

Pressing "d" twice doesn't slow down acting against a target on the same
tile as the actor too much. No mouse required.

See patch #7578

Modified:
trunk/client/control.c
trunk/data/helpdata.txt

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=33552&r1=33551&r2=33552&view=diff
==
--- trunk/client/control.c  (original)
+++ trunk/client/control.c  Thu Aug 11 02:20:06 2016
@@ -3058,10 +3058,27 @@
 /**
   Have the user select what action the unit(s) in focus should perform to
   the targets at the tile the user will specify by clicking on it.
+
+  Will stop asking for a target tile and have each actor unit act against
+  its own tile if called twice.
 **/
 void key_unit_action_select_tgt(void)
 {
   struct unit_list *punits = get_units_in_focus();
+
+  if (hover_state == HOVER_ACT_SEL_TGT) {
+/* The 2nd key press means that the actor should target its own
+ * tile. */
+key_unit_action_select();
+
+/* Target tile selected. Clean up hover state. */
+set_hover_state(NULL, HOVER_NONE,
+ACTIVITY_LAST, NULL,
+EXTRA_NONE, ACTION_COUNT, ORDER_LAST);
+update_unit_info_label(punits);
+
+return;
+  }
 
   set_hover_state(punits, HOVER_ACT_SEL_TGT, ACTIVITY_LAST, NULL,
   EXTRA_NONE, ACTION_COUNT, ORDER_LAST);

Modified: trunk/data/helpdata.txt
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/helpdata.txt?rev=33552&r1=33551&r2=33552&view=diff
==
--- trunk/data/helpdata.txt (original)
+++ trunk/data/helpdata.txt Thu Aug 11 02:20:06 2016
@@ -1595,7 +1595,7 @@
   b: (b)uild city  (settler units)\n\
   b: help (b)uild wonder  (caravan units)\n\
   B: go to and (B)uild city on target tile  (settler units)\n\
-  d: (d)o an action to a target on this tile.\n\
+  d: (d)o an action to the selected tile (press twice to target own tile)\n\
   D: (D)isband unit\n\
   E: build airbas(e)  (airbase units)\n\
   f: (f)ortify unit  (military units)\n\


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33550 - /branches/S2_6/client/mapctrl_common.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 01:16:07 2016
New Revision: 33550

URL: http://svn.gna.org/viewcvs/freeciv?rev=33550&view=rev
Log:
Disable 'Turn Done' button from dead players.

See bug #24945

Modified:
branches/S2_6/client/mapctrl_common.c

Modified: branches/S2_6/client/mapctrl_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/mapctrl_common.c?rev=33550&r1=33549&r2=33550&view=diff
==
--- branches/S2_6/client/mapctrl_common.c   (original)
+++ branches/S2_6/client/mapctrl_common.c   Thu Aug 11 01:16:07 2016
@@ -519,6 +519,7 @@
 {
   return (can_client_issue_orders()
   && !client.conn.playing->ai_controlled
+  && client.conn.playing->is_alive
   && !client.conn.playing->phase_done
   && !is_server_busy()
   && is_player_phase(client.conn.playing, game.info.phase)


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33549 - /trunk/client/mapctrl_common.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 01:16:01 2016
New Revision: 33549

URL: http://svn.gna.org/viewcvs/freeciv?rev=33549&view=rev
Log:
Disable 'Turn Done' button from dead players.

See bug #24945

Modified:
trunk/client/mapctrl_common.c

Modified: trunk/client/mapctrl_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/mapctrl_common.c?rev=33549&r1=33548&r2=33549&view=diff
==
--- trunk/client/mapctrl_common.c   (original)
+++ trunk/client/mapctrl_common.c   Thu Aug 11 01:16:01 2016
@@ -521,6 +521,7 @@
 {
   return (can_client_issue_orders()
   && is_human(client.conn.playing)
+  && client.conn.playing->is_alive
   && !client.conn.playing->phase_done
   && !is_server_busy()
   && is_player_phase(client.conn.playing, game.info.phase)


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33551 - /branches/S2_5/client/mapctrl_common.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Thu Aug 11 01:16:14 2016
New Revision: 33551

URL: http://svn.gna.org/viewcvs/freeciv?rev=33551&view=rev
Log:
Disable 'Turn Done' button from dead players.

See bug #24945

Modified:
branches/S2_5/client/mapctrl_common.c

Modified: branches/S2_5/client/mapctrl_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/mapctrl_common.c?rev=33551&r1=33550&r2=33551&view=diff
==
--- branches/S2_5/client/mapctrl_common.c   (original)
+++ branches/S2_5/client/mapctrl_common.c   Thu Aug 11 01:16:14 2016
@@ -514,6 +514,7 @@
 {
   return (can_client_issue_orders()
   && !client.conn.playing->ai_controlled
+  && client.conn.playing->is_alive
   && !client.conn.playing->phase_done
   && !is_server_busy()
   && is_player_phase(client.conn.playing, game.info.phase)


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33548 - in /trunk: ai/default/daieffects.c common/city.c common/effects.h doc/README.effects

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 22:31:19 2016
New Revision: 33548

URL: http://svn.gna.org/viewcvs/freeciv?rev=33548&view=rev
Log:
Added effect type Output_Waste_By_Rel_Distance

In response to request by Jacob Nevins 

See patch #7566

Modified:
trunk/ai/default/daieffects.c
trunk/common/city.c
trunk/common/effects.h
trunk/doc/README.effects

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=33548&r1=33547&r2=33548&view=diff
==
--- trunk/ai/default/daieffects.c   (original)
+++ trunk/ai/default/daieffects.c   Wed Aug 10 22:31:19 2016
@@ -181,6 +181,7 @@
   case EFT_OUTPUT_PER_TILE:
   case EFT_OUTPUT_WASTE:
   case EFT_OUTPUT_WASTE_BY_DISTANCE:
+  case EFT_OUTPUT_WASTE_BY_REL_DISTANCE:
   case EFT_OUTPUT_WASTE_PCT:
   case EFT_SPECIALIST_OUTPUT:
   case EFT_ENEMY_CITIZEN_UNHAPPY_PCT:

Modified: trunk/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/city.c?rev=33548&r1=33547&r2=33548&view=diff
==
--- trunk/common/city.c (original)
+++ trunk/common/city.c Wed Aug 10 22:31:19 2016
@@ -3048,6 +3048,8 @@
   if (total_eft > 0) {
 int waste_by_dist = get_city_output_bonus(pcity, get_output_type(otype),
   EFT_OUTPUT_WASTE_BY_DISTANCE);
+int waste_by_rel_dist = get_city_output_bonus(pcity, 
get_output_type(otype),
+  
EFT_OUTPUT_WASTE_BY_REL_DISTANCE);
 if (waste_by_dist > 0) {
   const struct city *gov_center = NULL;
   int min_dist = FC_INFINITY;
@@ -3075,6 +3077,9 @@
 waste_all = TRUE; /* no gov center - no income */
   } else {
 waste_level += waste_by_dist * min_dist;
+if (waste_by_rel_dist > 0) {
+  waste_level += waste_by_rel_dist * min_dist / MAX(wld.map.xsize, 
wld.map.ysize);
+}
   }
 }
   }

Modified: trunk/common/effects.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.h?rev=33548&r1=33547&r2=33548&view=diff
==
--- trunk/common/effects.h  (original)
+++ trunk/common/effects.h  Wed Aug 10 22:31:19 2016
@@ -285,6 +285,8 @@
 #define SPECENUM_VALUE111NAME "Border_Vision"
 #define SPECENUM_VALUE112 EFT_STEALINGS_IGNORE
 #define SPECENUM_VALUE112NAME "Stealings_Ignore"
+#define SPECENUM_VALUE113 EFT_OUTPUT_WASTE_BY_REL_DISTANCE
+#define SPECENUM_VALUE113NAME "Output_Waste_By_Rel_Distance"
 /* keep this last */
 #define SPECENUM_COUNT EFT_COUNT
 #include "specenum_gen.h"

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=33548&r1=33547&r2=33548&view=diff
==
--- trunk/doc/README.effects(original)
+++ trunk/doc/README.effectsWed Aug 10 22:31:19 2016
@@ -452,6 +452,10 @@
 For each tile in real distance that a city is from nearest
 Government Center, it gets amount of extra waste.
 
+Output_Waste_By_Rel_Distance
+City gets extra waste based on distance to nearest Government Center, 
relative
+to world size. The amount of this extra waste is (distance * amount / 
max_distance)
+
 Output_Penalty_Tile
 When a tile yields more output than amount, it gets a penalty of -1.
 


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33547 - in /trunk: client/ data/

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 20:49:32 2016
New Revision: 33547

URL: http://svn.gna.org/viewcvs/freeciv?rev=33547&view=rev
Log:
Added support for field "for_ruleset" in .tilespec files. If it's set in 
currently loaded tileset,
client forked server will start with that ruleset. 

See patch #7577

Modified:
trunk/client/connectdlg_common.c
trunk/client/tilespec.c
trunk/client/tilespec.h
trunk/data/alio.tilespec
trunk/data/amplio.tilespec
trunk/data/amplio2.tilespec
trunk/data/cimpletoon.tilespec
trunk/data/hex2t.tilespec
trunk/data/hexemplio.tilespec
trunk/data/isophex.tilespec
trunk/data/isotrident.tilespec
trunk/data/toonhex.tilespec
trunk/data/trident.tilespec

Modified: trunk/client/connectdlg_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/connectdlg_common.c?rev=33547&r1=33546&r2=33547&view=diff
==
--- trunk/client/connectdlg_common.c(original)
+++ trunk/client/connectdlg_common.cWed Aug 10 20:49:32 2016
@@ -225,6 +225,7 @@
   char savesdir[MAX_LEN_PATH];
   char scensdir[MAX_LEN_PATH];
   char *storage;
+  char *ruleset;
 
 #if !defined(HAVE_USABLE_FORK)
   /* Above also implies that this is FREECIV_MSWINDOWS ->
@@ -232,8 +233,9 @@
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
 
-  char options[512];
+  char options[1024];
   char *depr;
+  char rsparam[256];
 #ifdef FREECIV_DEBUG
   char cmdline1[512];
 #ifndef FREECIV_WEB
@@ -284,10 +286,12 @@
 return FALSE;
   }
 
+  ruleset = tileset_what_ruleset(tileset);
+
 #ifdef HAVE_USABLE_FORK
   {
 int argc = 0;
-const int max_nargs = 23;
+const int max_nargs = 25;
 char *argv[max_nargs + 1];
 char port_buf[32];
 char dbg_lvl_buf[32]; /* Do not move this inside the block where it gets 
filled,
@@ -336,6 +340,10 @@
 if (are_deprecation_warnings_enabled()) {
   argv[argc++] = "--warnings";
 }
+if (ruleset != NULL) {
+  argv[argc++] = "--ruleset";
+  argv[argc++] = ruleset;
+}
 argv[argc] = NULL;
 fc_assert(argc <= max_nargs);
 
@@ -469,12 +477,17 @@
   } else {
 depr = "";
   }
+  if (ruleset != NULL) {
+fc_snprintf(rsparam, sizeof(rsparam), " --ruleset %s", ruleset);
+  } else {
+rsparam[0] = '\0';
+  }
 
   fc_snprintf(options, sizeof(options),
   "-p %d --bind localhost -q 1 -e%s%s%s --saves \"%s\" "
-  "--scenarios \"%s\" -A none %s",
+  "--scenarios \"%s\" -A none %s%s",
   internal_server_port, logcmdline, scriptcmdline, savefilecmdline,
-  savescmdline, scenscmdline, depr);
+  savescmdline, scenscmdline, rsparam, depr);
 #ifdef FREECIV_DEBUG
 #ifdef FREECIV_WEB
   fc_snprintf(cmdline1, sizeof(cmdline1),

Modified: trunk/client/tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.c?rev=33547&r1=33546&r2=33547&view=diff
==
--- trunk/client/tilespec.c (original)
+++ trunk/client/tilespec.c Wed Aug 10 20:49:32 2016
@@ -462,6 +462,8 @@
   char *summary;
   char *description;
 
+  char *for_ruleset;
+
   enum ts_type type;
   int hex_width, hex_height;
   int ts_topo_idx;
@@ -1167,6 +1169,10 @@
   if (t->description != NULL) {
 free(t->description);
 t->description = NULL;
+  }
+  if (t->for_ruleset != NULL) {
+free(t->for_ruleset);
+t->for_ruleset = NULL;
   }
 }
 
@@ -1771,6 +1777,13 @@
   free(t->description);
   t->description = NULL;
 }
+  }
+
+  tstr = secfile_lookup_str_default(file, NULL, "tilespec.for_ruleset");
+  if (tstr != NULL) {
+t->for_ruleset = fc_strdup(tstr);
+  } else {
+t->for_ruleset = NULL;
   }
 
   sz_strlcpy(t->name, tileset_name);
@@ -6757,6 +6770,14 @@
 }
 
 /
+  Return what ruleset this tileset is primarily meant for
+/
+char *tileset_what_ruleset(struct tileset *t)
+{
+  return t->for_ruleset;
+}
+
+/
   Return tileset topology index
 /
 int tileset_topo_index(struct tileset *t)

Modified: trunk/client/tilespec.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.h?rev=33547&r1=33546&r2=33547&view=diff
==
--- trunk/client/tilespec.h (original)
+++ trunk/client/tilespec.h Wed Aug 10 20:49:32 2016
@@ -408,6 +408,7 @@
 const char *tileset_version(struct tileset *t);
 const char *tileset_summary(struct tileset *t);
 const char *tileset_description(struct tileset *t);
+char *tileset_what_ruleset(struct tileset *t);
 int tileset_topo_index(struct tileset *t);
 
 #ifdef __cplusplus

Modified: trunk/data/alio.

[Freeciv-commits] r33545 - in /branches/S2_6/client: control.c control.h goto.c gui-xaw/mapview.c mapctrl_common.c mapview_common.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Wed Aug 10 16:48:37 2016
New Revision: 33545

URL: http://svn.gna.org/viewcvs/freeciv?rev=33545&view=rev
Log:
Support user specified target tile for "Do...".

Common client code support for letting the user specify the tile "Do..."
should target. No client uses it yet. The user specifies the target tile by
selecting it on the map.

See patch #7572

Modified:
branches/S2_6/client/control.c
branches/S2_6/client/control.h
branches/S2_6/client/goto.c
branches/S2_6/client/gui-xaw/mapview.c
branches/S2_6/client/mapctrl_common.c
branches/S2_6/client/mapview_common.c

Modified: branches/S2_6/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.c?rev=33545&r1=33544&r2=33545&view=diff
==
--- branches/S2_6/client/control.c  (original)
+++ branches/S2_6/client/control.c  Wed Aug 10 16:48:37 2016
@@ -1187,6 +1187,10 @@
   case HOVER_PARADROP:
 /* FIXME: check for invalid tiles. */
 mouse_cursor_type = CURSOR_PARADROP;
+break;
+  case HOVER_ACT_SEL_TGT:
+/* Select a tile to target / find targets on. */
+mouse_cursor_type = CURSOR_SELECT;
 break;
   };
 
@@ -2453,6 +2457,22 @@
 }
 
 /**
+  An action selection dialog for the selected units against the specified
+  tile is wanted.
+**/
+static void do_unit_act_sel_vs(struct tile *ptile)
+{
+  unit_list_iterate(get_units_in_focus(), punit) {
+if (utype_may_act_at_all(unit_type_get(punit))) {
+  /* Have the server record that an action decision is wanted for
+   * this unit against this tile. */
+  request_do_action(ACTION_COUNT, punit->id, tile_index(ptile),
+ACTSIG_QUEUE);
+}
+  } unit_list_iterate_end;
+}
+
+/**
  Handles everything when the user clicked a tile
 **/
 void do_map_click(struct tile *ptile, enum quickselect_type qtype)
@@ -2482,6 +2502,9 @@
 case HOVER_PATROL:
   do_unit_patrol_to(ptile);
   break;   
+case HOVER_ACT_SEL_TGT:
+  do_unit_act_sel_vs(ptile);
+  break;
 }
 
 set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, NULL, ORDER_LAST);
@@ -2809,6 +2832,7 @@
 }
 /* else fall through: */
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
 set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, NULL, ORDER_LAST);
 update_unit_info_label(get_units_in_focus());
 
@@ -2931,6 +2955,18 @@
 ACTSIG_QUEUE);
 }
   } unit_list_iterate_end;
+}
+
+/**
+  Have the user select what action the unit(s) in focus should perform to
+  the targets at the tile the user will specify by clicking on it.
+**/
+void key_unit_action_select_tgt(void)
+{
+  struct unit_list *punits = get_units_in_focus();
+
+  set_hover_state(punits, HOVER_ACT_SEL_TGT, ACTIVITY_LAST, NULL,
+  ORDER_LAST);
 }
 
 /**

Modified: branches/S2_6/client/control.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.h?rev=33545&r1=33544&r2=33545&view=diff
==
--- branches/S2_6/client/control.h  (original)
+++ branches/S2_6/client/control.h  Wed Aug 10 16:48:37 2016
@@ -28,7 +28,8 @@
   HOVER_NUKE,
   HOVER_PARADROP,
   HOVER_CONNECT,
-  HOVER_PATROL
+  HOVER_PATROL,
+  HOVER_ACT_SEL_TGT
 };
 
 /* Selecting unit from a stack without popup. */
@@ -228,6 +229,7 @@
 void key_unit_connect(enum unit_activity activity,
   struct extra_type *tgt);
 void key_unit_action_select(void);
+void key_unit_action_select_tgt(void);
 void key_unit_convert(void);
 void key_unit_done(void);
 void key_unit_fallout(void);

Modified: branches/S2_6/client/goto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/goto.c?rev=33545&r1=33544&r2=33545&view=diff
==
--- branches/S2_6/client/goto.c (original)
+++ branches/S2_6/client/goto.c Wed Aug 10 16:48:37 2016
@@ -966,9 +966,12 @@
 break;
   case HOVER_NONE:
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
 fc_assert_msg(hover_state != HOVER_NONE, "Goto with HOVER_NONE?");
 fc_assert_msg(hover_state != HOVER_PARADROP,
   "Goto with HOVER_PARADROP?");
+fc_assert_msg(hover_state != HOVER_ACT_SEL_TGT,
+  "Goto with HOVER_ACT_SEL_TGT?");
 break;
   };
 }

Modified: branches/S2_6/client/gui-xaw/mapview.c
URL: 
http://svn.gna.org/vie

[Freeciv-commits] r33546 - in /branches/S2_6/client: gui-sdl/menu.c gui-sdl2/menu.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Wed Aug 10 16:48:47 2016
New Revision: 33546

URL: http://svn.gna.org/viewcvs/freeciv?rev=33546&view=rev
Log:
SDL clients: ask for target for "Do...".

Change "Do..." to always ask the player for a target tile. This is done
to give the SDL client the ability to specify a target tile for the action
selection dialog without having to add a new button to the limited space it
has.

See patch #7575

Modified:
branches/S2_6/client/gui-sdl/menu.c
branches/S2_6/client/gui-sdl2/menu.c

Modified: branches/S2_6/client/gui-sdl/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/menu.c?rev=33546&r1=33545&r2=33546&view=diff
==
--- branches/S2_6/client/gui-sdl/menu.c (original)
+++ branches/S2_6/client/gui-sdl/menu.c Wed Aug 10 16:48:47 2016
@@ -234,7 +234,7 @@
   popup_unit_disband_dlg(pUnit, FALSE);
   break;
 case ID_UNIT_ORDER_DIPLOMAT_DLG:
-  key_unit_action_select();
+  key_unit_action_select_tgt();
   break;
 case ID_UNIT_ORDER_NUKE:
   key_unit_nuke();
@@ -442,7 +442,7 @@
   add_to_gui_list(ID_UNIT_ORDER_NUKE, pBuf);
   /* - */
 
-  /* Act against own tile. */
+  /* Act against the specified tile. */
   /* TRANS: Button to bring up the action selection dialog. */
   fc_snprintf(cBuf, sizeof(cBuf),"%s (%s)", _("Do..."), "D");
   pBuf = create_themeicon(current_theme->OSpy_Icon, Main.gui,
@@ -1416,7 +1416,7 @@
 }
   }
 
-  if (can_unit_act_against_own_tile(pUnit)) {
+  if (unit_can_do_action(pUnit, ACTION_ANY)) {
local_show(ID_UNIT_ORDER_DIPLOMAT_DLG);
   } else {
local_hide(ID_UNIT_ORDER_DIPLOMAT_DLG);

Modified: branches/S2_6/client/gui-sdl2/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/menu.c?rev=33546&r1=33545&r2=33546&view=diff
==
--- branches/S2_6/client/gui-sdl2/menu.c(original)
+++ branches/S2_6/client/gui-sdl2/menu.cWed Aug 10 16:48:47 2016
@@ -240,7 +240,7 @@
   popup_unit_disband_dlg(pUnit, FALSE);
   break;
 case ID_UNIT_ORDER_DIPLOMAT_DLG:
-  key_unit_action_select();
+  key_unit_action_select_tgt();
   break;
 case ID_UNIT_ORDER_NUKE:
   key_unit_nuke();
@@ -438,7 +438,7 @@
   add_to_gui_list(ID_UNIT_ORDER_NUKE, pBuf);
   /* - */
 
-  /* Act against own tile. */
+  /* Act against the specified tile. */
   /* TRANS: Button to bring up the action selection dialog. */
   fc_snprintf(cBuf, sizeof(cBuf),"%s (%s)", _("Do..."), "D");
   pBuf = create_themeicon(current_theme->OSpy_Icon, Main.gui,
@@ -1394,7 +1394,7 @@
 }
   }
 
- if (can_unit_act_against_own_tile(pUnit)) {
+ if (unit_can_do_action(pUnit, ACTION_ANY)) {
local_show(ID_UNIT_ORDER_DIPLOMAT_DLG);
   } else {
local_hide(ID_UNIT_ORDER_DIPLOMAT_DLG);


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33544 - /trunk/client/gui-sdl2/action_dialog.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Wed Aug 10 16:45:25 2016
New Revision: 33544

URL: http://svn.gna.org/viewcvs/freeciv?rev=33544&view=rev
Log:
SDL client: act sel dlg paradrop and airlift.

Support the actions "Paradrop Unit" and "Airlift Unit" in the action
selection dialog.

This makes the clients more friendly to rules like "airlifting becomes
impossible once any player discovers Air Solidifiers".

See patch #7576

Modified:
trunk/client/gui-sdl2/action_dialog.c

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=33544&r1=33543&r2=33544&view=diff
==
--- trunk/client/gui-sdl2/action_dialog.c   (original)
+++ trunk/client/gui-sdl2/action_dialog.c   Wed Aug 10 16:45:25 2016
@@ -958,6 +958,23 @@
 }
 
 /
+  User clicked "Paradrop Unit"
+*/
+static int paradrop_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+int actor_id = MAX_ID - pWidget->ID;
+int target_id = pWidget->data.tile->index;
+
+popdown_diplomat_dialog();
+request_do_action(ACTION_PARADROP,
+  actor_id, target_id, 0, "");
+  }
+
+  return -1;
+}
+
+/
   User clicked "Disband Unit"
 */
 static int disband_unit_callback(struct widget *pWidget)
@@ -984,6 +1001,27 @@
   pDiplomat_Dlg->target_ids[ATK_CITY])
 && NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)) {
   request_do_action(ACTION_HOME_CITY,
+pDiplomat_Dlg->actor_unit_id,
+pDiplomat_Dlg->target_ids[ATK_CITY],
+0, "");
+}
+
+popdown_diplomat_dialog();
+  }
+
+  return -1;
+}
+
+/
+  User clicked "Airlift Unit"
+*/
+static int airlift_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+if (NULL != game_city_by_number(
+  pDiplomat_Dlg->target_ids[ATK_CITY])
+&& NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)) {
+  request_do_action(ACTION_AIRLIFT,
 pDiplomat_Dlg->actor_unit_id,
 pDiplomat_Dlg->target_ids[ATK_CITY],
 0, "");
@@ -1048,6 +1086,7 @@
   [ACTION_DESTROY_CITY] = destroy_city_callback,
   [ACTION_RECYCLE_UNIT] = unit_recycle_callback,
   [ACTION_HOME_CITY] = home_city_callback,
+  [ACTION_AIRLIFT] = airlift_callback,
 
   /* Unit acting against a unit target. */
   [ACTION_SPY_BRIBE_UNIT] = diplomat_bribe_callback,
@@ -1061,6 +1100,7 @@
   /* Unit acting against a tile. */
   [ACTION_FOUND_CITY] = found_city_callback,
   [ACTION_NUKE] = nuke_callback,
+  [ACTION_PARADROP] = paradrop_callback,
   [ACTION_ATTACK] = attack_callback,
 
   /* Unit acting with no target except itself. */


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33543 - /trunk/client/gui-sdl2/menu.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Wed Aug 10 16:45:17 2016
New Revision: 33543

URL: http://svn.gna.org/viewcvs/freeciv?rev=33543&view=rev
Log:
SDL client: ask for target for "Do...".

Change "Do..." to always ask the player for a target tile. This is done
to give the SDL client the ability to specify a target tile for the action
selection dialog without having to add a new button to the limited space it
has.

See patch #7575

Modified:
trunk/client/gui-sdl2/menu.c

Modified: trunk/client/gui-sdl2/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/menu.c?rev=33543&r1=33542&r2=33543&view=diff
==
--- trunk/client/gui-sdl2/menu.c(original)
+++ trunk/client/gui-sdl2/menu.cWed Aug 10 16:45:17 2016
@@ -240,7 +240,7 @@
   popup_unit_disband_dlg(pUnit, FALSE);
   break;
 case ID_UNIT_ORDER_DIPLOMAT_DLG:
-  key_unit_action_select();
+  key_unit_action_select_tgt();
   break;
 case ID_UNIT_ORDER_NUKE:
   key_unit_nuke();
@@ -439,7 +439,7 @@
   add_to_gui_list(ID_UNIT_ORDER_NUKE, pBuf);
   /* - */
 
-  /* Act against own tile. */
+  /* Act against the specified tile. */
   /* TRANS: Button to bring up the action selection dialog. */
   fc_snprintf(cBuf, sizeof(cBuf),"%s (%s)", _("Do..."), "D");
   pBuf = create_themeicon(current_theme->OSpy_Icon, Main.gui,
@@ -1400,7 +1400,7 @@
 }
   }
 
- if (can_unit_act_against_own_tile(pUnit)) {
+ if (unit_can_do_action(pUnit, ACTION_ANY)) {
local_show(ID_UNIT_ORDER_DIPLOMAT_DLG);
   } else {
local_hide(ID_UNIT_ORDER_DIPLOMAT_DLG);


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33542 - in /trunk/client: control.c control.h goto.c mapctrl_common.c mapview_common.c

2016-08-10 Thread sveinung84
Author: sveinung
Date: Wed Aug 10 16:45:04 2016
New Revision: 33542

URL: http://svn.gna.org/viewcvs/freeciv?rev=33542&view=rev
Log:
Support user specified target tile for "Do...".

Common client code support for letting the user specify the tile "Do..."
should target. No client uses it yet. The user specifies the target tile by
selecting it on the map.

See patch #7572

Modified:
trunk/client/control.c
trunk/client/control.h
trunk/client/goto.c
trunk/client/mapctrl_common.c
trunk/client/mapview_common.c

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=33542&r1=33541&r2=33542&view=diff
==
--- trunk/client/control.c  (original)
+++ trunk/client/control.c  Wed Aug 10 16:45:04 2016
@@ -1260,6 +1260,10 @@
   case HOVER_PARADROP:
 /* FIXME: check for invalid tiles. */
 mouse_cursor_type = CURSOR_PARADROP;
+break;
+  case HOVER_ACT_SEL_TGT:
+/* Select a tile to target / find targets on. */
+mouse_cursor_type = CURSOR_SELECT;
 break;
   };
 
@@ -2622,6 +2626,22 @@
 }
 
 /**
+  An action selection dialog for the selected units against the specified
+  tile is wanted.
+**/
+static void do_unit_act_sel_vs(struct tile *ptile)
+{
+  unit_list_iterate(get_units_in_focus(), punit) {
+if (utype_may_act_at_all(unit_type_get(punit))) {
+  /* Have the server record that an action decision is wanted for
+   * this unit against this tile. */
+  dsend_packet_unit_sscs_set(&client.conn, punit->id,
+ USSDT_QUEUE, tile_index(ptile));
+}
+  } unit_list_iterate_end;
+}
+
+/**
  Handles everything when the user clicked a tile
 **/
 void do_map_click(struct tile *ptile, enum quickselect_type qtype)
@@ -2648,6 +2668,9 @@
 case HOVER_PATROL:
   do_unit_patrol_to(ptile);
   break;   
+case HOVER_ACT_SEL_TGT:
+  do_unit_act_sel_vs(ptile);
+  break;
 }
 
 set_hover_state(NULL, HOVER_NONE,
@@ -2905,6 +2928,7 @@
 }
 /* else fall through: */
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
 set_hover_state(NULL, HOVER_NONE,
 ACTIVITY_LAST, NULL,
 EXTRA_NONE, ACTION_COUNT, ORDER_LAST);
@@ -3029,6 +3053,18 @@
  USSDT_QUEUE, tile_index(ptile));
 }
   } unit_list_iterate_end;
+}
+
+/**
+  Have the user select what action the unit(s) in focus should perform to
+  the targets at the tile the user will specify by clicking on it.
+**/
+void key_unit_action_select_tgt(void)
+{
+  struct unit_list *punits = get_units_in_focus();
+
+  set_hover_state(punits, HOVER_ACT_SEL_TGT, ACTIVITY_LAST, NULL,
+  EXTRA_NONE, ACTION_COUNT, ORDER_LAST);
 }
 
 /**

Modified: trunk/client/control.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.h?rev=33542&r1=33541&r2=33542&view=diff
==
--- trunk/client/control.h  (original)
+++ trunk/client/control.h  Wed Aug 10 16:45:04 2016
@@ -27,7 +27,8 @@
   HOVER_GOTO,
   HOVER_PARADROP,
   HOVER_CONNECT,
-  HOVER_PATROL
+  HOVER_PATROL,
+  HOVER_ACT_SEL_TGT
 };
 
 /* Selecting unit from a stack without popup. */
@@ -229,6 +230,7 @@
 void key_unit_connect(enum unit_activity activity,
   struct extra_type *tgt);
 void key_unit_action_select(void);
+void key_unit_action_select_tgt(void);
 void key_unit_convert(void);
 void key_unit_done(void);
 void key_unit_fallout(void);

Modified: trunk/client/goto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/goto.c?rev=33542&r1=33541&r2=33542&view=diff
==
--- trunk/client/goto.c (original)
+++ trunk/client/goto.c Wed Aug 10 16:45:04 2016
@@ -967,9 +967,12 @@
 break;
   case HOVER_NONE:
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
 fc_assert_msg(hover_state != HOVER_NONE, "Goto with HOVER_NONE?");
 fc_assert_msg(hover_state != HOVER_PARADROP,
   "Goto with HOVER_PARADROP?");
+fc_assert_msg(hover_state != HOVER_ACT_SEL_TGT,
+  "Goto with HOVER_ACT_SEL_TGT?");
 break;
   };
 }

Modified: trunk/client/mapctrl_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/mapctrl_common.c?rev=33542&r1=33541&r2=33542&view=diff

[Freeciv-commits] r33540 - /trunk/ai/default/daidomestic.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 15:47:35 2016
New Revision: 33540

URL: http://svn.gna.org/viewcvs/freeciv?rev=33540&view=rev
Log:
If city already has caravans it has been unable to use for any reason,
reduce want for building more.

See patch #7570

Modified:
trunk/ai/default/daidomestic.c

Modified: trunk/ai/default/daidomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daidomestic.c?rev=33540&r1=33539&r2=33540&view=diff
==
--- trunk/ai/default/daidomestic.c  (original)
+++ trunk/ai/default/daidomestic.c  Wed Aug 10 15:47:35 2016
@@ -134,7 +134,7 @@
 "Non existence of wonder helper unit not caught");
 
   /* Check if wonder needs a little help. */
-  if (build_points_left(wonder_city) 
+  if (build_points_left(wonder_city)
   > utype_build_shield_cost(unit_type) * caravans) {
 struct impr_type *wonder = wonder_city->production.value.building;
 adv_want want = 
wonder_city->server.adv->building_want[improvement_index(wonder)];
@@ -181,6 +181,8 @@
   adv_want want;
   int income, bonus;
   int trade_routes;
+  int caravan_units;
+  int unassigned_caravans;
   int max_routes;
   Continent_id continent = tile_continent(pcity->tile);
   bool dest_city_found = FALSE;
@@ -283,8 +285,7 @@
   unit_type = best_role_unit(pcity, action_get_role(ACTION_TRADE_ROUTE));
 
   if (!unit_type) {
-/* Can't establish trade route yet. What about entering a market
- * place? */
+/* Can't establish trade route yet. What about entering a marketplace? */
 /* TODO: Should a future unit capable of establishing trade routes be
  * prioritized above a present unit capable of entering a market place?
  * In that case this should be below the check for a future unit
@@ -300,7 +301,7 @@
 
   if (!unit_type) {
 /* We'll never be able to establish a trade route. Consider a unit that
- * can enter the market place in stead to stimulate science. */
+ * can enter the marketplace in stead to stimulate science. */
 unit_type = get_role_unit(action_get_role(ACTION_MARKETPLACE), 0);
   }
 
@@ -309,13 +310,16 @@
 
   trade_routes = city_num_trade_routes(pcity);
   /* Count also caravans enroute to establish traderoutes */
+  caravan_units = 0;
   unit_list_iterate(pcity->units_supported, punit) {
 if (unit_can_do_action(punit, ACTION_TRADE_ROUTE)) {
-  trade_routes++;
+  caravan_units++;
 }
   } unit_list_iterate_end;
 
   max_routes = max_trade_routes(pcity);
+  unassigned_caravans = caravan_units - (max_routes - trade_routes);
+  trade_routes += caravan_units;
 
   /* We consider only initial benefit from establishing trade route.
* We may actually get only initial benefit if both cities already
@@ -391,7 +395,7 @@
   if (pplayer->economic.science < 50 && trade_routes < max_routes
   && utype_can_do_action(unit_type, ACTION_TRADE_ROUTE)) {
 want *=
-  (6 - pplayer->economic.science/10) * (6 - pplayer->economic.science/10);
+  (6 - pplayer->economic.science / 10) * (6 - pplayer->economic.science / 
10);
   }
 
   if (trade_routes == 0 && max_routes > 0
@@ -405,6 +409,13 @@
   }
 
   want -= utype_build_shield_cost(unit_type) * SHIELD_WEIGHTING / 150;
+
+  /* Don't pile too many of them */
+  if (unassigned_caravans * 10 > want && want > 0.0) {
+want = 0.1;
+  } else {
+want -= unassigned_caravans * 10; /* Don't pile too many of them */
+  }
 
   CITY_LOG(LOG_DEBUG, pcity,
"want for trade route unit is " ADV_WANT_PRINTF " (expected initial 
income %d)",


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33541 - /branches/S2_6/ai/default/daidomestic.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 15:47:41 2016
New Revision: 33541

URL: http://svn.gna.org/viewcvs/freeciv?rev=33541&view=rev
Log:
If city already has caravans it has been unable to use for any reason,
reduce want for building more.

See patch #7570

Modified:
branches/S2_6/ai/default/daidomestic.c

Modified: branches/S2_6/ai/default/daidomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/daidomestic.c?rev=33541&r1=33540&r2=33541&view=diff
==
--- branches/S2_6/ai/default/daidomestic.c  (original)
+++ branches/S2_6/ai/default/daidomestic.c  Wed Aug 10 15:47:41 2016
@@ -130,7 +130,7 @@
 "Non existence of wonder helper unit not caught");
 
   /* Check if wonder needs a little help. */
-  if (build_points_left(wonder_city) 
+  if (build_points_left(wonder_city)
   > utype_build_shield_cost(unit_type) * caravans) {
 struct impr_type *wonder = wonder_city->production.value.building;
 int want = 
wonder_city->server.adv->building_want[improvement_index(wonder)];
@@ -177,6 +177,8 @@
   int want;
   int income, bonus;
   int trade_routes;
+  int caravan_units;
+  int unassigned_caravans;
   int max_routes;
   Continent_id continent = tile_continent(pcity->tile);
   bool dest_city_found = FALSE;
@@ -278,8 +280,7 @@
   unit_type = best_role_unit(pcity, action_get_role(ACTION_TRADE_ROUTE));
 
   if (!unit_type) {
-/* Can't establish trade route yet. What about entering a market
- * place? */
+/* Can't establish trade route yet. What about entering a marketplace? */
 /* TODO: Should a future unit capable of establishing trade routes be
  * prioritized above a present unit capable of entering a market place?
  * In that case this should be below the check for a future unit
@@ -295,7 +296,7 @@
 
   if (!unit_type) {
 /* We'll never be able to establish a trade route. Consider a unit that
- * can enter the market place in stead to stimulate science. */
+ * can enter the marketplace in stead to stimulate science. */
 unit_type = get_role_unit(action_get_role(ACTION_MARKETPLACE), 0);
   }
 
@@ -304,13 +305,16 @@
 
   trade_routes = city_num_trade_routes(pcity);
   /* Count also caravans enroute to establish traderoutes */
+  caravan_units = 0;
   unit_list_iterate(pcity->units_supported, punit) {
 if (unit_can_do_action(punit, ACTION_TRADE_ROUTE)) {
-  trade_routes++;
+  caravan_units++;
 }
   } unit_list_iterate_end;
 
   max_routes = max_trade_routes(pcity);
+  unassigned_caravans = caravan_units - (max_routes - trade_routes);
+  trade_routes += caravan_units;
 
   /* We consider only initial benefit from establishing trade route.
* We may actually get only initial benefit if both cities already
@@ -376,7 +380,7 @@
   if (pplayer->economic.science < 50 && trade_routes < max_routes
   && utype_can_do_action(unit_type, ACTION_TRADE_ROUTE)) {
 want *=
-  (6 - pplayer->economic.science/10) * (6 - pplayer->economic.science/10);
+  (6 - pplayer->economic.science / 10) * (6 - pplayer->economic.science / 
10);
   }
 
   if (trade_routes == 0 && max_routes > 0
@@ -390,6 +394,13 @@
   }
 
   want -= utype_build_shield_cost(unit_type) * SHIELD_WEIGHTING / 150;
+
+  /* Don't pile too many of them */
+  if (unassigned_caravans * 10 > want && want > 0) {
+want = 1;
+  } else {
+want -= unassigned_caravans * 10; /* Don't pile too many of them */
+  }
 
   CITY_LOG(LOG_DEBUG, pcity,
"want for trade route unit is %d (expected initial income %d)",


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33539 - in /trunk/common: requirements.c requirements.h

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 12:32:33 2016
New Revision: 33539

URL: http://svn.gna.org/viewcvs/freeciv?rev=33539&view=rev
Log:
Factored out universal_value_from_str() from universal_by_rule_name().

See patch #7571

Modified:
trunk/common/requirements.c
trunk/common/requirements.h

Modified: trunk/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.c?rev=33539&r1=33538&r2=33539&view=diff
==
--- trunk/common/requirements.c (original)
+++ trunk/common/requirements.c Wed Aug 10 12:32:33 2016
@@ -56,7 +56,7 @@
   FIXME: ensure that every caller checks error return!
 **/
 struct universal universal_by_rule_name(const char *kind,
-   const char *value)
+const char *value)
 {
   struct universal source;
 
@@ -65,248 +65,259 @@
 return source;
   }
 
+  universal_value_from_str(&source, value);
+
+  return source;
+}
+
+/**
+  Parse requirement value strings into a universal
+  structure.
+**/
+void universal_value_from_str(struct universal *source, const char *value)
+{
   /* Finally scan the value string based on the type of the source. */
-  switch (source.kind) {
+  switch (source->kind) {
   case VUT_NONE:
-return source;
+return;
   case VUT_ADVANCE:
-source.value.advance = advance_by_rule_name(value);
-if (source.value.advance != NULL) {
-  return source;
+source->value.advance = advance_by_rule_name(value);
+if (source->value.advance != NULL) {
+  return;
 }
 break;
   case VUT_TECHFLAG:
-source.value.techflag
+source->value.techflag
   = tech_flag_id_by_name(value, fc_strcasecmp);
-if (tech_flag_id_is_valid(source.value.techflag)) {
-  return source;
+if (tech_flag_id_is_valid(source->value.techflag)) {
+  return;
 }
 break;
   case VUT_GOVERNMENT:
-source.value.govern = government_by_rule_name(value);
-if (source.value.govern != NULL) {
-  return source;
+source->value.govern = government_by_rule_name(value);
+if (source->value.govern != NULL) {
+  return;
 }
 break;
   case VUT_ACHIEVEMENT:
-source.value.achievement = achievement_by_rule_name(value);
-if (source.value.achievement != NULL) {
-  return source;
+source->value.achievement = achievement_by_rule_name(value);
+if (source->value.achievement != NULL) {
+  return;
 }
 break;
   case VUT_STYLE:
-source.value.style = style_by_rule_name(value);
-if (source.value.style != NULL) {
-  return source;
+source->value.style = style_by_rule_name(value);
+if (source->value.style != NULL) {
+  return;
 }
 break;
   case VUT_IMPROVEMENT:
-source.value.building = improvement_by_rule_name(value);
-if (source.value.building != NULL) {
-  return source;
+source->value.building = improvement_by_rule_name(value);
+if (source->value.building != NULL) {
+  return;
 }
 break;
   case VUT_IMPR_GENUS:
-source.value.impr_genus = impr_genus_id_by_name(value, fc_strcasecmp);
-if (impr_genus_id_is_valid(source.value.impr_genus)) {
-  return source;
+source->value.impr_genus = impr_genus_id_by_name(value, fc_strcasecmp);
+if (impr_genus_id_is_valid(source->value.impr_genus)) {
+  return;
 }
 break;
   case VUT_EXTRA:
-source.value.extra = extra_type_by_rule_name(value);
-if (source.value.extra != NULL) {
-  return source;
+source->value.extra = extra_type_by_rule_name(value);
+if (source->value.extra != NULL) {
+  return;
 }
 break;
   case VUT_GOOD:
-source.value.good = goods_by_rule_name(value);
-if (source.value.good != NULL) {
-  return source;
+source->value.good = goods_by_rule_name(value);
+if (source->value.good != NULL) {
+  return;
 }
 break;
   case VUT_TERRAIN:
-source.value.terrain = terrain_by_rule_name(value);
-if (source.value.terrain != T_UNKNOWN) {
-  return source;
+source->value.terrain = terrain_by_rule_name(value);
+if (source->value.terrain != T_UNKNOWN) {
+  return;
 }
 break;
   case VUT_TERRFLAG:
-source.value.terrainflag
+source->value.terrainflag
   = terrain_flag_id_by_name(value, fc_strcasecmp);
-if (terrain_flag_id_is_valid(source.value.terrainflag)) {
-  return source;
+if (terrain_flag_id_is_valid(source->value.terrainflag)) {
+  return;
 }
 break;
   case VUT_NATION:
-source.value.nation = nation_by_rule_name(value);
-if (source.value.nation != NO_NATION_SELECTED) {
-  return source;
+source->value.nation = nation_by_rule_name(value);
+if (source->va

[Freeciv-commits] r33536 - /trunk/server/unittools.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 11:09:55 2016
New Revision: 33536

URL: http://svn.gna.org/viewcvs/freeciv?rev=33536&view=rev
Log:
Remove drowning units from the clients even if they didn't see those units when 
they still had not
jumped out of the sinking transport.

Reported by Christian Knoke 

See bug #24921

Modified:
trunk/server/unittools.c

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=33536&r1=33535&r2=33536&view=diff
==
--- trunk/server/unittools.c(original)
+++ trunk/server/unittools.cWed Aug 10 11:09:55 2016
@@ -1751,7 +1751,15 @@
 _("%s lost when %s was lost."),
 unit_tile_link(pcargo),
 utype_name_translation(ptransport));
-  wipe_unit_full(pcargo, TRUE, ULR_TRANSPORT_LOST, killer);
+  /* Unit is not transported any more at this point, but it has jumped
+   * off the transport and drowns outside. So it must be removed from
+   * all clients.
+   * However, we don't know if given client has received ANY updates
+   * about the swimming unit, and we can't remove it if it's not there
+   * in the first place -> we send it once here just to be sure it's
+   * there. */
+  send_unit_info(NULL, pcargo);
+  wipe_unit_full(pcargo, FALSE, ULR_TRANSPORT_LOST, killer);
 }
 
 /
@@ -1798,7 +1806,11 @@
   }
 
   /* Could use unit_transport_unload_send here, but that would
-   * call send_unit_info for the transporter unnecessarily. */
+   * call send_unit_info for the transporter unnecessarily.
+   * Note that this means that unit might to get seen briefly
+   * by clients other than owner's, for example as a result of
+   * update of homecity common to this cargo and some other
+   * destroyed unit. */
   unit_transport_unload(pcargo);
   if (pcargo->activity == ACTIVITY_SENTRY) {
 /* Activate sentried units - like planes on a disbanded carrier.


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33538 - /branches/S2_5/server/unittools.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 11:10:08 2016
New Revision: 33538

URL: http://svn.gna.org/viewcvs/freeciv?rev=33538&view=rev
Log:
Remove drowning units from the clients even if they didn't see those units when 
they still had not
jumped out of the sinking transport.

Reported by Christian Knoke 

See bug #24921

Modified:
branches/S2_5/server/unittools.c

Modified: branches/S2_5/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/unittools.c?rev=33538&r1=33537&r2=33538&view=diff
==
--- branches/S2_5/server/unittools.c(original)
+++ branches/S2_5/server/unittools.cWed Aug 10 11:10:08 2016
@@ -1744,7 +1744,15 @@
 _("%s lost when %s was lost."),
 unit_tile_link(pcargo),
 utype_name_translation(ptransport));
-  wipe_unit_full(pcargo, TRUE, ULR_TRANSPORT_LOST, killer);
+  /* Unit is not transported any more at this point, but it has jumped
+   * off the transport and drowns outside. So it must be removed from
+   * all clients.
+   * However, we don't know if given client has received ANY updates
+   * about the swimming unit, and we can't remove it if it's not there
+   * in the first place -> we send it once here just to be sure it's
+   * there. */
+  send_unit_info(NULL, pcargo);
+  wipe_unit_full(pcargo, FALSE, ULR_TRANSPORT_LOST, killer);
 }
 
 /
@@ -1791,7 +1799,11 @@
   }
 
   /* Could use unit_transport_unload_send here, but that would
-   * call send_unit_info for the transporter unnecessarily. */
+   * call send_unit_info for the transporter unnecessarily.
+   * Note that this means that unit might to get seen briefly
+   * by clients other than owner's, for example as a result of
+   * update of homecity common to this cargo and some other
+   * destroyed unit. */
   unit_transport_unload(pcargo);
   if (pcargo->activity == ACTIVITY_SENTRY) {
 /* Activate sentried units - like planes on a disbanded carrier.


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits


[Freeciv-commits] r33537 - /branches/S2_6/server/unittools.c

2016-08-10 Thread cazfi74
Author: cazfi
Date: Wed Aug 10 11:10:02 2016
New Revision: 33537

URL: http://svn.gna.org/viewcvs/freeciv?rev=33537&view=rev
Log:
Remove drowning units from the clients even if they didn't see those units when 
they still had not
jumped out of the sinking transport.

Reported by Christian Knoke 

See bug #24921

Modified:
branches/S2_6/server/unittools.c

Modified: branches/S2_6/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=33537&r1=33536&r2=33537&view=diff
==
--- branches/S2_6/server/unittools.c(original)
+++ branches/S2_6/server/unittools.cWed Aug 10 11:10:02 2016
@@ -1707,7 +1707,15 @@
 _("%s lost when %s was lost."),
 unit_tile_link(pcargo),
 utype_name_translation(ptransport));
-  wipe_unit_full(pcargo, TRUE, ULR_TRANSPORT_LOST, killer);
+  /* Unit is not transported any more at this point, but it has jumped
+   * off the transport and drowns outside. So it must be removed from
+   * all clients.
+   * However, we don't know if given client has received ANY updates
+   * about the swimming unit, and we can't remove it if it's not there
+   * in the first place -> we send it once here just to be sure it's
+   * there. */
+  send_unit_info(NULL, pcargo);
+  wipe_unit_full(pcargo, FALSE, ULR_TRANSPORT_LOST, killer);
 }
 
 /
@@ -1754,7 +1762,11 @@
   }
 
   /* Could use unit_transport_unload_send here, but that would
-   * call send_unit_info for the transporter unnecessarily. */
+   * call send_unit_info for the transporter unnecessarily.
+   * Note that this means that unit might to get seen briefly
+   * by clients other than owner's, for example as a result of
+   * update of homecity common to this cargo and some other
+   * destroyed unit. */
   unit_transport_unload(pcargo);
   if (pcargo->activity == ACTIVITY_SENTRY) {
 /* Activate sentried units - like planes on a disbanded carrier.


___
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits