Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9823) change "return" to "return-and-recover"
Home

[Freeciv-Dev] (PR#9823) change "return" to "return-and-recover"

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9823) change "return" to "return-and-recover"
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Sep 2004 17:48:04 -0700
Reply-to: rt@xxxxxxxxxxx

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

Here's an updated patch.  It only sentries the unit if its HP aren't full.

jason

? freeciv-1.14.99-devel
? settler_recursion_crash
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.139
diff -u -r1.139 control.c
--- client/control.c    2 Aug 2004 16:59:14 -0000       1.139
+++ client/control.c    14 Sep 2004 00:47:37 -0000
@@ -692,7 +692,15 @@
   }
 
   if ((path = path_to_nearest_allied_city(punit))) {
-    send_goto_path(punit, path);
+    enum unit_activity activity = ACTIVITY_LAST;
+    int turns = pf_last_position(path)->turn;
+
+    if (punit->hp + turns * get_player_bonus(game.player_ptr,
+                                            EFT_UNIT_RECOVER)
+       < unit_type(punit)->hp) {
+      activity = ACTIVITY_SENTRY;
+    }
+    send_goto_path(punit, path, activity);
     pf_destroy_path(path);
   }
 }
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.71
diff -u -r1.71 goto.c
--- client/goto.c       26 Aug 2004 18:37:51 -0000      1.71
+++ client/goto.c       14 Sep 2004 00:47:37 -0000
@@ -515,7 +515,8 @@
   Send a path as a goto or patrol route to the server.
 **************************************************************************/
 static void send_path_orders(struct unit *punit, struct pf_path *path,
-                            bool repeat, bool vigilant)
+                            bool repeat, bool vigilant,
+                            enum unit_activity final_activity)
 {
   struct packet_unit_orders p;
   int i, old_x, old_y;
@@ -556,6 +557,13 @@
     old_y = new_y;
   }
 
+  if (final_activity != ACTIVITY_LAST) {
+    p.orders[i] = ORDER_ACTIVITY;
+    p.dir[i] = -1;
+    p.activity[i] = final_activity;
+    p.length++;
+  }
+
   p.dest_x = old_x;
   p.dest_y = old_y;
 
@@ -565,9 +573,10 @@
 /**************************************************************************
   Send an arbitrary goto path for the unit to the server.
 **************************************************************************/
-void send_goto_path(struct unit *punit, struct pf_path *path)
+void send_goto_path(struct unit *punit, struct pf_path *path,
+                   enum unit_activity final_activity)
 {
-  send_path_orders(punit, path, FALSE, FALSE);
+  send_path_orders(punit, path, FALSE, FALSE, final_activity);
 }
 
 /**************************************************************************
@@ -603,7 +612,7 @@
   pf_destroy_map(map);
   pf_destroy_path(return_path);
 
-  send_path_orders(punit, path, TRUE, TRUE);
+  send_path_orders(punit, path, TRUE, TRUE, ACTIVITY_LAST);
 
   pf_destroy_path(path);
 }
@@ -625,7 +634,7 @@
     path = pft_concat(path, goto_map.parts[i].path);
   }
 
-  send_goto_path(punit, path);
+  send_goto_path(punit, path, ACTIVITY_LAST);
   pf_destroy_path(path);
 }
 
Index: client/goto.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.h,v
retrieving revision 1.13
diff -u -r1.13 goto.h
--- client/goto.h       21 Jun 2004 15:14:43 -0000      1.13
+++ client/goto.h       14 Sep 2004 00:47:37 -0000
@@ -33,7 +33,8 @@
 bool is_endpoint(int x, int y);
 
 void request_orders_cleared(struct unit *punit);
-void send_goto_path(struct unit *punit, struct pf_path *path);
+void send_goto_path(struct unit *punit, struct pf_path *path,
+                   enum unit_activity final_activity);
 void send_patrol_route(struct unit *punit);
 void send_goto_route(struct unit *punit);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9823) change "return" to "return-and-recover", Jason Short <=