Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#15747) gui-win32 compile fix
Home

[Freeciv-Dev] (PR#15747) gui-win32 compile fix

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15747) gui-win32 compile fix
From: "Christian Prochaska" <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Sun, 30 Jul 2006 14:40:59 -0700
Reply-to: bugs@xxxxxxxxxxx

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

updated patch for current S2_1.

I don't plan to work on this client, but since it's not really broken
yet, I think it should be in a compileable state in the 2.1 release.
Index: client/gui-win32/citydlg.c
===================================================================
--- client/gui-win32/citydlg.c  (revision 12170)
+++ client/gui-win32/citydlg.c  (working copy)
@@ -4,7 +4,7 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.
- 
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -30,6 +30,7 @@
 #include "player.h"
 #include "shared.h"
 #include "support.h"
+#include "unitlist.h"
 
 #include "canvas.h"
 #include "climap.h"
Index: client/gui-win32/connectdlg.c
===================================================================
--- client/gui-win32/connectdlg.c       (revision 12170)
+++ client/gui-win32/connectdlg.c       (working copy)
@@ -59,12 +59,14 @@
 #include "gui_main.h"
 
 static enum {
-  LOGIN_TYPE, 
-  NEW_PASSWORD_TYPE, 
+  LOGIN_TYPE,
+  NEW_PASSWORD_TYPE,
   VERIFY_PASSWORD_TYPE,
   ENTER_PASSWORD_TYPE
 } dialog_config;
 
+extern void popup_settable_options_dialog(void);
+
 static HWND connect_dlg;
 static HWND start_dlg;
 static HWND newgame_dlg;
@@ -78,7 +80,6 @@
 static HWND server_listview;
 static HWND lan_listview;
 
-static int autoconnect_timer_id;
 struct t_server_button {
   HWND button;
   char *button_string;
@@ -103,6 +104,7 @@
 
 static int num_lanservers_timer = 0;
 
+struct server_scan *lan = NULL, *meta = NULL;
 
 /*************************************************************************
  configure the dialog depending on what type of authentication request the
@@ -343,7 +345,7 @@
   Callback function for network subwindow messages
 **************************************************************************/
 static LONG CALLBACK networkdlg_proc(HWND hWnd, UINT message, WPARAM wParam,
-                                    LPARAM lParam)  
+                                    LPARAM lParam)
 {
   LPNMHDR nmhdr;
   switch(message)
@@ -395,7 +397,7 @@
     default:
       return DefWindowProc(hWnd, message, wParam, lParam); 
     }
