From 05957b65bd293adbe0e52268392b57c254cb3584 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2026 02:27:15 +0000 Subject: [PATCH] bugfix(crc): Prevent division by zero in CRC interval calculation --- Core/GameEngine/Include/GameNetwork/GameInfo.h | 2 +- Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp | 3 ++- .../Code/GameEngine/Source/GameLogic/System/GameLogic.cpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/GameEngine/Include/GameNetwork/GameInfo.h b/Core/GameEngine/Include/GameNetwork/GameInfo.h index 0b67a2f47fc..d2133d667f7 100644 --- a/Core/GameEngine/Include/GameNetwork/GameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/GameInfo.h @@ -214,7 +214,7 @@ class GameInfo virtual void closeOpenSlots(); ///< close all slots that are currently unoccupied. // CRC checking hack - void setCRCInterval( Int val ) { m_crcInterval = (val<100)?val:100; } + void setCRCInterval( Int val ) { m_crcInterval = (val<1)?1:(val<100)?val:100; } Int getCRCInterval() const { return m_crcInterval; } Bool haveWeSurrendered() { return m_surrendered; } diff --git a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 44d49f5b03f..984efc6dc30 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -3143,7 +3143,8 @@ void GameLogic::update() // would be getting the CRC anyway, so replays can get the CRCs from the exact instant in time as the original. Bool isMPGameOrReplay = (TheRecorder && TheRecorder->isMultiplayer() && getGameMode() != GAME_SHELL && getGameMode() != GAME_NONE); Bool isSoloGameOrReplay = (TheRecorder && !TheRecorder->isMultiplayer() && getGameMode() != GAME_SHELL && getGameMode() != GAME_NONE); - Bool generateForMP = (isMPGameOrReplay && (m_frame % TheGameInfo->getCRCInterval()) == 0); + Int crcInterval = TheGameInfo ? TheGameInfo->getCRCInterval() : 0; + Bool generateForMP = (isMPGameOrReplay && crcInterval > 0 && (m_frame % crcInterval) == 0); #ifdef DEBUG_CRC Bool generateForSolo = isSoloGameOrReplay && ((m_frame && (m_frame%100 == 0)) || (getFrame() >= TheCRCFirstFrameToLog && getFrame() < TheCRCLastFrameToLog && ((m_frame % REPLAY_CRC_INTERVAL) == 0))); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index c829be1ccd1..881fc6e6e03 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -3889,7 +3889,8 @@ void GameLogic::update() // would be getting the CRC anyway, so replays can get the CRCs from the exact instant in time as the original. Bool isMPGameOrReplay = (TheRecorder && TheRecorder->isMultiplayer() && getGameMode() != GAME_SHELL && getGameMode() != GAME_NONE); Bool isSoloGameOrReplay = (TheRecorder && !TheRecorder->isMultiplayer() && getGameMode() != GAME_SHELL && getGameMode() != GAME_NONE); - Bool generateForMP = (isMPGameOrReplay && (m_frame % TheGameInfo->getCRCInterval()) == 0); + Int crcInterval = TheGameInfo ? TheGameInfo->getCRCInterval() : 0; + Bool generateForMP = (isMPGameOrReplay && crcInterval > 0 && (m_frame % crcInterval) == 0); #ifdef DEBUG_CRC Bool generateForSolo = isSoloGameOrReplay && ((m_frame && (m_frame % 100 == 0)) || (getFrame() >= TheCRCFirstFrameToLog && getFrame() < TheCRCLastFrameToLog && ((m_frame % REPLAY_CRC_INTERVAL) == 0)));