diff options
Diffstat (limited to 'src/net_structrw.c')
-rw-r--r-- | src/net_structrw.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/net_structrw.c b/src/net_structrw.c index c2e878fa..7380e334 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -21,14 +21,31 @@ // Reading and writing various structures into packets // +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include "doomdef.h" +#include "doomtype.h" #include "net_packet.h" #include "net_structrw.h" +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); +} + +boolean NET_ReadConnectData(net_packet_t *packet, net_connect_data_t *data) +{ + return NET_ReadInt8(packet, (unsigned int *) &data->gamemode) + && NET_ReadInt8(packet, (unsigned int *) &data->gamemission) + && NET_ReadInt8(packet, (unsigned int *) &data->lowres_turn) + && NET_ReadInt8(packet, (unsigned int *) &data->drone); +} + void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) { NET_WriteInt8(packet, settings->ticdup); @@ -45,6 +62,8 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings) NET_WriteInt8(packet, settings->new_sync); NET_WriteInt32(packet, settings->timelimit); NET_WriteInt8(packet, settings->loadgame); + NET_WriteInt8(packet, settings->num_players); + NET_WriteInt8(packet, settings->consoleplayer); } boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) @@ -62,7 +81,9 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings) && NET_ReadInt8(packet, (unsigned int *) &settings->lowres_turn) && NET_ReadInt8(packet, (unsigned int *) &settings->new_sync) && NET_ReadInt32(packet, (unsigned int *) &settings->timelimit) - && NET_ReadSInt8(packet, (signed int *) &settings->loadgame); + && NET_ReadSInt8(packet, (signed int *) &settings->loadgame) + && NET_ReadInt8(packet, (unsigned int *) &settings->num_players) + && NET_ReadSInt8(packet, (signed int *) &settings->consoleplayer); } boolean NET_ReadQueryData(net_packet_t *packet, net_querydata_t *query) @@ -131,6 +152,10 @@ void NET_WriteTiccmdDiff(net_packet_t *packet, net_ticdiff_t *diff, NET_WriteInt8(packet, diff->cmd.consistancy); if (diff->diff & NET_TICDIFF_CHATCHAR) NET_WriteInt8(packet, diff->cmd.chatchar); + if (diff->diff & NET_TICDIFF_LOOKFLY) + NET_WriteInt8(packet, diff->cmd.lookfly); + if (diff->diff & NET_TICDIFF_ARTIFACT) + NET_WriteInt8(packet, diff->cmd.arti); } boolean NET_ReadTiccmdDiff(net_packet_t *packet, net_ticdiff_t *diff, @@ -197,6 +222,20 @@ boolean NET_ReadTiccmdDiff(net_packet_t *packet, net_ticdiff_t *diff, diff->cmd.chatchar = val; } + if (diff->diff & NET_TICDIFF_LOOKFLY) + { + if (!NET_ReadInt8(packet, &val)) + return false; + diff->cmd.lookfly = val; + } + + if (diff->diff & NET_TICDIFF_ARTIFACT) + { + if (!NET_ReadInt8(packet, &val)) + return false; + diff->cmd.arti = val; + } + return true; } @@ -217,6 +256,13 @@ void NET_TiccmdDiff(ticcmd_t *tic1, ticcmd_t *tic2, net_ticdiff_t *diff) diff->diff |= NET_TICDIFF_CONSISTANCY; if (tic2->chatchar != 0) diff->diff |= NET_TICDIFF_CHATCHAR; + + // Hexen-specific: + + if (tic1->lookfly != tic2->lookfly) + diff->diff |= NET_TICDIFF_LOOKFLY; + if (tic2->arti != 0) + diff->diff |= NET_TICDIFF_ARTIFACT; } void NET_TiccmdPatch(ticcmd_t *src, net_ticdiff_t *diff, ticcmd_t *dest) @@ -240,6 +286,17 @@ void NET_TiccmdPatch(ticcmd_t *src, net_ticdiff_t *diff, ticcmd_t *dest) dest->chatchar = diff->cmd.chatchar; else dest->chatchar = 0; + + // Heretic/Hexen specific: + + if (diff->diff & NET_TICDIFF_LOOKFLY) + dest->lookfly = diff->cmd.lookfly; + + if (diff->diff & NET_TICDIFF_ARTIFACT) + dest->arti = diff->cmd.arti; + else + dest->arti = 0; + } // |