[Freeciv-Dev] (PR#13789) remove game.game_connections
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13789 >
> [jdorje - Fri Aug 26 19:30:50 2005]:
>
> This patch removes game.game_connections.
Here is a new version of the patch.
After some more testing (I've given it extensive testing in autogames)
I'd like to commit it.
-jason
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.233
diff -p -u -r1.233 civclient.c
--- client/civclient.c 4 Sep 2005 01:15:48 -0000 1.233
+++ client/civclient.c 4 Sep 2005 04:56:55 -0000
@@ -308,7 +308,6 @@ int main(int argc, char *argv[])
game.all_connections = conn_list_new();
game.est_connections = conn_list_new();
- game.game_connections = conn_list_new();
ui_init();
charsets_init();
@@ -379,7 +378,6 @@ void ui_exit(void)
helpdata_done(); /* ui_exit() unlinks help text list */
conn_list_free(game.all_connections);
conn_list_free(game.est_connections);
- conn_list_free(game.game_connections);
exit(EXIT_SUCCESS);
}
@@ -574,7 +572,6 @@ void client_remove_cli_conn(struct conne
}
conn_list_unlink(game.all_connections, pconn);
conn_list_unlink(game.est_connections, pconn);
- conn_list_unlink(game.game_connections, pconn);
assert(pconn != &aconnection);
free(pconn);
}
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.547
diff -p -u -r1.547 packhand.c
--- client/packhand.c 4 Sep 2005 04:31:16 -0000 1.547
+++ client/packhand.c 4 Sep 2005 04:56:56 -0000
@@ -1615,7 +1615,6 @@ void handle_conn_info(struct packet_conn
}
conn_list_append(game.all_connections, pconn);
conn_list_append(game.est_connections, pconn);
- conn_list_append(game.game_connections, pconn);
} else {
freelog(LOG_DEBUG, "Server reports updated connection %d %s",
pinfo->id, pinfo->username);
Index: client/gui-gtk-2.0/pages.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/pages.c,v
retrieving revision 1.39
diff -p -u -r1.39 pages.c
--- client/gui-gtk-2.0/pages.c 19 Aug 2005 20:52:58 -0000 1.39
+++ client/gui-gtk-2.0/pages.c 4 Sep 2005 04:56:57 -0000
@@ -930,9 +930,10 @@ static void ai_fill_callback(GtkWidget *
**************************************************************************/
static void start_start_callback(GtkWidget *w, gpointer data)
{
- really_close_connection_dialog();
- dsend_packet_player_ready(&aconnection, game.info.player_idx,
- !game.player_ptr->is_ready);
+ if (game.player_ptr) {
+ dsend_packet_player_ready(&aconnection, game.info.player_idx,
+ !game.player_ptr->is_ready);
+ }
}
/**************************************************************************
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.198
diff -p -u -r1.198 game.h
--- common/game.h 18 Aug 2005 06:44:28 -0000 1.198
+++ common/game.h 4 Sep 2005 04:56:57 -0000
@@ -75,7 +75,6 @@ struct civ_game {
struct player players[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
struct conn_list *all_connections; /* including not yet established */
struct conn_list *est_connections; /* all established client conns */
- struct conn_list *game_connections; /* involved in game; send map etc
*/
char save_name[MAX_LEN_NAME];
bool scorelog;
int seed;
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.346
diff -p -u -r1.346 citytools.c
--- server/citytools.c 4 Sep 2005 04:31:18 -0000 1.346
+++ server/citytools.c 4 Sep 2005 04:56:57 -0000
@@ -1388,7 +1388,7 @@ static void broadcast_city_info(struct c
/* send to non-player observers:
* should these only get dumb_city type info?
*/
- conn_list_iterate(game.game_connections, pconn) {
+ conn_list_iterate(game.est_connections, pconn) {
if (!pconn->player && pconn->observer) {
package_city(pcity, &packet, FALSE);
send_packet_city_info(pconn, &packet);
Index: server/connecthand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/connecthand.c,v
retrieving revision 1.54
diff -p -u -r1.54 connecthand.c
--- server/connecthand.c 4 Sep 2005 03:03:44 -0000 1.54
+++ server/connecthand.c 4 Sep 2005 04:56:57 -0000
@@ -91,6 +91,8 @@ static void establish_new_connection(str
/* "establish" the connection */
pconn->established = TRUE;
+ conn_list_append(game.est_connections, pconn);
+
/* introduce the server to the connection */
if (my_gethostname(hostname, sizeof(hostname)) == 0) {
notify_conn(dest, NULL, E_CONNECTION,
@@ -191,7 +193,6 @@ static void establish_new_connection(str
}
send_conn_info(dest, game.est_connections);
- conn_list_append(game.est_connections, pconn);
send_conn_info(game.est_connections, dest);
send_player_info_c(NULL, dest);
reset_all_start_commands();
@@ -700,7 +701,6 @@ bool attach_connection_to_player(struct
pconn->player = pplayer;
conn_list_append(pplayer->connections, pconn);
- conn_list_append(game.game_connections, pconn);
send_game_info(NULL);
send_player_info(pplayer, NULL);
@@ -723,7 +723,6 @@ bool unattach_connection_from_player(str
}
conn_list_unlink(pconn->player->connections, pconn);
- conn_list_unlink(game.game_connections, pconn);
pconn->player->is_connected = FALSE;
pconn->observer = FALSE;
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.167
diff -p -u -r1.167 gamehand.c
--- server/gamehand.c 26 Aug 2005 19:40:26 -0000 1.167
+++ server/gamehand.c 4 Sep 2005 04:56:58 -0000
@@ -288,7 +288,7 @@ void init_new_game(void)
void send_start_phase_to_clients(void)
{
/* This function is so simple it could probably be dropped... */
- dlsend_packet_start_phase(game.game_connections, game.info.phase);
+ dlsend_packet_start_phase(game.est_connections, game.info.phase);
}
/**************************************************************************
@@ -307,11 +307,10 @@ void send_year_to_clients(int year)
apacket.year = year;
apacket.turn = game.info.turn;
- lsend_packet_new_year(game.game_connections, &apacket);
+ lsend_packet_new_year(game.est_connections, &apacket);
/* Hmm, clients could add this themselves based on above packet? */
- notify_conn_ex(game.game_connections, NULL, E_NEXT_YEAR, _("Year: %s"),
- textyear(year));
+ notify_conn_ex(NULL, NULL, E_NEXT_YEAR, _("Year: %s"), textyear(year));
}
@@ -327,14 +326,14 @@ void send_game_state(struct conn_list *d
/**************************************************************************
Send game_info packet; some server options and various stuff...
- dest==NULL means game.game_connections
+ dest==NULL means game.est_connections
**************************************************************************/
void send_game_info(struct conn_list *dest)
{
struct packet_game_info ginfo;
if (!dest) {
- dest = game.game_connections;
+ dest = game.est_connections;
}
ginfo = game.info;
@@ -384,7 +383,7 @@ int update_timeout(void)
game.timeoutint += game.timeoutintinc;
if (game.info.timeout > GAME_MAX_TIMEOUT) {
- notify_conn_ex(game.game_connections, NULL, E_SETTING,
+ notify_conn_ex(NULL, NULL, E_SETTING,
_("The turn timeout has exceeded its maximum value, "
"fixing at its maximum"));
freelog(LOG_DEBUG, "game.info.timeout exceeded maximum value");
@@ -392,7 +391,7 @@ int update_timeout(void)
game.timeoutint = 0;
game.timeoutinc = 0;
} else if (game.info.timeout < 0) {
- notify_conn_ex(game.game_connections, NULL, E_SETTING,
+ notify_conn_ex(NULL, NULL, E_SETTING,
_("The turn timeout is smaller than zero, "
"fixing at zero."));
freelog(LOG_DEBUG, "game.info.timeout less than zero");
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.175
diff -p -u -r1.175 maphand.c
--- server/maphand.c 29 Aug 2005 12:59:58 -0000 1.175
+++ server/maphand.c 4 Sep 2005 04:56:58 -0000
@@ -408,7 +408,7 @@ void give_citymap_from_player_to_player(
/**************************************************************************
Send all tiles known to specified clients.
- If dest is NULL means game.game_connections.
+ If dest is NULL means game.est_connections.
Note for multiple connections this may change "sent" multiple times
for single player. This is ok, because "sent" data is just optimised
@@ -420,7 +420,7 @@ void send_all_known_tiles(struct conn_li
int tiles_sent;
if (!dest) {
- dest = game.game_connections;
+ dest = game.est_connections;
}
/* send whole map piece by piece to each player to balance the load
@@ -445,7 +445,7 @@ void send_all_known_tiles(struct conn_li
/**************************************************************************
Send tile information to all the clients in dest which know and see
- the tile. If dest is NULL, sends to all clients (game.game_connections)
+ the tile. If dest is NULL, sends to all clients (game.est_connections)
which know and see tile.
Note that this function does not update the playermap. For that call
@@ -456,7 +456,7 @@ void send_tile_info(struct conn_list *de
struct packet_tile_info info;
if (!dest) {
- dest = game.game_connections;
+ dest = game.est_connections;
}
info.x = ptile->x;
@@ -1140,7 +1140,7 @@ void update_tile_knowledge(struct tile *
} players_iterate_end;
/* Global observers */
- conn_list_iterate(game.game_connections, pconn) {
+ conn_list_iterate(game.est_connections, pconn) {
struct player *pplayer = pconn->player;
if (!pplayer && pconn->observer) {
send_tile_info(pconn->self, ptile);
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.420
diff -p -u -r1.420 plrhand.c
--- server/plrhand.c 4 Sep 2005 04:31:18 -0000 1.420
+++ server/plrhand.c 4 Sep 2005 04:56:59 -0000
@@ -843,11 +843,11 @@ void send_player_info_c(struct player *s
Send information about player src, or all players if src is NULL,
to specified players dest (that is, to dest->connections).
As convenience to old code, dest may be NULL meaning send to
- game.game_connections.
+ game.est_connections.
**************************************************************************/
void send_player_info(struct player *src, struct player *dest)
{
- send_player_info_c(src, (dest ? dest->connections : game.game_connections));
+ send_player_info_c(src, (dest ? dest->connections : game.est_connections));
}
/**************************************************************************
@@ -1110,7 +1110,7 @@ void server_remove_player(struct player
notify_conn(game.est_connections, NULL, E_CONNECTION,
_("%s has been removed from the game."), pplayer->name);
- dlsend_packet_player_remove(game.game_connections, pplayer->player_no);
+ dlsend_packet_player_remove(game.est_connections, pplayer->player_no);
/* Note it is ok to remove the _current_ item in a list_iterate. */
conn_list_iterate(pplayer->connections, pconn) {
Index: server/report.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/report.c,v
retrieving revision 1.70
diff -p -u -r1.70 report.c
--- server/report.c 18 Aug 2005 06:44:29 -0000 1.70
+++ server/report.c 4 Sep 2005 04:56:59 -0000
@@ -199,7 +199,7 @@ static void historian_generic(enum histo
}
my_snprintf(title, sizeof(title), _(historian_message[which_news]),
_(historian_name[myrand(ARRAY_SIZE(historian_name))]));
- page_conn_etype(game.game_connections, _("Historian Publishes!"),
+ page_conn_etype(game.est_connections, _("Historian Publishes!"),
title, buffer, E_BROADCAST_REPORT);
}
@@ -1103,7 +1103,7 @@ void report_final_scores(void)
packet.spaceship[i] = get_spaceship(size[i].player);
}
- lsend_packet_endgame_report(game.game_connections, &packet);
+ lsend_packet_endgame_report(game.est_connections, &packet);
}
/**************************************************************************
Index: server/sanitycheck.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sanitycheck.c,v
retrieving revision 1.74
diff -p -u -r1.74 sanitycheck.c
--- server/sanitycheck.c 4 Sep 2005 04:31:19 -0000 1.74
+++ server/sanitycheck.c 4 Sep 2005 04:56:59 -0000
@@ -499,10 +499,6 @@ static void check_connections(void)
/* est_connections is a subset of all_connections */
SANITY_CHECK(conn_list_size(game.all_connections)
>= conn_list_size(game.est_connections));
-
- /* game_connections is a subset of est_connections */
- SANITY_CHECK(conn_list_size(game.est_connections)
- >= conn_list_size(game.game_connections));
}
/**************************************************************************
Index: server/sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.143
diff -p -u -r1.143 sernet.c
--- server/sernet.c 15 Aug 2005 03:33:27 -0000 1.143
+++ server/sernet.c 4 Sep 2005 04:56:59 -0000
@@ -199,7 +199,6 @@ void close_connection(struct connection
/* safe to do these even if not in lists: */
conn_list_unlink(game.all_connections, pconn);
conn_list_unlink(game.est_connections, pconn);
- conn_list_unlink(game.game_connections, pconn);
pconn->player = NULL;
pconn->access_level = ALLOW_NONE;
@@ -225,7 +224,6 @@ void close_connections_and_socket(void)
/* Remove the game connection lists and make sure they are empty. */
conn_list_free(game.all_connections);
conn_list_free(game.est_connections);
- conn_list_free(game.game_connections);
my_closesocket(sock);
my_closesocket(socklan);
@@ -914,7 +912,6 @@ void init_connections(void)
game.all_connections = conn_list_new();
game.est_connections = conn_list_new();
- game.game_connections = conn_list_new();
for(i=0; i<MAX_NUM_CONNECTIONS; i++) {
struct connection *pconn = &connections[i];
@@ -1001,17 +998,7 @@ static void send_ping_times_to_all(void)
int i;
i = 0;
- conn_list_iterate(game.game_connections, pconn) {
- if (!pconn->used) {
- continue;
- }
- i++;
- } conn_list_iterate_end;
-
- packet.connections = i;
-
- i = 0;
- conn_list_iterate(game.game_connections, pconn) {
+ conn_list_iterate(game.est_connections, pconn) {
if (!pconn->used) {
continue;
}
@@ -1020,6 +1007,8 @@ static void send_ping_times_to_all(void)
packet.ping_time[i] = pconn->ping_time;
i++;
} conn_list_iterate_end;
+ packet.connections = i;
+
lsend_packet_conn_ping_info(game.est_connections, &packet);
}
Index: server/spacerace.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/spacerace.c,v
retrieving revision 1.43
diff -p -u -r1.43 spacerace.c
--- server/spacerace.c 29 Aug 2005 12:59:58 -0000 1.43
+++ server/spacerace.c 4 Sep 2005 04:56:59 -0000
@@ -110,14 +110,14 @@ void spaceship_calc_derived(struct playe
/**************************************************************************
Send details of src's spaceship (or spaceships of all players
if src is NULL) to specified destinations. If dest is NULL then
- game.game_connections is used.
+ game.est_connections is used.
**************************************************************************/
void send_spaceship_info(struct player *src, struct conn_list *dest)
{
int j;
if (!dest) {
- dest = game.game_connections;
+ dest = game.est_connections;
}
players_iterate(pplayer) {
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.290
diff -p -u -r1.290 srv_main.c
--- server/srv_main.c 4 Sep 2005 04:31:19 -0000 1.290
+++ server/srv_main.c 4 Sep 2005 04:57:00 -0000
@@ -522,7 +522,7 @@ static void begin_phase(bool is_new_phas
{
freelog(LOG_DEBUG, "Begin phase");
- conn_list_do_buffer(game.game_connections);
+ conn_list_do_buffer(game.est_connections);
phase_players_iterate(pplayer) {
pplayer->phase_done = FALSE;
@@ -555,7 +555,7 @@ static void begin_phase(bool is_new_phas
} phase_players_iterate_end;
flush_packets(); /* to curb major city spam */
- conn_list_do_unbuffer(game.game_connections);
+ conn_list_do_unbuffer(game.est_connections);
phase_players_iterate(pplayer) {
update_revolution(pplayer);
@@ -797,9 +797,9 @@ void start_game(void)
}
/* Remove ALLOW_CTRL from whoever has it (gotten from 'first'). */
- conn_list_iterate(game.game_connections, pconn) {
+ conn_list_iterate(game.est_connections, pconn) {
if (pconn->access_level == ALLOW_CTRL) {
- notify_conn(game.game_connections, NULL, E_SETTING,
+ notify_conn(NULL, NULL, E_SETTING,
_("%s lost control cmdlevel on "
"game start. Use voting from now on."),
pconn->username);
@@ -1258,7 +1258,7 @@ void handle_nation_select_req(struct pla
name[0] = my_toupper(name[0]);
- notify_conn_ex(game.game_connections, NULL, E_NATION_SELECTED,
+ notify_conn_ex(NULL, NULL, E_NATION_SELECTED,
_("%s is the %s ruler %s."), pplayer->username,
new_nation->name, name);
@@ -1552,7 +1552,7 @@ static void main_loop(void)
* Do this before the body so that the PACKET_THAW_HINT packet is
* balanced.
*/
- lsend_packet_freeze_hint(game.game_connections);
+ lsend_packet_freeze_hint(game.est_connections);
while(server_state==RUN_GAME_STATE) {
/* The beginning of a turn.
@@ -1573,7 +1573,7 @@ static void main_loop(void)
/*
* This will thaw the reports and agents at the client.
*/
- lsend_packet_thaw_hint(game.game_connections);
+ lsend_packet_thaw_hint(game.est_connections);
/* Before sniff (human player activites), report time to now: */
freelog(LOG_VERBOSE, "End/start-turn server/ai activities: %g seconds",
@@ -1605,18 +1605,18 @@ static void main_loop(void)
break;
}
- conn_list_do_buffer(game.game_connections);
+ conn_list_do_buffer(game.est_connections);
sanity_check();
/*
* This will freeze the reports and agents at the client.
*/
- lsend_packet_freeze_hint(game.game_connections);
+ lsend_packet_freeze_hint(game.est_connections);
end_phase();
- conn_list_do_unbuffer(game.game_connections);
+ conn_list_do_unbuffer(game.est_connections);
}
if (server_state == GAME_OVER_STATE) {
break;
@@ -1633,7 +1633,7 @@ static void main_loop(void)
/*
* This will thaw the reports and agents at the client.
*/
- lsend_packet_thaw_hint(game.game_connections);
+ lsend_packet_thaw_hint(game.est_connections);
free_timer(eot_timer);
}
@@ -1697,7 +1697,7 @@ void srv_main(void)
while (TRUE) {
srv_loop();
- send_game_state(game.game_connections, CLIENT_GAME_OVER_STATE);
+ send_game_state(game.est_connections, CLIENT_GAME_OVER_STATE);
report_final_scores();
show_map_to_all();
notify_player(NULL, NULL, E_GAME_END, _("The game is over..."));
@@ -1857,9 +1857,9 @@ static void srv_loop(void)
} players_iterate_end;
}
- lsend_packet_freeze_hint(game.game_connections);
- send_all_info(game.game_connections);
- lsend_packet_thaw_hint(game.game_connections);
+ lsend_packet_freeze_hint(game.est_connections);
+ send_all_info(game.est_connections);
+ lsend_packet_thaw_hint(game.est_connections);
if(game.info.is_new_game) {
init_new_game();
@@ -1872,7 +1872,7 @@ static void srv_loop(void)
} players_iterate_end;
}
- send_game_state(game.game_connections, CLIENT_GAME_RUNNING_STATE);
+ send_game_state(game.est_connections, CLIENT_GAME_RUNNING_STATE);
/*** Where the action is. ***/
main_loop();
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.434
diff -p -u -r1.434 stdinhand.c
--- server/stdinhand.c 4 Sep 2005 03:03:44 -0000 1.434
+++ server/stdinhand.c 4 Sep 2005 04:57:01 -0000
@@ -1612,7 +1612,7 @@ static bool explain_option(struct connec
static bool wall(char *str, bool check)
{
if (!check) {
- notify_conn_ex(game.game_connections, NULL, E_MESSAGE_WALL,
+ notify_conn_ex(NULL, NULL, E_MESSAGE_WALL,
_("Server Operator: %s"), str);
}
return TRUE;
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.350
diff -p -u -r1.350 unithand.c
--- server/unithand.c 29 Aug 2005 12:59:58 -0000 1.350
+++ server/unithand.c 4 Sep 2005 04:57:01 -0000
@@ -677,7 +677,7 @@ static void send_combat(struct unit *pat
/* Send combat info to non-player observers as well. They already know
* about the unit so no unit_info is needed. */
- conn_list_iterate(game.game_connections, pconn) {
+ conn_list_iterate(game.est_connections, pconn) {
if (!pconn->player && pconn->observer) {
send_packet_unit_combat_info(pconn, &combat);
}
@@ -790,8 +790,8 @@ static void handle_unit_attack_request(s
return;
}
- dlsend_packet_nuke_tile_info(game.game_connections, def_tile->x,
- def_tile->y);
+ dlsend_packet_nuke_tile_info(game.est_connections,
+ def_tile->x, def_tile->y);
wipe_unit(punit);
do_nuclear_explosion(pplayer, def_tile);
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.381
diff -p -u -r1.381 unittools.c
--- server/unittools.c 1 Sep 2005 02:32:41 -0000 1.381
+++ server/unittools.c 4 Sep 2005 04:57:02 -0000
@@ -1853,7 +1853,7 @@ void send_unit_info_to_onlookers(struct
struct packet_unit_short_info sinfo;
if (!dest) {
- dest = game.game_connections;
+ dest = game.est_connections;
}
CHECK_UNIT(punit);
@@ -1887,7 +1887,7 @@ void send_unit_info_to_onlookers(struct
void send_unit_info(struct player *dest, struct unit *punit)
{
struct conn_list *conn_dest = (dest ? dest->connections
- : game.game_connections);
+ : game.est_connections);
send_unit_info_to_onlookers(conn_dest, punit, punit->tile, FALSE);
}
@@ -1998,7 +1998,7 @@ void do_nuclear_explosion(struct player
do_nuke_tile(pplayer, ptile1);
} square_iterate_end;
- notify_conn_ex(game.game_connections, ptile, E_NUKE,
+ notify_conn_ex(NULL, ptile, E_NUKE,
_("%s detonated a nuke!"), pplayer->name);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13789) remove game.game_connections,
Jason Short <=
|
|