diff options
author | Simon Howard | 2006-10-06 07:02:42 +0000 |
---|---|---|
committer | Simon Howard | 2006-10-06 07:02:42 +0000 |
commit | 69ac893307c01d4fb51e6b1e0c9d54ebb3d0f256 (patch) | |
tree | 4631c8828179dd92ea41e9bfc05b9262f06716e9 | |
parent | d2b34da108fae24c9c70ab00aa261cc9648018c3 (diff) | |
download | chocolate-doom-69ac893307c01d4fb51e6b1e0c9d54ebb3d0f256.tar.gz chocolate-doom-69ac893307c01d4fb51e6b1e0c9d54ebb3d0f256.tar.bz2 chocolate-doom-69ac893307c01d4fb51e6b1e0c9d54ebb3d0f256.zip |
Send deh/wad checksums to the server when connecting.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 688
-rw-r--r-- | src/deh_main.c | 4 | ||||
-rw-r--r-- | src/deh_main.h | 5 | ||||
-rw-r--r-- | src/md5.h | 1 | ||||
-rw-r--r-- | src/net_client.c | 15 | ||||
-rw-r--r-- | src/net_server.c | 10 | ||||
-rw-r--r-- | src/net_structrw.c | 30 | ||||
-rw-r--r-- | src/net_structrw.h | 5 | ||||
-rw-r--r-- | src/w_checksum.c | 2 | ||||
-rw-r--r-- | src/w_checksum.h | 2 |
9 files changed, 63 insertions, 11 deletions
diff --git a/src/deh_main.c b/src/deh_main.c index b7c59316..2fa57f97 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: deh_main.c 687 2006-10-05 22:12:22Z fraggle $ +// $Id: deh_main.c 688 2006-10-06 07:02:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -113,7 +113,7 @@ static deh_section_t *section_types[] = static int num_section_types = sizeof(section_types) / sizeof(*section_types); -void DEH_Checksum(byte digest[16]) +void DEH_Checksum(md5_digest_t digest) { md5_context_t md5_context; int i; diff --git a/src/deh_main.h b/src/deh_main.h index ef3a51dc..e9adcd9a 100644 --- a/src/deh_main.h +++ b/src/deh_main.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: deh_main.h 687 2006-10-05 22:12:22Z fraggle $ +// $Id: deh_main.h 688 2006-10-06 07:02:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -46,12 +46,13 @@ #include "doomtype.h" #include "doomfeatures.h" +#include "md5.h" void DEH_Init(void); boolean DEH_ParseAssignment(char *line, char **variable_name, char **value); -void DEH_Checksum(byte digest[16]); +void DEH_Checksum(md5_digest_t digest); // deh_text.c: // @@ -34,6 +34,7 @@ #define md5byte unsigned char typedef struct md5_context_s md5_context_t; +typedef md5byte md5_digest_t[16]; struct md5_context_s { UWORD32 buf[4]; diff --git a/src/net_client.c b/src/net_client.c index a3281ac8..9a90b7e3 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.c 685 2006-10-05 17:19:43Z fraggle $ +// $Id: net_client.c 688 2006-10-06 07:02:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -163,6 +163,7 @@ #include "net_packet.h" #include "net_server.h" #include "net_structrw.h" +#include "w_checksum.h" typedef enum { @@ -271,6 +272,11 @@ static net_server_recv_t recvwindow[BACKUPTICS]; static boolean need_to_acknowledge; static unsigned int gamedata_recv_time; +// Hash checksums of our wad directory and dehacked data. + +static md5_digest_t wad_md5sum; +static md5_digest_t deh_md5sum; + // Average time between sending our ticcmd and receiving from the server static fixed_t average_latency; @@ -1158,6 +1164,8 @@ static void NET_CL_SendSYN(void) NET_WriteInt16(packet, gamemission); NET_WriteInt8(packet, lowres_turn); NET_WriteInt8(packet, drone); + NET_WriteMD5Sum(packet, wad_md5sum); + NET_WriteMD5Sum(packet, deh_md5sum); NET_WriteString(packet, net_player_name); NET_Conn_SendPacket(&client_connection, packet); NET_FreePacket(packet); @@ -1179,6 +1187,11 @@ boolean NET_CL_Connect(net_addr_t *addr) lowres_turn = true; } + // Read checksums of our WAD directory and dehacked information + + W_Checksum(wad_md5sum); + DEH_Checksum(deh_md5sum); + // create a new network I/O context and add just the // necessary module diff --git a/src/net_server.c b/src/net_server.c index 87180793..4628e7e7 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.c 685 2006-10-05 17:19:43Z fraggle $ +// $Id: net_server.c 688 2006-10-06 07:02:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -252,6 +252,7 @@ static net_context_t *server_context; static int sv_gamemode; static int sv_gamemission; static net_gamesettings_t sv_settings; +static md5_digest_t sv_wad_md5sum, sv_deh_md5sum; // receive window @@ -555,6 +556,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, unsigned int cl_gamemode, cl_gamemission; unsigned int cl_recording_lowres; unsigned int cl_drone; + md5_digest_t deh_md5sum, wad_md5sum; char *player_name; char *client_version; int i; @@ -593,7 +595,9 @@ static void NET_SV_ParseSYN(net_packet_t *packet, if (!NET_ReadInt16(packet, &cl_gamemode) || !NET_ReadInt16(packet, &cl_gamemission) || !NET_ReadInt8(packet, &cl_recording_lowres) - || !NET_ReadInt8(packet, &cl_drone)) + || !NET_ReadInt8(packet, &cl_drone) + || !NET_ReadMD5Sum(packet, wad_md5sum) + || !NET_ReadMD5Sum(packet, deh_md5sum)) { return; } @@ -682,6 +686,8 @@ static void NET_SV_ParseSYN(net_packet_t *packet, { sv_gamemode = cl_gamemode; sv_gamemission = cl_gamemission; + memcpy(sv_wad_md5sum, wad_md5sum, sizeof(md5_digest_t)); + memcpy(sv_deh_md5sum, deh_md5sum, sizeof(md5_digest_t)); } // Check the connecting client is playing the same game as all diff --git a/src/net_structrw.c b/src/net_structrw.c index c947fb30..28e3585e 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_structrw.c 612 2006-09-17 20:37:26Z fraggle $ +// $Id: net_structrw.c 688 2006-10-06 07:02:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -356,3 +356,31 @@ void NET_WriteFullTiccmd(net_packet_t *packet, net_full_ticcmd_t *cmd, boolean l } } +boolean NET_ReadMD5Sum(net_packet_t *packet, md5_digest_t digest) +{ + unsigned int b; + int i; + + for (i=0; i<16; ++i) + { + if (!NET_ReadInt8(packet, &b)) + { + return false; + } + + digest[i] = b; + } + + return true; +} + +void NET_WriteMD5Sum(net_packet_t *packet, md5_digest_t digest) +{ + int i; + + for (i=0; i<16; ++i) + { + NET_WriteInt8(packet, digest[i]); + } +} + diff --git a/src/net_structrw.h b/src/net_structrw.h index 920dd851..ab012aa5 100644 --- a/src/net_structrw.h +++ b/src/net_structrw.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_structrw.h 612 2006-09-17 20:37:26Z fraggle $ +// $Id: net_structrw.h 688 2006-10-06 07:02:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -47,6 +47,7 @@ #ifndef NET_STRUCTRW_H #define NET_STRUCTRW_H +#include "md5.h" #include "net_defs.h" #include "net_packet.h" @@ -64,6 +65,8 @@ extern void NET_TiccmdPatch(ticcmd_t *src, net_ticdiff_t *diff, ticcmd_t *dest); boolean NET_ReadFullTiccmd(net_packet_t *packet, net_full_ticcmd_t *cmd, boolean lowres_turn); void NET_WriteFullTiccmd(net_packet_t *packet, net_full_ticcmd_t *cmd, boolean lowres_turn); +boolean NET_ReadMD5Sum(net_packet_t *packet, md5_digest_t digest); +void NET_WriteMD5Sum(net_packet_t *packet, md5_digest_t digest); #endif /* #ifndef NET_STRUCTRW_H */ diff --git a/src/w_checksum.c b/src/w_checksum.c index faa6108a..a3d97e24 100644 --- a/src/w_checksum.c +++ b/src/w_checksum.c @@ -74,7 +74,7 @@ static void ChecksumAddLump(md5_context_t *md5_context, lumpinfo_t *lump) MD5_UpdateInt32(md5_context, lump->size); } -void W_Checksum(byte digest[16]) +void W_Checksum(md5_digest_t digest) { md5_context_t md5_context; int i; diff --git a/src/w_checksum.h b/src/w_checksum.h index 7967a36d..c2ac2c98 100644 --- a/src/w_checksum.h +++ b/src/w_checksum.h @@ -30,7 +30,7 @@ #include "doomtype.h" -extern void W_Checksum(byte digest[16]); +extern void W_Checksum(md5_digest_t digest); #endif /* #ifndef W_CHECKSUM_H */ |