NetPacket now exposes its data as BYTESTREAM_s

This commit is contained in:
Benjamin Berkels 2018-07-28 17:15:44 +02:00
parent c439f2586b
commit 37fec050f1
4 changed files with 24 additions and 10 deletions

View file

@ -23,14 +23,6 @@
#include "d_net.h"
enum class NetPacketType
{
ConnectRequest,
ConnectResponse,
Disconnect,
Tic
};
enum class NodeStatus
{
Closed,

View file

@ -21,6 +21,7 @@
#include "c_dispatch.h"
#include "actor.h"
#include "doomstat.h"
#include "i_net.h"
extern bool netserver, netclient;

View file

@ -3,7 +3,6 @@
#include "vectors.h"
#include "r_data/renderstyle.h"
#include "d_netserver.h"
// Maximum size of the packets sent out by the server.
#define MAX_UDP_PACKET 8192
@ -11,6 +10,16 @@
// This is the longest possible string we can pass over the network.
#define MAX_NETWORK_STRING 2048
enum class NetPacketType
{
ConnectRequest,
ConnectResponse,
Disconnect,
Tic
};
class AActor;
struct NetSyncData {
DVector3 Pos;
DVector3 Vel;
@ -121,6 +130,8 @@ struct NETBUFFER_s
int WriteTo( BYTESTREAM_s &ByteStream ) const;
};
struct NetPacket;
/**
* \author Benjamin Berkels
*/

View file

@ -2,13 +2,21 @@
#pragma once
#include <memory>
#include "d_netsync.h"
#define MAX_MSGLEN 14000
#define DOOMPORT 5029
struct NetPacket
{
NetPacket() { memset(data, 0, sizeof(data)); }
NetPacket()
{
memset(data, 0, sizeof(data));
stream.pbStream = data;
stream.bitBuffer = NULL;
stream.bitShift = -1;
stream.pbStreamEnd = stream.pbStream + sizeof(data);
}
// packet data to be sent
uint8_t data[MAX_MSGLEN];
@ -21,6 +29,8 @@ struct NetPacket
uint8_t &operator[](int i) { return data[i]; }
const uint8_t &operator[](int i) const { return data[i]; }
BYTESTREAM_s stream;
};
// Network packet data.