Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9706) Wishlist: Change homecity without visiting it
Home

[Freeciv-Dev] (PR#9706) Wishlist: Change homecity without visiting it

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9706) Wishlist: Change homecity without visiting it
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sun, 15 Aug 2004 01:53:45 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9706 >


  I see no point in moving units from city they are garrisoned in to 
another city and back just in order to make other city to pay its 
upkeep. Micromanagement.

  When unit wants to change its homecity, client should just popup 
dialog listing players cities (can we reuse city report here?) so new 
homecity can be selected.

  For civ/2 compatibility this must be implemented as ruleset option, 
unless everybody agrees that current behaviour is just a bug in civ/2.


  So far I have looked into server code and found out that it does not 
force curernt rule, its just client that requests homecity changes only 
when unit is in that city. Attached patch fixes server end in this 
respect. I'm sending it separately in case this new feature gets 
rejected; current behaviour should still be fixed.
  In addition to checking that unit actually is in that particular city 
when it wants to change homecity, I special cased 'changing' homecity to 
current homecity. I'm pretty sure that it has caused no problems in the 
past, but certainly it was bug prune to go through all homecity changing 
routines when new_city == old_city:
unit_list_insert(&new_pcity->units_supported, punit);
unit_list_unlink(&old_pcity->units_supported, punit);
  Maybe client(s) already make sure that no homecity changing request is 
sent for present homecity, I don't know.


  - Caz


diff -Nurd freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c   2004-08-15 02:08:49.937500000 +0300
+++ freeciv/server/unithand.c   2004-08-15 11:26:30.546875000 +0300
@@ -325,11 +325,21 @@
   struct city *old_pcity, *new_pcity =
       player_find_city_by_id(pplayer, city_id);
 
-  if (!punit || !new_pcity) {
+  if (!punit || !new_pcity || city_id == punit->homecity) {
     return;
   }
   old_pcity = player_find_city_by_id(pplayer, punit->homecity);
 
+  if (!same_pos(punit->x, punit->y, new_pcity->x, new_pcity->y)) {
+    freelog(LOG_ERROR,
+            _("%s's %s (%d) is at (%d,%d), but tried to make "
+              "%s at (%d,%d) its homecity."),
+            pplayer->name,
+            unit_name(punit->type), unit_id, punit->x, punit->y,
+            new_pcity->name, new_pcity->x, new_pcity->y);
+    return;
+  }
+
   unit_list_insert(&new_pcity->units_supported, punit);
   if (old_pcity) {
     unit_list_unlink(&old_pcity->units_supported, punit);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9706) Wishlist: Change homecity without visiting it, Marko Lindqvist <=