61 _network_game_info.map_height = MapSizeY(); |
61 _network_game_info.map_height = MapSizeY(); |
62 _network_game_info.map_set = _opt.landscape; |
62 _network_game_info.map_set = _opt.landscape; |
63 |
63 |
64 NetworkSend_uint8 (packet, NETWORK_GAME_INFO_VERSION); |
64 NetworkSend_uint8 (packet, NETWORK_GAME_INFO_VERSION); |
65 |
65 |
|
66 /* NETWORK_GAME_INFO_VERSION = 3 */ |
|
67 NetworkSend_uint32(packet, _network_game_info.game_date); |
|
68 NetworkSend_uint32(packet, _network_game_info.start_date); |
|
69 |
66 /* NETWORK_GAME_INFO_VERSION = 2 */ |
70 /* NETWORK_GAME_INFO_VERSION = 2 */ |
67 NetworkSend_uint8 (packet, _network_game_info.companies_max); |
71 NetworkSend_uint8 (packet, _network_game_info.companies_max); |
68 NetworkSend_uint8 (packet, ActivePlayerCount()); |
72 NetworkSend_uint8 (packet, ActivePlayerCount()); |
69 NetworkSend_uint8 (packet, _network_game_info.spectators_max); |
73 NetworkSend_uint8 (packet, _network_game_info.spectators_max); |
70 |
74 |
74 NetworkSend_uint8 (packet, _network_game_info.server_lang); |
78 NetworkSend_uint8 (packet, _network_game_info.server_lang); |
75 NetworkSend_uint8 (packet, _network_game_info.use_password); |
79 NetworkSend_uint8 (packet, _network_game_info.use_password); |
76 NetworkSend_uint8 (packet, _network_game_info.clients_max); |
80 NetworkSend_uint8 (packet, _network_game_info.clients_max); |
77 NetworkSend_uint8 (packet, _network_game_info.clients_on); |
81 NetworkSend_uint8 (packet, _network_game_info.clients_on); |
78 NetworkSend_uint8 (packet, NetworkSpectatorCount()); |
82 NetworkSend_uint8 (packet, NetworkSpectatorCount()); |
79 NetworkSend_uint16(packet, _network_game_info.game_date); |
|
80 NetworkSend_uint16(packet, _network_game_info.start_date); |
|
81 NetworkSend_string(packet, _network_game_info.map_name); |
83 NetworkSend_string(packet, _network_game_info.map_name); |
82 NetworkSend_uint16(packet, _network_game_info.map_width); |
84 NetworkSend_uint16(packet, _network_game_info.map_width); |
83 NetworkSend_uint16(packet, _network_game_info.map_height); |
85 NetworkSend_uint16(packet, _network_game_info.map_height); |
84 NetworkSend_uint8 (packet, _network_game_info.map_set); |
86 NetworkSend_uint8 (packet, _network_game_info.map_set); |
85 NetworkSend_uint8 (packet, _network_game_info.dedicated); |
87 NetworkSend_uint8 (packet, _network_game_info.dedicated); |
112 item = NetworkGameListAddItem(inet_addr(inet_ntoa(client_addr->sin_addr)), ntohs(client_addr->sin_port)); |
114 item = NetworkGameListAddItem(inet_addr(inet_ntoa(client_addr->sin_addr)), ntohs(client_addr->sin_port)); |
113 |
115 |
114 /* Please observer the order. In the order in which packets are sent |
116 /* Please observer the order. In the order in which packets are sent |
115 * they are to be received */ |
117 * they are to be received */ |
116 switch (game_info_version) { |
118 switch (game_info_version) { |
|
119 case 3: |
|
120 item->info.game_date = NetworkRecv_uint32(&_udp_cs, p); |
|
121 item->info.start_date = NetworkRecv_uint32(&_udp_cs, p); |
|
122 /* Fallthrough */ |
117 case 2: |
123 case 2: |
118 item->info.companies_max = NetworkRecv_uint8(&_udp_cs, p); |
124 item->info.companies_max = NetworkRecv_uint8(&_udp_cs, p); |
119 item->info.companies_on = NetworkRecv_uint8(&_udp_cs, p); |
125 item->info.companies_on = NetworkRecv_uint8(&_udp_cs, p); |
120 item->info.spectators_max = NetworkRecv_uint8(&_udp_cs, p); |
126 item->info.spectators_max = NetworkRecv_uint8(&_udp_cs, p); |
121 /* Fallthrough */ |
127 /* Fallthrough */ |
125 item->info.server_lang = NetworkRecv_uint8(&_udp_cs, p); |
131 item->info.server_lang = NetworkRecv_uint8(&_udp_cs, p); |
126 item->info.use_password = NetworkRecv_uint8(&_udp_cs, p); |
132 item->info.use_password = NetworkRecv_uint8(&_udp_cs, p); |
127 item->info.clients_max = NetworkRecv_uint8(&_udp_cs, p); |
133 item->info.clients_max = NetworkRecv_uint8(&_udp_cs, p); |
128 item->info.clients_on = NetworkRecv_uint8(&_udp_cs, p); |
134 item->info.clients_on = NetworkRecv_uint8(&_udp_cs, p); |
129 item->info.spectators_on = NetworkRecv_uint8(&_udp_cs, p); |
135 item->info.spectators_on = NetworkRecv_uint8(&_udp_cs, p); |
130 item->info.game_date = NetworkRecv_uint16(&_udp_cs, p); |
136 if (game_info_version < 3) { // 16 bits dates got scrapped and are read earlier |
131 item->info.start_date = NetworkRecv_uint16(&_udp_cs, p); |
137 item->info.game_date = NetworkRecv_uint16(&_udp_cs, p) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
|
138 item->info.start_date = NetworkRecv_uint16(&_udp_cs, p) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
|
139 } |
132 NetworkRecv_string(&_udp_cs, p, item->info.map_name, sizeof(item->info.map_name)); |
140 NetworkRecv_string(&_udp_cs, p, item->info.map_name, sizeof(item->info.map_name)); |
133 item->info.map_width = NetworkRecv_uint16(&_udp_cs, p); |
141 item->info.map_width = NetworkRecv_uint16(&_udp_cs, p); |
134 item->info.map_height = NetworkRecv_uint16(&_udp_cs, p); |
142 item->info.map_height = NetworkRecv_uint16(&_udp_cs, p); |
135 item->info.map_set = NetworkRecv_uint8(&_udp_cs, p); |
143 item->info.map_set = NetworkRecv_uint8(&_udp_cs, p); |
136 item->info.dedicated = NetworkRecv_uint8(&_udp_cs, p); |
144 item->info.dedicated = NetworkRecv_uint8(&_udp_cs, p); |
183 |
191 |
184 /* Send the information */ |
192 /* Send the information */ |
185 NetworkSend_uint8(packet, current); |
193 NetworkSend_uint8(packet, current); |
186 |
194 |
187 NetworkSend_string(packet, _network_player_info[player->index].company_name); |
195 NetworkSend_string(packet, _network_player_info[player->index].company_name); |
188 NetworkSend_uint8 (packet, _network_player_info[player->index].inaugurated_year); |
196 NetworkSend_uint32(packet, _network_player_info[player->index].inaugurated_year); |
189 NetworkSend_uint64(packet, _network_player_info[player->index].company_value); |
197 NetworkSend_uint64(packet, _network_player_info[player->index].company_value); |
190 NetworkSend_uint64(packet, _network_player_info[player->index].money); |
198 NetworkSend_uint64(packet, _network_player_info[player->index].money); |
191 NetworkSend_uint64(packet, _network_player_info[player->index].income); |
199 NetworkSend_uint64(packet, _network_player_info[player->index].income); |
192 NetworkSend_uint16(packet, _network_player_info[player->index].performance); |
200 NetworkSend_uint16(packet, _network_player_info[player->index].performance); |
193 |
201 |
210 if (ci->client_playas - 1 == player->index) { |
218 if (ci->client_playas - 1 == player->index) { |
211 /* The uint8 == 1 indicates that a client is following */ |
219 /* The uint8 == 1 indicates that a client is following */ |
212 NetworkSend_uint8(packet, 1); |
220 NetworkSend_uint8(packet, 1); |
213 NetworkSend_string(packet, ci->client_name); |
221 NetworkSend_string(packet, ci->client_name); |
214 NetworkSend_string(packet, ci->unique_id); |
222 NetworkSend_string(packet, ci->unique_id); |
215 NetworkSend_uint16(packet, ci->join_date); |
223 NetworkSend_uint32(packet, ci->join_date); |
216 } |
224 } |
217 } |
225 } |
218 /* Also check for the server itself */ |
226 /* Also check for the server itself */ |
219 ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX); |
227 ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX); |
220 if (ci->client_playas - 1 == player->index) { |
228 if (ci->client_playas - 1 == player->index) { |
221 /* The uint8 == 1 indicates that a client is following */ |
229 /* The uint8 == 1 indicates that a client is following */ |
222 NetworkSend_uint8(packet, 1); |
230 NetworkSend_uint8(packet, 1); |
223 NetworkSend_string(packet, ci->client_name); |
231 NetworkSend_string(packet, ci->client_name); |
224 NetworkSend_string(packet, ci->unique_id); |
232 NetworkSend_string(packet, ci->unique_id); |
225 NetworkSend_uint16(packet, ci->join_date); |
233 NetworkSend_uint32(packet, ci->join_date); |
226 } |
234 } |
227 |
235 |
228 /* Indicates end of client list */ |
236 /* Indicates end of client list */ |
229 NetworkSend_uint8(packet, 0); |
237 NetworkSend_uint8(packet, 0); |
230 } |
238 } |
235 if (ci->client_playas - 1 > MAX_PLAYERS) { |
243 if (ci->client_playas - 1 > MAX_PLAYERS) { |
236 /* The uint8 == 1 indicates that a client is following */ |
244 /* The uint8 == 1 indicates that a client is following */ |
237 NetworkSend_uint8(packet, 1); |
245 NetworkSend_uint8(packet, 1); |
238 NetworkSend_string(packet, ci->client_name); |
246 NetworkSend_string(packet, ci->client_name); |
239 NetworkSend_string(packet, ci->unique_id); |
247 NetworkSend_string(packet, ci->unique_id); |
240 NetworkSend_uint16(packet, ci->join_date); |
248 NetworkSend_uint32(packet, ci->join_date); |
241 } |
249 } |
242 } |
250 } |
243 /* Also check for the server itself */ |
251 /* Also check for the server itself */ |
244 ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX); |
252 ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX); |
245 if (ci->client_playas - 1 > MAX_PLAYERS) { |
253 if (ci->client_playas - 1 > MAX_PLAYERS) { |
246 /* The uint8 == 1 indicates that a client is following */ |
254 /* The uint8 == 1 indicates that a client is following */ |
247 NetworkSend_uint8(packet, 1); |
255 NetworkSend_uint8(packet, 1); |
248 NetworkSend_string(packet, ci->client_name); |
256 NetworkSend_string(packet, ci->client_name); |
249 NetworkSend_string(packet, ci->unique_id); |
257 NetworkSend_string(packet, ci->unique_id); |
250 NetworkSend_uint16(packet, ci->join_date); |
258 NetworkSend_uint32(packet, ci->join_date); |
251 } |
259 } |
252 |
260 |
253 /* Indicates end of client list */ |
261 /* Indicates end of client list */ |
254 NetworkSend_uint8(packet, 0); |
262 NetworkSend_uint8(packet, 0); |
255 |
263 |