[Freeciv-Dev] Re: (PR#1883) Client is not full aware of game end
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, 2002-12-02 at 00:05, Jason Short via RT wrote:
> [rfalke - Mon Oct 28 03:27:16 2002]:
>
>
> > It is related to PR#533 (Because a proper fix of that bug will help
> > this one)
>
> PR#533 is somewhat fixed. But I don't see how that helps with this problem.
Good!
I have updated my patch, to cope with HEAD changes in the last month and
I'll attach at the end of this mail.
Why PR#533 was related to this one:
When the game end, the server send the GAME_OVER_STATE packet and
afterwords the client is informed of the status change.
This 1883 problem is related to the fact that we take in no account in
the client the fact that the game has ended, thus we let the player buy
improvement, move units and other "strange" things (if you consider that
the game has ended!).
But even if I have started to make the client aware of the game end if
you consider that you can open a dialog *BEFORE* the game end and have
it still open *AFTER* the game end, then we need a function to popdown
all the dialogs or at least all the possible wrong dialogs when the
status changes, for thi reason PR#533 was related to this one.
For this patch, this is a resume:
- After end game, no more focus on units (This is not extended on
observer clients)
- After end game, no more modification in cities or other things, it
makes no sense. (Observer status clients are similarly excluded from
having this possibility)
Residual issues:
1. Misc. options, in city dialog, is not finished.
(all option must be made unsensitive for observer client, and
perhaps also for end game state)
2. clients other than gtk are only partially fixed and need more work
One important question:
As an observer I would like to see all units movement and position, but
at the same time I can't issue order for them.
So, many times clicking on a sentried units, send a packet to the
server, that isn't appropriate.
Which should be the correct solution?
> jason
diff -urN -Xfreeciv/diff_ignore freeciv/client/civclient.c
freeciv-1883/client/civclient.c
--- freeciv/client/civclient.c Thu Dec 12 23:11:04 2002
+++ freeciv-1883/client/civclient.c Sat Dec 14 21:48:34 2002
@@ -627,19 +627,6 @@
&& (newstate == CLIENT_PRE_GAME_STATE);
enum client_states oldstate = client_state;
- /*
- * We are currently ignoring the CLIENT_GAME_OVER_STATE state
- * because the client hasen't been changed to take care of it. So it
- * breaks the show-whole-map-at-the-end-of-the-game. Nevertheless
- * the server is so kind and sends the client this information. And
- * in the future the client can/should take advantage of this
- * information.
- *
- * FIXME: audit all client code to that it copes with
- * CLIENT_GAME_OVER_STATE and implement specific
- * CLIENT_GAME_OVER_STATE actions like history browsing. Then remove
- * the kludge below.
- */
if (newstate == CLIENT_GAME_OVER_STATE) {
/*
* Extra kludge for end-game handling of the CMA.
@@ -649,10 +636,9 @@
cma_release_city(pcity);
}
} city_list_iterate_end;
- newstate = CLIENT_GAME_RUNNING_STATE;
}
- if(client_state!=newstate) {
+ if (client_state!=newstate) {
/* If changing from pre-game state to _either_ select race
or running state, then we have finished getting ruleset data,
@@ -669,7 +655,7 @@
client_state=newstate;
- if(client_state==CLIENT_GAME_RUNNING_STATE) {
+ if (client_state==CLIENT_GAME_RUNNING_STATE) {
load_ruleset_specific_options();
create_event(-1, -1, E_GAME_START, _("Game started."));
update_research(game.player_ptr);
@@ -677,7 +663,7 @@
boot_help_texts(); /* reboot */
update_unit_focus();
}
- else if(client_state==CLIENT_PRE_GAME_STATE) {
+ else if (client_state==CLIENT_PRE_GAME_STATE) {
popdown_all_city_dialogs();
popdown_all_game_dialogs();
close_all_diplomacy_dialogs();
@@ -817,3 +803,21 @@
flip = !flip;
}
+
+/**************************************************************************
+ Can the client now issue orders.
+**************************************************************************/
+bool can_client_issue_orders()
+{
+ return (!client_is_observer()
+ && get_client_state() == CLIENT_GAME_RUNNING_STATE);
+}
+
+/**************************************************************************
+ Can the client now change the view.
+**************************************************************************/
+bool can_client_change_view()
+{
+ return (get_client_state() == CLIENT_GAME_RUNNING_STATE
+ || get_client_state() == CLIENT_GAME_OVER_STATE);
+}
diff -urN -Xfreeciv/diff_ignore freeciv/client/civclient.h
freeciv-1883/client/civclient.h
--- freeciv/client/civclient.h Mon Nov 25 17:54:58 2002
+++ freeciv-1883/client/civclient.h Sat Dec 14 21:48:34 2002
@@ -56,6 +56,8 @@
void wait_till_request_got_processed(int request_id);
bool client_is_observer(void);
void real_timer_callback(void);
+bool can_client_issue_orders(void);
+bool can_client_change_view(void);
void client_game_init(void);
void client_game_free(void);
diff -urN -Xfreeciv/diff_ignore freeciv/client/climisc.c
freeciv-1883/client/climisc.c
--- freeciv/client/climisc.c Fri Nov 15 15:22:39 2002
+++ freeciv-1883/client/climisc.c Sat Dec 14 21:48:34 2002
@@ -491,7 +491,7 @@
struct city *pcity;
struct unit *punit;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
return;
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/control.c
freeciv-1883/client/control.c
--- freeciv/client/control.c Thu Dec 12 23:11:04 2002
+++ freeciv-1883/client/control.c Sat Dec 14 21:48:34 2002
@@ -382,8 +382,8 @@
int i;
- if(punit) {
- if(punit->type != prev_unit_type
+ if (punit && get_client_state() != CLIENT_GAME_OVER_STATE) {
+ if (punit->type != prev_unit_type
|| punit->activity != prev_activity
|| punit->hp != prev_hp) {
set_unit_icon(-1, punit);
@@ -929,7 +929,9 @@
**************************************************************************/
void request_toggle_map_grid(void)
{
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) return;
+ if (!can_client_change_view()) {
+ return;
+ }
draw_map_grid^=1;
update_map_canvas_visible();
@@ -940,8 +942,9 @@
**************************************************************************/
void request_toggle_city_names(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_city_names ^= 1;
update_map_canvas_visible();
@@ -965,8 +968,9 @@
**************************************************************************/
void request_toggle_city_productions(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_city_productions ^= 1;
update_map_canvas_visible();
@@ -977,8 +981,9 @@
**************************************************************************/
void request_toggle_terrain(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_terrain ^= 1;
update_map_canvas_visible();
@@ -989,8 +994,9 @@
**************************************************************************/
void request_toggle_coastline(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_coastline ^= 1;
update_map_canvas_visible();
@@ -1001,8 +1007,9 @@
**************************************************************************/
void request_toggle_roads_rails(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_roads_rails ^= 1;
update_map_canvas_visible();
@@ -1013,8 +1020,9 @@
**************************************************************************/
void request_toggle_irrigation(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_irrigation ^= 1;
update_map_canvas_visible();
@@ -1025,8 +1033,9 @@
**************************************************************************/
void request_toggle_mines(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_mines ^= 1;
update_map_canvas_visible();
@@ -1037,8 +1046,9 @@
**************************************************************************/
void request_toggle_fortress_airbase(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_fortress_airbase ^= 1;
update_map_canvas_visible();
@@ -1049,8 +1059,9 @@
**************************************************************************/
void request_toggle_specials(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_specials ^= 1;
update_map_canvas_visible();
@@ -1061,8 +1072,9 @@
**************************************************************************/
void request_toggle_pollution(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_pollution ^= 1;
update_map_canvas_visible();
@@ -1073,8 +1085,9 @@
**************************************************************************/
void request_toggle_cities(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_cities ^= 1;
update_map_canvas_visible();
@@ -1085,8 +1098,9 @@
**************************************************************************/
void request_toggle_units(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_units ^= 1;
update_map_canvas_visible();
@@ -1097,8 +1111,9 @@
**************************************************************************/
void request_toggle_focus_unit(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_focus_unit ^= 1;
update_map_canvas_visible();
@@ -1109,8 +1124,9 @@
**************************************************************************/
void request_toggle_fog_of_war(void)
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
draw_fog_of_war ^= 1;
update_map_canvas_visible();
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/citydlg.c
freeciv-1883/client/gui-gtk/citydlg.c
--- freeciv/client/gui-gtk/citydlg.c Sat Dec 14 17:36:39 2002
+++ freeciv-1883/client/gui-gtk/citydlg.c Sat Dec 14 21:48:34 2002
@@ -33,6 +33,7 @@
#include "shared.h"
#include "support.h"
+#include "civclient.h"
#include "cityrep.h"
#include "cma_fe.h"
#include "cma_fec.h"
@@ -435,12 +436,17 @@
refresh_cma_dialog(pdialog->pcity, REFRESH_ALL);
gtk_widget_set_sensitive(pdialog->unit.activate_command,
+ can_client_issue_orders() &&
have_present_units);
gtk_widget_set_sensitive(pdialog->unit.sentry_all_command,
+ can_client_issue_orders() &&
have_present_units);
gtk_widget_set_sensitive(pdialog->unit.show_units_command,
+ can_client_issue_orders() &&
have_present_units);
gtk_widget_set_sensitive(pdialog->overview.sell_command, FALSE);
+ gtk_widget_set_sensitive(pdialog->overview.change_command,
+ can_client_issue_orders());
} else {
/* Set the buttons we do not want live while a Diplomat investigates */
gtk_widget_set_sensitive(pdialog->overview.buy_command, FALSE);
@@ -1393,6 +1399,8 @@
gtk_signal_connect(GTK_OBJECT(pdialog->misc.rename_command), "clicked",
GTK_SIGNAL_FUNC(rename_callback), pdialog);
+ gtk_widget_set_sensitive(pdialog->misc.rename_command,
+ can_client_issue_orders());
/* next is the next-time-open radio group in the right column */
frame = gtk_frame_new(_("Next time open"));
@@ -1926,9 +1934,10 @@
gfloat pct;
int cost;
- gtk_widget_set_sensitive(pdialog->overview.buy_command, !pcity->did_buy);
+ gtk_widget_set_sensitive(pdialog->overview.buy_command,
+ can_client_issue_orders() && !pcity->did_buy);
gtk_widget_set_sensitive(pdialog->overview.sell_command,
- !pcity->did_sell);
+ can_client_issue_orders() && !pcity->did_sell);
get_city_dialog_production(pcity, buf, sizeof(buf));
@@ -2509,7 +2518,7 @@
(pcity = find_city_by_id(punit->homecity)) &&
(pdialog = get_city_dialog(pcity))) {
- if (ev->button == 2 || ev->button == 3)
+ if (ev->button == 2 || ev->button == 3 || !can_client_issue_orders())
return FALSE;
popup_message_dialog(pdialog->shell, /* "supported unit popup" */
@@ -2540,7 +2549,7 @@
(pcity = map_get_city(punit->x, punit->y)) &&
(pdialog = get_city_dialog(pcity))) {
- if (ev->button == 2 || ev->button == 3)
+ if (ev->button == 2 || ev->button == 3 || !can_client_issue_orders())
return FALSE;
wd = popup_message_dialog(pdialog->shell, /* "present unit popup" */
@@ -2590,8 +2599,8 @@
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data)) &&
(pcity = map_get_city(punit->x, punit->y)) &&
- (pdialog = get_city_dialog(pcity)) && (ev->button == 2
- || ev->button == 3)) {
+ (pdialog = get_city_dialog(pcity)) && can_client_issue_orders() &&
+ (ev->button == 2 || ev->button == 3)) {
activate_unit(punit);
if (ev->button == 2)
close_city_dialog(pdialog);
@@ -2613,8 +2622,8 @@
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data)) &&
(pcity = find_city_by_id(punit->homecity)) &&
- (pdialog = get_city_dialog(pcity)) && (ev->button == 2
- || ev->button == 3)) {
+ (pdialog = get_city_dialog(pcity)) && can_client_issue_orders() &&
+ (ev->button == 2 || ev->button == 3)) {
activate_unit(punit);
if (ev->button == 2)
close_city_dialog(pdialog);
@@ -3265,7 +3274,8 @@
improvement_value(id));
gtk_set_label(GTK_BUTTON(pdialog->overview.sell_command)->child,
buf);
- gtk_widget_set_sensitive(pdialog->overview.sell_command, TRUE);
+ gtk_widget_set_sensitive(pdialog->overview.sell_command,
+ can_client_issue_orders());
}
}
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/cityrep.c
freeciv-1883/client/gui-gtk/cityrep.c
--- freeciv/client/gui-gtk/cityrep.c Thu Dec 12 23:11:06 2002
+++ freeciv-1883/client/gui-gtk/cityrep.c Sat Dec 14 21:48:34 2002
@@ -33,6 +33,7 @@
#include "support.h"
#include "unit.h"
+#include "civclient.h"
#include "chatline.h"
#include "citydlg.h"
#include "cityrepdata.h"
@@ -683,11 +684,12 @@
*****************************************************************/
static void city_list_callback(GtkWidget *w, gint row, gint column)
{
+ gtk_widget_set_sensitive(city_change_command, can_client_issue_orders());
+ gtk_widget_set_sensitive(city_select_command, can_client_issue_orders());
if (GTK_CLIST(city_list)->selection) {
- gtk_widget_set_sensitive(city_change_command, TRUE);
gtk_widget_set_sensitive(city_center_command, TRUE);
gtk_widget_set_sensitive(city_popup_command, TRUE);
- gtk_widget_set_sensitive(city_buy_command, TRUE);
+ gtk_widget_set_sensitive(city_buy_command, can_client_issue_orders());
} else {
gtk_widget_set_sensitive(city_center_command, FALSE);
gtk_widget_set_sensitive(city_popup_command, FALSE);
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/cma_fe.c
freeciv-1883/client/gui-gtk/cma_fe.c
--- freeciv/client/gui-gtk/cma_fe.c Mon Nov 25 17:54:59 2002
+++ freeciv-1883/client/gui-gtk/cma_fe.c Sat Dec 14 21:48:34 2002
@@ -24,6 +24,7 @@
#include "mem.h"
#include "support.h"
+#include "civclient.h"
#include "chatline_g.h"
#include "citydlg_g.h"
#include "cityrep.h"
@@ -351,10 +352,13 @@
}
gtk_widget_set_sensitive(GTK_WIDGET(pdialog->change_command),
+ can_client_issue_orders() &&
result.found_a_valid && !controlled);
gtk_widget_set_sensitive(GTK_WIDGET(pdialog->perm_command),
+ can_client_issue_orders() &&
result.found_a_valid && !controlled);
gtk_widget_set_sensitive(GTK_WIDGET(pdialog->release_command),
+ can_client_issue_orders() &&
controlled);
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/dialogs.c
freeciv-1883/client/gui-gtk/dialogs.c
--- freeciv/client/gui-gtk/dialogs.c Sat Dec 14 17:36:39 2002
+++ freeciv-1883/client/gui-gtk/dialogs.c Sat Dec 14 21:48:34 2002
@@ -2356,9 +2356,10 @@
size_t i;
int delta=10;
struct packet_player_request packet;
-
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+
+ if (!can_client_issue_orders()) {
return;
+ }
i= (size_t)data;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/gotodlg.c
freeciv-1883/client/gui-gtk/gotodlg.c
--- freeciv/client/gui-gtk/gotodlg.c Fri Nov 15 15:22:43 2002
+++ freeciv-1883/client/gui-gtk/gotodlg.c Sat Dec 14 21:48:34 2002
@@ -75,9 +75,7 @@
GtkWidget *scrolled;
GtkAccelGroup *accel=gtk_accel_group_new();
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
- if (!get_unit_in_focus()) {
+ if (!can_client_issue_orders() || !get_unit_in_focus()) {
return;
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/gui_main.c
freeciv-1883/client/gui-gtk/gui_main.c
--- freeciv/client/gui-gtk/gui_main.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-gtk/gui_main.c Sat Dec 14 21:48:34 2002
@@ -1015,6 +1015,11 @@
w = unit_below_pixmap[idx];
unit_ids[idx] = punit ? punit->id : 0;
}
+
+ if (get_client_state() == CLIENT_GAME_OVER_STATE) {
+ gtk_pixcomm_clear(GTK_PIXCOMM(w), TRUE);
+ return;
+ }
if (punit) {
gtk_pixcomm_clear(GTK_PIXCOMM(w), FALSE);
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/mapctrl.c
freeciv-1883/client/gui-gtk/mapctrl.c
--- freeciv/client/gui-gtk/mapctrl.c Fri Nov 15 15:22:43 2002
+++ freeciv-1883/client/gui-gtk/mapctrl.c Sat Dec 14 21:48:34 2002
@@ -279,8 +279,7 @@
int xtile, ytile;
/* when you get a <SHIFT>+<LMB> pow! */
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE
- || !(ev->state & GDK_SHIFT_MASK)) {
+ if (!can_client_issue_orders() || !(ev->state & GDK_SHIFT_MASK)) {
return TRUE;
}
@@ -296,11 +295,13 @@
gint butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev)
{
int xtile, ytile;
-
- if(get_client_state() != CLIENT_GAME_RUNNING_STATE)
+
+ if (!can_client_change_view()) {
return TRUE;
-
- if ((ev->button == 1) && (ev->state & GDK_SHIFT_MASK)) {
+ }
+
+ if (can_client_issue_orders()
+ && (ev->button == 1) && (ev->state & GDK_SHIFT_MASK)) {
adjust_workers(w, ev);
return TRUE;
}
@@ -367,7 +368,7 @@
struct packet_city_request packet;
enum city_tile_type wrk;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_issue_orders()) {
return;
}
@@ -421,14 +422,12 @@
}
ytile = ev->y / 2;
- if(get_client_state() != CLIENT_GAME_RUNNING_STATE)
- return TRUE;
-
- if (ev->button == 1) {
- do_unit_goto(xtile, ytile);
- } else if (ev->button == 3) {
+ if (can_client_change_view() && ev->button == 3) {
center_tile_mapcanvas(xtile, ytile);
+ } else if (can_client_issue_orders() && ev->button == 1) {
+ do_unit_goto(xtile, ytile);
}
+
return TRUE;
}
@@ -448,7 +447,7 @@
int x,y;
struct city *pcity;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
return;
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/mapview.c
freeciv-1883/client/gui-gtk/mapview.c
--- freeciv/client/gui-gtk/mapview.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-gtk/mapview.c Sat Dec 14 21:48:34 2002
@@ -382,7 +382,7 @@
**************************************************************************/
void update_unit_info_label(struct unit *punit)
{
- if(punit) {
+ if (punit && get_client_state() != CLIENT_GAME_OVER_STATE) {
char buffer[512];
struct city *pcity =
player_find_city_by_id(game.player_ptr, punit->homecity);
@@ -653,7 +653,7 @@
**************************************************************************/
gint overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev)
{
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
if(radar_gfx_sprite)
gdk_draw_pixmap(overview_canvas->window, civ_gc,
radar_gfx_sprite->pixmap, ev->area.x, ev->area.y,
@@ -832,7 +832,7 @@
map_resized=TRUE;
}
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
if (!intro_gfx_sprite) {
load_intro_gfx();
}
@@ -1573,8 +1573,9 @@
gfloat percent=adj->value;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
+ if (!can_client_change_view()) {
+ return;
+ }
last_map_view_x0=map_view_x0;
last_map_view_y0=map_view_y0;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/menu.c
freeciv-1883/client/gui-gtk/menu.c
--- freeciv/client/gui-gtk/menu.c Mon Nov 25 17:54:59 2002
+++ freeciv-1883/client/gui-gtk/menu.c Sat Dec 14 21:48:34 2002
@@ -970,7 +970,7 @@
*****************************************************************/
void update_menus(void)
{
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
menus_set_sensitive("<main>/_Reports", FALSE);
menus_set_sensitive("<main>/_Kingdom", FALSE);
menus_set_sensitive("<main>/_View", FALSE);
@@ -980,12 +980,11 @@
menus_set_sensitive("<main>/_Reports", TRUE);
menus_set_sensitive("<main>/_Kingdom", TRUE);
menus_set_sensitive("<main>/_View", TRUE);
- menus_set_sensitive("<main>/_Orders", !client_is_observer());
+ menus_set_sensitive("<main>/_Orders", can_client_issue_orders());
- menus_set_sensitive("<main>/_Kingdom/_Tax Rates", !client_is_observer());
- menus_set_sensitive("<main>/_Kingdom/Work_lists", !client_is_observer());
- menus_set_sensitive("<main>/_Kingdom/_Revolution",
- !client_is_observer());
+ menus_set_sensitive("<main>/_Kingdom/_Tax Rates",
can_client_issue_orders());
+ menus_set_sensitive("<main>/_Kingdom/Work_lists",
can_client_issue_orders());
+ menus_set_sensitive("<main>/_Kingdom/_Revolution",
can_client_issue_orders());
menus_set_sensitive("<main>/_Reports/S_paceship",
(game.player_ptr->spaceship.state!=SSHIP_NONE));
@@ -1012,7 +1011,7 @@
/* Remaining part of this function: Update Orders menu */
- if (client_is_observer()) {
+ if (!can_client_issue_orders()) {
return;
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/plrdlg.c
freeciv-1883/client/gui-gtk/plrdlg.c
--- freeciv/client/gui-gtk/plrdlg.c Thu Dec 12 23:11:06 2002
+++ freeciv-1883/client/gui-gtk/plrdlg.c Sat Dec 14 21:48:34 2002
@@ -30,6 +30,7 @@
#include "player.h"
#include "support.h"
+#include "civclient.h"
#include "chatline.h"
#include "climisc.h"
#include "clinet.h"
@@ -489,18 +490,18 @@
gtk_widget_set_sensitive(players_war_command, FALSE);
break;
default:
- gtk_widget_set_sensitive(players_war_command,
+ gtk_widget_set_sensitive(players_war_command, can_client_issue_orders() &&
game.player_idx != player_index);
}
- gtk_widget_set_sensitive(players_vision_command,
+ gtk_widget_set_sensitive(players_vision_command, can_client_issue_orders() &&
gives_shared_vision(game.player_ptr, pplayer));
if (pplayer->is_alive
&& pplayer != game.player_ptr
&& player_has_embassy(game.player_ptr, pplayer)) {
if (pplayer->is_connected)
- gtk_widget_set_sensitive(players_meet_command, TRUE);
+ gtk_widget_set_sensitive(players_meet_command,
can_client_issue_orders());
else
gtk_widget_set_sensitive(players_meet_command, FALSE);
gtk_widget_set_sensitive(players_int_command, TRUE);
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/repodlgs.c
freeciv-1883/client/gui-gtk/repodlgs.c
--- freeciv/client/gui-gtk/repodlgs.c Thu Dec 12 23:11:06 2002
+++ freeciv-1883/client/gui-gtk/repodlgs.c Sat Dec 14 21:48:34 2002
@@ -251,6 +251,7 @@
} else {
gfloat pct;
+ gtk_widget_set_sensitive(science_change_menu_button,
can_client_issue_orders());
my_snprintf(text, sizeof(text), "%d/%d",
game.player_ptr->research.bulbs_researched,
total_bulbs_required(game.player_ptr));
@@ -467,6 +468,7 @@
gtk_option_menu_set_menu(GTK_OPTION_MENU(science_change_menu_button),
popupmenu);
+ gtk_widget_set_sensitive(science_change_menu_button,
can_client_issue_orders());
gtk_widget_destroy(goalmenu);
goalmenu = gtk_menu_new();
@@ -517,6 +519,7 @@
gtk_option_menu_set_menu(GTK_OPTION_MENU(science_goal_menu_button),
goalmenu);
+ gtk_widget_set_sensitive(science_goal_menu_button,
can_client_issue_orders());
}
}
@@ -648,8 +651,10 @@
bool is_sellable = (i >= 0 && i < game.num_impr_types && !is_wonder(i));
gtk_widget_set_sensitive(sellobsolete_command, is_sellable
+ && can_client_issue_orders()
&& improvement_obsolete(game.player_ptr, i));
- gtk_widget_set_sensitive(sellall_command, is_sellable);
+ gtk_widget_set_sensitive(sellall_command, is_sellable
+ && can_client_issue_orders());
}
/****************************************************************
@@ -881,7 +886,7 @@
{
if ((unit_type_exists(activeunits_type[row])) &&
(can_upgrade_unittype(game.player_ptr, activeunits_type[row]) != -1))
- gtk_widget_set_sensitive(upgrade_command, TRUE);
+ gtk_widget_set_sensitive(upgrade_command, can_client_issue_orders());
}
/****************************************************************
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk/wldlg.c
freeciv-1883/client/gui-gtk/wldlg.c
--- freeciv/client/gui-gtk/wldlg.c Fri Nov 15 15:22:43 2002
+++ freeciv-1883/client/gui-gtk/wldlg.c Sat Dec 14 21:48:34 2002
@@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include "civclient.h"
#include "city.h"
#include "fcintl.h"
#include "game.h"
@@ -910,7 +911,7 @@
int row_selected;
struct worklist_editor *peditor = (struct worklist_editor *) data;
- if (ev && ev->type == GDK_2BUTTON_PRESS) {
+ if (can_client_issue_orders() && ev && ev->type == GDK_2BUTTON_PRESS) {
/* Double-click to remove item from worklist */
worklist_remove_item(peditor);
return;
@@ -918,8 +919,10 @@
row_selected = (GTK_CLIST(peditor->worklist)->selection != NULL);
- gtk_widget_set_sensitive(peditor->btn_up, row_selected && row > 0);
- gtk_widget_set_sensitive(peditor->btn_down, row_selected &&
+ gtk_widget_set_sensitive(peditor->btn_up, can_client_issue_orders() &&
+ row_selected && row > 0 );
+ gtk_widget_set_sensitive(peditor->btn_down, can_client_issue_orders() &&
+ row_selected &&
row < GTK_CLIST(peditor->worklist)->rows - 1);
}
@@ -929,7 +932,7 @@
static void targets_select_callback(GtkWidget * w, gint row, gint column,
GdkEvent * ev, gpointer data)
{
- if (ev && ev->type == GDK_2BUTTON_PRESS) {
+ if (can_client_issue_orders() && ev && ev->type == GDK_2BUTTON_PRESS) {
struct worklist_editor *peditor = (struct worklist_editor *) data;
/* Double-click to insert item in worklist */
worklist_insert_item(peditor);
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk-2.0/dialogs.c
freeciv-1883/client/gui-gtk-2.0/dialogs.c
--- freeciv/client/gui-gtk-2.0/dialogs.c Thu Dec 12 23:11:06 2002
+++ freeciv-1883/client/gui-gtk-2.0/dialogs.c Sat Dec 14 21:48:34 2002
@@ -2282,8 +2282,9 @@
int delta=10;
struct packet_player_request packet;
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_issue_orders()) {
return TRUE;
+ }
i= (size_t)data;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk-2.0/gotodlg.c
freeciv-1883/client/gui-gtk-2.0/gotodlg.c
--- freeciv/client/gui-gtk-2.0/gotodlg.c Fri Nov 15 15:22:43 2002
+++ freeciv-1883/client/gui-gtk-2.0/gotodlg.c Sat Dec 14 21:48:34 2002
@@ -75,9 +75,7 @@
GtkWidget *scrolled;
GtkAccelGroup *accel=gtk_accel_group_new();
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
- if (!get_unit_in_focus()) {
+ if (!can_client_issue_orders() || !get_unit_in_focus()) {
return;
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk-2.0/mapctrl.c
freeciv-1883/client/gui-gtk-2.0/mapctrl.c
--- freeciv/client/gui-gtk-2.0/mapctrl.c Fri Nov 15 15:22:43 2002
+++ freeciv-1883/client/gui-gtk-2.0/mapctrl.c Sat Dec 14 21:48:34 2002
@@ -271,8 +271,7 @@
int xtile, ytile;
/* when you get a <SHIFT>+<LMB> pow! */
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE
- || !(ev->state & GDK_SHIFT_MASK)) {
+ if (!can_client_issue_orders() || !(ev->state & GDK_SHIFT_MASK)) {
return TRUE;
}
@@ -288,11 +287,13 @@
gboolean butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
{
int xtile, ytile;
-
- if(get_client_state() != CLIENT_GAME_RUNNING_STATE)
+
+ if (!can_client_change_view()) {
return TRUE;
-
- if ((ev->button == 1) && (ev->state & GDK_SHIFT_MASK)) {
+ }
+
+ if (can_client_issue_orders()
+ && (ev->button == 1) && (ev->state & GDK_SHIFT_MASK)) {
adjust_workers(w, ev);
return TRUE;
}
@@ -359,7 +360,7 @@
struct packet_city_request packet;
enum city_tile_type wrk;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_issue_orders()) {
return;
}
@@ -412,15 +413,13 @@
(map_view_x0 + map_canvas_store_twidth / 2));
}
ytile = ev->y / 2;
-
- if(get_client_state() != CLIENT_GAME_RUNNING_STATE)
- return TRUE;
- if (ev->button == 1) {
- do_unit_goto(xtile, ytile);
- } else if (ev->button == 3) {
+ if (can_client_change_view() && (ev->button == 3)) {
center_tile_mapcanvas(xtile, ytile);
+ } else if (can_client_issue_orders() && (ev->button == 1)) {
+ do_unit_goto(xtile, ytile);
}
+
return TRUE;
}
@@ -440,7 +439,7 @@
int x,y;
struct city *pcity;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
return;
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk-2.0/mapview.c
freeciv-1883/client/gui-gtk-2.0/mapview.c
--- freeciv/client/gui-gtk-2.0/mapview.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-gtk-2.0/mapview.c Sat Dec 14 21:48:34 2002
@@ -659,11 +659,12 @@
**************************************************************************/
gboolean overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer
data)
{
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
- if(radar_gfx_sprite)
+ if (!can_client_change_view()) {
+ if (radar_gfx_sprite) {
gdk_draw_pixmap(overview_canvas->window, civ_gc,
radar_gfx_sprite->pixmap, ev->area.x, ev->area.y,
ev->area.x, ev->area.y, ev->area.width, ev->area.height);
+ }
return TRUE;
}
@@ -830,7 +831,7 @@
gdk_draw_rectangle(map_canvas_store, fill_bg_gc, TRUE, 0, 0, -1, -1);
update_map_canvas_scrollbars_size();
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+ if (can_client_change_view()) {
if (map.xsize) { /* do we have a map at all */
update_map_canvas_visible();
update_map_canvas_scrollbars();
@@ -851,7 +852,7 @@
{
static bool cleared = FALSE;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
if (map_configure || !scaled_intro_sprite) {
if (!intro_gfx_sprite) {
@@ -1645,8 +1646,9 @@
gfloat percent=adj->value;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
+ if (!can_client_change_view()) {
+ return;
+ }
last_map_view_x0=map_view_x0;
last_map_view_y0=map_view_y0;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-gtk-2.0/menu.c
freeciv-1883/client/gui-gtk-2.0/menu.c
--- freeciv/client/gui-gtk-2.0/menu.c Mon Nov 25 17:54:59 2002
+++ freeciv-1883/client/gui-gtk-2.0/menu.c Sat Dec 14 21:48:34 2002
@@ -965,7 +965,7 @@
*****************************************************************/
void update_menus(void)
{
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
menus_set_sensitive("<main>/_Reports", FALSE);
menus_set_sensitive("<main>/_Kingdom", FALSE);
menus_set_sensitive("<main>/_View", FALSE);
@@ -975,12 +975,12 @@
menus_set_sensitive("<main>/_Reports", TRUE);
menus_set_sensitive("<main>/_Kingdom", TRUE);
menus_set_sensitive("<main>/_View", TRUE);
- menus_set_sensitive("<main>/_Orders", !client_is_observer());
+ menus_set_sensitive("<main>/_Orders", can_client_issue_orders());
- menus_set_sensitive("<main>/_Kingdom/_Tax Rates", !client_is_observer());
- menus_set_sensitive("<main>/_Kingdom/Work_lists", !client_is_observer());
+ menus_set_sensitive("<main>/_Kingdom/_Tax Rates",
can_client_issue_orders());
+ menus_set_sensitive("<main>/_Kingdom/Work_lists",
can_client_issue_orders());
menus_set_sensitive("<main>/_Kingdom/_Revolution",
- !client_is_observer());
+ can_client_issue_orders());
menus_set_sensitive("<main>/_Reports/S_paceship",
(game.player_ptr->spaceship.state!=SSHIP_NONE));
@@ -1011,6 +1011,12 @@
return;
}
+ /* Remaining part of this function: Update Orders menu */
+
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
if((punit=get_unit_in_focus())) {
char *irrfmt = _("Change to %s (_I)");
char *minfmt = _("Change to %s (_M)");
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-mui/gui_main.c
freeciv-1883/client/gui-mui/gui_main.c
--- freeciv/client/gui-mui/gui_main.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-mui/gui_main.c Sat Dec 14 21:48:34 2002
@@ -412,8 +412,7 @@
}
break;
case END_TURN:
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE)
- key_end_turn();
+ key_end_turn();
break;
case NEXT_UNIT:
advance_unit_focus(); /*focus_to_next_unit(); */
@@ -727,7 +726,7 @@
int delta = 10;
struct packet_player_request packet;
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_issue_orders())
return;
i = (size_t) * number;
@@ -1183,7 +1182,7 @@
**************************************************************************/
void update_menus(void) /* from menu.c */
{
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
{
menu_title_sensitive(MENU_REPORT, FALSE);
menu_title_sensitive(MENU_ORDER, FALSE);
@@ -1207,13 +1206,17 @@
}
menu_title_sensitive(MENU_REPORT, TRUE);
- menu_title_sensitive(MENU_ORDER, punit ? TRUE : FALSE);
+ menu_title_sensitive(MENU_ORDER, punit ? can_client_issue_orders() :
FALSE);
menu_title_sensitive(MENU_VIEW, TRUE);
menu_title_sensitive(MENU_KINGDOM, TRUE);
+ menu_title_sensitive(MENU_KINGDOM_TAX_RATE, can_client_issue_orders());
+ menu_title_sensitive(MENU_KINGDOM_WORKLISTS, can_client_issue_orders());
+ menu_title_sensitive(MENU_KINGDOM_REVOLUTION, can_client_issue_orders());
+
menu_entry_sensitive(MENU_REPORT_SPACESHIP,
(game.player_ptr->spaceship.state != SSHIP_NONE));
- if (punit)
+ if (punit && can_client_issue_orders())
{
const char *chgfmt = _("Change to %s");
static char irrtext[64];
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-mui/mapclass.c
freeciv-1883/client/gui-mui/mapclass.c
--- freeciv/client/gui-mui/mapclass.c Thu Dec 12 23:11:06 2002
+++ freeciv-1883/client/gui-mui/mapclass.c Sat Dec 14 21:48:34 2002
@@ -782,7 +782,7 @@
}
}
- if (redraw && get_client_state() == CLIENT_GAME_RUNNING_STATE)
+ if (redraw && can_client_change_view())
{
data->old_horiz_first = data->horiz_first;
data->old_vert_first = data->vert_first;
@@ -1082,7 +1082,7 @@
DoSuperMethodA(cl, o, (Msg) msg);
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE)
+ if (can_client_change_view())
{
BOOL drawmap = FALSE;
if (msg->flags & MADF_DRAWUPDATE)
@@ -1587,7 +1587,7 @@
}
- if (msg->imsg && (get_client_state() == CLIENT_GAME_RUNNING_STATE))
+ if (msg->imsg && can_client_change_view())
{
UWORD qual = msg->imsg->Qualifier;
@@ -1666,7 +1666,7 @@
if (data->context_menu)
MUI_DisposeObject(data->context_menu);
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE)
+ if (can_client_change_view())
{
if (_isinobject(msg->mx, msg->my))
{
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-mui/overviewclass.c
freeciv-1883/client/gui-mui/overviewclass.c
--- freeciv/client/gui-mui/overviewclass.c Fri Nov 15 15:22:44 2002
+++ freeciv-1883/client/gui-mui/overviewclass.c Sat Dec 14 21:48:34 2002
@@ -449,7 +449,7 @@
MUI_RequestIDCMP(o, IDCMP_MOUSEBUTTONS);
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE)
+ if (can_client_change_view())
{
Overview_FillBuffer(data);
}
@@ -510,7 +510,7 @@
DoSuperMethodA(cl, o, (Msg) msg);
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE)
+ if (can_client_change_view())
{
LONG scalex = data->ov_ScaleX;
LONG scaley = data->ov_ScaleY;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-win32/gotodlg.c
freeciv-1883/client/gui-win32/gotodlg.c
--- freeciv/client/gui-win32/gotodlg.c Fri Nov 15 15:22:44 2002
+++ freeciv-1883/client/gui-win32/gotodlg.c Sat Dec 14 21:48:34 2002
@@ -140,7 +140,7 @@
struct fcwin_box *vbox;
if (goto_dialog)
return;
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
return;
if (get_unit_in_focus()==0)
return;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-win32/gui_main.c
freeciv-1883/client/gui-win32/gui_main.c
--- freeciv/client/gui-win32/gui_main.c Thu Dec 12 23:11:07 2002
+++ freeciv-1883/client/gui-win32/gui_main.c Sat Dec 14 21:48:34 2002
@@ -460,7 +460,7 @@
static VOID CALLBACK blink_timer(HWND hwnd, UINT uMsg, UINT idEvent,
DWORD dwTime)
{
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+ if (can_client_change_view()) {
check_mapstore();
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-win32/mapctrl.c
freeciv-1883/client/gui-win32/mapctrl.c
--- freeciv/client/gui-win32/mapctrl.c Fri Nov 15 15:22:44 2002
+++ freeciv-1883/client/gui-win32/mapctrl.c Sat Dec 14 21:48:34 2002
@@ -273,7 +273,7 @@
case WM_CREATE:
break;
case WM_LBUTTONDOWN:
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
break;
SetFocus(root_window);
get_map_xy(LOWORD(lParam),HIWORD(lParam),&xtile,&ytile);
@@ -287,13 +287,13 @@
}
break;
case WM_MBUTTONDOWN:
- if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+ if (can_client_change_view()) {
get_map_xy(LOWORD(lParam), HIWORD(lParam), &xtile, &ytile);
popit(LOWORD(lParam), HIWORD(lParam), xtile, ytile);
}
break;
case WM_RBUTTONDOWN:
- if (get_client_state()==CLIENT_GAME_RUNNING_STATE) {
+ if (can_client_change_view()) {
get_map_xy(LOWORD(lParam),HIWORD(lParam),&xtile,&ytile);
if (wParam&MK_CONTROL) {
popit(LOWORD(lParam),HIWORD(lParam),xtile,ytile);
@@ -315,7 +315,7 @@
}
break;
case WM_MOUSEMOVE:
- if (get_client_state()==CLIENT_GAME_RUNNING_STATE) {
+ if (can_client_change_view()) {
map_handle_move(LOWORD(lParam),HIWORD(lParam));
}
break;
@@ -365,8 +365,9 @@
ytile=y/2;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return ;
+ if (!can_client_change_view()) {
+ return;
+ }
center_tile_mapcanvas(xtile,ytile);
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-win32/mapview.c
freeciv-1883/client/gui-win32/mapview.c
--- freeciv/client/gui-win32/mapview.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-win32/mapview.c Sat Dec 14 21:48:34 2002
@@ -117,7 +117,7 @@
map_view_width=(map_win_width+NORMAL_TILE_WIDTH-1)/NORMAL_TILE_WIDTH;
map_view_height=(map_win_height+NORMAL_TILE_HEIGHT-1)/NORMAL_TILE_HEIGHT;
update_map_canvas_scrollbars_size();
- if ((get_client_state()==CLIENT_GAME_RUNNING_STATE)&&(map.xsize))
+ if (can_client_change_view() && (map.xsize != 0))
{
update_map_canvas_visible();
update_map_canvas_scrollbars();
@@ -154,7 +154,7 @@
HBITMAP bmsave;
HDC introgfxdc;
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
{
if (!intro_gfx_sprite) load_intro_gfx();
if (!intro_gfx) intro_gfx=BITMAP2HBITMAP(&intro_gfx_sprite->bmp);
@@ -1238,7 +1238,7 @@
HBITMAP old;
HBITMAP bmp;
int i;
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
{
if (!radar_gfx_sprite) {
load_intro_gfx();
@@ -1304,7 +1304,7 @@
**************************************************************************/
void map_handle_hscroll(int pos)
{
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
return;
map_view_x=pos;
update_map_canvas_visible();
@@ -1316,7 +1316,7 @@
**************************************************************************/
void map_handle_vscroll(int pos)
{
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view())
return;
map_view_y=pos;
map_view_y=(map_view_y<0)?0:map_view_y;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-win32/menu.c
freeciv-1883/client/gui-win32/menu.c
--- freeciv/client/gui-win32/menu.c Fri Nov 15 15:22:44 2002
+++ freeciv-1883/client/gui-win32/menu.c Sat Dec 14 21:48:34 2002
@@ -860,7 +860,7 @@
enum MenuID id;
HMENU menu;
menu=GetMenu(root_window);
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_issue_orders())
{
for(id=IDM_KINGDOM_MENU+1;id<IDM_HELP_MENU;id++)
my_enable_menu(menu,id,FALSE);
@@ -881,6 +881,10 @@
for(id=IDM_KINGDOM_MENU+1;id<IDM_HELP_MENU;id++)
my_enable_menu(menu,id,TRUE);
+ my_enable_menu(menu, IDM_KINGDOM_TAX, can_client_issue_orders());
+ my_enable_menu(menu, IDM_KINGDOM_WORK, can_client_issue_orders());
+ my_enable_menu(menu, IDM_KINGDOM_REVOLUTION, can_client_issue_orders());
+
my_enable_menu(menu,IDM_GAME_LOCAL_OPT,TRUE);
my_enable_menu(menu,IDM_GAME_MESSAGE_OPT,TRUE);
my_enable_menu(menu,IDM_GAME_SAVE_SETTINGS,TRUE);
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-xaw/actions.c
freeciv-1883/client/gui-xaw/actions.c
--- freeciv/client/gui-xaw/actions.c Fri Nov 15 15:22:44 2002
+++ freeciv-1883/client/gui-xaw/actions.c Sat Dec 14 21:48:34 2002
@@ -193,105 +193,105 @@
static void xaw_key_open_city_report(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_CITIES))
popup_city_report_dialog(0);
}
static void xaw_key_open_demographics(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_DEMOGRAPHIC))
send_report_request(REPORT_DEMOGRAPHIC);
}
static void xaw_key_open_economy_report(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_ECONOMY))
popup_economy_report_dialog(0);
}
static void xaw_key_open_find_city(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_KINGDOM, MENU_KINGDOM_FIND_CITY))
popup_find_dialog();
}
static void xaw_key_open_goto_airlift(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_ORDER, MENU_ORDER_GOTO_CITY))
popup_goto_dialog();
}
static void xaw_key_open_messages(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_MESSAGES))
popup_meswin_dialog();
}
static void xaw_key_open_players(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_PLAYERS))
popup_players_dialog();
}
static void xaw_key_open_rates(Widget w, XEvent *event, String *argv, Cardinal
*argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_KINGDOM, MENU_KINGDOM_RATES))
popup_rates_dialog();
}
static void xaw_key_open_revolution(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_KINGDOM, MENU_KINGDOM_REVOLUTION))
popup_revolution_dialog();
}
static void xaw_key_open_science_report(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_SCIENCE))
popup_science_dialog(0);
}
static void xaw_key_open_spaceship(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_SPACESHIP))
popup_spaceship_dialog(game.player_ptr);
}
static void xaw_key_open_top_five(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_TOP_CITIES))
send_report_request(REPORT_TOP_5_CITIES);
}
static void xaw_key_open_units_report(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_UNITS))
popup_activeunits_report_dialog(0);
}
static void xaw_key_open_wonders(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_REPORT, MENU_REPORT_WOW))
send_report_request(REPORT_WONDERS_OF_THE_WORLD);
}
static void xaw_key_open_worklists(Widget w, XEvent *event, String *argv,
Cardinal *argc)
{
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ if (can_client_change_view() &&
is_menu_item_active(MENU_KINGDOM, MENU_KINGDOM_WORKLISTS))
popup_worklists_dialog(game.player_ptr);
}
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-xaw/dialogs.c
freeciv-1883/client/gui-xaw/dialogs.c
--- freeciv/client/gui-xaw/dialogs.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-xaw/dialogs.c Sat Dec 14 21:48:34 2002
@@ -2443,8 +2443,9 @@
int delta=10;
struct packet_player_request packet;
- if (get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_issue_orders) {
return;
+ }
i= (size_t)client_data;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-xaw/gotodlg.c
freeciv-1883/client/gui-xaw/gotodlg.c
--- freeciv/client/gui-xaw/gotodlg.c Fri Nov 15 15:22:44 2002
+++ freeciv-1883/client/gui-xaw/gotodlg.c Sat Dec 14 21:48:34 2002
@@ -98,8 +98,9 @@
Dimension width, height;
Boolean no_player_cities = !(city_list_size(&game.player_ptr->cities));
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_issue_orders()) {
return;
+ }
if(get_unit_in_focus()==0)
return;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-xaw/mapctrl.c
freeciv-1883/client/gui-xaw/mapctrl.c
--- freeciv/client/gui-xaw/mapctrl.c Fri Nov 15 15:22:45 2002
+++ freeciv-1883/client/gui-xaw/mapctrl.c Sat Dec 14 21:48:34 2002
@@ -240,8 +240,9 @@
int map_x, map_y, is_real;
XButtonEvent *ev=&event->xbutton;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
map_x = map_view_x0 + ev->x / NORMAL_TILE_WIDTH;
map_y = map_view_y0 + ev->y / NORMAL_TILE_HEIGHT;
@@ -259,8 +260,9 @@
int x, y;
XButtonEvent *ev=&event->xbutton;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
get_map_xy(ev->x, ev->y, &x, &y);
@@ -326,8 +328,9 @@
struct packet_city_request packet;
enum city_tile_type wrk;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
map_x = map_view_x0 + ev->x / NORMAL_TILE_WIDTH;
map_y = map_view_y0 + ev->y / NORMAL_TILE_HEIGHT;
@@ -367,8 +370,9 @@
XButtonEvent *ev=&event->xbutton;
struct city *pcity;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+ if (!can_client_change_view()) {
return;
+ }
x = map_view_x0 + ev->x / NORMAL_TILE_WIDTH;
y = map_view_y0 + ev->y / NORMAL_TILE_HEIGHT;
@@ -394,8 +398,9 @@
xtile=ev->x/2-(map.xsize/2-(map_view_x0+map_canvas_store_twidth/2));
ytile=ev->y/2;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
+ if (!can_client_change_view()) {
+ return;
+ }
if(ev->button==Button1)
do_unit_goto(xtile,ytile);
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-xaw/mapview.c
freeciv-1883/client/gui-xaw/mapview.c
--- freeciv/client/gui-xaw/mapview.c Sat Dec 14 17:36:40 2002
+++ freeciv-1883/client/gui-xaw/mapview.c Sat Dec 14 21:48:34 2002
@@ -439,8 +439,8 @@
{
Dimension height, width;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
- if(radar_gfx_sprite)
+ if (!can_client_change_view()) {
+ if (radar_gfx_sprite)
XCopyArea(display, radar_gfx_sprite->pixmap, XtWindow(overview_canvas),
civ_gc,
event->xexpose.x, event->xexpose.y,
@@ -555,11 +555,15 @@
tile_width=(width+NORMAL_TILE_WIDTH-1)/NORMAL_TILE_WIDTH;
tile_height=(height+NORMAL_TILE_HEIGHT-1)/NORMAL_TILE_HEIGHT;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
- if(!intro_gfx_sprite) load_intro_gfx();
- if(height!=scaled_intro_pixmap_height || width!=scaled_intro_pixmap_width)
{
- if(scaled_intro_pixmap)
+ if (!can_client_change_view()) {
+ if (!intro_gfx_sprite) {
+ load_intro_gfx();
+ }
+ if (height != scaled_intro_pixmap_height
+ || width != scaled_intro_pixmap_width) {
+ if (scaled_intro_pixmap) {
XFreePixmap(display, scaled_intro_pixmap);
+ }
scaled_intro_pixmap=x_scale_pixmap(intro_gfx_sprite->pixmap,
intro_gfx_sprite->width,
@@ -1092,8 +1096,9 @@
{
float percent=*(float*)percent_ptr;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
+ if (!can_client_change_view()) {
+ return;
+ }
if(w==map_horizontal_scrollbar)
map_view_x0=percent*map.xsize;
@@ -1121,9 +1126,9 @@
{
int position = XTPOINTER_TO_INT(position_val), is_real;
-
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
- return;
+ if (!can_client_change_view()) {
+ return;
+ }
if(w==map_horizontal_scrollbar) {
if(position>0)
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-xaw/menu.c
freeciv-1883/client/gui-xaw/menu.c
--- freeciv/client/gui-xaw/menu.c Mon Nov 25 17:55:00 2002
+++ freeciv-1883/client/gui-xaw/menu.c Sat Dec 14 21:48:34 2002
@@ -246,7 +246,7 @@
*****************************************************************/
void update_menus(void)
{
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
XtSetSensitive(menus[MENU_REPORT]->button, False);
XtSetSensitive(menus[MENU_ORDER]->button, False);
XtSetSensitive(menus[MENU_VIEW]->button, False);
@@ -275,10 +275,17 @@
}
XtSetSensitive(menus[MENU_REPORT]->button, True);
- XtSetSensitive(menus[MENU_ORDER]->button, (punit != NULL));
+ XtSetSensitive(menus[MENU_ORDER]->button, punit
+ && can_client_issue_orders());
XtSetSensitive(menus[MENU_VIEW]->button, True);
XtSetSensitive(menus[MENU_KINGDOM]->button, True);
+ menu_entry_sensitive(MENU_KINGDOM, MENU_KINGDOM_RATES,
+ can_client_issue_orders());
+ menu_entry_sensitive(MENU_KINGDOM, MENU_KINGDOM_WORKLISTS,
+ can_client_issue_orders());
+ menu_entry_sensitive(MENU_KINGDOM, MENU_KINGDOM_REVOLUTION,
+ can_client_issue_orders());
menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_CITY_GROWTH,
draw_city_names);
menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_TERRAIN, 1);
@@ -306,7 +313,7 @@
menu_entry_sensitive(MENU_REPORT, MENU_REPORT_SPACESHIP,
(game.player_ptr->spaceship.state!=SSHIP_NONE));
- if(punit) {
+ if (punit && can_client_issue_orders()) {
enum tile_terrain_type ttype;
struct tile_type * tinfo;
diff -urN -Xfreeciv/diff_ignore freeciv/client/mapctrl_common.c
freeciv-1883/client/mapctrl_common.c
--- freeciv/client/mapctrl_common.c Fri Nov 15 15:22:39 2002
+++ freeciv-1883/client/mapctrl_common.c Sat Dec 14 21:48:34 2002
@@ -55,9 +55,8 @@
turn_done_state);
}
- new_state = (get_client_state() == CLIENT_GAME_RUNNING_STATE
+ new_state = (can_client_issue_orders()
&& !game.player_ptr->turn_done && !agents_busy()
- && !client_is_observer()
&& !turn_done_sent);
if (new_state == turn_done_state) {
return;
diff -urN -Xfreeciv/diff_ignore freeciv/client/packhand.c
freeciv-1883/client/packhand.c
--- freeciv/client/packhand.c Thu Dec 12 23:11:05 2002
+++ freeciv-1883/client/packhand.c Sat Dec 14 21:48:34 2002
@@ -275,7 +275,7 @@
**************************************************************************/
void handle_game_state(struct packet_generic_integer *packet)
{
- if(get_client_state()==CLIENT_SELECT_RACE_STATE &&
+ if (get_client_state()==CLIENT_SELECT_RACE_STATE &&
packet->value==CLIENT_GAME_RUNNING_STATE &&
game.player_ptr->nation == MAX_NUM_NATIONS) {
popdown_races_dialog();
@@ -283,7 +283,7 @@
set_client_state(packet->value);
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE) {
+ if (get_client_state()==CLIENT_GAME_RUNNING_STATE) {
refresh_overview_canvas();
refresh_overview_viewrect();
player_set_unit_focus_status(game.player_ptr);
@@ -298,6 +298,15 @@
free_intro_radar_sprites();
agents_game_start();
}
+
+ if (get_client_state() == CLIENT_GAME_OVER_STATE) {
+ refresh_overview_canvas();
+ refresh_overview_viewrect();
+
+ update_info_label();
+ update_unit_focus();
+ update_unit_info_label(NULL);
+ }
}
/**************************************************************************
@@ -448,7 +457,7 @@
pcity->occupied =
(unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0);
- popup = (city_is_new && get_client_state()==CLIENT_GAME_RUNNING_STATE &&
+ popup = (city_is_new && can_client_change_view() &&
pcity->owner==game.player_idx && popup_new_cities)
|| packet->diplomat_investigate;
@@ -488,7 +497,7 @@
}
}
- if (draw_map_grid && get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+ if (draw_map_grid && can_client_change_view()) {
queue_mapview_update();
} else {
refresh_tile_mapcanvas(pcity->x, pcity->y, TRUE);
@@ -1076,7 +1085,7 @@
game.heating=pinfo->heating;
game.nuclearwinter=pinfo->nuclearwinter;
game.cooling=pinfo->cooling;
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
+ if (!can_client_change_view()) {
improvement_status_init(game.improvements,
ARRAY_SIZE(game.improvements));
@@ -1110,9 +1119,8 @@
/* Only update effects if a new wonder appeared or was destroyed */
try_update_effects(need_effect_update);
- if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
- if(get_client_state()==CLIENT_SELECT_RACE_STATE)
- popdown_races_dialog();
+ if (get_client_state() == CLIENT_SELECT_RACE_STATE) {
+ popdown_races_dialog();
}
game.techpenalty=pinfo->techpenalty;
game.foodbox=pinfo->foodbox;
@@ -1120,7 +1128,7 @@
game.unhappysize = pinfo->unhappysize;
game.cityfactor = pinfo->cityfactor;
- boot_help = (get_client_state() == CLIENT_GAME_RUNNING_STATE
+ boot_help = (can_client_change_view()
&& game.spacerace != pinfo->spacerace);
game.spacerace=pinfo->spacerace;
if (game.timeout != 0) {
@@ -1208,7 +1216,7 @@
pplayer->future_tech=pinfo->future_tech;
pplayer->ai.tech_goal=pinfo->tech_goal;
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE &&
pplayer==game.player_ptr) {
+ if(can_client_change_view() && pplayer==game.player_ptr) {
if(poptechup) {
if(!game.player_ptr->ai.control || ai_popup_windows)
popup_science_dialog(TRUE);
@@ -1246,7 +1254,7 @@
(pplayer->revolution < 1 || pplayer->revolution > 5) &&
pplayer->government == game.government_when_anarchy &&
(!game.player_ptr->ai.control || ai_popup_windows) &&
- (get_client_state() == CLIENT_GAME_RUNNING_STATE)) {
+ can_client_change_view()) {
create_event(-1, -1, E_REVOLT_DONE, _("Game: Revolution finished"));
popup_government_dialog();
}
@@ -1254,8 +1262,7 @@
update_players_dialog();
update_worklist_report_dialog();
- if (pplayer == game.player_ptr
- && get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+ if (pplayer == game.player_ptr && can_client_change_view()) {
update_info_label();
}
}
@@ -1598,7 +1605,7 @@
}
/* refresh tiles */
- if(get_client_state()==CLIENT_GAME_RUNNING_STATE) {
+ if (can_client_change_view()) {
int x = packet->x, y = packet->y;
/* the tile itself */
|
|