asd
This commit is contained in:
43
Main.cs
43
Main.cs
@@ -1269,21 +1269,39 @@ namespace KCM
|
|||||||
public class SpeedControlUISetSpeedHook
|
public class SpeedControlUISetSpeedHook
|
||||||
{
|
{
|
||||||
private static long lastTime = 0;
|
private static long lastTime = 0;
|
||||||
|
private static long lastClientBlockLogTime = 0;
|
||||||
|
|
||||||
public static bool Prefix(ref bool __state)
|
public static bool Prefix(int idx, ref bool __state)
|
||||||
{
|
{
|
||||||
__state = false;
|
__state = false;
|
||||||
if (KCClient.client.IsConnected)
|
if (!KCClient.client.IsConnected)
|
||||||
{
|
return true;
|
||||||
|
|
||||||
bool calledFromPacket = false;
|
bool calledFromPacket = false;
|
||||||
try { calledFromPacket = PacketHandler.IsHandlingPacket; } catch { }
|
try { calledFromPacket = PacketHandler.IsHandlingPacket; } catch { }
|
||||||
|
|
||||||
|
// In multiplayer, keep time control authoritative to the host to avoid clients pausing/stalling the simulation.
|
||||||
|
if (!KCServer.IsRunning)
|
||||||
|
{
|
||||||
|
if (calledFromPacket)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
if ((now - lastClientBlockLogTime) >= 2000)
|
||||||
|
{
|
||||||
|
lastClientBlockLogTime = now;
|
||||||
|
Main.helper.Log("Blocked SpeedControlUI.SetSpeed on non-host client: " + idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!calledFromPacket)
|
if (!calledFromPacket)
|
||||||
{
|
{
|
||||||
if ((DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTime) >= 250) // Set speed spam fix / hack
|
long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
if ((now - lastTime) >= 250) // Set speed spam fix / hack
|
||||||
__state = true;
|
__state = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1463,18 +1481,13 @@ namespace KCM
|
|||||||
public static bool Prefix(ref string __result)
|
public static bool Prefix(ref string __result)
|
||||||
{
|
{
|
||||||
Main.helper.Log("Get save dir");
|
Main.helper.Log("Get save dir");
|
||||||
if (KCClient.client.IsConnected)
|
|
||||||
{
|
|
||||||
if (KCServer.IsRunning)
|
if (KCServer.IsRunning)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
__result = Application.persistentDataPath + "/Saves/Multiplayer";
|
__result = Application.persistentDataPath + "/Saves/Multiplayer";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__result = Application.persistentDataPath + "/Saves"; ;
|
__result = Application.persistentDataPath + "/Saves";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1554,6 +1567,14 @@ namespace KCM
|
|||||||
Main.SetMultiplayerSaveLoadInProgress(false);
|
Main.SetMultiplayerSaveLoadInProgress(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RunPostLoadRebuild("LoadAtPath (multiplayer)");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Broadcast.OnLoadedEvent.Broadcast(new OnLoadedEvent());
|
Broadcast.OnLoadedEvent.Broadcast(new OnLoadedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ namespace KCM.Packets.Lobby
|
|||||||
{
|
{
|
||||||
Main.SetMultiplayerSaveLoadInProgress(false);
|
Main.SetMultiplayerSaveLoadInProgress(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RunPostLoadRebuild("Save transfer complete");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
Broadcast.OnLoadedEvent.Broadcast(new OnLoadedEvent());
|
Broadcast.OnLoadedEvent.Broadcast(new OnLoadedEvent());
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user