- fixed: Checking the terrain for any texture that was created after initializing the terrain data either returned random garbage or could even create an access violation. Added a range check to the array access function to prevent this.

This commit is contained in:
Christoph Oelckers 2014-12-25 20:43:40 +01:00
parent 1a39ac9243
commit a5a17e45cf

View file

@ -49,11 +49,13 @@ public:
WORD operator [](FTextureID tex) const WORD operator [](FTextureID tex) const
{ {
if ((unsigned)tex.GetIndex() >= Types.Size()) return DefaultTerrainType;
WORD type = Types[tex.GetIndex()]; WORD type = Types[tex.GetIndex()];
return type == 0xffff? DefaultTerrainType : type; return type == 0xffff? DefaultTerrainType : type;
} }
WORD operator [](int texnum) const WORD operator [](int texnum) const
{ {
if ((unsigned)texnum >= Types.Size()) return DefaultTerrainType;
WORD type = Types[texnum]; WORD type = Types[texnum];
return type == 0xffff? DefaultTerrainType : type; return type == 0xffff? DefaultTerrainType : type;
} }