7 #include "world_load.h"
11 #include "ent_challenge.h"
12 #include "ent_skateshop.h"
13 #include "ent_route.h"
14 #include "ent_traffic.h"
16 static void world_entity_focus( u32 entity_id
){
17 localplayer
.immobile
= 1;
18 menu
.disable_open
= 1;
20 v3_zero( localplayer
.rb
.v
);
21 v3_zero( localplayer
.rb
.w
);
22 player_walk
.move_speed
= 0.0f
;
23 world_static
.focused_entity
= entity_id
;
24 skaterift
.activity
= k_skaterift_ent_focus
;
27 static void world_entity_unfocus(void){
28 localplayer
.immobile
= 0;
29 skaterift
.activity
= k_skaterift_default
;
30 menu
.disable_open
= 0;
31 srinput
.state
= k_input_state_resume
;
34 static void world_entity_focus_camera( world_instance
*world
, u32 uid
){
35 if( mdl_entity_id_type( uid
) == k_ent_camera
){
36 u32 index
= mdl_entity_id_id( uid
);
37 ent_camera
*cam
= mdl_arritm( &world
->ent_camera
, index
);
39 v3f dir
= {0.0f
,-1.0f
,0.0f
};
40 mdl_transform_vector( &cam
->transform
, dir
, dir
);
41 v3_angles( dir
, world_static
.focus_cam
.angles
);
42 v3_copy( cam
->transform
.co
, world_static
.focus_cam
.pos
);
43 world_static
.focus_cam
.fov
= cam
->fov
;
46 camera_copy( &localplayer
.cam
, &world_static
.focus_cam
);
49 world_static
.focus_cam
.nearz
= localplayer
.cam
.nearz
;
50 world_static
.focus_cam
.farz
= localplayer
.cam
.farz
;
55 static void world_entity_focus_preupdate(void){
56 f32 rate
= vg_minf( 1.0f
, vg
.time_frame_delta
* 2.0f
);
58 if( skaterift
.activity
== k_skaterift_ent_focus
)
61 vg_slewf( &world_static
.focus_strength
, active
,
62 vg
.time_frame_delta
* (1.0f
/0.5f
) );
64 u32 type
= mdl_entity_id_type( world_static
.focused_entity
),
65 index
= mdl_entity_id_id( world_static
.focused_entity
);
66 world_instance
*world
= world_current_instance();
69 if( type
== k_ent_skateshop
){
70 ent_skateshop
*skateshop
= mdl_arritm( &world
->ent_skateshop
, index
);
71 ent_skateshop_preupdate( skateshop
, active
);
73 else if( type
== k_ent_challenge
){
74 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
75 ent_challenge_preupdate( challenge
, active
);
77 else if( type
== k_ent_route
){
78 ent_route
*route
= mdl_arritm( &world
->ent_route
, index
);
79 ent_route_preupdate( route
, active
);
83 /* additional renderings like text etc.. */
84 static void world_entity_focus_render(void){
85 world_instance
*world
= world_current_instance();
86 if( skaterift
.activity
!= k_skaterift_ent_focus
){
87 skateshop_render_nonfocused( world
, &skaterift
.cam
);
91 u32 type
= mdl_entity_id_type( world_static
.focused_entity
),
92 index
= mdl_entity_id_id( world_static
.focused_entity
);
94 if( type
== k_ent_skateshop
){
95 ent_skateshop
*skateshop
= mdl_arritm( &world
->ent_skateshop
, index
);
96 skateshop_render( skateshop
);
98 else if( type
== k_ent_challenge
){}
99 else if( type
== k_ent_route
){}
100 else if( type
== k_ent_miniworld
){}
102 vg_fatal_error( "Programming error\n" );
106 static void world_gen_entities_init( world_instance
*world
){
108 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_light
); j
++ ){
109 ent_light
*light
= mdl_arritm( &world
->ent_light
, j
);
112 q_m3x3( light
->transform
.q
, to_world
);
113 v3_copy( light
->transform
.co
, to_world
[3] );
114 m4x3_invert_affine( to_world
, light
->inverse_world
);
116 light
->angle_sin_cos
[0] = sinf( light
->angle
* 0.5f
);
117 light
->angle_sin_cos
[1] = cosf( light
->angle
* 0.5f
);
121 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_gate
); j
++ ){
122 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, j
);
124 if( !(gate
->flags
& k_ent_gate_nonlocal
) ) {
125 gate_transform_update( gate
);
129 vg_async_call( world_link_nonlocal_async
, world
, 0 );
132 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_water
); j
++ ){
133 ent_water
*water
= mdl_arritm( &world
->ent_water
, j
);
134 if( world
->water
.enabled
){
135 vg_warn( "Multiple water surfaces in level!\n" );
139 world
->water
.enabled
= 1;
140 water_set_surface( world
, water
->transform
.co
[1] );
144 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_volume
); j
++ ){
145 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, j
);
146 mdl_transform_m4x3( &volume
->transform
, volume
->to_world
);
147 m4x3_invert_full( volume
->to_world
, volume
->to_local
);
151 for( u32 j
=0; j
<mdl_arrcount(&world
->ent_audio
); j
++ ){
152 ent_audio
*audio
= mdl_arritm( &world
->ent_audio
, j
);
154 for( u32 k
=0; k
<audio
->clip_count
; k
++ ){
155 ent_audio_clip
*clip
= mdl_arritm( &world
->ent_audio_clip
,
156 audio
->clip_start
+k
);
158 if( clip
->_
.file
.pack_size
){
159 u32 size
= clip
->_
.file
.pack_size
,
160 offset
= clip
->_
.file
.pack_offset
;
162 /* embedded files are fine to clear the scratch buffer, only
163 * external audio uses it */
165 vg_linear_clear( vg_mem
.scratch
);
166 void *data
= vg_linear_alloc( vg_mem
.scratch
,
167 clip
->_
.file
.pack_size
);
169 mdl_fread_pack_file( &world
->meta
, &clip
->_
.file
, data
);
171 clip
->_
.clip
.path
= NULL
;
172 clip
->_
.clip
.flags
= audio
->flags
;
173 clip
->_
.clip
.data
= data
;
174 clip
->_
.clip
.size
= size
;
177 clip
->_
.clip
.path
= mdl_pstr(&world
->meta
,clip
->_
.file
.pstr_path
);
178 clip
->_
.clip
.flags
= audio
->flags
;
179 clip
->_
.clip
.data
= NULL
;
180 clip
->_
.clip
.size
= 0;
183 audio_clip_load( &clip
->_
.clip
, world
->heap
);
187 /* create generic entity hierachy for those who need it */
188 u32 indexed_count
= 0;
191 mdl_array_ptr
*array
;
194 { k_ent_gate
, &world
->ent_gate
},
195 { k_ent_objective
, &world
->ent_objective
},
196 { k_ent_volume
, &world
->ent_volume
},
197 { k_ent_challenge
, &world
->ent_challenge
}
200 for( u32 i
=0; i
<vg_list_size(indexables
); i
++ )
201 indexed_count
+= mdl_arrcount( indexables
[i
].array
);
202 vg_info( "indexing %u entities\n", indexed_count
);
204 world
->entity_list
= vg_linear_alloc( world
->heap
,
205 vg_align8(indexed_count
*sizeof(u32
)));
208 for( u32 i
=0; i
<vg_list_size(indexables
); i
++ ){
209 u32 type
= indexables
[i
].type
,
210 count
= mdl_arrcount( indexables
[i
].array
);
212 for( u32 j
=0; j
<count
; j
++ )
213 world
->entity_list
[index
++] = mdl_entity_id( type
, j
);
216 world
->entity_bh
= bh_create( world
->heap
, &bh_system_entity_list
, world
,
219 world
->tar_min
= world
->entity_bh
->nodes
[0].bbx
[0][1];
220 world
->tar_max
= world
->entity_bh
->nodes
[0].bbx
[1][1] + 20.0f
;
222 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_marker
); i
++ ){
223 ent_marker
*marker
= mdl_arritm( &world
->ent_marker
, i
);
225 if( MDL_CONST_PSTREQ( &world
->meta
, marker
->pstr_alias
, "tar_min" ) )
226 world
->tar_min
= marker
->transform
.co
[1];
228 if( MDL_CONST_PSTREQ( &world
->meta
, marker
->pstr_alias
, "tar_max" ) )
229 world
->tar_max
= marker
->transform
.co
[1];
234 ent_spawn
*world_find_closest_spawn( world_instance
*world
, v3f position
)
236 ent_spawn
*rp
= NULL
, *r
;
237 float min_dist
= INFINITY
;
239 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_spawn
); i
++ ){
240 r
= mdl_arritm( &world
->ent_spawn
, i
);
241 float d
= v3_dist2( r
->transform
.co
, position
);
250 if( mdl_arrcount(&world
->ent_spawn
) ){
251 vg_warn( "Invalid distances to spawns.. defaulting to first one.\n" );
252 return mdl_arritm( &world
->ent_spawn
, 0 );
255 vg_error( "There are no spawns in the level!\n" );
263 ent_spawn
*world_find_spawn_by_name( world_instance
*world
, const char *name
)
265 ent_spawn
*rp
= NULL
, *r
;
266 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_spawn
); i
++ ){
267 r
= mdl_arritm( &world
->ent_spawn
, i
);
268 if( !strcmp( mdl_pstr(&world
->meta
, r
->pstr_name
), name
) ){
275 vg_warn( "No spawn named '%s'\n", name
);
280 static void ent_volume_call( world_instance
*world
, ent_call
*call
)
282 u32 index
= mdl_entity_id_id( call
->id
);
283 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
284 if( !volume
->target
) return;
286 if( call
->function
== k_ent_function_trigger
){
287 call
->id
= volume
->target
;
289 if( volume
->flags
& k_ent_volume_flag_particles
){
290 float *co
= alloca( sizeof(float)*3 );
291 co
[0] = vg_randf64()*2.0f
-1.0f
;
292 co
[1] = vg_randf64()*2.0f
-1.0f
;
293 co
[2] = vg_randf64()*2.0f
-1.0f
;
294 m4x3_mulv( volume
->to_world
, co
, co
);
296 call
->function
= k_ent_function_particle_spawn
;
298 entity_call( world
, call
);
301 call
->function
= volume
->trigger
.event
;
302 entity_call( world
, call
);
305 else if( call
->function
== k_ent_function_trigger_leave
){
306 call
->id
= volume
->target
;
308 if( volume
->flags
& k_ent_volume_flag_particles
){
312 call
->function
= volume
->trigger
.event_leave
;
313 entity_call( world
, call
);
318 static void ent_audio_call( world_instance
*world
, ent_call
*call
){
319 if( world
->status
== k_world_status_unloading
){
320 vg_warn( "cannot modify audio while unloading world\n" );
324 u8 world_id
= (world
- world_static
.instances
) + 1;
325 u32 index
= mdl_entity_id_id( call
->id
);
326 ent_audio
*audio
= mdl_arritm( &world
->ent_audio
, index
);
330 if( call
->function
== k_ent_function_particle_spawn
){
331 v3_copy( call
->data
, sound_co
);
333 else if( call
->function
== k_ent_function_trigger
){
334 v3_copy( audio
->transform
.co
, sound_co
);
339 float chance
= vg_randf64()*100.0f
,
342 for( u32 i
=0; i
<audio
->clip_count
; i
++ ){
343 ent_audio_clip
*clip
= mdl_arritm( &world
->ent_audio_clip
,
344 audio
->clip_start
+i
);
346 float mod
= world
->probabilities
[ audio
->probability_curve
],
347 p
= clip
->probability
* mod
;
353 if( audio
->behaviour
== k_channel_behaviour_unlimited
){
354 audio_oneshot_3d( &clip
->_
.clip
, sound_co
,
355 audio
->transform
.s
[0],
358 else if( audio
->behaviour
== k_channel_behaviour_discard_if_full
){
360 audio_get_group_idle_channel( audio
->group
,
361 audio
->max_channels
);
364 audio_channel_init( ch
, &clip
->_
.clip
, audio
->flags
);
365 audio_channel_group( ch
, audio
->group
);
366 audio_channel_world( ch
, world_id
);
367 audio_channel_set_spacial( ch
, sound_co
, audio
->transform
.s
[0] );
368 audio_channel_edit_volume( ch
, audio
->volume
, 1 );
369 ch
= audio_relinquish_channel( ch
);
372 else if( audio
->behaviour
== k_channel_behaviour_crossfade_if_full
){
374 audio_get_group_idle_channel( audio
->group
,
375 audio
->max_channels
);
379 audio_channel
*existing
=
380 audio_get_group_first_active_channel( audio
->group
);
383 if( existing
->source
== &clip
->_
.clip
){
389 existing
= audio_channel_fadeout(existing
, audio
->crossfade
);
392 ch
= audio_get_first_idle_channel();
396 audio_channel_init( ch
, &clip
->_
.clip
, audio
->flags
);
397 audio_channel_group( ch
, audio
->group
);
398 audio_channel_world( ch
, world_id
);
399 audio_channel_fadein( ch
, audio
->crossfade
);
400 ch
= audio_relinquish_channel( ch
);
411 static void ent_ccmd_call( world_instance
*world
, ent_call
*call
){
412 if( call
->function
== k_ent_function_trigger
){
413 u32 index
= mdl_entity_id_id( call
->id
);
414 ent_ccmd
*ccmd
= mdl_arritm( &world
->ent_ccmd
, index
);
415 vg_execute_console_input( mdl_pstr(&world
->meta
, ccmd
->pstr_command
) );
421 * ----------------------------------------------------------------------------
425 entity_bh_expand_bound( void *user
, boxf bound
, u32 item_index
){
426 world_instance
*world
= user
;
428 u32 id
= world
->entity_list
[ item_index
],
429 type
= mdl_entity_id_type( id
),
430 index
= mdl_entity_id_id( id
);
432 if( type
== k_ent_gate
){
433 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
434 boxf box
= {{ -gate
->dimensions
[0], -gate
->dimensions
[1], -0.1f
},
435 { gate
->dimensions
[0], gate
->dimensions
[1], 0.1f
}};
437 m4x3_expand_aabb_aabb( gate
->to_world
, bound
, box
);
439 else if( type
== k_ent_objective
){
440 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
442 /* TODO: This might be more work than necessary. could maybe just get
443 * away with representing them as points */
448 for( u32 i
=0; i
<objective
->submesh_count
; i
++ ){
449 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
,
450 objective
->submesh_start
+i
);
451 box_concat( box
, sm
->bbx
);
455 mdl_transform_m4x3( &objective
->transform
, transform
);
456 m4x3_expand_aabb_aabb( transform
, bound
, box
);
458 else if( type
== k_ent_volume
){
459 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
460 m4x3_expand_aabb_aabb( volume
->to_world
, bound
,
461 (boxf
){{-1.0f
,-1.0f
,-1.0f
},{ 1.0f
, 1.0f
, 1.0f
}} );
463 else if( type
== k_ent_challenge
){
464 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
466 boxf box
= {{-1.2f
*0.5f
,-0.72f
*0.5f
,-0.01f
*0.5f
},
467 { 1.2f
*0.5f
, 0.72f
*0.5f
, 0.01f
*0.5f
}};
469 mdl_transform_m4x3( &challenge
->transform
, transform
);
470 m4x3_expand_aabb_aabb( transform
, bound
, box
);
473 vg_fatal_error( "Programming error\n" );
477 static float entity_bh_centroid( void *user
, u32 item_index
, int axis
){
478 world_instance
*world
= user
;
480 u32 id
= world
->entity_list
[ item_index
],
481 type
= mdl_entity_id_type( id
),
482 index
= mdl_entity_id_id( id
);
484 if( type
== k_ent_gate
){
485 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
486 return gate
->to_world
[3][axis
];
488 else if( type
== k_ent_objective
){
489 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
490 return objective
->transform
.co
[axis
];
492 else if( type
== k_ent_volume
){
493 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
494 return volume
->transform
.co
[axis
];
496 else if( type
== k_ent_challenge
){
497 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
498 return challenge
->transform
.co
[axis
];
501 vg_fatal_error( "Programming error\n" );
506 static void entity_bh_swap( void *user
, u32 ia
, u32 ib
){
507 world_instance
*world
= user
;
509 u32 a
= world
->entity_list
[ ia
],
510 b
= world
->entity_list
[ ib
];
512 world
->entity_list
[ ia
] = b
;
513 world
->entity_list
[ ib
] = a
;
516 static void entity_bh_debug( void *user
, u32 item_index
){
517 world_instance
*world
= user
;
519 u32 id
= world
->entity_list
[ item_index
],
520 type
= mdl_entity_id_type( id
),
521 index
= mdl_entity_id_id( id
);
523 if( type
== k_ent_gate
){
524 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
525 boxf box
= {{ -gate
->dimensions
[0], -gate
->dimensions
[1], -0.1f
},
526 { gate
->dimensions
[0], gate
->dimensions
[1], 0.1f
}};
527 vg_line_boxf_transformed( gate
->to_world
, box
, 0xf000ff00 );
529 else if( type
== k_ent_objective
){
530 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
534 for( u32 i
=0; i
<objective
->submesh_count
; i
++ ){
535 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
,
536 objective
->submesh_start
+i
);
537 box_concat( box
, sm
->bbx
);
541 mdl_transform_m4x3( &objective
->transform
, transform
);
542 vg_line_boxf_transformed( transform
, box
, 0xf000ff00 );
544 else if( type
== k_ent_volume
){
545 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
546 vg_line_boxf_transformed( volume
->to_world
,
547 (boxf
){{-1.0f
,-1.0f
,-1.0f
},{ 1.0f
, 1.0f
, 1.0f
}},
550 else if( type
== k_ent_challenge
){
551 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
553 boxf box
= {{-1.2f
*0.5f
,-0.72f
*0.5f
,-0.01f
*0.5f
},
554 { 1.2f
*0.5f
, 0.72f
*0.5f
, 0.01f
*0.5f
}};
556 mdl_transform_m4x3( &challenge
->transform
, transform
);
557 vg_line_boxf_transformed( transform
, box
, 0xf0ff0000 );
560 vg_fatal_error( "Programming error\n" );
564 static void update_ach_models(void){
565 world_instance
*hub
= &world_static
.instances
[k_world_purpose_hub
];
566 if( hub
->status
!= k_world_status_loaded
) return;
568 for( u32 i
=0; i
<mdl_arrcount( &hub
->ent_prop
); i
++ ){
569 ent_prop
*prop
= mdl_arritm( &hub
->ent_prop
, i
);
570 if( prop
->flags
& 0x2 ){
571 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "MARC" ) )
572 if( skaterift
.achievements
& 0x1 )
574 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "ALBERT" ) )
575 if( skaterift
.achievements
& 0x2 )
577 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "JANET" ) )
578 if( skaterift
.achievements
& 0x4 )
580 if( MDL_CONST_PSTREQ( &hub
->meta
, prop
->pstr_alias
, "BERNADETTA" ) )
581 if( skaterift
.achievements
& 0x8 )
587 static void entity_bh_closest( void *user
, u32 item_index
, v3f point
,
589 world_instance
*world
= user
;
591 u32 id
= world
->entity_list
[ item_index
],
592 type
= mdl_entity_id_type( id
),
593 index
= mdl_entity_id_id( id
);
595 if( type
== k_ent_gate
){
596 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, index
);
597 v3_copy( gate
->to_world
[3], closest
);
599 else if( type
== k_ent_objective
){
600 ent_objective
*challenge
= mdl_arritm( &world
->ent_objective
, index
);
601 v3_copy( challenge
->transform
.co
, closest
);
603 else if( type
== k_ent_volume
){
604 ent_volume
*volume
= mdl_arritm( &world
->ent_volume
, index
);
605 v3_copy( volume
->to_world
[3], closest
);
607 else if( type
== k_ent_challenge
){
608 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
609 v3_copy( challenge
->transform
.co
, closest
);
612 vg_fatal_error( "Programming error\n" );
616 static void world_entity_start( world_instance
*world
, vg_msg
*sav
){
617 vg_info( "Start instance %p\n", world
);
619 world
->probabilities
[ k_probability_curve_constant
] = 1.0f
;
620 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_audio
); i
++ ){
621 ent_audio
*audio
= mdl_arritm(&world
->ent_audio
,i
);
622 if( audio
->flags
& AUDIO_FLAG_AUTO_START
){
625 call
.function
= k_ent_function_trigger
;
626 call
.id
= mdl_entity_id( k_ent_audio
, i
);
627 entity_call( world
, &call
);
632 * ----------------------------------------------------------------------- */
634 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_challenge
); i
++ ){
635 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, i
);
636 const char *alias
= mdl_pstr( &world
->meta
, challenge
->pstr_alias
);
638 if( vg_msg_getkvu32( sav
, alias
, 0 ) ){
642 call
.id
= mdl_entity_id( k_ent_challenge
, i
);
643 entity_call( world
, &call
);
647 vg_msg routes_block
= *sav
;
648 if( vg_msg_seekframe( &routes_block
, "routes" ) ){
649 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_route
); i
++ ){
650 ent_route
*route
= mdl_arritm( &world
->ent_route
, i
);
652 vg_msg route_info
= routes_block
;
653 if( vg_msg_seekframe( &route_info
,
654 mdl_pstr(&world
->meta
,route
->pstr_name
) ) ){
655 route
->flags
|= vg_msg_getkvu32( &route_info
, "flags", 0 );
656 route
->best_laptime
=
657 vg_msg_getkvf64( &route_info
, "best_laptime", 0.0 );
659 f32 sections
[ route
->checkpoints_count
];
661 if( vg_msg_getkvcmd( &route_info
, "sections", &cmd
) ){
662 vg_msg_cast( cmd
.value
, cmd
.code
, sections
,
664 vg_msg_count_bits(route
->checkpoints_count
) );
667 for( u32 j
=0; j
<route
->checkpoints_count
; j
++ )
671 for( u32 j
=0; j
<route
->checkpoints_count
; j
++ ){
672 ent_checkpoint
*cp
= mdl_arritm( &world
->ent_checkpoint
,
673 route
->checkpoints_start
+ j
);
675 cp
->best_time
= sections
[j
];
678 /* LEGACY: check if steam achievements can give us a medal */
679 if( steam_ready
&& steam_stats_ready
){
680 for( u32 j
=0; j
<vg_list_size(track_infos
); j
++ ){
681 struct track_info
*inf
= &track_infos
[j
];
682 if( !strcmp(inf
->name
,
683 mdl_pstr(&world
->meta
,route
->pstr_name
))){
685 steamapi_bool set
= 0;
686 if( SteamAPI_ISteamUserStats_GetAchievement(
687 hSteamUserStats
, inf
->achievement_id
, &set
) )
690 route
->flags
|= k_ent_route_flag_achieve_silver
;
700 ent_region_re_eval( world
);
703 static void world_entity_serialize( world_instance
*world
, vg_msg
*sav
){
704 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_challenge
); i
++ ){
705 ent_challenge
*challenge
= mdl_arritm(&world
->ent_challenge
,i
);
707 const char *alias
= mdl_pstr(&world
->meta
,challenge
->pstr_alias
);
708 vg_msg_wkvu32( sav
, alias
, challenge
->status
);
711 if( mdl_arrcount(&world
->ent_route
) ){
712 vg_msg_frame( sav
, "routes" );
713 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_route
); i
++ ){
714 ent_route
*route
= mdl_arritm( &world
->ent_route
, i
);
716 vg_msg_frame( sav
, mdl_pstr( &world
->meta
, route
->pstr_name
) );
718 vg_msg_wkvu32( sav
, "flags", route
->flags
);
719 vg_msg_wkvf64( sav
, "best_laptime", route
->best_laptime
);
721 f32 sections
[ route
->checkpoints_count
];
723 for( u32 j
=0; j
<route
->checkpoints_count
; j
++ ){
724 ent_checkpoint
*cp
= mdl_arritm( &world
->ent_checkpoint
,
725 route
->checkpoints_start
+ j
);
727 sections
[j
] = cp
->best_time
;
730 vg_msg_wkvnum( sav
, "sections", k_vg_msg_f32
,
731 route
->checkpoints_count
, sections
);
733 vg_msg_end_frame( sav
);
735 vg_msg_end_frame( sav
);
739 #endif /* WORLD_ENTITY_C */