Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] Re: (PR#2293) Paratroopers jumping into an empty city
Home

[Freeciv-Dev] Re: (PR#2293) Paratroopers jumping into an empty city

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ue80@xxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2293) Paratroopers jumping into an empty city
From: "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 12 Nov 2002 14:52:21 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Sun, 10 Nov 2002, Thomas Strub via RT wrote:
> when jumping with a Paratrooper into an empty city of people with status
> neutral, the Paratrooper is in the enemy city.

Patch attached. If you aren't in war, and know the city is there, you
won't be allowed to drop. If you aren't in war and you don't know, you die
on the drop but get to see stuff around the city.

  - Per

? explorer_stop.diff
? game_over.diff
? hmm
? non_massive_aidip.diff
? paradrop1.diff
? ai/aidiplomat.c
? ai/aidiplomat.h
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.193
diff -u -r1.193 unittools.c
--- server/unittools.c  9 Nov 2002 22:41:39 -0000       1.193
+++ server/unittools.c  12 Nov 2002 22:43:16 -0000
@@ -2263,8 +2263,11 @@
 **************************************************************************/
 bool do_paradrop(struct unit *punit, int dest_x, int dest_y)
 {
+  struct tile *ptile = map_get_tile(dest_x, dest_y);
+  struct player *pplayer = unit_owner(punit);
+
   if (!unit_flag(punit, F_PARATROOPERS)) {
-    notify_player_ex(unit_owner(punit), punit->x, punit->y, E_NOEVENT,
+    notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
                     _("Game: This unit type can not be paradropped."));
     return FALSE;
   }
@@ -2272,23 +2275,29 @@
   if (!can_unit_paradrop(punit))
     return FALSE;
 
-  if (!map_get_known(dest_x, dest_y, unit_owner(punit))) {
-    notify_player_ex(unit_owner(punit), dest_x, dest_y, E_NOEVENT,
+  if (!map_get_known(dest_x, dest_y, pplayer)) {
+    notify_player_ex(pplayer, dest_x, dest_y, E_NOEVENT,
                     _("Game: The destination location is not known."));
     return FALSE;
   }
 
-  if (map_get_player_tile(dest_x, dest_y, unit_owner(punit))->terrain == 
T_OCEAN) {
-    notify_player_ex(unit_owner(punit), dest_x, dest_y, E_NOEVENT,
+  if (map_get_player_tile(dest_x, dest_y, pplayer)->terrain == T_OCEAN) {
+    notify_player_ex(pplayer, dest_x, dest_y, E_NOEVENT,
                     _("Game: Cannot paradrop into ocean."));
     return FALSE;    
   }
 
+  if (map_get_player_tile(dest_x, dest_y, pplayer)->city) {
+    notify_player_ex(pplayer, dest_x, dest_y, E_NOEVENT,
+                    _("Game: You are not at war with %s."), pplayer->name);
+    return FALSE;    
+  }
+
   {
     int range = unit_type(punit)->paratroopers_range;
     int distance = real_map_distance(punit->x, punit->y, dest_x, dest_y);
     if (distance > range) {
-      notify_player_ex(unit_owner(punit), dest_x, dest_y, E_NOEVENT,
+      notify_player_ex(pplayer, dest_x, dest_y, E_NOEVENT,
                       _("Game: The distance to the target (%i) "
                         "is greater than the unit's range (%i)."),
                       distance, range);
@@ -2298,9 +2307,9 @@
 
   if (map_get_terrain(dest_x, dest_y) == T_OCEAN) {
     int srange = unit_type(punit)->vision_range;
-    show_area(unit_owner(punit), dest_x, dest_y, srange);
+    show_area(pplayer, dest_x, dest_y, srange);
 
-    notify_player_ex(unit_owner(punit), dest_x, dest_y, E_UNIT_LOST,
+    notify_player_ex(pplayer, dest_x, dest_y, E_UNIT_LOST,
                     _("Game: Your %s paradropped into the ocean "
                       "and was lost."),
                     unit_type(punit)->name);
@@ -2308,11 +2317,11 @@
     return TRUE;
   }
 
-  if (is_non_allied_unit_tile
-      (map_get_tile(dest_x, dest_y), unit_owner(punit))) {
+  if (is_non_allied_unit_tile(ptile, pplayer)
+      || (ptile->city && !pplayers_at_war(pplayer, city_owner(ptile->city)))) {
     int srange = unit_type(punit)->vision_range;
-    show_area(unit_owner(punit), dest_x, dest_y, srange);
-    notify_player_ex(unit_owner(punit), dest_x, dest_y, E_UNIT_LOST_ATT,
+    show_area(pplayer, dest_x, dest_y, srange);
+    notify_player_ex(pplayer, dest_x, dest_y, E_UNIT_LOST_ATT,
                     _("Game: Your %s was killed by enemy units at the "
                       "paradrop destination."),
                     unit_type(punit)->name);

[Prev in Thread] Current Thread [Next in Thread]