[Freeciv-Dev] Re: (PR#3736) Pregame player list
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Mike Kaufman wrote:
>On Sat, Apr 19, 2003 at 11:59:53AM -0700, andrearo@xxxxxxxxxxxx wrote:
>
>
>>To make sure that game.est_connections always contains
>>a correct list of connections, I had to change connecthand.c:
>> - struct conn_list *dest = &pconn->self;
>>+ struct conn_list *dest = &game.est_connections;
>>It solves the problem, but is this the correct way to do it?
>>
>>
>
>no it isn't. To see why, connect a first client to the server and then
>connect a second. watch what happens.
>
>-mike
>
I see, the problem is that the new client conneting doesn't get the list
of the other clients.
A solution is to first send info about the new client to all clients,
and then send info
about all clients to the new client. I've tested it without any problems.
Andreas Røsdal
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore
freeciv-cvs-Apr-18/client/gui-gtk-2.0/gui_main.c
freeciv-changed/client/gui-gtk-2.0/gui_main.c
--- freeciv-cvs-Apr-18/client/gui-gtk-2.0/gui_main.c 2003-04-19
06:57:11.000000000 +0200
+++ freeciv-changed/client/gui-gtk-2.0/gui_main.c 2003-04-20
09:02:16.000000000 +0200
@@ -105,6 +105,14 @@
GtkWidget *main_frame_civ_name;
GtkWidget *main_label_info;
+static GtkWidget *avbox, *ahbox, *vbox, *conn_box;
+static GtkListStore *conn_list_model;
+static GtkWidget *conn_list_view;
+static GtkCellRenderer *conn_list_renderer;
+static GtkTreeViewColumn *conn_list_column;
+static GtkTreeIter conn_list_iter;
+static GtkWidget* scroll_panel;
+
GtkWidget *econ_label[10];
GtkWidget *bulb_label;
GtkWidget *sun_label;
@@ -644,8 +652,7 @@
**************************************************************************/
static void setup_widgets(void)
{
- GtkWidget *box, *ebox, *hbox, *vbox;
- GtkWidget *avbox, *ahbox, *align;
+ GtkWidget *box, *ebox, *hbox, *sbox, *align, *conn_label;
GtkWidget *frame, *table, *table2, *paned, *menubar, *sw, *text;
GtkStyle *style;
int i;
@@ -679,7 +686,7 @@
avbox = detached_widget_fill(ahbox);
align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
- gtk_box_pack_start(GTK_BOX(avbox), align, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(avbox), align, FALSE, FALSE, 0);
overview_canvas = gtk_drawing_area_new();
@@ -695,13 +702,43 @@
g_signal_connect(overview_canvas, "button_press_event",
G_CALLBACK(butt_down_overviewcanvas), NULL);
+ /* Prepare list of connections in the pregame state. */
+ conn_list_model = gtk_list_store_new(1, G_TYPE_STRING);
+ conn_list_view = gtk_tree_view_new_with_model(
+ GTK_TREE_MODEL(conn_list_model));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(conn_list_view), false);
+
+ /* Add the player name column. */
+ conn_list_renderer = gtk_cell_renderer_text_new();
+ conn_list_column = gtk_tree_view_column_new_with_attributes("connections",
+ conn_list_renderer, "text", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(conn_list_view),conn_list_column);
+ g_object_set(conn_list_renderer, "weight", "bold", NULL);
+ gtk_list_store_append(conn_list_model, &conn_list_iter);
+
+ /* Display the list. */
+ conn_box = gtk_vbox_new(FALSE, 2);
+ conn_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "mnemonic-widget", conn_list_view,
+ "label", _("_Connected Players:"),
+ "xalign", 0.0, "yalign", 0.5, NULL);
+ scroll_panel = gtk_scrolled_window_new(NULL,NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_panel),
+ GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start(GTK_BOX(conn_box), conn_label, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(conn_box), scroll_panel);
+ gtk_container_add(GTK_CONTAINER(avbox), conn_box);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll_panel),
+ conn_list_view);
+
/* The Rest */
ahbox = detached_widget_new();
gtk_container_add(GTK_CONTAINER(vbox), ahbox);
avbox = detached_widget_fill(ahbox);
- /* Info on player's civilization */
+ /* Info on player's civilization, when game is running. */
frame = gtk_frame_new(NULL);
gtk_box_pack_start(GTK_BOX(avbox), frame, FALSE, FALSE, 0);
@@ -891,9 +928,9 @@
/* *** The message window -- this is a detachable widget *** */
- ahbox = detached_widget_new();
- gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE);
- avbox = detached_widget_fill(ahbox);
+ sbox = detached_widget_new();
+ gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
+ avbox = detached_widget_fill(sbox);
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
@@ -942,6 +979,26 @@
gtk_widget_hide(map_horizontal_scrollbar);
gtk_widget_hide(map_vertical_scrollbar);
}
+ gtk_widget_hide(ahbox); /* Hide info on player's civ in pregame */
+}
+
+/**************************************************************************
+ Update the list of connections in the pregame state.
+**************************************************************************/
+void update_conn_list_view(void)
+{
+ if (get_client_state() == CLIENT_PRE_GAME_STATE) {
+ gtk_list_store_clear(conn_list_model);
+ conn_list_iterate(game.est_connections, pconn)
+ gtk_list_store_append(conn_list_model, &conn_list_iter);
+ gtk_list_store_set(conn_list_model, &conn_list_iter, 0, pconn->username,
-1);
+ conn_list_iterate_end;
+ gtk_widget_hide(ahbox);
+ gtk_widget_show(conn_box);
+ } else {
+ gtk_widget_hide(conn_box);
+ gtk_widget_show(ahbox);
+ }
}
/**************************************************************************
@@ -1334,4 +1391,7 @@
{
gtk_input_remove(input_id);
gdk_window_set_cursor(root_window, NULL);
+ conn_list_init(&game.all_connections);
+ conn_list_init(&game.est_connections);
+ conn_list_init(&game.game_connections);
}
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore
freeciv-cvs-Apr-18/client/include/gui_main_g.h
freeciv-changed/client/include/gui_main_g.h
--- freeciv-cvs-Apr-18/client/include/gui_main_g.h 2002-08-25
08:53:22.000000000 +0200
+++ freeciv-changed/client/include/gui_main_g.h 2003-04-20 08:48:53.000000000
+0200
@@ -22,6 +22,7 @@
void sound_bell(void);
void add_net_input(int);
void remove_net_input(void);
+void update_conn_list_view(void);
void set_unit_icon(int idx, struct unit *punit);
void set_unit_icons_more_arrow(bool onoff);
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore freeciv-cvs-Apr-18/client/packhand.c
freeciv-changed/client/packhand.c
--- freeciv-cvs-Apr-18/client/packhand.c 2003-04-18 06:57:02.000000000
+0200
+++ freeciv-changed/client/packhand.c 2003-04-20 08:56:34.000000000 +0200
@@ -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
@@ -1445,6 +1445,7 @@
sz_strlcpy(pconn->capability, pinfo->capability);
}
update_players_dialog();
+ update_conn_list_view();
}
/*************************************************************************
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore
freeciv-cvs-Apr-18/server/connecthand.c freeciv-changed/server/connecthand.c
--- freeciv-cvs-Apr-18/server/connecthand.c 2003-04-13 06:57:19.000000000
+0200
+++ freeciv-changed/server/connecthand.c 2003-04-20 08:30:24.000000000
+0200
@@ -64,9 +64,12 @@
/* "establish" the connection */
pconn->established = TRUE;
- conn_list_insert_back(&game.est_connections, pconn);
send_conn_info(dest, &game.est_connections);
-
+ conn_list_insert_back(&game.est_connections, pconn);
+ send_conn_info(&game.est_connections, dest);
+
+
+
/* introduce the server to the connection */
if (my_gethostname(hostname, sizeof(hostname)) == 0) {
notify_conn(dest, _("Welcome to the %s Server running at %s port %d."),
- [Freeciv-Dev] (PR#3736) Pregame player list, Vasco Alexandre da Silva Costa, 2003/04/18
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, andrearo@xxxxxxxxxxxx, 2003/04/19
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, Mike Kaufman, 2003/04/19
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list,
andrearo@xxxxxxxxxxxx <=
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, Mike Kaufman, 2003/04/21
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, andrearo@xxxxxxxxxxxx, 2003/04/21
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, Mike Kaufman, 2003/04/21
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, andrearo@xxxxxxxxxxxx, 2003/04/24
|
|