//////////////////////////////// //~ Binds //- Bind kinds typedef i32 BindKind; enum { 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[P_Btn_Count] = { [P_Btn_W] = BindKind_MoveUp, [P_Btn_S] = BindKind_MoveDown, [P_Btn_A] = BindKind_MoveLeft, [P_Btn_D] = BindKind_MoveRight, [P_Btn_M1] = BindKind_Fire, [P_Btn_M2] = BindKind_AltFire, #if 0 [P_Btn_Alt] = BindKind_Walk, #endif /* Testing */ [P_Btn_Z] = BindKind_TestTile, [P_Btn_M5] = BindKind_DebugDrag, [P_Btn_M4] = BindKind_DebugDelete, [P_Btn_F] = BindKind_DebugExplode, [P_Btn_T] = BindKind_DebugTeleport, [P_Btn_C] = BindKind_DebugClear, [P_Btn_1] = BindKind_DebugSpawn1, [P_Btn_2] = BindKind_DebugSpawn2, [P_Btn_3] = BindKind_DebugSpawn3, [P_Btn_4] = BindKind_DebugSpawn4, [P_Btn_G] = BindKind_DebugWalls, [P_Btn_N] = BindKind_DebugStep, [P_Btn_Q] = BindKind_DebugFollow, [P_Btn_F1] = BindKind_DebugPause, [P_Btn_F2] = BindKind_DebugCamera, [P_Btn_F3] = BindKind_DebugDraw, [P_Btn_F4] = BindKind_DebugToggleTopmost, [P_Btn_GraveAccent] = BindKind_DebugConsole, [P_Btn_Alt] = BindKind_FullscreenMod, [P_Btn_Enter] = BindKind_Fullscreen, [P_Btn_MWheelUp] = BindKind_ZoomIn, [P_Btn_MWheelDown] = BindKind_ZoomOut, [P_Btn_M3] = BindKind_Pan, #if RtcIsEnabled [P_Btn_ForwardSlash] = BindKind_ResetDebugSteps, [P_Btn_Comma] = BindKind_DecrementDebugSteps, [P_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; }; //////////////////////////////// //~ Shared state 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; Counter shutdown_job_counters; P_Window *window; GPU_Swapchain *swapchain; struct sim_ctx *local_sim_ctx; 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; //- Gpu resources GPU_RenderSig *render_sig; BindState bind_states[BindKind_Count]; //- Debug camera EntityId debug_following; b32 debug_camera; b32 debug_camera_panning; Vec2 debug_camera_pan_start; b32 debug_draw; //- 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 +