medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 42fba3605552a459ec81d90785f1315cbfc747df
parent c7d1867abe4419df361b530ed7f3ba751cf54c36
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Aug 31 20:55:12 -0700

Don't crash at the edge of the map

Diffstat:
heightmap.cc | 2+-
terrain_manager.cc | 2++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/heightmap.cc b/heightmap.cc @@ -251,7 +251,7 @@ float Heightmap::bilerp_height( const float x, const float y ) const { } void Heightmap::render() const { - assert( vbo_verts != 0 ); + if( vbo_verts == 0 ) return; glBindVertexArray( vao ); glDrawElements( GL_TRIANGLES, width * height * 6, GL_UNSIGNED_INT, 0 ); diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -72,6 +72,8 @@ static void terrain_load_tile( if( hm->vbo_verts != 0 ) heightmap_destroy( hm ); + if( tx * TILE_SIZE >= tm->width || ty * TILE_SIZE >= tm->height ) return; + CompressedTile ct = tm->compressed_tiles[ tx ][ ty ]; int width, height;