? diff Index: client/civclient.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v retrieving revision 1.96 diff -u -r1.96 civclient.c --- client/civclient.c 2001/08/28 18:41:54 1.96 +++ client/civclient.c 2001/08/30 10:04:16 @@ -228,7 +228,7 @@ break; case PACKET_SELECT_NATION: - handle_select_nation((struct packet_generic_values *)packet); + handle_select_nation((struct packet_nations_used *)packet); break; case PACKET_PLAYER_INFO: @@ -381,6 +381,10 @@ case PACKET_CONN_PING: send_packet_generic_empty(&aconnection, PACKET_CONN_PONG); + break; + + case PACKET_SELECT_NATION_OK: + handle_select_nation(NULL); break; default: Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.181 diff -u -r1.181 packhand.c --- client/packhand.c 2001/08/29 10:32:22 1.181 +++ client/packhand.c 2001/08/30 10:04:18 @@ -1467,23 +1467,22 @@ /************************************************************************** ... **************************************************************************/ -void handle_select_nation(struct packet_generic_values *packet) +void handle_select_nation(struct packet_nations_used *packet) { - if(get_client_state()==CLIENT_SELECT_RACE_STATE) { - if(packet->value2 == 0xffff) { + if (get_client_state() == CLIENT_SELECT_RACE_STATE) { + if (!packet) { set_client_state(CLIENT_WAITING_FOR_GAME_START_STATE); popdown_races_dialog(); - } - else - races_toggles_set_sensitive( packet->value1, packet->value2); - } - else if(get_client_state()==CLIENT_PRE_GAME_STATE) { + } else + races_toggles_set_sensitive(packet); + } else if (get_client_state() == CLIENT_PRE_GAME_STATE) { set_client_state(CLIENT_SELECT_RACE_STATE); popup_races_dialog(); - races_toggles_set_sensitive( packet->value1, packet->value2); - } - else - freelog(LOG_ERROR, "got a select nation packet in an incompatible state"); + assert(packet); + races_toggles_set_sensitive(packet); + } else + freelog(LOG_ERROR, + "got a select nation packet in an incompatible state"); } /************************************************************************** Index: client/packhand.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.h,v retrieving revision 1.17 diff -u -r1.17 packhand.h --- client/packhand.h 2000/08/27 06:57:22 1.17 +++ client/packhand.h 2001/08/30 10:04:18 @@ -22,7 +22,7 @@ void handle_conn_info(struct packet_conn_info *packet); void handle_game_info(struct packet_game_info *packet); void handle_map_info(struct packet_map_info *pinfo); -void handle_select_nation(struct packet_generic_values *packet); +void handle_select_nation(struct packet_nations_used *packet); void handle_unit_info(struct packet_unit_info *packet); void handle_chat_msg(struct packet_generic_message *packet); Index: client/gui-gtk/dialogs.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/dialogs.c,v retrieving revision 1.76 diff -u -r1.76 dialogs.c --- client/gui-gtk/dialogs.c 2001/08/05 22:19:57 1.76 +++ client/gui-gtk/dialogs.c 2001/08/30 10:04:20 @@ -2089,38 +2089,31 @@ /************************************************************************** ... **************************************************************************/ -void races_toggles_set_sensitive(int bits1, int bits2) +void races_toggles_set_sensitive(struct packet_nations_used *packet) { - int i, mybits; + int i; - mybits=bits1; - - for(i=0; i>=1; + for (i = 0; i < game.playable_nation_count; i++) { + gtk_widget_set_sensitive(races_toggles + [g_list_index + (sorted_races_list, GINT_TO_POINTER(i))], + TRUE); } + + freelog(LOG_DEBUG, "%d nations used:",packet->num_nations_used); + for (i = 0; i < packet->num_nations_used; i++) { + int nation = packet->nations_used[i]; - mybits=bits2; + freelog(LOG_DEBUG, " [%d]: %d",i,nation); - for(i=32; i>=1; } } Index: client/include/dialogs_g.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/include/dialogs_g.h,v retrieving revision 1.7 diff -u -r1.7 dialogs_g.h --- client/include/dialogs_g.h 2000/04/16 14:35:42 1.7 +++ client/include/dialogs_g.h 2001/08/30 10:04:20 @@ -16,6 +16,7 @@ struct tile; struct unit; struct city; +struct packet_nations_used; void popup_notify_goto_dialog(char *headline, char *lines, int x, int y); void popup_notify_dialog(char *caption, char *headline, char *lines); @@ -25,7 +26,7 @@ void popup_unit_select_dialog(struct tile *ptile); -void races_toggles_set_sensitive(int bits1, int bits2); +void races_toggles_set_sensitive(struct packet_nations_used *packet); void popup_revolution_dialog(void); void popup_government_dialog(void); Index: common/capstr.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v retrieving revision 1.82 diff -u -r1.82 capstr.c --- common/capstr.c 2001/08/29 10:32:26 1.82 +++ common/capstr.c 2001/08/30 10:04:21 @@ -70,7 +70,7 @@ * are not directly related to the capability strings discussed here.) */ -#define CAPABILITY "+1.11.6 conn_info pop_cost turn" +#define CAPABILITY "+1.11.6 conn_info pop_cost turn +new_nation_selection" /* "+1.11.6" is protocol for 1.11.6 beta release. @@ -82,6 +82,9 @@ cities. "turn" additionally transfers game.turn to the client. + + "new_nation_selection" transfer array of used nations instead of + bit mask */ void init_our_capability(void) Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.155 diff -u -r1.155 packets.c --- common/packets.c 2001/08/29 10:32:27 1.155 +++ common/packets.c 2001/08/30 10:04:25 @@ -233,6 +233,7 @@ case PACKET_CONN_PING: case PACKET_CONN_PONG: case PACKET_BEFORE_NEW_YEAR: + case PACKET_SELECT_NATION_OK: return receive_packet_generic_empty(pc); case PACKET_NEW_YEAR: @@ -242,7 +243,7 @@ return receive_packet_tile_info(pc); case PACKET_SELECT_NATION: - return receive_packet_generic_values(pc); + return receive_packet_nations_used(pc); case PACKET_REMOVE_UNIT: case PACKET_REMOVE_CITY: @@ -3947,4 +3948,51 @@ freelog(LOG_ERROR, "invalid type in receive_packet_goto_route()"); return NULL; } +} + +/************************************************************************** +... +**************************************************************************/ +int send_packet_nations_used(struct connection *pc, + const struct packet_nations_used *packet) +{ + unsigned char buffer[MAX_LEN_PACKET], *cptr; + int i; + + cptr = put_uint8(buffer + 2, PACKET_SELECT_NATION); + + for (i = 0; i < packet->num_nations_used; i++) { + assert((packet->nations_used[i] & 0xffff) == packet->nations_used[i]); + cptr = put_uint16(cptr, packet->nations_used[i]); + } + put_uint16(buffer, cptr - buffer); + return send_connection_data(pc, buffer, cptr - buffer); +} + +/************************************************************************** +... +**************************************************************************/ +struct packet_nations_used *receive_packet_nations_used(struct connection + *pc) +{ + struct pack_iter iter; + struct packet_nations_used *packet = + fc_malloc(sizeof(struct packet_nations_used)); + + pack_iter_init(&iter, pc); + + packet->num_nations_used = 0; + + for (;;) { + assert((pack_iter_remaining(&iter) % 2) == 0); + + if (pack_iter_remaining(&iter) == 0) + break; + + iget_uint16(&iter, &packet->nations_used[packet->num_nations_used]); + packet->num_nations_used++; + } + pack_iter_end(&iter, pc); + remove_packet_from_buffer(pc->buffer); + return packet; } Index: common/packets.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v retrieving revision 1.91 diff -u -r1.91 packets.h --- common/packets.h 2001/08/29 10:32:28 1.91 +++ common/packets.h 2001/08/30 10:04:25 @@ -118,6 +118,7 @@ PACKET_CONN_PING, PACKET_CONN_PONG, PACKET_UNIT_AIRLIFT, + PACKET_SELECT_NATION_OK, PACKET_LAST /* leave this last */ }; @@ -857,6 +858,14 @@ int unit_id; }; +/********************************************************* +... +*********************************************************/ +struct packet_nations_used { + int num_nations_used; + Nation_Type_id nations_used[MAX_NUM_PLAYERS]; +}; + /* These two are non-static for meta.c; others are now static --dwp */ unsigned char *put_uint16(unsigned char *buffer, int val); unsigned char *put_string(unsigned char *buffer, const char *mystring); @@ -1068,6 +1077,11 @@ int send_packet_generic_empty(struct connection *pc, int type); struct packet_generic_empty * receive_packet_generic_empty(struct connection *pc); + +int send_packet_nations_used(struct connection *pc, + const struct packet_nations_used *packet); +struct packet_nations_used *receive_packet_nations_used(struct connection + *pc); #include "packets_lsend.h" /* lsend_packet_* functions */ Index: common/packets_lsend.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets_lsend.c,v retrieving revision 1.6 diff -u -r1.6 packets_lsend.c --- common/packets_lsend.c 2001/02/19 23:37:53 1.6 +++ common/packets_lsend.c 2001/08/30 10:04:26 @@ -355,3 +355,11 @@ conn_list_iterate_end; } +void lsend_packet_nations_used(struct conn_list *dest, + const struct packet_nations_used *packet) +{ + conn_list_iterate(*dest, pconn) + send_packet_nations_used(pconn, packet); + conn_list_iterate_end; +} + Index: common/packets_lsend.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets_lsend.h,v retrieving revision 1.6 diff -u -r1.6 packets_lsend.h --- common/packets_lsend.h 2001/02/19 23:37:53 1.6 +++ common/packets_lsend.h 2001/08/30 10:04:26 @@ -102,3 +102,5 @@ const struct packet_goto_route *packet, enum goto_route_type type); void lsend_packet_generic_empty(struct conn_list *dest, int type); +void lsend_packet_nations_used(struct conn_list *dest, + const struct packet_nations_used *packet); Index: server/srv_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v retrieving revision 1.46 diff -u -r1.46 srv_main.c --- server/srv_main.c 2001/08/22 19:47:48 1.46 +++ server/srv_main.c 2001/08/30 10:04:30 @@ -897,7 +897,6 @@ struct packet_alloc_nation *packet) { int i, nation_used_count; - struct packet_generic_values select_nation; if (server_state != SELECT_RACES_STATE) { freelog(LOG_ERROR, _("Trying to alloc nation outside " @@ -940,9 +939,8 @@ get_nation_name(packet->nation_no), packet->name); /* inform player his choice was ok */ - select_nation.value2=0xffff; - lsend_packet_generic_values(&pplayer->connections, PACKET_SELECT_NATION, - &select_nation); + lsend_packet_generic_empty(&pplayer->connections, + PACKET_SELECT_NATION_OK); pplayer->nation=packet->nation_no; sz_strlcpy(pplayer->name, packet->name); @@ -974,28 +972,24 @@ } /************************************************************************** -Send request to select nation, mask1, mask2 contains those that were -already selected and are not available +... **************************************************************************/ static void send_select_nation(struct player *pplayer) { int i; - struct packet_generic_values select_nation; - - select_nation.value1=0; /* assume int is 32 bit, safe */ - select_nation.value2=0; - - /* set bits in mask corresponding to nations already selected by others */ - for( i=0; iconnections, PACKET_SELECT_NATION, - &select_nation); + lsend_packet_nations_used(&pplayer->connections, &packet); } /**************************************************************************