<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.000000000 +0300
+++ freeciv/server/diplomats.c	2007-08-04 04:23:46.000000000 +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 *victim_player = 0;
   struct tile *victim_tile = NULL;
 
@@ -1329,10 +1330,24 @@
  	 get inside this "if" */
       die("Bug in maybe_cause_incident()");
     }
+    offender_unit->foul = TRUE;
     victim_player->diplstates[offender->player_no].has_reason_to_cancel = 2;
     ai_incident_diplomat(offender, victim_player);
     send_player_info(offender, NULL);
     send_player_info(victim_player, NULL);
+  } else { /* Players at war */
+    switch (action) {
+     case DIPLOMAT_MOVE:
+     case DIPLOMAT_EMBASSY:
+     case DIPLOMAT_INVESTIGATE:
+     case SPY_GET_SABOTAGE_LIST:
+       break; /* These are not considered offences */
+     case DIPLOMAT_ANY_ACTION:
+       break; /* This is not real action */
+     default:
+       offender_unit->foul = TRUE;
+       break;
+    }
   }
 
   return;
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c	2007-08-01 19:18:41.000000000 +0300
+++ freeciv/server/unittools.c	2007-08-04 04:21:09.000000000 +0300
@@ -1339,9 +1339,7 @@
    * (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));
+  punit->foul = FALSE;
 
   unit_list_prepend(pplayer->units, punit);
   unit_list_prepend(ptile->units, punit);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to