medfall

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

commit f1e829cf0801cc3a94a43eada30bff55d2efff90
parent 1c0cbbccf4781bcde83335c522c414766fc5f6bb
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Aug 31 09:37:17 -0700

Get rid of std::string in bsp module

Diffstat:
bsp.cc | 19++-----------------
bsp.h | 2+-
2 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/bsp.cc b/bsp.cc @@ -1,5 +1,3 @@ -#include <iostream> -#include <fstream> #include <math.h> #include "opengl33.h" @@ -56,21 +54,8 @@ float point_plane_distance( const glm::vec3 point, const glm::vec3 normal, const return glm::dot( point, normal ) - d; } -void bsp_init( BSP * bsp, std::string filename ) { - std::ifstream file( filename.c_str(), std::ifstream::binary ); - - assert( file.is_open() ); - - file.seekg( 0, file.end ); - ssize_t len = file.tellg(); - file.seekg( 0, file.beg ); - - bsp->contents = new char[ len ]; - file.read( bsp->contents, len ); - - assert( ( file.rdstate() & std::ifstream::failbit ) == 0 ); - - file.close(); +void bsp_init( BSP * bsp, const char * filename ) { + bsp->contents = file_get_contents( filename, NULL ); bsp->load_lump( bsp->num_textures, bsp->textures, LUMP_TEXTURES ); bsp->load_lump( bsp->num_planes, bsp->planes, LUMP_PLANES ); diff --git a/bsp.h b/bsp.h @@ -156,7 +156,7 @@ struct BSP_Intersection { class BSP { private: public: // TODO - char * contents; + u8 * contents; u32 num_textures; BSP_Texture * textures;