Added NetworkBuffer

Allows for a command to be built before sending it off. Added wrapper functions for certain data types. Changed command from a number to a Name.
This commit is contained in:
Boondorl 2024-01-04 14:18:28 -05:00 committed by Christoph Oelckers
commit 202d0d747f
6 changed files with 293 additions and 16 deletions

View file

@ -2708,13 +2708,16 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_ZSC_CMD:
{
int cmd = ReadLong(stream);
FName cmd = ReadStringConst(stream);
unsigned int size = ReadWord(stream);
TArray<uint8_t> buffer = {};
buffer.Grow(size);
for (unsigned int i = 0u; i < size; ++i)
buffer.Push(ReadByte(stream));
if (size)
{
buffer.Grow(size);
for (unsigned int i = 0u; i < size; ++i)
buffer.Push(ReadByte(stream));
}
FNetworkCommand netCmd = { player, cmd, buffer };
primaryLevel->localEventManager->NetCommand(netCmd);
@ -2779,7 +2782,8 @@ void Net_SkipCommand (int type, uint8_t **stream)
break;
case DEM_ZSC_CMD:
skip = 6 + (((*stream)[4] << 8) | (*stream)[5]);
skip = strlen((char*)(*stream)) + 1;
skip += (((*stream)[skip] << 8) | (*stream)[skip + 1]) + 2;
break;
case DEM_SUMMON2: