Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/sync CompObelisk_Abductor (Warped Obelisk/Labyrinth) #476

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion Source/Client/Patches/LongEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ static void Postfix()
[HarmonyPatch(typeof(LongEventHandler), nameof(LongEventHandler.QueueLongEvent), new[] { typeof(Action), typeof(string), typeof(bool), typeof(Action<Exception>), typeof(bool), typeof(Action) })]
static class LongEventAlwaysSync
{
static void Prefix(ref bool doAsynchronously)
static void Prefix(ref bool doAsynchronously, ref Action action, Action callback)
{
if (Multiplayer.ExecutingCmds)
{
doAsynchronously = false;

// Callback is only called in asynchronous long events and will be skipped in
// a synchronous ones. Make sure they are called after the actual action.
if (callback != null)
action += callback;
}
}
}
}
8 changes: 7 additions & 1 deletion Source/Client/Patches/Seeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ static void Postfix(Map map, bool __state)
[HarmonyPatch(typeof(LongEventHandler), nameof(LongEventHandler.QueueLongEvent), typeof(Action), typeof(string), typeof(bool), typeof(Action<Exception>), typeof(bool), typeof(Action))]
static class SeedLongEvents
{
static void Prefix(ref Action action)
static void Prefix(ref Action action, ref Action callback)
{
if (Multiplayer.Client != null && (Multiplayer.Ticking || Multiplayer.ExecutingCmds))
{
var seed = Rand.Int;
action = (() => Rand.PushState(seed)) + action + Rand.PopState;

if (callback != null)
{
var callbackSeed = Rand.Int;
callback = (() => Rand.PushState(callbackSeed)) + callback + Rand.PopState;
}
}
}
}
Expand Down
Loading