scoreboard stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
1 /*
2 * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef WORLD_H
6 #define WORLD_H
7
8 #include "render.h"
9 #include "network_msg.h"
10
11 /* types
12 */
13
14 enum world_geo_type{
15 k_world_geo_type_solid = 0,
16 k_world_geo_type_nonsolid = 1,
17 k_world_geo_type_water = 2
18 };
19
20 enum world_purpose{
21 k_world_purpose_hub = 0,
22 k_world_purpose_client = 1,
23 k_world_max
24 };
25
26 struct leaderboard_cache {
27 enum request_status status;
28 f64 cache_time;
29 u8 *data;
30 u32 data_len;
31 };
32
33 typedef struct world_instance world_instance;
34
35 static void skaterift_world_get_save_path( enum world_purpose which,
36 char buf[128] );
37
38 /* submodule headers */
39 #include "world_entity.h"
40 #include "world_gate.h"
41 #include "world_gen.h"
42 #include "world_info.h"
43 #include "world_load.h"
44 #include "world_physics.h"
45 #include "world_render.h"
46 #include "world_sfd.h"
47 #include "world_volumes.h"
48 #include "world_water.h"
49 #include "world_audio.h"
50 #include "world_routes.h"
51
52 /* console variables */
53
54 static f32 k_day_length = 30.0f; /* minutes */
55 static i32 k_debug_light_indices = 0,
56 k_debug_light_complexity= 0,
57 k_light_preview = 0;
58
59
60 struct world_instance {
61 /* Fixed items
62 * -------------------------------------------------------
63 */
64
65 void *heap;
66 enum world_status{
67 k_world_status_unloaded = 0,
68 k_world_status_loading = 1,
69 k_world_status_loaded = 2,
70 k_world_status_unloading = 3 /* dont spawn sounds and stuff */
71 }
72 status;
73
74 struct{
75 boxf depthbounds;
76 int depth_computed;
77
78 float height;
79 int enabled;
80 v4f plane;
81 }
82 water;
83
84 f64 time;
85
86 /* STD140 */
87 struct ub_world_lighting{
88 v4f g_cube_min,
89 g_cube_inv_range;
90
91 v4f g_water_plane,
92 g_depth_bounds;
93
94 v4f g_daysky_colour;
95 v4f g_nightsky_colour;
96 v4f g_sunset_colour;
97 v4f g_ambient_colour;
98 v4f g_sunset_ambient;
99 v4f g_sun_colour;
100 v4f g_sun_dir;
101 v4f g_board_0;
102 v4f g_board_1;
103
104 float g_water_fog;
105 float g_time;
106 float g_realtime;
107 float g_shadow_length;
108 float g_shadow_spread;
109
110 float g_time_of_day;
111 float g_day_phase;
112 float g_sunset_phase;
113
114 int g_light_preview;
115 int g_shadow_samples;
116
117 int g_debug_indices;
118 int g_debug_complexity;
119 }
120 ub_lighting;
121 GLuint ubo_lighting;
122 int ubo_bind_point;
123
124 GLuint tbo_light_entities,
125 tex_light_entities,
126 tex_light_cubes;
127
128 float probabilities[3];
129
130 v3i light_cubes;
131 struct framebuffer heightmap;
132
133 /*
134 * Dynamically allocated when world_load is called.
135 *
136 * the following arrays index somewhere into this linear
137 * allocator
138 * --------------------------------------------------------------------------
139 */
140
141 /*
142 * Main world .mdl
143 */
144 mdl_context meta;
145
146 GLuint *textures;
147 u32 texture_count;
148
149 struct world_surface{
150 mdl_material info;
151 mdl_submesh sm_geo,
152 sm_no_collide;
153 }
154 * surfaces;
155 u32 surface_count;
156
157 ent_worldinfo info;
158 mdl_array_ptr ent_spawn,
159 ent_gate,
160 ent_light,
161 ent_route_node,
162 ent_path_index,
163 ent_checkpoint,
164 ent_route,
165 ent_water,
166
167 ent_audio_clip,
168 ent_audio,
169 ent_volume,
170 ent_traffic,
171 ent_skateshop,
172 ent_marker,
173 ent_camera,
174 ent_swspreview,
175 ent_ccmd,
176 ent_objective,
177 ent_challenge,
178 ent_relay,
179 ent_cubemap;
180
181 ent_gate *rendering_gate;
182
183 /* logic
184 * ----------------------------------------------------
185 */
186
187 /* world geometry */
188 scene_context scene_geo,
189 scene_no_collide,
190 scene_lines;
191
192 /* spacial mappings */
193 bh_tree *geo_bh,
194 *entity_bh;
195 u32 *entity_list;
196
197 /* graphics */
198 glmesh mesh_route_lines;
199 glmesh mesh_geo,
200 mesh_no_collide,
201 mesh_water;
202 u32 cubemap_cooldown, cubemap_side;
203
204 rb_object rb_geo;
205
206 /* leaderboards */
207 struct leaderboard_cache *leaderboard_cache;
208 };
209
210 struct world_static {
211 /*
212 * Allocated as system memory
213 * --------------------------------------------------------------------------
214 */
215 void *heap;
216
217 u32 current_run_version;
218 double time, rewind_from, rewind_to, last_use;
219
220 u32 active_trigger_volumes[8];
221 u32 active_trigger_volume_count;
222
223 addon_reg *instance_addons[ k_world_max ];
224 world_instance instances[ k_world_max ];
225
226 enum world_purpose active_instance;
227 u32 focused_entity; /* like skateshop, challenge.. */
228 f32 focus_strength;
229 camera focus_cam;
230
231 /* challenges */
232 ent_objective *challenge_target;
233 f32 challenge_timer;
234
235 enum world_loader_state{
236 k_world_loader_none,
237 k_world_loader_preload,
238 k_world_loader_load
239 }
240 load_state;
241 }
242 static world_static;
243
244 static void world_init(void);
245 static world_instance *world_current_instance(void);
246 static void world_set_active_instance( u32 index );
247
248 #endif /* WORLD_H */