mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-21 21:43:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22550a88ca | ||
|
|
2b98a211bd | ||
|
|
cb799e877e |
No files matched your search
@@ -57,12 +57,25 @@ namespace Reactor.Patches
|
||||
[HarmonyPatch(typeof(FileIO), nameof(FileIO.WriteAllText))]
|
||||
private static class WritePatch
|
||||
{
|
||||
public static void Prefix(string path)
|
||||
public static bool Prefix(string path, string contents)
|
||||
{
|
||||
// Among Us' region loading code unfortunately contains a call
|
||||
// to SaveServers, which will write out the region file. This
|
||||
// will lead to a positive feedback loop when detecting writes,
|
||||
// which is undesireable. So we check if the write makes a
|
||||
// change to the file on disk and if it would write the same
|
||||
// file again, stop AU from actually writing it.
|
||||
if (ServerManager.Instance && path == ServerManager.Instance.serverInfoFileJson)
|
||||
{
|
||||
PluginSingleton<ReactorPlugin>.Instance.RegionInfoWatcher.IgnoreNext = true;
|
||||
var currentContents = FileIO.ReadAllText(path);
|
||||
var continueWrite = currentContents != contents;
|
||||
Logger<ReactorPlugin>.Debug($"Continue serverInfoFile write? {continueWrite}");
|
||||
// If we will write, ignore the next change action from the observer.
|
||||
PluginSingleton<ReactorPlugin>.Instance.RegionInfoWatcher.IgnoreNext = continueWrite;
|
||||
return continueWrite;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
<VersionPrefix>1.2.5</VersionPrefix>
|
||||
<VersionPrefix>1.2.6</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
<Description>Core mod and API for Among Us</Description>
|
||||
<Authors>NuclearPowered</Authors>
|
||||
|
||||
Reference in new issue
Block a user