diff --git a/Source/Client/ConstantTicker.cs b/Source/Client/ConstantTicker.cs index 00b6f249..214ce1e3 100644 --- a/Source/Client/ConstantTicker.cs +++ b/Source/Client/ConstantTicker.cs @@ -94,7 +94,8 @@ private static void TickAutosave() session.autosaveCounter = 0; Autosaving.DoAutosave(); } - } else if (server.settings.autosaveUnit == AutosaveUnit.Days && server.settings.autosaveInterval > 0) + } + else if (server.settings.autosaveUnit == AutosaveUnit.Days && server.settings.autosaveInterval > 0) { var anyMapCounterUp = Multiplayer.game.mapComps diff --git a/Source/Client/Patches/VTRSyncPatch.cs b/Source/Client/Patches/VTRSyncPatch.cs index 9e9ac2ca..582f1c25 100644 --- a/Source/Client/Patches/VTRSyncPatch.cs +++ b/Source/Client/Patches/VTRSyncPatch.cs @@ -16,8 +16,8 @@ static bool Prefix(Thing thing, ref int __result) if (Multiplayer.Client == null) return true; - // TODO: Put this back to the original value - // Probably need to sync up all the animations before doing this + // Keep the synchronized update rate until animation timing can be + // brought back in line with the vanilla value. __result = VTRSync.GetSynchronizedUpdateRate(thing); return false; } diff --git a/Source/Client/Saving/SaveLoad.cs b/Source/Client/Saving/SaveLoad.cs index 933ecd60..e33a5d15 100644 --- a/Source/Client/Saving/SaveLoad.cs +++ b/Source/Client/Saving/SaveLoad.cs @@ -25,7 +25,6 @@ public static TempGameData SaveAndReload() Multiplayer.reloading = true; var worldGridSaved = Find.WorldGrid; - var worldRendererSaved = Find.World.renderer; var tweenedPos = new Dictionary(); var drawers = new Dictionary(); var localFactionId = Multiplayer.RealPlayerFaction.loadID; @@ -59,10 +58,10 @@ public static TempGameData SaveAndReload() gameData = SaveGameData(); } - // TODO - //MapDrawerRegenPatch.copyFrom = drawers; - //WorldGridCachePatch.copyFrom = worldGridSaved; - //WorldGridExposeDataPatch.copyFrom = worldGridSaved; + MapDrawerRegenPatch.copyFrom = drawers; + WorldGridCachePatch.copyFrom = worldGridSaved; + WorldGridExposeDataPatch.copyFrom = worldGridSaved; + WorldRendererCachePatch.copyFrom = worldGridSaved; MusicManagerPlay musicManager = null; if (Find.MusicManagerPlay.gameObjectCreated) diff --git a/Source/Common/Networking/State/ServerPlayingState.cs b/Source/Common/Networking/State/ServerPlayingState.cs index 93a9fab8..39b75215 100644 --- a/Source/Common/Networking/State/ServerPlayingState.cs +++ b/Source/Common/Networking/State/ServerPlayingState.cs @@ -66,9 +66,11 @@ public void HandleChat(ClientChatPacket packet) string msg = packet.msg; msg = msg.Trim(); - // todo handle max length if (msg.Length == 0) return; + if (msg.Length > MaxChatMsgLength) + msg = msg[..MaxChatMsgLength]; + if (msg[0] == '/') { var cmd = msg[1..]; @@ -230,7 +232,8 @@ public void HandleAutosaving(ClientAutosavingPacket packet) [TypedPacketHandler] public void HandleDebug(ClientDebugPacket _) { - // todo restrict handling + if (!Server.commands.CanUseDevMode(Player)) + return; Server.worldData.mapCmds.Clear(); Server.gameTimer = Server.startingTimer; diff --git a/Source/Tests/StandaloneMapStreamingTest.cs b/Source/Tests/StandaloneMapStreamingTest.cs index 37cf4393..6676875b 100644 --- a/Source/Tests/StandaloneMapStreamingTest.cs +++ b/Source/Tests/StandaloneMapStreamingTest.cs @@ -140,4 +140,38 @@ public void MapToMapTransition_DoesNotSendMapResponseWhenStreamingDisabled() Assert.That(player.currentMapId, Is.EqualTo(5)); Assert.That(conn.SentPackets, Does.Not.Contain(Packets.Server_MapResponse)); } + + [Test] + public void HandleDebug_IgnoredWhenDevModeDisabled() + { + server.gameTimer = 123; + server.startingTimer = 5; + server.worldData.mapCmds[1] = [[1]]; + var (player, conn) = AddPlayer("player", 1); + + var state = player.conn.GetState()!; + state.HandleDebug(new ClientDebugPacket()); + + Assert.That(server.gameTimer, Is.EqualTo(123)); + Assert.That(server.worldData.mapCmds[1], Has.Count.EqualTo(1)); + Assert.That(conn.SentPackets, Does.Not.Contain(Packets.Server_Debug)); + } + + [Test] + public void HandleDebug_AllowsPlayersWhenDevModeEnabled() + { + server.settings.debugMode = true; + server.settings.devModeScope = DevModeScope.Everyone; + server.gameTimer = 123; + server.startingTimer = 5; + server.worldData.mapCmds[1] = [[1]]; + var (player, conn) = AddPlayer("player", 1); + + var state = player.conn.GetState()!; + state.HandleDebug(new ClientDebugPacket()); + + Assert.That(server.gameTimer, Is.EqualTo(5)); + Assert.That(server.worldData.mapCmds, Is.Empty); + Assert.That(conn.SentPackets, Does.Contain(Packets.Server_Debug)); + } }