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

> From: Jonathan Landis <[EMAIL PROTECTED]>
>
>   I wrote a patch for the Win32 client a couple of weeks ago.

 Thanks for the patch, Jonathan.

 I cannot compile and I have not even seen win32 client, but I looked
some of the most obviously correct things from your patch. Attached is
two patches which I split from your patch and reworked a bit.
 I decided that since worklist_report had player pointer only for
accessing worklists and worklists no longer are part of player
structure, whole player pointer should go.
 Could you check that I have not made any mistakes (that it compiles
for example)? I plan to commit these two soon.
 I'll send another patch containing parts of the original patch that
were left out from these. They probably should go in later.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/gui-win32/helpdlg.c freeciv/client/gui-win32/helpdlg.c
--- freeciv/client/gui-win32/helpdlg.c	2006-10-31 18:28:41.000000000 +0200
+++ freeciv/client/gui-win32/helpdlg.c	2007-01-19 00:41:57.000000000 +0200
@@ -655,7 +655,7 @@
   
   /* Give tile a background color, based on the type of unit
    * FIXME: make a new set of colors for this.               */
-  switch (utype->move_type) {
+  switch (get_unit_move_type(utype)) {
   case LAND_MOVING: bg_color = COLOR_OVERVIEW_LAND;       break;
   case SEA_MOVING:  bg_color = COLOR_OVERVIEW_OCEAN;      break;
   case HELI_MOVING: bg_color = COLOR_OVERVIEW_MY_UNIT;    break;
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/menu.c freeciv/client/gui-win32/menu.c
--- freeciv/client/gui-win32/menu.c	2006-10-31 18:28:41.000000000 +0200
+++ freeciv/client/gui-win32/menu.c	2007-01-19 00:34:58.000000000 +0200
@@ -602,7 +602,7 @@
       popup_find_dialog();
       break;
     case IDM_GOVERNMENT_WORKLISTS:
-      popup_worklists_report(game.player_ptr);
+      popup_worklists_report();
       break;
     case IDM_GOVERNMENT_REVOLUTION:
       popup_revolution_dialog(NULL);
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/wldlg.c freeciv/client/gui-win32/wldlg.c
--- freeciv/client/gui-win32/wldlg.c	2006-07-17 23:56:51.000000000 +0300
+++ freeciv/client/gui-win32/wldlg.c	2007-01-19 00:39:09.000000000 +0200
@@ -37,7 +37,9 @@
 #include "log.h"
 #include "climisc.h"
 #include "clinet.h"
-                        
+
+#include "civclient.h"
+    
 #include "wldlg.h"
 #include "citydlg.h"
 
@@ -124,11 +126,11 @@
 
   /* Fill in the global worklists now?                      */
   /* perhaps judicious use of goto would be good here? -mck */
-  if (wl_first && game.player_ptr->worklists[0].is_valid && pcity) {
+  if (wl_first && client.worklists[0].is_valid && pcity) {
     int i;
 
     for (i = 0; i < MAX_NUM_WORKLISTS; i++) {
-      if (game.player_ptr->worklists[i].is_valid) {
+      if (client.worklists[i].is_valid) {
 	dest_wids[wids_used] = wid_encode(FALSE, TRUE, i);
 	wids_used++;
       }
@@ -147,11 +149,11 @@
   }
 
   /* we didn't fill in the global worklists above */
-  if (!wl_first && game.player_ptr->worklists[0].is_valid && pcity) {
+  if (!wl_first && client.worklists[0].is_valid && pcity) {
     int i;
 
     for (i = 0; i < MAX_NUM_WORKLISTS; i++) {
-      if (game.player_ptr->worklists[i].is_valid) {
+      if (client.worklists[i].is_valid) {
         dest_wids[wids_used] = wid_encode(FALSE, TRUE, i);
         wids_used++;
       }
@@ -169,7 +171,6 @@
 struct worklist_report {
   HWND win;
   HWND list;
-  struct player *pplr;
   char worklist_names[MAX_NUM_WORKLISTS][MAX_LEN_NAME];
   char *worklist_names_ptrs[MAX_NUM_WORKLISTS + 1];
   struct worklist *worklist_ptr[MAX_NUM_WORKLISTS];
@@ -235,10 +236,10 @@
   int i, n;
 
   for (i = 0, n = 0; i < MAX_NUM_WORKLISTS; i++) {
-    if (preport->pplr->worklists[i].is_valid) {
-      strcpy(preport->worklist_names[n], preport->pplr->worklists[i].name);
+    if (client.worklists[i].is_valid) {
+      strcpy(preport->worklist_names[n], client.worklists[i].name);
       preport->worklist_names_ptrs[n] = preport->worklist_names[n];
-      preport->worklist_ptr[n] = &preport->pplr->worklists[i];
+      preport->worklist_ptr[n] = &client.worklists[i];
 
       n++;
     }
@@ -268,18 +269,18 @@
 
   /* Look for the last free worklist */
   for (i = 0; i < MAX_NUM_WORKLISTS; i++)
-    if (!preport->pplr->worklists[i].is_valid)
+    if (!client.worklists[i].is_valid)
       break;
 
   for (j = sel; j < i - 1; j++) {
-    copy_worklist(&preport->pplr->worklists[j],
-                  &preport->pplr->worklists[j + 1]);
+    copy_worklist(&client.worklists[j],
+                  &client.worklists[j + 1]);
   }
 
   /* The last worklist in the set is no longer valid -- it's been slid up
    * one slot. */
-  preport->pplr->worklists[i-1].is_valid = FALSE;
-  strcpy(preport->pplr->worklists[i-1].name, "\0");
+  client.worklists[i-1].is_valid = FALSE;
+  strcpy(client.worklists[i-1].name, "\0");
 
   global_list_update(preport);
 }
@@ -292,9 +293,9 @@
   struct worklist_report *preport = (struct worklist_report *) data;
 
   if (preport) {
-    strncpy(preport->pplr->worklists[preport->wl_idx].name,
+    strncpy(client.worklists[preport->wl_idx].name,
             input_dialog_get_input(w), MAX_LEN_NAME);
-    preport->pplr->worklists[preport->wl_idx].name[MAX_LEN_NAME - 1] = '\0';
+    client.worklists[preport->wl_idx].name[MAX_LEN_NAME - 1] = '\0';
 
     global_list_update(preport);
   }
@@ -312,7 +313,7 @@
   /* Find the next free worklist for this player */
 
   for (j = 0; j < MAX_NUM_WORKLISTS; j++)
-    if (!preport->pplr->worklists[j].is_valid)
+    if (!client.worklists[j].is_valid)
       break;
 
   /* No more worklist slots free.  (!!!Maybe we should tell the user?) */
@@ -320,9 +321,9 @@
     return;
 
   /* Validate this slot. */
-  init_worklist(&preport->pplr->worklists[j]);
-  preport->pplr->worklists[j].is_valid = TRUE;
-  strcpy(preport->pplr->worklists[j].name, _("empty worklist"));
+  init_worklist(&client.worklists[j]);
+  client.worklists[j].is_valid = TRUE;
+  strcpy(client.worklists[j].name, _("empty worklist"));
 
   global_list_update(preport);
 }
@@ -361,7 +362,7 @@
 	input_dialog_create(hwnd,
 			    _("Rename Worklist"),
 			    _("What should the new name be?"),
-			    preport->pplr->worklists[preport->wl_idx].name,
+			    client.worklists[preport->wl_idx].name,
 			    (void *) global_rename_sub_callback,
 			    (void *) preport,
 			    (void *) global_rename_sub_callback,
@@ -401,16 +402,14 @@
 /****************************************************************
   Bring up the global worklist report.
 *****************************************************************/
-void popup_worklists_report(struct player *pplr)
+void popup_worklists_report(void)
 {
   struct fcwin_box *vbox;
   struct fcwin_box *hbox;
   if (report_dialog && report_dialog->win)
     return;
   assert(!report_dialog);
-  assert(pplr);
   report_dialog = fc_malloc(sizeof(struct worklist_report));
-  report_dialog->pplr = pplr;
   report_dialog->win=fcwin_create_layouted_window(global_wl_proc,
 						  _("Edit worklists"),
 						  WS_OVERLAPPEDWINDOW,
@@ -487,7 +486,7 @@
 {
   struct worklist_report *preport = (struct worklist_report *) data;
   
-  copy_worklist(&preport->pplr->worklists[preport->wl_idx], pwl);
+  copy_worklist(&client.worklists[preport->wl_idx], pwl);
 }
 
 /****************************************************************
@@ -631,8 +630,7 @@
   
   /* target is a global worklist id */
   if (wid_is_worklist(wid)) {
-    struct player *pplr = city_owner(peditor->pcity);
-    struct worklist *pwl = &pplr->worklists[wid_id(wid)];
+    struct worklist *pwl = &client.worklists[wid_id(wid)];
 
     copy_worklist_to_editor(pwl, peditor, where);
     where += worklist_length(pwl);
@@ -1053,7 +1051,6 @@
 static void targets_list_update(struct worklist_editor *peditor)
 {
   int i = 0, wids_used = 0;
-  struct player *pplr = game.player_ptr;
   int advanced_tech;
   char *row[COLUMNS];
   char buf[COLUMNS][BUFFER_SIZE];
@@ -1084,7 +1081,7 @@
 
     if (wid_is_worklist(wid)) {
       my_snprintf(buf[0], BUFFER_SIZE, "%s",
-		  pplr->worklists[wid_id(wid)].name);
+		  client.worklists[wid_id(wid)].name);
       my_snprintf(buf[1], BUFFER_SIZE, _("Worklist"));
       my_snprintf(buf[2], BUFFER_SIZE, "---");
       my_snprintf(buf[3], BUFFER_SIZE, "---");
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/wldlg.h freeciv/client/gui-win32/wldlg.h
--- freeciv/client/gui-win32/wldlg.h	2006-07-17 23:56:51.000000000 +0300
+++ freeciv/client/gui-win32/wldlg.h	2007-01-19 00:34:26.000000000 +0200
@@ -28,7 +28,7 @@
 
 void popup_worklist(struct worklist_window_init *init);
 
-void popup_worklists_report(struct player *pplr);
+void popup_worklists_report(void);
                                         /* The global worklist view */ 
 void update_worklist_report_dialog(void);
 void update_worklist_editor_win(HWND win);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to