From 090c01942cd2649a28fced2656f53c7173fc9678 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Wed, 11 Nov 2026 19:41:44 +0100 Subject: [PATCH 1/4] bugfix(drawable): Fix crash in Drawable::setColorTintEnvelope. --- .../GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp | 5 ++--- .../GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp | 3 ++- .../GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp | 3 ++- GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp index c4ab5f185a9..006ca5267c8 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp @@ -97,9 +97,8 @@ void W3DOverlordAircraftDraw::doDrawModule(const Matrix3D* transformMtx) Drawable *riderDraw = me->getContain()->friend_getRider()->getDrawable(); if ( riderDraw ) { - TintEnvelope *env = getDrawable()->getColorTintEnvelope(); - if ( env ) - riderDraw->setColorTintEnvelope( *env ); + if (const TintEnvelope* tint = getDrawable()->getColorTintEnvelope()) + riderDraw->setColorTintEnvelope(*tint); riderDraw->notifyDrawableDependencyCleared(); riderDraw->draw(); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp index c23862303ba..d0fcb8a980b 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp @@ -86,7 +86,8 @@ void W3DOverlordTankDraw::doDrawModule(const Matrix3D* transformMtx) ) { Drawable *riderDraw = me->getContain()->friend_getRider()->getDrawable(); - riderDraw->setColorTintEnvelope( *getDrawable()->getColorTintEnvelope() ); + if (const TintEnvelope* tint = getDrawable()->getColorTintEnvelope()) + riderDraw->setColorTintEnvelope(*tint); riderDraw->notifyDrawableDependencyCleared(); riderDraw->draw(); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp index e7416ead16c..bb73a8f5d26 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp @@ -86,7 +86,8 @@ void W3DOverlordTruckDraw::doDrawModule(const Matrix3D* transformMtx) ) { Drawable *riderDraw = me->getContain()->friend_getRider()->getDrawable(); - riderDraw->setColorTintEnvelope( *getDrawable()->getColorTintEnvelope() ); + if (const TintEnvelope* tint = getDrawable()->getColorTintEnvelope()) + riderDraw->setColorTintEnvelope(*tint); riderDraw->notifyDrawableDependencyCleared(); riderDraw->draw(); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h index def8f8e231c..f4cfe93eb85 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h @@ -314,8 +314,8 @@ class Drawable : public Thing, void setTintStatus( TintStatus statusBits ) { BitSet( m_tintStatus, statusBits ); }; void clearTintStatus( TintStatus statusBits ) { BitClear( m_tintStatus, statusBits ); }; Bool testTintStatus( TintStatus statusBits ) const { return BitIsSet( m_tintStatus, statusBits ); }; - TintEnvelope *getColorTintEnvelope() { return m_colorTintEnvelope; } - void setColorTintEnvelope( TintEnvelope &source ) { if (m_colorTintEnvelope) *m_colorTintEnvelope = source; } + const TintEnvelope *getColorTintEnvelope() const { return m_colorTintEnvelope; } + void setColorTintEnvelope( const TintEnvelope& source ) { if (m_colorTintEnvelope) *m_colorTintEnvelope = source; } void imitateStealthLook( Drawable& otherDraw ); From 35e63e1d909b61665918ee2f4101fed680da3a78 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 29 Oct 2026 02:51:19 +0100 Subject: [PATCH 2/4] bugfix(drawable): Set disabled tint status for powered units that get built without sufficient power. --- GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp index 3136edbf55d..d6231354478 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp @@ -4096,6 +4096,12 @@ void Drawable::friend_bindToObject( Object *obj ) ///< bind this drawable to an m_object = obj; if (getObject()) { + // TheSuperHackers @bugfix Set tint status here because the object may get disabled before the drawable is attached. + if (getObject()->isKindOf(KINDOF_POWERED) && getObject()->isDisabledByType(DISABLED_UNDERPOWERED)) + { + setTintStatus(TINT_STATUS_DISABLED); + } + if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT) setIndicatorColor(getObject()->getNightIndicatorColor()); else From 3a393dcb2326d7536cfb16394cd44fa80e601588 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:54:50 +0100 Subject: [PATCH 3/4] tweak(object): Add support for powered objects with zero energy consumption. --- GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h | 1 + .../Code/GameEngine/Source/Common/RTS/Energy.cpp | 7 +++++++ .../Code/GameEngine/Source/Common/RTS/Player.cpp | 9 +++------ .../GameEngine/Source/GameLogic/Object/Object.cpp | 11 +++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h index 214abbf58f8..7af851495d1 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h @@ -560,6 +560,7 @@ class Object : public Thing, public Snapshot // @todo: inline Bool hasSpecialPower( SpecialPowerType type ) const; Bool hasAnySpecialPower() const; + void doPowerDisable(bool disabling); void setWeaponBonusCondition(WeaponBonusConditionType wst); void clearWeaponBonusCondition(WeaponBonusConditionType wst); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Energy.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Energy.cpp index bc5d450ca07..c5d073a98af 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Energy.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Energy.cpp @@ -143,6 +143,13 @@ void Energy::objectEnteringInfluence( Object *obj ) addConsumption( -energy ); else if( energy > 0 ) addProduction( energy ); +#if !RETAIL_COMPATIBLE_CRC + // TheSuperHackers @tweak Add support for powered objects that consume no energy. + else if (obj->isKindOf(KINDOF_POWERED)) + { + obj->doPowerDisable(!hasSufficientPower()); + } +#endif // sanity DEBUG_ASSERTCRASH( m_energyProduction >= 0 && m_energyConsumption >= 0, diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp index 9439759e534..2c562f04fb1 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -3280,13 +3280,10 @@ Bool Player::hasRadar() const //------------------------------------------------------------------------------------------------ static void doPowerDisable( Object *obj, void *userData ) { - Bool disabling = *((Bool*)userData); - if( obj && obj->isKindOf(KINDOF_POWERED) ) + if (obj) { - if( disabling ) - obj->setDisabled( DISABLED_UNDERPOWERED ); //set disabled has a pauseAllSpecialPowers that prevents double pausing - else - obj->clearDisabled( DISABLED_UNDERPOWERED ); + const Bool disabling = *reinterpret_cast(userData); + obj->doPowerDisable(disabling); } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index 88028578414..ba1daed9f3c 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3171,6 +3171,17 @@ Bool Object::hasAnySpecialPower() const return SPECIALPOWERMASK_ANY_SET( m_specialPowerBits ); } +void Object::doPowerDisable(bool disabling) +{ + if( isKindOf(KINDOF_POWERED) ) + { + if( disabling ) + setDisabled( DISABLED_UNDERPOWERED ); //set disabled has a pauseAllSpecialPowers that prevents double pausing + else + clearDisabled( DISABLED_UNDERPOWERED ); + } +} + //------------------------------------------------------------------------------------------------- void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback ) { From daf29595bc77c78a1f11a53a42b896569b15e006 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:55:06 +0100 Subject: [PATCH 4/4] fix(object): Initialize Object::m_behaviors fields as nullptr. --- GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index ba1daed9f3c..63de8547988 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -306,7 +306,7 @@ Object::Object( const ThingTemplate *tt, const ObjectStatusMaskType &objectStatu // allocate the publicModule arrays // pool[]ify - m_behaviors = MSGNEW("ModulePtrs") BehaviorModule*[totalModules + 1]; + m_behaviors = MSGNEW("ModulePtrs") BehaviorModule*[totalModules + 1](); BehaviorModule** curB = m_behaviors; const ModuleInfo& mi = tt->getBehaviorModuleInfo();