Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12497) [Patch] Validate change_homecity request
Home

[Freeciv-Dev] (PR#12497) [Patch] Validate change_homecity request

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12497) [Patch] Validate change_homecity request
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sun, 13 Mar 2005 05:31:26 -0800
Reply-to: bugs@xxxxxxxxxxx

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


  Usable parts from rejected #9706, adjusted and updated. This patch 
makes sure that client cannot cheat in homecity changing.


  - ML


diff -Nurd -X.diff_ignore freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c   2005-03-13 12:38:43.250000000 +0200
+++ freeciv/server/unithand.c   2005-03-13 13:50:05.562500000 +0200
@@ -289,9 +289,20 @@
   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;
   }
+  if (!same_pos(punit->tile, new_pcity->tile)) {
+    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->tile->x,
+            punit->tile->y, new_pcity->name, new_pcity->tile->x,
+            new_pcity->tile->y);
+    return;
+  }
+
   old_pcity = player_find_city_by_id(pplayer, punit->homecity);
 
   unit_list_prepend(new_pcity->units_supported, punit);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12497) [Patch] Validate change_homecity request, Marko Lindqvist <=