Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] Re: (PR#2280) Transfer or city with allied units inside --
Home

[Freeciv-Dev] Re: (PR#2280) Transfer or city with allied units inside --

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2280) Transfer or city with allied units inside --> core dump
From: "Davide Pagnin via RT" <rt@xxxxxxxxxxxxxx>
Date: Sat, 9 Nov 2002 10:02:25 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Sat, 2002-11-09 at 18:27, Mike Kaufman via RT wrote:
> 
> your style is incorrect: the elses should be on the same lines and the }
> and remove the tabs so that I can see that the indenting is correct, it
> doesn't appear to be. also initialize vcity to NULL.

Sorry for the elses.

I've initialized vcity tough in Codingstyle you found:
"variables CAN be initialized as soon as they're declared"

Don't know for the tabs, vi from redhat 7.3 linux put them by default,
and I guess they were ok. I have substituted them with spaces.

> 
> appears correct otherwise. I take it it does work on your savegame.
> 
> -mike
> 
> 


diff -urN -Xfreeciv/diff_ignore freeciv/server/citytools.c 
freeciv-beta/server/citytools.c
--- freeciv/server/citytools.c  Mon Sep 23 17:00:56 2002
+++ freeciv-beta/server/citytools.c     Sat Nov  9 18:43:39 2002
@@ -620,6 +620,7 @@
 {
   int x = pcity->x;
   int y = pcity->y;
+  struct city *vcity = NULL;
 
   /* Transfer enemy units in the city to the new owner.
      Only relevant if we are transfering to another player. */
@@ -630,6 +631,14 @@
        transfer_unit(vunit, pcity, verbose);
        wipe_unit_safe(vunit, &myiter);
        unit_list_unlink(units, vunit);
+      } else if (!pplayers_allied(pplayer, unit_owner(vunit))) {
+        vcity = find_closest_owned_city(unit_owner(vunit), x, y,
+                is_sailing_unit(vunit), NULL);
+        if (vcity) {
+          (void) teleport_unit_to_city(vunit, vcity, 0, verbose);
+        } else {
+          disband_stack_conflict_unit(vunit, verbose);
+        }
       }
     } unit_list_iterate_end;
   }
diff -urN -Xfreeciv/diff_ignore freeciv/server/unittools.c 
freeciv-beta/server/unittools.c
--- freeciv/server/unittools.c  Sun Sep 29 01:00:51 2002
+++ freeciv-beta/server/unittools.c     Sat Nov  9 18:41:54 2002
@@ -1412,7 +1412,7 @@
 /**************************************************************************
 Disband given unit because of a stack conflict.
 **************************************************************************/
-static void disband_stack_conflict_unit(struct unit *punit, bool verbose)
+void disband_stack_conflict_unit(struct unit *punit, bool verbose)
 {
   freelog(LOG_VERBOSE, "Disbanded %s's %s at (%d, %d)",
          unit_owner(punit)->name, unit_name(punit->type),
diff -urN -Xfreeciv/diff_ignore freeciv/server/unittools.h 
freeciv-beta/server/unittools.h
--- freeciv/server/unittools.h  Wed Mar 13 10:56:27 2002
+++ freeciv-beta/server/unittools.h     Sat Nov  9 18:41:54 2002
@@ -43,6 +43,7 @@
 bool teleport_unit_to_city(struct unit *punit, struct city *pcity, int 
move_cost,
                          bool verbose);
 void resolve_unit_stack(int x, int y, bool verbose);
+void disband_stack_conflict_unit(struct unit *punit, bool verbose);
 int get_watchtower_vision(struct unit *punit);
 bool unit_profits_of_watchtower(struct unit *punit);
 

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