//////////////////////////////////////////////////////////// //~ Binds //- Bind kinds Enum(BindKind) { BindKind_None, BindKind_MoveUp, BindKind_MoveDown, BindKind_MoveLeft, BindKind_MoveRight, BindKind_Walk, BindKind_Fire, BindKind_AltFire, BindKind_TestTile, BindKind_DebugClear, BindKind_DebugSpawn1, BindKind_DebugSpawn2, BindKind_DebugSpawn3, BindKind_DebugSpawn4, BindKind_DebugWalls, BindKind_DebugFollow, BindKind_DebugDraw, BindKind_DebugConsole, BindKind_DebugCamera, BindKind_DebugPause, BindKind_DebugStep, BindKind_DebugDrag, BindKind_DebugDelete, BindKind_DebugTeleport, BindKind_DebugExplode, BindKind_DebugToggleTopmost, BindKind_FullscreenMod, BindKind_Fullscreen, BindKind_ZoomIn, BindKind_ZoomOut, BindKind_Pan, #if RtcIsEnabled /* Debug */ BindKind_ResetDebugSteps, BindKind_IncrementDebugSteps, BindKind_DecrementDebugSteps, #endif BindKind_Count }; //- Test bindings /* TODO: Remove this */ Global Readonly BindKind g_binds[Btn_Count] = { [Btn_W] = BindKind_MoveUp, [Btn_S] = BindKind_MoveDown, [Btn_A] = BindKind_MoveLeft, [Btn_D] = BindKind_MoveRight, [Btn_M1] = BindKind_Fire, [Btn_M2] = BindKind_AltFire, #if 0 [Btn_Alt] = BindKind_Walk, #endif /* Testing */ [Btn_Z] = BindKind_TestTile, [Btn_M5] = BindKind_DebugDrag, [Btn_M4] = BindKind_DebugDelete, [Btn_F] = BindKind_DebugExplode, [Btn_T] = BindKind_DebugTeleport, [Btn_C] = BindKind_DebugClear, [Btn_1] = BindKind_DebugSpawn1, [Btn_2] = BindKind_DebugSpawn2, [Btn_3] = BindKind_DebugSpawn3, [Btn_4] = BindKind_DebugSpawn4, [Btn_G] = BindKind_DebugWalls, [Btn_N] = BindKind_DebugStep, [Btn_Q] = BindKind_DebugFollow, [Btn_F1] = BindKind_DebugPause, [Btn_F2] = BindKind_DebugCamera, [Btn_F3] = BindKind_DebugDraw, [Btn_F4] = BindKind_DebugToggleTopmost, [Btn_GraveAccent] = BindKind_DebugConsole, [Btn_Alt] = BindKind_FullscreenMod, [Btn_Enter] = BindKind_Fullscreen, [Btn_MWheelUp] = BindKind_ZoomIn, [Btn_MWheelDown] = BindKind_ZoomOut, [Btn_M3] = BindKind_Pan, #if RtcIsEnabled [Btn_ForwardSlash] = BindKind_ResetDebugSteps, [Btn_Comma] = BindKind_DecrementDebugSteps, [Btn_Period] = BindKind_IncrementDebugSteps #endif }; //////////////////////////////////////////////////////////// //~ Stats Struct(SecondsStat) { u64 last_second_start; u64 last_second_end; u64 last_second; }; //////////////////////////////////////////////////////////// //~ Console log Struct(ConsoleLog) { String msg; i32 level; i32 color_index; P_DateTime datetime; i64 time_ns; Rect bounds; ConsoleLog *prev; ConsoleLog *next; }; //////////////////////////////////////////////////////////// //~ Sim decode queue Struct(DecodeQueueNode) { Client *client; u64 tick; u64 base_tick; String tmp_encoded; DecodeQueueNode *next; }; Struct(DecodeQueue) { DecodeQueueNode *first; DecodeQueueNode *last; }; //////////////////////////////////////////////////////////// //~ State types Struct(BindState) { b32 is_held; /* Is this bind held down this frame */ u32 num_presses; /* How many times was this bind's pressed since last frame */ u32 num_repeats; /* How many times was this bind's key repeated since last frame */ u32 num_presses_and_repeats; /* Same as `num_presses` but includes key repeats as well */ u32 num_releases; /* How many times was this bind released since last frame */ }; Struct(SharedUserState) { Atomic32 shutdown; Fence shutdown_jobs_fence; u64 shutdown_jobs_count; Arena *arena; String connect_address_str; ClientStore *user_client_store; Client *user_unblended_client; /* Contains snapshots received from local sim */ Client *user_blended_client; /* Contains single snapshot from result of blending local sim snapshots */ Snapshot *ss_blended; /* Points to blended snapshot contained in blended client */ //- Usage stats i64 last_second_reset_ns; SecondsStat net_bytes_read; SecondsStat net_bytes_sent; //- Renderer gbuffers GPU_Resource *albedo; GPU_Resource *emittance; GPU_Resource *emittance_flood_read; GPU_Resource *emittance_flood_target; GPU_Resource *shade_read; GPU_Resource *shade_target; //- Renderer transient buffers GPU_TransientBuffer material_instances_tbuff; GPU_TransientBuffer grids_tbuff; Arena *material_instances_arena; Arena *grids_arena; //- Renderer state RandState frame_rand; u64 frame_index; i64 gpu_render_fence_target; //- Bind state BindState bind_states[BindKind_Count]; //- Debug console Mutex console_logs_mutex; Arena *console_logs_arena; ConsoleLog *first_console_log; ConsoleLog *last_console_log; i32 console_log_color_indices[P_LogLevel_Count]; f32 console_logs_height; b32 debug_console; //- Window -> user Mutex sys_window_events_mutex; Arena *sys_window_events_arena; //- User -> sim Mutex user_sim_cmd_mutex; ControlData user_sim_cmd_control; EntityId user_hovered_ent; u64 last_user_sim_cmd_gen; u64 user_sim_cmd_gen; Atomic32 user_paused; Atomic32 user_paused_steps; //- Sim -> user Mutex local_to_user_client_mutex; ClientStore *local_to_user_client_store; Client *local_to_user_client; i64 local_to_user_client_publish_dt_ns; i64 local_to_user_client_publish_time_ns; //- Local sim -> user rolling window of publish time deltas i64 last_local_to_user_snapshot_published_at_ns; i64 average_local_to_user_snapshot_publish_dt_ns; i64 local_sim_predicted_time_ns; /* Calculated from +