From 05d1518653ab6f75da19f032376e77f61121c9a8 Mon Sep 17 00:00:00 2001 From: Jordan Cristiano Date: Wed, 27 May 2015 22:57:30 -0400 Subject: [PATCH] Made DemoFileReader::ReadUserCmd return length of usercmd instead of sequence number --- demboyz/demofile.cpp | 9 ++------- demboyz/demofile.h | 2 +- demboyz/demreader.cpp | 5 ++++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/demboyz/demofile.cpp b/demboyz/demofile.cpp index da0d1c3..c052d22 100644 --- a/demboyz/demofile.cpp +++ b/demboyz/demofile.cpp @@ -60,15 +60,10 @@ void DemoFileReader::ReadCmdHeader(unsigned char& cmd, int32_t& tick) } } -int32_t DemoFileReader::ReadUserCmd(uint8_t* buffer, int32_t length) +int32_t DemoFileReader::ReadUserCmd(int32_t& sequenceNum, uint8_t* buffer, int32_t length) { - int32_t sequenceNum; fread(&sequenceNum, sizeof(int32_t), 1, m_demoFp); - if (ReadRawData(buffer, length) < 0) - { - return -1; - } - return sequenceNum; + return ReadRawData(buffer, length); } // DemoFileWriter diff --git a/demboyz/demofile.h b/demboyz/demofile.h index 7ed6bf9..1e4bd21 100644 --- a/demboyz/demofile.h +++ b/demboyz/demofile.h @@ -17,7 +17,7 @@ public: void ReadSequenceInfo(int32_t& seqNum1, int32_t& seqNum2); void ReadCmdInfo(democmdinfo_t& info); void ReadCmdHeader(unsigned char& cmd, int32_t& tick); - int32_t ReadUserCmd(uint8_t* buffer, int32_t length); + int32_t ReadUserCmd(int32_t& sequenceNum, uint8_t* buffer, int32_t length); private: FILE* m_demoFp; diff --git a/demboyz/demreader.cpp b/demboyz/demreader.cpp index ef28342..8228089 100644 --- a/demboyz/demreader.cpp +++ b/demboyz/demreader.cpp @@ -136,7 +136,10 @@ void DemoReader::ProcessDem(void* inputFp, IDemoWriter* writer) reader.ReadRawData(nullptr, 1024); break; case dem_usercmd: - reader.ReadUserCmd(buffer.data(), 256); + { + int32_t sequenceNum; + reader.ReadUserCmd(sequenceNum, buffer.get(), 256); + } break; case dem_datatables: // TODO: datatables