Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] another fix for explorer recursion (PR#2631)
Home

[Freeciv-Dev] another fix for explorer recursion (PR#2631)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxx, Gregory.Berkolaiko@xxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] another fix for explorer recursion (PR#2631)
From: "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>
Date: Thu, 16 Jan 2003 15:40:59 -0800
Reply-to: rt@xxxxxxxxxxxxxx

I didn't like any of Greg's fixes, so I made my own. It moves the calls to
ai_manage_explorer() higher up in the API, into handle_unit_info() instead
of a subfunction of handle_unit_activity_request().

  - Per

Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.248
diff -u -r1.248 unithand.c
--- server/unithand.c   16 Jan 2003 23:16:12 -0000      1.248
+++ server/unithand.c   16 Jan 2003 23:37:50 -0000
@@ -627,6 +627,21 @@
                                          pinfo->activity,
                                          pinfo->activity_target,
                                          pinfo->select_it);
+    if (punit->moves_left > 0 && pinfo->activity == ACTIVITY_EXPLORE) {
+      int id = punit->id;
+      bool more_to_explore = ai_manage_explorer(punit);
+
+      if ((punit = find_unit_by_id(id))) {
+       if (more_to_explore) {
+         /* ai_manage_explorer sets the activity to idle, so we reset
+          * it. */
+         set_unit_activity(punit, ACTIVITY_EXPLORE);
+         send_unit_info(NULL, punit);
+       } else {
+         punit->ai.control = FALSE;
+       }
+      }
+    }
   }
 }
 
@@ -1248,21 +1263,8 @@
     break;
   case ACTIVITY_EXPLORE:
     punit->ai.control = TRUE;
-    if (punit->moves_left > 0) {
-      int id = punit->id;
-      bool more_to_explore = ai_manage_explorer(punit);
-
-      if ((punit = find_unit_by_id(id))) {
-       if (more_to_explore) {
-         /* ai_manage_explorer sets the activity to idle, so we reset
-          * it. */
-         set_unit_activity(punit, ACTIVITY_EXPLORE);
-         send_unit_info(NULL, punit);
-       } else {
-         punit->ai.control = FALSE;
-       }
-      }
-    }
+    set_unit_activity(punit, ACTIVITY_EXPLORE);
+    send_unit_info(NULL, punit);
     break;
   default:
     /* do nothing */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] another fix for explorer recursion (PR#2631), Per I. Mathisen via RT <=