[Freeciv-Dev] (PR#2714) Meet and intelligence code wrapping in client
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] (PR#2714) Meet and intelligence code wrapping in client |
From: |
"Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Fri, 3 Jan 2003 18:48:01 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
This wraps some checks for meet and intelligence in clients and puts them
in client-common code. This is taken from the AI diplomacy patch.
Client authors, please read carefully. I was not.
- Per
Index: civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.159
diff -u -r1.159 civclient.c
--- civclient.c 2003/01/01 11:51:32 1.159
+++ civclient.c 2003/01/04 02:44:16
@@ -815,6 +815,30 @@
}
/**************************************************************************
+ Returns TRUE iff the client can do diplomatic meetings with another
+ given player.
+**************************************************************************/
+bool can_meet_with_player(struct player *pplayer)
+{
+ return (pplayer->is_alive
+ && pplayer != game.player_ptr
+ && player_has_embassy(game.player_ptr, pplayer)
+ && pplayer->is_connected
+ && can_client_issue_orders());
+}
+
+/**************************************************************************
+ Returns TRUE iff the client can get intelligence from another
+ given player.
+**************************************************************************/
+bool can_intel_with_player(struct player *pplayer)
+{
+ return (pplayer->is_alive
+ && pplayer != game.player_ptr
+ && player_has_embassy(game.player_ptr, pplayer));
+}
+
+/**************************************************************************
Return TRUE if the client can change the view; i.e. if the mapview is
active. This function should be called each time before allowing the
user to do mapview actions.
Index: civclient.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.h,v
retrieving revision 1.25
diff -u -r1.25 civclient.h
--- civclient.h 2003/01/01 11:51:32 1.25
+++ civclient.h 2003/01/04 02:44:16
@@ -56,6 +56,8 @@
void real_timer_callback(void);
bool can_client_issue_orders(void);
bool can_client_change_view(void);
+bool can_meet_with_player(struct player *pplayer);
+bool can_intel_with_player(struct player *pplayer);
void client_game_init(void);
void client_game_free(void);
Index: gui-gtk/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/plrdlg.c,v
retrieving revision 1.43
diff -u -r1.43 plrdlg.c
--- gui-gtk/plrdlg.c 2003/01/01 11:51:33 1.43
+++ gui-gtk/plrdlg.c 2003/01/04 02:44:16
@@ -499,20 +499,10 @@
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,
- can_client_issue_orders());
- else
- gtk_widget_set_sensitive(players_meet_command, FALSE);
- gtk_widget_set_sensitive(players_int_command, TRUE);
- return;
- }
-
- gtk_widget_set_sensitive(players_meet_command, FALSE);
- gtk_widget_set_sensitive(players_int_command, FALSE);
+ gtk_widget_set_sensitive(players_meet_command,
+ can_meet_with_player(pplayer));
+ gtk_widget_set_sensitive(players_int_command,
+ can_intel_with_player(pplayer));
}
void players_list_ucallback(GtkWidget *w, gint row, gint column)
Index: gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.13
diff -u -r1.13 plrdlg.c
--- gui-gtk-2.0/plrdlg.c 2002/12/30 02:32:02 1.13
+++ gui-gtk-2.0/plrdlg.c 2003/01/04 02:44:17
@@ -161,13 +161,9 @@
gtk_widget_set_sensitive(players_vision_command,
gives_shared_vision(game.player_ptr, plr));
- if (plr->is_alive
- && plr != game.player_ptr
- && player_has_embassy(game.player_ptr, plr)) {
- gtk_widget_set_sensitive(players_meet_command, plr->is_connected);
- gtk_widget_set_sensitive(players_int_command, TRUE);
- return;
- }
+ gtk_widget_set_sensitive(players_meet_command, can_meet_with_player(plr));
+ gtk_widget_set_sensitive(players_int_command, can_intel_with_player(plr));
+ return;
}
gtk_widget_set_sensitive(players_meet_command, FALSE);
Index: gui-mui/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/plrdlg.c,v
retrieving revision 1.25
diff -u -r1.25 plrdlg.c
--- gui-mui/plrdlg.c 2002/11/14 09:14:57 1.25
+++ gui-mui/plrdlg.c 2003/01/04 02:44:17
@@ -208,17 +208,10 @@
set(player_vision_button, MUIA_Disabled,
!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)
- set(player_meet_button, MUIA_Disabled, FALSE);
- else
- set(player_meet_button, MUIA_Disabled, TRUE);
- set(player_intelligence_button, MUIA_Disabled, FALSE);
- return;
- }
+ set(player_meet_button, MUIA_Disabled, !can_meet_with_player(pplayer));
+ set(player_intelligence_button, MUIA_Disabled,
+ !can_intel_with_player(pplayer));
+ return;
}
set(player_meet_button, MUIA_Disabled, TRUE);
Index: gui-win32/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/plrdlg.c,v
retrieving revision 1.10
diff -u -r1.10 plrdlg.c
--- gui-win32/plrdlg.c 2002/11/14 09:14:59 1.10
+++ gui-win32/plrdlg.c 2003/01/04 02:44:17
@@ -237,19 +237,10 @@
EnableWindow(GetDlgItem(players_dialog, ID_PLAYERS_VISION),
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)
- EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_MEET), TRUE);
- else
- EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_MEET), FALSE);
- EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_INT), TRUE);
- return;
- }
-
- EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_MEET), FALSE);
- EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_INT), FALSE);
+ EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_MEET),
+ can_meet_with_player(pplayer));
+ EnableWindow(GetDlgItem(players_dialog,ID_PLAYERS_INT),
+ can_intel_with_player(pplayer));
}
/******************************************************************
Index: gui-xaw/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/plrdlg.c,v
retrieving revision 1.34
diff -u -r1.34 plrdlg.c
--- gui-xaw/plrdlg.c 2002/11/29 20:11:59 1.34
+++ gui-xaw/plrdlg.c 2003/01/04 02:44:17
@@ -310,16 +310,8 @@
XtSetSensitive(players_vision_command,
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)
- XtSetSensitive(players_meet_command, TRUE);
- else
- XtSetSensitive(players_meet_command, FALSE);
- XtSetSensitive(players_int_command, TRUE);
- return;
- }
+ XtSetSensitive(players_meet_command, can_meet_with_player(pplayer));
+ XtSetSensitive(players_int_command, can_intel_with_player(pplayer));
}
XtSetSensitive(players_meet_command, FALSE);
XtSetSensitive(players_int_command, FALSE);
- [Freeciv-Dev] (PR#2714) Meet and intelligence code wrapping in client,
Per I. Mathisen via RT <=
|
|