From b67f448d182cafb0e8a1dbe9080e432b56f722ee Mon Sep 17 00:00:00 2001 From: Jordan Cristiano Date: Thu, 18 Jun 2015 20:18:55 -0400 Subject: [PATCH] Changed DemHandlers file read/write types to typedefs --- demboyz/demmessages/dem_consolecmd.cpp | 4 ++-- demboyz/demmessages/dem_datatables.cpp | 4 ++-- demboyz/demmessages/dem_packet.cpp | 4 ++-- demboyz/demmessages/dem_stop.cpp | 4 ++-- demboyz/demmessages/dem_stringtables.cpp | 4 ++-- demboyz/demmessages/dem_synctick.cpp | 4 ++-- demboyz/demmessages/dem_unknown.cpp | 4 ++-- demboyz/demmessages/dem_usercmd.cpp | 4 ++-- demboyz/demmessages/demhandlers.cpp | 8 ++++---- demboyz/demmessages/demhandlers.h | 14 ++++++++------ 10 files changed, 28 insertions(+), 26 deletions(-) diff --git a/demboyz/demmessages/dem_consolecmd.cpp b/demboyz/demmessages/dem_consolecmd.cpp index 2ce8d25..c32e988 100644 --- a/demboyz/demmessages/dem_consolecmd.cpp +++ b/demboyz/demmessages/dem_consolecmd.cpp @@ -4,7 +4,7 @@ namespace DemHandlers { - bool Dem_ConsoleCmd_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_ConsoleCmd* data) + bool Dem_ConsoleCmd_FileRead_Internal(FileRead& demofile, DemMsg::Dem_ConsoleCmd* data) { char command[DemMsg::Dem_ConsoleCmd::COMMAND_MAX_LENGTH]; demofile.ReadRawData(reinterpret_cast(command), sizeof(command)); @@ -12,7 +12,7 @@ namespace DemHandlers return demofile.IsOk(); } - bool Dem_ConsoleCmd_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_ConsoleCmd* data) + bool Dem_ConsoleCmd_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_ConsoleCmd* data) { const uint8_t* command = reinterpret_cast(data->command.data()); demofile.WriteRawData(command, data->command.length() + 1); diff --git a/demboyz/demmessages/dem_datatables.cpp b/demboyz/demmessages/dem_datatables.cpp index 1d50125..693552d 100644 --- a/demboyz/demmessages/dem_datatables.cpp +++ b/demboyz/demmessages/dem_datatables.cpp @@ -4,13 +4,13 @@ namespace DemHandlers { - bool Dem_DataTables_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_DataTables* data) + bool Dem_DataTables_FileRead_Internal(FileRead& demofile, DemMsg::Dem_DataTables* data) { data->data = demofile.ReadRawData(DemMsg::Dem_DataTables::DATA_MAX_LENGTH); return demofile.IsOk(); } - bool Dem_DataTables_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_DataTables* data) + bool Dem_DataTables_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_DataTables* data) { demofile.WriteRawData(data->data.begin(), data->data.length()); return demofile.IsOk(); diff --git a/demboyz/demmessages/dem_packet.cpp b/demboyz/demmessages/dem_packet.cpp index 92f5c96..592be17 100644 --- a/demboyz/demmessages/dem_packet.cpp +++ b/demboyz/demmessages/dem_packet.cpp @@ -4,7 +4,7 @@ namespace DemHandlers { - bool Dem_Packet_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_Packet* data) + bool Dem_Packet_FileRead_Internal(FileRead& demofile, DemMsg::Dem_Packet* data) { demofile.ReadCmdInfo(data->cmdInfo); demofile.ReadSequenceInfo(data->sequenceNum1, data->sequenceNum2); @@ -12,7 +12,7 @@ namespace DemHandlers return demofile.IsOk(); } - bool Dem_Packet_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_Packet* data) + bool Dem_Packet_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_Packet* data) { demofile.WriteCmdInfo(data->cmdInfo); demofile.WriteSequenceInfo(data->sequenceNum1, data->sequenceNum2); diff --git a/demboyz/demmessages/dem_stop.cpp b/demboyz/demmessages/dem_stop.cpp index 3995df3..2fa47b9 100644 --- a/demboyz/demmessages/dem_stop.cpp +++ b/demboyz/demmessages/dem_stop.cpp @@ -3,12 +3,12 @@ namespace DemHandlers { - bool Dem_Stop_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_Stop* data) + bool Dem_Stop_FileRead_Internal(FileRead& demofile, DemMsg::Dem_Stop* data) { return true; } - bool Dem_Stop_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_Stop* data) + bool Dem_Stop_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_Stop* data) { return true; } diff --git a/demboyz/demmessages/dem_stringtables.cpp b/demboyz/demmessages/dem_stringtables.cpp index 5850963..831943c 100644 --- a/demboyz/demmessages/dem_stringtables.cpp +++ b/demboyz/demmessages/dem_stringtables.cpp @@ -93,7 +93,7 @@ static void StringTable_BitWrite(bf_write& bitbuf, DemMsg::Dem_StringTables::Str namespace DemHandlers { - bool Dem_StringTables_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_StringTables* data) + bool Dem_StringTables_FileRead_Internal(FileRead& demofile, DemMsg::Dem_StringTables* data) { using StringTable = DemMsg::Dem_StringTables::StringTable; @@ -108,7 +108,7 @@ namespace DemHandlers return !bitbuf.IsOverflowed(); } - bool Dem_StringTables_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_StringTables* data) + bool Dem_StringTables_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_StringTables* data) { using StringTable = DemMsg::Dem_StringTables::StringTable; diff --git a/demboyz/demmessages/dem_synctick.cpp b/demboyz/demmessages/dem_synctick.cpp index d7cce2b..326130f 100644 --- a/demboyz/demmessages/dem_synctick.cpp +++ b/demboyz/demmessages/dem_synctick.cpp @@ -3,12 +3,12 @@ namespace DemHandlers { - bool Dem_SyncTick_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_SyncTick* data) + bool Dem_SyncTick_FileRead_Internal(FileRead& demofile, DemMsg::Dem_SyncTick* data) { return true; } - bool Dem_SyncTick_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_SyncTick* data) + bool Dem_SyncTick_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_SyncTick* data) { return true; } diff --git a/demboyz/demmessages/dem_unknown.cpp b/demboyz/demmessages/dem_unknown.cpp index a896623..325b896 100644 --- a/demboyz/demmessages/dem_unknown.cpp +++ b/demboyz/demmessages/dem_unknown.cpp @@ -3,12 +3,12 @@ namespace DemHandlers { - bool Dem_Unknown_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_Unknown* data) + bool Dem_Unknown_FileRead_Internal(FileRead& demofile, DemMsg::Dem_Unknown* data) { return true; } - bool Dem_Unknown_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_Unknown* data) + bool Dem_Unknown_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_Unknown* data) { return true; } diff --git a/demboyz/demmessages/dem_usercmd.cpp b/demboyz/demmessages/dem_usercmd.cpp index ca4e499..d377fef 100644 --- a/demboyz/demmessages/dem_usercmd.cpp +++ b/demboyz/demmessages/dem_usercmd.cpp @@ -4,13 +4,13 @@ namespace DemHandlers { - bool Dem_UserCmd_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_UserCmd* data) + bool Dem_UserCmd_FileRead_Internal(FileRead& demofile, DemMsg::Dem_UserCmd* data) { data->commandData = demofile.ReadUserCmd(data->commandNum, DemMsg::Dem_UserCmd::COMMANDDATA_MAX_LENGTH); return demofile.IsOk(); } - bool Dem_UserCmd_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_UserCmd* data) + bool Dem_UserCmd_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_UserCmd* data) { demofile.WriteUserCmd(data->commandNum, data->commandData.begin(), data->commandData.length()); return demofile.IsOk(); diff --git a/demboyz/demmessages/demhandlers.cpp b/demboyz/demmessages/demhandlers.cpp index 2de8b23..c51f746 100644 --- a/demboyz/demmessages/demhandlers.cpp +++ b/demboyz/demmessages/demhandlers.cpp @@ -15,18 +15,18 @@ &DemHandlers::Dem_StringTables_##funcname \ } -typedef bool (*DemMsgFileReadFn)(DemoFileReader& demofile, void* data); -typedef bool (*DemMsgFileWriteFn)(DemoFileWriter& demofile, void* data); +typedef bool (*DemMsgFileReadFn)(FileRead& demofile, void* data); +typedef bool (*DemMsgFileWriteFn)(FileWrite& demofile, void* data); typedef bool (*DemMsgJsonReadFn)(JsonRead& jsonbuf, void* data); typedef bool (*DemMsgJsonWriteFn)(JsonWrite& jsonbuf, void* data); -bool DemHandlers::DemMsg_FileRead(uint32_t type, DemoFileReader& demofile, void* data) +bool DemHandlers::DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data) { static const DemMsgFileReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileRead); return demHandlers[type](demofile, data); } -bool DemHandlers::DemMsg_FileWrite(uint32_t type, DemoFileWriter& demofile, void* data) +bool DemHandlers::DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data) { static const DemMsgFileWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileWrite); return demHandlers[type](demofile, data); diff --git a/demboyz/demmessages/demhandlers.h b/demboyz/demmessages/demhandlers.h index a4759fa..13fc2bb 100644 --- a/demboyz/demmessages/demhandlers.h +++ b/demboyz/demmessages/demhandlers.h @@ -5,21 +5,23 @@ class DemoFileReader; class DemoFileWriter; +using FileRead = DemoFileReader; +using FileWrite = DemoFileWriter; class JsonRead; class JsonWrite; #define DECLARE_DEM_HANDLERS(msgname) \ namespace DemHandlers \ { \ - bool msgname##_FileRead_Internal(DemoFileReader& demofile, DemMsg::msgname* data); \ - bool msgname##_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::msgname* data); \ + bool msgname##_FileRead_Internal(FileRead& demofile, DemMsg::msgname* data); \ + bool msgname##_FileWrite_Internal(FileWrite& demofile, DemMsg::msgname* data); \ bool msgname##_JsonRead_Internal(JsonRead& jsonbuf, DemMsg::msgname* data); \ bool msgname##_JsonWrite_Internal(JsonWrite& jsonbuf, DemMsg::msgname* data); \ - inline bool msgname##_FileRead(DemoFileReader& demofile, void* data) \ + inline bool msgname##_FileRead(FileRead& demofile, void* data) \ { \ return msgname##_FileRead_Internal(demofile, reinterpret_cast(data)); \ } \ - inline bool msgname##_FileWrite(DemoFileWriter& demofile, void* data) \ + inline bool msgname##_FileWrite(FileWrite& demofile, void* data) \ { \ return msgname##_FileWrite_Internal(demofile, reinterpret_cast(data)); \ } \ @@ -35,8 +37,8 @@ class JsonWrite; namespace DemHandlers { - bool DemMsg_FileRead(uint32_t type, DemoFileReader& demofile, void* data); - bool DemMsg_FileWrite(uint32_t type, DemoFileWriter& demofile, void* data); + bool DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data); + bool DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data); bool DemMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, void* data); bool DemMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, void* data); }