add medals to miniworld display
[carveJwlIkooP6JGAAIwe30JlM.git] / world_routes.c
index 33d84db5cb8ff2a80ada0c8e2064634493afa3e5..48df26729b91483e61c0fd4183e4d4a8f25b4e93 100644 (file)
@@ -48,6 +48,7 @@ static void world_routes_time_lap( world_instance *world, ent_route *route )
    u32 last_version=0;
 
    u32 valid_count=0;
+   int clean = 1;
 
    for( u32 i=0; i<route->checkpoints_count; i++ ){
       u32 cpid  = (i+route->active_checkpoint) % route->checkpoints_count;
@@ -69,7 +70,12 @@ static void world_routes_time_lap( world_instance *world, ent_route *route )
       }
 
       last_version = rg->timing_version;
-      vg_info( "%u %f\n", rg->timing_version, rg->timing_time );
+
+      vg_info( "%u %f [%s]\n", rg->timing_version, rg->timing_time,
+               (rg->flags & k_ent_gate_clean_pass)? "CLEAN": "-----");
+
+      if( !(rg->flags & k_ent_gate_clean_pass) )
+         clean = 0;
    }
 
    if( world_static.current_run_version == last_version+1 ){
@@ -85,8 +91,16 @@ static void world_routes_time_lap( world_instance *world, ent_route *route )
 
    if( valid_count==route->checkpoints_count ){
       f64 lap_time = world_static.time - start_time;
-      //world_routes_local_set_record( world, route, lap_time );
 
+      if( (route->best_laptime == 0.0) || (lap_time < route->best_laptime) ){
+         route->best_laptime = lap_time;
+         route->achievment_status |= 0x1;
+
+         if( clean )
+            route->achievment_status |= 0x2;
+      }
+
+      /* for steam achievements. */
       if( route->anon.official_track_id != 0xffffffff ){
          struct track_info *ti = &track_infos[ route->anon.official_track_id ];
          if( ti->achievement_id ){
@@ -120,6 +134,13 @@ static void world_routes_activate_entry_gate( world_instance *world,
    world_static.last_use = world_static.time;
    ent_gate *dest = mdl_arritm( &world->ent_gate, rg->target );
 
+   if( localplayer.rewinded_since_last_gate ){
+      localplayer.rewinded_since_last_gate = 0;
+      dest->flags &= ~k_ent_gate_clean_pass;
+   }
+   else
+      dest->flags |= k_ent_gate_clean_pass;
+
    for( u32 i=0; i<mdl_arrcount(&world->ent_route); i++ ){
       ent_route *route = mdl_arritm( &world->ent_route, i );