Skip to content

Commit 931e248

Browse files
authored
Merge pull request #188 from 1rgs/fix/skybox-null-guard
Fix segfault in WaterRenderObjClass when skybox asset fails to load
2 parents 0cdbc81 + ae4557b commit 931e248

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,13 @@ void WaterRenderObjClass::update()
13381338
//-------------------------------------------------------------------------------------------------
13391339
void WaterRenderObjClass::replaceSkyboxTexture(const AsciiString& oldTexName, const AsciiString& newTextName)
13401340
{
1341+
// GeneralsX @bugfix Claude 05/07/2026 Guard against null m_skyBox: replaceAssetTexture dereferences the
1342+
// render object unconditionally, so skip texture replacement when the skybox asset never loaded.
1343+
if (m_skyBox == nullptr)
1344+
{
1345+
return;
1346+
}
1347+
13411348
W3DAssetManager* assetManager = ((W3DAssetManager*)W3DAssetManager::Get_Instance());
13421349

13431350
assetManager->replacePrototypeTexture(m_skyBox, oldTexName.str(), newTextName.str());
@@ -1737,7 +1744,9 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo)
17371744
break;
17381745
}
17391746

1740-
if (TheGlobalData && TheGlobalData->m_drawSkyBox)
1747+
// GeneralsX @bugfix Claude 05/07/2026 Guard against null m_skyBox: Create_Render_Obj("new_skybox") can fail
1748+
// when the skybox asset is unavailable (e.g. base Generals archives not found), causing a segfault here.
1749+
if (TheGlobalData && TheGlobalData->m_drawSkyBox && m_skyBox)
17411750
{ //center skybox around camera
17421751
Vector3 pos=rinfo.Camera.Get_Position();
17431752
pos.Z = TheGlobalData->m_skyBoxPositionZ;

Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,11 @@ void TextureLoadTaskClass::Apply_Missing_Texture()
13211321
return;
13221322
}
13231323

1324+
#ifndef _WIN32
1325+
// DIAG: log which textures fall back to the magenta placeholder
1326+
fprintf(stderr, "[TEX_MISSING] '%s'\n", static_cast<const char*>(Texture->Get_Full_Path()));
1327+
#endif
1328+
13241329
D3DTexture = MissingTexture::_Get_Missing_Texture();
13251330
if (D3DTexture == nullptr)
13261331
{

0 commit comments

Comments
 (0)