Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/GameEngine/Include/GameNetwork/NetCommandList.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class NetCommandList : public MemoryPoolObject
void init(); ///< Initialize the list
void reset(); ///< Reset the list to the initial state.
NetCommandRef * addMessage(NetCommandMsg *cmdMsg); ///< Add message to the list in its properly ordered place.
NetCommandRef * addMessage(NetCommandRef *&msg); ///< Add message to the list in its properly ordered place.
Bool isEqualCommandMsg(NetCommandMsg *msg1, NetCommandMsg *msg2);
NetCommandRef * getFirstMessage(); ///< Get the first message on the list.
NetCommandRef * findMessage(NetCommandMsg *msg); ///< Find and return a reference to the given message if one exists.
Expand Down
65 changes: 63 additions & 2 deletions Core/GameEngine/Include/GameNetwork/NetCommandMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,61 @@

class NetCommandRef;

//-----------------------------------------------------------------------------
class NetCommandDataChunk
{
NetCommandDataChunk(const NetCommandDataChunk&) CPP_11(= delete);
void operator=(const NetCommandDataChunk&) CPP_11(= delete);

public:
NetCommandDataChunk(Byte *data, UnsignedInt size)
: m_data(reinterpret_cast<UnsignedByte *>(data))
, m_size(size)
{}

NetCommandDataChunk(UnsignedByte *data, UnsignedInt size)
: m_data(data)
, m_size(size)
{}

NetCommandDataChunk(UnsignedInt size)
: m_data(NEW UnsignedByte[size])
, m_size(size)
{}

~NetCommandDataChunk()
{
delete[] m_data;
}

const UnsignedByte *data() const
{
return m_data;
}

UnsignedByte *data()
{
return m_data;
}

UnsignedInt size() const
{
return m_size;
}

UnsignedByte *release()
{
UnsignedByte *ret = m_data;
m_data = nullptr;
m_size = 0;
return ret;
}

private:
UnsignedByte *m_data;
UnsignedInt m_size;
};

//-----------------------------------------------------------------------------
class NetCommandMsg : public MemoryPoolObject
{
Expand All @@ -60,6 +115,7 @@ class NetCommandMsg : public MemoryPoolObject
virtual size_t getSizeForSmallNetPacket(const Select* select = nullptr) const = 0;
virtual size_t copyBytesForSmallNetPacket(UnsignedByte* buffer, const NetCommandRef& ref, const Select* select = nullptr) const = 0;
virtual Select getSmallNetPacketSelect() const = 0;
virtual size_t readMessageData(NetCommandRef& ref, NetPacketBuf buf) const = 0;
void attach();
void detach();

Expand Down Expand Up @@ -96,6 +152,11 @@ class NetCommandMsgT : public NetCommandMsg
{
return SmallNetPacketType::copyBytes(buffer, ref, select);
}

virtual size_t readMessageData(NetCommandRef& ref, NetPacketBuf buf) const override
{
return SmallNetPacketType::CommandData::readMessage(ref, buf);
}
};

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -440,7 +501,7 @@ class NetWrapperCommandMsg : public NetCommandMsgT<NetPacketWrapperCommand, Smal

const UnsignedByte * getData() const;
UnsignedByte * getData();
void setData(UnsignedByte *data, UnsignedInt dataLength);
void setData(NetCommandDataChunk &dataChunk);

UnsignedInt getChunkNumber() const;
void setChunkNumber(UnsignedInt chunkNumber);
Expand Down Expand Up @@ -490,7 +551,7 @@ class NetFileCommandMsg : public NetCommandMsgT<NetPacketFileCommand, SmallNetPa

const UnsignedByte * getFileData() const;
UnsignedByte * getFileData();
void setFileData(UnsignedByte *data, UnsignedInt dataLength);
void setFileData(NetCommandDataChunk &dataChunk);

virtual Select getSmallNetPacketSelect() const override;

Expand Down
35 changes: 2 additions & 33 deletions Core/GameEngine/Include/GameNetwork/NetPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class NetPacket : public MemoryPoolObject

NetCommandList *getCommandList();

static NetCommandRef * ConstructNetCommandMsgFromRawData(UnsignedByte *data, UnsignedShort dataLength);
static NetCommandRef *ConstructNetCommandMsgFromRawData(const UnsignedByte *data, UnsignedInt dataLength);
static NetPacketList ConstructBigCommandPacketList(NetCommandRef *ref);

UnsignedByte *getData();
Expand All @@ -80,38 +80,7 @@ class NetPacket : public MemoryPoolObject
Bool isAckStage2Repeat(NetCommandRef *msg);
Bool isFrameRepeat(NetCommandRef *msg);

static NetCommandMsg * readGameMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readAckBothMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readAckStage1Message(UnsignedByte *data, Int &i);
static NetCommandMsg * readAckStage2Message(UnsignedByte *data, Int &i);
static NetCommandMsg * readFrameMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readPlayerLeaveMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readRunAheadMetricsMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readRunAheadMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDestroyPlayerMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readKeepAliveMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDisconnectKeepAliveMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDisconnectPlayerMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readPacketRouterQueryMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readPacketRouterAckMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDisconnectChatMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDisconnectVoteMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readChatMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readProgressMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readLoadCompleteMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readTimeOutGameStartMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readWrapperMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readFileMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readFileAnnounceMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readFileProgressMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDisconnectFrameMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readDisconnectScreenOffMessage(UnsignedByte *data, Int &i);
static NetCommandMsg * readFrameResendRequestMessage(UnsignedByte *data, Int &i);

void writeGameMessageArgumentToPacket(GameMessageArgumentDataType type, GameMessageArgumentType arg);
static void readGameMessageArgumentFromPacket(GameMessageArgumentDataType type, NetGameCommandMsg *msg, UnsignedByte *data, Int &i);

void dumpPacketToLog();
static void dumpPacketToLog(const UnsignedByte *packet, Int packetLen);

protected:
UnsignedByte m_packet[MAX_PACKET_SIZE];
Expand Down
Loading
Loading