Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions Generals/Code/GameEngine/Include/GameClient/Shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit this comment because it does not add any value to the next reader.

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.
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling the constructor like this is not necessary. It is automatically called on construction.

Several times in this change.

decalInfo.allowUpdates = FALSE; // shadow texture will never update
decalInfo.allowWorldAlign = TRUE; // shadow image will wrap around world objects
decalInfo.m_type = m_shadowType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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))
Expand Down
Loading