change list_size to ARRAY_LEN menu2
authorhgn <hgodden00@gmail.com>
Fri, 6 Sep 2024 03:26:42 +0000 (04:26 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 6 Sep 2024 03:26:42 +0000 (04:26 +0100)
31 files changed:
addon.c
audio.c
client.c
ent_relay.c
ent_skateshop.c
entity.c
gui.h
menu.c
model.c
network.c
particle.c
player.c
player_glide.c
player_ragdoll.c
player_remote.c
player_replay.c
player_skate.c
render.c
scene.c
skaterift.c
steam.c
trail.c
workshop.c
world.c
world_entity.c
world_gate.c
world_gen.c
world_load.c
world_render.c
world_routes.c
world_volumes.c

diff --git a/addon.c b/addon.c
index 34e16f8e42b995a3028bec2f655dd551d2475cd8..6769b5a2d35dcfbd97e3529f224b670259ccdb41 100644 (file)
--- a/addon.c
+++ b/addon.c
@@ -486,7 +486,7 @@ void addon_mount_workshop_items(void)
       struct async_workshop_filepath_info *info = call1->payload;
       info->buf = path;
       info->id = id;
-      info->len = vg_list_size(path);
+      info->len = VG_ARRAY_LEN(path);
       vg_async_dispatch( call1, async_workshop_get_filepath );
       vg_async_stall(); /* too bad! */
 
diff --git a/audio.c b/audio.c
index a5080cd526674040ba03d2d6cb49ac8475ce420c..dda8a2d033314a2ec3f10208b1db1008ea2c49ec 100644 (file)
--- a/audio.c
+++ b/audio.c
@@ -180,28 +180,28 @@ static audio_clip air_synth = {
 
 void audio_init(void)
 {
-   audio_clip_loadn( audio_board, vg_list_size(audio_board), NULL );
-   audio_clip_loadn( audio_taps, vg_list_size(audio_taps), NULL );
-   audio_clip_loadn( audio_flips, vg_list_size(audio_flips), NULL );
-   audio_clip_loadn( audio_hits, vg_list_size(audio_hits), NULL );
-   audio_clip_loadn( audio_ambience, vg_list_size(audio_ambience), NULL );
+   audio_clip_loadn( audio_board, VG_ARRAY_LEN(audio_board), NULL );
+   audio_clip_loadn( audio_taps, VG_ARRAY_LEN(audio_taps), NULL );
+   audio_clip_loadn( audio_flips, VG_ARRAY_LEN(audio_flips), NULL );
+   audio_clip_loadn( audio_hits, VG_ARRAY_LEN(audio_hits), NULL );
+   audio_clip_loadn( audio_ambience, VG_ARRAY_LEN(audio_ambience), NULL );
    audio_clip_loadn( &audio_splash, 1, NULL );
    audio_clip_loadn( &audio_gate_pass, 1, NULL );
    audio_clip_loadn( &audio_gate_lap, 1, NULL );
    audio_clip_loadn( &audio_gate_ambient, 1, NULL );
 
-   audio_clip_loadn( audio_jumps, vg_list_size(audio_jumps), NULL );
-   audio_clip_loadn( audio_lands, vg_list_size(audio_lands), NULL );
-   audio_clip_loadn( audio_water, vg_list_size(audio_water), NULL );
-   audio_clip_loadn( audio_grass, vg_list_size(audio_grass), NULL );
-   audio_clip_loadn( audio_footsteps, vg_list_size(audio_footsteps), NULL );
+   audio_clip_loadn( audio_jumps, VG_ARRAY_LEN(audio_jumps), NULL );
+   audio_clip_loadn( audio_lands, VG_ARRAY_LEN(audio_lands), NULL );
+   audio_clip_loadn( audio_water, VG_ARRAY_LEN(audio_water), NULL );
+   audio_clip_loadn( audio_grass, VG_ARRAY_LEN(audio_grass), NULL );
+   audio_clip_loadn( audio_footsteps, VG_ARRAY_LEN(audio_footsteps), NULL );
    audio_clip_loadn( audio_footsteps_grass, 
-                     vg_list_size(audio_footsteps_grass), NULL );
+                     VG_ARRAY_LEN(audio_footsteps_grass), NULL );
    audio_clip_loadn( audio_footsteps_wood, 
-                     vg_list_size(audio_footsteps_wood), NULL );
-   audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind), NULL );
-   audio_clip_loadn( audio_ui, vg_list_size(audio_ui), NULL );
-   audio_clip_loadn( audio_challenge, vg_list_size(audio_challenge), NULL );
+                     VG_ARRAY_LEN(audio_footsteps_wood), NULL );
+   audio_clip_loadn( audio_rewind, VG_ARRAY_LEN(audio_rewind), NULL );
+   audio_clip_loadn( audio_ui, VG_ARRAY_LEN(audio_ui), NULL );
+   audio_clip_loadn( audio_challenge, VG_ARRAY_LEN(audio_challenge), NULL );
 
    audio_lock();
    audio_set_lfo_wave( 0, k_lfo_polynomial_bipolar, 80.0f );
index b958425e815ad9b6bd38a173471d71136656fc7a..e06c2538d3e50191e527f544c1a4a0ad9773520b 100644 (file)
--- a/client.c
+++ b/client.c
@@ -10,6 +10,8 @@
 #include "player_remote.h"
 #include "menu.h"
 
