diff options
author | Simon Howard | 2011-10-17 18:13:10 +0000 |
---|---|---|
committer | Simon Howard | 2011-10-17 18:13:10 +0000 |
commit | 854cb8073a336455d0bcd9b6a40d67c1b4226bb3 (patch) | |
tree | c421979a327967662292eab158bd3980fd6235c3 /src | |
parent | d0ada124a2700e4c762c1126e9e13e36b094a614 (diff) | |
download | chocolate-doom-854cb8073a336455d0bcd9b6a40d67c1b4226bb3.tar.gz chocolate-doom-854cb8073a336455d0bcd9b6a40d67c1b4226bb3.tar.bz2 chocolate-doom-854cb8073a336455d0bcd9b6a40d67c1b4226bb3.zip |
Rework net_connect_data_t structure to include WAD and Dehacked
checksums, plus the is_freedoom flag.
Subversion-branch: /branches/v2-branch
Subversion-revision: 2434
Diffstat (limited to 'src')
-rw-r--r-- | src/doom/d_net.c | 11 | ||||
-rw-r--r-- | src/heretic/d_net.c | 8 | ||||
-rw-r--r-- | src/hexen/d_net.c | 14 | ||||
-rw-r--r-- | src/net_client.c | 15 | ||||
-rw-r--r-- | src/net_defs.h | 5 | ||||
-rw-r--r-- | src/net_server.c | 13 | ||||
-rw-r--r-- | src/net_structrw.c | 34 | ||||
-rw-r--r-- | src/strife/d_net.c | 8 |
8 files changed, 80 insertions, 28 deletions
diff --git a/src/doom/d_net.c b/src/doom/d_net.c index 5230668f..923d4fcd 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -38,6 +38,8 @@ #include "g_game.h" #include "doomdef.h" #include "doomstat.h" +#include "w_checksum.h" +#include "w_wad.h" #include "deh_main.h" @@ -209,6 +211,15 @@ static void SaveGameSettings(net_gamesettings_t *settings, // Are we recording a demo? Possibly set lowres turn mode connect_data->lowres_turn = settings->lowres_turn; + + // Read checksums of our WAD directory and dehacked information + + W_Checksum(connect_data->wad_md5sum); + DEH_Checksum(connect_data->deh_md5sum); + + // Are we playing with the Freedoom IWAD? + + connect_data->is_freedoom = W_CheckNumForName("FREEDOOM") >= 0; } void D_InitSinglePlayerGame(net_gamesettings_t *settings) diff --git a/src/heretic/d_net.c b/src/heretic/d_net.c index 440944eb..1eb88b67 100644 --- a/src/heretic/d_net.c +++ b/src/heretic/d_net.c @@ -34,6 +34,7 @@ #include "i_timer.h" #include "i_video.h" #include "doomdef.h" +#include "w_checksum.h" #include "deh_main.h" @@ -173,6 +174,13 @@ static void SaveGameSettings(net_gamesettings_t *settings, connect_data->gamemission = gamemission; connect_data->lowres_turn = false; + + // Read checksums of our WAD directory and dehacked information + + W_Checksum(connect_data->wad_md5sum); + DEH_Checksum(connect_data->deh_md5sum); + + connect_data->is_freedoom = 0; } void D_InitSinglePlayerGame(net_gamesettings_t *settings) diff --git a/src/hexen/d_net.c b/src/hexen/d_net.c index 301b521b..94b06fc6 100644 --- a/src/hexen/d_net.c +++ b/src/hexen/d_net.c @@ -36,6 +36,7 @@ #include "h2def.h" #include "p_local.h" #include "s_sound.h" +#include "w_checksum.h" #include "deh_main.h" @@ -198,6 +199,13 @@ static void SaveGameSettings(net_gamesettings_t *settings, { connect_data->player_class = PCLASS_FIGHTER; } + + // Read checksums of our WAD directory and dehacked information + + W_Checksum(connect_data->wad_md5sum); + memset(connect_data->deh_md5sum, 0, sizeof(md5_digest_t)); + + connect_data->is_freedoom = 0; } void D_InitSinglePlayerGame(net_gamesettings_t *settings) @@ -265,9 +273,3 @@ void NET_SendFrags(player_t * player) // Not sure what this is intended for. Unused? } -// TODO: This is a temporary hack! - -void DEH_Checksum(md5_digest_t digest) -{ - memset(digest, 0, sizeof(digest)); -} diff --git a/src/net_client.c b/src/net_client.c index e84eb47c..e151a773 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -967,9 +967,6 @@ static void NET_CL_SendSYN(net_connect_data_t *data) NET_WriteInt32(packet, NET_MAGIC_NUMBER); NET_WriteString(packet, PACKAGE_STRING); NET_WriteConnectData(packet, data); - NET_WriteMD5Sum(packet, net_local_wad_md5sum); - NET_WriteMD5Sum(packet, net_local_deh_md5sum); - NET_WriteInt8(packet, net_local_is_freedoom); NET_WriteString(packet, net_player_name); NET_Conn_SendPacket(&client_connection, packet); NET_FreePacket(packet); @@ -984,15 +981,9 @@ boolean NET_CL_Connect(net_addr_t *addr, net_connect_data_t *data) server_addr = addr; - // TODO: Move into net_connect_data_t - // Read checksums of our WAD directory and dehacked information - - W_Checksum(net_local_wad_md5sum); - DEH_Checksum(net_local_deh_md5sum); - - // Are we playing with the Freedoom IWAD? - - net_local_is_freedoom = W_CheckNumForName("FREEDOOM") >= 0; + memcpy(net_local_wad_md5sum, data->wad_md5sum, sizeof(md5_digest_t)); + memcpy(net_local_deh_md5sum, data->deh_md5sum, sizeof(md5_digest_t)); + net_local_is_freedoom = data->is_freedoom; // create a new network I/O context and add just the // necessary module diff --git a/src/net_defs.h b/src/net_defs.h index 0d2516b6..7f79c139 100644 --- a/src/net_defs.h +++ b/src/net_defs.h @@ -30,6 +30,7 @@ #include "doomtype.h" #include "d_ticcmd.h" +#include "md5.h" // Absolute maximum number of "nodes" in the game. This is different to // MAXPLAYERS, as there may be observers that are not participating @@ -144,7 +145,9 @@ typedef struct int gamemission; int lowres_turn; int drone; - // TODO: is_freedoom in here? WAD/DEH checksums? + int is_freedoom; + md5_digest_t wad_md5sum; + md5_digest_t deh_md5sum; int player_class; } net_connect_data_t; diff --git a/src/net_server.c b/src/net_server.c index 4d6d96fd..fcece975 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -477,9 +477,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, net_addr_t *addr) { unsigned int magic; - unsigned int is_freedoom; net_connect_data_t data; - md5_digest_t deh_md5sum, wad_md5sum; char *player_name; char *client_version; int i; @@ -529,10 +527,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, // read the game mode and mission - if (!NET_ReadConnectData(packet, &data) - || !NET_ReadMD5Sum(packet, wad_md5sum) - || !NET_ReadMD5Sum(packet, deh_md5sum) - || !NET_ReadInt8(packet, &is_freedoom)) + if (!NET_ReadConnectData(packet, &data)) { return; } @@ -625,9 +620,9 @@ static void NET_SV_ParseSYN(net_packet_t *packet, // Save the MD5 checksums - memcpy(client->wad_md5sum, wad_md5sum, sizeof(md5_digest_t)); - memcpy(client->deh_md5sum, deh_md5sum, sizeof(md5_digest_t)); - client->is_freedoom = is_freedoom; + memcpy(client->wad_md5sum, data.wad_md5sum, sizeof(md5_digest_t)); + memcpy(client->deh_md5sum, data.deh_md5sum, sizeof(md5_digest_t)); + client->is_freedoom = data.is_freedoom; // Check the connecting client is playing the same game as all // the other clients diff --git a/src/net_structrw.c b/src/net_structrw.c index 6e748b6b..a15e812a 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -31,12 +31,43 @@ #include "net_packet.h" #include "net_structrw.h" +static void NET_WriteMD5(net_packet_t *packet, md5_digest_t digest) +{ + int i; + + for (i = 0; i < sizeof(md5_digest_t); ++i) + { + NET_WriteInt8(packet, digest[i]); + } +} + +static boolean NET_ReadMD5(net_packet_t *packet, md5_digest_t digest) +{ + unsigned int val; + int i; + + for (i = 0; i < sizeof(md5_digest_t); ++i) + { + if (!NET_ReadInt8(packet, &val)) + { + return false; + } + + digest[i] = (uint8_t) val; + } + + return true; +} + void NET_WriteConnectData(net_packet_t *packet, net_connect_data_t *data) { NET_WriteInt8(packet, data->gamemode); NET_WriteInt8(packet, data->gamemission); NET_WriteInt8(packet, data->lowres_turn); NET_WriteInt8(packet, data->drone); + NET_WriteInt8(packet, data->is_freedoom); + NET_WriteMD5(packet, data->wad_md5sum); + NET_WriteMD5(packet, data->deh_md5sum); NET_WriteInt8(packet, data->player_class); } @@ -46,6 +77,9 @@ boolean NET_ReadConnectData(net_packet_t *packet, net_connect_data_t *data) && NET_ReadInt8(packet, (unsigned int *) &data->gamemission) && NET_ReadInt8(packet, (unsigned int *) &data->lowres_turn) && NET_ReadInt8(packet, (unsigned int *) &data->drone) + && NET_ReadInt8(packet, (unsigned int *) &data->is_freedoom) + && NET_ReadMD5(packet, data->wad_md5sum) + && NET_ReadMD5(packet, data->deh_md5sum) && NET_ReadInt8(packet, (unsigned int *) &data->player_class); } diff --git a/src/strife/d_net.c b/src/strife/d_net.c index 0f3b3d75..15a48873 100644 --- a/src/strife/d_net.c +++ b/src/strife/d_net.c @@ -38,6 +38,7 @@ #include "g_game.h" #include "doomdef.h" #include "doomstat.h" +#include "w_checksum.h" #include "deh_main.h" @@ -215,6 +216,13 @@ static void SaveGameSettings(net_gamesettings_t *settings, // Are we recording a demo? Possibly set lowres turn mode connect_data->lowres_turn = settings->lowres_turn; + + // Read checksums of our WAD directory and dehacked information + + W_Checksum(connect_data->wad_md5sum); + DEH_Checksum(connect_data->deh_md5sum); + + connect_data->is_freedoom = 0; } void D_InitSinglePlayerGame(net_gamesettings_t *settings) |