<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.000000000 +0300
+++ freeciv/ai/aidiplomat.c	2007-08-04 13:56:54.000000000 +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.000000000 +0300
+++ freeciv/common/unit.c	2007-08-04 13:54:04.000000000 +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.000000000 +0300
+++ freeciv/common/unit.h	2007-08-04 13:54:09.000000000 +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.000000000 +0300
+++ freeciv/server/diplomats.c	2007-08-04 13:58:10.000000000 +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.000000000 +0300
+++ freeciv/server/savegame.c	2007-08-04 14:03:26.000000000 +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, "player%d.u%d.veteran", 
 				plrno, i);
-    secfile_insert_bool(file, punit->foul, "player%d.u%d.foul", 
-				plrno, i);
     secfile_insert_int(file, punit->hp, "player%d.u%d.hp", plrno, i);
     secfile_insert_int(file, punit->homecity, "player%d.u%d.homecity",
 				plrno, i);
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c	2007-08-01 17:17:23.000000000 +0300
+++ freeciv/server/unittools.c	2007-08-04 13:54:34.000000000 +0300
@@ -1365,10 +1365,6 @@
    * (Otherwise could pass moved arg too...)  --dwp */
   punit->moved = (moves_left >= 0);
 
-  /* See if this is a spy that has been moved (corrupt and therefore 
-   * unable to establish an embassy. */
-  punit->foul = (moves_left != -1 && unit_has_type_flag(punit, F_SPY));
-
   unit_list_prepend(pplayer->units, punit);
   unit_list_prepend(ptile->units, punit);
   if (pcity && !utype_has_flag(type, F_NOHOME)) {
diff -Nurd -X.diff_ignore freeciv/ai/aidiplomat.c freeciv/ai/aidiplomat.c
--- freeciv/ai/aidiplomat.c	2007-03-05 19:16:00.000000000 +0200
+++ freeciv/ai/aidiplomat.c	2007-08-04 14:09:13.000000000 +0300
@@ -274,7 +274,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 */
   }
@@ -335,8 +336,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-03-05 19:15:59.000000000 +0200
+++ freeciv/common/unit.c	2007-08-04 14:09:13.000000000 +0300
@@ -1741,7 +1741,6 @@
   punit->upkeep_gold = 0;
   punit->unhappiness = 0;
   /* A unit new and fresh ... */
-  punit->foul = FALSE;
   punit->debug = FALSE;
   punit->fuel = unit_type(punit)->fuel;
   punit->hp = unit_type(punit)->hp;
diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h
--- freeciv/common/unit.h	2007-03-05 19:15:59.000000000 +0200
+++ freeciv/common/unit.h	2007-08-04 14:09:13.000000000 +0300
@@ -149,7 +149,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-03-05 19:15:25.000000000 +0200
+++ freeciv/server/diplomats.c	2007-08-04 14:09:45.000000000 +0300
@@ -229,7 +229,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.
@@ -251,23 +250,6 @@
 
   freelog (LOG_DEBUG, "embassy: unit: %d", pdiplomat->id);
 
-  /* Check for "foul" ambassador. */
-  if (pdiplomat->foul) {
-    notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
-		     _("Game: Your %s was executed in %s on suspicion"
-		       " of spying.  The %s welcome future diplomatic"
-		       " efforts providing the Ambassador is reputable."),
-		     unit_name(pdiplomat->type),
-		     pcity->name, get_nation_name_plural(cplayer->nation));
-    notify_player_ex(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(pdiplomat->type),
-		     get_nation_name_plural(pplayer->nation), pcity->name);
-    wipe_unit(pdiplomat);
-    return;
-  }
-
   /* Check for Barbarian response. */
   if (is_barbarian (cplayer)) {
     notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
@@ -457,7 +439,6 @@
 
   /* Copy some more unit fields */
   gained_unit->fuel        = pvictim->fuel;
-  gained_unit->foul        = pvictim->foul;
   gained_unit->paradropped = pvictim->paradropped;
 
   /* Inform owner about less than full fuel */
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2007-08-04 04:27:24.000000000 +0300
+++ freeciv/server/savegame.c	2007-08-04 14:09:13.000000000 +0300
@@ -1429,9 +1429,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);
 
@@ -2626,8 +2627,6 @@
     secfile_insert_int(file, punit->tile->nat_y, "player%d.u%d.y", plrno, i);
     secfile_insert_int(file, punit->veteran, "player%d.u%d.veteran", 
 				plrno, i);
-    secfile_insert_bool(file, punit->foul, "player%d.u%d.foul", 
-				plrno, i);
     secfile_insert_int(file, punit->hp, "player%d.u%d.hp", plrno, i);
     secfile_insert_int(file, punit->homecity, "player%d.u%d.homecity",
 				plrno, i);
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c	2007-03-05 19:15:25.000000000 +0200
+++ freeciv/server/unittools.c	2007-08-04 14:10:05.000000000 +0300
@@ -1485,10 +1485,6 @@
    * (Otherwise could pass moved arg too...)  --dwp */
   punit->moved = (moves_left >= 0);
 
-  /* See if this is a spy that has been moved (corrupt and therefore 
-   * unable to establish an embassy. */
-  punit->foul = (moves_left != -1 && unit_flag(punit, F_SPY));
-
   unit_list_insert(&pplayer->units, punit);
   unit_list_insert(&ptile->units, punit);
   if (pcity && !unit_type_flag(type, F_NOHOME)) {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to