Signal to stop reading demo if invalid command is found

This commit is contained in:
Jordan Cristiano 2015-07-13 23:08:05 -04:00
parent 2bf16179ad
commit f5d8d9bbf1

View File

@ -77,13 +77,9 @@ void DemoFileReader::ReadCmdInfo(democmdinfo_t& info)
void DemoFileReader::ReadCmdHeader(unsigned char& cmd, int32_t& tick) void DemoFileReader::ReadCmdHeader(unsigned char& cmd, int32_t& tick)
{ {
FILE* fp = m_demoFp; FILE* fp = m_demoFp;
fread(&cmd, sizeof(unsigned char), 1, fp); fread(&cmd, 1, sizeof(unsigned char), fp);
fread(&tick, sizeof(int32_t), 1, fp); fread(&tick, 1, sizeof(int32_t), fp);
if (cmd >= 0) if (cmd > dem_lastcmd)
{
assert(cmd <= dem_lastcmd);
}
else
{ {
cmd = dem_stop; cmd = dem_stop;
} }