From 20ac222fa51f0ce2b4c623ff142126023d12ebfa Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Fri, 18 Jul 2025 14:05:26 +0200 Subject: [PATCH 1/3] Added check for under construction status. --- Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp | 6 ++++++ .../Code/GameEngine/Source/GameLogic/Object/Object.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp index a4e0e20a371..60ff5ccb9ce 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3318,6 +3318,12 @@ void Object::onDisabledEdge(Bool becomingDisabled) } } + // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. +#if !RETAIL_COMPATIBLE_CRC + if (testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION)) + return; +#endif + // We will need to adjust power ... somehow ... Int powerToAdjust = getTemplate()->getEnergyProduction(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index 077d7cbb45f..feb86cf25b1 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3838,6 +3838,12 @@ void Object::onDisabledEdge(Bool becomingDisabled) } } + // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. +#if !RETAIL_COMPATIBLE_CRC + if (testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION)) + return; +#endif + // We will need to adjust power ... somehow ... Int powerToAdjust = getTemplate()->getEnergyProduction(); From 73730aaa96b24f48274ddd335dbeff06098feadf Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Fri, 18 Jul 2025 23:46:48 +0200 Subject: [PATCH 2/3] Refactored code to remove the early return. --- .../Code/GameEngine/Source/GameLogic/Object/Object.cpp | 9 +++++---- .../Code/GameEngine/Source/GameLogic/Object/Object.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp index 60ff5ccb9ce..a2f9efc50e1 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3319,15 +3319,16 @@ void Object::onDisabledEdge(Bool becomingDisabled) } // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. -#if !RETAIL_COMPATIBLE_CRC - if (testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION)) - return; +#if RETAIL_COMPATIBLE_CRC + const Bool underConstruction = false; +#else + const Bool underConstruction = testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION); #endif // We will need to adjust power ... somehow ... Int powerToAdjust = getTemplate()->getEnergyProduction(); - if( powerToAdjust > 0 ) + if( !underConstruction && powerToAdjust > 0 ) { // We can't affect something that consumes, or else we go low power which removes the consumption // which makes us not low power so we add the consumption so we go low power... diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index feb86cf25b1..f330c785a6b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3839,15 +3839,16 @@ void Object::onDisabledEdge(Bool becomingDisabled) } // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. -#if !RETAIL_COMPATIBLE_CRC - if (testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION)) - return; +#if RETAIL_COMPATIBLE_CRC + const Bool underConstruction = false; +#else + const Bool underConstruction = testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION); #endif // We will need to adjust power ... somehow ... Int powerToAdjust = getTemplate()->getEnergyProduction(); - if( powerToAdjust > 0 ) + if( !underConstruction && powerToAdjust > 0 ) { // We can't affect something that consumes, or else we go low power which removes the consumption // which makes us not low power so we add the consumption so we go low power... From 8697219c8826daff8b00ced83313ba8d514626dc Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sat, 19 Jul 2025 12:16:12 +0200 Subject: [PATCH 3/3] Refactored code again. --- .../GameEngine/Source/GameLogic/Object/Object.cpp | 14 ++++++-------- .../GameEngine/Source/GameLogic/Object/Object.cpp | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp index a2f9efc50e1..6ec11879111 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3318,17 +3318,15 @@ void Object::onDisabledEdge(Bool becomingDisabled) } } - // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. -#if RETAIL_COMPATIBLE_CRC - const Bool underConstruction = false; -#else - const Bool underConstruction = testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION); -#endif - // We will need to adjust power ... somehow ... Int powerToAdjust = getTemplate()->getEnergyProduction(); - if( !underConstruction && powerToAdjust > 0 ) + // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. +#if !RETAIL_COMPATIBLE_CRC + if ( powerToAdjust > 0 && !testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) ) +#else + if ( powerToAdjust > 0 ) +#endif { // We can't affect something that consumes, or else we go low power which removes the consumption // which makes us not low power so we add the consumption so we go low power... diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index f330c785a6b..370851e84ad 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3838,17 +3838,15 @@ void Object::onDisabledEdge(Bool becomingDisabled) } } - // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. -#if RETAIL_COMPATIBLE_CRC - const Bool underConstruction = false; -#else - const Bool underConstruction = testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION); -#endif - // We will need to adjust power ... somehow ... Int powerToAdjust = getTemplate()->getEnergyProduction(); - if( !underConstruction && powerToAdjust > 0 ) + // TheSuperHackers @bugfix Caball009 18/07/2025 Don't adjust the power for power plants that are still under construction. +#if !RETAIL_COMPATIBLE_CRC + if ( powerToAdjust > 0 && !testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) ) +#else + if ( powerToAdjust > 0 ) +#endif { // We can't affect something that consumes, or else we go low power which removes the consumption // which makes us not low power so we add the consumption so we go low power...