medfall

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

commit 933fa8f562e2dea7d3ee0f258a95c0dd43fa1acc
parent eb22bb81fbae3e775cfd492510e028c9ed0c9e71
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu Dec 29 14:17:32 +0200

Fix some MSVC warnings

Diffstat:
build.bat | 7+++----
hm.cc | 12++++++------
immediate.cc | 24++++++++++++------------
launcher/main.cc | 2+-
main.cc | 10+++++-----
terrain_manager.cc | 46+++++++++++++---------------------------------
6 files changed, 40 insertions(+), 61 deletions(-)
diff --git a/build.bat b/build.bat @@ -16,16 +16,15 @@ @cl immediate.cc -c %FLAGS% @cl log.cc -c %FLAGS% @cl memory_arena.cc -c %FLAGS% -@cl mod_btt.cc -c %FLAGS% @cl lz4.cc -c %FLAGS% @cl lz4hc.cc -c %FLAGS% @cl profiler.cc -c %FLAGS% @cl renderer.cc -c %FLAGS% -@cl sha2.cc -c %FLAGS% +@cl sha2.cc -c %FLAGS% -W0 @cl skybox.cc -c %FLAGS% @cl stats.cc -c %FLAGS% -@cl -Tpstb_image.h -c %FLAGS% -DSTB_IMAGE_IMPLEMENTATION -@cl -Tpstb_truetype.h -c %FLAGS% -DSTB_TRUETYPE_IMPLEMENTATION +@cl -Tpstb_image.h -c %FLAGS% -DSTB_IMAGE_IMPLEMENTATION -W0 +@cl -Tpstb_truetype.h -c %FLAGS% -DSTB_TRUETYPE_IMPLEMENTATION -W0 @cl strlcpy.cc -c %FLAGS% @cl terrain_manager.cc -c %FLAGS% @cl text_renderer.cc -c %FLAGS% diff --git a/hm.cc b/hm.cc @@ -105,8 +105,8 @@ extern "C" GAME_INIT( game_init ) { immediate_init( &game->test_immediate, immediate_memory, triangles ); const float aspect = float( WIDTH ) / float( HEIGHT ); - const float crosshair_thickness = 0.0025; - const float crosshair_length = 0.01; + const float crosshair_thickness = 0.0025f; + const float crosshair_length = 0.01f; const v4 red( 1, 0, 0, 1 ); immediate_triangle( &game->test_immediate, @@ -194,8 +194,8 @@ extern "C" GAME_FRAME( game_frame ) { game->angles.x += pitch * dt * 2; game->angles.y += yaw * dt * 2; - game->angles.x += input->mouse_dy * 0.01; - game->angles.y += input->mouse_dx * 0.01; + game->angles.x += input->mouse_dy * 0.01f; + game->angles.y += input->mouse_dx * 0.01f; const float dsun = ( input->keys[ KEY_EQUALS ] - input->keys[ KEY_MINUS ] ) * dt; game->test_sun += dsun; @@ -206,7 +206,7 @@ extern "C" GAME_FRAME( game_frame ) { game->pos += angles_to_vector_xy( game->angles ) * speed * dt * ( float ) fb; const v3 sideways = v3( -cosf( game->angles.y ), sinf( game->angles.y ), 0 ); game->pos += sideways * speed * dt * ( float ) lr; - // game->pos.z = terrain_height( &game->tm, game->pos ) + 2; + // game->pos.z = terrain_height( &game->tm, game->pos ) + 1.8f; game->pos.z += dz * 50.0f * dt; terrain_update( &game->tm, game->pos ); @@ -285,7 +285,7 @@ extern "C" GAME_FRAME( game_frame ) { immediate_init( &imm, asdf, ARRAY_COUNT( asdf ) ); for( Explosion * explosion : explosions ) { - float t = current_time - explosion->created_at; + float t = float( current_time - explosion->created_at ); if( t < 0.5f ) { immediate_sphere( &imm, explosion->pos, t * 32.0f, v4( 1, 0.5, 0, 1 ) ); } diff --git a/immediate.cc b/immediate.cc @@ -40,8 +40,8 @@ void immediate_sphere( ImmediateContext * ctx, v3 centre, float radius, v4 colour, u32 subdivisions ) { - const float azimuth_max = 2.0f * M_PI; - const float pitch_max = M_PI; + const float azimuth_max = 2.0f * float( M_PI ); + const float pitch_max = float( M_PI ); const float dsa = sinf( 0.5f * azimuth_max / ( subdivisions - 1 ) ); const float dca = cosf( 0.5f * azimuth_max / ( subdivisions - 1 ) ); @@ -126,15 +126,15 @@ void immediate_aabb( ImmediateContext * ctx, v3 mins, v3 maxs, v4 colour ) { static m3 about_with_sin_cos( v3 axis, float s, float c ) { return m3( - axis.x * axis.x + ( 1.0 - axis.x * axis.x ) * c, - axis.x * axis.y * ( 1.0 - c ) - axis.z * s, - axis.x * axis.z * ( 1.0 - c ) + axis.y * s, - axis.y * axis.x * ( 1.0 - c ) + axis.z * s, - axis.y * axis.y + ( 1.0 - axis.y * axis.y ) * c, - axis.y * axis.z * ( 1.0 - c ) - axis.x * s, - axis.z * axis.x * ( 1.0 - c ) - axis.y * s, - axis.z * axis.y * ( 1.0 - c ) + axis.x * s, - axis.z * axis.z + ( 1.0 - axis.z * axis.z ) * c + axis.x * axis.x + ( 1.0f - axis.x * axis.x ) * c, + axis.x * axis.y * ( 1.0f - c ) - axis.z * s, + axis.x * axis.z * ( 1.0f - c ) + axis.y * s, + axis.y * axis.x * ( 1.0f - c ) + axis.z * s, + axis.y * axis.y + ( 1.0f - axis.y * axis.y ) * c, + axis.y * axis.z * ( 1.0f - c ) - axis.x * s, + axis.z * axis.x * ( 1.0f - c ) - axis.y * s, + axis.z * axis.y * ( 1.0f - c ) + axis.x * s, + axis.z * axis.z + ( 1.0f - axis.z * axis.z ) * c ); } @@ -181,7 +181,7 @@ void immediate_arrow( float s = sinf( float( i ) / float( ARRAY_COUNT( cone ) ) * 2.0f * M_PI ); float c = cosf( float( i ) / float( ARRAY_COUNT( cone ) ) * 2.0f * M_PI ); - cone[ i ] = v3( 0.2f * c, 0.2f * s, 0.6 ); + cone[ i ] = v3( 0.2f * c, 0.2f * s, 0.6f ); } m3 rot = rotation_between( v3( 0, 0, 1 ), normalize( direction ) ); diff --git a/launcher/main.cc b/launcher/main.cc @@ -105,7 +105,7 @@ static bool already_downloaded( const std::string & path, const ManifestEntry & SCOPE_EXIT( fclose( file ) ); fseek( file, 0, SEEK_END ); - u64 file_size = checked_cast< u64 >( ftell( file ) ); + u32 file_size = checked_cast< u32 >( ftell( file ) ); fseek( file, 0, SEEK_SET ); if( file_size != entry.file_size ) return false; diff --git a/main.cc b/main.cc @@ -122,8 +122,8 @@ int main( int argc, char ** argv ) { glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED ); - const float program_start_time = glfwGetTime(); - float last_frame_time = program_start_time; + const double program_start_time = glfwGetTime(); + double last_frame_time = program_start_time; u64 total_frames = 0; _MM_SET_DENORMALS_ZERO_MODE( _MM_DENORMALS_ZERO_ON ); @@ -133,8 +133,8 @@ int main( int argc, char ** argv ) { double last_ypos = 0.0; while( !glfwWindowShouldClose( window ) ) { - const float current_frame_time = glfwGetTime(); - const float dt = current_frame_time - last_frame_time; + const double current_frame_time = glfwGetTime(); + const float dt = float( current_frame_time - last_frame_time ); if( glfwGetKey( window, GLFW_KEY_Q ) == GLFW_PRESS || glfwGetKey( window, GLFW_KEY_ESCAPE ) == GLFW_PRESS ) { break; @@ -199,7 +199,7 @@ int main( int argc, char ** argv ) { } } - const float program_run_time = glfwGetTime() - program_start_time; + const double program_run_time = glfwGetTime() - program_start_time; #if !STATIC_GAME unload_game( &game ); diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -307,8 +307,8 @@ void terrain_teleport( TerrainManager * tm, v3 position ) { tm->first_teleport = false; - s32 player_tile_x = position.x / TILE_SIZE; - s32 player_tile_y = position.y / TILE_SIZE; + s32 player_tile_x = s32( position.x / TILE_SIZE ); + s32 player_tile_y = s32( position.y / TILE_SIZE ); tm->tile_x = player_tile_x; tm->tile_y = player_tile_y; @@ -322,27 +322,9 @@ void terrain_teleport( TerrainManager * tm, v3 position ) { } } -static u8 terrain_tile_lod( - s32 player_tile_x, s32 player_tile_y, - s32 tx, s32 ty -) { - u16 manhattan_distance = abs( player_tile_x - tx ) - + abs( player_tile_y - ty ); - return min( ( u16 ) 8, manhattan_distance ); -} - -static void terrain_update_lods( TerrainManager * tm ) { - for( u16 tx = 0; tx < WORLD_SIZE; tx++ ) { - for( u16 ty = 0; ty < WORLD_SIZE; ty++ ) { - tm->lods[ tx ][ ty ] = terrain_tile_lod( - tm->tile_x, tm->tile_y, tx, ty ); - } - } -} - void terrain_update( TerrainManager * tm, v3 position ) { - s32 player_tile_x = position.x / TILE_SIZE; - s32 player_tile_y = position.y / TILE_SIZE; + s32 player_tile_x = s32( position.x / TILE_SIZE ); + s32 player_tile_y = s32( position.y / TILE_SIZE ); if( player_tile_x != tm->tile_x ) { if( player_tile_x > tm->tile_x ) { @@ -398,8 +380,6 @@ void terrain_update( TerrainManager * tm, v3 position ) { } tm->tile_y--; } - - terrain_update_lods( tm ); } } @@ -491,8 +471,8 @@ float terrain_height( const TerrainManager * tm, v3 position ) { assert( position.x < tm->width ); assert( position.y < tm->height ); - s32 tx = position.x / TILE_SIZE; - s32 ty = position.y / TILE_SIZE; + s32 tx = s32( position.x / TILE_SIZE ); + s32 ty = s32( position.y / TILE_SIZE ); if( tm->tile_states[ tx ][ ty ] != TILE_LOADED ) { return 0.0f; @@ -530,16 +510,16 @@ static T bilerp( const array2d< T > arr, float x, float y ) { } v3 terrain_normal( const TerrainManager * tm, v3 position ) { - assert( position.x >= 0 ); - assert( position.y >= 0 ); - assert( position.x < tm->width ); - assert( position.y < tm->height ); + ASSERT( position.x >= 0 ); + ASSERT( position.y >= 0 ); + ASSERT( position.x < tm->width ); + ASSERT( position.y < tm->height ); - s32 tx = position.x / TILE_SIZE; - s32 ty = position.y / TILE_SIZE; + s32 tx = s32( position.x / TILE_SIZE ); + s32 ty = s32( position.y / TILE_SIZE ); if( tm->tile_states[ tx ][ ty ] != TILE_LOADED ) { - return v3( 0, 0, 1 ); + return v3( 0.0f, 0.0f, 1.0f ); } const array2d< v3 > normalmap( tm->decompressed_tiles[ tx ][ ty ].normalmap, TILE_SIZE + 1, TILE_SIZE + 1 );