Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12231) allied AI loads my ships
Home

[Freeciv-Dev] (PR#12231) allied AI loads my ships

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#12231) allied AI loads my ships
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Feb 2005 09:29:45 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [chrisk - Sun Feb 13 00:02:44 2005]:
> 
> 
> CVS S2
> 
> Think this has been reported before. Really funny.
> 
> Allied AI moves units on my caravel (which I do need for my own troop
> transports).
> 
> No way to remove them. Not at the coast nor in my city. I can Shift-U
> but
> the units are not unloaded in city (L-icon!). Trying to load my own
> units
> does not work either.
> 
> I can activate the allied units! but not move. Usual orders in menue
> are
> present but don't work (Shift-G might be a solution :)
> 
> Now I disband my caravelle; units are still there and have 'L'. I
> build a new
> caravelle.
> 
> Next turn. I have luck. AI has fortified it's units so I can load my
> own.

handle_unit_unload is buggy.  It doesn't allow you to remove your units
from your allies transporters.

This patch fixes both problems.  Now you can unload a unit if you own
either the unit or the transporter.

For both branches.

-jason

Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.319
diff -u -r1.319 unithand.c
--- server/unithand.c   5 Feb 2005 07:41:54 -0000       1.319
+++ server/unithand.c   14 Feb 2005 17:28:28 -0000
@@ -1544,13 +1544,20 @@
 ****************************************************************************/
 void handle_unit_unload(struct player *pplayer, int cargo_id, int trans_id)
 {
-  struct unit *pcargo = player_find_unit_by_id(pplayer, cargo_id);
-  struct unit *ptrans = player_find_unit_by_id(pplayer, trans_id);
+  struct unit *pcargo = find_unit_by_id(cargo_id);
+  struct unit *ptrans = find_unit_by_id(trans_id);
 
   if (!pcargo || !ptrans) {
     return;
   }
 
+  /* You are allowed to unload a unit if it is yours or if the transporter
+   * is yours. */
+  if (pcargo->owner != pplayer->player_no
+      && ptrans->owner != pplayer->player_no) {
+    return;
+  }
+
   if (!can_unit_unload(pcargo, ptrans)) {
     return;
   }

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