#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;
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" );
}
route->active_checkpoint = 0xffffffff;
}
+ for( u32 i=0; i<mdl_arrcount( &world->ent_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; i<route->checkpoints_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
*/
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; i<mdl_arrcount(&world->ent_route); i++ ){
ent_route *route = mdl_arritm( &world->ent_route, i );
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;
}
}
}
}
}
-
- world_global.current_run_version ++;
dest->timing_version = world_global.current_run_version;
dest->timing_time = world_global.time;
+
world_global.current_run_version ++;
}
}
vg_release_thread_sync();
vg_linear_del( world_global.generic_heap, world->scene_lines );
+
+ world_routes_clear( world );
}
/* load all routes from model header */
for( u32 i=0; i<mdl_arrcount(&world->ent_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; j<vg_list_size(track_infos); j ++ ){
+ if( !strcmp(track_infos[j].name,
+ mdl_pstr(&world->meta,route->pstr_name))){
+ route->official_track_id = j;
+ }
+ }
for( u32 j=0; j<route->checkpoints_count; j++ ){
u32 id = route->checkpoints_start + j;