Skip to content

Commit 8b4870c

Browse files
authored
Merge pull request #490 from GeneralsOnlineDevelopmentTeam/seer/fix/w3ddisplay-texture-data-checks
bugfix(w3ddisplay): Prevent crashes when texture data or filename is missing
2 parents 3d3ddc9 + 03c161f commit 8b4870c

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,9 +2545,17 @@ void W3DDisplay::drawImage( const Image *image, Int startX, Int startY,
25452545

25462546
// if we have raw texture data we will use it, otherwise we are referencing filenames
25472547
if( BitIsSet( image->getStatus(), IMAGE_STATUS_RAW_TEXTURE ) )
2548+
{
2549+
if( image->getRawTextureData() == nullptr )
2550+
return;
25482551
m_2DRender->Set_Texture( (TextureClass *)(image->getRawTextureData()) );
2552+
}
25492553
else
2554+
{
2555+
if( image->getFilename().isEmpty() )
2556+
return;
25502557
m_2DRender->Set_Texture( image->getFilename().str() );
2558+
}
25512559

25522560
RectClass screen_rect(startX,startY,endX,endY);
25532561
RectClass uv_rect(uv->lo.x,uv->lo.y,uv->hi.x,uv->hi.y);

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,9 +2652,17 @@ void W3DDisplay::drawImage(const Image* image, Int startX, Int startY,
26522652

26532653
// if we have raw texture data we will use it, otherwise we are referencing filenames
26542654
if (BitIsSet(image->getStatus(), IMAGE_STATUS_RAW_TEXTURE))
2655+
{
2656+
if (image->getRawTextureData() == nullptr)
2657+
return;
26552658
m_2DRender->Set_Texture((TextureClass*)(image->getRawTextureData()));
2659+
}
26562660
else
2661+
{
2662+
if (image->getFilename().isEmpty())
2663+
return;
26572664
m_2DRender->Set_Texture(image->getFilename().str());
2665+
}
26582666

26592667
RectClass screen_rect(startX, startY, endX, endY);
26602668
RectClass uv_rect(uv->lo.x, uv->lo.y, uv->hi.x, uv->hi.y);

0 commit comments

Comments
 (0)