7 #include "world_load.h"
11 #include "ent_challenge.h"
12 #include "ent_skateshop.h"
13 #include "ent_route.h"
15 static void world_entity_focus( u32 entity_id
){
16 localplayer
.immobile
= 1;
17 menu
.disable_open
= 1;
19 v3_zero( localplayer
.rb
.v
);
20 v3_zero( localplayer
.rb
.w
);
21 player_walk
.move_speed
= 0.0f
;
22 world_static
.focused_entity
= entity_id
;
23 skaterift
.activity
= k_skaterift_ent_focus
;
26 static void world_entity_unfocus(void){
27 localplayer
.immobile
= 0;
28 skaterift
.activity
= k_skaterift_default
;
29 menu
.disable_open
= 0;
30 srinput
.state
= k_input_state_resume
;
33 static void world_entity_focus_camera( world_instance
*world
, u32 uid
){
34 if( mdl_entity_id_type( uid
) == k_ent_camera
){
35 u32 index
= mdl_entity_id_id( uid
);
36 ent_camera
*cam
= mdl_arritm( &world
->ent_camera
, index
);
38 v3f dir
= {0.0f
,-1.0f
,0.0f
};
39 mdl_transform_vector( &cam
->transform
, dir
, dir
);
40 v3_angles( dir
, world_static
.focus_cam
.angles
);
41 v3_copy( cam
->transform
.co
, world_static
.focus_cam
.pos
);
42 world_static
.focus_cam
.fov
= cam
->fov
;
45 camera_copy( &localplayer
.cam
, &world_static
.focus_cam
);
48 world_static
.focus_cam
.nearz
= localplayer
.cam
.nearz
;
49 world_static
.focus_cam
.farz
= localplayer
.cam
.farz
;
54 static void world_entity_focus_preupdate(void){
55 f32 rate
= vg_minf( 1.0f
, vg
.time_frame_delta
* 2.0f
);
57 if( skaterift
.activity
== k_skaterift_ent_focus
)
60 vg_slewf( &world_static
.focus_strength
, active
,
61 vg
.time_frame_delta
* (1.0f
/0.5f
) );
63 u32 type
= mdl_entity_id_type( world_static
.focused_entity
),
64 index
= mdl_entity_id_id( world_static
.focused_entity
);
65 world_instance
*world
= world_current_instance();
68 if( type
== k_ent_skateshop
){
69 ent_skateshop
*skateshop
= mdl_arritm( &world
->ent_skateshop
, index
);
70 ent_skateshop_preupdate( skateshop
, active
);
72 else if( type
== k_ent_challenge
){
73 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
74 ent_challenge_preupdate( challenge
, active
);
76 else if( type
== k_ent_route
){
77 ent_route
*route
= mdl_arritm( &world
->ent_route
, index
);
78 ent_route_preupdate( route
, active
);
82 /* additional renderings like text etc.. */
83 static void world_entity_focus_render(void){
84 world_instance
*world
= world_current_instance();
85 if( skaterift
.activity
!= k_skaterift_ent_focus
){
86 skateshop_render_nonfocused( world
, &skaterift
.cam
);
90 u32 type
= mdl_entity_id_type( world_static
.focused_entity
),
91 index
= mdl_entity_id_id( world_static
.focused_entity
);
93 if( type
== k_ent_skateshop
){
94 ent_skateshop
*skateshop
= mdl_arritm( &world
->ent_skateshop
, index
);
95 skateshop_render( skateshop
);
97 else if( type
== k_ent_challenge
){}
98 else if( type
== k_ent_route
){}
99 else if( type
== k_ent_miniworld
){}
101 vg_fatal_error( "Programming error\n" );
105 static void world_gen_entities_init( world_instance
*world
){
107 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_light
); j
++ ){
108 ent_light
*light
= mdl_arritm( &world
->ent_light
, j
);
111 q_m3x3( light
->transform
.q
, to_world
);
112 v3_copy( light
->transform
.co
, to_world
[3] );
113 m4x3_invert_affine( to_world
, light
->inverse_world
);
115 light
->angle_sin_cos
[0] = sinf( light
->angle
* 0.5f
);
116 light
->angle_sin_cos
[1] = cosf( light
->angle
* 0.5f
);
120 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_gate
); j
++ ){
121 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, j
);
123 if( !(gate
->flags
& k_ent_gate_nonlocal
) ) {
124 gate_transform_update( gate
);
128 vg_async_call( world_link_nonlocal_async
, world
, 0 );
131 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_water
); j
++ ){
132 ent_water
*water
= mdl_arritm( &world
->ent_water
, j
);
133 if( world
->water
.enabled
){
134 vg_warn( "Multiple water surfaces in level!\n" );
138 world
->water
.enabled
= 1;
139 water_set_surface( world
, water
->transform
.co
[1] );
143 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_volume
); j
++ ){
144 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, j
);
145 mdl_transform_m4x3( &volume
->transform
, volume
->to_world
);
146 m4x3_invert_full( volume
->to_world
, volume
->to_local
);
150 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_audio
); j
++ ){
151 ent_audio
*audio
= mdl_arritm( &world
->ent_audio
, j
);
153 for( u32 k
=0; k
<audio
->clip_count
; k
++ ){
154 ent_audio_clip
*clip
= mdl_arritm( &world
->ent_audio_clip
,
155 audio
->clip_start
+k
);
157 if( clip
->_
.file
.pack_size
){
158 u32 size
= clip
->_
.file
.pack_size
,
159 offset
= clip
->_
.file
.pack_offset
;
161 /* embedded files are fine to clear the scratch buffer, only
162 * external audio uses it */
164 vg_linear_clear( vg_mem
.scratch
);
165 void *data
= vg_linear_alloc( vg_mem
.scratch
,
166 clip
->_
.file
.pack_size
);
168 mdl_fread_pack_file( &world
->meta
, &clip
->_
.file
, data
);
170 clip
->_
.clip
.path
= NULL
;
171 clip
->_
.clip
.flags
= audio
->flags
;
172 clip
->_
.clip
.data
= data
;
173 clip
->_
.clip
.size
= size
;
176 clip
->_
.clip
.path
= mdl_pstr(&world
->meta
,clip
->_
.file
.pstr_path
);
177 clip
->_
.clip
.flags
= audio
->flags
;
178 clip
->_
.clip
.data
= NULL
;
179 clip
->_
.clip
.size
= 0;
182 audio_clip_load( &clip
->_
.clip
, world
->heap
);
186 /* create generic entity hierachy for those who need it */
187 u32 indexed_count
= 0;
190 mdl_array_ptr
*array
;
193 { k_ent_gate
, &world
->ent_gate
},
194 { k_ent_objective
, &world
->ent_objective
},
195 { k_ent_volume
, &world
->ent_volume
},
196 { k_ent_challenge
, &world
->ent_challenge
}
199 for( u32 i
=0; i
<vg_list_size(indexables
); i
++ )
200 indexed_count
+= mdl_arrcount( indexables
[i
].array
);
201 vg_info( "indexing %u entities\n", indexed_count
);
203 world
->entity_list
= vg_linear_alloc( world
->heap
,
204 vg_align8(indexed_count
*sizeof(u32
)));
207 for( u32 i
=0; i
<vg_list_size(indexables
); i
++ ){
208 u32 type
= indexables
[i
].type
,
209 count
= mdl_arrcount( indexables
[i
].array
);
211 for( u32 j
=0; j
<count
; j
++ )
212 world
->entity_list
[index
++] = mdl_entity_id( type
, j
);
215 world
->entity_bh
= bh_create( world
->heap
, &bh_system_entity_list
, world
,
218 world
->tar_min
= world
->entity_bh
->nodes
[0].bbx
[0][1];
219 world
->tar_max
= world
->entity_bh
->nodes
[0].bbx
[1][1] + 20.0f
;
221 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_marker
); i
++ ){
222 ent_marker
*marker
= mdl_arritm( &world
->ent_marker
, i
);
224 if( MDL_CONST_PSTREQ( &world
->meta
, marker
->pstr_alias
, "tar_min" ) )
225 world
->tar_min
= marker
->transform
.co
[1];
227 if( MDL_CONST_PSTREQ( &world
->meta
, marker
->pstr_alias
, "tar_max" ) )
228 world
->tar_max
= marker
->transform
.co
[1];
233 ent_spawn
*world_find_closest_spawn( world_instance
*world
, v3f position
)
235 ent_spawn
*rp
= NULL
, *r
;
236 float min_dist
= INFINITY
;
238 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_spawn
); i
++ ){
239 r
= mdl_arritm( &world
->ent_spawn
, i
);
240 float d
= v3_dist2( r
->transform
.co
, position
);
249 if( mdl_arrcount(&world
->ent_spawn
) ){
250 vg_warn( "Invalid distances to spawns.. defaulting to first one.\n" );
251 return mdl_arritm( &world
->ent_spawn
, 0 );
254 vg_error( "There are no spawns in the level!\n" );
262 ent_spawn
*world_find_spawn_by_name( world_instance
*world
, const char *name
)
264 ent_spawn
*rp
= NULL
, *r
;
265 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_spawn
); i
++ ){
266 r
= mdl_arritm( &world
->ent_spawn
, i
);
267 if( !strcmp( mdl_pstr(&world
->meta
, r
->pstr_name
), name
) ){
274 vg_warn( "No spawn named '%s'\n", name
);
279 static void ent_volume_call( world_instance
*world
, ent_call
*call
)
281 u32 index
= mdl_entity_id_id( call
->id
);
282 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
283 if( !volume
->target
) return;
285 if( call
->function
== k_ent_function_trigger
){
286 call
->id
= volume
->target
;
288 if( volume
->flags
& k_ent_volume_flag_particles
){
289 float *co
= alloca( sizeof(float)*3 );
290 co
[0] = vg_randf64()*2.0f
-1.0f
;
291 co
[1] = vg_randf64()*2.0f
-1.0f
;
292 co
[2] = vg_randf64()*2.0f
-1.0f
;
293 m4x3_mulv( volume
->to_world
, co
, co
);
295 call
->function
= k_ent_function_particle_spawn
;
297 entity_call( world
, call
);
300 call
->function
= volume
->trigger
.event
;
301 entity_call( world
, call
);
304 else if( call
->function
== k_ent_function_trigger_leave
){
305 call
->id
= volume
->target
;
307 if( volume
->flags
& k_ent_volume_flag_particles
){
311 call
->function
= volume
->trigger
.event_leave
;
312 entity_call( world
, call
);
317 static void ent_audio_call( world_instance
*world
, ent_call
*call
){
318 if( world
->status
== k_world_status_unloading
){
319 vg_warn( "cannot modify audio while unloading world\n" );
323 u8 world_id
= (world
- world_static
.instances
) + 1;
324 u32 index
= mdl_entity_id_id( call
->id
);
325 ent_audio
*audio
= mdl_arritm( &world
->ent_audio
, index
);
329 if( call
->function
== k_ent_function_particle_spawn
){
330 v3_copy( call
->data
, sound_co
);
332 else if( call
->function
== k_ent_function_trigger
){
333 v3_copy( audio
->transform
.co
, sound_co
);
338 float chance
= vg_randf64()*100.0f
,
341 for( u32 i
=0; i
<audio
->clip_count
; i
++ ){
342 ent_audio_clip
*clip
= mdl_arritm( &world
->ent_audio_clip
,
343 audio
->clip_start
+i
);
345 float mod
= world
->probabilities
[ audio
->probability_curve
],
346 p
= clip
->probability
* mod
;
352 if( audio
->behaviour
== k_channel_behaviour_unlimited
){
353 audio_oneshot_3d( &clip
->_
.clip
, sound_co
,
354 audio
->transform
.s
[0],
357 else if( audio
->behaviour
== k_channel_behaviour_discard_if_full
){
359 audio_get_group_idle_channel( audio
->group
,
360 audio
->max_channels
);
363 audio_channel_init( ch
, &clip
->_
.clip
, audio
->flags
);
364 audio_channel_group( ch
, audio
->group
);
365 audio_channel_world( ch
, world_id
);
366 audio_channel_set_spacial( ch
, sound_co
, audio
->transform
.s
[0] );
367 audio_channel_edit_volume( ch
, audio
->volume
, 1 );
368 ch
= audio_relinquish_channel( ch
);
371 else if( audio
->behaviour
== k_channel_behaviour_crossfade_if_full
){
373 audio_get_group_idle_channel( audio
->group
,
374 audio
->max_channels
);
378 audio_channel
*existing
=
379 audio_get_group_first_active_channel( audio
->group
);
382 if( existing
->source
== &clip
->_
.clip
){
388 existing
= audio_channel_fadeout(existing
, audio
->crossfade
);
391 ch
= audio_get_first_idle_channel();
395 audio_channel_init( ch
, &clip
->_
.clip
, audio
->flags
);
396 audio_channel_group( ch
, audio
->group
);
397 audio_channel_world( ch
, world_id
);
398 audio_channel_fadein( ch
, audio
->crossfade
);
399 ch
= audio_relinquish_channel( ch
);
410 static void ent_ccmd_call( world_instance
*world
, ent_call
*call
){
411 if( call
->function
== k_ent_function_trigger
){
412 u32 index
= mdl_entity_id_id( call
->id
);
413 ent_ccmd
*ccmd
= mdl_arritm( &world
->ent_ccmd
, index
);
414 vg_execute_console_input( mdl_pstr(&world
->meta
, ccmd
->pstr_command
) );
420 * ----------------------------------------------------------------------------
424 entity_bh_expand_bound( void *user
, boxf bound
, u32 item_index
){
425 world_instance
*world
= user
;
427 u32 id
= world
->entity_list
[ item_index
],
428 type
= mdl_entity_id_type( id
),
429 index
= mdl_entity_id_id( id
);
431 if( type
== k_ent_gate
){
432 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
433 boxf box
= {{ -gate
->dimensions
[0], -gate
->dimensions
[1], -0.1f
},
434 { gate
->dimensions
[0], gate
->dimensions
[1], 0.1f
}};
436 m4x3_expand_aabb_aabb( gate
->to_world
, bound
, box
);
438 else if( type
== k_ent_objective
){
439 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
441 /* TODO: This might be more work than necessary. could maybe just get
442 * away with representing them as points */
447 for( u32 i
=0; i
<objective
->submesh_count
; i
++ ){
448 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
,
449 objective
->submesh_start
+i
);
450 box_concat( box
, sm
->bbx
);
454 mdl_transform_m4x3( &objective
->transform
, transform
);
455 m4x3_expand_aabb_aabb( transform
, bound
, box
);
457 else if( type
== k_ent_volume
){
458 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
459 m4x3_expand_aabb_aabb( volume
->to_world
, bound
,
460 (boxf
){{-1.0f
,-1.0f
,-1.0f
},{ 1.0f
, 1.0f
, 1.0f
}} );
462 else if( type
== k_ent_challenge
){
463 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
465 boxf box
= {{-1.2f
*0.5f
,-0.72f
*0.5f
,-0.01f
*0.5f
},
466 { 1.2f
*0.5f
, 0.72f
*0.5f
, 0.01f
*0.5f
}};
468 mdl_transform_m4x3( &challenge
->transform
, transform
);
469 m4x3_expand_aabb_aabb( transform
, bound
, box
);
472 vg_fatal_error( "Programming error\n" );
476 static float entity_bh_centroid( void *user
, u32 item_index
, int axis
){
477 world_instance
*world
= user
;
479 u32 id
= world
->entity_list
[ item_index
],
480 type
= mdl_entity_id_type( id
),
481 index
= mdl_entity_id_id( id
);
483 if( type
== k_ent_gate
){
484 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
485 return gate
->to_world
[3][axis
];
487 else if( type
== k_ent_objective
){
488 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
489 return objective
->transform
.co
[axis
];
491 else if( type
== k_ent_volume
){
492 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
493 return volume
->transform
.co
[axis
];
495 else if( type
== k_ent_challenge
){
496 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
497 return challenge
->transform
.co
[axis
];
500 vg_fatal_error( "Programming error\n" );
505 static void entity_bh_swap( void *user
, u32 ia
, u32 ib
){
506 world_instance
*world
= user
;
508 u32 a
= world
->entity_list
[ ia
],
509 b
= world
->entity_list
[ ib
];
511 world
->entity_list
[ ia
] = b
;
512 world
->entity_list
[ ib
] = a
;
515 static void entity_bh_debug( void *user
, u32 item_index
){
516 world_instance
*world
= user
;
518 u32 id
= world
->entity_list
[ item_index
],
519 type
= mdl_entity_id_type( id
),
520 index
= mdl_entity_id_id( id
);
522 if( type
== k_ent_gate
){
523 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
524 boxf box
= {{ -gate
->dimensions
[0], -gate
->dimensions
[1], -0.1f
},
525 { gate
->dimensions
[0], gate
->dimensions
[1], 0.1f
}};
526 vg_line_boxf_transformed( gate
->to_world
, box
, 0xf000ff00 );
528 else if( type
== k_ent_objective
){
529 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
533 for( u32 i
=0; i
<objective
->submesh_count
; i
++ ){
534 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
,
535 objective
->submesh_start
+i
);
536 box_concat( box
, sm
->bbx
);
540 mdl_transform_m4x3( &objective
->transform
, transform
);
541 vg_line_boxf_transformed( transform
, box
, 0xf000ff00 );
543 else if( type
== k_ent_volume
){
544 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
545 vg_line_boxf_transformed( volume
->to_world
,
546 (boxf
){{-1.0f
,-1.0f
,-1.0f
},{ 1.0f
, 1.0f
, 1.0f
}},
549 else if( type
== k_ent_challenge
){
550 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
552 boxf box
= {{-1.2f
*0.5f
,-0.72f
*0.5f
,-0.01f
*0.5f
},
553 { 1.2f
*0.5f
, 0.72f
*0.5f
, 0.01f
*0.5f
}};
555 mdl_transform_m4x3( &challenge
->transform
, transform
);
556 vg_line_boxf_transformed( transform
, box
, 0xf0ff0000 );
559 vg_fatal_error( "Programming error\n" );
563 static void update_ach_models(void){
564 world_instance
*hub
= &world_static
.instances
[k_world_purpose_hub
];
565 if( hub
->status
!= k_world_status_loaded
) return;
567 for( u32 i
=0; i
<mdl_arrcount( &hub
->ent_prop
); i
++ ){
568 ent_prop
*prop
= mdl_arritm( &hub
->ent_prop
, i
);
569 if( prop
->flags
& 0x2 ){
570 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "MARC" ) )
571 if( skaterift
.achievements
& 0x1 )
573 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "ALBERT" ) )
574 if( skaterift
.achievements
& 0x2 )
576 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "JANET" ) )
577 if( skaterift
.achievements
& 0x4 )
579 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "BERNADETTA" ) )
580 if( skaterift
.achievements
& 0x8 )
586 static void entity_bh_closest( void *user
, u32 item_index
, v3f point
,
588 world_instance
*world
= user
;
590 u32 id
= world
->entity_list
[ item_index
],
591 type
= mdl_entity_id_type( id
),
592 index
= mdl_entity_id_id( id
);
594 if( type
== k_ent_gate
){
595 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
596 v3_copy( gate
->to_world
[3], closest
);
598 else if( type
== k_ent_objective
){
599 ent_objective
*challenge
= mdl_arritm( &world
->ent_objective
, index
);
600 v3_copy( challenge
->transform
.co
, closest
);
602 else if( type
== k_ent_volume
){
603 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
604 v3_copy( volume
->to_world
[3], closest
);
606 else if( type
== k_ent_challenge
){
607 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
608 v3_copy( challenge
->transform
.co
, closest
);
611 vg_fatal_error( "Programming error\n" );
615 static void world_entity_start( world_instance
*world
, vg_msg
*sav
){
616 vg_info( "Start instance %p\n", world
);
618 world
->probabilities
[ k_probability_curve_constant
] = 1.0f
;
619 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_audio
); i
++ ){
620 ent_audio
*audio
= mdl_arritm(&world
->ent_audio
,i
);
621 if( audio
->flags
& AUDIO_FLAG_AUTO_START
){
624 call
.function
= k_ent_function_trigger
;
625 call
.id
= mdl_entity_id( k_ent_audio
, i
);
626 entity_call( world
, &call
);
631 * ----------------------------------------------------------------------- */
633 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_challenge
); i
++ ){
634 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, i
);
635 const char *alias
= mdl_pstr( &world
->meta
, challenge
->pstr_alias
);
637 if( vg_msg_getkvu32( sav
, alias
, 0 ) ){
641 call
.id
= mdl_entity_id( k_ent_challenge
, i
);
642 entity_call( world
, &call
);
646 vg_msg routes_block
= *sav
;
647 if( vg_msg_seekframe( &routes_block
, "routes" ) ){
648 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_route
); i
++ ){
649 ent_route
*route
= mdl_arritm( &world
->ent_route
, i
);
651 vg_msg route_info
= routes_block
;
652 if( vg_msg_seekframe( &route_info
,
653 mdl_pstr(&world
->meta
,route
->pstr_name
) ) ){
654 route
->flags
|= vg_msg_getkvu32( &route_info
, "flags", 0 );
655 route
->best_laptime
=
656 vg_msg_getkvf64( &route_info
, "best_laptime", 0.0 );
658 f32 sections
[ route
->checkpoints_count
];
660 if( vg_msg_getkvcmd( &route_info
, "sections", &cmd
) ){
661 vg_msg_cast( cmd
.value
, cmd
.code
, sections
,
663 vg_msg_count_bits(route
->checkpoints_count
) );
666 for( u32 j
=0; j
<route
->checkpoints_count
; j
++ )
670 for( u32 j
=0; j
<route
->checkpoints_count
; j
++ ){
671 ent_checkpoint
*cp
= mdl_arritm( &world
->ent_checkpoint
,
672 route
->checkpoints_start
+ j
);
674 cp
->best_time
= sections
[j
];
677 /* LEGACY: check if steam achievements can give us a medal */
678 if( steam_ready
&& steam_stats_ready
){
679 for( u32 j
=0; j
<vg_list_size(track_infos
); j
++ ){
680 struct track_info
*inf
= &track_infos
[j
];
681 if( !strcmp(inf
->name
,
682 mdl_pstr(&world
->meta
,route
->pstr_name
))){
684 steamapi_bool set
= 0;
685 if( SteamAPI_ISteamUserStats_GetAchievement(
686 hSteamUserStats
, inf
->achievement_id
, &set
) )
689 route
->flags
|= k_ent_route_flag_achieve_silver
;
699 ent_region_re_eval( world
);
702 static void world_entity_serialize( world_instance
*world
, vg_msg
*sav
){
703 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_challenge
); i
++ ){
704 ent_challenge
*challenge
= mdl_arritm(&world
->ent_challenge
,i
);
706 const char *alias
= mdl_pstr(&world
->meta
,challenge
->pstr_alias
);
707 vg_msg_wkvu32( sav
, alias
, challenge
->status
);
710 if( mdl_arrcount(&world
->ent_route
) ){
711 vg_msg_frame( sav
, "routes" );
712 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_route
); i
++ ){
713 ent_route
*route
= mdl_arritm( &world
->ent_route
, i
);
715 vg_msg_frame( sav
, mdl_pstr( &world
->meta
, route
->pstr_name
) );
717 vg_msg_wkvu32( sav
, "flags", route
->flags
);
718 vg_msg_wkvf64( sav
, "best_laptime", route
->best_laptime
);
720 f32 sections
[ route
->checkpoints_count
];
722 for( u32 j
=0; j
<route
->checkpoints_count
; j
++ ){
723 ent_checkpoint
*cp
= mdl_arritm( &world
->ent_checkpoint
,
724 route
->checkpoints_start
+ j
);
726 sections
[j
] = cp
->best_time
;
729 vg_msg_wkvnum( sav
, "sections", k_vg_msg_f32
,
730 route
->checkpoints_count
, sections
);
732 vg_msg_end_frame( sav
);
734 vg_msg_end_frame( sav
);
738 #endif /* WORLD_ENTITY_C */