Added netmsg struct allocation
This commit is contained in:
parent
e13608fcd6
commit
3f9bd6e3f2
@ -13,7 +13,79 @@
|
|||||||
typedef bool (*NetMsgReadFn)(bf_read& bitbuf, SourceGameContext& context, void* data);
|
typedef bool (*NetMsgReadFn)(bf_read& bitbuf, SourceGameContext& context, void* data);
|
||||||
|
|
||||||
static const NetMsgReadFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(BitRead);
|
static const NetMsgReadFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(BitRead);
|
||||||
//static const void* netDataStructs[] = DECLARE_NET_DATA_ARRAY;
|
static void* netDataStructs[32];
|
||||||
|
|
||||||
|
static void CreateNetMsgStructs()
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DestroyNetMsgStructs()
|
||||||
|
{
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
void ParsePacket(uint8_t* packet, size_t length, SourceGameContext& context, IDemoWriter* writer)
|
void ParsePacket(uint8_t* packet, size_t length, SourceGameContext& context, IDemoWriter* writer)
|
||||||
{
|
{
|
||||||
@ -23,13 +95,14 @@ void ParsePacket(uint8_t* packet, size_t length, SourceGameContext& context, IDe
|
|||||||
while (bitbuf.GetNumBitsLeft() >= NETMSG_TYPE_BITS)
|
while (bitbuf.GetNumBitsLeft() >= NETMSG_TYPE_BITS)
|
||||||
{
|
{
|
||||||
netPacket.type = bitbuf.ReadUBitLong(NETMSG_TYPE_BITS);
|
netPacket.type = bitbuf.ReadUBitLong(NETMSG_TYPE_BITS);
|
||||||
//netPacket.data = netDataStructs[netPacket.type];
|
netPacket.data = netDataStructs[netPacket.type];
|
||||||
netHandlers[netPacket.type](bitbuf, context, nullptr);
|
netHandlers[netPacket.type](bitbuf, context, netPacket.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoReader::ProcessDem(void* inputFp, IDemoWriter* writer)
|
void DemoReader::ProcessDem(void* inputFp, IDemoWriter* writer)
|
||||||
{
|
{
|
||||||
|
CreateNetMsgStructs();
|
||||||
SourceGameContext context;
|
SourceGameContext context;
|
||||||
DemoFileReader reader(reinterpret_cast<FILE*>(inputFp));
|
DemoFileReader reader(reinterpret_cast<FILE*>(inputFp));
|
||||||
{
|
{
|
||||||
@ -91,4 +164,5 @@ void DemoReader::ProcessDem(void* inputFp, IDemoWriter* writer)
|
|||||||
writer->EndCommandPacket();
|
writer->EndCommandPacket();
|
||||||
} while (packet.cmd != dem_stop);
|
} while (packet.cmd != dem_stop);
|
||||||
writer->EndWriting();
|
writer->EndWriting();
|
||||||
|
DestroyNetMsgStructs();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user