-  return FALSE;  
+  return FALSE;
 }
 
 /**************************************************************************
@@ -498,11 +500,41 @@
 }
 
 /**************************************************************************
+  Callback function for when there's an error in the server scan.
+**************************************************************************/
+static void server_scan_error(struct server_scan *scan,
+                             const char *message)
+{
+  append_output_window(message);
+  freelog(LOG_NORMAL, "%s", message);
+  switch (server_scan_get_type(scan)) {
+  case SERVER_SCAN_LOCAL:
+    server_scan_finish(lan);
+    lan = NULL;
+    break;
+  case SERVER_SCAN_GLOBAL:
+    server_scan_finish(meta);
+    meta = NULL;
+    break;
+  case SERVER_SCAN_LAST:
+    break;
+  }
+}
+
+/**************************************************************************
  This function updates the list of LAN servers every 100 ms for 5 seconds. 
 **************************************************************************/
 static int get_lanservers(HWND list)
 {
-  struct server_list *server_list = get_lan_server_list();
+  struct server_list *server_list = NULL;
+
+  if (lan) {
+    server_list = server_scan_get_servers(lan);
+    if (!server_list) {
+      return -1;
+    }
+  }
+
   char *row[6];
 
   if (server_list != NULL) {
@@ -531,7 +563,7 @@
 
   num_lanservers_timer++;
   if (num_lanservers_timer == 50) {
-    finish_lanserver_scan();
+    server_scan_finish(lan);
     num_lanservers_timer = 0;
     return 0;
   }
@@ -541,14 +573,24 @@
 /**************************************************************************
 
  *************************************************************************/
-static int get_meta_list(HWND list, char *errbuf, int n_errbuf)
+static int get_meta_list(HWND list)
 {
   int i;
   char *row[6];
   char  buf[6][64];
 
-  struct server_list *server_list = create_server_list(errbuf, n_errbuf);
+  struct server_list *server_list = NULL;
 
+  if (meta) {
+    for (i = 0; i < 100; i++) {
+      server_list = server_scan_get_servers(meta);
+      if (server_list) {
+        break;
+      }
+      Sleep(100);
+    }
+  }
+
   if (!server_list) {
     return -1;
   }
@@ -567,7 +609,7 @@
     sz_strlcpy(buf[5], pserver->message);
     fcwin_listview_add_row(list, 0, 6, row);
   } server_list_iterate_end;
-  
+
   ListView_SetColumnWidth(list, 0, LVSCW_AUTOSIZE);
   ListView_SetColumnWidth(list, 1, LVSCW_AUTOSIZE);
   ListView_SetColumnWidth(list, 2, LVSCW_AUTOSIZE);
@@ -575,8 +617,6 @@
   ListView_SetColumnWidth(list, 4, LVSCW_AUTOSIZE);
   ListView_SetColumnWidth(list, 5, LVSCW_AUTOSIZE);
 
-  delete_server_list(server_list);
-
   return 0;
 }
 
@@ -624,14 +664,18 @@
       break;
     case WM_COMMAND:
       if (LOWORD(wParam)==IDOK) {
-       char errbuf[128];
        if (TabCtrl_GetCurSel(tab_ctrl) == 2) {
+          if (!lan) {
+            lan = server_scan_begin(SERVER_SCAN_LOCAL, server_scan_error);
+          }
          get_lanservers(lan_listview);
        } else {
-         if (get_meta_list(server_listview, errbuf, sizeof(errbuf)) == -1) {
-           append_output_window(errbuf);
-         }
-       }
+          if (!meta) {
+            meta = server_scan_begin(SERVER_SCAN_GLOBAL, server_scan_error);
+          }
+          Sleep(500);
+         get_meta_list(server_listview);
+       }
       }
       break;
     case WM_NOTIFY:
@@ -842,6 +886,15 @@
 **************************************************************************/
 static void cdlg_del(void *data)
 {
+  if (lan) {
+    server_scan_finish(lan);
+    lan = NULL;
+  }
+  if (meta) {
+    server_scan_finish(meta);
+    meta = NULL;
+  }
+
   DestroyWindow(network_dlg);
   DestroyWindow(start_dlg);
   DestroyWindow(players_dlg);
Index: client/gui-win32/dialogs.c
===================================================================
--- client/gui-win32/dialogs.c  (revision 12170)
+++ client/gui-win32/dialogs.c  (working copy)
@@ -22,7 +22,7 @@
 #include <windows.h>
 #include <windowsx.h>
 #include <commctrl.h>
- 
+
 #include "capability.h"
 #include "fcintl.h"
 #include "game.h"
@@ -34,6 +34,7 @@
 #include "player.h"
 #include "rand.h"
 #include "support.h"
+#include "unitlist.h"
  
 #include "civclient.h"
 #include "clinet.h"
@@ -97,7 +98,7 @@
   HWND label;
   HWND main;
   struct fcwin_box *vbox;
-  struct message_dialog_button *firstbutton; 
+  struct message_dialog_button *firstbutton;
 };
 
 static HWND races_dlg;
@@ -118,7 +119,7 @@
 
 
 
