Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] Re: (PR#5096) Remove a duplicate gameloss unit safety net
Home

[Freeciv-Dev] Re: (PR#5096) Remove a duplicate gameloss unit safety net

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#5096) Remove a duplicate gameloss unit safety net
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 19 Aug 2003 09:26:38 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Thu, 14 Aug 2003, Jason Short wrote:
> > This removes an unnecessary F_GAMELOSS unit safety net, and also
> > simplifies some code using the new bounce_unit() function.
...
> I think disband_stack_conflict_unit() should just be dropped.
> bounce_unit() is enough, and better named IMO.

Done. New patch attached.

  - Per

"The truth is there is an ideological struggle between those who believe
that the best way to grow the economy is to give more money to the
wealthy, and the Democrats who believe that the wealthy will make more
money if average people do better." -- Bill Clinton, November 2000

Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.241
diff -u -r1.241 unittools.c
--- server/unittools.c  14 Aug 2003 19:07:01 -0000      1.241
+++ server/unittools.c  19 Aug 2003 16:26:03 -0000
@@ -1275,35 +1275,6 @@
 }
 
 /**************************************************************************
-Disband given unit because of a stack conflict.
-**************************************************************************/
-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),
-         punit->x, punit->y);
-  /* Too cheesy way to kill an enemy player */
-  if (unit_flag(punit, F_GAMELOSS)) {
-    struct city *toc =
-          find_closest_owned_city(unit_owner(punit),
-              punit->x, punit->y, FALSE, NULL);
-    assert(toc != NULL);
-    notify_player_ex(unit_owner(punit), punit->x, punit->y, E_UNIT_WIN,
-        _("%s narrowly escaped death and fled to %s"), 
-        unit_name(punit->type), toc->name);
-    teleport_unit_to_city(punit, toc, -1, TRUE);
-    return;
-  }
-  /* remove it */
-  if (verbose) {
-    notify_player(unit_owner(punit),
-                 _("Game: Disbanded your %s at (%d, %d)."),
-                 unit_name(punit->type), punit->x, punit->y);
-  }
-  wipe_unit(punit);
-}
-
-/**************************************************************************
 Teleport punit to city at cost specified.  Returns success.
 (If specified cost is -1, then teleportation costs all movement.)
                          - Kris Bubendorfer
@@ -1335,7 +1306,7 @@
 /**************************************************************************
   Teleport or remove a unit due to stack conflict.
 **************************************************************************/
-static void bounce_unit(struct unit *punit, bool verbose)
+void bounce_unit(struct unit *punit, bool verbose)
 {
   struct player *pplayer = unit_owner(punit);
   struct city *pcity = find_closest_owned_city(pplayer, punit->x, punit->y,
@@ -1344,7 +1315,13 @@
   if (pcity) {
     (void) teleport_unit_to_city(punit, pcity, 0, verbose);
   } else {
-    disband_stack_conflict_unit(punit, verbose);
+    /* remove it */
+    if (verbose) {
+      notify_player(unit_owner(punit),
+                    _("Game: Disbanded your %s at (%d, %d)."),
+                    unit_name(punit->type), punit->x, punit->y);
+    }
+    wipe_unit(punit);
   }
 }
 
Index: server/unittools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.h,v
retrieving revision 1.52
diff -u -r1.52 unittools.h
--- server/unittools.h  2 Jul 2003 19:32:47 -0000       1.52
+++ server/unittools.h  19 Aug 2003 16:26:03 -0000
@@ -44,10 +44,10 @@
                          bool verbose);
 void resolve_unit_stacks(struct player *pplayer, struct player *aplayer,
                          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);
 void pay_for_units(struct player *pplayer, struct city *pcity);
+void bounce_unit(struct unit *punit, bool verbose);
 
 /* creation/deletion/upgrading */
 void upgrade_unit(struct unit *punit, Unit_Type_id to_unit);
@@ -61,7 +61,6 @@
 void wipe_unit_spec_safe(struct unit *punit, struct genlist_iterator *iter,
                         bool wipe_cargo);
 void kill_unit(struct unit *pkiller, struct unit *punit);
-
 
 /* sending to client */
 void package_unit(struct unit *punit, struct packet_unit_info *packet,
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.228
diff -u -r1.228 citytools.c
--- server/citytools.c  1 Aug 2003 19:58:47 -0000       1.228
+++ server/citytools.c  19 Aug 2003 16:26:04 -0000
@@ -641,14 +641,7 @@
        unit_list_unlink(units, vunit);
       } else if (!pplayers_allied(pplayer, unit_owner(vunit))) {
         /* the owner of vunit is allied to pvictim but not to pplayer */
-        struct city *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);
-        }
+        bounce_unit(vunit, verbose);
       }
     } unit_list_iterate_end;
   }

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