Changed demdata struct array to use std array

This commit is contained in:
Jordan Cristiano 2015-10-15 01:06:51 -04:00
parent e3ccd21314
commit 3b11809be7
5 changed files with 18 additions and 16 deletions

View File

@ -2,7 +2,16 @@
#include "demhandlers.h"
#include "demmessages.h"
void DemHandlers::CreateDemMsgStructs(void* demDataStructs[9])
#include "dem_unknown.h"
#include "dem_packet.h"
#include "dem_synctick.h"
#include "dem_consolecmd.h"
#include "dem_usercmd.h"
#include "dem_datatables.h"
#include "dem_stop.h"
#include "dem_stringtables.h"
void DemHandlers::CreateDemMsgStructs(DemDataStructArray& demDataStructs)
{
demDataStructs[0] = new DemMsg::Dem_Unknown();
demDataStructs[1] = new DemMsg::Dem_Packet();
@ -15,7 +24,7 @@ void DemHandlers::CreateDemMsgStructs(void* demDataStructs[9])
demDataStructs[8] = new DemMsg::Dem_StringTables();
}
void DemHandlers::DestroyDemMsgStructs(void* demDataStructs[9])
void DemHandlers::DestroyDemMsgStructs(DemDataStructArray& demDataStructs)
{
delete reinterpret_cast<DemMsg::Dem_Unknown*>(demDataStructs[0]);
delete reinterpret_cast<DemMsg::Dem_Packet*>(demDataStructs[1]);

View File

@ -2,6 +2,8 @@
#pragma once
#include <cstdint>
#include <array>
#include "demmessages.h"
namespace base
{
@ -49,8 +51,9 @@ namespace DemHandlers
namespace DemHandlers
{
void CreateDemMsgStructs(void* demDataStructs[9]);
void DestroyDemMsgStructs(void* demDataStructs[9]);
using DemDataStructArray = std::array<void*, dem_lastcmd + 1>;
void CreateDemMsgStructs(DemDataStructArray& demDataStructs);
void DestroyDemMsgStructs(DemDataStructArray& demDataStructs);
bool DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data);
bool DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data);

View File

@ -1,14 +1,4 @@
#pragma once
#include <cstdint>
#include "demofile/demotypes.h"
#include "dem_unknown.h"
#include "dem_packet.h"
#include "dem_synctick.h"
#include "dem_consolecmd.h"
#include "dem_usercmd.h"
#include "dem_datatables.h"
#include "dem_stop.h"
#include "dem_stringtables.h"

View File

@ -43,7 +43,7 @@ PacketTrailingBits ParsePacket(uint8_t* packet, size_t length,
void DemoReader::ProcessDem(std::FILE* inputFp, IDemoWriter* writer)
{
NetHandlers::NetDataStructArray netDataStructs;
void* demDataStructs[9];
DemHandlers::DemDataStructArray demDataStructs;
NetHandlers::CreateNetMsgStructs(netDataStructs);
DemHandlers::CreateDemMsgStructs(demDataStructs);

View File

@ -41,7 +41,7 @@ PacketTrailingBits ParsePacket(base::JsonReaderFile& jsonReader,
void DemoReader::ProcessJson(std::FILE* inputFp, IDemoWriter* writer)
{
NetHandlers::NetDataStructArray netDataStructs;
void* demDataStructs[9];
DemHandlers::DemDataStructArray demDataStructs;
NetHandlers::CreateNetMsgStructs(netDataStructs);
DemHandlers::CreateDemMsgStructs(demDataStructs);