lap timing publish and store, username store in db
[carveJwlIkooP6JGAAIwe30JlM.git] / world.c
1 /*
2 * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef WORLD_C
6 #define WORLD_C
7
8 #include "world.h"
9 #include "network.h"
10
11 static world_instance *world_current_instance(void){
12 return &world_static.instances[ world_static.active_instance ];
13 }
14
15 static void world_init(void)
16 {
17 vg_loader_step( world_render_init, NULL );
18 vg_loader_step( world_sfd_init, NULL );
19 vg_loader_step( world_water_init, NULL );
20 vg_loader_step( world_gates_init, NULL );
21 vg_loader_step( world_routes_init, NULL );
22
23 /* Allocate dynamic world memory arena */
24 u32 max_size = 76*1024*1024;
25 world_static.heap = vg_create_linear_allocator( vg_mem.rtmemory, max_size,
26 VG_MEMORY_SYSTEM );
27 }
28
29 static void world_set_active_instance( u32 index ){
30 world_static.challenge_target = NULL;
31 world_static.challenge_timer = 0.0f;
32 world_static.focused_entity = 0;
33 world_static.focus_strength = 0.0f;
34 world_static.active_trigger_volume_count = 0;
35 world_static.active_instance = index;
36 }
37
38 static void skaterift_world_get_save_path( enum world_purpose which,
39 char buf[128] ){
40 addon_reg *reg;
41
42 if( which == k_world_purpose_hub ) reg = world_static.addon_hub;
43 else reg = world_static.addon_client;
44
45 assert( reg );
46
47 char id[76];
48 addon_alias_uid( &reg->alias, id );
49 snprintf( buf, 128, "savedata/%s.bkv", id );
50 }
51
52
53 #include "world_entity.c"
54 #include "world_gate.c"
55 #include "world_gen.c"
56 #include "world_load.c"
57 #include "world_physics.c"
58 #include "world_render.c"
59 #include "world_sfd.c"
60 #include "world_volumes.c"
61 #include "world_water.c"
62 #include "world_audio.c"
63 #include "world_routes.c"
64 #include "world_traffic.c"
65
66 static void world_update( world_instance *world, v3f pos )
67 {
68 world_render.sky_time += world_render.sky_rate * vg.time_delta;
69 world_render.sky_rate = vg_lerp( world_render.sky_rate,
70 world_render.sky_target_rate,
71 vg.time_delta * 5.0 );
72
73 world_routes_update_timer_texts( world );
74 world_routes_update( world );
75 world_traffic_update( world, pos );
76 world_sfd_update( world, pos );
77 world_volumes_update( world, pos );
78 }
79
80 #endif /* WORLD_C */