Added Server Browser and Lobby Server (#10, #45, #35), in-game chat (#8) and minor bug fixes (#36)#46
Open
AMacro wants to merge 636 commits into
Open
Added Server Browser and Lobby Server (#10, #45, #35), in-game chat (#8) and minor bug fixes (#36)#46AMacro wants to merge 636 commits into
AMacro wants to merge 636 commits into
Conversation
This was referenced Sep 22, 2024
Open
Open
Jarnster
pushed a commit
to Jarnster/dv-multiplayer
that referenced
this pull request
Nov 27, 2024
Fix project board link in the README
1e8fee4 to
48e900a
Compare
PluggableObjects automatically return home at `Awake()` - patch this behaviour and prevent the bulk update from applying until the initialisation is complete
Add null checks in NetworkClient.SendHoseConnected to avoid null reference exceptions when either coupler is missing
Add a debug-only Harmony patch that triggers ExportSaveData.DumpSaveData when StartGameData_FromSaveGame.GetSaveGameData runs.
Port update subscription refactored so that ports for controls inheriting from OverridableBaseControl are not subscribed to, instead using the OverridableBaseControl.ControlUpdated() event. ControlUpdated() is not triggered by MU propagation.
- Add ObiRopeGrabAreaHandler and ObiRopeGrabAreaPatch to wrap ObiRopeGrabAreas, surface Grabbed/Ungrabbed events and handle interaction enable/disable requests. - Update NetworkedTrainCar: - Add INTERIOR_CONTROLS_TIMEOUT and state for InteriorControlsManager, scroll delegates and active scrolling coroutines. - Use a coroutine-based HookControls flow that waits for control initialisation, hooks standard controls and ObiRope handlers, registers scroll events, and logs warnings for missing ports/implementations. - Block control port updates from being transmitted when a control is marked blocked. - Implement Client_ControlScrolled / Client_CheckScrolling to request authority while scrolling and release when done. - Implement WaitForControlToSettle before releasing authority on physics-driven controls. - Improve cleanup: stop scrolling coroutines and remove delegates on teardown. - Update Client_ReceiveAuthorityUpdate to properly enable/disable controls and related components (hinges, whistle rope, handcar bar) and stop active scroll coroutines when blocking. - Fix NetworkServer send-to-all logic: change excludeSelf handling when broadcasting packets.
Add PlayerListPosition enum and window constants to PlayerListGUI and compute the player list window Rect based on a new setting (TopLeft, TopRight, TopCenter). Adjust positioning logic (including special-case centering when ShowStats is enabled) and keep dynamic height. Expose the new PlayerListPosition setting in Settings with default TopCenter and visible only when ShowPlayerListInAltMouseMode is enabled.
Add defensive checks, logging and safer event wiring to avoid NREs. Adds null checks and warnings for TrainCar, couplers, controlsOverrider, simulationFlow and brakeSystem; protects coupler/control/fuse/port subscription loops; guards brake event hookups; improves debug/warning messages; and wraps control-settling loop in a try/finally so authority is always released. Overall improves robustness and diagnostics during initialisation and control handling.
Add a log entry when receiving a player-joined packet. Adjust the loading UI text from "Syncing Rolling Stock" to "Syncing rolling stock" for consistent casing.
…sting playerId Add a guard in ClientPlayerManager.AddPlayer to detect if a player with the same playerId already exists. If found, log a warning and remove the existing player before instantiating a new player.
* Reorganise packet subscriptions in NetworkServer * Enable client car spawning Added ServerboundTrainSpawnRequestPacket and server-side validation for client-initiated car spawns. Updated NetworkedCarSpawner and related patches to support new spawn flow and play spawn sounds for player-initiated spawns. Removed unused ClientboundSpawnTrainCarPacket * Fix job overview despawn on clients Removed call to `ClearAvailableJobOverviewGOs` in `NetworkedStationController`. Fixes issue where clearing a carriage for an available job causes all client job overviews to despawn at the station. * Refactor job item destruction logic Moved the logic for destroying JobOverview and JobBooklet items into dedicated methods in NetworkedJob. Updated NetworkedStationController to use these new methods, improving code clarity and encapsulation. Fixed error where a job overview could be destroyed while in a client's inventory, and slot would remain used (item not properly removed) * Initial commit for Work Train Functionality Allow clients to request work trains. * Refactored sync process for players joining the server Add a basic player loading state machine and use PlayerLoadingState throughout the codebase to coordinate world synchronisation. Replaces boolean IsLoaded checks with LoadingState and introduces ClientboundLoadStateInfoPacket and ServerboundLoadStateUpdatePacket (removing older single-step packets). Client now runs a SyncWorldState coroutine that advances through discrete states (game data, world state, trainsets, items, jobs, tiles, complete) and requests the server for each phase; server handles those states and streams the appropriate data (including trainset counts). Trainset and restoration support updated: TrainsetSpawnPart now encodes RestorationType and optional second-car netId, RestorationData/RestorationType structs added, and NetworkedCarSpawner collects/apply restoration states after spawning. Add Harmony transpiler patch for LocoRestorationController start logic to respect world sync completion. Misc: ServerPlayer gains LoadingState/LastLogin/TotalPlaytime, various managers (item/culling/savegame) check LoadingState thresholds, logging and minor serialization fixes. * Add debug save export and tidy settings Add debug utility to dump saves as readable JSON * Improve debug logging for IdMonoBehaviours * Filter outgoing packets by player loading state Introduce a PlayerLoadingState filter to Server.SendPacketToAll so the server skips peers that haven't reached a minimum load state. Update the SendPacketToAll signature and calling sites across the server to supply appropriate minimumLoadState values (ReadyForWorldState, ReadyForTrainSets, ReadyForJobs, Complete, etc.), preventing premature packet delivery. Also add handling for the Complete load state and kick on unexpected load-state in server load-state processing. Minor client tweaks: mark railwayStateLoaded instead of requesting cars and remove small whitespace/noise in brake update handling. Add DV.Customization using directive. * Remove playerSpawned param from SendSpawnTrainset * Change NetworkedStationController netId Generation to use hashes Convert station network IDs from ushort to uint across networking code and packets. Update NetworkedStationController to use uint generic ID, compute NetId from station ID (Fnv1a hash) during registration, and set IsIdServerAuthoritative to false. Adjust job-related APIs: JobData.FromJob signature simplified, JobUpdateStruct.ValidationStationId changed to uint (with corresponding serialization), and client/server job packets updated to use uint StationNetId. Remove an unused GetAll helper. * Reorganise client packet subscriptions Reorganise NetworkClient.Subscribe() into logical groups for readability * Improve client loading progress and timing Update NetworkClient loading flow and UI: show dynamic progress percent (based on LoadingState/PlayerLoadingState.Complete) instead of hardcoded 100, add/loading status updates for rolling stock and final Complete, and log when requesting cars. Change railway wait to use railwayStateLoaded and move the ReadyForTrainSets state update to after railway state is loaded. Reduce several artificial waits from 0.5s to 0.25s for snappier loading transitions. * Skip loco restoration popup when player is far from loco Patch LocoRestorationController.SetState() to replace the call to LocoRestorationView.GetStatusMessageFor with a custom method which checks the player's distance to the loco and tender. If the player is beyond the threshold range from vehicle the method returns null to prevent the restoration popup from showing. * Add transportCars sync for Demonstrators * Fix deposited cash check and null-safe player list Validate payment using CashRegister.DepositedCash instead of the player's Inventory money so the register checks the actual deposited amount against the total cost. Also add null-conditional access for _cullingManager.ActivePlayers when sending the packet to avoid a potential null reference if the culling manager or its ActivePlayers collection is not set. * Add sync for restoration parts purchased Send parts purchased event to all clients. Increase distance at which LocoRestorationState notifications are displayed from 50m to 100m. * Complete loco restoration sync * Send generic switch states on player join * Add null check in SendHoseConnected Add null checks in NetworkClient.SendHoseConnected to avoid null reference exceptions when either coupler is missing * Add a debug mode to export savegame data at load Add a debug-only Harmony patch that triggers ExportSaveData.DumpSaveData when StartGameData_FromSaveGame.GetSaveGameData runs. * Fix issues with MU Jank Port update subscription refactored so that ports for controls inheriting from OverridableBaseControl are not subscribed to, instead using the OverridableBaseControl.ControlUpdated() event. ControlUpdated() is not triggered by MU propagation. * Fix issues with control jank with multiple players in the cab - Add ObiRopeGrabAreaHandler and ObiRopeGrabAreaPatch to wrap ObiRopeGrabAreas, surface Grabbed/Ungrabbed events and handle interaction enable/disable requests. - Update NetworkedTrainCar: - Add INTERIOR_CONTROLS_TIMEOUT and state for InteriorControlsManager, scroll delegates and active scrolling coroutines. - Use a coroutine-based HookControls flow that waits for control initialisation, hooks standard controls and ObiRope handlers, registers scroll events, and logs warnings for missing ports/implementations. - Block control port updates from being transmitted when a control is marked blocked. - Implement Client_ControlScrolled / Client_CheckScrolling to request authority while scrolling and release when done. - Implement WaitForControlToSettle before releasing authority on physics-driven controls. - Improve cleanup: stop scrolling coroutines and remove delegates on teardown. - Update Client_ReceiveAuthorityUpdate to properly enable/disable controls and related components (hinges, whistle rope, handcar bar) and stop active scroll coroutines when blocking. - Fix NetworkServer send-to-all logic: change excludeSelf handling when broadcasting packets. * Make player list position configurable Add PlayerListPosition enum and window constants to PlayerListGUI and compute the player list window Rect based on a new setting (TopLeft, TopRight, TopCenter). Adjust positioning logic (including special-case centering when ShowStats is enabled) and keep dynamic height. Expose the new PlayerListPosition setting in Settings with default TopCenter and visible only when ShowPlayerListInAltMouseMode is enabled. * Ready for Pre-release testing * Clean up incorrect logging * Harden NetworkedTrainCar.Start() Add defensive checks, logging and safer event wiring to avoid NREs. Adds null checks and warnings for TrainCar, couplers, controlsOverrider, simulationFlow and brakeSystem; protects coupler/control/fuse/port subscription loops; guards brake event hookups; improves debug/warning messages; and wraps control-settling loop in a try/finally so authority is always released. Overall improves robustness and diagnostics during initialisation and control handling. * Add null checks for cleanup handlers * Improve logging Add a log entry when receiving a player-joined packet. Adjust the loading UI text from "Syncing Rolling Stock" to "Syncing rolling stock" for consistent casing. * Attempt to fix a bug where a newly added playerId clashes with an existing playerId Add a guard in ClientPlayerManager.AddPlayer to detect if a player with the same playerId already exists. If found, log a warning and remove the existing player before instantiating a new player.
Add a lobby metadata check in both join-request and invite handlers so only lobbies tagged with the multiplayer mod key are processed. This prevents reacting to unrelated Steam lobby requests.
Pre-size `itemBaseToNetworkedItem` with a capacity of 4096 to reduce dictionary reallocations, and change `GetAll()` to return the dictionary `ValueCollection` directly instead of allocating a filtered list. This cuts per-call allocations and improves access performance for cached networked items.
Preallocate common collections in `NetworkedItemManager`, reduce a few allocations, and quiet noisy debug logging. Also switch the item cache error path to error-level logging so failures are more visible.
Delay host initialization for networked junctions and turntables until Start when the server may not be running during Awake, while still handling already-running servers. Also prevent duplicate ID components with DisallowMultipleComponent and switch the turntable patch to GetOrAddComponent to avoid adding duplicate NetworkedTurntable instances.
Adds a new `FastTravelAdvancesTime` gameplay setting and propagates it from server to clients via `ClientboundGameParamsPacket`.
Use `pwsh` instead of `powershell` on non-Windows platforms, with forward-slash paths and `ContinueOnError=true` to handle missing PowerShell gracefully.
Prevent clients and host (when other players are connected) from fast travelling with loco. This can be re-enabled once fast travel has been: 1. Made server authoritative 2. Can teleport locos safely, without causing de-syncs (refer to Work Trains code for a possible method)
Adds a Harmony postfix patch on SaveLoadController.RefreshInterface to disable the load save button when not in the main menu, preventing a softlock that occurs when loading a save game mid-session.
Add a server-side flag for whether fast travel should advance time, and import the world patch namespace needed to support that behavior.
commit e36d604 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jul 12 19:09:51 2026 +1000 Refactor player position sync and add VR tracking Replaced per-field position packets with a `PlayerTrackingData` payload that serializes only changed tracking fields, and wired it through client/server packet handling and player state storage. Local player tracking was consolidated into a shared base flow with non-VR/VR-specific hooks, including VR hand pose deltas and controller re-init logic. Added a `NetworkedPlayerIKHandler` and enabled IK pass in the locomotion animator so remote VR hand targets can drive avatar IK. Enabled IK pass in the locomotion controller to allow IK data to be used. commit 9a4031c Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jul 12 19:05:25 2026 +1000 Collect VR flag at player login Add an `IsVR` field across the login and player-join flow so VR state is sent by clients, stored on `ServerPlayer`, and broadcast to other clients. Client-side player creation now receives and stores this flag on `NetworkedPlayer` for downstream VR-specific behavior. commit b9d1ced Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jul 12 19:03:05 2026 +1000 Move PlayerPreference to Player namespace Relocated `PlayerPreference` to `Networking/Data/Player` and changed its namespace to `Multiplayer.Networking.Data.Player` to better group player-specific data. Updated all affected references/usings in server/client managers and preference packet classes to match the new location. commit 56b0e7b Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jul 12 06:48:11 2026 +1000 Refactor CustomFirspersonControllerPatch Create a LocalPlayerTrackerNonVR and LocalPlayerTrackerVR class to replace CustomFirstpersonControllerPatch functionality. commit 801bfa1 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jul 11 21:37:53 2026 +1000 Add Sit Logic Adds sit animations, updates the locomotion controller and animation handler and implements transmission of sit height commit 92c3009 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jul 11 13:37:41 2026 +1000 Add Lean poses commit 8717f1f Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jul 11 13:18:53 2026 +1000 Fix debug logs commit a8aa027 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Tue Jul 7 19:40:49 2026 +1000 Send player posture Replace the old packed jump/car bitfield with explicit posture flags and a separate on-car field. commit 39eba9b Author: Macka <andrew@andrewcraigmackenzie.com> Date: Tue Jul 7 17:54:17 2026 +1000 Fix foot offset in sit and crouch pose commit f1de4c6 Author: AMacro <andrew@andrewcraigmackenzie.com> Date: Sat May 10 14:40:02 2025 +1000 Continue work on Locomotions Controller commit 0af88f0 Author: AMacro <andrew@andrewcraigmackenzie.com> Date: Mon May 5 12:28:04 2025 +1000 Tidied up animations commit c5bc16b Author: AMacro <andrew@andrewcraigmackenzie.com> Date: Mon May 5 12:17:30 2025 +1000 Added swimming and fixed crouch walk commit 5694197 Author: AMacro <andrew@andrewcraigmackenzie.com> Date: Mon May 5 11:24:36 2025 +1000 Crouch walk working commit 9f5f547 Author: AMacro <andrew@andrewcraigmackenzie.com> Date: Mon May 5 09:49:29 2025 +1000 Fix easing poses commit cf86923 Author: AMacro <andrew@andrewcraigmackenzie.com> Date: Mon May 5 00:26:49 2025 +1000 Add crouch and sit poses commit 72aa965 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Tue Jul 7 12:53:52 2026 +1000 Improve player head tracking Switch networked player head tracking to the animated head bone instead of a fixed child lookup. Update local player head tracking to work with VR commit 9189e88 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jun 6 21:12:00 2026 +1000 Add handling for nonVR player head and item pitch commit d6af0b1 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jul 5 20:47:43 2026 +1000 Fix preview camera and VR model rotation Moves `ModelRotator` into the UI settings namespace and extends drag handling for both flat and VR pointer workflows. Updates character preview camera setup/lifecycle (render texture descriptor, enable/disable timing, and cleanup) Makes `PlayerModelRegistry` reloadable - returning to main menu causes assets to be unloaded and prefabs become null. commit 3232b98 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jul 5 20:09:37 2026 +1000 Split tooltips for character selector commit c028e83 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jul 4 19:24:45 2026 +1000 Update localisation strings commit 8b25ab3 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jun 28 21:04:37 2026 +1000 Update models Fix prefab naming convention and create a new model for a Tic Tac for nostalgia with Patrick van Halm's original DV MP mod commit 88c61c3 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jun 28 21:01:40 2026 +1000 Add support for players choosing a character model Allow players to choose and change character models as desired commit 25e2448 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jun 28 20:34:34 2026 +1000 Add player model registry and fallback logic Create a centralised player model registry for future support of custom models. commit 8861fc7 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jun 27 23:17:02 2026 +1000 Add key bind UI for chat key setting Implements a KeyBindInterface singleton that shows a fullscreen overlay and captures keyboard input with a countdown timeout. Wires it into the multiplayer settings menu so users can rebind the chat key. Also adds a locale key for the overlay text and excludes Escape/SysReq from valid key bind targets. commit b6245a4 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jun 27 23:07:49 2026 +1000 Fix character selector settings sync Align the character selector with saved settings, keep Apply state in sync with the selected character, and preserve the menu state when returning from discard/apply. Also removes stale selector cleanup and debug code now covered by the new flow. commit a280a34 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jun 27 23:07:07 2026 +1000 Reorganise server browser UI components Move server browser and grid view classes into dedicated UI namespaces and folders commit a322139 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sat Jun 27 17:51:03 2026 +1000 Refactor the spawning of UI Controls commit 7d08286 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Tue Jun 23 23:02:34 2026 +1000 Improve character selector UI and settings Refactor and enhance the multiplayer character selector and settings UI: - CharacterSelectorMenu: resize preview render target (512->435), adjust layout padding/alignment, extract BuildCharacterSelector, rename vars to previewModel/selectedIndex, add OnEnable/OnDisable to wire BottomButtons and Apply/Discard handlers, add SettingsChanged stub, add tooltips, and stubbed Apply/Discard methods. Also tweak preview camera, anchors, and model handling (ensure animators/springs/blinkers handled for unscaled time). - SettingsControllerPatch: create separate Multiplayer and Character panes, add MultiplayerSettingsMenu component, wire menu indices and bottom buttons, create CreateBottomButtons helper, move left menu into a ScrollView (MoveMenuToScrollView) to avoid overflow/VR issues, and replace some Object.Destroy calls with GameObject.Destroy. Add rich UI debugging helpers (LogUIHierarchy, AppendUINode, AppendComponentInfo). - Settings: add CharacterId property to persist selected character. These changes improve layout/preview behavior, add Apply/Discard button wiring, make the character selector accessible from multiplayer settings, and provide utilities for inspecting UI hierarchies. commit e79643e Author: Macka <andrew@andrewcraigmackenzie.com> Date: Tue Jun 23 23:01:02 2026 +1000 Create Multiplayer Settings Menu Base menu, requires code to manage settings commit f4b5b4b Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jun 21 00:55:08 2026 +1000 Client: instantiate player model and name tag Refactor client-side player creation and NetworkedPlayer to support dynamic models. - NetworkedPlayer: add a playerModel field, expose ChangeModel(GameObject) to instantiate/destroy models, derive animationHandler from the instantiated model, use null-conditional calls for nameTag updates, and use transform via a property instead of caching selfTransform. - ClientPlayerManager: replace single prefab with a player tag prefab and an array of player prefabs; create a parent GameObject for each player, instantiate the name tag as a child, attach NetworkedPlayer, and call ChangeModel to set the visual model. AddPlayer signature now accepts a prefabId (currently passed as empty string). - NetworkClient: forward the prefabId argument (as empty string for now) when handling player-joined packets. - Minor whitespace tweak in Multiplayer.cs. These changes prepare the client codebase for multiple player models and decouple the visible model from the NetworkedPlayer component. commit f0ed0af Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jun 21 00:53:23 2026 +1000 Add character selector UI and settings pane Introduce an in-settings character selector and preview system. - Add CharacterSelectorMenu (Multiplayer/Components/MainMenu) to build a UI panel with a RenderTexture preview, preview camera/light, and populate selectable character list from AssetIndex. Ensures animations run in unscaled time and sets item layers for isolated rendering. - Add ModelRotator to allow pointer drag rotation with inertia for the preview model. - Patch SettingsController to inject a new "Multiplayer" settings pane by cloning the Gameplay pane, add the character selector component, wire up the menu button, localization key, and icon. - Add settings locale keys in Locale.cs and update locale.csv with settings/char_select entries and tooltips. - Minor cleanup in RightPaneControllerPatch usings. This enables players to preview and pick cosmetic characters from the settings menu. commit d36ddf8 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Sun Jun 21 00:51:29 2026 +1000 Update models Add blink and hair animations as well as an model metadata system commit 65e1de1 Author: Macka <andrew@andrewcraigmackenzie.com> Date: Fri Jun 19 17:33:32 2026 +1000 Create & Rig New Player Models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@Insprill
This is a consolidation PR that covers multiple issues.
Work is ongoing for #6 and #11.