Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14393) yet another server crash
Home

[Freeciv-Dev] (PR#14393) yet another server crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#14393) yet another server crash
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Thu, 20 Oct 2005 09:59:37 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The attached patch seems to fix the problem.
Index: server/unithand.c
===================================================================
--- server/unithand.c   (wersja 11161)
+++ server/unithand.c   (kopia robocza)
@@ -758,7 +758,8 @@
   int moves_used, def_moves_used; 
   struct tile *def_tile = pdefender->tile;
   int old_unit_vet, old_defender_vet, vet;
-
+  int winner_id;
+  
   freelog(LOG_DEBUG, "Start attack: %s's %s against %s's %s.",
          pplayer->name, unit_type(punit)->name, 
          unit_owner(pdefender)->name,
@@ -833,6 +834,7 @@
   if (unit_flag(punit, F_ONEATTACK)) 
     punit->moves_left = 0;
   pwinner = (punit->hp > 0) ? punit : pdefender;
+  winner_id = pwinner->id;
   plooser = (pdefender->hp > 0) ? punit : pdefender;
 
   vet = (pwinner->veteran == ((punit->hp > 0) ? old_unit_vet :
@@ -914,7 +916,10 @@
     }
   }
 
-  send_unit_info(NULL, pwinner);
+  /* The attacker may have died for many reasons */
+  if (find_unit_by_id(winner_id) != NULL) {
+    send_unit_info(NULL, pwinner);
+  }
 }
 
 /**************************************************************************

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