Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] fix transport bug (PR#4095)
Home

[Freeciv-Dev] fix transport bug (PR#4095)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ChrisK@xxxxxxxx
Subject: [Freeciv-Dev] fix transport bug (PR#4095)
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 16 Sep 2003 09:56:19 -0700
Reply-to: rt@xxxxxxxxxxxxxx

This fixes the bug where a transport can move an allied cargo unit on to a
tile that contains units allied to the transport's owner but not to the
cargo's owner. Test the attached savegame for correctness. To reproduce
bug, move Henryk's unit into Angmar's transport, then move transport on
Angmar's allies. If you 'turn done' while the transport with Henryk's unit
is in the city, the server will core dump.

Note that this patch relies on transported_by being set correctly. It
often isn't, but since we are going to fix that, this patch is correct
anyway.

  - Per

Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.269
diff -u -r1.269 unithand.c
--- server/unithand.c   9 Sep 2003 20:10:28 -0000       1.269
+++ server/unithand.c   16 Sep 2003 16:47:15 -0000
@@ -1095,6 +1095,22 @@
 
   /*** Phase 4: OK now move the unit ***/
 
+  /* We cannot move a transport into a tile that holds
+   * units not allied with all of our cargo. */
+  if (get_transporter_capacity(punit) > 0) {
+    unit_list_iterate(map_get_tile(punit->x, punit->y)->units, pcargo) {
+      if (pcargo->transported_by == punit->id
+          && (is_non_allied_unit_tile(pdesttile, unit_owner(pcargo))
+              || is_non_allied_city_tile(pdesttile, unit_owner(pcargo)))) {
+         notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
+                       _("Game: A transported unit is not allied to all "
+                        "units on target tile."));
+         return FALSE;
+      }
+    } unit_list_iterate_end;
+  }
+
+
   if (can_unit_move_to_tile_with_notify(punit, x, y, igzoc)
       && try_move_unit(punit, x, y)) {
     int move_cost = map_move_cost(punit, x, y);

Attachment: transportbug.sav.gz
Description: transportbug.sav.gz


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] fix transport bug (PR#4095), Per I. Mathisen <=