176 // Make sure the data get's there before we close the connection |
176 // Make sure the data get's there before we close the connection |
177 NetworkSend_Packets(cs); |
177 NetworkSend_Packets(cs); |
178 |
178 |
179 // The client made a mistake, so drop his connection now! |
179 // The client made a mistake, so drop his connection now! |
180 NetworkCloseClient(cs); |
180 NetworkCloseClient(cs); |
|
181 } |
|
182 |
|
183 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHECK_NEWGRFS)(NetworkClientState *cs) |
|
184 { |
|
185 // |
|
186 // Packet: PACKET_SERVER_CHECK_NEWGRFS |
|
187 // Function: Sends info about the used GRFs to the client |
|
188 // Data: |
|
189 // uint8: Amount of GRFs |
|
190 // And then for each GRF: |
|
191 // uint32: GRF ID |
|
192 // 16 * uint8: MD5 checksum of the GRF |
|
193 // |
|
194 |
|
195 Packet *p = NetworkSend_Init(PACKET_SERVER_CHECK_NEWGRFS); |
|
196 const GRFConfig *c; |
|
197 uint grf_count = 0; |
|
198 |
|
199 for (c = _grfconfig; c != NULL; c = c->next) grf_count++; |
|
200 |
|
201 NetworkSend_uint8 (p, grf_count); |
|
202 for (c = _grfconfig; c != NULL; c = c->next) { |
|
203 NetworkSend_GRFIdentifier(p, c); |
|
204 } |
|
205 |
|
206 NetworkSend_Packet(p, cs); |
181 } |
207 } |
182 |
208 |
183 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkClientState *cs, NetworkPasswordType type) |
209 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkClientState *cs, NetworkPasswordType type) |
184 { |
210 { |
185 // |
211 // |
565 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO) |
591 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO) |
566 { |
592 { |
567 SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)(cs); |
593 SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)(cs); |
568 } |
594 } |
569 |
595 |
|
596 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED) |
|
597 { |
|
598 NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs); |
|
599 |
|
600 /* We now want a password from the client else we do not allow him in! */ |
|
601 if (_network_game_info.use_password) { |
|
602 SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD); |
|
603 } else { |
|
604 if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') { |
|
605 SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD); |
|
606 } else { |
|
607 SEND_COMMAND(PACKET_SERVER_WELCOME)(cs); |
|
608 } |
|
609 } |
|
610 } |
|
611 |
570 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN) |
612 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN) |
571 { |
613 { |
572 char name[NETWORK_CLIENT_NAME_LENGTH]; |
614 char name[NETWORK_CLIENT_NAME_LENGTH]; |
573 char unique_id[NETWORK_NAME_LENGTH]; |
615 char unique_id[NETWORK_NAME_LENGTH]; |
574 NetworkClientInfo *ci; |
616 NetworkClientInfo *ci; |
631 ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name)); |
673 ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name)); |
632 ttd_strlcpy(ci->unique_id, unique_id, sizeof(ci->unique_id)); |
674 ttd_strlcpy(ci->unique_id, unique_id, sizeof(ci->unique_id)); |
633 ci->client_playas = playas; |
675 ci->client_playas = playas; |
634 ci->client_lang = client_lang; |
676 ci->client_lang = client_lang; |
635 |
677 |
636 // We now want a password from the client |
|
637 // else we do not allow him in! |
|
638 if (_network_game_info.use_password) { |
|
639 SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD); |
|
640 } else { |
|
641 if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') { |
|
642 SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD); |
|
643 } else { |
|
644 SEND_COMMAND(PACKET_SERVER_WELCOME)(cs); |
|
645 } |
|
646 } |
|
647 |
|
648 /* Make sure companies to which people try to join are not autocleaned */ |
678 /* Make sure companies to which people try to join are not autocleaned */ |
649 if (IsValidPlayer(playas)) _network_player_info[playas].months_empty = 0; |
679 if (IsValidPlayer(playas)) _network_player_info[playas].months_empty = 0; |
|
680 |
|
681 if (_grfconfig == NULL) { |
|
682 RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)(cs, NULL); |
|
683 } else { |
|
684 SEND_COMMAND(PACKET_SERVER_CHECK_NEWGRFS)(cs); |
|
685 } |
650 } |
686 } |
651 |
687 |
652 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD) |
688 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD) |
653 { |
689 { |
654 NetworkPasswordType type; |
690 NetworkPasswordType type; |
1179 NULL, /*PACKET_SERVER_ERROR_QUIT,*/ |
1215 NULL, /*PACKET_SERVER_ERROR_QUIT,*/ |
1180 NULL, /*PACKET_SERVER_SHUTDOWN,*/ |
1216 NULL, /*PACKET_SERVER_SHUTDOWN,*/ |
1181 NULL, /*PACKET_SERVER_NEWGAME,*/ |
1217 NULL, /*PACKET_SERVER_NEWGAME,*/ |
1182 NULL, /*PACKET_SERVER_RCON,*/ |
1218 NULL, /*PACKET_SERVER_RCON,*/ |
1183 RECEIVE_COMMAND(PACKET_CLIENT_RCON), |
1219 RECEIVE_COMMAND(PACKET_CLIENT_RCON), |
|
1220 NULL, /*PACKET_CLIENT_CHECK_NEWGRFS,*/ |
|
1221 RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED), |
1184 }; |
1222 }; |
1185 |
1223 |
1186 // If this fails, check the array above with network_data.h |
1224 // If this fails, check the array above with network_data.h |
1187 assert_compile(lengthof(_network_server_packet) == PACKET_END); |
1225 assert_compile(lengthof(_network_server_packet) == PACKET_END); |
1188 |
1226 |