[Freeciv-Dev] (PR#13607) gui-xaw: compile-fixes
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13607) gui-xaw: compile-fixes |
From: |
"Egor Vyscrebentsov" <evyscr@xxxxxxxxx> |
Date: |
Sat, 22 Oct 2005 04:14:11 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13607 >
Good daytime!
Attached patch allows to compile gui-xaw successfully.
But:
1. I think that connectdlg should be rewritten.
2. Support of observers is not full. (And possibly there are
errors with game.player_ptr.)
And there are many other errors including crashes while
switching tilesets (I still have not adapt my own patch
to current code...)
Anyway, I'm going to commit this patch soon.
Thanks, evyscr.
Index: client/gui-xaw/citydlg.c
===================================================================
--- client/gui-xaw/citydlg.c (revision 11170)
+++ client/gui-xaw/citydlg.c (working copy)
@@ -50,6 +50,7 @@
#include "cityrep.h"
#include "citydlg.h"
+#include "civclient.h"
#include "cma_fe.h"
#include "colors.h"
#include "control.h" /* request_xxx and set_unit_focus */
@@ -367,11 +368,11 @@
XtSetSensitive(pdialog->cma_command, True);
XtSetSensitive(pdialog->cityopt_command, True);
}
- if (city_owner(pcity) == game.player_ptr) {
+ if (!game.player_ptr || city_owner(pcity) == game.player_ptr) {
city_report_dialog_update_city(pcity);
economy_report_dialog_update();
} else {
- if(pdialog) {
+ if (pdialog) {
/* Set the buttons we do not want live while a Diplomat investigates */
XtSetSensitive(pdialog->buy_command, FALSE);
XtSetSensitive(pdialog->change_command, FALSE);
@@ -386,9 +387,9 @@
}
}
-/****************************************************************
-...
-*****************************************************************/
+/**************************************************************************
+ Updates supported and present units views in city dialogs for given unit
+**************************************************************************/
void refresh_unit_city_dialogs(struct unit *punit)
{
struct city *pcity_sup, *pcity_pre;
@@ -1338,7 +1339,8 @@
if (punit->homecity == pcity->id) {
XtSetSensitive(XtNameToWidget(wd, "*button5"), FALSE);
}
- if (can_upgrade_unittype(game.player_ptr, punit->type) == NULL) {
+ if (!game.player_ptr
+ || (can_upgrade_unittype(game.player_ptr, punit->type) == NULL)) {
XtSetSensitive(XtNameToWidget(wd, "*button6"), FALSE);
}
}
@@ -1644,7 +1646,7 @@
int i, j, adj_base;
Widget pixcomm;
- if (city_owner(pdialog->pcity) != game.player_ptr) {
+ if (game.player_ptr && (city_owner(pdialog->pcity) != game.player_ptr)) {
plist = pdialog->pcity->info_units_supported;
} else {
plist = pdialog->pcity->units_supported;
@@ -1704,7 +1706,7 @@
int i, j, adj_base;
Widget pixcomm;
- if (city_owner(pdialog->pcity) != game.player_ptr) {
+ if (game.player_ptr && (city_owner(pdialog->pcity) != game.player_ptr)) {
plist = pdialog->pcity->info_units_present;
} else {
plist = pdialog->pcity->tile->units;
@@ -1870,6 +1872,10 @@
pdialog=(struct city_dialog *)client_data;
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
if(pdialog->pcity->production.is_unit) {
name=get_unit_type(pdialog->pcity->production.value)->name;
}
@@ -1878,7 +1884,7 @@
}
value=city_buy_cost(pdialog->pcity);
- if(game.player_ptr->economic.gold>=value) {
+ if (game.player_ptr->economic.gold>=value) {
my_snprintf(buf, sizeof(buf),
_("Buy %s for %d gold?\nTreasury contains %d gold."),
name, value, game.player_ptr->economic.gold);
@@ -1906,6 +1912,11 @@
{
struct unit *punit;
+ /* Is it right place for breaking? -ev */
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)client_data))) {
request_unit_upgrade(punit);
}
Index: client/gui-xaw/gotodlg.c
===================================================================
--- client/gui-xaw/gotodlg.c (revision 11170)
+++ client/gui-xaw/gotodlg.c (working copy)
@@ -98,11 +98,14 @@
{
Position x, y;
Dimension width, height;
- Boolean no_player_cities = !(city_list_size(game.player_ptr->cities));
+ Boolean no_player_cities;
if (!can_client_issue_orders()) {
return;
}
+
+ no_player_cities = !(city_list_size(game.player_ptr->cities));
+
if(get_unit_in_focus()==0)
return;
@@ -206,6 +209,10 @@
int i, j;
Boolean all_cities;
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
XtVaGetValues(goto_all_toggle, XtNstate, &all_cities, NULL);
cleanup_goto_list();
Index: client/gui-xaw/mapview.c
===================================================================
--- client/gui-xaw/mapview.c (revision 11170)
+++ client/gui-xaw/mapview.c (working copy)
@@ -164,7 +164,7 @@
void update_info_label(void)
{
int d;
-
+
xaw_set_label(info_command, get_info_label_text());
set_indicator_icons(client_research_sprite(),
@@ -172,6 +172,10 @@
client_cooling_sprite(),
client_government_sprite());
+ if (!game.player_ptr) {
+ return;
+ }
+
d = 0;
for(; d < (game.player_ptr->economic.luxury) / 10; d++)
xaw_set_bitmap(econ_label[d], get_tax_sprite(tileset, O_LUXURY)->pixmap);
@@ -350,7 +354,7 @@
* is written (otherwise drawing bugs happen when old data is copied
* to screen). Then we draw all changed areas to the screen. */
unqueue_mapview_updates(FALSE);
- XCopyArea(display, map_canvas_store, XtWindow(map_canvas),
+ XCopyArea(display, mapview.store->pixmap, XtWindow(map_canvas),
civ_gc,
event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height,
Index: client/gui-xaw/pages.c
===================================================================
--- client/gui-xaw/pages.c (revision 11170)
+++ client/gui-xaw/pages.c (working copy)
@@ -55,6 +55,14 @@
XtPointer call_data);
+/***************************************************************************
+ Returns current client page
+***************************************************************************/
+enum client_pages get_client_page(void)
+{
+ return old_page;
+}
+
/**************************************************************************
Sets the "page" that the client should show. See documentation in
pages_g.h.
@@ -199,9 +207,6 @@
j = 0;
players_iterate(pplayer) {
- if (pplayer->is_observer) {
- continue; /* Connections are listed individually. */
- }
if (pplayer->ai.control) {
name = _("<AI>");
} else {
@@ -228,7 +233,7 @@
j++;
} players_iterate_end;
conn_list_iterate(game.est_connections, pconn) {
- if (pconn->player && !pconn->observer && !pconn->player->is_observer) {
+ if (pconn->player && !pconn->observer) {
continue; /* Already listed above. */
}
name = pconn->username;
@@ -268,7 +273,9 @@
void start_page_nation_callback(Widget w, XtPointer client_data,
XtPointer call_data)
{
- popup_races_dialog(game.player_ptr);
+ if (game.player_ptr) {
+ popup_races_dialog(game.player_ptr);
+ }
}
/**************************************************************************
Index: client/gui-xaw/menu.c
===================================================================
--- client/gui-xaw/menu.c (revision 11170)
+++ client/gui-xaw/menu.c (working copy)
@@ -355,8 +355,12 @@
menu_entry_sensitive(MENU_GAME, MENU_GAME_CLEAR_OUTPUT, 1);
menu_entry_sensitive(MENU_GAME, MENU_GAME_DISCONNECT, 1);
- menu_entry_sensitive(MENU_REPORT, MENU_REPORT_SPACESHIP,
- (game.player_ptr->spaceship.state!=SSHIP_NONE));
+ if (game.player_ptr) {
+ menu_entry_sensitive(MENU_REPORT, MENU_REPORT_SPACESHIP,
+ (game.player_ptr->spaceship.state!=SSHIP_NONE));
+ } else {
+ menu_entry_sensitive(MENU_REPORT, MENU_REPORT_SPACESHIP, 0);
+ }
if (punit && can_client_issue_orders()) {
Terrain_type_id ttype;
@@ -561,6 +565,9 @@
{
struct government *pgovernment = client_data;
+ if (!can_client_issue_orders()) {
+ return;
+ }
if (game.player_ptr->revolution_finishes == -1) {
popup_revolution_dialog(pgovernment);
} else {
@@ -796,7 +803,9 @@
send_report_request(REPORT_DEMOGRAPHIC);
break;
case MENU_REPORT_SPACESHIP:
- popup_spaceship_dialog(game.player_ptr);
+ if (game.player_ptr) {
+ popup_spaceship_dialog(game.player_ptr);
+ }
break;
}
}
Index: client/gui-xaw/cityrep.c
===================================================================
--- client/gui-xaw/cityrep.c (revision 11170)
+++ client/gui-xaw/cityrep.c (working copy)
@@ -504,7 +504,9 @@
*****************************************************************/
void city_report_dialog_update(void)
{
- if(is_report_dialogs_frozen()) return;
+ if (is_report_dialogs_frozen() || !game.player_ptr) {
+ return;
+ }
if(city_dialog_shell) {
int i=0, n;
Dimension width;
Index: client/gui-xaw/dialogs.c
===================================================================
--- client/gui-xaw/dialogs.c (revision 11170)
+++ client/gui-xaw/dialogs.c (working copy)
@@ -165,7 +165,7 @@
int caravan_city_id;
int caravan_unit_id;
-bool diplomat_dialog_open = FALSE;
+static Widget diplomat_dialog;
int diplomat_id;
int diplomat_target_id;
@@ -480,7 +480,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(find_unit_by_id(diplomat_id) &&
find_city_by_id(diplomat_target_id)) {
@@ -498,7 +498,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(find_unit_by_id(diplomat_id) &&
(find_city_by_id(diplomat_target_id))) {
@@ -516,7 +516,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(find_unit_by_id(diplomat_id) &&
(find_city_by_id(diplomat_target_id))) {
@@ -546,7 +546,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(find_unit_by_id(diplomat_id) &&
(find_city_by_id(diplomat_target_id))) {
@@ -563,7 +563,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(find_unit_by_id(diplomat_id) &&
find_city_by_id(diplomat_target_id)) {
@@ -872,7 +872,7 @@
pvictim to NULL and account for !pvictim in create_advances_list. -- Syela */
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(!spy_tech_shell){
Position x, y;
@@ -899,7 +899,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if(find_unit_by_id(diplomat_id) &&
(find_city_by_id(diplomat_target_id))) {
@@ -964,7 +964,7 @@
XtPointer call_data)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if (find_unit_by_id(diplomat_id) && find_city_by_id(diplomat_target_id)) {
dsend_packet_city_incite_inq(&aconnection, diplomat_target_id);
@@ -1016,7 +1016,7 @@
struct city *pcity;
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
if( (punit=find_unit_by_id(diplomat_id))
&& (pcity=find_city_by_id(diplomat_target_id))
@@ -1033,7 +1033,7 @@
static void diplomat_cancel_callback(Widget w, XtPointer a, XtPointer b)
{
destroy_message_dialog(w);
- diplomat_dialog_open = FALSE;
+ diplomat_dialog = NULL;
process_diplomat_arrival(NULL, 0);
}
@@ -1046,7 +1046,6 @@
{
struct city *pcity;
struct unit *ptunit;
- Widget shl;
char buf[128];
diplomat_id=punit->id;
@@ -1059,8 +1058,9 @@
_("Your %s has arrived at %s.\nWhat is your command?"),
unit_name(punit->type), pcity->name);
- if(!unit_flag(punit, F_SPY)){
- shl=popup_message_dialog(toplevel, "diplomatdialog", buf,
+ if (!unit_flag(punit, F_SPY)) {
+ diplomat_dialog =
+ popup_message_dialog(toplevel, "diplomatdialog", buf,
diplomat_embassy_callback, 0, 1,
diplomat_investigate_callback, 0, 1,
diplomat_sabotage_callback, 0, 1,
@@ -1071,19 +1071,20 @@
NULL);
if(!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button0"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button0"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button1"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button1"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button2"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button2"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button3"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button3"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button4"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button4"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button5"), FALSE);
- }else{
- shl=popup_message_dialog(toplevel, "spydialog", buf,
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button5"), FALSE);
+ } else {
+ diplomat_dialog =
+ popup_message_dialog(toplevel, "spydialog", buf,
diplomat_embassy_callback, 0, 1,
diplomat_investigate_callback, 0, 1,
spy_poison_callback,0, 1,
@@ -1095,26 +1096,25 @@
NULL);
if(!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button0"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button0"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button1"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button1"), FALSE);
if(!diplomat_can_do_action(punit, SPY_POISON, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button2"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button2"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button3"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button3"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button4"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button4"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button5"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button5"), FALSE);
if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile))
- XtSetSensitive(XtNameToWidget(shl, "*button6"), FALSE);
+ XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button6"), FALSE);
}
-
- diplomat_dialog_open = TRUE;
- }else{
+ } else {
if ((ptunit = unit_list_get(dest_tile->units, 0))) {
/* Spy/Diplomat acting against a unit */
+ Widget shl;
const char *message = !unit_flag(punit, F_SPY)
? _("Sir, the diplomat is waiting for your command")
: _("Sir, the spy is waiting for your command");
@@ -1136,12 +1136,25 @@
}
}
+/***************************************************************************
+ Return id of a diplomat currently handled in diplomat dialog
+***************************************************************************/
+int diplomat_handled_in_diplomat_dialog(void)
+{
+ if (diplomat_dialog == NULL) {
+ return -1;
+ }
+ return diplomat_id;
+}
+
/****************************************************************
-...
-*****************************************************************/
-bool diplomat_dialog_is_open(void)
+ Close the diplomat dialog
+****************************************************************/
+void close_diplomat_dialog(void)
{
- return diplomat_dialog_open;
+ if (diplomat_dialog != NULL) {
+ XtDestroyWidget(diplomat_dialog);
+ }
}
Index: client/gui-xaw/ratesdlg.c
===================================================================
--- client/gui-xaw/ratesdlg.c (revision 11170)
+++ client/gui-xaw/ratesdlg.c (working copy)
@@ -35,7 +35,9 @@
#include "shared.h"
#include "support.h"
+#include "civclient.h"
#include "clinet.h"
+
#include "gui_main.h"
#include "gui_stuff.h"
#include "mapview.h"
@@ -79,6 +81,10 @@
Dimension width, height;
char buf[64];
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
XtSetSensitive(main_form, FALSE);
create_rates_dialog();
@@ -106,6 +112,9 @@
Widget rates_form;
Widget rates_ok_command, rates_cancel_command;
+ if (!can_client_issue_orders()) {
+ return;
+ }
rates_dialog_shell =
I_T(XtCreatePopupShell("ratespopup", transientShellWidgetClass,
@@ -250,6 +259,10 @@
Boolean tax_lock, lux_lock, sci_lock;
int maxrate;
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
XtVaGetValues(rates_tax_toggle, XtNstate, &tax_lock, NULL);
XtVaGetValues(rates_lux_toggle, XtNstate, &lux_lock, NULL);
XtVaGetValues(rates_sci_toggle, XtNstate, &sci_lock, NULL);
Index: client/gui-xaw/helpdlg.c
===================================================================
--- client/gui-xaw/helpdlg.c (revision 11170)
+++ client/gui-xaw/helpdlg.c (working copy)
@@ -870,7 +870,7 @@
xaw_set_label(help_unit_fp_data, buf);
sprintf(buf, "%d ", punittype->hp);
xaw_set_label(help_unit_hp_data, buf);
- sprintf(buf, "%d ", punittype->vision_range);
+ sprintf(buf, "%d ", (int)sqrt((double)punittype->vision_radius_sq));
xaw_set_label(help_unit_visrange_data, buf);
xaw_set_label(help_unit_upkeep_data,
helptext_unit_upkeep_str(punittype));
Index: client/gui-xaw/wldlg.c
===================================================================
--- client/gui-xaw/wldlg.c (revision 11170)
+++ client/gui-xaw/wldlg.c (working copy)
@@ -20,33 +20,36 @@
#include <string.h>
#include <X11/Intrinsic.h>
+#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Command.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
-#include <X11/Xaw/Command.h>
+#include <X11/Xaw/List.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xaw/List.h>
+#include <X11/Xaw/Toggle.h>
#include <X11/Xaw/Viewport.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Toggle.h>
-#include <X11/IntrinsicP.h>
+#include "fcintl.h"
+#include "mem.h"
#include "city.h"
-#include "fcintl.h"
#include "game.h"
-#include "gui_main.h"
-#include "gui_stuff.h"
-#include "helpdlg.h"
-#include "inputdlg.h"
-#include "mem.h"
#include "packets.h"
#include "worklist.h"
+
+#include "civclient.h"
#include "climisc.h"
#include "clinet.h"
+#include "gui_main.h"
+#include "gui_stuff.h"
+#include "helpdlg.h"
+#include "inputdlg.h"
+
#include "wldlg.h"
#define WORKLIST_ADVANCED_TARGETS 1
@@ -1301,6 +1304,10 @@
int can_build, can_eventually_build;
struct city_production production;
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
n = 0;
/* Is the worklist limited to just the current targets, or
Index: client/gui-xaw/connectdlg.c
===================================================================
--- client/gui-xaw/connectdlg.c (revision 11170)
+++ client/gui-xaw/connectdlg.c (working copy)
@@ -46,7 +46,7 @@
#include "gui_stuff.h"
#include "pages.h"
-#include "connectdlg_g.h"
+#include "connectdlg_common.h"
#include "connectdlg.h"
static enum {
@@ -90,6 +90,8 @@
static bool lan_mode; /* true for LAN mode, false when Meta mode */
static int num_lanservers_timer = 0;
+struct server_scan *lan, *meta;
+
/**************************************************************************
really close and destroy the dialog.
**************************************************************************/
@@ -103,14 +105,23 @@
**************************************************************************/
void close_connection_dialog()
{
+ if (lan) {
+ server_scan_finish(lan);
+ lan = NULL;
+ }
+ if (meta) {
+ server_scan_finish(meta);
+ meta = NULL;
+ }
+
if (shell) {
XtDestroyWidget(shell);
- shell = 0;
+ shell = NULL;
}
- if(meta_dialog_shell) {
+ if (meta_dialog_shell) {
XtDestroyWidget(meta_dialog_shell);
- meta_dialog_shell = 0;
+ meta_dialog_shell = NULL;
}
}
@@ -328,13 +339,38 @@
}
}
+/**************************************************************************
+ 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;
+ }
+}
+
/****************************************************************
-...
+ Callback function for Metaserver button
*****************************************************************/
void connect_meta_callback(Widget w, XtPointer client_data,
XtPointer call_data)
{
lan_mode = false;
+ if (!meta) {
+ meta = server_scan_begin(SERVER_SCAN_GLOBAL, server_scan_error);
+ }
if (meta_dialog_shell) {
/* Metaserver window already poped up */
return;
@@ -343,19 +379,20 @@
}
/****************************************************************
-...
+ Callback function for LAN Server button
*****************************************************************/
void connect_lan_callback(Widget w, XtPointer client_data,
XtPointer call_data)
{
lan_mode = true;
+ if (!lan) {
+ lan = server_scan_begin(SERVER_SCAN_LOCAL, server_scan_error);
+ }
if (meta_dialog_shell) {
/* Metaserver window already poped up */
return;
}
- if (begin_lanserver_scan()) {
- create_meta_dialog((Widget)client_data);
- }
+ create_meta_dialog((Widget)client_data);
}
/**************************************************************************
@@ -380,7 +417,7 @@
if (lan_mode) {
if (num_lanservers_timer == 50 && lan_mode) {
- finish_lanserver_scan();
+ server_scan_finish(lan);
num_lanservers_timer = 0;
return;
}
@@ -442,7 +479,7 @@
{
if (num_lanservers_timer == 0) {
if (lan_mode) {
- if (begin_lanserver_scan()) {
+ if (lan) {
server_list_timer((Widget)client_data, NULL);
}
} else {
@@ -485,7 +522,7 @@
server_list[i]=NULL;
}
if (num_lanservers_timer != 0) {
- finish_lanserver_scan();
+ server_scan_finish(lan);
}
}
@@ -499,19 +536,23 @@
struct server_list *server_list = NULL;
if (lan_mode) {
- server_list = get_lan_server_list();
- if (server_list == NULL) {
- if (num_lanservers_timer == 0) {
- *list = mystrdup(" ");;
- return 0;
- } else {
- return -1;
+ if (lan) {
+ server_list = server_scan_get_servers(lan);
+ if (server_list == NULL) {
+ if (num_lanservers_timer == 0) {
+ *list = mystrdup(" ");;
+ return 0;
+ } else {
+ return -1;
+ }
}
}
} else {
- server_list = create_server_list(errbuf, n_errbuf);
- if (!server_list) {
- return -1;
+ if (meta) {
+ server_list = server_scan_get_servers(meta);
+ if (!server_list) {
+ return -1;
+ }
}
}
@@ -525,9 +566,11 @@
list++;
} server_list_iterate_end;
+/*
if (!lan_mode) {
delete_server_list(server_list);
}
+*/
*list=NULL;
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13607) gui-xaw: compile-fixes,
Egor Vyscrebentsov <=
|
|