Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2006:
[Freeciv-Dev] (PR#15864) Fix two borders problems
Home

[Freeciv-Dev] (PR#15864) Fix two borders problems

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15864) Fix two borders problems
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 11 Mar 2006 08:22:58 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15864 >

A possible crash in maphand.c if ptile->owner is set and
ptile->owner_source is NULL. This should never happen, but defensive
programming is nice.

When a player dies or is killed off, make sure we immediately unown any
tiles that player owns.

  - Per

Index: server/maphand.c
===================================================================
--- server/maphand.c    (revision 11755)
+++ server/maphand.c    (working copy)
@@ -1602,7 +1602,9 @@
   /* Third remove undue ownership. */
   whole_map_iterate(ptile) {
     if (ptile->owner
-        && (ptile->owner != ptile->owner_source->owner
+        && (!ptile->owner_source
+            || !ptile->owner->is_alive
+            || ptile->owner != ptile->owner_source->owner
             || (!ptile->owner_source->city
                 && !tile_has_special(ptile->owner_source, S_FORTRESS)))) {
       /* Ownership source gone */
Index: server/plrhand.c
===================================================================
--- server/plrhand.c    (revision 11755)
+++ server/plrhand.c    (working copy)
@@ -172,6 +172,13 @@
   } city_list_iterate_end;
   game.info.savepalace = palace;
 
+  /* Remove ownership of tiles */
+  whole_map_iterate(ptile) {
+    if (ptile->owner == pplayer) {
+      map_claim_ownership(ptile, NULL, NULL);
+    }
+  } whole_map_iterate_end;
+
   /* Ensure this dead player doesn't win with a spaceship.
    * Now that would be truly unbelievably dumb - Per */
   spaceship_init(&pplayer->spaceship);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#15864) Fix two borders problems, Per I. Mathisen <=