Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13603) rename collect functions
Home

[Freeciv-Dev] (PR#13603) rename collect functions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13603) rename collect functions
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 3 Aug 2005 09:53:43 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch renames the collect_cidsN function to not be so completely 
terrible.  I can't make any guarantee as to the accuraccy of the new 
names, because the documentation on them is poor ("Collect the cids of 
all targets which can be build by this city or in general" - what is the 
purpose) and it would take a good bit of effort to understand some of 
these functions.  I'm very tempted just to delete some (ideally, all but 
one) of the functions.

<rant>As you may gather this code is very frustrating.  Whoever wrote 
these names (naming no names, ahem) should never be allowed to name 
another function, ever.  We should have a policy that it is not allowed 
to give differently-behaving functions identical names with only a 
number to distinguish them.  We had the same problem with 
can_player_see_unit_at...a new feature was added and instead of fixing 
the original function a new function can_player_see_unit_at2 was added 
which eventually came to replace the original function.  Terrible.</rant>

-jason

? diff
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.176
diff -p -u -r1.176 climisc.c
--- client/climisc.c    3 Aug 2005 16:38:26 -0000       1.176
+++ client/climisc.c    3 Aug 2005 16:45:27 -0000
@@ -636,10 +636,10 @@ void name_and_sort_items(int *pcids, int
 /**************************************************************************
 ...
 **************************************************************************/
-int collect_cids1(cid * dest_cids, struct city **selected_cities,
-                 int num_selected_cities, bool append_units,
-                 bool append_wonders, bool change_prod,
-                 TestCityFunc test_func)
+int collect_production_targets(cid * dest_cids, struct city **selected_cities,
+                              int num_selected_cities, bool append_units,
+                              bool append_wonders, bool change_prod,
+                              TestCityFunc test_func)
 {
   cid first = append_units ? B_LAST : 0;
   cid last = (append_units
@@ -682,7 +682,7 @@ int collect_cids1(cid * dest_cids, struc
  Collect the cids of all targets (improvements and units) which are
  currently built in a city.
 **************************************************************************/
-int collect_cids2(cid * dest_cids)
+int collect_currently_building_targets(cid * dest_cids)
 {
   bool mapping[B_LAST + U_LAST];
   int cids_used = 0;
@@ -707,7 +707,7 @@ int collect_cids2(cid * dest_cids)
  Collect the cids of all targets (improvements and units) which can
  be build in a city.
 **************************************************************************/
-int collect_cids3(cid * dest_cids)
+int collect_buildable_targets(cid * dest_cids)
 {
   int cids_used = 0;
 
@@ -732,7 +732,9 @@ int collect_cids3(cid * dest_cids)
  Collect the cids of all targets which can be build by this city or
  in general.
 **************************************************************************/
-int collect_cids4(cid * dest_cids, struct city *pcity, bool advanced_tech)
+int collect_eventually_buildable_targets(cid * dest_cids,
+                                        struct city *pcity,
+                                        bool advanced_tech)
 {
   int cids_used = 0;
 
@@ -780,7 +782,7 @@ int collect_cids4(cid * dest_cids, struc
 /**************************************************************************
  Collect the cids of all improvements which are built in the given city.
 **************************************************************************/
-int collect_cids5(cid * dest_cids, struct city *pcity)
+int collect_already_built_targets(cid * dest_cids, struct city *pcity)
 {
   int cids_used = 0;
 
Index: client/climisc.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.h,v
retrieving revision 1.59
diff -p -u -r1.59 climisc.h
--- client/climisc.h    3 Aug 2005 16:38:26 -0000       1.59
+++ client/climisc.h    3 Aug 2005 16:45:27 -0000
@@ -76,14 +76,16 @@ typedef bool (*TestCityFunc)(const struc
 
 void name_and_sort_items(int *pcids, int num_cids, struct item *items,
                         bool show_cost, struct city *pcity);
-int collect_cids1(cid * dest_cids, struct city **selected_cities,
-                int num_selected_cities, bool append_units,
-                bool append_wonders, bool change_prod,
-                 TestCityFunc test_func);
-int collect_cids2(cid * dest_cids);
-int collect_cids3(cid * dest_cids);
-int collect_cids4(cid * dest_cids, struct city *pcity, bool advanced_tech);
-int collect_cids5(cid * dest_cids, struct city *pcity);
+int collect_production_targets(cid * dest_cids, struct city **selected_cities,
+                              int num_selected_cities, bool append_units,
+                              bool append_wonders, bool change_prod,
+                              TestCityFunc test_func);
+int collect_currently_building_targets(cid * dest_cids);
+int collect_buildable_targets(cid * dest_cids);
+int collect_eventually_buildable_targets(cid * dest_cids,
+                                        struct city *pcity,
+                                        bool advanced_tech);
+int collect_already_built_targets(cid * dest_cids, struct city *pcity);
 
 /* the number of units in city */
 int num_present_units_in_city(struct city* pcity);
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.138
diff -p -u -r1.138 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        3 Aug 2005 16:19:07 -0000       1.138
+++ client/gui-gtk-2.0/citydlg.c        3 Aug 2005 16:45:28 -0000
@@ -1551,7 +1551,7 @@ static void city_dialog_update_building(
                            -1);
   gtk_list_store_clear(store);
 
-  cids_used = collect_cids4(cids, pdialog->pcity, FALSE);  
+  cids_used = collect_eventually_buildable_targets(cids, pdialog->pcity, 
FALSE);  
   name_and_sort_items(cids, cids_used, items, FALSE, pcity);
 
   for (item = 0; item < cids_used; item++) {
@@ -1593,7 +1593,7 @@ static void city_dialog_update_improveme
     gtk_tree_view_get_model(GTK_TREE_VIEW(pdialog->overview.improvement_list));
   store = GTK_LIST_STORE(model);
   
-  cids_used = collect_cids5(cids, pdialog->pcity);
+  cids_used = collect_already_built_targets(cids, pdialog->pcity);
   name_and_sort_items(cids, cids_used, items, FALSE, pdialog->pcity);
 
   gtk_list_store_clear(store);  
Index: client/gui-gtk-2.0/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cityrep.c,v
retrieving revision 1.77
diff -p -u -r1.77 cityrep.c
--- client/gui-gtk-2.0/cityrep.c        3 Aug 2005 16:19:07 -0000       1.77
+++ client/gui-gtk-2.0/cityrep.c        3 Aug 2005 16:45:28 -0000
@@ -237,11 +237,11 @@ static void append_impr_or_unit_to_menu_
     }
 
     data = (struct city **)g_ptr_array_free(selected, FALSE);
-    cids_used = collect_cids1(cids, data, num_selected, append_units,
+    cids_used = collect_production_targets(cids, data, num_selected, 
append_units,
                              append_wonders, TRUE, test_func);
     g_free(data);
   } else {
-    cids_used = collect_cids1(cids, NULL, 0, append_units,
+    cids_used = collect_production_targets(cids, NULL, 0, append_units,
                              append_wonders, FALSE, test_func);
   }
 
Index: client/gui-gtk-2.0/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/wldlg.c,v
retrieving revision 1.49
diff -p -u -r1.49 wldlg.c
--- client/gui-gtk-2.0/wldlg.c  3 Aug 2005 16:19:07 -0000       1.49
+++ client/gui-gtk-2.0/wldlg.c  3 Aug 2005 16:45:28 -0000
@@ -1360,7 +1360,7 @@ void refresh_worklist(GtkWidget *editor)
   }
   gtk_list_store_clear(ptr->src);
 
-  cids_used = collect_cids4(cids, ptr->pcity, ptr->future);
+  cids_used = collect_eventually_buildable_targets(cids, ptr->pcity, 
ptr->future);
   name_and_sort_items(cids, cids_used, items, FALSE, ptr->pcity);
 
   path = NULL;
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.106
diff -p -u -r1.106 citydlg.c
--- client/gui-win32/citydlg.c  26 Jul 2005 16:35:58 -0000      1.106
+++ client/gui-win32/citydlg.c  3 Aug 2005 16:45:28 -0000
@@ -252,7 +252,7 @@ void city_dialog_update_improvement_list
     pdialog->last_improvlist_seen[i] = pdialog->pcity->improvements[i];
   } impr_type_iterate_end;
   
-  cids_used = collect_cids5(cids, pdialog->pcity);
+  cids_used = collect_already_built_targets(cids, pdialog->pcity);
   name_and_sort_items(cids, cids_used, items, FALSE, pdialog->pcity);
    
   ListView_DeleteAllItems(pdialog->buildings_list);
Index: client/gui-win32/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/cityrep.c,v
retrieving revision 1.37
diff -p -u -r1.37 cityrep.c
--- client/gui-win32/cityrep.c  23 Apr 2005 17:40:26 -0000      1.37
+++ client/gui-win32/cityrep.c  3 Aug 2005 16:45:29 -0000
@@ -205,7 +205,7 @@ append_impr_or_unit_to_menu_sub(HMENU me
     }
   }
 
-  cids_used = collect_cids1(cids, selected_cities,
+  cids_used = collect_production_targets(cids, selected_cities,
                            num_selected_cities, append_units,
                            append_wonders, change_prod, test_func);
   if (selected_cities) {
@@ -766,7 +766,7 @@ static void cityrep_changeall(HWND hWnd)
                                                 selid));
   }
 
-  cids_used = collect_cids2(cids);
+  cids_used = collect_currently_building_targets(cids);
   name_and_sort_items(cids, cids_used, items, FALSE, NULL);
 
   hLst = GetDlgItem(hDlg, ID_PRODCHANGE_FROM);
@@ -777,7 +777,7 @@ static void cityrep_changeall(HWND hWnd)
       ListBox_SetCurSel(hLst, id);
   }
 
-  cids_used = collect_cids3(cids);
+  cids_used = collect_buildable_targets(cids);
   name_and_sort_items(cids, cids_used, items, TRUE, NULL);
 
   hLst = GetDlgItem(hDlg, ID_PRODCHANGE_TO);
Index: client/gui-win32/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/wldlg.c,v
retrieving revision 1.20
diff -p -u -r1.20 wldlg.c
--- client/gui-win32/wldlg.c    3 Aug 2005 16:38:26 -0000       1.20
+++ client/gui-win32/wldlg.c    3 Aug 2005 16:45:30 -0000
@@ -136,7 +136,7 @@ static int collect_wids1(wid * dest_wids
   }
 
   /* Fill in improvements and units */
-  cids_used = collect_cids4(cids, pcity, advanced_tech);
+  cids_used = collect_eventually_buildable_targets(cids, pcity, advanced_tech);
   name_and_sort_items(cids, cids_used, items, FALSE, pcity);
 
   for (item = 0; item < cids_used; item++) {
Index: client/gui-xaw/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/cityrep.c,v
retrieving revision 1.62
diff -p -u -r1.62 cityrep.c
--- client/gui-xaw/cityrep.c    28 Jul 2005 18:03:59 -0000      1.62
+++ client/gui-xaw/cityrep.c    3 Aug 2005 16:45:30 -0000
@@ -1082,7 +1082,7 @@ static void chgall_refresh_command_callb
   struct item items[U_LAST + B_LAST];
   int i;
 
-  state->fr_count = collect_cids2(cids);
+  state->fr_count = collect_currently_building_targets(cids);
   name_and_sort_items(cids, state->fr_count, items, FALSE, NULL);
   for (i = 0; i < state->fr_count; i++) {
     state->fr_list[i] = mystrdup(items[i].descr);
@@ -1090,7 +1090,7 @@ static void chgall_refresh_command_callb
   }
   XawListChange(state->w.fr, state->fr_list, state->fr_count, 0, FALSE);
 
-  state->to_count = collect_cids3(cids);
+  state->to_count = collect_buildable_targets(cids);
   name_and_sort_items(cids, state->to_count, items, TRUE, NULL);
   for (i = 0; i < state->to_count; i++) {
     state->to_list[i] = mystrdup(items[i].descr);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13603) rename collect functions, Jason Short <=