diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp index 204b14ec293..cd6929440e8 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp @@ -696,7 +696,7 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p } if (m_shadow == nullptr && TheW3DProjectedShadowManager) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.m_ShadowName[0] = 0; shadowInfo.allowUpdates=FALSE; //shadow image will never update shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects diff --git a/Generals/Code/GameEngine/Include/GameClient/Shadow.h b/Generals/Code/GameEngine/Include/GameClient/Shadow.h index 2e40ea7ae3a..2b6901815f7 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Shadow.h +++ b/Generals/Code/GameEngine/Include/GameClient/Shadow.h @@ -73,6 +73,19 @@ class Shadow struct ShadowTypeInfo { + // TheSuperHackers @fix Stubbjax 30/01/2026 Initialize all members in the constructor to avoid garbage data and potential crashes. + ShadowTypeInfo() + { + m_ShadowName[0] = '\0'; + m_type = SHADOW_NONE; + allowUpdates = false; + allowWorldAlign = false; + m_sizeX = 0.0f; + m_sizeY = 0.0f; + m_offsetX = 0.0f; + m_offsetY = 0.0f; + } + char m_ShadowName[64]; //when set, overrides the default model shadow (used mostly for Decals). ShadowType m_type; //type of shadow Bool allowUpdates; //whether to update the shadow image when object/light moves. diff --git a/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp index 645c8845b47..1b7ce359fcb 100644 --- a/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp @@ -69,7 +69,7 @@ void RadiusDecalTemplate::createRadiusDecal(const Coord3D& pos, Real radius, con if (!m_onlyVisibleToOwningPlayer || owningPlayer->getPlayerIndex() == ThePlayerList->getLocalPlayer()->getPlayerIndex()) { - Shadow::ShadowTypeInfo decalInfo; + Shadow::ShadowTypeInfo decalInfo = Shadow::ShadowTypeInfo(); decalInfo.allowUpdates = FALSE; // shadow texture will never update decalInfo.allowWorldAlign = TRUE; // shadow image will wrap around world objects decalInfo.m_type = m_shadowType; diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp index f7b57d4fa4c..5f23021f74b 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp @@ -127,10 +127,8 @@ void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t) if (t != SHADOW_NONE) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.m_type = t; - shadowInfo.m_sizeX=0; - shadowInfo.m_sizeY=0; m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo); } else diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp index e199b6b0500..7afb99f9e1b 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp @@ -60,12 +60,8 @@ W3DDefaultDraw::W3DDefaultDraw(Thing *thing, const ModuleData* moduleData) : Dra { m_renderObject = W3DDisplay::m_assetManager->Create_Render_Obj(getDrawable()->getTemplate()->getLTAName().str(), getDrawable()->getScale(), 0); - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.m_type=(ShadowType)SHADOW_VOLUME; - shadowInfo.m_sizeX=0; //use defaults - shadowInfo.m_sizeY=0; - shadowInfo.m_offsetX=0; - shadowInfo.m_offsetY=0; m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo); diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp index 7afabdada40..d8da016d14c 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp @@ -1825,7 +1825,7 @@ void W3DModelDraw::allocateShadows(void) //Check if we don't already have a shadow but need one for this type of model. if (m_shadow == nullptr && m_renderObject && TheW3DShadowManager && tmplate->getShadowType() != SHADOW_NONE) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); strlcpy(shadowInfo.m_ShadowName, tmplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); DEBUG_ASSERTCRASH(shadowInfo.m_ShadowName[0] != '\0', ("this should be validated in ThingTemplate now")); shadowInfo.allowUpdates = FALSE; //shadow image will never update @@ -2693,7 +2693,7 @@ void W3DModelDraw::setTerrainDecal(TerrainDecalType type) const ThingTemplate *tmplate=getDrawable()->getTemplate(); //create a new terrain decal - Shadow::ShadowTypeInfo decalInfo; + Shadow::ShadowTypeInfo decalInfo = Shadow::ShadowTypeInfo(); decalInfo.allowUpdates = FALSE; //shadow image will never update decalInfo.allowWorldAlign = TRUE; //shadow image will wrap around world objects decalInfo.m_type = SHADOW_ALPHA_DECAL; @@ -3015,7 +3015,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) // set up shadows if (m_renderObject && TheW3DShadowManager && tmplate->getShadowType() != SHADOW_NONE) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); strlcpy(shadowInfo.m_ShadowName, tmplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); DEBUG_ASSERTCRASH(shadowInfo.m_ShadowName[0] != '\0', ("this should be validated in ThingTemplate now")); shadowInfo.allowUpdates = FALSE; //shadow image will never update diff --git a/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp b/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp index 7508a17af66..dd3cd8c6a76 100644 --- a/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp @@ -1135,7 +1135,7 @@ void WbView3d::invalBuildListItemInView(BuildListInfo *pBuildToInval) if( m_showShadows && tTemplate->getShadowType() != SHADOW_NONE) { //add correct type of shadow - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.allowUpdates=FALSE; //shadow image will never update shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects strlcpy(shadowInfo.m_ShadowName, tTemplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); @@ -1402,7 +1402,7 @@ void WbView3d::invalObjectInView(MapObject *pMapObjIn) renderObj = m_assetManager->Create_Render_Obj( modelName.str(), scale, playerColor); if( m_showShadows ) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.allowUpdates=FALSE; //shadow image will never update shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects const ThingTemplate *tTemplate = pMapObj->getThingTemplate(); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h index 01e02d09dbe..cc04cd03a05 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h @@ -73,6 +73,19 @@ class Shadow struct ShadowTypeInfo { + // TheSuperHackers @fix Stubbjax 30/01/2026 Initialize all members in the constructor to avoid garbage data and potential crashes. + ShadowTypeInfo() + { + m_ShadowName[0] = '\0'; + m_type = SHADOW_NONE; + allowUpdates = false; + allowWorldAlign = false; + m_sizeX = 0.0f; + m_sizeY = 0.0f; + m_offsetX = 0.0f; + m_offsetY = 0.0f; + } + char m_ShadowName[64]; //when set, overrides the default model shadow (used mostly for Decals). ShadowType m_type; //type of shadow Bool allowUpdates; //whether to update the shadow image when object/light moves. diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp index c7863220aaf..4dd6a8a48ba 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp @@ -69,7 +69,7 @@ void RadiusDecalTemplate::createRadiusDecal(const Coord3D& pos, Real radius, con if (!m_onlyVisibleToOwningPlayer || owningPlayer->getPlayerIndex() == ThePlayerList->getLocalPlayer()->getPlayerIndex()) { - Shadow::ShadowTypeInfo decalInfo; + Shadow::ShadowTypeInfo decalInfo = Shadow::ShadowTypeInfo(); decalInfo.allowUpdates = FALSE; // shadow texture will never update decalInfo.allowWorldAlign = TRUE; // shadow image will wrap around world objects decalInfo.m_type = m_shadowType; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp index bf641e4407b..129269769a1 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp @@ -127,10 +127,8 @@ void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t) if (t != SHADOW_NONE) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.m_type = t; - shadowInfo.m_sizeX=0; - shadowInfo.m_sizeY=0; m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo); } else diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp index c6b30a4fdf5..24f25ce9c85 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp @@ -60,12 +60,8 @@ W3DDefaultDraw::W3DDefaultDraw(Thing *thing, const ModuleData* moduleData) : Dra { m_renderObject = W3DDisplay::m_assetManager->Create_Render_Obj(getDrawable()->getTemplate()->getLTAName().str(), getDrawable()->getScale(), 0); - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.m_type=(ShadowType)SHADOW_VOLUME; - shadowInfo.m_sizeX=0; //use defaults - shadowInfo.m_sizeY=0; - shadowInfo.m_offsetX=0; - shadowInfo.m_offsetY=0; m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp index 5908a041a8d..e8d52d9e598 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp @@ -1860,7 +1860,7 @@ void W3DModelDraw::allocateShadows(void) //Check if we don't already have a shadow but need one for this type of model. if (m_shadow == nullptr && m_renderObject && TheW3DShadowManager && tmplate->getShadowType() != SHADOW_NONE) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); strlcpy(shadowInfo.m_ShadowName, tmplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); DEBUG_ASSERTCRASH(shadowInfo.m_ShadowName[0] != '\0', ("this should be validated in ThingTemplate now")); shadowInfo.allowUpdates = FALSE; //shadow image will never update @@ -2745,7 +2745,7 @@ void W3DModelDraw::setTerrainDecal(TerrainDecalType type) const ThingTemplate *tmplate=getDrawable()->getTemplate(); //create a new terrain decal - Shadow::ShadowTypeInfo decalInfo; + Shadow::ShadowTypeInfo decalInfo = Shadow::ShadowTypeInfo(); decalInfo.allowUpdates = FALSE; //shadow image will never update decalInfo.allowWorldAlign = TRUE; //shadow image will wrap around world objects decalInfo.m_type = SHADOW_ALPHA_DECAL; @@ -3070,7 +3070,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) // set up shadows if (m_renderObject && TheW3DShadowManager && tmplate->getShadowType() != SHADOW_NONE) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); strlcpy(shadowInfo.m_ShadowName, tmplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); DEBUG_ASSERTCRASH(shadowInfo.m_ShadowName[0] != '\0', ("this should be validated in ThingTemplate now")); shadowInfo.allowUpdates = FALSE; //shadow image will never update diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp index 91d6c315ec0..05edb642efe 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp @@ -1193,7 +1193,7 @@ void WbView3d::invalBuildListItemInView(BuildListInfo *pBuildToInval) if( m_showShadows && tTemplate->getShadowType() != SHADOW_NONE) { //add correct type of shadow - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.allowUpdates=FALSE; //shadow image will never update shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects strlcpy(shadowInfo.m_ShadowName, tTemplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); @@ -1469,7 +1469,7 @@ void WbView3d::invalObjectInView(MapObject *pMapObjIn) renderObj = m_assetManager->Create_Render_Obj( modelName.str(), scale, playerColor); if( m_showShadows ) { - Shadow::ShadowTypeInfo shadowInfo; + Shadow::ShadowTypeInfo shadowInfo = Shadow::ShadowTypeInfo(); shadowInfo.allowUpdates=FALSE; //shadow image will never update shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects if (tTemplate && tTemplate->getShadowType() != SHADOW_NONE && !(pMapObj->getFlags() & FLAG_DONT_RENDER))