X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.h;h=3b30973099152990e276dbc780869f1f08dc623c;hb=bceb3a28f8127fa27a17f480bd21fa20a340e848;hp=ba5d5e4b7409e7f57492aaef82cad54675cbf02a;hpb=b93c61c54e7ac56f6808b9a563d3e4221ca8482e;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index ba5d5e4..3b30973 100644 --- a/world.h +++ b/world.h @@ -58,11 +58,31 @@ static struct gworld spawns[32]; u32 spawn_count; + struct world_audio_thing + { + v3f pos; + float volume; + u32 flags; + + audio_player player; + audio_clip temp_embedded_clip; + } + * audio_things; + + u32 audio_things_count, + audio_things_cap; + struct achievement_zone { m4x3f transform, inv_transform; char name[32]; int triggered; + + union + { + mdl_node *ptarget_delegated; + struct world_audio_thing *ptarget; + }; } * achievement_zones; @@ -305,13 +325,18 @@ static void world_free( void *_ ) mesh_free( &world.cars ); mesh_free( &world.skydome ); vg_free( world.achievement_zones ); + + /* FIXME: This fucks with the audio player. Use-after-free */ +#if 0 + vg_free( world.audio_things ); +#endif } static void world_update( v3f pos ) { world.sky_time += world.sky_rate * vg.time_delta; world.sky_rate = vg_lerp( world.sky_rate, world.sky_target_rate, - vg.time_delta * 10.0 ); + vg.time_delta * 5.0 ); world_routes_update(); #if 0 @@ -353,13 +378,14 @@ static void world_update( v3f pos ) } } + static int in_zone = 0; + + int in_zone_this_time = 0; + for( int i=0; itriggered ) - continue; - v3f local; m4x3_mulv( zone->inv_transform, pos, local ); @@ -367,15 +393,31 @@ static void world_update( v3f pos ) (fabsf(local[1]) <= 1.0f) && (fabsf(local[2]) <= 1.0f) ) { + in_zone_this_time = 1; + + if( !in_zone && zone->ptarget ) + { + audio_lock(); + audio_player_playclip( &zone->ptarget->player, + &zone->ptarget->temp_embedded_clip ); + audio_unlock(); + } + + if( !zone->triggered ) + { + steam_set_achievement( zone->name ); + steam_store_achievements(); + } + zone->triggered = 1; - steam_set_achievement( zone->name ); - steam_store_achievements(); } vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f}, { 1.0f, 1.0f, 1.0f}}, 0xff00ff00 ); } + + in_zone = in_zone_this_time; sfd_update( &world.sfd.tester ); }