From 87c269bfe9170357982ff23b085d070b0217215e Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 21 Apr 2025 15:05:20 +0200 Subject: [PATCH 01/15] Fix mismatch in release+logging build when AI player is involved --- .../GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index 53f33d2f1b..c03041416a 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -681,12 +681,16 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName, Real s = sin(angle); Real c = cos(angle); - DEBUG_LOG(("buildAIBaseDefenseStructure -- Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); +#if defined(_DEBUG) || defined(_INTERNAL) + // TheSuperHackers @info helmutbuhler 04/21/2025 + // This log causes mismatch on Release when logging is enabled. + DEBUG_LOG(("buildAIBaseDefenseStructure -- Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); DEBUG_LOG(("buildAIBaseDefenseStructure -- Offset is %f %f, Final Position is %f, %f \n", offset.x, offset.y, offset.x*c - offset.y*s, offset.y*c + offset.x*s - )); + )); +#endif Coord3D buildPos = m_baseCenter; buildPos.x += offset.x*c - offset.y*s; buildPos.y += offset.y*c + offset.x*s; From d520d2862d4acd7d36e541eaee45df9a009a5d66 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 21 Apr 2025 15:56:46 +0200 Subject: [PATCH 02/15] Gen: Fix mismatch in release+logging build when AI player is involved --- .../GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index df556f9bfa..ae6c335fe9 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -672,12 +672,16 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName, Real s = sin(angle); Real c = cos(angle); - DEBUG_LOG(("Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); +#if defined(_DEBUG) || defined(_INTERNAL) + // TheSuperHackers @info helmutbuhler 04/21/2025 + // This log causes mismatch on Release when logging is enabled. + DEBUG_LOG(("Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); DEBUG_LOG(("Offset is %f %f, new is %f, %f \n", offset.x, offset.y, offset.x*c - offset.y*s, offset.y*c + offset.x*s - )); + )); +#endif Coord3D buildPos = m_baseCenter; buildPos.x += offset.x*c - offset.y*s; buildPos.y += offset.y*c + offset.x*s; From 22fb160d0078d09a5a1ceedba3976da6e3b733aa Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 21 Apr 2025 17:25:19 +0200 Subject: [PATCH 03/15] Fix date in comments --- .../Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 2 +- .../Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index ae6c335fe9..f1bac28cb7 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -673,7 +673,7 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName, Real c = cos(angle); #if defined(_DEBUG) || defined(_INTERNAL) - // TheSuperHackers @info helmutbuhler 04/21/2025 + // TheSuperHackers @info helmutbuhler 21/04/2025 // This log causes mismatch on Release when logging is enabled. DEBUG_LOG(("Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); DEBUG_LOG(("Offset is %f %f, new is %f, %f \n", diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index c03041416a..9358d5f2e0 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -682,7 +682,7 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName, Real c = cos(angle); #if defined(_DEBUG) || defined(_INTERNAL) - // TheSuperHackers @info helmutbuhler 04/21/2025 + // TheSuperHackers @info helmutbuhler 21/04/2025 // This log causes mismatch on Release when logging is enabled. DEBUG_LOG(("buildAIBaseDefenseStructure -- Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); DEBUG_LOG(("buildAIBaseDefenseStructure -- Offset is %f %f, Final Position is %f, %f \n", From 643123bd8b8338e31ac4540658d804d707ad9c2e Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Sat, 26 Apr 2025 12:01:30 +0200 Subject: [PATCH 04/15] ZH: Fix logs that mismatch on Release in StateMachine --- .../Code/GameEngine/Source/Common/StateMachine.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp index cf79a8f029..9dd1f08f01 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp @@ -518,15 +518,19 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { + // TheSuperHackers @info helmutbuhler 26/04/2025 + // These logs cause mismatch on Release when logging is enabled. DEBUG_CRASH( ("StateMachine::internalGetState(): Invalid state for object %s using state %d", m_owner->getTemplate()->getName().str(), id) ); - DEBUG_LOG(("Transisioning to state #d\n", (Int)id)); +#if defined(_DEBUG) || defined(_INTERNAL) + DEBUG_LOG(("Transitioning to state #d\n", (Int)id)); DEBUG_LOG(("Attempting to recover - locating default state...\n")); +#endif i = m_stateMap.find(m_defaultStateID); if (i == m_stateMap.end()) { +#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Failed to located default state. Aborting...\n")); +#endif throw ERROR_BAD_ARG; - } else { - DEBUG_LOG(("Located default state to recover.\n")); } } From 559e701ea19197c8f51971ddc10a69095d0c48fb Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Sat, 26 Apr 2025 12:08:09 +0200 Subject: [PATCH 05/15] Gen: Fix logs that mismatch on Release in StateMachine --- .../GameEngine/Source/Common/StateMachine.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp index f8df862b8c..cd73176dca 100644 --- a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp @@ -499,8 +499,20 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { - DEBUG_CRASH(( "StateMachine::internalGetState(): Invalid state" )); - throw ERROR_BAD_ARG; + // TheSuperHackers @info helmutbuhler 26/04/2025 + // These logs cause mismatch on Release when logging is enabled. + DEBUG_CRASH( ("StateMachine::internalGetState(): Invalid state for object %s using state %d", m_owner->getTemplate()->getName().str(), id) ); +#if defined(_DEBUG) || defined(_INTERNAL) + DEBUG_LOG(("Transitioning to state #d\n", (Int)id)); + DEBUG_LOG(("Attempting to recover - locating default state...\n")); +#endif + i = m_stateMap.find(m_defaultStateID); + if (i == m_stateMap.end()) { +#if defined(_DEBUG) || defined(_INTERNAL) + DEBUG_LOG(("Failed to located default state. Aborting...\n")); +#endif + throw ERROR_BAD_ARG; + } } return (*i).second; From f83ec496143495b8dabc4ed532b6e376d040da82 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 5 May 2025 11:52:45 +0200 Subject: [PATCH 06/15] ZH Gen: Fix crash when version is logged in debug build and replay version contains non-ascii characters --- Generals/Code/GameEngine/Source/Common/Recorder.cpp | 5 ++++- GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/Recorder.cpp b/Generals/Code/GameEngine/Source/Common/Recorder.cpp index e7e2c12f0c..1bd11941e3 100644 --- a/Generals/Code/GameEngine/Source/Common/Recorder.cpp +++ b/Generals/Code/GameEngine/Source/Common/Recorder.cpp @@ -1112,7 +1112,10 @@ Bool RecorderClass::playbackFile(AsciiString filename) debugString = "EXE is different:\n"; if (versionStringDiff) { - tempStr.format(" Version [%ls] vs [%ls]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); + // AsciiString::format with %ls can make internal _vsnprintf call fail on some strings. We convert using translate here. (TheSuperHackers @fix helmutbuhler 05/05/2025) + UnicodeString tempStrWide; + tempStrWide.format(L" Version [%s] vs [%s]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); + tempStr.translate(tempStrWide); debugString.concat(tempStr); } if (versionTimeStringDiff) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp index 46ebcaa78e..626d2823b4 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp @@ -1115,7 +1115,10 @@ Bool RecorderClass::playbackFile(AsciiString filename) debugString = "EXE is different:\n"; if (versionStringDiff) { - tempStr.format(" Version [%ls] vs [%ls]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); + // AsciiString::format with %ls can make internal _vsnprintf call fail on some strings. We convert using translate here. (TheSuperHackers @fix helmutbuhler 05/05/2025) + UnicodeString tempStrWide; + tempStrWide.format(L" Version [%s] vs [%s]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); + tempStr.translate(tempStrWide); debugString.concat(tempStr); } if (versionTimeStringDiff) From 17fca13d04e2bc03723a41660fb9bc866be51701 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 5 May 2025 11:58:40 +0200 Subject: [PATCH 07/15] GEN ZH Remove Debug condition on DEBUG_LOGs in StateMachine. They are not necessary afterall. --- Generals/Code/GameEngine/Source/Common/StateMachine.cpp | 6 ------ GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp index cd73176dca..ab226102bd 100644 --- a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp @@ -499,18 +499,12 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { - // TheSuperHackers @info helmutbuhler 26/04/2025 - // These logs cause mismatch on Release when logging is enabled. DEBUG_CRASH( ("StateMachine::internalGetState(): Invalid state for object %s using state %d", m_owner->getTemplate()->getName().str(), id) ); -#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Transitioning to state #d\n", (Int)id)); DEBUG_LOG(("Attempting to recover - locating default state...\n")); -#endif i = m_stateMap.find(m_defaultStateID); if (i == m_stateMap.end()) { -#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Failed to located default state. Aborting...\n")); -#endif throw ERROR_BAD_ARG; } } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp index 9dd1f08f01..55724954c4 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp @@ -518,18 +518,12 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { - // TheSuperHackers @info helmutbuhler 26/04/2025 - // These logs cause mismatch on Release when logging is enabled. DEBUG_CRASH( ("StateMachine::internalGetState(): Invalid state for object %s using state %d", m_owner->getTemplate()->getName().str(), id) ); -#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Transitioning to state #d\n", (Int)id)); DEBUG_LOG(("Attempting to recover - locating default state...\n")); -#endif i = m_stateMap.find(m_defaultStateID); if (i == m_stateMap.end()) { -#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Failed to located default state. Aborting...\n")); -#endif throw ERROR_BAD_ARG; } } From b10df8e6a10b855f74ad3aea0e9bcec34f9c5451 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 5 May 2025 12:01:22 +0200 Subject: [PATCH 08/15] GEN ZH: Fix format #d -> %d --- Generals/Code/GameEngine/Source/Common/StateMachine.cpp | 2 +- GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp index ab226102bd..f3cc44161f 100644 --- a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp @@ -500,7 +500,7 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { DEBUG_CRASH( ("StateMachine::internalGetState(): Invalid state for object %s using state %d", m_owner->getTemplate()->getName().str(), id) ); - DEBUG_LOG(("Transitioning to state #d\n", (Int)id)); + DEBUG_LOG(("Transitioning to state %d\n", (Int)id)); DEBUG_LOG(("Attempting to recover - locating default state...\n")); i = m_stateMap.find(m_defaultStateID); if (i == m_stateMap.end()) { diff --git a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp index 55724954c4..dd2c2ff5b0 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp @@ -519,7 +519,7 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { DEBUG_CRASH( ("StateMachine::internalGetState(): Invalid state for object %s using state %d", m_owner->getTemplate()->getName().str(), id) ); - DEBUG_LOG(("Transitioning to state #d\n", (Int)id)); + DEBUG_LOG(("Transitioning to state %d\n", (Int)id)); DEBUG_LOG(("Attempting to recover - locating default state...\n")); i = m_stateMap.find(m_defaultStateID); if (i == m_stateMap.end()) { From e05e1b2bb912c4cffb3eb2718de025a174f42078 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 5 May 2025 14:00:37 +0200 Subject: [PATCH 09/15] Fix another mismatch due to logging --- GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 5bd89527fa..6fc12f6e10 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -4149,8 +4149,11 @@ StateReturnType AIFollowWaypointPathState::update() if (getAdjustsDestination() && ai->isDoingGroundMovement()) { if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { + // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) +#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); +#endif } return STATE_FAILURE; } @@ -4219,8 +4222,11 @@ StateReturnType AIFollowWaypointPathState::update() if (getAdjustsDestination() && ai->isDoingGroundMovement()) { if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { + // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) +#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); +#endif } return STATE_FAILURE; } From b0a340d425bd5c582790fff51858d9b8782c7917 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Mon, 5 May 2025 23:01:47 +0200 Subject: [PATCH 10/15] Fix yet another mm in Release. This time when DEBUG_CRASHING is enabled --- .../Source/GameLogic/Object/Contain/GarrisonContain.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp index 4b69792e68..bd97a0c0a2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp @@ -94,7 +94,11 @@ inline Real calcDistSqr(const Coord3D& a, const Coord3D& b) Int GarrisonContain::findClosestFreeGarrisonPointIndex( Int conditionIndex, const Coord3D *targetPos ) { +#if defined(_DEBUG) || defined(_INTERNAL) + // TheSuperHackers @info helmutbuhler 05/05/2025 + // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited")); +#endif // sanity if( targetPos == NULL || m_garrisonPointsInUse == MAX_GARRISON_POINTS ) From 153adceda8d6d63aea312f39cd37668d38745faf Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Tue, 6 May 2025 01:38:11 +0200 Subject: [PATCH 11/15] Fix another mm when DEBUG_CRASHING is defined --- .../Source/GameLogic/Object/Update/PhysicsUpdate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp index 343a23aee9..3156e1e329 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp @@ -321,7 +321,11 @@ Real PhysicsBehavior::getZFriction() const */ void PhysicsBehavior::applyForce( const Coord3D *force ) { +#if defined(_DEBUG) || defined(_INTERNAL) + // TheSuperHackers @info helmutbuhler 06/05/2025 + // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(!(_isnan(force->x) || _isnan(force->y) || _isnan(force->z)), ("PhysicsBehavior::applyForce force NAN!\n")); +#endif if (_isnan(force->x) || _isnan(force->y) || _isnan(force->z)) { return; } From b9db1d46b11d9dcf1017f66e1efe99b3ad1dc60e Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Tue, 6 May 2025 09:51:17 +0200 Subject: [PATCH 12/15] Sync with Generals --- Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 6 ++++++ .../Source/GameLogic/Object/Contain/GarrisonContain.cpp | 4 ++++ .../Source/GameLogic/Object/Update/PhysicsUpdate.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 3d81a08c52..580a8b5ff5 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -3984,8 +3984,11 @@ StateReturnType AIFollowWaypointPathState::update() if (getAdjustsDestination() && ai->isDoingGroundMovement()) { if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { + // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) +#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); +#endif } return STATE_FAILURE; } @@ -4054,8 +4057,11 @@ StateReturnType AIFollowWaypointPathState::update() if (getAdjustsDestination() && ai->isDoingGroundMovement()) { if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { + // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) +#if defined(_DEBUG) || defined(_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); +#endif } return STATE_FAILURE; } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp index 626230a42f..979e554964 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp @@ -93,7 +93,11 @@ inline Real calcDistSqr(const Coord3D& a, const Coord3D& b) Int GarrisonContain::findClosestFreeGarrisonPointIndex( Int conditionIndex, const Coord3D *targetPos ) { +#if defined(_DEBUG) || defined(_INTERNAL) + // TheSuperHackers @info helmutbuhler 05/05/2025 + // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited")); +#endif // sanity if( targetPos == NULL || m_garrisonPointsInUse == MAX_GARRISON_POINTS ) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp index 7b59b43f0e..f2359b320b 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp @@ -303,7 +303,11 @@ Real PhysicsBehavior::getZFriction() const */ void PhysicsBehavior::applyForce( const Coord3D *force ) { +#if defined(_DEBUG) || defined(_INTERNAL) + // TheSuperHackers @info helmutbuhler 06/05/2025 + // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(!(_isnan(force->x) || _isnan(force->y) || _isnan(force->z)), ("PhysicsBehavior::applyForce force NAN!\n")); +#endif if (_isnan(force->x) || _isnan(force->y) || _isnan(force->z)) { return; } From 578bb75fd09ee8a927915c12c2d581b63ab429a5 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Tue, 6 May 2025 09:59:07 +0200 Subject: [PATCH 13/15] Rename defines to RTS_DEBUG and RTS_INTERNAL --- .../Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 2 +- Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 4 ++-- .../Source/GameLogic/Object/Contain/GarrisonContain.cpp | 2 +- .../Source/GameLogic/Object/Update/PhysicsUpdate.cpp | 2 +- .../Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 2 +- GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 4 ++-- .../Source/GameLogic/Object/Contain/GarrisonContain.cpp | 2 +- .../Source/GameLogic/Object/Update/PhysicsUpdate.cpp | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index dec95f66b0..65fdc03836 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -672,7 +672,7 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName, Real s = sin(angle); Real c = cos(angle); -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // TheSuperHackers @info helmutbuhler 21/04/2025 // This log causes mismatch on Release when logging is enabled. DEBUG_LOG(("Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 03bff2387d..caac762aea 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -4029,7 +4029,7 @@ StateReturnType AIFollowWaypointPathState::update() if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); #endif @@ -4102,7 +4102,7 @@ StateReturnType AIFollowWaypointPathState::update() if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); #endif diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp index 9ae0d0a615..e04cec1dd1 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp @@ -93,7 +93,7 @@ inline Real calcDistSqr(const Coord3D& a, const Coord3D& b) Int GarrisonContain::findClosestFreeGarrisonPointIndex( Int conditionIndex, const Coord3D *targetPos ) { -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // TheSuperHackers @info helmutbuhler 05/05/2025 // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited")); diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp index e95371a213..9fc0ddaf85 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp @@ -303,7 +303,7 @@ Real PhysicsBehavior::getZFriction() const */ void PhysicsBehavior::applyForce( const Coord3D *force ) { -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // TheSuperHackers @info helmutbuhler 06/05/2025 // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(!(_isnan(force->x) || _isnan(force->y) || _isnan(force->z)), ("PhysicsBehavior::applyForce force NAN!\n")); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index a8ca09d8e6..3b8c19fa88 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -681,7 +681,7 @@ void AISkirmishPlayer::buildAIBaseDefenseStructure(const AsciiString &thingName, Real s = sin(angle); Real c = cos(angle); -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // TheSuperHackers @info helmutbuhler 21/04/2025 // This log causes mismatch on Release when logging is enabled. DEBUG_LOG(("buildAIBaseDefenseStructure -- Angle is %f sin %f, cos %f \n", 180*angle/PI, s, c)); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index fdb36ec1eb..648c0dc2d0 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -4150,7 +4150,7 @@ StateReturnType AIFollowWaypointPathState::update() if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); #endif @@ -4223,7 +4223,7 @@ StateReturnType AIFollowWaypointPathState::update() if (!TheAI->pathfinder()->adjustDestination(obj, ai->getLocomotorSet(), &m_goalPosition)) { if (m_currentWaypoint) { // This log causes mismatch on Release (TheSuperHackers @info helmutbuhler 05/05/2025) -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) DEBUG_LOG(("Breaking out of follow waypoint path %s of %s\n", m_currentWaypoint->getName().str(), m_currentWaypoint->getPathLabel1().str())); #endif diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp index 7066d16e4a..2df6a64357 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp @@ -94,7 +94,7 @@ inline Real calcDistSqr(const Coord3D& a, const Coord3D& b) Int GarrisonContain::findClosestFreeGarrisonPointIndex( Int conditionIndex, const Coord3D *targetPos ) { -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // TheSuperHackers @info helmutbuhler 05/05/2025 // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited")); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp index 358016c285..ca9dcbda8c 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp @@ -321,7 +321,7 @@ Real PhysicsBehavior::getZFriction() const */ void PhysicsBehavior::applyForce( const Coord3D *force ) { -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // TheSuperHackers @info helmutbuhler 06/05/2025 // This assert causes a mismatch on Release when DEBUG_CRASHING is enabled. DEBUG_ASSERTCRASH(!(_isnan(force->x) || _isnan(force->y) || _isnan(force->z)), ("PhysicsBehavior::applyForce force NAN!\n")); From fc0ba7d396eb0eec9f47d738461020f339d4b81e Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Tue, 6 May 2025 20:32:40 +0200 Subject: [PATCH 14/15] Remove Unicode fix in RecorderClass::playbackFile --- Generals/Code/GameEngine/Source/Common/Recorder.cpp | 5 +---- GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/Recorder.cpp b/Generals/Code/GameEngine/Source/Common/Recorder.cpp index 66ac615c1e..497aa71bfb 100644 --- a/Generals/Code/GameEngine/Source/Common/Recorder.cpp +++ b/Generals/Code/GameEngine/Source/Common/Recorder.cpp @@ -1115,10 +1115,7 @@ Bool RecorderClass::playbackFile(AsciiString filename) debugString = "EXE is different:\n"; if (versionStringDiff) { - // AsciiString::format with %ls can make internal _vsnprintf call fail on some strings. We convert using translate here. (TheSuperHackers @fix helmutbuhler 05/05/2025) - UnicodeString tempStrWide; - tempStrWide.format(L" Version [%s] vs [%s]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); - tempStr.translate(tempStrWide); + tempStr.format(" Version [%ls] vs [%ls]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); debugString.concat(tempStr); } if (versionTimeStringDiff) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp index d853df9421..bccc2c2add 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp @@ -1118,10 +1118,7 @@ Bool RecorderClass::playbackFile(AsciiString filename) debugString = "EXE is different:\n"; if (versionStringDiff) { - // AsciiString::format with %ls can make internal _vsnprintf call fail on some strings. We convert using translate here. (TheSuperHackers @fix helmutbuhler 05/05/2025) - UnicodeString tempStrWide; - tempStrWide.format(L" Version [%s] vs [%s]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); - tempStr.translate(tempStrWide); + tempStr.format(" Version [%ls] vs [%ls]\n", TheVersion->getUnicodeVersion().str(), header.versionString.str()); debugString.concat(tempStr); } if (versionTimeStringDiff) From 5b6be6037d2b5e29bc65f073c360e3eb01307176 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Tue, 6 May 2025 20:34:18 +0200 Subject: [PATCH 15/15] Add stupid else-block back --- Generals/Code/GameEngine/Source/Common/StateMachine.cpp | 2 ++ GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp index 96e309a7c8..f5a83d1f69 100644 --- a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp @@ -506,6 +506,8 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { DEBUG_LOG(("Failed to located default state. Aborting...\n")); throw ERROR_BAD_ARG; + } else { + DEBUG_LOG(("Located default state to recover.\n")); } } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp index 4158015826..b9a5b1dff2 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp @@ -525,6 +525,8 @@ State *StateMachine::internalGetState( StateID id ) if (i == m_stateMap.end()) { DEBUG_LOG(("Failed to located default state. Aborting...\n")); throw ERROR_BAD_ARG; + } else { + DEBUG_LOG(("Located default state to recover.\n")); } }