medfall

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

commit 671dc48ddc31000c7b8e03a3f0346bc2c824f12c
parent b053e61d09efaa77d0343b337fc7af09cf8e0b7e
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Dec 15 19:35:20 +0000

constexpr -> macros, nullptr -> NULL

Diffstat:
btt.cc | 2+-
gl.cc | 4++--
intrinsics.h | 20+++++---------------
linux_audio.cc | 2+-
main.cc | 8++++----
platform_opengl.h | 2+-
pp.cc | 2+-
terrain_manager.cc | 2+-
unix_thread.cc | 2+-
9 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/btt.cc b/btt.cc @@ -233,7 +233,7 @@ extern "C" GAME_INIT( game_init ) { state->test_outline_un_vp = glGetUniformLocation( state->test_outline_shader, "vp" ); int w, h; - u8 * pixels = stbi_load( "terrains/mountains512.png", &w, &h, nullptr, 1 ); + u8 * pixels = stbi_load( "terrains/mountains512.png", &w, &h, NULL, 1 ); heightmap_init( &state->hm, &mem->persistent_arena, pixels, w, h, 0, 0, state->test_at_position, state->test_at_normal, state->test_at_lit ); diff --git a/gl.cc b/gl.cc @@ -85,7 +85,7 @@ GLFWwindow * gl_init() { glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 ); glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 2 ); - GLFWwindow * const window = glfwCreateWindow( WIDTH, HEIGHT, "bsp", nullptr, nullptr ); + GLFWwindow * const window = glfwCreateWindow( WIDTH, HEIGHT, "bsp", NULL, NULL ); if( !window ) { errx( 1, "glfwCreateWindow" ); } @@ -100,7 +100,7 @@ GLFWwindow * gl_init() { } glEnable( GL_DEBUG_OUTPUT ); - glDebugMessageCallback( gl_error_printer, nullptr ); + glDebugMessageCallback( gl_error_printer, NULL ); #endif warnx( "Version %s", glGetString( GL_VERSION ) ); diff --git a/intrinsics.h b/intrinsics.h @@ -31,17 +31,9 @@ typedef double f64; // TODO: clashes with some crap in std::string #define align_TODO( n, alignment ) ( ( ( n ) + ( alignment ) - 1 ) / ( alignment ) * ( alignment ) ) -inline constexpr size_t kilobytes( const size_t kb ) { - return kb * 1024; -} - -inline constexpr size_t megabytes( const size_t mb ) { - return kilobytes( mb ) * 1024; -} - -inline constexpr size_t gigabytes( const size_t gb ) { - return megabytes( gb ) * 1024; -} +#define kilobytes( kb ) ( size_t( kb ) * size_t( 1024 ) ) +#define megabytes( mb ) ( kilobytes( mb ) * size_t( 1024 ) ) +#define gigabytes( gb ) ( megabytes( gb ) * size_t( 1024 ) ) inline float max_f( float a, float b ) { return a > b ? a : b; @@ -74,7 +66,7 @@ inline void mike_assert( const bool predicate, const char * const message ) { #define assert( predicate ) mike_assert( predicate, "\e[1;31massertion failed at " __FILE__ " line " STRINGIFY( __LINE__ ) ": \e[0;1m" #predicate "\e[0m" ) // TODO: this sucks -inline u8 * file_get_contents( const char * const path, size_t * const out_len = nullptr ) { +inline u8 * file_get_contents( const char * const path, size_t * const out_len = NULL ) { FILE * const file = fopen( path, "rb" ); assert( file ); @@ -88,9 +80,7 @@ inline u8 * file_get_contents( const char * const path, size_t * const out_len = contents[ len ] = '\0'; assert( bytes_read == len ); - if( out_len ) { - *out_len = len; - } + if( out_len ) *out_len = len; fclose( file ); diff --git a/linux_audio.cc b/linux_audio.cc @@ -126,7 +126,7 @@ int main( int argc, char ** argv ) { Thread mix_thread; thread_init( &mix_thread, mix_worker, pcm ); - char * line = nullptr; + char * line = NULL; size_t n; float volume = 0.1f; diff --git a/main.cc b/main.cc @@ -41,8 +41,8 @@ static Game load_game( const char * const path ) { if( !game.init || !game.frame ) { warnx( "load_game: couldn't find game functions (init = %p, frame = %p)", game.init, game.frame ); - game.init = nullptr; - game.frame = nullptr; + game.init = NULL; + game.frame = NULL; } } @@ -61,8 +61,8 @@ static void unload_game( Game * game ) { dlclose( game->lib ); } - game->init = nullptr; - game->frame = nullptr; + game->init = NULL; + game->frame = NULL; } static bool should_reload_game( const char * const path, const time_t lib_write_time ) { diff --git a/platform_opengl.h b/platform_opengl.h @@ -51,7 +51,7 @@ inline void show_info_log( glGet__iv(object, GL_INFO_LOG_LENGTH, &log_length); log = ( char * ) malloc(log_length); - glGet__InfoLog(object, log_length, nullptr, log); + glGet__InfoLog(object, log_length, NULL, log); fprintf(stderr, "%s", log); free(log); } diff --git a/pp.cc b/pp.cc @@ -39,7 +39,7 @@ void write_tile( const std::string & dir, const int tx, const int ty ) { int main( int argc, char ** argv ) { const std::string path = argc == 2 ? argv[ 1 ] : "terrains/mountains512.png"; - pixels = stbi_load( path.c_str(), &w, &h, nullptr, 1 ); + pixels = stbi_load( path.c_str(), &w, &h, NULL, 1 ); const std::string dir = path + ".parts"; diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -76,7 +76,7 @@ static void terrain_load_tile( assert( contents ); int width, height; - u8 * pixels = stbi_load_from_memory( contents, len, &width, &height, nullptr, 1 ); + u8 * pixels = stbi_load_from_memory( contents, len, &width, &height, NULL, 1 ); free( contents ); if( !pixels ) err( 1, "stbi_load failed (%s)", stbi_failure_reason() ); diff --git a/unix_thread.cc b/unix_thread.cc @@ -6,7 +6,7 @@ struct Thread { }; inline void thread_init( Thread * thread, void * callback( void * ), void * data ) { - const int ok = pthread_create( &thread->pthread, nullptr, callback, data ); + const int ok = pthread_create( &thread->pthread, NULL, callback, data ); if( ok == -1 ) { err( 1, "pthread_create failed" ); }