+const char* __asan_default_options() { return "detect_leaks=0"; }
+
 struct game_client g_client = 
 {
    .demo_mode = 1
@@ -77,7 +79,7 @@ void vg_launch_opt(void)
 int main( int argc, char *argv[] )
 {
    network_set_host( "skaterift.com", NULL );
-   vg_mem.use_libc_malloc = 0;
+   vg_mem.use_libc_malloc = 1;
    vg_set_mem_quota( 160*1024*1024 );
    vg_enter( argc, argv, "Voyager Game Engine" ); 
    return 0;
index 1f97584af5843f1b0384a73f9dde4bfc3be5339b..b22b0b59634eae9049294c52fedc2ec237f2a488 100644 (file)
@@ -7,7 +7,7 @@ entity_call_result ent_relay_call( world_instance *world, ent_call *call )
 
    if( call->function == 0 )
    {
-      for( u32 i=0; i<vg_list_size(relay->targets); i++ )
+      for( u32 i=0; i<VG_ARRAY_LEN(relay->targets); i++ )
       {
          if( relay->targets[i][0] )
          {
index f2b4a176448c1e64b589e0093bb223bf4b4a4bb8..ded707c1064da2296db3a7152b04bc9bbc6855c4 100644 (file)
@@ -445,7 +445,7 @@ void skateshop_world_preupdate( world_instance *world )
 
 static void skateshop_render_boardshop( ent_skateshop *shop ){
    world_instance *world = world_current_instance();
-   u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
+   u32 slot_count = VG_ARRAY_LEN(global_skateshop.shop_view_slots);
 
    ent_marker *mark_rack = mdl_arritm( &world->ent_marker, 
                                   mdl_entity_id_id(shop->boards.id_rack)),
@@ -733,7 +733,7 @@ void skateshop_render_nonfocused( world_instance *world, vg_camera *cam )
       if( !mark_rack ) 
          continue;
 
-      u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
+      u32 slot_count = VG_ARRAY_LEN(global_skateshop.shop_view_slots);
       for( u32 i=0; i<slot_count; i++ )
       {
          struct player_board *board = &localplayer.fallback_board;
index ffb5deed5d9c0c9e905e1c39335b80c8173e04fe..797e29d2361687ef12a0be35ac95253829915a44 100644 (file)
--- a/entity.c
+++ b/entity.c
@@ -37,7 +37,7 @@ void entity_call( world_instance *world, ent_call *call )
       [k_ent_water]     = ent_water_call,
    };
 
-   if( type >= vg_list_size(table) ){
+   if( type >= VG_ARRAY_LEN(table) ){
       vg_error( "call to entity type: %u is out of range\n", type );
       return;
    }
diff --git a/gui.h b/gui.h
index 3823c152156ed419e51ac68b64581f1a820cb7a0..46e2e1ecf72344ae6cb7f6ed317903f6efe84cc8 100644 (file)
--- a/gui.h
+++ b/gui.h
@@ -78,7 +78,7 @@ static void gui_helper_clear(void){
 }
 
 static struct gui_helper *gui_new_helper( vg_input_op *bind, vg_str *out_text ){
-   if( gui.helper_count >= vg_list_size(gui.helpers) ){
+   if( gui.helper_count >= VG_ARRAY_LEN(gui.helpers) ){
       vg_error( "Too many helpers\n" );
       return NULL;
    }
@@ -283,7 +283,7 @@ static int gui_showtrick_ccmd( int argc, const char *argv[] )
 
 static void gui_draw_icon( enum gui_icon icon, v2f co, f32 size )
 {
-   if( gui.icon_draw_count == vg_list_size(gui.icon_draw_buffer) )
+   if( gui.icon_draw_count == VG_ARRAY_LEN(gui.icon_draw_buffer) )
       return;
 
    struct icon_call *call = &gui.icon_draw_buffer[ gui.icon_draw_count ++ ];
diff --git a/menu.c b/menu.c
index f9b4c3ee59812004fcdc008b0a75d01a38986d04..1f2b9c8f542a622f5c4714f53570734a171158cc 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -613,7 +613,7 @@ void menu_gui( ui_context *ctx )
       if( menu.main_index == -1 )
          menu.main_index ++;
 
-      if( menu.main_index == vg_list_size(opts) )
+      if( menu.main_index == VG_ARRAY_LEN(opts) )
          menu.main_index --;
 
       audio_lock();
@@ -635,7 +635,7 @@ void menu_gui( ui_context *ctx )
          x += 32 + spacer;
       }
 
-      for( i32 i=0; i<vg_list_size(opts); i ++ )
+      for( i32 i=0; i<VG_ARRAY_LEN(opts); i ++ )
       {
          ui_rect box = { x, 0, ui_text_line_width(ctx, opts[i]) + 32, height };
 
diff --git a/model.c b/model.c
index 19f45f2d0466c8d3c55e1aca8160595b6e242431..a623e7b4e201a865915774b957b5f27784415b83 100644 (file)
--- a/model.c
+++ b/model.c
 
 static void mdl_load_fatal_corrupt( mdl_context *mdl )
 {
+   vg_fatal_condition();
+   vg_file_error_info( mdl->file );
    fclose( mdl->file );
-   vg_file_print_invalid( mdl->file );
-   vg_fatal_error( "Corrupt model" );
+   vg_fatal_exit();
 }
 
 /*
@@ -33,8 +34,10 @@ void mdl_fread_pack_file( mdl_context *mdl, mdl_file *info, void *dst )
 {
    if( !info->pack_size )
    {
-      vg_warn( "path: %s\n", mdl_pstr( mdl, info->pstr_path ) );
-      vg_fatal_error( "Packed file is only a header; it is not packed" );
+      vg_fatal_condition();
+      vg_info( "Packed file is only a header; it is not packed" );
+      vg_info( "path: %s\n", mdl_pstr( mdl, info->pstr_path ) );
+      vg_fatal_exit();
    }
 
    fseek( mdl->file, mdl->pack_base_offset+info->pack_offset, SEEK_SET );
@@ -350,8 +353,9 @@ void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc )
 
    if( !mdl->file )
    {
-      vg_error( "mdl_open('%s'): %s\n", path, strerror(errno) );
-      vg_fatal_error( "see above for details" );
+      vg_fatal_condition();
+      vg_info( "mdl_open('%s'): %s\n", path, strerror(errno) );
+      vg_fatal_exit();
    }
 
    u64 l = fread( &mdl->info, sizeof(mdl_header), 1, mdl->file );
@@ -360,11 +364,12 @@ void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc )
 
    if( mdl->info.version < MDL_VERSION_MIN )
    {
-      vg_warn( "For model: %s\n", path );
-      vg_warn( "  version: %u (min: %u, current: %u)\n", 
+      vg_fatal_condition();
+      vg_info( "Legacy model version incompatable" );
+      vg_info( "For model: %s\n", path );
+      vg_info( "  version: %u (min: %u, current: %u)\n", 
                mdl->info.version, MDL_VERSION_MIN, MDL_VERSION_NR );
-
-      vg_fatal_error( "Legacy model version incompatable" );
+      vg_fatal_exit();
    }
 
    mdl_load_array_file( mdl, &mdl->index, &mdl->info.index, lin_alloc,
@@ -465,8 +470,6 @@ static void mesh_upload( glmesh *mesh,
          stride, (void *)offsetof(mdl_vert, groups) );
    glEnableVertexAttribArray( 5 );
 
-   VG_CHECK_GL_ERR();
-
    mesh->indice_count = indice_count;
    mesh->loaded = 1;
 }
@@ -618,7 +621,9 @@ void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh, u32 *fixup_table )
    }
    else
    {
-      vg_fatal_error( "no vertex/indice data\n" );
+      vg_fatal_condition();
+      vg_info( "No vertex/indice data in model file\n" );
+      vg_fatal_exit();
    }
 }
 
index 6d6178e2a9b6fb9adf8218d3d417f5566e81a6f3..0869612fca9a91e6fafd93cd41f7713fa4910470 100644 (file)
--- a/network.c
+++ b/network.c
@@ -57,7 +57,7 @@ static void on_auth_ticket_recieved( void *result, void *context ){
    
    if( SteamAPI_ISteamUser_GetEncryptedAppTicket( hSteamUser, 
             network_client.app_symmetric_key,
-            vg_list_size(network_client.app_symmetric_key),
+            VG_ARRAY_LEN(network_client.app_symmetric_key),
             &network_client.app_key_length )){
       vg_success( "  Loaded app ticket\n" );
    }
@@ -316,7 +316,7 @@ static void network_disconnect(void){
    network_client.remote = 0;
    network_client.state = k_ESteamNetworkingConnectionState_None;
 
-   for( int i=0; i<vg_list_size(netplayers.list); i++ ){
+   for( int i=0; i<VG_ARRAY_LEN(netplayers.list); i++ ){
       netplayers.list[i].active = 0;
    }
 }
@@ -533,7 +533,7 @@ static void poll_remote_connection(void){
    for( int i=0; i<10; i++ ){
       len = SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnConnection(
             hSteamNetworkingSockets, network_client.remote, 
-            messages, vg_list_size(messages));
+            messages, VG_ARRAY_LEN(messages));
 
       if( len <= 0 )
          return;
index 2e05a1923dc05a5d94560731832d94704a339b1f..ec2960b7784bd588e598163c5afa68a61cfee6e6 100644 (file)
@@ -108,8 +108,6 @@ static void async_particle_init( void *payload, u32 size ){
    glVertexAttribPointer( 1, 4, GL_UNSIGNED_BYTE, GL_TRUE, 
          stride, (void *)offsetof(particle_vert, colour) );
    glEnableVertexAttribArray( 1 );
-
-   VG_CHECK_GL_ERR();
 }
 
 void particle_alloc( particle_system *sys, u32 max )
index 5a5616993084193a77c140815ec2fa550dc9d334..551b39be0ee9305da0733b0a3ab02cd97b9c9209 100644 (file)
--- a/player.c
+++ b/player.c
@@ -303,7 +303,7 @@ void player__clean_refs(void)
 
    localplayer.boundary_hash ^= NETMSG_BOUNDARY_BIT;
 
-   for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(world_static.instances); i++ ){
       world_instance *instance = &world_static.instances[i];
       if( instance->status == k_world_status_loaded ){
          world_routes_clear( instance );
index 3cbcb28041470de213dd49074550b952dda4e462..d9977ce20ea829fef1cb877129da07a5fc5b3d8b 100644 (file)
@@ -214,7 +214,7 @@ bool glider_physics( v2f steer )
    rigidbody _null = {0};
    _null.inv_mass = 0.0f;
    m3x3_zero( _null.iI );
-   for( u32 i=0; i < vg_list_size(player_glide.parts); i ++ ){
+   for( u32 i=0; i < VG_ARRAY_LEN(player_glide.parts); i ++ ){
       m4x3f mmdl;
       m4x3_mul( rb->to_world, player_glide.parts[i].mdl, mmdl );
 
@@ -401,7 +401,7 @@ void player_glide_bind(void)
    m3x3f I;
    m3x3_zero( I );
 
-   for( u32 i=0; i<vg_list_size(player_glide.parts); i ++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(player_glide.parts); i ++ ){
       /* create part transform matrix */
       v4f qp, qy, qr, q;
       q_axis_angle( qp, (v3f){1,0,0}, player_glide.parts[i].euler[0] );
@@ -469,12 +469,12 @@ void player_glide_bind(void)
       v3_copy( marker->transform.co, 
                player_glide.trail_positions[ player_glide.trail_count ++ ] );
 
-      if( player_glide.trail_count == vg_list_size(trails_glider) )
+      if( player_glide.trail_count == VG_ARRAY_LEN(trails_glider) )
          break;
    }
 
    /* allocate effects */
-   for( u32 i=0; i<vg_list_size(trails_glider); i ++ )
+   for( u32 i=0; i<VG_ARRAY_LEN(trails_glider); i ++ )
    {
       trail_alloc( &trails_glider[i], 200 );
    }
@@ -488,7 +488,7 @@ void player_glide_transition(void)
    world_static.challenge_timer = 0.0f;
    world_static.focused_entity = 0;
    world_static.last_use = 0.0;
-   for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(world_static.instances); i++ ){
       world_instance *instance = &world_static.instances[i];
       if( instance->status == k_world_status_loaded ){
          world_routes_clear( instance );
index 6f9d430c56cefff23fe7ca69ed577f8e0597327b..1527d106df934f3d5d6a17a0887b2015f125f6b3 100644 (file)
@@ -177,7 +177,7 @@ void setup_ragdoll_from_skeleton( struct skeleton *sk,
       if( !(bone->collider) )
          continue;
 
-      if( rd->part_count > vg_list_size(rd->parts) )
+      if( rd->part_count > VG_ARRAY_LEN(rd->parts) )
          vg_fatal_error( "Playermodel has too many colliders" );
 
       u32 part_id = rd->part_count;
index e8ca56c62cb65d4e98ccfccc8bfe368f6f0687dc..6fdf04f7f1191df9348dd101e8e3569667406533 100644 (file)
@@ -60,7 +60,7 @@ static void relink_remote_player_worlds( u32 client_id ){
  */
 void relink_all_remote_player_worlds(void)
 {
-   for( u32 i=0; i<vg_list_size(netplayers.list); i++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(netplayers.list); i++ ){
       struct network_player *player = &netplayers.list[i];
       if( player->active )
          relink_remote_player_worlds(i);
@@ -84,7 +84,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
       netmsg_playerjoin *playerjoin = msg->m_pData;
       if( !packet_minsize( msg, sizeof(*playerjoin) )) return;
 
-      if( playerjoin->index < vg_list_size(netplayers.list) ){
+      if( playerjoin->index < VG_ARRAY_LEN(netplayers.list) ){
          struct network_player *player = &netplayers.list[ playerjoin->index ];
          player_remote_clear( player );
          player->active = 1;
@@ -97,7 +97,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
 
          struct interp_buffer *buf = &netplayers.interp_data[playerjoin->index];
          buf->t = -99999999.9;
-         for( u32 i=0; i<vg_list_size(buf->frames); i ++ ){
+         for( u32 i=0; i<VG_ARRAY_LEN(buf->frames); i ++ ){
             buf->frames[i].active = 0;
          }
 
@@ -112,7 +112,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
       netmsg_playerleave *playerleave = msg->m_pData;
       if( !packet_minsize( msg, sizeof(*playerleave) )) return;
       
-      if( playerleave->index < vg_list_size(netplayers.list) ){
+      if( playerleave->index < VG_ARRAY_LEN(netplayers.list) ){
          struct network_player *player = &netplayers.list[ playerleave->index ];
          player_remote_clear( player );
          player->active = 0;
@@ -126,7 +126,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
       netmsg_playerusername *update = msg->m_pData;
       if( !packet_minsize( msg, sizeof(*update) )) return;
 
-      if( update->index < vg_list_size(netplayers.list) ){
+      if( update->index < VG_ARRAY_LEN(netplayers.list) ){
          struct network_player *player = &netplayers.list[ update->index ];
 
          network_msgstring( update->name, msg->m_cbSize, sizeof(*update),
@@ -149,7 +149,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
       
       netmsg_playerframe *frame = msg->m_pData;
 
-      if( frame->client >= vg_list_size(netplayers.list) ){
+      if( frame->client >= VG_ARRAY_LEN(netplayers.list) ){
          vg_error( "inetmsg_playerframe: player index out of range\n" );
          return;
       }
@@ -163,7 +163,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
       struct interp_frame *dest = NULL;
 
       f64 min_time = INFINITY;
-      for( u32 i=0; i<vg_list_size(ib->frames); i++ ){
+      for( u32 i=0; i<VG_ARRAY_LEN(ib->frames); i++ ){
          struct interp_frame *ifr = &ib->frames[i];
 
          if( !ifr->active ){
@@ -253,7 +253,7 @@ void player_remote_rx_200_300( SteamNetworkingMessage_t *msg )
       netmsg_playeritem *item = msg->m_pData;
       if( !packet_minsize( msg, sizeof(*item)+1 )) return;
 
-      if( item->client >= vg_list_size(netplayers.list) ){
+      if( item->client >= VG_ARRAY_LEN(netplayers.list) ){
          vg_error( "inetmsg_playerframe: player index out of range\n" );
          return;
       }
@@ -402,7 +402,7 @@ void remote_player_debug_update(void)
       netplayers.last_data_measurement = vg.time_real;
       u32 total_down = 0;
 
-      for( u32 i=0; i<vg_list_size(netplayers.list); i++ ){
+      for( u32 i=0; i<VG_ARRAY_LEN(netplayers.list); i++ ){
          struct network_player *player = &netplayers.list[i];
          if( player->active ){
             total_down += player->down_bytes;
@@ -470,7 +470,7 @@ void remote_player_network_imgui( ui_context *ctx, m4x4f pv )
           { k_ESteamNetworkingConnectionState_Linger, "Linger" },
           { k_ESteamNetworkingConnectionState_Dead, "Dead" }
    };
-   for( u32 i=0; i<vg_list_size(states); i ++ )
+   for( u32 i=0; i<VG_ARRAY_LEN(states); i ++ )
    {
       if( states[i].state == network_client.state )
       {
@@ -490,7 +490,7 @@ void remote_player_network_imgui( ui_context *ctx, m4x4f pv )
                 netplayers.up_kbs, netplayers.down_kbs );
       ui_info( ctx, panel, buf );
 
-      for( u32 i=0; i<vg_list_size(netplayers.list); i++ )
+      for( u32 i=0; i<VG_ARRAY_LEN(netplayers.list); i++ )
       {
          struct network_player *player = &netplayers.list[i];
          if( player->active )
@@ -636,7 +636,7 @@ void animate_remote_player( u32 index )
                        *abs_max_frame = NULL;
 
    struct interp_buffer *buf = &netplayers.interp_data[index];
-   for( u32 i=0; i<vg_list_size(buf->frames); i ++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(buf->frames); i ++ ){
       struct interp_frame *ifr = &buf->frames[i];
 
       if( ifr->active ){
@@ -680,7 +680,7 @@ void animate_remote_player( u32 index )
  */
 void animate_remote_players(void)
 {
-   for( u32 i=0; i<vg_list_size(netplayers.list); i ++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(netplayers.list); i ++ ){
       struct network_player *player = &netplayers.list[i];
       if( !player->active ) continue;
 
index 0db1ca4d665822b8251555d62b5289c412e89c97..950ad78e229a6bf2d39dfa0f574983da7067c34d 100644 (file)
@@ -1124,7 +1124,7 @@ void skaterift_replay_imgui( ui_context *ctx )
 
       if( !absorb_by_keyframe && ui_click_down( ctx, UI_MOUSE_LEFT ) )
       {
-         u32 max = vg_list_size( player_replay.keyframes );
+         u32 max = VG_ARRAY_LEN( player_replay.keyframes );
          if( player_replay.keyframe_count == max )
          {
             ui_start_modal( ctx, "Maximum keyframes reached", UI_MODAL_BAD );
index 50247502224d9b27963e44d9db793f256ddb9e90..aea7027140484443df9905496e44159cd0b3d2dc 100644 (file)
@@ -59,7 +59,7 @@ void player__skate_bind(void){
       { &player_skate.anim_handplant,    "handplant" },
    };
 
-   for( u32 i=0; i<vg_list_size(bindings); i++ )
+   for( u32 i=0; i<VG_ARRAY_LEN(bindings); i++ )
       *bindings[i].anim = skeleton_get_anim( sk, bindings[i].name );
 }
 
@@ -200,7 +200,7 @@ static int skate_grind_scansq( v3f pos, v3f dir, float r,
             v2_normalize( sample->normal );
             sample_count ++;
 
-            if( sample_count == vg_list_size( samples ) )
+            if( sample_count == VG_ARRAY_LEN( samples ) )
                goto too_many_samples;
          }
       }
@@ -3248,7 +3248,7 @@ void player__skate_pose( void *_animator, player_pose *pose ){
                            0.75f,
                            0.75f };
 
-   for( int i=0; i<vg_list_size(apply_to); i ++ ){
+   for( int i=0; i<VG_ARRAY_LEN(apply_to); i ++ ){
       pose->keyframes[apply_to[i]-1].co[0] += animator->offset[0]*add_grab_mod;
       pose->keyframes[apply_to[i]-1].co[2] += animator->offset[2]*add_grab_mod;
    }
@@ -3258,7 +3258,7 @@ void player__skate_pose( void *_animator, player_pose *pose ){
    v3f origin;
    v3_add( sk->bones[localplayer.id_hip].co, kf_hip->co, origin );
 
-   for( int i=0; i<vg_list_size(apply_to); i ++ ){
+   for( int i=0; i<VG_ARRAY_LEN(apply_to); i ++ ){
       mdl_keyframe *kf = &pose->keyframes[apply_to[i]-1];
       keyframe_rotate_around( kf, origin, sk->bones[apply_to[i]].co,
                               animator->qfixuptotal );
@@ -3439,7 +3439,7 @@ void player__skate_pose( void *_animator, player_pose *pose ){
       v4f qskid;
       q_axis_angle( qskid, (v3f){0,1,0}, -animator->steer[1]*0.2f );
 
-      for( u32 i=0; i<vg_list_size(skidders); i ++ ){
+      for( u32 i=0; i<VG_ARRAY_LEN(skidders); i ++ ){
          mdl_keyframe *kf = &pose->keyframes[ skidders[i]-1 ];
          keyframe_rotate_around( kf, 
                (v3f){0,0,0.4f*(animator->z*2.0f-1.0f)*amt}, 
index aa0cfab94382879a76431ac31b3d1858413f754c..fada4a58080731821e11bd1b0cbdd25f3e9e0492 100644 (file)
--- a/render.c
+++ b/render.c
@@ -53,8 +53,6 @@ static void async_render_init( void *payload, u32 size )
                           sizeof(float)*2, (void*)0 );
    glEnableVertexAttribArray( 0 );
 
-   VG_CHECK_GL_ERR();
-
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
    g_render.ready = 1;
 }
diff --git a/scene.c b/scene.c
index f472f2cafde666817ffc502b12289a5a8002b83a..a94fbcaf377a0ef60366d4636b8a092f280d6827 100644 (file)
--- a/scene.c
+++ b/scene.c
@@ -214,8 +214,6 @@ void async_scene_upload( void *payload, u32 size )
          stride, (void *)offsetof(scene_vert, uv) );
    glEnableVertexAttribArray( 2 );
 
-   VG_CHECK_GL_ERR();
-
    mesh->indice_count = ctx->indice_count;
    mesh->loaded = 1;
 
index d9ff9d185ae207ec7a0b88b11e6becbd4fdcb4c9..36e087f3a0be7f383d3826d25174c3fb7d953afa 100644 (file)
@@ -351,7 +351,7 @@ static void render_scene(void)
    /* Draw world */
    glEnable( GL_DEPTH_TEST );
 
-   for( u32 i=0; i<vg_list_size(world_static.instances); i++ )
+   for( u32 i=0; i<VG_ARRAY_LEN(world_static.instances); i++ )
    {
       if( world_static.instances[i].status == k_world_status_loaded )
       {
diff --git a/steam.c b/steam.c
index a9484ddc71ef8d1f80f3405a1bbfc0d31cfaaf98..f28b8e786718733e6bcd1bb477998a67ad6258ee 100644 (file)
--- a/steam.c
+++ b/steam.c
@@ -99,7 +99,7 @@ void steam_print_all_achievements(void)
    vg_info( "Achievements: \n" );
 
    if( steam_ready && steam_stats_ready ){
-      for( int i=0; i<vg_list_size(steam_achievement_names); i++ ){
+      for( int i=0; i<VG_ARRAY_LEN(steam_achievement_names); i++ ){
          steamapi_bool set = 0;
          const char *name = steam_achievement_names[i];
 
@@ -128,7 +128,7 @@ int steam_achievement_ccmd( int argc, char const *argv[] )
          return 0;
       }
       else if( !strcmp( argv[0], "clearall" )){
-         for( int i=0; i<vg_list_size(steam_achievement_names); i++ )
+         for( int i=0; i<VG_ARRAY_LEN(steam_achievement_names); i++ )
             steam_clear_achievement( steam_achievement_names[i] );
          
          steam_store_achievements();
@@ -282,7 +282,7 @@ int steam_init(void)
 
    /* TODO: On username update callback */
    str_utf8_collapse( username, steam_username_at_startup, 
-                        vg_list_size(steam_username_at_startup) );
+                        VG_ARRAY_LEN(steam_username_at_startup) );
 
    return 1;
 }
diff --git a/trail.c b/trail.c
index 6bdee69262a8d0eab261862fca9b9914263c48f7..376a00917b4e18609d0e3d21d3d065c4c0dbb2ef 100644 (file)
--- a/trail.c
+++ b/trail.c
@@ -130,8 +130,6 @@ void async_trail_init( void *payload, u32 size )
    /* 0: coordinates */
    glVertexAttribPointer( 0, 4, GL_FLOAT, GL_FALSE, stride, (void*)0 );
    glEnableVertexAttribArray( 0 );
-
-   VG_CHECK_GL_ERR();
 }
 
 void trail_alloc( trail_system *sys, u32 max )
index 6975d601e587d43edcdd6ff7790a18bf69f7ce05..7814b094988144e34fc1b78c1d8a0739b8dec27a 100644 (file)
@@ -677,16 +677,16 @@ static void workshop_op_download_and_view_submission( int result_index )
 
       vg_strncpy( details.m_rgchDescription, 
                   workshop_form.submission.description, 
-                  vg_list_size( workshop_form.submission.description ),
+                  VG_ARRAY_LEN( workshop_form.submission.description ),
                   k_strncpy_always_add_null );
 
       vg_strncpy( details.m_rgchTitle,
                   workshop_form.submission.title,
-                  vg_list_size( workshop_form.submission.title ),
+                  VG_ARRAY_LEN( workshop_form.submission.title ),
                   k_strncpy_always_add_null );
 
       snprintf( workshop_form.addon_folder, 
-                 vg_list_size( workshop_form.addon_folder ),
+                 VG_ARRAY_LEN( workshop_form.addon_folder ),
                  "Steam Cloud ("PRINTF_U64")", details.m_nPublishedFileId );
 
       workshop_form.submission.file_id = details.m_nPublishedFileId;
@@ -1235,7 +1235,7 @@ static void workshop_form_gui_edit_page( ui_context *ctx, ui_rect content )
          .change = workshop_changed_model_path
       };
       ui_textbox( ctx, content, buf, workshop_form.addon_folder,
-                  vg_list_size(workshop_form.addon_folder), 1, 0, &callbacks );
+                  VG_ARRAY_LEN(workshop_form.addon_folder), 1, 0, &callbacks );
    }
    else
    {
@@ -1267,7 +1267,7 @@ static void workshop_form_gui_edit_page( ui_context *ctx, ui_rect content )
          };
 
          ui_textbox( ctx, file_entry, buf, workshop_form.addon_folder,
-                     vg_list_size(workshop_form.addon_folder), 1,
+                     VG_ARRAY_LEN(workshop_form.addon_folder), 1,
                      0, &callbacks );
 
          if( ui_button_text( ctx, file_button, "Load", 1 ) == 1 )
@@ -1285,7 +1285,7 @@ static void workshop_form_gui_edit_page( ui_context *ctx, ui_rect content )
          .change = workshop_changed_title
       };
       ui_textbox( ctx, content, str_title, workshop_form.submission.title, 
-                  vg_list_size(workshop_form.submission.title), 1,
+                  VG_ARRAY_LEN(workshop_form.submission.title), 1,
                   0, &callbacks );
    }
 
@@ -1302,7 +1302,7 @@ static void workshop_form_gui_edit_page( ui_context *ctx, ui_rect content )
          .change = workshop_changed_description
       };
       ui_textbox( ctx, content, str_desc, workshop_form.submission.description,
-                  vg_list_size(workshop_form.submission.description), 4,
+                  VG_ARRAY_LEN(workshop_form.submission.description), 4,
                   UI_TEXTBOX_MULTILINE|UI_TEXTBOX_WRAP, &callbacks );
    }
 
diff --git a/world.c b/world.c
index 9b19387208ad9a47a5c96805b6923a83185af09b..e6d6c318ff2363b8df1ab5520d47374f96475be3 100644 (file)
--- a/world.c
+++ b/world.c
@@ -41,7 +41,7 @@ void world_switch_instance( u32 index )
 {
    localplayer.subsystem = k_player_subsystem_walk;
 
-   if( index >= vg_list_size(world_static.instances) ){
+   if( index >= VG_ARRAY_LEN(world_static.instances) ){
       vg_error( "Instance ID out of range (%u)\n", index );
       return;
    }
index e75cb29cebfdb2c09519b33e1c212c35845ffb95..b85e6fa65fdce99149de1ab6c80a42434e270a6f 100644 (file)
@@ -129,7 +129,7 @@ void world_entity_focus_preupdate(void)
       [ k_ent_npc ] = ent_npc_preupdate,
    };
 
-   if( (type > vg_list_size(table)) || (table[type] == NULL) )
+   if( (type > VG_ARRAY_LEN(table)) || (table[type] == NULL) )
    {
       vg_fatal_error( "No pre-update method set for entity (%u#%u)\n",
                       type, index );
@@ -255,7 +255,7 @@ void world_gen_entities_init( world_instance *world )
       { k_ent_npc, &world->ent_npc }
    };
 
-   for( u32 i=0; i<vg_list_size(indexables); i++ )
+   for( u32 i=0; i<VG_ARRAY_LEN(indexables); i++ )
       indexed_count += mdl_arrcount( indexables[i].array );
    vg_info( "indexing %u entities\n", indexed_count );
 
@@ -263,7 +263,7 @@ void world_gen_entities_init( world_instance *world )
                                          vg_align8(indexed_count*sizeof(u32)));
 
    u32 index=0;
-   for( u32 i=0; i<vg_list_size(indexables); i++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(indexables); i++ ){
       u32 type  = indexables[i].type,
           count = mdl_arrcount( indexables[i].array );
       
@@ -814,7 +814,7 @@ void world_entity_start( world_instance *world, vg_msg *sav )
 
             /* LEGACY: check if steam achievements can give us a medal */
             if( steam_ready && steam_stats_ready ){
-               for( u32 j=0; j<vg_list_size(track_infos); j ++ ){
+               for( u32 j=0; j<VG_ARRAY_LEN(track_infos); j ++ ){
                   struct track_info *inf = &track_infos[j];
                   if( !strcmp(inf->name,
                               mdl_pstr(&world->meta,route->pstr_name))){
index 2a236d4391c0d8d7f67d8bcc94bcbad42151a787..3e6fdbb0a9009266bbb8f408bb7631da7b5b5de4 100644 (file)
@@ -354,7 +354,7 @@ void world_link_gates_async( void *payload, u32 size )
       const char *key = mdl_pstr( &world->meta, gate->key );
       vg_info( "key: %s\n", key );
 
-      for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
+      for( u32 i=0; i<VG_ARRAY_LEN(world_static.instances); i++ ){
          world_instance *other = &world_static.instances[i];
          if( other == world ) continue;
          if( other->status != k_world_status_loaded ) continue;
index 91e5b7bef5d63ae6dada59aba05a366870e74cde..e51836d757574d9e7ee1e2bfd2c8b17afa0cf332 100644 (file)
@@ -71,10 +71,10 @@ static void world_gen_add_blob( vg_rand *rand, world_instance *world,
 
    const u32 indices[] = { 0,1,3, 0,3,2, 2,3,5, 2,5,4 };
 
-   if( scene->vertex_count + vg_list_size(verts) > scene->max_vertices )
+   if( scene->vertex_count + VG_ARRAY_LEN(verts) > scene->max_vertices )
       vg_fatal_error( "Scene vertex buffer overflow" );
 
-   if( scene->indice_count + vg_list_size(indices) > scene->max_indices )
+   if( scene->indice_count + VG_ARRAY_LEN(indices) > scene->max_indices )
       vg_fatal_error( "Scene index buffer overflow" );
 
    scene_vert *dst_verts = &scene->arrvertices[ scene->vertex_count ];
@@ -82,7 +82,7 @@ static void world_gen_add_blob( vg_rand *rand, world_instance *world,
 
    scene_vert *ref       = &world->scene_geo.arrvertices[ hit->tri[0] ];
 
-   for( u32 i=0; i<vg_list_size(verts); i++ ){
+   for( u32 i=0; i<VG_ARRAY_LEN(verts); i++ ){
       scene_vert *pvert = &dst_verts[ i ],
                  *src   = &verts[ i ];
 
@@ -92,11 +92,11 @@ static void world_gen_add_blob( vg_rand *rand, world_instance *world,
       v2_copy( ref->uv, pvert->uv );
    }
 
-   for( u32 i=0; i<vg_list_size(indices); i++ )
+   for( u32 i=0; i<VG_ARRAY_LEN(indices); i++ )
       dst_indices[i] = indices[i] + scene->vertex_count;
 
-   scene->vertex_count += vg_list_size(verts);
-   scene->indice_count += vg_list_size(indices);
+   scene->vertex_count += VG_ARRAY_LEN(verts);
+   scene->indice_count += VG_ARRAY_LEN(indices);
 }
 
 /* 
@@ -485,7 +485,7 @@ void world_gen_compute_light_indices( world_instance *world )
             u32 count = 0;
 
             float influences[6] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
-            const int N = vg_list_size( influences );
+            const int N = VG_ARRAY_LEN( influences );
 
             for( u32 j=0; j<mdl_arrcount(&world->ent_light); j ++ ){
                ent_light *light = mdl_arritm( &world->ent_light, j );
index dafd58d5c3b98089672de52f82539c72779f80f6..30c2b2cce14573855069ddf5621632c35d8a5714 100644 (file)
@@ -438,7 +438,7 @@ int world_freeable( world_instance *world )
    if( world->status != k_world_status_unloading ) return 0;
    u8 world_id = (world - world_static.instances) + 1;
 
-   for( u32 i=world_id; i<vg_list_size(world_static.instances); i++ ){
+   for( u32 i=world_id; i<VG_ARRAY_LEN(world_static.instances); i++ ){
       if( world_static.instances[i].status != k_world_status_unloaded ){
          return 0;
       }
index 7d93920e558014a1aac6562153e19a266d2075de..3eb07a1270c55e5ea50cee1bbcccd7fc21be72be 100644 (file)
@@ -38,7 +38,6 @@ static void async_world_render_init( void *payload, u32 size )
                     NULL, GL_DYNAMIC_DRAW );
 
       glBindBufferBase( GL_UNIFORM_BUFFER, i, world->ubo_lighting );
-      VG_CHECK_GL_ERR();
    }
 }
 
@@ -551,11 +550,11 @@ static void world_render_challenges( world_instance *world,
              index = mdl_entity_id_id( id );
 
          if( type == k_ent_objective ) {
-            if( objective_count < vg_list_size(objective_list) )
+            if( objective_count < VG_ARRAY_LEN(objective_list) )
                objective_list[ objective_count ++ ] = index;
          }
          else if( type == k_ent_challenge ){
-            if( challenge_count < vg_list_size(challenge_list) )
+            if( challenge_count < VG_ARRAY_LEN(challenge_list) )
                challenge_list[ challenge_count ++ ] = index;
          }
       }
@@ -979,12 +978,12 @@ static void render_other_entities( world_instance *world, vg_camera *cam )
 
       if( type == k_ent_glider ) 
       {
-         if( glider_count < vg_list_size(glider_list) )
+         if( glider_count < VG_ARRAY_LEN(glider_list) )
             glider_list[ glider_count ++ ] = index;
       }
       else if( type == k_ent_npc ) 
       {
-         if( npc_count < vg_list_size(npc_list) )
+         if( npc_count < VG_ARRAY_LEN(npc_list) )
             npc_list[ npc_count ++ ] = index;
       }
    }
index c4b339385bc9794df093d1789f76d93b321c9382..e4fd80e99e2aa790df90b18716f4b2e283e5bdcd 100644 (file)
@@ -203,7 +203,7 @@ static void world_routes_debug( world_instance *world )
 
       u32 cc = 0xffcccccc;
       if( route->active_checkpoint != 0xffff ){
-         cc = colours[i%vg_list_size(colours)];
+         cc = colours[i%VG_ARRAY_LEN(colours)];
       }
 
       for( int i=0; i<route->checkpoints_count; i++ ){
@@ -564,7 +564,7 @@ void world_gen_routes_ent_init( world_instance *world )
          route->flags |= k_ent_route_flag_out_of_zone;
 
       route->anon.official_track_id = 0xffffffff;
-      for( u32 j=0; j<vg_list_size(track_infos); j ++ ){
+      for( u32 j=0; j<VG_ARRAY_LEN(track_infos); j ++ ){
          if( !strcmp(track_infos[j].name, 
                      mdl_pstr(&world->meta,route->pstr_name))){
             route->anon.official_track_id = j;
index ae507d0cffec927296435ae7f3bd0c25677de15e..b74e4932daa2c0e295e62f63c3a91a6d999f49d2 100644 (file)
@@ -78,7 +78,7 @@ void world_volumes_update( world_instance *world, v3f pos )
                goto next_volume;
 
          if( world_static.active_trigger_volume_count > 
-               vg_list_size(world_static.active_trigger_volumes) ) continue;
+               VG_ARRAY_LEN(world_static.active_trigger_volumes) ) continue;
 
          v3f local;
          m4x3_mulv( volume->to_local, pos, local );