Author: cazfi Date: Sat May 20 09:34:52 2017 New Revision: 35671 URL: http://svn.gna.org/viewcvs/freeciv?rev=35671&view=rev Log: Add "stay" property for individual units
See hrm Feature #661437 Modified: branches/S3_0/common/movement.c branches/S3_0/common/movement.h branches/S3_0/common/unit.c branches/S3_0/common/unit.h branches/S3_0/server/savegame3.c Modified: branches/S3_0/common/movement.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/movement.c?rev=35671&r1=35670&r2=35671&view=diff ============================================================================== --- branches/S3_0/common/movement.c (original) +++ branches/S3_0/common/movement.c Sat May 20 09:34:52 2017 @@ -537,20 +537,21 @@ The unit can move if: 1) The unit is idle or on server goto. - 2) The target location is next to the unit. - 3) There are no non-allied units on the target tile. - 4) Animals cannot move out from home terrains - 5) Unit can move to a tile where it can't survive on its own if there + 2) Unit is not prohibited from moving by scenario + 3) The target location is next to the unit. + 4) There are no non-allied units on the target tile. + 5) Animals cannot move out from home terrains + 6) Unit can move to a tile where it can't survive on its own if there is free transport capacity. - 6) There are no peaceful but non allied units on the target tile. - 7) There is not a non allied city on the target tile when + 7) There are no peaceful but non allied units on the target tile. + 8) There is not a non allied city on the target tile when enter_enemy_city is false. When enter_enemy_city is true a non peaceful city is also accepted. - 8) There is no non-allied unit blocking (zoc) [or igzoc is true]. - 9) Triremes cannot move out of sight from land. - 10) It is not the territory of a player we are at peace with. - 11) The unit is unable to disembark from current transporter. - 12) The unit is making a non-native move (e.g. lack of road) + 9) There is no non-allied unit blocking (zoc) [or igzoc is true]. + 10) Triremes cannot move out of sight from land. + 11) It is not the territory of a player we are at peace with. + 12) The unit is unable to disembark from current transporter. + 13) The unit is making a non-native move (e.g. lack of road) **************************************************************************/ enum unit_move_result unit_move_to_tile_test(const struct unit *punit, @@ -573,25 +574,30 @@ } /* 2) */ + if (punit->stay) { + return MR_UNIT_STAY; + } + + /* 3) */ if (!is_tiles_adjacent(src_tile, dst_tile)) { /* Of course you can only move to adjacent positions. */ return MR_BAD_DESTINATION; } - /* 3) */ + /* 4) */ if (is_non_allied_unit_tile(dst_tile, puowner)) { /* You can't move onto a tile with non-allied units on it (try * attacking instead). */ return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT; } - /* 4) */ + /* 5) */ if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN && dst_tile->terrain->animal != punittype) { return MR_ANIMAL_DISALLOWED; } - /* 5) */ + /* 6) */ if (embark_to != NULL) { if (!could_unit_load(punit, embark_to)) { return MR_NO_TRANSPORTER_CAPACITY; @@ -601,7 +607,7 @@ return MR_NO_TRANSPORTER_CAPACITY; } - /* 6) */ + /* 7) */ if (is_non_attack_unit_tile(dst_tile, puowner)) { /* You can't move into a non-allied tile. * @@ -610,7 +616,7 @@ return MR_NO_WAR; } - /* 7) */ + /* 8) */ if ((pcity = tile_city(dst_tile))) { if (enter_enemy_city) { if (pplayers_non_attack(city_owner(pcity), puowner)) { @@ -628,7 +634,7 @@ } } - /* 8) */ + /* 9) */ zoc = igzoc || can_step_taken_wrt_to_zoc(punittype, puowner, src_tile, dst_tile); if (!zoc) { @@ -636,24 +642,24 @@ return MR_ZOC; } - /* 9) */ + /* 10) */ if (utype_has_flag(punittype, UTYF_COAST_STRICT) && !is_safe_ocean(dst_tile)) { return MR_TRIREME; } - /* 10) */ + /* 11) */ if (!utype_has_flag(punittype, UTYF_CIVILIAN) && !player_can_invade_tile(puowner, dst_tile)) { return MR_PEACE; } - /* 11) */ + /* 12) */ if (unit_transported(punit) && !can_unit_unload(punit, unit_transport_get(punit))) { return MR_CANNOT_DISEMBARK; } - /* 12) */ + /* 13) */ if (!(is_native_move(utype_class(punittype), src_tile, dst_tile) /* Allow non-native moves into cities or boarding transport. */ || pcity Modified: branches/S3_0/common/movement.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/movement.h?rev=35671&r1=35670&r2=35671&view=diff ============================================================================== --- branches/S3_0/common/movement.h (original) +++ branches/S3_0/common/movement.h Sat May 20 09:34:52 2017 @@ -43,6 +43,7 @@ MR_CANNOT_DISEMBARK, MR_NON_NATIVE_MOVE, /* Usually RMM_RELAXED road diagonally without link */ MR_ANIMAL_DISALLOWED, + MR_UNIT_STAY, MR_NOT_ALLOWED }; Modified: branches/S3_0/common/unit.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/unit.c?rev=35671&r1=35670&r2=35671&view=diff ============================================================================== --- branches/S3_0/common/unit.c (original) +++ branches/S3_0/common/unit.c Sat May 20 09:34:52 2017 @@ -1615,6 +1615,8 @@ punit->action_decision_want = ACT_DEC_NOTHING; punit->action_decision_tile = NULL; + + punit->stay = FALSE; if (is_server()) { punit->server.debug = FALSE; Modified: branches/S3_0/common/unit.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/unit.h?rev=35671&r1=35670&r2=35671&view=diff ============================================================================== --- branches/S3_0/common/unit.h (original) +++ branches/S3_0/common/unit.h Sat May 20 09:34:52 2017 @@ -172,6 +172,8 @@ /* The unit may want the player to choose an action. */ enum action_decision action_decision_want; struct tile *action_decision_tile; + + bool stay; /* Unit is prohibited from moving */ union { struct { Modified: branches/S3_0/server/savegame3.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/savegame3.c?rev=35671&r1=35670&r2=35671&view=diff ============================================================================== --- branches/S3_0/server/savegame3.c (original) +++ branches/S3_0/server/savegame3.c Sat May 20 09:34:52 2017 @@ -5422,6 +5422,8 @@ (void) secfile_entry_lookup(loading->file, "%s.action_decision_tile_y", unitstr); punit->action_decision_tile = NULL; } + + punit->stay = secfile_lookup_bool_default(loading->file, FALSE, "%s.stay", unitstr); /* load the unit orders */ { @@ -5821,6 +5823,9 @@ "%s.action_decision_tile_y", buf); } + secfile_insert_bool(saving->file, punit->stay, + "%s.stay", buf); + if (punit->has_orders) { int len = punit->orders.length; char orders_buf[len + 1], dir_buf[len + 1]; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits