ref: 854cb8073a336455d0bcd9b6a40d67c1b4226bb3
parent: d0ada124a2700e4c762c1126e9e13e36b094a614
author: Simon Howard <[email protected]>
date: Mon Oct 17 14:13:10 EDT 2011
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
--- 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 @@
// 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)
--- 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 @@
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)
--- 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 @@
{
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 @@
// 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));
-}
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -967,9 +967,6 @@
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 @@
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
--- 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 @@
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;
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -477,9 +477,7 @@
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 @@
// 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 @@
// 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
--- a/src/net_structrw.c
+++ b/src/net_structrw.c
@@ -31,6 +31,34 @@
#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);
@@ -37,6 +65,9 @@
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 @@
&& 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);
}
--- 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 @@
// 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)