X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.h;h=91456aa0afdbde6bb4f42937aceaab8399a06a79;hb=59c926ee69a041fbe9450b302e11072d39abb432;hp=b43ec0ee1fe63762acd9103971002f2e70906490;hpb=a1056ed8198f0f5be0e0f341da8bd49aa6c47198;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.h b/world_routes.h index b43ec0e..91456aa 100644 --- a/world_routes.h +++ b/world_routes.h @@ -17,20 +17,19 @@ #include "shaders/routeui.h" -VG_STATIC void world_routes_local_set_record( world_instance *world, - u32 route, double lap_time ) +VG_STATIC +void world_routes_local_set_record( world_instance *world, ent_route *route, + double lap_time ) { -#if 0 vg_success( " NEW LAP TIME: %f\n", lap_time ); - if( pr->track_id != 0xffffffff ) - { + if( route->official_track_id != 0xffffffff ){ double time_centiseconds = lap_time * 100.0; - if( time_centiseconds > (float)0xfffe ) + if( time_centiseconds > (float)0xfffe ) /* skill issue */ return; highscore_record temp; - temp.trackid = pr->track_id; + temp.trackid = route->official_track_id; temp.datetime = time(NULL); temp.playerid = 0; temp.points = 0; @@ -38,21 +37,17 @@ VG_STATIC void world_routes_local_set_record( world_instance *world, highscores_push_record( &temp ); - struct track_info *pti = &track_infos[ pr->track_id ]; - pti->push = 1; + struct track_info *ti = &track_infos[ route->official_track_id ]; + ti->push = 1; - if( pti->achievement_id ) - { - steam_set_achievement( pti->achievement_id ); + if( ti->achievement_id ){ + steam_set_achievement( ti->achievement_id ); steam_store_achievements(); } } - else - { + else{ vg_warn( "There is no associated track for this record...\n" ); } -#endif - vg_warn( "set_record unimplemented\n" ); } @@ -63,10 +58,53 @@ VG_STATIC void world_routes_clear( world_instance *world ) route->active_checkpoint = 0xffffffff; } + for( u32 i=0; ient_gate ); i++ ){ + ent_gate *rg = mdl_arritm( &world->ent_gate, i ); + rg->timing_version = 0; + rg->timing_time = 0.0; + } + world_global.current_run_version += 4; world_global.last_use = 0.0; } +VG_STATIC void world_routes_time_lap( world_instance *world, ent_route *route ) +{ + vg_info( "------- time lap %s -------\n", + mdl_pstr(&world->meta,route->pstr_name) ); + + double total_time = 0.0; + u32 last_version; + int validated = 1; + + for( u32 i=0; icheckpoints_count; i++ ){ + u32 cpid = route->checkpoints_start+(i+route->active_checkpoint); + cpid = cpid % route->checkpoints_count; + + ent_checkpoint *cp = mdl_arritm( &world->ent_checkpoint, cpid ); + ent_gate *rg = mdl_arritm( &world->ent_gate, cp->gate_index ); + rg = mdl_arritm( &world->ent_gate, rg->target ); + + if( i == 0 ) + total_time = rg->timing_time; + else{ + if( last_version+1 != rg->timing_version ) + validated = 0; + } + + last_version = rg->timing_version; + vg_info( "%u %f\n", rg->timing_version, rg->timing_time ); + } + + vg_info( "%u %f\n", world_global.current_run_version, world_global.time ); + + if( validated && (world_global.current_run_version == last_version+1)){ + total_time = world_global.time - total_time; + world_routes_local_set_record( world, route, total_time ); + } + vg_info( "----------------------------\n" ); +} + /* * When going through a gate this is called for bookkeeping purposes */ @@ -76,8 +114,6 @@ VG_STATIC void world_routes_activate_entry_gate( world_instance *world, ent_gate *dest = mdl_arritm( &world->ent_gate, rg->target ); world_global.last_use = world_global.time; - rg->timing_version = world_global.current_run_version; - rg->timing_time = world_global.time; for( u32 i=0; ient_route); i++ ){ ent_route *route = mdl_arritm( &world->ent_route, i ); @@ -94,6 +130,7 @@ VG_STATIC void world_routes_activate_entry_gate( world_instance *world, ent_gate *gk = mdl_arritm( &world->ent_gate, cp->gate_index ); if( gk == rg ){ route->active_checkpoint = k; + world_routes_time_lap( world, route ); break; } } @@ -101,11 +138,10 @@ VG_STATIC void world_routes_activate_entry_gate( world_instance *world, } } } - - world_global.current_run_version ++; dest->timing_version = world_global.current_run_version; dest->timing_time = world_global.time; + world_global.current_run_version ++; } @@ -435,6 +471,8 @@ VG_STATIC void world_routes_generate( world_instance *world ) } vg_release_thread_sync(); vg_linear_del( world_global.generic_heap, world->scene_lines ); + + world_routes_clear( world ); } /* load all routes from model header */ @@ -451,6 +489,15 @@ VG_STATIC void world_routes_ent_init( world_instance *world ) for( u32 i=0; ient_route); i++ ){ ent_route *route = mdl_arritm(&world->ent_route,i); + mdl_transform_m4x3( &route->transform, route->board_transform ); + + route->official_track_id = 0xffffffff; + for( u32 j=0; jmeta,route->pstr_name))){ + route->official_track_id = j; + } + } for( u32 j=0; jcheckpoints_count; j++ ){ u32 id = route->checkpoints_start + j; @@ -517,7 +564,8 @@ VG_STATIC void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void render_world_routes( world_instance *world, camera *cam ) +VG_STATIC void render_world_routes( world_instance *world, camera *cam, + int layer_depth ) { m4x3f identity_matrix; m4x3_identity( identity_matrix ); @@ -564,6 +612,8 @@ VG_STATIC void render_world_routes( world_instance *world, camera *cam ) mesh_bind( &world_global.mesh_gate ); /* skip writing into the motion vectors for this */ + /* TODO: draw future gate if the one we're looking through is to be passed, + * instead of current gate */ glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } ); for( u32 i=0; ient_route); i++ ){ @@ -577,8 +627,9 @@ VG_STATIC void render_world_routes( world_instance *world, camera *cam ) shader_model_gate_uColour( colour ); - u32 next = route->checkpoints_start + - (route->active_checkpoint+1) % route->checkpoints_count; + u32 next = route->active_checkpoint+1+layer_depth; + next = next % route->checkpoints_count; + next += route->checkpoints_start; ent_checkpoint *cp = mdl_arritm( &world->ent_checkpoint, next ); ent_gate *gate = mdl_arritm( &world->ent_gate, cp->gate_index );