Re: [Freeciv-Dev] (PR#38165) Bug in 2.1.0-beta3
URL: http://bugs.freeciv.org/Ticket/Display.html?id=38165 On 04/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote: It seems that units should never get foul status inside create_unit(). It is no longer called for spies getting foul. Attached patch changes create_unit() to always create non-foul units. Also, mark spies foul when they actually do something nasty. Untested patch for trunk. I have to check if above is true for S2_1 too. In #12677 it is pointed out that maybe whole foulness concept should be removed. And indeed it is very special case rule and no way clear to users. I'm going to remove it even from S2_0, since broken foulness code is causing trouble there too. - ML diff -Nurd -X.diff_ignore freeciv/ai/aidiplomat.c freeciv/ai/aidiplomat.c --- freeciv/ai/aidiplomat.c 2007-08-01 17:17:27.0 +0300 +++ freeciv/ai/aidiplomat.c 2007-08-04 13:56:54.0 +0300 @@ -288,7 +288,8 @@ return; \ } - if (!punit-foul) T(DIPLOMAT_EMBASSY,0); + T(DIPLOMAT_EMBASSY,0); + if (pplayers_allied(pplayer, tplayer)) { return; /* Don't do the rest to allies */ } @@ -349,8 +350,7 @@ } aplayer = city_owner(acity); -/* sneaky way of avoiding foul diplomat capture -AJS */ -has_embassy = player_has_embassy(pplayer, aplayer) || punit-foul; +has_embassy = player_has_embassy(pplayer, aplayer); if (aplayer == pplayer || is_barbarian(aplayer) || (pplayers_allied(pplayer, aplayer) has_embassy)) { diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c --- freeciv/common/unit.c 2007-08-01 17:17:24.0 +0300 +++ freeciv/common/unit.c 2007-08-04 13:54:04.0 +0300 @@ -1304,7 +1304,6 @@ punit-goto_tile = NULL; punit-veteran = veteran_level; /* A unit new and fresh ... */ - punit-foul = FALSE; punit-debug = FALSE; punit-fuel = unit_type(punit)-fuel; punit-birth_turn = game.info.turn; diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h --- freeciv/common/unit.h 2007-07-09 22:39:41.0 +0300 +++ freeciv/common/unit.h 2007-08-04 13:54:09.0 +0300 @@ -141,7 +141,6 @@ int ord_map, ord_city; /* ord_map and ord_city are the order index of this unit in tile.units and city.units_supported; they are only used for save/reload */ - bool foul; bool debug; bool moved; bool paradropped; diff -Nurd -X.diff_ignore freeciv/server/diplomats.c freeciv/server/diplomats.c --- freeciv/server/diplomats.c 2007-08-01 17:17:23.0 +0300 +++ freeciv/server/diplomats.c 2007-08-04 13:58:10.0 +0300 @@ -236,7 +236,6 @@ - Either a Diplomat or Spy can establish an embassy. - - Foul ambassadors are detected and executed. - Barbarians always execute ambassadors. - Otherwise, the embassy is created. - It costs some minimal movement to establish an embassy. @@ -258,25 +257,6 @@ freelog (LOG_DEBUG, embassy: unit: %d, pdiplomat-id); - /* Check for foul ambassador. */ - if (pdiplomat-foul) { -notify_player(pplayer, pcity-tile, E_MY_DIPLOMAT_FAILED, - _(Your %s was executed in %s on suspicion - of spying. The %s welcome future diplomatic - efforts providing the Ambassador is reputable.), - unit_name_translation(pdiplomat), - pcity-name, - nation_plural_for_player(cplayer)); -notify_player(cplayer, pcity-tile, E_ENEMY_DIPLOMAT_FAILED, - _(You executed a %s the %s had sent to establish - an embassy in %s for being untrustworthy), - unit_name_translation(pdiplomat), - nation_plural_for_player(pplayer), - pcity-name); -wipe_unit(pdiplomat); -return; - } - /* Check for Barbarian response. */ if (get_player_bonus(cplayer, EFT_NO_DIPLOMACY)) { notify_player(pplayer, pcity-tile, E_MY_DIPLOMAT_FAILED, @@ -470,7 +450,6 @@ /* Copy some more unit fields */ gained_unit-fuel= pvictim-fuel; - gained_unit-foul= pvictim-foul; gained_unit-paradropped = pvictim-paradropped; gained_unit-birth_turn = pvictim-birth_turn; diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c --- freeciv/server/savegame.c 2007-08-01 17:17:23.0 +0300 +++ freeciv/server/savegame.c 2007-08-04 14:03:26.0 +0300 @@ -1638,9 +1638,10 @@ nat_y = secfile_lookup_int(file, player%d.u%d.y, plrno, i); punit-tile = native_pos_to_tile(nat_x, nat_y); -punit-foul - = secfile_lookup_bool_default(file, FALSE, player%d.u%d.foul, -plrno, i); +/* Avoid warning when loading pre-2.1 saves containing foul status */ +secfile_lookup_bool_default(file, FALSE, player%d.u%d.foul, +plrno, i); + punit-homecity = secfile_lookup_int(file, player%d.u%d.homecity, plrno, i); @@ -2950,8 +2951,6 @@ secfile_insert_int(file, punit-tile-nat_y, player%d.u%d.y, plrno, i); secfile_insert_int(file, punit-veteran,
Re: [Freeciv-Dev] (PR#38165) Bug in 2.1.0-beta3
URL: http://bugs.freeciv.org/Ticket/Display.html?id=38165 On 04/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote: It seems that units should never get foul status inside create_unit(). It is no longer called for spies getting foul. Attached patch changes create_unit() to always create non-foul units. Also, mark spies foul when they actually do something nasty. Untested patch for trunk. I have to check if above is true for S2_1 too. S2_1 version - ML diff -Nurd -X.diff_ignore freeciv/server/diplomats.c freeciv/server/diplomats.c --- freeciv/server/diplomats.c 2007-07-04 14:04:17.0 +0300 +++ freeciv/server/diplomats.c 2007-08-04 04:23:46.0 +0300 @@ -50,7 +50,7 @@ struct unit *pdiplomat, struct tile *ptile); static void diplomat_escape(struct player *pplayer, struct unit *pdiplomat, const struct city *pcity); -static void maybe_cause_incident(enum diplomat_actions action, struct player *offender, +static void maybe_cause_incident(enum diplomat_actions action, struct unit *offender_unit, struct unit *victim_unit, struct city *victim_city); /** @@ -121,7 +121,7 @@ send_city_info(NULL, pcity); /* this may cause a diplomatic incident */ - maybe_cause_incident(SPY_POISON, pplayer, NULL, pcity); + maybe_cause_incident(SPY_POISON, pdiplomat, NULL, pcity); /* Now lets see if the spy survives. */ diplomat_escape(pplayer, pdiplomat, pcity); @@ -187,7 +187,7 @@ } /* this may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_INVESTIGATE, pplayer, NULL, pcity); + maybe_cause_incident(DIPLOMAT_INVESTIGATE, pdiplomat, NULL, pcity); /* Spies always survive. Diplomats never do. */ if (!unit_has_type_flag(pdiplomat, F_SPY)) { @@ -227,7 +227,7 @@ lsend_packet_city_sabotage_list(player_reply_dest(pplayer), packet); /* this may cause a diplomatic incident */ - maybe_cause_incident(SPY_GET_SABOTAGE_LIST, pplayer, NULL, pcity); + maybe_cause_incident(SPY_GET_SABOTAGE_LIST, pdiplomat, NULL, pcity); } /** @@ -307,7 +307,7 @@ } /* this may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_EMBASSY, pplayer, NULL, pcity); + maybe_cause_incident(DIPLOMAT_EMBASSY, pdiplomat, NULL, pcity); /* Spies always survive. Diplomats never do. */ if (!unit_has_type_flag(pdiplomat, F_SPY)) { @@ -385,7 +385,7 @@ pplayer-name); /* this may cause a diplomatic incident */ - maybe_cause_incident(SPY_SABOTAGE_UNIT, pplayer, pvictim, NULL); + maybe_cause_incident(SPY_SABOTAGE_UNIT, pdiplomat, pvictim, NULL); /* Now lets see if the spy survives. */ diplomat_escape(pplayer, pdiplomat, NULL); @@ -502,7 +502,7 @@ pplayer-economic.gold -= pvictim-bribe_cost; /* This may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_BRIBE, pplayer, pvictim, NULL); + maybe_cause_incident(DIPLOMAT_BRIBE, pdiplomat, pvictim, NULL); /* Be sure to wipe the converted unit! */ victim_tile = pvictim-tile; @@ -642,7 +642,7 @@ unit_name_translation(pdiplomat), pcity-name); /* this may cause a diplomatic incident */ -maybe_cause_incident(DIPLOMAT_STEAL, pplayer, NULL, pcity); +maybe_cause_incident(DIPLOMAT_STEAL, pdiplomat, NULL, pcity); wipe_unit(pdiplomat); return; } @@ -665,7 +665,7 @@ (pcity-steal)++; /* this may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_STEAL, pplayer, NULL, pcity); + maybe_cause_incident(DIPLOMAT_STEAL, pdiplomat, NULL, pcity); /* Check if a spy survives her mission. Diplomats never do. */ diplomat_escape(pplayer, pdiplomat, pcity); @@ -776,7 +776,7 @@ steal_a_tech (pplayer, cplayer, A_UNSET); /* this may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_INCITE, pplayer, NULL, pcity); + maybe_cause_incident(DIPLOMAT_INCITE, pdiplomat, NULL, pcity); /* Transfer city and units supported by this city (that are within one square of the city) to the new owner. @@ -1034,7 +1034,7 @@ send_city_info(NULL, pcity); /* this may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_SABOTAGE, pplayer, NULL, pcity); + maybe_cause_incident(DIPLOMAT_SABOTAGE, pdiplomat, NULL, pcity); /* Check if a spy survives her mission. Diplomats never do. */ diplomat_escape(pplayer, pdiplomat, pcity); @@ -1268,9 +1268,10 @@ /** ... **/ -static void maybe_cause_incident(enum diplomat_actions action, struct player *offender, +static void maybe_cause_incident(enum diplomat_actions action, struct unit *offender_unit, struct unit *victim_unit, struct city *victim_city) { + struct player *offender = unit_owner(offender_unit); struct player
Re: [Freeciv-Dev] (PR#38165) Bug in 2.1.0-beta3
URL: http://bugs.freeciv.org/Ticket/Display.html?id=38165 On Wed, 14 Mar 2007, [EMAIL PROTECTED] wrote: I found a bug in the 2.1.0-beta3: spies are always executed when trying to establish an embassy, even if they haven't been in any contact with the enemy. I quickly checked the source code, and it would seem to me that the problem is actually that the spies are always created with the foul status: In server/cityturn.c, line 1212 units are created with 0 moves left, which in turn is interpreted as already moved in server/unittools.c line 1339, where spies are flagged as foul. In the stable version the units are created with -1 moves left, so there it works as intended. However, as somebody has obviously intentionally changed the moves_left argument from -1 to 0 for the beta version, changing it back might break something that I'm not aware of. This is why I didn't submit a patch but just a bug report. This is the change: [EMAIL PROTECTED] freeciv]$ svn log -r 9884 r9884 | jdorje | 2005-02-23 04:34:06 +0100 (Wed, 23 Feb 2005) | 9 lines Introduce an alternating-movement mode for freeciv. In this mode (off by default for now), each player moves in sequence rather than all simultaneously. Actions other than unit movement may be done during at any time. Feature request by many in PR#576. Patch by me. Thanks to Thomas Strub for advice on end-of-turn actions. Thanks to canophone and gilles for playtesting. [EMAIL PROTECTED] freeciv]$ svn diff -r 9883:9884 server/cityturn.c|more Index: server/cityturn.c === --- server/cityturn.c (revision 9883) +++ server/cityturn.c (revision 9884) @@ -1083,7 +1083,7 @@ (void) create_unit(pplayer, pcity-tile, pcity-currently_building, do_make_unit_veteran(pcity, pcity-currently_building), - pcity-id, -1); + pcity-id, 0); /* After we created the unit remove the citizen. This will also rearrange the worker to take into account the extra resources @@ -1418,7 +1418,7 @@ (void) create_unit(pplayer, ptile, pcity-currently_building, do_make_unit_veteran(pcity, pcity-currently_building), -pcity-id, -1); +pcity-id, 0); /* Shift all the units supported by pcity (including the new unit) * to rcity. transfer_city_units does not make sure no units are I am not sure what changing it back would do to alternating movement mode. Jason? - Per ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#38165) Bug in 2.1.0-beta3
URL: http://bugs.freeciv.org/Ticket/Display.html?id=38165 Reported it 2 years ago, don't think anything came of it... http://bugs.freeciv.org/Ticket/Display.html?id=12677 Spies getting executed has been broken since 1.14. No one has noticed until it created this bug, may as well just get rid of it (or just go with executing veteran spies like I suggested, as there is no way to tell if they're foul or not). ps. Thanks for implementing some of my other diplomats.c suggestions tacked on the end of that ticket Per :P. ~~Yautja On 3/16/07, Per I. Mathisen [EMAIL PROTECTED] wrote: URL: http://bugs.freeciv.org/Ticket/Display.html?id=38165 On Wed, 14 Mar 2007, [EMAIL PROTECTED] wrote: I found a bug in the 2.1.0-beta3: spies are always executed when trying to establish an embassy, even if they haven't been in any contact with the enemy. I quickly checked the source code, and it would seem to me that the problem is actually that the spies are always created with the foul status: In server/cityturn.c, line 1212 units are created with 0 moves left, which in turn is interpreted as already moved in server/unittools.c line 1339, where spies are flagged as foul. In the stable version the units are created with -1 moves left, so there it works as intended. However, as somebody has obviously intentionally changed the moves_left argument from -1 to 0 for the beta version, changing it back might break something that I'm not aware of. This is why I didn't submit a patch but just a bug report. This is the change: [EMAIL PROTECTED] freeciv]$ svn log -r 9884 r9884 | jdorje | 2005-02-23 04:34:06 +0100 (Wed, 23 Feb 2005) | 9 lines Introduce an alternating-movement mode for freeciv. In this mode (off by default for now), each player moves in sequence rather than all simultaneously. Actions other than unit movement may be done during at any time. Feature request by many in PR#576. Patch by me. Thanks to Thomas Strub for advice on end-of-turn actions. Thanks to canophone and gilles for playtesting. [EMAIL PROTECTED] freeciv]$ svn diff -r 9883:9884 server/cityturn.c|more Index: server/cityturn.c === --- server/cityturn.c (revision 9883) +++ server/cityturn.c (revision 9884) @@ -1083,7 +1083,7 @@ (void) create_unit(pplayer, pcity-tile, pcity-currently_building, do_make_unit_veteran(pcity, pcity-currently_building), - pcity-id, -1); + pcity-id, 0); /* After we created the unit remove the citizen. This will also rearrange the worker to take into account the extra resources @@ -1418,7 +1418,7 @@ (void) create_unit(pplayer, ptile, pcity-currently_building, do_make_unit_veteran(pcity, pcity-currently_building), -pcity-id, -1); +pcity-id, 0); /* Shift all the units supported by pcity (including the new unit) * to rcity. transfer_city_units does not make sure no units are I am not sure what changing it back would do to alternating movement mode. Jason? - Per ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev