medfall

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

commit ba5a4de3be0f766c1f85f1a3898fd1a256a53744
parent f59dee8c863c5cccd4e168906b165f4637c7de9b
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Nov 20 10:33:56 +0200

array_count -> ARRAY_COUNT

Diffstat:
hm.cc | 2+-
immediate.cc | 18+++++++++---------
intrinsics.h | 1-
mod_btt.cc | 6+++---
rng/fixed.cc | 2+-
server/main.cc | 4++--
shadow_map.cc | 2+-
skybox.cc | 2+-
work_queue.cc | 6+++---
9 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/hm.cc b/hm.cc @@ -216,7 +216,7 @@ static void draw_string( const GameState * game, ImmediateContext imm; ImmediateTriangle triangles[ 256 ]; - immediate_init( &imm, triangles, array_count( triangles ) ); + immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); glBindTexture( GL_TEXTURE_2D, game->assets[ ASSET_FONT ].texture ); diff --git a/immediate.cc b/immediate.cc @@ -177,19 +177,19 @@ void immediate_arrow( // TODO: do the fast sin/cos thing // TODO: make a helper function to do it that fills in an array of floats - for( size_t i = 0; i < array_count( cone ); i++ ) { - 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 ); + for( size_t i = 0; i < ARRAY_COUNT( cone ); i++ ) { + 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 ); } m3 rot = rotation_between( v3( 0, 0, 1 ), normalize( direction ) ); - for( size_t i = 0; i < array_count( v ); i++ ) { + for( size_t i = 0; i < ARRAY_COUNT( v ); i++ ) { v[ i ] = ( rot * v[ i ] ) * length + origin; } - for( size_t i = 0; i < array_count( cone ); i++ ) { + for( size_t i = 0; i < ARRAY_COUNT( cone ); i++ ) { cone[ i ] = ( rot * cone[ i ] ) * length + origin; } @@ -206,12 +206,12 @@ void immediate_arrow( immediate_triangle( ctx, v[ 3 ], v[ 7 ], v[ 2 ], colour ); // back immediate_triangle( ctx, v[ 7 ], v[ 6 ], v[ 2 ], colour ); - for( size_t i = 0; i < array_count( cone ); i++ ) { - immediate_triangle( ctx, v[ 8 ], cone[ ( i + 1 ) % array_count( cone ) ], cone[ i ], colour ); + for( size_t i = 0; i < ARRAY_COUNT( cone ); i++ ) { + immediate_triangle( ctx, v[ 8 ], cone[ ( i + 1 ) % ARRAY_COUNT( cone ) ], cone[ i ], colour ); } - for( size_t i = 0; i < array_count( cone ); i++ ) { - immediate_triangle( ctx, v[ 9 ], cone[ i ], cone[ ( i + 1 ) % array_count( cone ) ], colour ); + for( size_t i = 0; i < ARRAY_COUNT( cone ); i++ ) { + immediate_triangle( ctx, v[ 9 ], cone[ i ], cone[ ( i + 1 ) % ARRAY_COUNT( cone ) ], colour ); } } diff --git a/intrinsics.h b/intrinsics.h @@ -39,7 +39,6 @@ typedef uintptr_t uptr; template< typename T, size_t N > char ( &ArrayCountObj( const T ( & )[ N ] ) )[ N ]; #define ARRAY_COUNT( arr ) ( sizeof( ArrayCountObj( arr ) ) ) -#define array_count ARRAY_COUNT #define is_power_of_2( n ) ( ( ( n ) & ( ( n ) - 1 ) ) == 0 ) diff --git a/mod_btt.cc b/mod_btt.cc @@ -264,7 +264,7 @@ extern "C" GAME_FRAME( game_frame ) { render_state.ubs[ UB_FS_HOT ] = ub_fs; gpubtt_render( &game->gpubtt, render_state ); - immediate_init( &imm, triangles, array_count( triangles ) ); + immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); for( size_t i = 0; i < game->hm.width; i++ ) { v3 origin = v3( i, 1, game->hm.point( i, 1 ).z ); v3 direction = normalize( v3( -1, 0, horizons[ 1 * game->hm.width + i ] ) ); @@ -283,7 +283,7 @@ extern "C" GAME_FRAME( game_frame ) { else printf( "nope\n" ); immediate_render( &imm, game->test_outline_at_position, game->test_outline_at_colour ); - immediate_init( &imm, triangles, array_count( triangles ) ); + immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); v3u32 mins = v3u32( 0, 0, qt.nodes[ 0 ].min_z ); v3u32 maxs = v3u32( qt.dim, qt.dim, qt.nodes[ 0 ].max_z ); draw_qt( &imm, AABBu32( mins, maxs ), qt.nodes, 0 ); @@ -292,7 +292,7 @@ extern "C" GAME_FRAME( game_frame ) { glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glUseProgram( 0 ); - // immediate_init( &imm, triangles, array_count( triangles ) ); + // immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); // draw_btt( game->btt.left_root, &game->hm, &imm, glm::ivec2( 0, 0 ), glm::ivec2( 0, game->hm.height - 1 ), glm::ivec2( game->hm.width - 1, game->hm.height - 1 ) ); // draw_btt( game->btt.right_root, &game->hm, &imm, glm::ivec2( game->hm.width - 1, game->hm.height - 1 ), glm::ivec2( game->hm.width - 1, 0 ), glm::ivec2( 0, 0 ) ); diff --git a/rng/fixed.cc b/rng/fixed.cc @@ -21,7 +21,7 @@ void rng_fixed_init( RNGFixed * rng ) { u32 rng_fixed_next( RNGFixed * rng ) { u32 ret = nums[ rng->index ]; - rng->index = ( rng->index + 1 ) % array_count( nums ); + rng->index = ( rng->index + 1 ) % ARRAY_COUNT( nums ); return ret; } diff --git a/server/main.cc b/server/main.cc @@ -141,7 +141,7 @@ int main() { RNGWell512 rng; rng_well512_init( &rng ); - for( size_t i = 0; i < array_count( states ); i++ ) { + for( size_t i = 0; i < ARRAY_COUNT( states ); i++ ) { states[ i ].pos = 0; states[ i ].next_free = u16( i + 1 ); states[ i ].connected = false; @@ -177,7 +177,7 @@ int main() { while( receive( server_fd_ipv6, buf, &len, sizeof( buf ) ) ); printf( "frame\n" ); - for( size_t i = 0; i < array_count( states ); i++ ) { + for( size_t i = 0; i < ARRAY_COUNT( states ); i++ ) { if( states[ i ].connected ) { printf( "%zu: %d\n", i, states[ i ].pos ); } diff --git a/shadow_map.cc b/shadow_map.cc @@ -74,7 +74,7 @@ static const char * depth_frag_src = GLSL( ); static void draw_scene( GLint at_position, GLint at_colour ) { - immediate_init( &imm, triangles, array_count( triangles ) ); + immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); immediate_sphere( &imm, v3( 0, 0, 5 ), 3, v4( 1, 0, 0, 1 ) ); immediate_sphere( &imm, v3( -3, 7, 5 ), 2, v4( 0, 1, 0, 1 ) ); diff --git a/skybox.cc b/skybox.cc @@ -90,7 +90,7 @@ void skybox_render( const Skybox * skybox, const glm::vec3 & angles ) { glUniformMatrix4fv( skybox->un_v, 1, GL_FALSE, glm::value_ptr( V ) ); - glDrawElements( GL_TRIANGLE_STRIP, array_count( cube_indices ), GL_UNSIGNED_INT, 0 ); + glDrawElements( GL_TRIANGLE_STRIP, ARRAY_COUNT( cube_indices ), GL_UNSIGNED_INT, 0 ); glBindVertexArray( 0 ); glUseProgram( 0 ); diff --git a/work_queue.cc b/work_queue.cc @@ -20,7 +20,7 @@ static bool workqueue_step( u32 thread_id, WorkQueue * queue ) { if( current_head != load_acquire( &queue->tail ) ) { if( compare_exchange_acqrel( &queue->head, &current_head, new_head ) ) { - const Job & job = queue->jobs[ current_head % array_count( queue->jobs ) ]; + const Job & job = queue->jobs[ current_head % ARRAY_COUNT( queue->jobs ) ]; job.callback( job.data, &queue->arenas[ thread_id ] ); } @@ -84,11 +84,11 @@ void workqueue_enqueue( WorkQueue * queue, WorkQueueCallback * callback, const v callback( data, &queue->arenas[ 0 ] ); #else u32 tail = fetch_add_release( &queue->tail, 1 ); - assert( tail - load_acquire( &queue->head ) < array_count( queue->jobs ) - 1 ); + assert( tail - load_acquire( &queue->head ) < ARRAY_COUNT( queue->jobs ) - 1 ); Job job = { callback, data }; - queue->jobs[ tail % array_count( queue->jobs ) ] = job; + queue->jobs[ tail % ARRAY_COUNT( queue->jobs ) ] = job; semaphore_signal( &queue->sem ); #endif