Not sure how this diddn't crash before! Fix bad index.
authorhgn <hgodden00@gmail.com>
Thu, 6 Feb 2025 17:04:30 +0000 (17:04 +0000)
committerhgn <hgodden00@gmail.com>
Thu, 6 Feb 2025 17:04:30 +0000 (17:04 +0000)
src/world_render.c

index 68952c7fe863350102531a52bb8c8f23b0ac8e94..a5e700cb5864531f60c7c2f1f82be1e2657faa8a 100644 (file)
@@ -511,26 +511,32 @@ static void world_render_challenges( world_instance *world,
 
    ent_challenge *active_challenge = NULL;
    int running = 0;
-   if( mdl_entity_id_type( world_static.focused_entity ) == k_ent_challenge ){
+   if( mdl_entity_id_type( world_static.focused_entity ) == k_ent_challenge )
+   {
       if( (skaterift.activity == k_skaterift_default) &&
-           world_static.challenge_target ){
+           world_static.challenge_target )
+      {
          running = 1;
       }
 
       if( !((skaterift.activity != k_skaterift_ent_focus) &&
-            !world_static.challenge_target) ){
+            !world_static.challenge_target) )
+      {
          world_instance *challenge_world = world_current_instance();
          u32 index = mdl_entity_id_id( world_static.focused_entity );
          active_challenge = af_arritm(&challenge_world->ent_challenge, index);
       }
    }
 
-   if( active_challenge ){
+   if( active_challenge )
+   {
       shader_scene_fxglow_uUvOffset( (v2f){ 8.0f/256.0f, 0.0f } );
-      challenge_list[ challenge_count ++ ] = world_static.focused_entity;
+      challenge_list[ challenge_count ++ ] = 
+         mdl_entity_id_id( world_static.focused_entity );
 
       u32 next = active_challenge->first;
-      while( mdl_entity_id_type(next) == k_ent_objective ){
+      while( mdl_entity_id_type(next) == k_ent_objective )
+      {
          u32 index = mdl_entity_id_id( next );
          objective_list[ objective_count ++ ] = index;
 
@@ -540,21 +546,25 @@ static void world_render_challenges( world_instance *world,
 
       radius = 10000.0f;
    }
-   else {
+   else 
+   {
       shader_scene_fxglow_uUvOffset( (v2f){ 0.0f, 0.0f } );
       bh_iter it;
       bh_iter_init_range( 0, &it, pos, radius+10.0f );
       i32 idx;
-      while( bh_next( world->entity_bh, &it, &idx ) ){
+      while( bh_next( world->entity_bh, &it, &idx ) )
+      {
          u32 id    = world->entity_list[ idx ],
              type  = mdl_entity_id_type( id ),
              index = mdl_entity_id_id( id );
 
-         if( type == k_ent_objective ) {
+         if( type == k_ent_objective ) 
+         {
             if( objective_count < VG_ARRAY_LEN(objective_list) )
                objective_list[ objective_count ++ ] = index;
          }
-         else if( type == k_ent_challenge ){
+         else if( type == k_ent_challenge )
+         {
             if( challenge_count < VG_ARRAY_LEN(challenge_list) )
                challenge_list[ challenge_count ++ ] = index;
          }
@@ -569,8 +579,8 @@ static void world_render_challenges( world_instance *world,
    {
       u32 index = objective_list[ i ];
       ent_objective *objective = af_arritm( &world->ent_objective, index );
-      if( (objective->flags & k_ent_objective_hidden) &&
-          !active_challenge ) continue;
+      if( (objective->flags & k_ent_objective_hidden) && !active_challenge ) 
+         continue;
 
       f32 scale = 1.0f;
 
@@ -639,6 +649,7 @@ static void world_render_challenges( world_instance *world,
    for( u32 i=0; i<challenge_count; i++ )
    {
       u32 index = challenge_list[ i ];
+
       ent_challenge *challenge = af_arritm( &world->ent_challenge, index );
       m4x3f mmdl;
       mdl_transform_m4x3( &challenge->transform, mmdl );