-int diplomat_dialog_open = 0;
+static HWND diplomat_dialog;
 int diplomat_id;
 int diplomat_target_id;
 static LONG APIENTRY msgdialog_proc(HWND hWnd,
@@ -205,7 +206,7 @@
       break;
     case WM_CLOSE:
       DestroyWindow(hWnd);
-      
+
       break;
     case WM_COMMAND:
       if (LOWORD(wParam)==ID_NOTIFY_CLOSE)
@@ -349,7 +350,7 @@
  
   ComboBox_GetText(GetDlgItem(hWnd,ID_RACESDLG_LEADER),
                   name,MAX_LEN_NAME);
- 
+
   if (strlen(name) == 0) {
     append_output_window(_("You must type a legal name."));
     return;
@@ -482,7 +483,7 @@
       continue;
     }
 
-    if (group != NULL && !nation_in_group(pnation, group->name)) {
+    if (group != NULL && !is_nation_in_group(pnation, group->name)) {
       continue;
     }
 
@@ -1070,17 +1071,26 @@
   
 }
 
-bool caravan_dialog_is_open(void)
+bool caravan_dialog_is_open( int* unit_id, int* city_id)
 {
-  return BOOL_VAL(caravan_dialog);          
+  return BOOL_VAL(caravan_dialog);
 }
+
 /****************************************************************
+  Updates caravan dialog
+****************************************************************/
+void caravan_dialog_update(void)
+{
+  /* PORT ME */
+}
+
+/****************************************************************
 ...
 *****************************************************************/
 static void diplomat_investigate_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
  
   if(find_unit_by_id(diplomat_id) &&
      (find_city_by_id(diplomat_target_id))) {
@@ -1096,7 +1106,7 @@
 static void diplomat_steal_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
  
   if(find_unit_by_id(diplomat_id) &&
      find_city_by_id(diplomat_target_id)) {
@@ -1112,7 +1122,7 @@
 static void diplomat_sabotage_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
  
   if(find_unit_by_id(diplomat_id) &&
      find_city_by_id(diplomat_target_id)) {
@@ -1126,7 +1136,7 @@
 static void diplomat_embassy_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
  
   if(find_unit_by_id(diplomat_id) &&
      (find_city_by_id(diplomat_target_id))) {
@@ -1153,7 +1163,7 @@
 static void spy_poison_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
 
   if(find_unit_by_id(diplomat_id) &&
      (find_city_by_id(diplomat_target_id))) {
@@ -1266,7 +1276,7 @@
 pvictim to NULL and account for !pvictim in create_advances_list. -- Syela */
   
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
   if(!spy_tech_dialog){
     HWND lb;
     struct fcwin_box *hbox;
@@ -1303,7 +1313,7 @@
 static void spy_request_sabotage_list(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
 
   if(find_unit_by_id(diplomat_id) &&
      (find_city_by_id(diplomat_target_id))) {
@@ -1524,7 +1534,7 @@
 static void diplomat_incite_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open = 0;
+  diplomat_dialog = 0;
 
   if (find_unit_by_id(diplomat_id) && find_city_by_id(diplomat_target_id)) {
     dsend_packet_city_incite_inq(&aconnection, diplomat_target_id);
@@ -1569,7 +1579,7 @@
 static void diplomat_cancel_callback(HWND w, void * data)
 {
   destroy_message_dialog(w);
-  diplomat_dialog_open=0;
+  diplomat_dialog=0;
 
   process_diplomat_arrival(NULL, 0);
 }
@@ -1627,7 +1637,7 @@
                _("Incite a _Revolt"), diplomat_incite_callback, 0,
                _("_Cancel"), diplomat_cancel_callback, 0,
                0);
- 
+
       if (!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, ptile))
        message_dialog_button_set_sensitive(shl,0,FALSE);
       if (!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, ptile))
@@ -1642,13 +1652,13 @@
        message_dialog_button_set_sensitive(shl,5,FALSE);
      }
 
-    diplomat_dialog_open=1;
-   }else{ 
+    diplomat_dialog=shl;
+   }else{
      if ((ptunit = unit_list_get(ptile->units, 0))){
-       /* Spy/Diplomat acting against a unit */ 
-       
+       /* Spy/Diplomat acting against a unit */
+
        diplomat_target_id=ptunit->id;
- 
+
        shl=popup_message_dialog(root_window, /*"spybribedialog"*/_("Subvert 
Enemy Unit"),
                               (!unit_flag(punit, F_SPY))?
                              _("Sir, the diplomat is waiting for your 
command"):
@@ -1657,7 +1667,7 @@
                              _("_Sabotage Enemy Unit"), 
spy_sabotage_unit_callback, 0,
                              _("_Cancel"), diplomat_cancel_callback, 0,
                              0);
-        
+
        if (!diplomat_can_do_action(punit, DIPLOMAT_BRIBE, ptile))
         message_dialog_button_set_sensitive(shl,0,FALSE);
        if (!diplomat_can_do_action(punit, SPY_SABOTAGE_UNIT, ptile))
@@ -1667,13 +1677,26 @@
 }
 
 /****************************************************************
-...
+  Returns id of a diplomat currently handled in diplomat dialog
 *****************************************************************/
-bool diplomat_dialog_is_open(void)
+int diplomat_handled_in_diplomat_dialog(void)
 {
-  return diplomat_dialog_open;
+  if (diplomat_dialog == 0) {
+    return -1;
+  }
+  return diplomat_id;
 }
 
+/****************************************************************
+  Closes the diplomat dialog
+****************************************************************/
+void close_diplomat_dialog(void)
+{
+  if (diplomat_dialog != 0) {
+    destroy_message_dialog(diplomat_dialog);
+    diplomat_dialog = 0;
+  }
+}
 
 /**************************************************************************
 
Index: client/gui-win32/gotodlg.c
===================================================================
--- client/gui-win32/gotodlg.c  (revision 12170)
+++ client/gui-win32/gotodlg.c  (working copy)
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -28,11 +28,13 @@
 #include "player.h"
 #include "support.h"
 #include "unit.h"
+#include "unitlist.h"
 
 #include "clinet.h"
 #include "civclient.h"
 #include "control.h"
 #include "dialogs.h"
+#include "goto.h"
 #include "gui_main.h"
 #include "gui_stuff.h"
 #include "mapview.h"
@@ -79,7 +81,7 @@
        {
        case ID_LIST:
          if((pdestcity=get_selected_city())) {
-           struct unit *punit=get_unit_in_focus();
+           struct unit *punit=unit_list_get(get_units_in_focus(), 0);
            center_tile_mapcanvas(pdestcity->tile);
            if(punit && unit_can_airlift_to(punit, pdestcity)) {
              EnableWindow(GetDlgItem(dlg,ID_AIRLIFT),TRUE);
@@ -97,11 +99,10 @@
          {
            pdestcity=get_selected_city();
            if (pdestcity) {
-             struct unit *punit=get_unit_in_focus();
-             if (punit) {
-               send_goto_tile(punit, pdestcity->tile);
-               DestroyWindow(dlg);
-             }
+             unit_list_iterate(get_units_in_focus(), punit) {
+               send_goto_tile(punit, pdestcity->tile);
+       } unit_list_iterate_end;
+                   DestroyWindow(dlg);
            }
          }
          break;
@@ -109,13 +110,12 @@
          {
            pdestcity=get_selected_city();
            if (pdestcity) {
-             struct unit *punit=get_unit_in_focus();
-             if (punit) {
-               request_unit_airlift(punit, pdestcity);
-               DestroyWindow(dlg);
-             }
+             unit_list_iterate(get_units_in_focus(), punit) {
+          request_unit_airlift(punit, pdestcity);
+       } unit_list_iterate_end;
+        DestroyWindow(dlg);
            }
-        
+
          }
          break;
        case IDCANCEL:
@@ -143,11 +143,12 @@
   if (!can_client_change_view()) {
     return;
   }
-  if (get_unit_in_focus()==0)
+  if (get_num_units_in_focus()==0) {
     return;
+  }
 
   original_tile = get_center_tile_mapcanvas();
-  
+
   goto_dialog=fcwin_create_layouted_window(goto_dialog_proc,
                                           _("Goto/Airlift Unit"),
                                           WS_OVERLAPPEDWINDOW,
Index: client/gui-win32/happiness.c
===================================================================
--- client/gui-win32/happiness.c        (revision 12170)
+++ client/gui-win32/happiness.c        (working copy)
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -243,7 +243,7 @@
   struct city *pcity = pdialog->pcity;
   struct government *g = get_gov_pcity(pcity);
   int mlmax = get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX);
-  int uhcfac = g->unit_happy_cost_factor;
+  int uhcfac = get_player_bonus(city_owner(pcity), EFT_UNHAPPY_FACTOR);
 
   my_snprintf(bptr, nleft, _("Units: "));
   bptr = end_of_strn(bptr, &nleft);
Index: client/gui-win32/helpdlg.c
===================================================================
--- client/gui-win32/helpdlg.c  (revision 12170)
+++ client/gui-win32/helpdlg.c  (working copy)
@@ -52,9 +52,6 @@
 #define ID_HELP_IMPROVEMENT_LINK 112
 #define ID_HELP_WONDER_LINK 113
 
-/* HACK: we use a static string for convenience. */
-static char long_buffer[64000];
-
 extern HINSTANCE freecivhinst;
 extern HWND root_window;
 static HWND helpdlg_win;
@@ -96,7 +93,7 @@
 char *help_tlabel_name[4][5] =
 {
     { N_("Move/Defense:"),   NULL, NULL, N_("Food/Res/Trade:"),   NULL },
-    { N_("Sp1 F/R/T:"),      NULL, NULL, N_("Sp2 F/R/T:"),        NULL },
+    { N_("Resources:"),      NULL, NULL, NULL                 ,   NULL },
     { N_("Road Rslt/Time:"), NULL, NULL, N_("Irrig. Rslt/Time:"), NULL },
     { N_("Mine Rslt/Time:"), NULL, NULL, N_("Trans. Rslt/Time:"), NULL }
 };                                 
@@ -431,7 +428,7 @@
                                           NULL,
                                           JUST_CLEANUP,
                                           NULL);
-  
+
   helpdlg_hbox=fcwin_hbox_new(helpdlg_win,FALSE);
   vbox=fcwin_vbox_new(helpdlg_win,FALSE);
   helpdlg_topic=fcwin_box_add_static(vbox,"",0,SS_LEFT,
@@ -559,8 +556,8 @@
 static void help_update_terrain(const struct help_item *pitem,
                                char *title, struct terrain *pterrain)
 {
-  char *buf = &long_buffer[0];
-  
+  char buf[64000];
+
   create_help_page(HELP_TERRAIN);
 
   if (pterrain) {
@@ -576,34 +573,19 @@
            pterrain->output[O_TRADE]);
     SetWindowText(help_tlabel[0][4], buf);
 
-    if (*(pterrain->special[0].name)) {
-      sprintf(buf, _("%s F/R/T:"),
-             pterrain->special[0].name);
-      SetWindowText(help_tlabel[1][0], buf);
-      sprintf(buf, "%d/%d/%d",
-             pterrain->special[0].output[O_FOOD],
-             pterrain->special[0].output[O_SHIELD],
-             pterrain->special[0].output[O_TRADE]);
-      SetWindowText(help_tlabel[1][1], buf);
+    buf[0] = '\0';
+    if (*(pterrain->resources)) {
+      const struct resource **r;
+      for (r = pterrain->resources; *r; r++) {
+       sprintf (buf + strlen (buf), " %s,", _((*r)->name));
+      }
+      buf[strlen (buf) - 1] = '.';
     } else {
-      SetWindowText(help_tlabel[1][0], " ");
-      SetWindowText(help_tlabel[1][1], " ");
+      /* TRANS: (none) as in "Resources: (none)". */
+      sprintf (buf + strlen (buf), _("(none)"));
     }
+    SetWindowText(help_tlabel[1][1], buf);
 
-    if (*(pterrain->special[1].name)) {
-      sprintf(buf, _("%s F/R/T:"),
-             pterrain->special[1].name);
-      SetWindowText(help_tlabel[1][3], buf);
-      sprintf(buf, "%d/%d/%d",
-             pterrain->special[1].output[O_FOOD],
-             pterrain->special[1].output[O_SHIELD],
-             pterrain->special[1].output[O_TRADE]);
-      SetWindowText(help_tlabel[1][4], buf);
-    } else {
-      SetWindowText(help_tlabel[1][3], " ");
-      SetWindowText(help_tlabel[1][4], " ");
-    }
-
     if (pterrain->road_trade_incr > 0) {
       sprintf(buf, _("+%d Trade / %d"),
              pterrain->road_trade_incr,
@@ -654,7 +636,7 @@
     SetWindowText(help_tlabel[3][4], buf);
   }
 
-  helptext_terrain(buf, pterrain, pitem->text);
+  helptext_terrain(buf, sizeof(buf), pterrain, pitem->text);
   set_help_text(buf);
 }
 
@@ -701,7 +683,7 @@
 static void help_update_unit_type(const struct help_item *pitem,
                                  char *title, struct unit_type *utype)
 {
-  char *buf = &long_buffer[0];
+  char buf[64000];
   create_help_page(HELP_UNIT);
 
   drawn_unit_type = utype;
@@ -720,7 +702,7 @@
     sprintf(buf, "%d", utype->hp);
     SetWindowText(help_ulabel[2][4], buf);
     SetWindowText(help_ulabel[3][1], helptext_unit_upkeep_str(utype));
-    sprintf(buf, "%d", utype->vision_range);
+    sprintf(buf, "%d", utype->vision_radius_sq);
     SetWindowText(help_ulabel[3][4], buf);
     if(utype->tech_requirement==A_LAST) {
       SetWindowText(help_ulabel[4][1], _("(Never)"));
@@ -761,7 +743,7 @@
 {
   int j;
   struct fcwin_box *hbox;
-  char *buf= &long_buffer[0];
+  char buf[64000];
 
   create_help_page(HELP_TECH);
   if (!is_future_tech(i)) {
@@ -769,7 +751,7 @@
          create_tech_tree(GTK_CTREE(help_tree), i, TECH_TREE_DEPTH,
          TECH_TREE_EXPANDED_DEPTH, NULL);
     */
-    helptext_tech(buf, i, pitem->text);
+    helptext_tech(buf, sizeof(i), i, pitem->text);
     wordwrap_string(buf, 68);
     fcwin_box_add_static(helpdlg_page_vbox,buf,0,SS_LEFT,FALSE,FALSE,5);
 
@@ -855,12 +837,12 @@
 static void help_update_government(const struct help_item *pitem,
                                    char *title, struct government *gov)
 {
-  char *buf = &long_buffer[0];
+  char buf[64000];
  
   if (!gov) {
     strcat(buf, pitem->text);
   } else {
-    helptext_government(buf, gov, pitem->text);
+    helptext_government(buf, sizeof(buf), gov, pitem->text);
   }
   create_help_page(HELP_TEXT);
   set_help_text(buf);
Index: client/gui-win32/mapctrl.c
===================================================================
--- client/gui-win32/mapctrl.c  (revision 12170)
+++ client/gui-win32/mapctrl.c  (working copy)
@@ -44,10 +44,11 @@
 #include "inputdlg.h"
 #include "mapview.h"
 #include "menu.h"
+#include "overview_common.h"
 #include "tilespec.h" 
 #include "text.h"
 
-#include "goto.h" 
+#include "goto.h"
 #include "mapctrl.h"
 #include "gui_main.h"
 
@@ -119,7 +120,7 @@
   struct tile **cross_head = cross_list;
   int i;
   struct unit *punit;
-  
+
   if (popit_popup!=NULL) {
     DestroyWindow(popit_popup);
     popit_popup=NULL;
Index: client/gui-win32/mapview.c
===================================================================
--- client/gui-win32/mapview.c  (revision 12170)
+++ client/gui-win32/mapview.c  (working copy)
@@ -31,6 +31,7 @@
 #include "rand.h"
 #include "support.h"
 #include "timing.h"
+#include "unitlist.h"
 #include "version.h"
 
 #include "canvas.h"
@@ -193,10 +194,10 @@
 
 **************************************************************************/
 void
-update_unit_info_label(struct unit *punit)
+update_unit_info_label(struct unit_list *punitlist)
 {
-  SetWindowText(unit_info_frame, get_unit_info_label_text1(punit));
-  SetWindowText(unit_info_label, get_unit_info_label_text2(punit));
+  SetWindowText(unit_info_frame, get_unit_info_label_text1(punitlist));
+  SetWindowText(unit_info_label, get_unit_info_label_text2(punitlist));
 
   switch (hover_state) {
     case HOVER_NONE:
Index: client/gui-win32/menu.c
===================================================================
--- client/gui-win32/menu.c     (revision 12170)
+++ client/gui-win32/menu.c     (working copy)
@@ -31,6 +31,7 @@
 #include "movement.h"
 #include "support.h"
 #include "unit.h"
+#include "unitlist.h"
  
 #include "chatline.h"
 #include "cityrep.h"
@@ -685,25 +686,28 @@
 
 
     case IDM_ORDERS_BUILD_CITY:
-      if(get_unit_in_focus()) {
-       struct unit *punit = get_unit_in_focus();
-       /* Enable the button for adding to a city in all cases, so we
-          get an eventual error message from the server if we try. */
-       if (can_unit_add_or_build_city(punit)) {
-         key_unit_build_city();
-       } else {
-         key_unit_build_wonder();
-       }
-      }
+      unit_list_iterate(get_units_in_focus(), punit) {
+        /* FIXME: this can provide different actions for different units...
+         * not good! */
+        /* Enable the button for adding to a city in all cases, so we
+         * get an eventual error message from the server if we try. */
+        if (can_unit_add_or_build_city(punit)) {
+          key_unit_build_city();
+        } else {
+          key_unit_build_wonder();
+        }
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_ROAD:
-      if (get_unit_in_focus()) {
-       if (unit_can_est_traderoute_here(get_unit_in_focus())) {
-         key_unit_traderoute();
-       } else {
-         key_unit_road();
-       }
-      }
+      unit_list_iterate(get_units_in_focus(), punit) {
+        /* FIXME: this can provide different actions for different units...
+         * not good! */
+        if (unit_can_est_traderoute_here(punit)) {
+          key_unit_traderoute();
+        } else {
+          key_unit_road();
+        }
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_IRRIGATE:
       key_unit_irrigate();
@@ -715,22 +719,29 @@
       key_unit_transform();
       break;
     case IDM_ORDERS_FORTRESS:
-      if (get_unit_in_focus()) {
-       if (can_unit_do_activity(get_unit_in_focus(), ACTIVITY_FORTRESS)) {
-         key_unit_fortress();
-       } else {
-         key_unit_fortify();
-       }
-      }
+      unit_list_iterate(get_units_in_focus(), punit) {
+        /* FIXME: this can provide different actions for different units...
+         * not good! */
+        if (can_unit_do_activity(punit, ACTIVITY_FORTRESS)) {
+          key_unit_fortress();
+        } else {
+          key_unit_fortify();
+        }
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_AIRBASE:
       key_unit_airbase();
       break;
     case IDM_ORDERS_POLLUTION:
-      if (can_unit_paradrop(get_unit_in_focus()))
-       key_unit_paradrop();
-      else
-       key_unit_pollution();
+      unit_list_iterate(get_units_in_focus(), punit) {
+        /* FIXME: this can provide different actions for different units...
+         * not good! */
+        if (can_unit_paradrop(punit)) {
+          key_unit_paradrop();
+        } else {
+          key_unit_pollution();
+        }
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_FALLOUT:
       key_unit_fallout();
@@ -745,26 +756,22 @@
       key_unit_homecity();
       break;
     case IDM_ORDERS_LOAD:
-      request_unit_load(get_unit_in_focus(), NULL);
+      unit_list_iterate(get_units_in_focus(), punit) {
+        request_unit_load(punit, NULL);
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_UNLOAD:
-      if (get_unit_in_focus()) {
-       struct unit *punit = get_unit_in_focus();
-       if (can_unit_unload(punit, find_unit_by_id(punit->transported_by))
-        && can_unit_exist_at_tile(punit, punit->tile)) {
-         request_unit_unload(punit);
-       } else if (get_transporter_occupancy(punit) > 0) {
-         key_unit_unload_all();
-       }
-      }
+      unit_list_iterate(get_units_in_focus(), punit) {
+        request_unit_unload(punit);
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_WAKEUP_OTHERS:
       key_unit_wakeup_others();
       break;
     case IDM_ORDERS_AUTO_SETTLER:
-      if (get_unit_in_focus()) {
-       request_unit_autosettlers(get_unit_in_focus());
-      }
+      unit_list_iterate(get_units_in_focus(), punit) {
+        request_unit_autosettlers(punit);
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_AUTO_EXPLORE:
       key_unit_auto_explore();
@@ -785,14 +792,14 @@
       key_unit_goto();
       break;
     case IDM_ORDERS_GOTO_CITY:
-      if(get_unit_in_focus()) {
-       popup_goto_dialog();
+      if (get_num_units_in_focus() > 0) {
+        popup_goto_dialog();
       }
       break;
     case IDM_ORDERS_RETURN:
-      if (get_unit_in_focus()) {
-       request_unit_return(get_unit_in_focus());
-      }
+      unit_list_iterate(get_units_in_focus(), punit) {
+        request_unit_return(punit);
+      } unit_list_iterate_end;
       break;
     case IDM_ORDERS_DISBAND:
       key_unit_disband();
@@ -829,10 +836,10 @@
       break;
     case IDM_REPORTS_WONDERS:
       send_report_request(REPORT_WONDERS_OF_THE_WORLD);
-      break;          
+      break;
     case IDM_REPORTS_TOP_CITIES:
       send_report_request(REPORT_TOP_5_CITIES);
-      break;       
+      break;
     case IDM_REPORTS_MESSAGES:
       popup_meswin_dialog(TRUE);
       break;
@@ -1064,7 +1071,7 @@
     }
 
 
-    my_enable_menu(menu, IDM_REPORTS_SPACESHIP, 
+    my_enable_menu(menu, IDM_REPORTS_SPACESHIP,
                   (game.player_ptr->spaceship.state!=SSHIP_NONE));
 
     my_check_menu(menu, IDM_VIEW_MAP_GRID, draw_map_grid);
@@ -1086,7 +1093,7 @@
     my_check_menu(menu, IDM_VIEW_CITIES, draw_cities);
     my_check_menu(menu, IDM_VIEW_UNITS, draw_units);
     my_check_menu(menu, IDM_VIEW_FOCUS_UNIT, draw_focus_unit);
-    my_enable_menu(menu, IDM_VIEW_FOCUS_UNIT, !draw_units); 
+    my_enable_menu(menu, IDM_VIEW_FOCUS_UNIT, !draw_units);
     my_check_menu(menu, IDM_VIEW_FOG_OF_WAR, draw_fog_of_war);
 
     /* Remaining part of this function: Update Orders menu */
@@ -1095,7 +1102,7 @@
       return;
     }
 
-    if ((punit = get_unit_in_focus())) {
+    if ((punit = unit_list_get(get_units_in_focus(), 0))) {
       const char *irrfmt = _("Change to %s");
       const char *minfmt = _("Change to %s");
       const char *transfmt = _("Transform to %s");
@@ -1106,7 +1113,7 @@
       sz_strlcpy(irrtext, N_("Build Irrigation") "\tI");
       sz_strlcpy(mintext, N_("Build Mine") "\tM");
       sz_strlcpy(transtext, N_("Transform Terrain") "\tO");
-      
+
       /* Since the entire menu is disabled by default, enable the
         items with no checks. */
       my_enable_menu(menu, IDM_ORDERS_PATROL, TRUE);
Index: client/gui-win32/repodlgs.c
===================================================================
--- client/gui-win32/repodlgs.c (revision 12170)
+++ client/gui-win32/repodlgs.c (working copy)
@@ -30,6 +30,7 @@
 #include "packets.h"
 #include "shared.h"
 #include "support.h"
+#include "unitlist.h"
 
 #include "chatline_common.h"   /* send_chat() */ 
 #include "cityrep.h"
@@ -387,7 +388,7 @@
                                WPARAM wParam,
                                LPARAM lParam) 
 {
-  
+
   switch(message)
     {
   
@@ -567,7 +568,7 @@
                          ut1->name, ut2->name,
                          unit_upgrade_price(game.player_ptr, ut1, ut2),
                          game.player_ptr->economic.gold);    
-             
+
              popup_message_dialog(NULL, 
                                   /*"upgradedialog"*/
                                   _("Upgrade Obsolete Units"), buf,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#15747) gui-win32 compile fix, Christian Prochaska <=