mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-01 15:20:49 +00:00
NetPacket now exposes its data as BYTESTREAM_s
This commit is contained in:
parent
c439f2586b
commit
37fec050f1
4 changed files with 24 additions and 10 deletions
|
@ -23,14 +23,6 @@
|
||||||
|
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
|
|
||||||
enum class NetPacketType
|
|
||||||
{
|
|
||||||
ConnectRequest,
|
|
||||||
ConnectResponse,
|
|
||||||
Disconnect,
|
|
||||||
Tic
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class NodeStatus
|
enum class NodeStatus
|
||||||
{
|
{
|
||||||
Closed,
|
Closed,
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "c_dispatch.h"
|
#include "c_dispatch.h"
|
||||||
#include "actor.h"
|
#include "actor.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
|
#include "i_net.h"
|
||||||
|
|
||||||
extern bool netserver, netclient;
|
extern bool netserver, netclient;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "r_data/renderstyle.h"
|
#include "r_data/renderstyle.h"
|
||||||
#include "d_netserver.h"
|
|
||||||
|
|
||||||
// Maximum size of the packets sent out by the server.
|
// Maximum size of the packets sent out by the server.
|
||||||
#define MAX_UDP_PACKET 8192
|
#define MAX_UDP_PACKET 8192
|
||||||
|
@ -11,6 +10,16 @@
|
||||||
// This is the longest possible string we can pass over the network.
|
// This is the longest possible string we can pass over the network.
|
||||||
#define MAX_NETWORK_STRING 2048
|
#define MAX_NETWORK_STRING 2048
|
||||||
|
|
||||||
|
enum class NetPacketType
|
||||||
|
{
|
||||||
|
ConnectRequest,
|
||||||
|
ConnectResponse,
|
||||||
|
Disconnect,
|
||||||
|
Tic
|
||||||
|
};
|
||||||
|
|
||||||
|
class AActor;
|
||||||
|
|
||||||
struct NetSyncData {
|
struct NetSyncData {
|
||||||
DVector3 Pos;
|
DVector3 Pos;
|
||||||
DVector3 Vel;
|
DVector3 Vel;
|
||||||
|
@ -121,6 +130,8 @@ struct NETBUFFER_s
|
||||||
int WriteTo( BYTESTREAM_s &ByteStream ) const;
|
int WriteTo( BYTESTREAM_s &ByteStream ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct NetPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \author Benjamin Berkels
|
* \author Benjamin Berkels
|
||||||
*/
|
*/
|
||||||
|
|
12
src/i_net.h
12
src/i_net.h
|
@ -2,13 +2,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "d_netsync.h"
|
||||||
|
|
||||||
#define MAX_MSGLEN 14000
|
#define MAX_MSGLEN 14000
|
||||||
#define DOOMPORT 5029
|
#define DOOMPORT 5029
|
||||||
|
|
||||||
struct NetPacket
|
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
|
// packet data to be sent
|
||||||
uint8_t data[MAX_MSGLEN];
|
uint8_t data[MAX_MSGLEN];
|
||||||
|
@ -21,6 +29,8 @@ struct NetPacket
|
||||||
|
|
||||||
uint8_t &operator[](int i) { return data[i]; }
|
uint8_t &operator[](int i) { return data[i]; }
|
||||||
const uint8_t &operator[](int i) const { return data[i]; }
|
const uint8_t &operator[](int i) const { return data[i]; }
|
||||||
|
|
||||||
|
BYTESTREAM_s stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Network packet data.
|
// Network packet data.
|
||||||
|
|
Loading…
Reference in a new issue