Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2614) activate_all_units
Home

[Freeciv-Dev] (PR#2614) activate_all_units

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2614) activate_all_units
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Fri, 20 Dec 2002 00:15:58 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This patch provides a client-common code to activate all units on a
given tile.  It is called by citydlg code when "activate all units" is
selected.

The name could be questionable.

jason


Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.13
diff -u -r1.13 citydlg_common.c
--- client/citydlg_common.c     2002/12/15 22:43:46     1.13
+++ client/citydlg_common.c     2002/12/20 07:26:30
@@ -21,6 +21,7 @@
 #include "support.h"
 
 #include "citydlg_common.h"
+#include "control.h"
 #include "options.h"           /* for concise_city_production */
 #include "tilespec.h"          /* for is_isometric */
 
@@ -292,4 +293,25 @@
   }
 
   assert(i == pcity->size);
+}
+
+/**************************************************************************
+  Activate all units on the given map tile.
+**************************************************************************/
+void activate_all_units(int map_x, int map_y)
+{
+  struct unit_list *punit_list = &map_get_tile(map_x, map_y)->units;
+  struct unit *pmyunit = NULL;
+
+  unit_list_iterate((*punit_list), punit) {
+    if (game.player_idx == punit->owner) {
+      /* Activate this unit. */
+      pmyunit = punit;
+      request_new_unit_activity(punit, ACTIVITY_IDLE);
+    }
+  } unit_list_iterate_end;
+  if (pmyunit) {
+    /* Put the focus on one of the activated units. */
+    set_unit_focus(pmyunit);
+  }
 }
Index: client/citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.7
diff -u -r1.7 citydlg_common.h
--- client/citydlg_common.h     2002/12/15 22:43:46     1.7
+++ client/citydlg_common.h     2002/12/20 07:26:30
@@ -45,4 +45,6 @@
 void get_city_citizen_types(struct city *pcity, int index,
                            enum citizen_type *citizens);
 
+void activate_all_units(int map_x, int map_y);
+
 #endif /* FC__CITYDLG_COMMON_H */
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.149
diff -u -r1.149 citydlg.c
--- client/gui-gtk/citydlg.c    2002/12/15 22:43:46     1.149
+++ client/gui-gtk/citydlg.c    2002/12/20 07:26:31
@@ -2407,22 +2407,9 @@
 *****************************************************************/
 static void activate_all_units_callback(GtkWidget * w, gpointer data)
 {
-  struct city_dialog *pdialog = (struct city_dialog *) data;
-  int x = pdialog->pcity->x, y = pdialog->pcity->y;
-  struct unit_list *punit_list = &map_get_tile(x, y)->units;
-  struct unit *pmyunit = NULL;
+  struct city_dialog *pdialog = data;
 
-  if (unit_list_size(punit_list)) {
-    unit_list_iterate((*punit_list), punit) {
-      if (game.player_idx == punit->owner) {
-       pmyunit = punit;
-       request_new_unit_activity(punit, ACTIVITY_IDLE);
-      }
-    }
-    unit_list_iterate_end;
-    if (pmyunit)
-      set_unit_focus(pmyunit);
-  }
+  activate_all_units(pdialog->pcity->x, pdialog->pcity->y);
 }
 
 /****************************************************************
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.19
diff -u -r1.19 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        2002/12/15 22:43:47     1.19
+++ client/gui-gtk-2.0/citydlg.c        2002/12/20 07:26:31
@@ -2355,22 +2355,9 @@
 *****************************************************************/
 static void activate_all_units_callback(GtkWidget * w, gpointer data)
 {
-  struct city_dialog *pdialog = (struct city_dialog *) data;
-  int x = pdialog->pcity->x, y = pdialog->pcity->y;
-  struct unit_list *punit_list = &map_get_tile(x, y)->units;
-  struct unit *pmyunit = NULL;
+  struct city_dialog *pdialog = data;
 
-  if (unit_list_size(punit_list)) {
-    unit_list_iterate((*punit_list), punit) {
-      if (game.player_idx == punit->owner) {
-       pmyunit = punit;
-       request_new_unit_activity(punit, ACTIVITY_IDLE);
-      }
-    }
-    unit_list_iterate_end;
-    if (pmyunit)
-      set_unit_focus(pmyunit);
-  }
+  activate_all_units(pdialog->pcity->x, pdialog->pcity->y);
 }
 
 /****************************************************************
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.60
diff -u -r1.60 citydlg.c
--- client/gui-mui/citydlg.c    2002/12/15 22:43:47     1.60
+++ client/gui-mui/citydlg.c    2002/12/20 07:26:32
@@ -858,20 +858,8 @@
 static void city_activate_units(struct city_dialog **ppdialog)
 {
   struct city_dialog *pdialog = *ppdialog;
-  int x=pdialog->pcity->x,y=pdialog->pcity->y;
-  struct unit_list *punit_list = &map_get_tile(x,y)->units;
-  struct unit *pmyunit = NULL;
 
-  if(unit_list_size(punit_list))  {
-    unit_list_iterate((*punit_list), punit) {
-      if(game.player_idx==punit->owner) {
-       pmyunit = punit;
-       request_new_unit_activity(punit, ACTIVITY_IDLE);
-      }
-    } unit_list_iterate_end;
-    if (pmyunit)
-      set_unit_focus(pmyunit);
-  }
+  activate_all_units(pdialog->pcity->x, pdialog->pcity->y);
 }
 
 /**************************************************************************
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.41
diff -u -r1.41 citydlg.c
--- client/gui-win32/citydlg.c  2002/12/15 22:43:47     1.41
+++ client/gui-win32/citydlg.c  2002/12/20 07:26:32
@@ -1420,20 +1420,7 @@
 
 void activate_callback(struct city_dialog *pdialog)
 {
-  int x=pdialog->pcity->x,y=pdialog->pcity->y;
-  struct unit_list *punit_list = &map_get_tile(x,y)->units;
-  struct unit *pmyunit = NULL;
- 
-  if(unit_list_size(punit_list))  {
-    unit_list_iterate((*punit_list), punit) {
-      if(game.player_idx==punit->owner) {
-        pmyunit = punit;
-        request_new_unit_activity(punit, ACTIVITY_IDLE);
-      }
-    } unit_list_iterate_end;
-    if (pmyunit)
-      set_unit_focus(pmyunit);
-  }
+  activate_all_units(pdialog->pcity->x, pdialog->pcity->y);
 }      
 
 /****************************************************************
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.86
diff -u -r1.86 citydlg.c
--- client/gui-xaw/citydlg.c    2002/12/15 22:43:47     1.86
+++ client/gui-xaw/citydlg.c    2002/12/20 07:26:32
@@ -1073,20 +1073,8 @@
                       XtPointer call_data)
 {
   struct city_dialog *pdialog = (struct city_dialog *)client_data;
-  int x=pdialog->pcity->x,y=pdialog->pcity->y;
-  struct unit_list *punit_list = &map_get_tile(x,y)->units;
-  struct unit *pmyunit = NULL;
 
-  if( unit_list_size(punit_list) )  {
-    unit_list_iterate((*punit_list), punit) {
-      if(game.player_idx==punit->owner) {
-       request_new_unit_activity(punit, ACTIVITY_IDLE);
-       pmyunit = punit;
-      }
-    } unit_list_iterate_end;
-    if (pmyunit)
-      set_unit_focus(pmyunit);
-  }
+  activate_all_units(pdialog->pcity->x, pdialog->pcity->y);
 }
 
 

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