mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- made the tile size getters a bit more robust.
They should not crash on invalid sprites.
This commit is contained in:
parent
d2c9b5979d
commit
cd58b1d055
2 changed files with 11 additions and 7 deletions
|
@ -820,7 +820,7 @@ void tileUpdateAnimations()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAXTILES; i++)
|
for (int i = 0; i < MAXTILES; i++)
|
||||||
{
|
{
|
||||||
if (picanm[i].sf & PICANM_ANIMTYPE_MASK)
|
if (TileFiles.tiledata[i].picanm.sf & PICANM_ANIMTYPE_MASK)
|
||||||
{
|
{
|
||||||
int j = i + animateoffs(i, 0);
|
int j = i + animateoffs(i, 0);
|
||||||
|
|
||||||
|
|
|
@ -407,25 +407,29 @@ extern PicAnm picanm;
|
||||||
|
|
||||||
inline int tileWidth(int num)
|
inline int tileWidth(int num)
|
||||||
{
|
{
|
||||||
assert(num < MAXTILES);
|
assert((unsigned)num < MAXTILES);
|
||||||
|
if ((unsigned)num >= MAXTILES) return 1;
|
||||||
return (int)TileFiles.tiledata[num].texture->GetDisplayWidth();
|
return (int)TileFiles.tiledata[num].texture->GetDisplayWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int tileHeight(int num)
|
inline int tileHeight(int num)
|
||||||
{
|
{
|
||||||
assert(num < MAXTILES);
|
assert((unsigned)num < MAXTILES);
|
||||||
|
if ((unsigned)num >= MAXTILES) return 1;
|
||||||
return (int)TileFiles.tiledata[num].texture->GetDisplayHeight();
|
return (int)TileFiles.tiledata[num].texture->GetDisplayHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int tileLeftOffset(int num)
|
inline int tileLeftOffset(int num)
|
||||||
{
|
{
|
||||||
assert(num < MAXTILES);
|
assert((unsigned)num < MAXTILES);
|
||||||
|
if ((unsigned)num >= MAXTILES) return 0;
|
||||||
return (int)TileFiles.tiledata[num].texture->GetDisplayLeftOffset();
|
return (int)TileFiles.tiledata[num].texture->GetDisplayLeftOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int tileTopOffset(int num)
|
inline int tileTopOffset(int num)
|
||||||
{
|
{
|
||||||
assert(num < MAXTILES);
|
assert((unsigned)num < MAXTILES);
|
||||||
|
if ((unsigned)num >= MAXTILES) return 0;
|
||||||
return (int)TileFiles.tiledata[num].texture->GetDisplayTopOffset();
|
return (int)TileFiles.tiledata[num].texture->GetDisplayTopOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,11 +444,11 @@ int32_t animateoffs(int const tilenum, int fakevar);
|
||||||
|
|
||||||
inline FGameTexture* tileGetTexture(int tile, bool animate = false)
|
inline FGameTexture* tileGetTexture(int tile, bool animate = false)
|
||||||
{
|
{
|
||||||
assert(tile < MAXTILES);
|
assert((unsigned)tile < MAXTILES);
|
||||||
if (tile < 0 || tile >= MAXTILES) return nullptr;
|
if (tile < 0 || tile >= MAXTILES) return nullptr;
|
||||||
if (animate)
|
if (animate)
|
||||||
{
|
{
|
||||||
if (picanm[tile].sf & PICANM_ANIMTYPE_MASK)
|
if (TileFiles.tiledata[tile].picanm.sf & PICANM_ANIMTYPE_MASK)
|
||||||
tile += animateoffs(tile, 0);
|
tile += animateoffs(tile, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue