Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/Client/ConstantTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Source/Client/Patches/VTRSyncPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 4 additions & 5 deletions Source/Client/Saving/SaveLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public static TempGameData SaveAndReload()
Multiplayer.reloading = true;

var worldGridSaved = Find.WorldGrid;
var worldRendererSaved = Find.World.renderer;
var tweenedPos = new Dictionary<int, Vector3>();
var drawers = new Dictionary<int, MapDrawer>();
var localFactionId = Multiplayer.RealPlayerFaction.loadID;
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions Source/Common/Networking/State/ServerPlayingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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..];
Expand Down Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions Source/Tests/StandaloneMapStreamingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerPlayingState>()!;
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<ServerPlayingState>()!;
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));
}
}
Loading