--- a/network_server.c Thu Jan 18 00:52:33 2007 +0000
+++ b/network_server.c Wed Jan 31 12:39:41 2007 +0000
@@ -180,6 +180,32 @@
NetworkCloseClient(cs);
}
+DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHECK_NEWGRFS)(NetworkClientState *cs)
+{
+ //
+ // Packet: PACKET_SERVER_CHECK_NEWGRFS
+ // Function: Sends info about the used GRFs to the client
+ // Data:
+ // uint8: Amount of GRFs
+ // And then for each GRF:
+ // uint32: GRF ID
+ // 16 * uint8: MD5 checksum of the GRF
+ //
+
+ Packet *p = NetworkSend_Init(PACKET_SERVER_CHECK_NEWGRFS);
+ const GRFConfig *c;
+ uint grf_count = 0;
+
+ for (c = _grfconfig; c != NULL; c = c->next) grf_count++;
+
+ NetworkSend_uint8 (p, grf_count);
+ for (c = _grfconfig; c != NULL; c = c->next) {
+ NetworkSend_GRFIdentifier(p, c);
+ }
+
+ NetworkSend_Packet(p, cs);
+}
+
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkClientState *cs, NetworkPasswordType type)
{
//
@@ -567,6 +593,22 @@
SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)(cs);
}
+DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)
+{
+ NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
+
+ /* We now want a password from the client else we do not allow him in! */
+ if (_network_game_info.use_password) {
+ SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD);
+ } else {
+ if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
+ } else {
+ SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
+ }
+ }
+}
+
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
{
char name[NETWORK_CLIENT_NAME_LENGTH];
@@ -633,20 +675,14 @@
ci->client_playas = playas;
ci->client_lang = client_lang;
- // We now want a password from the client
- // else we do not allow him in!
- if (_network_game_info.use_password) {
- SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD);
- } else {
- if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
- SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
- } else {
- SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
- }
- }
-
/* Make sure companies to which people try to join are not autocleaned */
if (IsValidPlayer(playas)) _network_player_info[playas].months_empty = 0;
+
+ if (_grfconfig == NULL) {
+ RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)(cs, NULL);
+ } else {
+ SEND_COMMAND(PACKET_SERVER_CHECK_NEWGRFS)(cs);
+ }
}
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
@@ -1181,6 +1217,8 @@
NULL, /*PACKET_SERVER_NEWGAME,*/
NULL, /*PACKET_SERVER_RCON,*/
RECEIVE_COMMAND(PACKET_CLIENT_RCON),
+ NULL, /*PACKET_CLIENT_CHECK_NEWGRFS,*/
+ RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED),
};
// If this fails, check the array above with network_data.h