- check for invalid tiles being passed to the 2D renderer.

Since mods can actually replace valid tiles with invalid ones, the low level render code needs to check this case.
This commit is contained in:
Christoph Oelckers 2021-01-27 23:52:40 +01:00
parent 8cf3e50ade
commit 3163e4a799
2 changed files with 6 additions and 4 deletions

View file

@ -114,8 +114,8 @@ void GLInstance::DoDraw()
for (auto& rs : rendercommands)
{
rs.Apply(*screen->RenderState(), lastState);
screen->RenderState()->Draw(rs.primtype, rs.vindex, rs.vcount);
if (rs.Apply(*screen->RenderState(), lastState))
screen->RenderState()->Draw(rs.primtype, rs.vindex, rs.vcount);
}
renderState.Apply(*screen->RenderState(), lastState); // apply any pending change before returning.
rendercommands.Clear();
@ -151,7 +151,7 @@ void GLInstance::SetFade(int index)
renderState.FogColor = 0;
}
void PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
bool PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
{
if (Flags & RF_ColorOnly)
{
@ -159,6 +159,7 @@ void PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
}
else
{
if (!mMaterial.mTexture) return false; // Oh no! Something passed an invalid tile!
state.EnableTexture(gl_texture);
state.SetMaterial(mMaterial.mTexture, mMaterial.uFlags, mMaterial.mScaleFlags, mMaterial.mClampMode, mMaterial.mTranslation, mMaterial.mOverrideShader);
}
@ -254,6 +255,7 @@ void PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
else state.EnableModelMatrix(false);
memset(matrixIndex, -1, sizeof(matrixIndex));
return true;
}
void DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width, int height, bool upsidedown)

View file

@ -89,5 +89,5 @@ struct PolymostRenderState
PalEntry FogColor;
void Apply(FRenderState & state, GLState& oldState);
bool Apply(FRenderState & state, GLState& oldState);
};