change pretty much everything so it does what I want :^)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
|
||||
#include "net_disconnect.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -10,32 +9,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadString(data->message, sizeof(data->message));
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_Disconnect_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_Disconnect* data)
|
||||
{
|
||||
bitbuf.WriteString(data->message);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_Disconnect_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_Disconnect* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
reader.ReadString("message", data->message, sizeof(data->message));
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool Net_Disconnect_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_Disconnect* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteString("message", data->message);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void Net_Disconnect_ToString_Internal(std::ostringstream& out, NetMsg::Net_Disconnect* data)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "net_file.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -12,38 +11,4 @@ namespace NetHandlers
|
||||
data->isRequest = bitbuf.ReadOneBit() != 0;
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_File_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_File* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->transferID, 32);
|
||||
bitbuf.WriteString(data->filename);
|
||||
bitbuf.WriteOneBit(data->isRequest);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_File_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_File* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->transferID = reader.ReadUInt32("transferId");
|
||||
reader.ReadString("filename", data->filename, sizeof(data->filename));
|
||||
data->isRequest = reader.ReadBool("isRequest");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool Net_File_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_File* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("transferId", data->transferID);
|
||||
jsonbuf.WriteString("filename", data->filename);
|
||||
jsonbuf.WriteBool("isRequest", data->isRequest);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void Net_File_ToString_Internal(std::ostringstream& out, NetMsg::Net_File* data)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
#include "net_nop.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -8,23 +7,4 @@ namespace NetHandlers
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Net_NOP_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_NOP* data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Net_NOP_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_NOP* data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Net_NOP_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_NOP* data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Net_NOP_ToString_Internal(std::ostringstream& out, NetMsg::Net_NOP* data)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "net_setconvar.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -14,55 +13,8 @@ namespace NetHandlers
|
||||
{
|
||||
bitbuf.ReadString(cvar.name, sizeof(cvar.name));
|
||||
bitbuf.ReadString(cvar.value, sizeof(cvar.value));
|
||||
//printf("%s -> %s\n", cvar.name, cvar.value);
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_SetConVar_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_SetConVar* data)
|
||||
{
|
||||
bitbuf.WriteByte(data->cvars.size());
|
||||
for (const cvar_t& cvar : data->cvars)
|
||||
{
|
||||
bitbuf.WriteString(cvar.name);
|
||||
bitbuf.WriteString(cvar.value);
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_SetConVar_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_SetConVar* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
|
||||
base::JsonReaderArray cvars = reader.ReadArray("cvars");
|
||||
cvars.TransformTo(data->cvars, [](base::JsonReaderObject& obj, cvar_t& cvar)
|
||||
{
|
||||
obj.ReadString("name", cvar.name, sizeof(cvar.name));
|
||||
obj.ReadString("value", cvar.value, sizeof(cvar.value));
|
||||
});
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool Net_SetConVar_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_SetConVar* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.StartArray("cvars");
|
||||
for (const cvar_t& cvar : data->cvars)
|
||||
{
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteString("name", cvar.name);
|
||||
jsonbuf.WriteString("value", cvar.value);
|
||||
jsonbuf.EndObject();
|
||||
}
|
||||
jsonbuf.EndArray();
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void Net_SetConVar_ToString_Internal(std::ostringstream& out, NetMsg::Net_SetConVar* data)
|
||||
{
|
||||
cvar_t cvar = data->cvars[0];
|
||||
out << "net_SetConVar: " << data->cvars.size() << " cvars, \"" << cvar.name << "\"=\"" << cvar.value << '"';
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "net_signonstate.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -12,36 +11,4 @@ namespace NetHandlers
|
||||
//assert(signonState >= SIGNONSTATE_NONE && signonState <= SIGNONSTATE_CHANGELEVEL);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_SignonState_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_SignonState* data)
|
||||
{
|
||||
bitbuf.WriteByte(data->signonState);
|
||||
bitbuf.WriteLong(data->spawnCount);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_SignonState_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_SignonState* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->signonState = reader.ReadUInt32("signonState");
|
||||
data->spawnCount = reader.ReadUInt32("spawnCount");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool Net_SignonState_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_SignonState* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("signonState", data->signonState);
|
||||
jsonbuf.WriteUInt32("spawnCount", data->spawnCount);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void Net_SignonState_ToString_Internal(std::ostringstream& out, NetMsg::Net_SignonState* data)
|
||||
{
|
||||
out << "net_SignonState: state " << static_cast<uint32_t>(data->signonState)
|
||||
<< ", count " << data->spawnCount;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "net_stringcmd.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -10,32 +9,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadString(data->command, sizeof(data->command));
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_StringCmd_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_StringCmd* data)
|
||||
{
|
||||
bitbuf.WriteString(data->command);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_StringCmd_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_StringCmd* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
reader.ReadString("command", data->command, sizeof(data->command));
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool Net_StringCmd_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_StringCmd* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteString("command", data->command);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void Net_StringCmd_ToString_Internal(std::ostringstream& out, NetMsg::Net_StringCmd* data)
|
||||
{
|
||||
out << "net_StringCmd: \"" << data->command << '"';
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "net_tick.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -12,38 +11,4 @@ namespace NetHandlers
|
||||
data->hostFrameTimeStdDev = bitbuf.ReadUBitLong(16);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_Tick_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::Net_Tick* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->tick, 32);
|
||||
bitbuf.WriteUBitLong(data->hostFrameTime, 16);
|
||||
bitbuf.WriteUBitLong(data->hostFrameTimeStdDev, 16);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool Net_Tick_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::Net_Tick* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->tick = reader.ReadInt32("tick");
|
||||
data->hostFrameTime = reader.ReadUInt32("hostFrameTime");
|
||||
data->hostFrameTimeStdDev = reader.ReadUInt32("hostFrameTimeStdDev");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool Net_Tick_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_Tick* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteInt32("tick", data->tick);
|
||||
jsonbuf.WriteUInt32("hostFrameTime", data->hostFrameTime);
|
||||
jsonbuf.WriteUInt32("hostFrameTimeStdDev", data->hostFrameTimeStdDev);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void Net_Tick_ToString_Internal(std::ostringstream& out, NetMsg::Net_Tick* data)
|
||||
{
|
||||
out << "net_Tick: tick " << data->tick;
|
||||
}
|
||||
}
|
||||
|
@ -49,5 +49,7 @@ enum constants
|
||||
SIGNONSTATE_FULL = 6, // we are fully connected, first non-delta packet received
|
||||
SIGNONSTATE_CHANGELEVEL = 7, // server is changing level, please wait
|
||||
|
||||
MAX_STRINGTABLE_DATA = 2 * 524288 // 2^19
|
||||
MAX_STRINGTABLE_DATA = 2 * 524288, // 2^19
|
||||
|
||||
NUM_NETWORKED_EHANDLE_SERIAL_NUMBER_BITS = 10
|
||||
};
|
||||
|
@ -45,78 +45,78 @@
|
||||
|
||||
void NetHandlers::CreateNetMsgStructs(NetDataStructArray& netDataStructs)
|
||||
{
|
||||
netDataStructs[0] = new NetMsg::Net_NOP();
|
||||
netDataStructs[1] = new NetMsg::Net_Disconnect();
|
||||
netDataStructs[2] = new NetMsg::Net_File();
|
||||
netDataStructs[3] = new NetMsg::Net_Tick();
|
||||
netDataStructs[4] = new NetMsg::Net_StringCmd();
|
||||
netDataStructs[5] = new NetMsg::Net_SetConVar();
|
||||
netDataStructs[6] = new NetMsg::Net_SignonState();
|
||||
netDataStructs[7] = new NetMsg::SVC_Print();
|
||||
netDataStructs[8] = new NetMsg::SVC_ServerInfo();
|
||||
netDataStructs[9] = new NetMsg::SVC_SendTable();
|
||||
netDataStructs[10] = new NetMsg::SVC_ClassInfo();
|
||||
netDataStructs[11] = new NetMsg::SVC_SetPause();
|
||||
netDataStructs[12] = new NetMsg::SVC_CreateStringTable();
|
||||
netDataStructs[13] = new NetMsg::SVC_UpdateStringTable();
|
||||
netDataStructs[14] = new NetMsg::SVC_VoiceInit();
|
||||
netDataStructs[15] = new NetMsg::SVC_VoiceData();
|
||||
netDataStructs[16] = new NetMsg::SVC_HLTV();
|
||||
netDataStructs[17] = new NetMsg::SVC_Sounds();
|
||||
netDataStructs[18] = new NetMsg::SVC_SetView();
|
||||
netDataStructs[19] = new NetMsg::SVC_FixAngle();
|
||||
netDataStructs[20] = new NetMsg::SVC_CrosshairAngle();
|
||||
netDataStructs[21] = new NetMsg::SVC_BSPDecal();
|
||||
netDataStructs[22] = new NetMsg::SVC_TerrainMod();
|
||||
netDataStructs[23] = new NetMsg::SVC_UserMessage();
|
||||
netDataStructs[24] = new NetMsg::SVC_EntityMessage();
|
||||
netDataStructs[25] = new NetMsg::SVC_GameEvent();
|
||||
netDataStructs[26] = new NetMsg::SVC_PacketEntities();
|
||||
netDataStructs[27] = new NetMsg::SVC_TempEntities();
|
||||
netDataStructs[28] = new NetMsg::SVC_Prefetch();
|
||||
netDataStructs[29] = new NetMsg::SVC_Menu();
|
||||
netDataStructs[30] = new NetMsg::SVC_GameEventList();
|
||||
netDataStructs[31] = new NetMsg::SVC_GetCvarValue();
|
||||
netDataStructs[32] = new NetMsg::SVC_CmdKeyValues();
|
||||
netDataStructs[33] = new NetMsg::SVC_SetPauseTimed();
|
||||
netDataStructs[NetMsg::net_NOP] = new NetMsg::Net_NOP();
|
||||
netDataStructs[NetMsg::net_Disconnect] = new NetMsg::Net_Disconnect();
|
||||
netDataStructs[NetMsg::net_File] = new NetMsg::Net_File();
|
||||
netDataStructs[NetMsg::net_Tick] = new NetMsg::Net_Tick();
|
||||
netDataStructs[NetMsg::net_StringCmd] = new NetMsg::Net_StringCmd();
|
||||
netDataStructs[NetMsg::net_SetConVar] = new NetMsg::Net_SetConVar();
|
||||
netDataStructs[NetMsg::net_SignonState] = new NetMsg::Net_SignonState();
|
||||
netDataStructs[NetMsg::svc_Print] = new NetMsg::SVC_Print();
|
||||
netDataStructs[NetMsg::svc_ServerInfo] = new NetMsg::SVC_ServerInfo();
|
||||
netDataStructs[NetMsg::svc_SendTable] = new NetMsg::SVC_SendTable();
|
||||
netDataStructs[NetMsg::svc_ClassInfo] = new NetMsg::SVC_ClassInfo();
|
||||
netDataStructs[NetMsg::svc_SetPause] = new NetMsg::SVC_SetPause();
|
||||
netDataStructs[NetMsg::svc_CreateStringTable] = new NetMsg::SVC_CreateStringTable();
|
||||
netDataStructs[NetMsg::svc_UpdateStringTable] = new NetMsg::SVC_UpdateStringTable();
|
||||
netDataStructs[NetMsg::svc_VoiceInit] = new NetMsg::SVC_VoiceInit();
|
||||
netDataStructs[NetMsg::svc_VoiceData] = new NetMsg::SVC_VoiceData();
|
||||
netDataStructs[NetMsg::svc_HLTV] = new NetMsg::SVC_HLTV();
|
||||
netDataStructs[NetMsg::svc_Sounds] = new NetMsg::SVC_Sounds();
|
||||
netDataStructs[NetMsg::svc_SetView] = new NetMsg::SVC_SetView();
|
||||
netDataStructs[NetMsg::svc_FixAngle] = new NetMsg::SVC_FixAngle();
|
||||
netDataStructs[NetMsg::svc_CrosshairAngle] = new NetMsg::SVC_CrosshairAngle();
|
||||
netDataStructs[NetMsg::svc_BSPDecal] = new NetMsg::SVC_BSPDecal();
|
||||
netDataStructs[NetMsg::svc_TerrainMod] = new NetMsg::SVC_TerrainMod();
|
||||
netDataStructs[NetMsg::svc_UserMessage] = new NetMsg::SVC_UserMessage();
|
||||
netDataStructs[NetMsg::svc_EntityMessage] = new NetMsg::SVC_EntityMessage();
|
||||
netDataStructs[NetMsg::svc_GameEvent] = new NetMsg::SVC_GameEvent();
|
||||
netDataStructs[NetMsg::svc_PacketEntities] = new NetMsg::SVC_PacketEntities();
|
||||
netDataStructs[NetMsg::svc_TempEntities] = new NetMsg::SVC_TempEntities();
|
||||
netDataStructs[NetMsg::svc_Prefetch] = new NetMsg::SVC_Prefetch();
|
||||
netDataStructs[NetMsg::svc_Menu] = new NetMsg::SVC_Menu();
|
||||
netDataStructs[NetMsg::svc_GameEventList] = new NetMsg::SVC_GameEventList();
|
||||
netDataStructs[NetMsg::svc_GetCvarValue] = new NetMsg::SVC_GetCvarValue();
|
||||
netDataStructs[NetMsg::svc_CmdKeyValues] = new NetMsg::SVC_CmdKeyValues();
|
||||
netDataStructs[NetMsg::svc_SetPauseTimed] = new NetMsg::SVC_SetPauseTimed();
|
||||
}
|
||||
|
||||
void NetHandlers::DestroyNetMsgStructs(NetDataStructArray& netDataStructs)
|
||||
{
|
||||
delete reinterpret_cast<NetMsg::Net_NOP*>(netDataStructs[0]);
|
||||
delete reinterpret_cast<NetMsg::Net_Disconnect*>(netDataStructs[1]);
|
||||
delete reinterpret_cast<NetMsg::Net_File*>(netDataStructs[2]);
|
||||
delete reinterpret_cast<NetMsg::Net_Tick*>(netDataStructs[3]);
|
||||
delete reinterpret_cast<NetMsg::Net_StringCmd*>(netDataStructs[4]);
|
||||
delete reinterpret_cast<NetMsg::Net_SetConVar*>(netDataStructs[5]);
|
||||
delete reinterpret_cast<NetMsg::Net_SignonState*>(netDataStructs[6]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Print*>(netDataStructs[7]);
|
||||
delete reinterpret_cast<NetMsg::SVC_ServerInfo*>(netDataStructs[8]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SendTable*>(netDataStructs[9]);
|
||||
delete reinterpret_cast<NetMsg::SVC_ClassInfo*>(netDataStructs[10]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SetPause*>(netDataStructs[11]);
|
||||
delete reinterpret_cast<NetMsg::SVC_CreateStringTable*>(netDataStructs[12]);
|
||||
delete reinterpret_cast<NetMsg::SVC_UpdateStringTable*>(netDataStructs[13]);
|
||||
delete reinterpret_cast<NetMsg::SVC_VoiceInit*>(netDataStructs[14]);
|
||||
delete reinterpret_cast<NetMsg::SVC_VoiceData*>(netDataStructs[15]);
|
||||
delete reinterpret_cast<NetMsg::SVC_HLTV*>(netDataStructs[16]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Sounds*>(netDataStructs[17]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SetView*>(netDataStructs[18]);
|
||||
delete reinterpret_cast<NetMsg::SVC_FixAngle*>(netDataStructs[19]);
|
||||
delete reinterpret_cast<NetMsg::SVC_CrosshairAngle*>(netDataStructs[20]);
|
||||
delete reinterpret_cast<NetMsg::SVC_BSPDecal*>(netDataStructs[21]);
|
||||
delete reinterpret_cast<NetMsg::SVC_TerrainMod*>(netDataStructs[22]);
|
||||
delete reinterpret_cast<NetMsg::SVC_UserMessage*>(netDataStructs[23]);
|
||||
delete reinterpret_cast<NetMsg::SVC_EntityMessage*>(netDataStructs[24]);
|
||||
delete reinterpret_cast<NetMsg::SVC_GameEvent*>(netDataStructs[25]);
|
||||
delete reinterpret_cast<NetMsg::SVC_PacketEntities*>(netDataStructs[26]);
|
||||
delete reinterpret_cast<NetMsg::SVC_TempEntities*>(netDataStructs[27]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Prefetch*>(netDataStructs[28]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Menu*>(netDataStructs[29]);
|
||||
delete reinterpret_cast<NetMsg::SVC_GameEventList*>(netDataStructs[30]);
|
||||
delete reinterpret_cast<NetMsg::SVC_GetCvarValue*>(netDataStructs[31]);
|
||||
delete reinterpret_cast<NetMsg::SVC_CmdKeyValues*>(netDataStructs[32]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SetPauseTimed*>(netDataStructs[33]);
|
||||
delete reinterpret_cast<NetMsg::Net_NOP*>(netDataStructs[NetMsg::net_NOP]);
|
||||
delete reinterpret_cast<NetMsg::Net_Disconnect*>(netDataStructs[NetMsg::net_Disconnect]);
|
||||
delete reinterpret_cast<NetMsg::Net_File*>(netDataStructs[NetMsg::net_File]);
|
||||
delete reinterpret_cast<NetMsg::Net_Tick*>(netDataStructs[NetMsg::net_Tick]);
|
||||
delete reinterpret_cast<NetMsg::Net_StringCmd*>(netDataStructs[NetMsg::net_StringCmd]);
|
||||
delete reinterpret_cast<NetMsg::Net_SetConVar*>(netDataStructs[NetMsg::net_SetConVar]);
|
||||
delete reinterpret_cast<NetMsg::Net_SignonState*>(netDataStructs[NetMsg::net_SignonState]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Print*>(netDataStructs[NetMsg::svc_Print]);
|
||||
delete reinterpret_cast<NetMsg::SVC_ServerInfo*>(netDataStructs[NetMsg::svc_ServerInfo]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SendTable*>(netDataStructs[NetMsg::svc_SendTable]);
|
||||
delete reinterpret_cast<NetMsg::SVC_ClassInfo*>(netDataStructs[NetMsg::svc_ClassInfo]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SetPause*>(netDataStructs[NetMsg::svc_SetPause]);
|
||||
delete reinterpret_cast<NetMsg::SVC_CreateStringTable*>(netDataStructs[NetMsg::svc_CreateStringTable]);
|
||||
delete reinterpret_cast<NetMsg::SVC_UpdateStringTable*>(netDataStructs[NetMsg::svc_UpdateStringTable]);
|
||||
delete reinterpret_cast<NetMsg::SVC_VoiceInit*>(netDataStructs[NetMsg::svc_VoiceInit]);
|
||||
delete reinterpret_cast<NetMsg::SVC_VoiceData*>(netDataStructs[NetMsg::svc_VoiceData]);
|
||||
delete reinterpret_cast<NetMsg::SVC_HLTV*>(netDataStructs[NetMsg::svc_HLTV]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Sounds*>(netDataStructs[NetMsg::svc_Sounds]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SetView*>(netDataStructs[NetMsg::svc_SetView]);
|
||||
delete reinterpret_cast<NetMsg::SVC_FixAngle*>(netDataStructs[NetMsg::svc_FixAngle]);
|
||||
delete reinterpret_cast<NetMsg::SVC_CrosshairAngle*>(netDataStructs[NetMsg::svc_CrosshairAngle]);
|
||||
delete reinterpret_cast<NetMsg::SVC_BSPDecal*>(netDataStructs[NetMsg::svc_BSPDecal]);
|
||||
delete reinterpret_cast<NetMsg::SVC_TerrainMod*>(netDataStructs[NetMsg::svc_TerrainMod]);
|
||||
delete reinterpret_cast<NetMsg::SVC_UserMessage*>(netDataStructs[NetMsg::svc_UserMessage]);
|
||||
delete reinterpret_cast<NetMsg::SVC_EntityMessage*>(netDataStructs[NetMsg::svc_EntityMessage]);
|
||||
delete reinterpret_cast<NetMsg::SVC_GameEvent*>(netDataStructs[NetMsg::svc_GameEvent]);
|
||||
delete reinterpret_cast<NetMsg::SVC_PacketEntities*>(netDataStructs[NetMsg::svc_PacketEntities]);
|
||||
delete reinterpret_cast<NetMsg::SVC_TempEntities*>(netDataStructs[NetMsg::svc_TempEntities]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Prefetch*>(netDataStructs[NetMsg::svc_Prefetch]);
|
||||
delete reinterpret_cast<NetMsg::SVC_Menu*>(netDataStructs[NetMsg::svc_Menu]);
|
||||
delete reinterpret_cast<NetMsg::SVC_GameEventList*>(netDataStructs[NetMsg::svc_GameEventList]);
|
||||
delete reinterpret_cast<NetMsg::SVC_GetCvarValue*>(netDataStructs[NetMsg::svc_GetCvarValue]);
|
||||
delete reinterpret_cast<NetMsg::SVC_CmdKeyValues*>(netDataStructs[NetMsg::svc_CmdKeyValues]);
|
||||
delete reinterpret_cast<NetMsg::SVC_SetPauseTimed*>(netDataStructs[NetMsg::svc_SetPauseTimed]);
|
||||
}
|
||||
|
||||
#define DECLARE_NET_HANDLER_ARRAY(funcname) \
|
||||
@ -158,10 +158,6 @@ void NetHandlers::DestroyNetMsgStructs(NetDataStructArray& netDataStructs)
|
||||
}
|
||||
|
||||
typedef bool (*NetMsgBitReadFn)(NetHandlers::BitRead& bitbuf, SourceGameContext& context, void* data);
|
||||
typedef bool (*NetMsgBitWriteFn)(NetHandlers::BitWrite& bitbuf, const SourceGameContext& context, void* data);
|
||||
typedef bool (*NetMsgJsonReadFn)(NetHandlers::JsonRead& jsonbuf, SourceGameContext& context, void* data);
|
||||
typedef bool (*NetMsgJsonWriteFn)(NetHandlers::JsonWrite& jsonbuf, const SourceGameContext& context, void* data);
|
||||
typedef void (*NetMsgToStringFn)(std::ostringstream& out, void* data);
|
||||
|
||||
template<typename BufType, typename FnType, typename ContextType, size_t NumHandlers>
|
||||
bool NetMsgFuncRunner(const FnType (&netHandlers)[NumHandlers], uint32_t type, BufType& buf, ContextType& context, void* data)
|
||||
@ -179,30 +175,3 @@ bool NetHandlers::NetMsg_BitRead(uint32_t type, BitRead& bitbuf, SourceGameConte
|
||||
return NetMsgFuncRunner(netHandlers, type, bitbuf, context, data);
|
||||
}
|
||||
|
||||
bool NetHandlers::NetMsg_BitWrite(uint32_t type, BitWrite& bitbuf, const SourceGameContext& context, void* data)
|
||||
{
|
||||
static const NetMsgBitWriteFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(BitWrite);
|
||||
return NetMsgFuncRunner(netHandlers, type, bitbuf, context, data);
|
||||
}
|
||||
|
||||
bool NetHandlers::NetMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, SourceGameContext& context, void* data)
|
||||
{
|
||||
static const NetMsgJsonReadFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(JsonRead);
|
||||
return NetMsgFuncRunner(netHandlers, type, jsonbuf, context, data);
|
||||
}
|
||||
|
||||
bool NetHandlers::NetMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, const SourceGameContext& context, void* data)
|
||||
{
|
||||
static const NetMsgJsonWriteFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(JsonWrite);
|
||||
return NetMsgFuncRunner(netHandlers, type, jsonbuf, context, data);
|
||||
}
|
||||
|
||||
void NetHandlers::NetMsg_ToString(uint32_t type, std::ostringstream& out, void* data)
|
||||
{
|
||||
static const NetMsgToStringFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(ToString);
|
||||
if (type >= (sizeof(netHandlers) / sizeof(NetMsgToStringFn)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
netHandlers[type](out, data);
|
||||
}
|
||||
|
@ -6,23 +6,11 @@
|
||||
#include <array>
|
||||
#include "netmessages.h"
|
||||
|
||||
namespace base
|
||||
{
|
||||
class JsonReaderFile;
|
||||
class JsonWriterFile;
|
||||
class BitFileRead;
|
||||
class BitFileWrite;
|
||||
}
|
||||
|
||||
class bf_read;
|
||||
class bf_write;
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
using BitRead = bf_read;
|
||||
using BitWrite = bf_write;
|
||||
using JsonRead = base::JsonReaderFile;
|
||||
using JsonWrite = base::JsonWriterFile;
|
||||
}
|
||||
|
||||
struct SourceGameContext;
|
||||
@ -35,30 +23,10 @@ struct SourceGameContext;
|
||||
namespace NetHandlers \
|
||||
{ \
|
||||
bool msgname##_BitRead_Internal(BitRead& bitbuf, SourceGameContext& context, NetMsg::msgname* data); \
|
||||
bool msgname##_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::msgname* data); \
|
||||
bool msgname##_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::msgname* data); \
|
||||
bool msgname##_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::msgname* data); \
|
||||
void msgname##_ToString_Internal(std::ostringstream& out, NetMsg::msgname* data); \
|
||||
inline bool msgname##_BitRead(BitRead& bitbuf, SourceGameContext& context, void* data) \
|
||||
{ \
|
||||
return msgname##_BitRead_Internal(bitbuf, context, reinterpret_cast<NetMsg::msgname*>(data)); \
|
||||
} \
|
||||
inline bool msgname##_BitWrite(BitWrite& bitbuf, const SourceGameContext& context, void* data) \
|
||||
{ \
|
||||
return msgname##_BitWrite_Internal(bitbuf, context, reinterpret_cast<NetMsg::msgname*>(data)); \
|
||||
} \
|
||||
inline bool msgname##_JsonRead(JsonRead& jsonbuf, SourceGameContext& context, void* data) \
|
||||
{ \
|
||||
return msgname##_JsonRead_Internal(jsonbuf, context, reinterpret_cast<NetMsg::msgname*>(data)); \
|
||||
} \
|
||||
inline bool msgname##_JsonWrite(JsonWrite& jsonbuf, const SourceGameContext& context, void* data) \
|
||||
{ \
|
||||
return msgname##_JsonWrite_Internal(jsonbuf, context, reinterpret_cast<NetMsg::msgname*>(data)); \
|
||||
} \
|
||||
inline void msgname##_ToString(std::ostringstream& out, void* data) \
|
||||
{ \
|
||||
msgname##_ToString_Internal(out, reinterpret_cast<NetMsg::msgname*>(data)); \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace NetHandlers
|
||||
@ -68,8 +36,4 @@ namespace NetHandlers
|
||||
void DestroyNetMsgStructs(NetDataStructArray& netDataStructs);
|
||||
|
||||
bool NetMsg_BitRead(uint32_t type, BitRead& bitbuf, SourceGameContext& context, void* data);
|
||||
bool NetMsg_BitWrite(uint32_t type, BitWrite& bitbuf, const SourceGameContext& context, void* data);
|
||||
bool NetMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, SourceGameContext& context, void* data);
|
||||
bool NetMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, const SourceGameContext& context, void* data);
|
||||
void NetMsg_ToString(uint32_t type, std::ostringstream& out, void* data);
|
||||
}
|
||||
|
18
demboyz/netmessages/netmath.cpp
Normal file
18
demboyz/netmessages/netmath.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
#include "netmath.h"
|
||||
|
||||
namespace math
|
||||
{
|
||||
uint32_t log2(uint32_t value)
|
||||
{
|
||||
uint32_t res = 0;
|
||||
while (value >>= 1)
|
||||
++res;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t BitsToBytes(uint32_t bits)
|
||||
{
|
||||
return ((bits + 7) >> 3);
|
||||
}
|
||||
}
|
@ -1,20 +1,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace math
|
||||
{
|
||||
static size_t log2(size_t value)
|
||||
{
|
||||
size_t res = 0;
|
||||
while (value >>= 1)
|
||||
++res;
|
||||
return res;
|
||||
}
|
||||
uint32_t log2(uint32_t value);
|
||||
|
||||
static size_t BitsToBytes(size_t bits)
|
||||
{
|
||||
return ((bits + 7) >> 3);
|
||||
}
|
||||
uint32_t BitsToBytes(uint32_t bits);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace NetMsg
|
||||
svc_VoiceInit = 14, // inits used voice codecs & quality
|
||||
svc_VoiceData = 15, // Voicestream data from the server
|
||||
|
||||
//svc_HLTV = 16, // HLTV control messages
|
||||
svc_HLTV = 16, // HLTV control messages
|
||||
|
||||
svc_Sounds = 17, // starts playing sound
|
||||
|
||||
@ -42,10 +42,10 @@ namespace NetMsg
|
||||
svc_BSPDecal = 21, // add a static decal to the world BSP
|
||||
|
||||
// NOTE: This is now unused!
|
||||
// svc_TerrainMod = 22, // modification to the terrain/displacement
|
||||
svc_TerrainMod = 22, // modification to the terrain/displacement
|
||||
|
||||
// Message from server side to client side entity
|
||||
svc_UserMessage = 23, // a game specific message
|
||||
svc_UserMessage = 23, // a game specific message
|
||||
svc_EntityMessage = 24, // a message for an entity
|
||||
svc_GameEvent = 25, // global game event fired
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "svc_bspdecal.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "demofile/demojson.h"
|
||||
#include "netcontants.h"
|
||||
|
||||
namespace NetHandlers
|
||||
@ -24,55 +22,4 @@ namespace NetHandlers
|
||||
data->lowPriority = bitbuf.ReadOneBit() != 0;
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_BSPDecal_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_BSPDecal* data)
|
||||
{
|
||||
bitbuf.WriteBitVec3Coord(data->position);
|
||||
bitbuf.WriteUBitLong(data->decalTextureIndex, MAX_DECAL_INDEX_BITS);
|
||||
if (data->entIndex != 0)
|
||||
{
|
||||
bitbuf.WriteOneBit(1);
|
||||
bitbuf.WriteUBitLong(data->entIndex, MAX_EDICT_BITS);
|
||||
bitbuf.WriteUBitLong(data->modelIndex, SP_MODEL_INDEX_BITS);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteOneBit(0);
|
||||
}
|
||||
bitbuf.WriteOneBit(data->lowPriority);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_BSPDecal_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_BSPDecal* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
DemoJsonReader::ReadVector(reader, "position", data->position);
|
||||
data->decalTextureIndex = reader.ReadUInt32("decalTextureIndex");
|
||||
data->entIndex = reader.ReadUInt32("entIndex");
|
||||
data->modelIndex = reader.ReadUInt32("modelIndex");
|
||||
data->lowPriority = reader.ReadBool("lowPriority");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_BSPDecal_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_BSPDecal* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
DemoJsonWriter::WriteVector(jsonbuf, "position", data->position);
|
||||
jsonbuf.WriteUInt32("decalTextureIndex", data->decalTextureIndex);
|
||||
jsonbuf.WriteUInt32("entIndex", data->entIndex);
|
||||
jsonbuf.WriteUInt32("modelIndex", data->modelIndex);
|
||||
jsonbuf.WriteBool("lowPriority", data->lowPriority);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_BSPDecal_ToString_Internal(std::ostringstream& out, NetMsg::SVC_BSPDecal* data)
|
||||
{
|
||||
out << "svc_BSPDecal: tex " << data->decalTextureIndex
|
||||
<< ", ent " << data->entIndex
|
||||
<< ", mod " << data->modelIndex
|
||||
<< " lowpriority " << data->lowPriority;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_classinfo.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netmath.h"
|
||||
|
||||
using class_t = NetMsg::SVC_ClassInfo::class_t;
|
||||
@ -27,67 +26,4 @@ namespace NetHandlers
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_ClassInfo_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_ClassInfo* data)
|
||||
{
|
||||
bitbuf.WriteShort(data->numServerClasses);
|
||||
bitbuf.WriteOneBit(data->createOnClient);
|
||||
if (!data->createOnClient)
|
||||
{
|
||||
const int numServerClassBits = math::log2(data->numServerClasses) + 1;
|
||||
for (class_t& serverClass : data->serverClasses)
|
||||
{
|
||||
bitbuf.WriteUBitLong(serverClass.classID, numServerClassBits);
|
||||
bitbuf.WriteString(serverClass.className);
|
||||
bitbuf.WriteString(serverClass.dataTableName);
|
||||
}
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_ClassInfo_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_ClassInfo* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->numServerClasses = reader.ReadInt32("numServerClasses");
|
||||
data->createOnClient = reader.ReadBool("createOnClient");
|
||||
if (!data->createOnClient)
|
||||
{
|
||||
base::JsonReaderArray serverClasses = reader.ReadArray("serverClasses");
|
||||
serverClasses.TransformTo(data->serverClasses, [](base::JsonReaderObject& obj, class_t& serverClass)
|
||||
{
|
||||
serverClass.classID = obj.ReadUInt32("classId");
|
||||
obj.ReadString("className", serverClass.className, sizeof(serverClass.className));
|
||||
obj.ReadString("dataTableName", serverClass.dataTableName, sizeof(serverClass.dataTableName));
|
||||
});
|
||||
}
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_ClassInfo_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_ClassInfo* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteInt32("numServerClasses", data->numServerClasses);
|
||||
jsonbuf.WriteBool("createOnClient", data->createOnClient);
|
||||
if (!data->createOnClient)
|
||||
{
|
||||
jsonbuf.StartArray("serverClasses");
|
||||
for (class_t& serverClass : data->serverClasses)
|
||||
{
|
||||
jsonbuf.WriteUInt32("classId", serverClass.classID);
|
||||
jsonbuf.WriteString("className", serverClass.className);
|
||||
jsonbuf.WriteString("dataTableName", serverClass.dataTableName);
|
||||
}
|
||||
jsonbuf.EndArray();
|
||||
}
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_ClassInfo_ToString_Internal(std::ostringstream& out, NetMsg::SVC_ClassInfo* data)
|
||||
{
|
||||
out << "svc_ClassInfo: num " << data->numServerClasses
|
||||
<< ", " << (data->createOnClient ? "use client classes" : "full update");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_cmdkeyvalues.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -11,28 +10,4 @@ namespace NetHandlers
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_CmdKeyValues_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_CmdKeyValues* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_CmdKeyValues_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_CmdKeyValues* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_CmdKeyValues_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_CmdKeyValues* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SVC_CmdKeyValues_ToString_Internal(std::ostringstream& out, NetMsg::SVC_CmdKeyValues* data)
|
||||
{
|
||||
assert(false);
|
||||
out << "svc_CmdKeyValues";
|
||||
}
|
||||
}
|
||||
|
@ -1,94 +1,14 @@
|
||||
|
||||
#include "svc_createstringtable.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
#include "game/stringtables.h"
|
||||
#include "netmath.h"
|
||||
#include "netcontants.h"
|
||||
|
||||
// #define WIP_STRINGTABLE
|
||||
|
||||
#ifdef WIP_STRINGTABLE
|
||||
#include "sourcesdk/common.h"
|
||||
#include <vector>
|
||||
|
||||
#define SUBSTRING_BITS 5
|
||||
struct StringHistoryEntry
|
||||
{
|
||||
char string[(1 << SUBSTRING_BITS)];
|
||||
};
|
||||
|
||||
static void StringTable_BitRead(NetHandlers::BitRead& bitbuf, SourceGameContext& context, NetMsg::SVC_CreateStringTable* data)
|
||||
{
|
||||
const size_t numEncodeBits = math::log2(data->maxEntries);
|
||||
std::vector<StringHistoryEntry> history;
|
||||
int entryIndex = -1;
|
||||
for (uint i = 0; i < data->numEntries; ++i)
|
||||
{
|
||||
entryIndex++;
|
||||
|
||||
if (bitbuf.ReadOneBit() == 0)
|
||||
{
|
||||
entryIndex = bitbuf.ReadUBitLong(numEncodeBits);
|
||||
}
|
||||
|
||||
const char *pEntry = NULL;
|
||||
char entry[1024];
|
||||
char substr[1024];
|
||||
if (bitbuf.ReadOneBit() != 0)
|
||||
{
|
||||
bool substringcheck = bitbuf.ReadOneBit() != 0;
|
||||
if (substringcheck)
|
||||
{
|
||||
int index = bitbuf.ReadUBitLong(5);
|
||||
int bytestocopy = bitbuf.ReadUBitLong(SUBSTRING_BITS);
|
||||
strncpy(entry, history.at(index).string, bytestocopy + 1);
|
||||
entry[bytestocopy + 1] = '\0';
|
||||
bitbuf.ReadString(substr, sizeof(substr));
|
||||
strncat(entry, substr, sizeof(entry));
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.ReadString(entry, sizeof(entry));
|
||||
}
|
||||
pEntry = entry;
|
||||
printf("%s\n", pEntry);
|
||||
}
|
||||
const int MAX_USERDATA_BITS = 14;
|
||||
unsigned char tempbuf[(1 << MAX_USERDATA_BITS)] = { 0 };
|
||||
const void *pUserData = NULL;
|
||||
if (bitbuf.ReadOneBit() != 0)
|
||||
{
|
||||
if (data->isUserDataFixedSize)
|
||||
{
|
||||
bitbuf.ReadBits(tempbuf, data->userDataSizeBits);
|
||||
}
|
||||
else
|
||||
{
|
||||
int nBytes = bitbuf.ReadUBitLong(MAX_USERDATA_BITS);
|
||||
bitbuf.ReadBytes(tempbuf, nBytes);
|
||||
}
|
||||
pUserData = tempbuf;
|
||||
}
|
||||
|
||||
if (pEntry == NULL)
|
||||
{
|
||||
pEntry = "";
|
||||
}
|
||||
|
||||
if (history.size() > 31)
|
||||
{
|
||||
history.erase(history.begin());
|
||||
}
|
||||
|
||||
StringHistoryEntry she;
|
||||
strncpy(she.string, pEntry, sizeof(she.string));
|
||||
history.emplace_back(she);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // WIP_STRINGTABLE
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
bool SVC_CreateStringTable_BitRead_Internal(BitRead& bitbuf, SourceGameContext& context, NetMsg::SVC_CreateStringTable* data)
|
||||
@ -105,21 +25,18 @@ namespace NetHandlers
|
||||
bitbuf.ReadString(data->tableName, sizeof(data->tableName));
|
||||
data->maxEntries = bitbuf.ReadWord();
|
||||
|
||||
const size_t numEncodeBits = math::log2(data->maxEntries);
|
||||
const uint32_t numEncodeBits = math::log2(data->maxEntries);
|
||||
data->numEntries = bitbuf.ReadUBitLong(numEncodeBits + 1);
|
||||
|
||||
size_t dataLengthInBits;
|
||||
if (context.protocol > 23)
|
||||
{
|
||||
dataLengthInBits = bitbuf.ReadVarInt32();
|
||||
data->dataLengthInBits = dataLengthInBits;
|
||||
data->dataLengthInBits = bitbuf.ReadVarInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
dataLengthInBits = bitbuf.ReadUBitLong(NET_MAX_PAYLOAD_BITS_OLD + 3);
|
||||
data->dataLengthInBits = dataLengthInBits;
|
||||
data->dataLengthInBits = bitbuf.ReadUBitLong(NET_MAX_PAYLOAD_BITS_OLD + 3);
|
||||
}
|
||||
const size_t dataLengthInBytes = math::BitsToBytes(dataLengthInBits);
|
||||
const uint32_t dataLengthInBytes = math::BitsToBytes(data->dataLengthInBits);
|
||||
|
||||
data->isUserDataFixedSize = bitbuf.ReadOneBit() != 0;
|
||||
if (data->isUserDataFixedSize)
|
||||
@ -136,13 +53,24 @@ namespace NetHandlers
|
||||
{
|
||||
data->compressedData = bitbuf.ReadOneBit() != 0;
|
||||
}
|
||||
data->data.reset(new uint8_t[dataLengthInBytes]);
|
||||
bitbuf.ReadBits(data->data.get(), dataLengthInBits);
|
||||
else
|
||||
{
|
||||
data->compressedData = false;
|
||||
}
|
||||
|
||||
data->data.reset(new uint8_t[dataLengthInBytes]);
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
|
||||
StringTable *table = context.stringTables->GetStringTable(data->tableName, true);
|
||||
table->maxEntries = data->maxEntries;
|
||||
table->isUserDataFixedSize = data->isUserDataFixedSize;
|
||||
table->userDataSize = data->userDataSize;
|
||||
table->userDataSizeBits = data->userDataSizeBits;
|
||||
table->entryBits = math::log2(table->maxEntries);
|
||||
|
||||
#ifdef WIP_STRINGTABLE
|
||||
if (data->compressedData)
|
||||
{
|
||||
bf_read bitbuf2(data->data.get(), dataLengthInBytes, dataLengthInBits);
|
||||
bf_read bitbuf2(data->data.get(), dataLengthInBytes, data->dataLengthInBits);
|
||||
const uint32_t decompressedNumBytes = bitbuf2.ReadUBitLong(32);
|
||||
const uint32_t compressedNumBytes = bitbuf2.ReadUBitLong(32);
|
||||
std::unique_ptr<uint8_t[]> compressedData(new uint8[compressedNumBytes]);
|
||||
@ -150,98 +78,16 @@ namespace NetHandlers
|
||||
bitbuf2.ReadBytes(compressedData.get(), compressedNumBytes);
|
||||
|
||||
uint32_t numWritten = COM_BufferToBufferDecompress(uncompressedData.get(), decompressedNumBytes, compressedData.get(), compressedNumBytes);
|
||||
assert(numWritten == decompressedNumBytes);
|
||||
bitbuf2 = bf_read(uncompressedData.get(), decompressedNumBytes);
|
||||
StringTable_BitRead(bitbuf2, context, data);
|
||||
table->ParseUpdate(bitbuf2, data->numEntries, context);
|
||||
}
|
||||
else
|
||||
else if(dataLengthInBytes)
|
||||
{
|
||||
bf_read bitbuf2(data->data.get(), dataLengthInBytes, dataLengthInBits);
|
||||
StringTable_BitRead(bitbuf2, context, data);
|
||||
bf_read bitbuf2(data->data.get(), dataLengthInBytes, data->dataLengthInBits);
|
||||
table->ParseUpdate(bitbuf2, data->numEntries, context);
|
||||
}
|
||||
#endif // WIP_STRINGTABLE
|
||||
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_CreateStringTable_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_CreateStringTable* data)
|
||||
{
|
||||
if (data->isFileNames)
|
||||
{
|
||||
bitbuf.WriteByte(':');
|
||||
}
|
||||
bitbuf.WriteString(data->tableName);
|
||||
bitbuf.WriteWord(data->maxEntries);
|
||||
bitbuf.WriteUBitLong(data->numEntries, math::log2(data->maxEntries) + 1);
|
||||
if (context.protocol > 23)
|
||||
{
|
||||
bitbuf.WriteVarInt32(data->dataLengthInBits);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, NET_MAX_PAYLOAD_BITS_OLD + 3);
|
||||
}
|
||||
bitbuf.WriteOneBit(data->isUserDataFixedSize);
|
||||
if (data->isUserDataFixedSize)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->userDataSize, 12);
|
||||
bitbuf.WriteUBitLong(data->userDataSizeBits, 4);
|
||||
}
|
||||
if (context.protocol > 14)
|
||||
{
|
||||
bitbuf.WriteOneBit(data->compressedData);
|
||||
}
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_CreateStringTable_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_CreateStringTable* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->isFileNames = reader.ReadBool("isFilenames");
|
||||
reader.ReadString("tableName", data->tableName, sizeof(data->tableName));
|
||||
data->maxEntries = reader.ReadUInt32("maxEntries");
|
||||
data->numEntries = reader.ReadUInt32("numEntries");
|
||||
data->dataLengthInBits = reader.ReadInt32("dataLengthInBits");
|
||||
data->isUserDataFixedSize = reader.ReadBool("isUserDataFixedSize");
|
||||
data->userDataSize = reader.ReadUInt32("userDataSize");
|
||||
data->userDataSizeBits = reader.ReadUInt32("userDataSizeBits");
|
||||
if (context.protocol > 14)
|
||||
{
|
||||
data->compressedData = reader.ReadBool("compressedData");
|
||||
}
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_CreateStringTable_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_CreateStringTable* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteBool("isFilenames", data->isFileNames);
|
||||
jsonbuf.WriteString("tableName", data->tableName);
|
||||
jsonbuf.WriteUInt32("maxEntries", data->maxEntries);
|
||||
jsonbuf.WriteUInt32("numEntries", data->numEntries);
|
||||
jsonbuf.WriteInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBool("isUserDataFixedSize", data->isUserDataFixedSize);
|
||||
jsonbuf.WriteUInt32("userDataSize", data->userDataSize);
|
||||
jsonbuf.WriteUInt32("userDataSizeBits", data->userDataSizeBits);
|
||||
if (context.protocol > 14)
|
||||
{
|
||||
jsonbuf.WriteBool("compressedData", data->compressedData);
|
||||
}
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_CreateStringTable_ToString_Internal(std::ostringstream& out, NetMsg::SVC_CreateStringTable* data)
|
||||
{
|
||||
out << "svc_CreateStringTable: table " << data->tableName
|
||||
<< ", entries " << data->numEntries
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits)
|
||||
<< " userdatasize " << data->userDataSize
|
||||
<< " userdatabits " << static_cast<uint32_t>(data->userDataSizeBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
|
||||
#include "svc_crosshairangle.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "demofile/demojson.h"
|
||||
#include <iomanip>
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -14,41 +11,4 @@ namespace NetHandlers
|
||||
data->angle.z = bitbuf.ReadBitAngle(16);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_CrosshairAngle_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data)
|
||||
{
|
||||
bitbuf.WriteBitAngle(data->angle.x, 16);
|
||||
bitbuf.WriteBitAngle(data->angle.y, 16);
|
||||
bitbuf.WriteBitAngle(data->angle.z, 16);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_CrosshairAngle_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
DemoJsonReader::ReadAngle(reader, "angle", data->angle);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_CrosshairAngle_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
DemoJsonWriter::WriteAngle(jsonbuf, "angle", data->angle);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_CrosshairAngle_ToString_Internal(std::ostringstream& out, NetMsg::SVC_CrosshairAngle* data)
|
||||
{
|
||||
const std::streamsize oldPrecision = out.precision();
|
||||
out << "svc_CrosshairAngle:"
|
||||
<< std::setprecision(1) << std::fixed
|
||||
<< " (" << data->angle.x
|
||||
<< " " << data->angle.y
|
||||
<< " " << data->angle.z << ")"
|
||||
<< std::setprecision(oldPrecision);
|
||||
out.unsetf(std::ios_base::floatfield);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_entitymessage.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netcontants.h"
|
||||
#include "netmath.h"
|
||||
|
||||
@ -16,44 +15,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_EntityMessage_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_EntityMessage* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->entIndex, MAX_EDICT_BITS);
|
||||
bitbuf.WriteUBitLong(data->classID, MAX_SERVER_CLASS_BITS);
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 11);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_EntityMessage_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_EntityMessage* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->entIndex = reader.ReadUInt32("entIndex");
|
||||
data->classID = reader.ReadUInt32("classId");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_EntityMessage_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_EntityMessage* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("entIndex", data->entIndex);
|
||||
jsonbuf.WriteUInt32("classId", data->classID);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_EntityMessage_ToString_Internal(std::ostringstream& out, NetMsg::SVC_EntityMessage* data)
|
||||
{
|
||||
out << "svc_EntityMessage: entity " << data->entIndex
|
||||
<< ", class " << data->classID
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
|
||||
#include "svc_fixangle.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "demofile/demojson.h"
|
||||
#include <iomanip>
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -15,44 +12,4 @@ namespace NetHandlers
|
||||
data->angle.z = bitbuf.ReadBitAngle(16);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_FixAngle_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_FixAngle* data)
|
||||
{
|
||||
bitbuf.WriteOneBit(data->relative);
|
||||
bitbuf.WriteBitAngle(data->angle.x, 16);
|
||||
bitbuf.WriteBitAngle(data->angle.y, 16);
|
||||
bitbuf.WriteBitAngle(data->angle.z, 16);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_FixAngle_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_FixAngle* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->relative = reader.ReadBool("relative");
|
||||
DemoJsonReader::ReadAngle(reader, "angle", data->angle);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_FixAngle_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_FixAngle* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteBool("relative", data->relative);
|
||||
DemoJsonWriter::WriteAngle(jsonbuf, "angle", data->angle);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_FixAngle_ToString_Internal(std::ostringstream& out, NetMsg::SVC_FixAngle* data)
|
||||
{
|
||||
const std::streamsize oldPrecision = out.precision();
|
||||
out << "svc_FixAngle: " << (data->relative ? "relative" : "absolute")
|
||||
<< std::setprecision(1) << std::fixed
|
||||
<< " " << data->angle.x
|
||||
<< " " << data->angle.y
|
||||
<< " " << data->angle.z
|
||||
<< std::setprecision(oldPrecision);
|
||||
out.unsetf(std::ios_base::floatfield);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
|
||||
#include "svc_gameevent.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
#include "netcontants.h"
|
||||
#include "netmath.h"
|
||||
|
||||
#ifdef WIP_GAMEEVENTS
|
||||
#include "svc_gameeventlist.h"
|
||||
#endif
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -20,49 +17,12 @@ namespace NetHandlers
|
||||
data->data.reset(new uint8_t[numBytes]);
|
||||
bitbuf.ReadBits(data->data.get(), numBits);
|
||||
|
||||
#ifdef WIP_GAMEEVENTS
|
||||
{
|
||||
BitRead bitbuf2(data->data.get(), numBytes, numBits);
|
||||
const size_t id = bitbuf2.ReadUBitLong(9);
|
||||
//std::vector<char> stringMem;
|
||||
//GameEvents::ParseEventData(bitbuf2, context.gameEventList->eventDescriptors[id], stringMem);
|
||||
GameEvents::PrintEventData(bitbuf2, context.gameEventList->eventDescriptors[id]);
|
||||
printf("%i\n", id);
|
||||
}
|
||||
#endif // WIP_GAMEEVENTS
|
||||
BitRead bitbuf2(data->data.get(), numBytes, numBits);
|
||||
const size_t id = bitbuf2.ReadUBitLong(9);
|
||||
GameEvents::EventDataMap eventData = GameEvents::ParseEventData(bitbuf2, context.gameEventList->eventDescriptors[id]);
|
||||
|
||||
context.OnGameEvent(context.gameEventList->eventDescriptors[id].name, eventData);
|
||||
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_GameEvent_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_GameEvent* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 11);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_GameEvent_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_GameEvent* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_GameEvent_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_GameEvent* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_GameEvent_ToString_Internal(std::ostringstream& out, NetMsg::SVC_GameEvent* data)
|
||||
{
|
||||
out << "svc_GameEvent: bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_gameeventlist.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
#include "netcontants.h"
|
||||
#include "netmath.h"
|
||||
@ -47,84 +46,11 @@ namespace NetHandlers
|
||||
event.values.shrink_to_fit();
|
||||
}
|
||||
|
||||
#ifdef WIP_GAMEEVENTS
|
||||
if (!context.gameEventList)
|
||||
{
|
||||
context.gameEventList = new NetMsg::SVC_GameEventList(*data);
|
||||
}
|
||||
#endif
|
||||
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_GameEventList_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_GameEventList* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->eventDescriptors.size(), MAX_EVENT_BITS);
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 20);
|
||||
assert(data->dataLengthInBits == CalculateNumDataBits(data->eventDescriptors));
|
||||
for (EventDescriptor& event : data->eventDescriptors)
|
||||
{
|
||||
bitbuf.WriteUBitLong(event.id, MAX_EVENT_BITS);
|
||||
bitbuf.WriteString(event.name);
|
||||
for (EventValue& value : event.values)
|
||||
{
|
||||
bitbuf.WriteUBitLong(value.type, 3);
|
||||
bitbuf.WriteString(value.name);
|
||||
}
|
||||
bitbuf.WriteUBitLong(0, 3);
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_GameEventList_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_GameEventList* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
|
||||
base::JsonReaderArray eventDescriptors = reader.ReadArray("eventDescriptors");
|
||||
eventDescriptors.TransformTo(data->eventDescriptors, [](base::JsonReaderObject& obj, EventDescriptor& event)
|
||||
{
|
||||
event.id = obj.ReadUInt32("id");
|
||||
obj.ReadString("name", event.name, sizeof(event.name));
|
||||
base::JsonReaderArray values = obj.ReadArray("values");
|
||||
values.TransformTo(event.values, [](base::JsonReaderObject& obj, EventValue& value)
|
||||
{
|
||||
value.type = static_cast<GameEvents::EventValueType>(obj.ReadUInt32("type"));
|
||||
obj.ReadString("name", value.name, sizeof(value.name));
|
||||
});
|
||||
});
|
||||
data->dataLengthInBits = CalculateNumDataBits(data->eventDescriptors);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_GameEventList_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_GameEventList* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.StartArray("eventDescriptors");
|
||||
for (const EventDescriptor& event : data->eventDescriptors)
|
||||
{
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("id", event.id);
|
||||
jsonbuf.WriteString("name", event.name);
|
||||
jsonbuf.StartArray("values");
|
||||
for (const EventValue& value : event.values)
|
||||
{
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("type", value.type);
|
||||
jsonbuf.WriteString("name", value.name);
|
||||
jsonbuf.EndObject();
|
||||
}
|
||||
jsonbuf.EndArray();
|
||||
jsonbuf.EndObject();
|
||||
}
|
||||
jsonbuf.EndArray();
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_GameEventList_ToString_Internal(std::ostringstream& out, NetMsg::SVC_GameEventList* data)
|
||||
{
|
||||
out << "svc_GameEventList: number " << data->eventDescriptors.size()
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_getcvarvalue.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -11,36 +10,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadString(data->cvarName, sizeof(data->cvarName));
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_GetCvarValue_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_GetCvarValue* data)
|
||||
{
|
||||
bitbuf.WriteSBitLong(data->cookie, 32);
|
||||
bitbuf.WriteString(data->cvarName);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_GetCvarValue_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_GetCvarValue* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->cookie = reader.ReadInt32("cookie");
|
||||
reader.ReadString("cvarName", data->cvarName, sizeof(data->cvarName));
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_GetCvarValue_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_GetCvarValue* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteInt32("cookie", data->cookie);
|
||||
jsonbuf.WriteString("cvarName", data->cvarName);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_GetCvarValue_ToString_Internal(std::ostringstream& out, NetMsg::SVC_GetCvarValue* data)
|
||||
{
|
||||
out << "svc_GetCvarValue: cvar: " << data->cvarName
|
||||
<< ", cookie: " << data->cookie;
|
||||
}
|
||||
}
|
||||
|
@ -9,27 +9,4 @@ namespace NetHandlers
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_HLTV_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_HLTV* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_HLTV_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_HLTV* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_HLTV_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_HLTV* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SVC_HLTV_ToString_Internal(std::ostringstream& out, NetMsg::SVC_HLTV* data)
|
||||
{
|
||||
out << "svc_HLTV";
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,9 @@
|
||||
|
||||
#include "svc_menu.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
using DialogType = NetMsg::SVC_Menu::DialogType;
|
||||
|
||||
#define KEYVALUES_TOKEN_SIZE 1024
|
||||
|
||||
static const char* KeyValuesBin_GetName(uint8_t* data, size_t dataLength)
|
||||
{
|
||||
if (dataLength <= 2)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<const char*>(data + 1);
|
||||
}
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
bool SVC_Menu_BitRead_Internal(BitRead& bitbuf, SourceGameContext& context, NetMsg::SVC_Menu* data)
|
||||
@ -26,44 +14,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBytes(data->menuBinaryKeyValues.get(), data->dataLengthInBytes);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Menu_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_Menu* data)
|
||||
{
|
||||
bitbuf.WriteShort(static_cast<int16_t>(data->type));
|
||||
bitbuf.WriteWord(data->dataLengthInBytes);
|
||||
bitbuf.WriteBytes(data->menuBinaryKeyValues.get(), data->dataLengthInBytes);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Menu_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_Menu* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->type = static_cast<DialogType>(reader.ReadInt32("dialogType"));
|
||||
data->dataLengthInBytes = reader.ReadUInt32("dataLengthInBytes");
|
||||
data->menuBinaryKeyValues.reset(new uint8_t[data->dataLengthInBytes]);
|
||||
reader.ReadBytes("data", data->menuBinaryKeyValues.get(), data->dataLengthInBytes);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_Menu_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Menu* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteInt32("dialogType", static_cast<int16_t>(data->type));
|
||||
jsonbuf.WriteUInt32("dataLengthInBytes", data->dataLengthInBytes);
|
||||
jsonbuf.WriteBytes("data", data->menuBinaryKeyValues.get(), data->dataLengthInBytes);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_Menu_ToString_Internal(std::ostringstream& out, NetMsg::SVC_Menu* data)
|
||||
{
|
||||
// binary keyvalues in form [type][name][value]
|
||||
// [char][cstr][type]
|
||||
const char* name = KeyValuesBin_GetName(data->menuBinaryKeyValues.get(), data->dataLengthInBytes);
|
||||
out << "svc_Menu: " << static_cast<int16_t>(data->type)
|
||||
<< " \"" << (name ? name : "No KeyValues")
|
||||
<< "\" (len:" << data->dataLengthInBytes << ")";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_packetentities.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netcontants.h"
|
||||
#include "netmath.h"
|
||||
|
||||
@ -25,67 +24,35 @@ namespace NetHandlers
|
||||
data->updateBaseline = bitbuf.ReadOneBit() != 0;
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_PacketEntities_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_PacketEntities* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->maxEntries, MAX_EDICT_BITS);
|
||||
if (data->isDelta)
|
||||
/*
|
||||
int last_index = -1;
|
||||
for (int i = 0; i < data->numUpdatedEntries; i++)
|
||||
{
|
||||
bitbuf.WriteOneBit(1);
|
||||
bitbuf.WriteLong(data->deltaFromTick);
|
||||
last_index += 1 + bitbuf.ReadUBitVar();
|
||||
|
||||
int pvs = bitbuf.ReadUBitLong(2);
|
||||
printf("%d - %d\n", last_index, pvs);
|
||||
switch(pvs)
|
||||
{
|
||||
case 0: // delta
|
||||
{
|
||||
|
||||
} break;
|
||||
case 2: // enter PVS
|
||||
{
|
||||
int iClass = bitbuf.ReadUBitLong(MAX_SERVER_CLASS_BITS);
|
||||
int serial = bitbuf.ReadUBitLong(NUM_NETWORKED_EHANDLE_SERIAL_NUMBER_BITS);
|
||||
printf("\t%d - %d\n", iClass, serial);
|
||||
} break;
|
||||
case 1: // leave PVS
|
||||
case 3: // delete
|
||||
{
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteOneBit(0);
|
||||
}
|
||||
bitbuf.WriteUBitLong(data->baselineIndex, 1);
|
||||
bitbuf.WriteUBitLong(data->numUpdatedEntries, MAX_EDICT_BITS);
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, DELTASIZE_BITS);
|
||||
bitbuf.WriteOneBit(data->updateBaseline);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
*/
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_PacketEntities_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_PacketEntities* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->maxEntries = reader.ReadInt32("maxEntries");
|
||||
data->isDelta = reader.ReadBool("isDelta");
|
||||
data->deltaFromTick = reader.ReadInt32("deltaFromTick");
|
||||
data->baselineIndex = reader.ReadUInt32("baselineIndex");
|
||||
data->numUpdatedEntries = reader.ReadUInt32("numUpdatedEntries");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->updateBaseline = reader.ReadBool("updateBaseline");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_PacketEntities_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_PacketEntities* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteInt32("maxEntries", data->maxEntries);
|
||||
jsonbuf.WriteBool("isDelta", data->isDelta);
|
||||
jsonbuf.WriteInt32("deltaFromTick", data->deltaFromTick);
|
||||
jsonbuf.WriteUInt32("baselineIndex", data->baselineIndex);
|
||||
jsonbuf.WriteUInt32("numUpdatedEntries", data->numUpdatedEntries);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBool("updateBaseline", data->updateBaseline);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_PacketEntities_ToString_Internal(std::ostringstream& out, NetMsg::SVC_PacketEntities* data)
|
||||
{
|
||||
out << "svc_PacketEntities: delta " << data->deltaFromTick
|
||||
<< ", max " << data->maxEntries
|
||||
<< ", changed " << data->numUpdatedEntries
|
||||
<< "," << (data->updateBaseline ? " BL update," : "")
|
||||
<< " bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_prefetch.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
#include "netcontants.h"
|
||||
|
||||
@ -20,42 +19,4 @@ namespace NetHandlers
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Prefetch_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_Prefetch* data)
|
||||
{
|
||||
if (context.protocol > 23)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->soundIndex, MAX_SOUND_INDEX_BITS);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->soundIndex, MAX_SOUND_INDEX_BITS_OLD);
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Prefetch_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_Prefetch* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->type = reader.ReadUInt32("type");
|
||||
data->soundIndex = reader.ReadUInt32("soundIndex");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_Prefetch_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Prefetch* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();;
|
||||
jsonbuf.WriteUInt32("type", data->type);
|
||||
jsonbuf.WriteUInt32("soundIndex", data->soundIndex);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_Prefetch_ToString_Internal(std::ostringstream& out, NetMsg::SVC_Prefetch* data)
|
||||
{
|
||||
out << "svc_Prefetch: type " << data->type
|
||||
<< " index " << data->soundIndex;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_print.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -10,32 +9,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadString(data->text, sizeof(data->text));
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Print_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_Print* data)
|
||||
{
|
||||
bitbuf.WriteString(data->text);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Print_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_Print* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
reader.ReadString("text", data->text, sizeof(data->text));
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_Print_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Print* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteString("text", data->text);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_Print_ToString_Internal(std::ostringstream& out, NetMsg::SVC_Print* data)
|
||||
{
|
||||
out << "svc_Print: \"" << data->text << '"';
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_sendtable.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netmath.h"
|
||||
|
||||
namespace NetHandlers
|
||||
@ -14,40 +13,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SendTable_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_SendTable* data)
|
||||
{
|
||||
bitbuf.WriteOneBit(data->needsDecoder);
|
||||
bitbuf.WriteShort(data->dataLengthInBits);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SendTable_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_SendTable* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->needsDecoder = reader.ReadBool("needsDecoder");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_SendTable_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SendTable* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteBool("needsDecoder", data->needsDecoder);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_SendTable_ToString_Internal(std::ostringstream& out, NetMsg::SVC_SendTable* data)
|
||||
{
|
||||
out << "svc_SendTable: needs Decoder " << (data->needsDecoder ? "yes" : "no")
|
||||
<< ",bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_serverinfo.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
|
||||
namespace NetHandlers
|
||||
@ -20,7 +19,7 @@ namespace NetHandlers
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.ReadBytes(data->unk1, sizeof(data->unk1));
|
||||
bitbuf.ReadBytes(data->mapMD5, sizeof(data->mapMD5));
|
||||
}
|
||||
data->playerSlot = bitbuf.ReadByte();
|
||||
data->maxClients = bitbuf.ReadByte();
|
||||
@ -32,113 +31,8 @@ namespace NetHandlers
|
||||
bitbuf.ReadString(data->hostName, sizeof(data->hostName));
|
||||
if (context.protocol > 15)
|
||||
{
|
||||
data->unk2 = bitbuf.ReadOneBit() != 0;
|
||||
data->isReplay = bitbuf.ReadOneBit() != 0;
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_ServerInfo_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_ServerInfo* data)
|
||||
{
|
||||
bitbuf.WriteShort(data->protocol);
|
||||
bitbuf.WriteLong(data->serverCount);
|
||||
bitbuf.WriteOneBit(data->isHLTV);
|
||||
bitbuf.WriteOneBit(data->isDedicated);
|
||||
bitbuf.WriteLong(data->clientCRC);
|
||||
bitbuf.WriteWord(data->maxClasses);
|
||||
if (context.protocol <= 17)
|
||||
{
|
||||
bitbuf.WriteLong(data->mapCRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteBytes(data->unk1, sizeof(data->unk1));
|
||||
}
|
||||
bitbuf.WriteByte(data->playerSlot);
|
||||
bitbuf.WriteByte(data->maxClients);
|
||||
bitbuf.WriteFloat(data->tickInterval);
|
||||
bitbuf.WriteChar(data->os);
|
||||
bitbuf.WriteString(data->gameDir);
|
||||
bitbuf.WriteString(data->mapName);
|
||||
bitbuf.WriteString(data->skyName);
|
||||
bitbuf.WriteString(data->hostName);
|
||||
if (context.protocol > 15)
|
||||
{
|
||||
bitbuf.WriteOneBit(data->unk2);
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_ServerInfo_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_ServerInfo* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->protocol = reader.ReadInt32("protocol");
|
||||
data->serverCount = reader.ReadUInt32("serverCount");
|
||||
data->isHLTV = reader.ReadBool("isHltv");
|
||||
data->isDedicated = reader.ReadBool("isDedicated");
|
||||
data->clientCRC = reader.ReadUInt32("clientCrc");
|
||||
data->maxClasses = reader.ReadUInt32("maxClasses");
|
||||
if (context.protocol <= 17)
|
||||
{
|
||||
data->mapCRC = reader.ReadUInt32("mapCRC");
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.ReadBytes("unk1", data->unk1, sizeof(data->unk1));
|
||||
}
|
||||
data->playerSlot = reader.ReadUInt32("playerSlot");
|
||||
data->maxClients = reader.ReadUInt32("maxClients");
|
||||
data->tickInterval = reader.ReadFloat("tickInterval");
|
||||
data->os = reader.ReadChar("os");
|
||||
reader.ReadString("gameDir", data->gameDir, sizeof(data->gameDir));
|
||||
reader.ReadString("mapName", data->mapName, sizeof(data->mapName));
|
||||
reader.ReadString("skyName", data->skyName, sizeof(data->skyName));
|
||||
reader.ReadString("hostName", data->hostName, sizeof(data->hostName));
|
||||
if (context.protocol > 15)
|
||||
{
|
||||
data->unk2 = reader.ReadBool("unk2");
|
||||
}
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_ServerInfo_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_ServerInfo* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteInt32("protocol", data->protocol);
|
||||
jsonbuf.WriteUInt32("serverCount", data->serverCount);
|
||||
jsonbuf.WriteBool("isHltv", data->isHLTV);
|
||||
jsonbuf.WriteBool("isDedicated", data->isDedicated);
|
||||
jsonbuf.WriteUInt32("clientCrc", data->clientCRC);
|
||||
jsonbuf.WriteUInt32("maxClasses", data->maxClasses);
|
||||
if (context.protocol <= 17)
|
||||
{
|
||||
jsonbuf.WriteUInt32("mapCRC", data->mapCRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonbuf.WriteBytes("unk1", data->unk1, sizeof(data->unk1));
|
||||
}
|
||||
jsonbuf.WriteUInt32("playerSlot", data->playerSlot);
|
||||
jsonbuf.WriteUInt32("maxClients", data->maxClients);
|
||||
jsonbuf.WriteFloat("tickInterval", data->tickInterval);
|
||||
jsonbuf.WriteChar("os", data->os);
|
||||
jsonbuf.WriteString("gameDir", data->gameDir);
|
||||
jsonbuf.WriteString("mapName", data->mapName);
|
||||
jsonbuf.WriteString("skyName", data->skyName);
|
||||
jsonbuf.WriteString("hostName", data->hostName);
|
||||
if (context.protocol > 15)
|
||||
{
|
||||
jsonbuf.WriteBool("unk2", data->unk2);
|
||||
}
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_ServerInfo_ToString_Internal(std::ostringstream& out, NetMsg::SVC_ServerInfo* data)
|
||||
{
|
||||
out << "svc_ServerInfo: game \"" << data->gameDir
|
||||
<< "\", map \"" << data->mapName
|
||||
<< "\", max " << static_cast<uint32_t>(data->maxClients);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace NetMsg
|
||||
uint32_t clientCRC; // client.dll CRC server is using
|
||||
uint16_t maxClasses; // max number of server classes
|
||||
uint32_t mapCRC; // server map CRC
|
||||
uint8_t unk1[16];
|
||||
uint8_t mapMD5[16];
|
||||
uint8_t playerSlot; // our client slot number
|
||||
uint8_t maxClients; // max number of clients on server
|
||||
float tickInterval; // server tick interval
|
||||
@ -23,7 +23,7 @@ namespace NetMsg
|
||||
char mapName[MAX_OSPATH]; // name of current map
|
||||
char skyName[MAX_OSPATH]; // name of current skybox
|
||||
char hostName[MAX_OSPATH]; // host name
|
||||
bool unk2;
|
||||
bool isReplay;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_setpause.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -10,32 +9,4 @@ namespace NetHandlers
|
||||
data->isPaused = bitbuf.ReadOneBit() != 0;
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SetPause_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_SetPause* data)
|
||||
{
|
||||
bitbuf.WriteOneBit(data->isPaused);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SetPause_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_SetPause* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->isPaused = reader.ReadBool("isPaused");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_SetPause_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SetPause* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteBool("isPaused", data->isPaused);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_SetPause_ToString_Internal(std::ostringstream& out, NetMsg::SVC_SetPause* data)
|
||||
{
|
||||
out << "svc_SetPause: " << (data->isPaused ? "paused" : "unpaused");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_setpausetimed.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -11,35 +10,4 @@ namespace NetHandlers
|
||||
data->time = bitbuf.ReadFloat();
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SetPauseTimed_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_SetPauseTimed* data)
|
||||
{
|
||||
bitbuf.WriteOneBit(data->isPaused);
|
||||
bitbuf.WriteFloat(data->time);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SetPauseTimed_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_SetPauseTimed* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->isPaused = reader.ReadBool("isPaused");
|
||||
data->time = reader.ReadFloat("time");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_SetPauseTimed_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SetPauseTimed* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteBool("isPaused", data->isPaused);
|
||||
jsonbuf.WriteFloat("time", data->time);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_SetPauseTimed_ToString_Internal(std::ostringstream& out, NetMsg::SVC_SetPauseTimed* data)
|
||||
{
|
||||
out << "svc_SetPauseTimed: " << (data->isPaused ? "paused" : "unpaused");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_setview.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netcontants.h"
|
||||
|
||||
namespace NetHandlers
|
||||
@ -11,32 +10,4 @@ namespace NetHandlers
|
||||
data->entIndex = bitbuf.ReadUBitLong(MAX_EDICT_BITS);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SetView_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_SetView* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->entIndex, MAX_EDICT_BITS);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_SetView_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_SetView* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->entIndex = reader.ReadUInt32("entIndex");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_SetView_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SetView* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("entIndex", data->entIndex);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_SetView_ToString_Internal(std::ostringstream& out, NetMsg::SVC_SetView* data)
|
||||
{
|
||||
out << "svc_SetView: view entity " << data->entIndex;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_sounds.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netmath.h"
|
||||
|
||||
namespace NetHandlers
|
||||
@ -23,52 +22,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Sounds_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_Sounds* data)
|
||||
{
|
||||
if (data->reliableSound)
|
||||
{
|
||||
bitbuf.WriteOneBit(1);
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteOneBit(0);
|
||||
bitbuf.WriteUBitLong(data->numSounds, 8);
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 16);
|
||||
}
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_Sounds_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_Sounds* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->reliableSound = reader.ReadBool("reliableSound");
|
||||
data->numSounds = reader.ReadUInt32("numSounds");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_Sounds_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Sounds* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteBool("reliableSound", data->reliableSound);
|
||||
jsonbuf.WriteUInt32("numSounds", data->numSounds);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_Sounds_ToString_Internal(std::ostringstream& out, NetMsg::SVC_Sounds* data)
|
||||
{
|
||||
out << "svc_Sounds: number " << static_cast<uint32_t>(data->numSounds)
|
||||
<< (data->reliableSound ? ", reliable" : "")
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_tempentities.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
#include "netcontants.h"
|
||||
#include "netmath.h"
|
||||
@ -23,47 +22,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_TempEntities_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_TempEntities* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->numEntries, EVENT_INDEX_BITS);
|
||||
if (context.protocol > 23)
|
||||
{
|
||||
bitbuf.WriteVarInt32(data->dataLengthInBits);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, NET_MAX_PAYLOAD_BITS_OLD);
|
||||
}
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_TempEntities_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_TempEntities* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->numEntries = reader.ReadUInt32("numEntries");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_TempEntities_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_TempEntities* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("numEntries", data->numEntries);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_TempEntities_ToString_Internal(std::ostringstream& out, NetMsg::SVC_TempEntities* data)
|
||||
{
|
||||
out << "svc_TempEntities: number " << data->numEntries
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -9,27 +9,4 @@ namespace NetHandlers
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_TerrainMod_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_TerrainMod* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_TerrainMod_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_TerrainMod* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVC_TerrainMod_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_TerrainMod* data)
|
||||
{
|
||||
assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SVC_TerrainMod_ToString_Internal(std::ostringstream& out, NetMsg::SVC_TerrainMod* data)
|
||||
{
|
||||
out << "svc_TerrainMod";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
#include "svc_updatestringtable.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "game/sourcecontext.h"
|
||||
#include "game/stringtables.h"
|
||||
#include "netmath.h"
|
||||
#include "netcontants.h"
|
||||
|
||||
@ -14,54 +15,11 @@ namespace NetHandlers
|
||||
data->dataLengthInBits = bitbuf.ReadUBitLong(20);
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
|
||||
StringTable *table = &context.stringTables->tables[data->tableID];
|
||||
bf_read bitbuf2(data->data.get(), math::BitsToBytes(data->dataLengthInBits), data->dataLengthInBits);
|
||||
table->ParseUpdate(bitbuf2, data->numChangedEntries, context);
|
||||
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_UpdateStringTable_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_UpdateStringTable* data)
|
||||
{
|
||||
bitbuf.WriteUBitLong(data->tableID, math::log2(MAX_TABLES));
|
||||
if (data->numChangedEntries != 1)
|
||||
{
|
||||
bitbuf.WriteOneBit(1);
|
||||
bitbuf.WriteWord(data->numChangedEntries);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitbuf.WriteOneBit(0);
|
||||
}
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 20);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_UpdateStringTable_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_UpdateStringTable* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->tableID = reader.ReadUInt32("tableId");
|
||||
data->numChangedEntries = reader.ReadUInt32("numChangedEntries");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_UpdateStringTable_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_UpdateStringTable* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("tableId", data->tableID);
|
||||
jsonbuf.WriteUInt32("numChangedEntries", data->numChangedEntries);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_UpdateStringTable_ToString_Internal(std::ostringstream& out, NetMsg::SVC_UpdateStringTable* data)
|
||||
{
|
||||
out << "svc_UpdateStringTable: table " << data->tableID
|
||||
<< ", changed " << data->numChangedEntries
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_usermessage.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netmath.h"
|
||||
#include "netcontants.h"
|
||||
#include <cassert>
|
||||
@ -17,40 +16,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_UserMessage_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_UserMessage* data)
|
||||
{
|
||||
bitbuf.WriteByte(data->msgType);
|
||||
bitbuf.WriteUBitLong(data->dataLengthInBits, 11);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_UserMessage_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_UserMessage* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->msgType = reader.ReadUInt32("msgType");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_UserMessage_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_UserMessage* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("msgType", data->msgType);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_UserMessage_ToString_Internal(std::ostringstream& out, NetMsg::SVC_UserMessage* data)
|
||||
{
|
||||
out << "svc_UserMessage: type " << static_cast<uint32_t>(data->msgType)
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "svc_voicedata.h"
|
||||
#include "svc_voiceinit.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
#include "netmath.h"
|
||||
|
||||
namespace NetHandlers
|
||||
@ -15,43 +15,4 @@ namespace NetHandlers
|
||||
bitbuf.ReadBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_VoiceData_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_VoiceData* data)
|
||||
{
|
||||
bitbuf.WriteByte(data->fromClientIndex);
|
||||
bitbuf.WriteByte(data->proximity);
|
||||
bitbuf.WriteWord(data->dataLengthInBits);
|
||||
bitbuf.WriteBits(data->data.get(), data->dataLengthInBits);
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_VoiceData_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_VoiceData* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->fromClientIndex = reader.ReadUInt32("fromClientIndex");
|
||||
data->proximity = reader.ReadBool("proximity");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_VoiceData_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_VoiceData* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("fromClientIndex", data->fromClientIndex);
|
||||
jsonbuf.WriteBool("proximity", data->proximity);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_VoiceData_ToString_Internal(std::ostringstream& out, NetMsg::SVC_VoiceData* data)
|
||||
{
|
||||
out << "svc_VoiceData: client " << static_cast<uint32_t>(data->fromClientIndex)
|
||||
<< ", bytes " << math::BitsToBytes(data->dataLengthInBits);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "svc_voiceinit.h"
|
||||
#include "base/bitfile.h"
|
||||
#include "base/jsonfile.h"
|
||||
|
||||
namespace NetHandlers
|
||||
{
|
||||
@ -20,49 +19,4 @@ namespace NetHandlers
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_VoiceInit_BitWrite_Internal(BitWrite& bitbuf, const SourceGameContext& context, NetMsg::SVC_VoiceInit* data)
|
||||
{
|
||||
bitbuf.WriteString(data->voiceCodec);
|
||||
bitbuf.WriteByte(data->quality);
|
||||
if(data->quality == NetMsg::SVC_VoiceInit::QUALITY_HAS_SAMPLE_RATE)
|
||||
{
|
||||
bitbuf.WriteShort(data->sampleRate);
|
||||
}
|
||||
return !bitbuf.IsOverflowed();
|
||||
}
|
||||
|
||||
bool SVC_VoiceInit_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_VoiceInit* data)
|
||||
{
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
reader.ReadString("voiceCodec", data->voiceCodec, sizeof(data->voiceCodec));
|
||||
data->quality = reader.ReadUInt32("quality");
|
||||
data->sampleRate = reader.ReadInt32("sampleRate");
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_VoiceInit_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_VoiceInit* data)
|
||||
{
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteString("voiceCodec", data->voiceCodec);
|
||||
jsonbuf.WriteUInt32("quality", data->quality);
|
||||
jsonbuf.WriteInt32("sampleRate", data->sampleRate);
|
||||
jsonbuf.EndObject();
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_VoiceInit_ToString_Internal(std::ostringstream& out, NetMsg::SVC_VoiceInit* data)
|
||||
{
|
||||
out << "svc_VoiceInit: codec \"" << data->voiceCodec;
|
||||
if(data->quality == NetMsg::SVC_VoiceInit::QUALITY_HAS_SAMPLE_RATE)
|
||||
{
|
||||
out << "\", sample rate " << static_cast<uint32_t>(data->sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "\", qualitty " << static_cast<uint32_t>(data->quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
demboyz/netmessages/usermessages.h
Normal file
56
demboyz/netmessages/usermessages.h
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace UserMsg
|
||||
{
|
||||
enum
|
||||
{
|
||||
Geiger = 0,
|
||||
Train = 1,
|
||||
HudText = 2,
|
||||
SayText = 3,
|
||||
SayText2 = 4,
|
||||
TextMsg = 5,
|
||||
HudMsg = 6,
|
||||
ResetHUD = 7,
|
||||
GameTitle = 8,
|
||||
ItemPickup = 9,
|
||||
ShowMenu = 10,
|
||||
Shake = 11,
|
||||
Fade = 12,
|
||||
VGUIMenu = 13,
|
||||
Rumble = 14,
|
||||
CloseCaption = 15,
|
||||
SendAudio = 16,
|
||||
RawAudio = 17,
|
||||
VoiceMask = 18,
|
||||
RequestState = 19,
|
||||
BarTime = 20,
|
||||
Damage = 21,
|
||||
RadioText = 22,
|
||||
HintText = 23,
|
||||
KeyHintText = 24,
|
||||
ReloadEffect = 25,
|
||||
PlayerAnimEvent = 26,
|
||||
AmmoDenied = 27,
|
||||
UpdateRadar = 28,
|
||||
KillCam = 29,
|
||||
MarkAchievement = 30,
|
||||
CallVoteFailed = 31,
|
||||
VoteStart = 32,
|
||||
VotePass = 33,
|
||||
VoteFailed = 34,
|
||||
VoteSetup = 35,
|
||||
SPHapWeapEvent = 36,
|
||||
HapDmg = 37,
|
||||
HapPunch = 38,
|
||||
HapSetDrag = 39,
|
||||
HapSetConst = 40,
|
||||
HapMeleeContact = 41,
|
||||
PlayerStatsUpdate_DEPRECATED = 42,
|
||||
AchievementEvent = 43,
|
||||
MatchEndConditions = 44,
|
||||
MatchStatsUpdate = 45,
|
||||
PlayerStatsUpdate = 46
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user