2 * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
11 static world_instance
*world_current_instance(void){
12 return &world_static
.instances
[ world_static
.active_instance
];
15 static void world_init(void)
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
);
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
,
29 static void world_switch_instance( u32 index
){
30 assert( localplayer
.subsystem
== k_player_subsystem_walk
);
32 if( index
>= vg_list_size(world_static
.instances
) ){
33 vg_error( "Instance ID out of range (%u)\n", index
);
37 world_instance
*new = &world_static
.instances
[ index
];
39 if( new->status
!= k_world_status_loaded
){
40 vg_error( "Instance is not loaded (%u)\n", index
);
44 if( index
!= world_static
.active_instance
){
45 world_instance
*current
=
46 &world_static
.instances
[ world_static
.active_instance
];
47 v3_copy( localplayer
.rb
.co
, current
->player_co
);
48 v3_copy( localplayer
.angles
, current
->player_angles
);
49 current
->player_angles
[3] = player_get_heading_yaw();
52 v3_copy( new->player_co
, localplayer
.rb
.co
);
53 v3_copy( new->player_angles
, localplayer
.angles
);
54 q_axis_angle( localplayer
.rb
.q
, (v3f
){0,1,0}, new->player_angles
[3] );
56 world_static
.active_instance
= index
;
61 static int skaterift_switch_instance_cmd( int argc
, const char *argv
[] ){
63 world_switch_instance( atoi(argv
[0]) );
65 vg_info( "switch_active_instance <id>\n" );
69 static void skaterift_world_get_save_path( enum world_purpose which
,
71 addon_reg
*reg
= world_static
.instance_addons
[ which
];
75 addon_alias_uid( ®
->alias
, id
);
76 snprintf( buf
, 128, "savedata/%s.bkv", id
);
79 #include "world_entity.c"
80 #include "world_gate.c"
81 #include "world_gen.c"
82 #include "world_load.c"
83 #include "world_physics.c"
84 #include "world_render.c"
85 #include "world_sfd.c"
86 #include "world_volumes.c"
87 #include "world_water.c"
88 #include "world_audio.c"
89 #include "world_routes.c"
90 #include "world_traffic.c"
92 static void world_update( world_instance
*world
, v3f pos
){
93 world_render
.sky_time
+= world_render
.sky_rate
* vg
.time_delta
;
94 world_render
.sky_rate
= vg_lerp( world_render
.sky_rate
,
95 world_render
.sky_target_rate
,
96 vg
.time_delta
* 5.0 );
98 world_routes_update_timer_texts( world
);
99 world_routes_update( world
);
100 world_traffic_update( world
, pos
);
101 world_sfd_update( world
, pos
);
102 world_volumes_update( world
, pos
);