ref: 69ac893307c01d4fb51e6b1e0c9d54ebb3d0f256
parent: d2b34da108fae24c9c70ab00aa261cc9648018c3
author: Simon Howard <[email protected]>
date: Fri Oct 6 03:02:42 EDT 2006
Send deh/wad checksums to the server when connecting. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 688
--- 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 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;
--- 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:
//
--- a/src/md5.h
+++ b/src/md5.h
@@ -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];
--- 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 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 @@
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);
@@ -1178,6 +1186,11 @@
{
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
--- 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 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 @@
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 @@
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 @@
{
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
--- 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
//
@@ -353,6 +353,34 @@
{
NET_WriteTiccmdDiff(packet, &cmd->cmds[i], lowres_turn);
}
+ }
+}
+
+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]);
}
}
--- 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 @@
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 */
--- a/src/w_checksum.c
+++ b/src/w_checksum.c
@@ -74,7 +74,7 @@
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;
--- 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 */