X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.h;h=35d3cd7088f32fc8330be7412a62d3ccdd6ff15a;hb=bceb3a28f8127fa27a17f480bd21fa20a340e848;hp=1a51102f08f39f1cbec769e27af032502bfe8e7d;hpb=a98ce96041b248580c0447bf87d4c6106483cade;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.h b/world_routes.h index 1a51102..35d3cd7 100644 --- a/world_routes.h +++ b/world_routes.h @@ -19,11 +19,6 @@ enum route_special_type k_route_special_type_collector = 2 }; -static void world_routes_interact(void) -{ - world.routes.last_interaction = vg.time; -} - static void debug_sbpath( struct route_node *rna, struct route_node *rnb, u32 colour, float xoffset ) { @@ -308,6 +303,8 @@ static void world_routes_ui_updatetime( u32 route, float time ) */ static void world_routes_ui_notch( u32 route, float time ) { + return; /* FIXME: Temporarily disabled */ + struct subworld_routes *r = &world.routes; struct route *pr = &r->routes[route]; @@ -410,7 +407,7 @@ static void world_routes_ui_draw( u32 route, v4f colour, float offset ) shader_routeui_use(); glBindVertexArray( pr->ui.vao ); - float fade_amt = vg.time - pr->ui.fade_timer_start; + float fade_amt = r->time - pr->ui.fade_timer_start; fade_amt = vg_clampf( fade_amt / 1.0f, 0.0f, 1.0f ); float fade_block_size = 0.0f, @@ -430,7 +427,8 @@ static void world_routes_ui_draw( u32 route, v4f colour, float offset ) v4_copy( colour, fade_colour ); fade_colour[3] *= 1.0f-fade_amt; - float timer_delta = (vg.time - world.routes.last_interaction) * (1.0/60.0), + /* 1 minute timer */ + float timer_delta = (r->time - r->last_use) * (1.0/45.0), timer_scale = 1.0f - vg_minf( timer_delta, 1.0f ); /* @@ -495,7 +493,15 @@ static void world_routes_local_set_record( u32 route, double lap_time ) temp.time = time_centiseconds; highscores_push_record( &temp ); - track_infos[ pr->track_id ].push = 1; + + struct track_info *pti = &track_infos[ pr->track_id ]; + pti->push = 1; + + if( pti->achievement_id ) + { + steam_set_achievement( pti->achievement_id ); + steam_store_achievements(); + } } else { @@ -580,7 +586,7 @@ static void world_routes_verify_run( u32 route ) pr->ui.fade_start = pr->ui.segment_start; pr->ui.fade_count = 0; - pr->ui.fade_timer_start = vg.time; + pr->ui.fade_timer_start = r->time; int orig_seg_count = pr->ui.segment_count; @@ -603,7 +609,7 @@ static void world_routes_verify_run( u32 route ) pr->ui.fade_count ++; } - r->routes[route].latest_pass = vg.time; + r->routes[route].latest_pass = r->time; } /* @@ -611,18 +617,18 @@ static void world_routes_verify_run( u32 route ) */ static void world_routes_activate_gate( u32 id ) { - world_routes_interact(); - struct subworld_routes *r = &world.routes; struct route_gate *rg = &r->gates[id]; struct route_node *pnode = &r->nodes[rg->node_id], *pdest = &r->nodes[pnode->next[0]]; + r->last_use = r->time; + struct route_collector *rc = &r->collectors[ pdest->special_id ]; r->active_gate = id; rg->timing.version = r->current_run_version; - rg->timing.time = vg.time; + rg->timing.time = r->time; for( u32 i=0; iroute_count; i++ ) { struct route *route = &r->routes[i]; @@ -644,7 +650,7 @@ static void world_routes_activate_gate( u32 id ) { route->ui.fade_start = route->ui.segment_start; route->ui.fade_count = route->ui.segment_count; - route->ui.fade_timer_start = vg.time; + route->ui.fade_timer_start = r->time; world_routes_ui_clear(i); vg_success( "CLEARING -> %u %u \n", route->ui.fade_start, @@ -655,7 +661,7 @@ static void world_routes_activate_gate( u32 id ) r->current_run_version ++; rc->timing.version = r->current_run_version; - rc->timing.time = vg.time; + rc->timing.time = r->time; r->current_run_version ++; } @@ -665,15 +671,24 @@ static void world_routes_activate_gate( u32 id ) static void world_routes_notify_reset(void) { struct subworld_routes *r = &world.routes; - world_routes_interact(); + r->rewind_from = r->time; + r->rewind_to = r->last_use; +#if 0 for( int i=0; iroute_count; i++ ) { struct route *route = &r->routes[i]; if( route->active ) - world_routes_ui_notch( i, vg.time - route->latest_pass ); + world_routes_ui_notch( i, r->time - route->latest_pass ); } +#endif +} + +static void world_routes_rollback_time( double t ) +{ + struct subworld_routes *r = &world.routes; + r->time = vg_lerp( r->rewind_to, r->rewind_from, t ); } static void world_routes_debug(void) @@ -1015,6 +1030,7 @@ static void world_routes_loadfrom( mdl_header *mdl ) 1, sizeof( struct route ) ); struct route *route = &r->routes[r->route_count]; + memset( route, 0, sizeof(struct route) ); v3_copy( inf->colour, route->colour ); route->colour[3] = 1.0f; @@ -1098,6 +1114,8 @@ static void world_routes_init(void) { struct subworld_routes *r = &world.routes; r->current_run_version = 2; + r->time = RESET_MAX_TIME*2.0; + r->last_use = 0.0; shader_route_register(); shader_routeui_register(); @@ -1115,6 +1133,7 @@ static void world_routes_free(void*_) static void world_routes_update(void) { struct subworld_routes *r = &world.routes; + r->time += vg.time_delta; for( int i=0; iroute_count; i++ ) { @@ -1124,7 +1143,7 @@ static void world_routes_update(void) if( route->active ) { - world_routes_ui_updatetime( i, vg.time - route->latest_pass ); + world_routes_ui_updatetime( i, r->time - route->latest_pass ); } } }