Decompiled source of Potato Server Filter v0.0.2

GDWeave/mods/PotatoServerFilter/PotatoServerFilter.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using GDWeave;
using GDWeave.Godot;
using GDWeave.Modding;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("ServerFilter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("ServerFilter")]
[assembly: AssemblyTitle("ServerFilter")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace ServerFilter;

public class Mod : IMod, global::System.IDisposable
{
	public Mod(IModInterface modInterface)
	{
		modInterface.RegisterScriptMod((IScriptMod)(object)new RefreshServerPatcher());
	}

	public void Dispose()
	{
	}
}
public class RefreshServerPatcher : IScriptMod
{
	[CompilerGenerated]
	private sealed class <Modify>d__1 : global::System.Collections.Generic.IEnumerable<Token>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<Token>, global::System.Collections.IEnumerator, global::System.IDisposable
	{
		private int <>1__state;

		private Token <>2__current;

		private int <>l__initialThreadId;

		private global::System.Collections.Generic.IEnumerable<Token> tokens;

		public global::System.Collections.Generic.IEnumerable<Token> <>3__tokens;

		private FunctionWaiter <waiter>5__2;

		private TokenWaiter <forLoopWaiter>5__3;

		private bool <insideFirstLineOfForLoop>5__4;

		private bool <insideFunction>5__5;

		private global::System.Collections.Generic.IEnumerator<Token> <>7__wrap5;

		private Token <token>5__7;

		private global::System.Collections.Generic.IEnumerator<Token> <>7__wrap7;

		Token global::System.Collections.Generic.IEnumerator<Token>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object global::System.Collections.IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Modify>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
			<>l__initialThreadId = Environment.CurrentManagedThreadId;
		}

		[DebuggerHidden]
		void global::System.IDisposable.Dispose()
		{
			int num = <>1__state;
			if ((uint)(num - -4) > 1u && (uint)(num - 1) > 4u)
			{
				return;
			}
			try
			{
				if (num != -4 && num != 4)
				{
					return;
				}
				try
				{
				}
				finally
				{
					<>m__Finally2();
				}
			}
			finally
			{
				<>m__Finally1();
			}
		}

		private bool MoveNext()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Invalid comparison between Unknown and I4
			try
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<waiter>5__2 = new FunctionWaiter("_find_all_webfishing_lobbies", false);
					<forLoopWaiter>5__3 = new TokenWaiter((Func<Token, bool>)((Token t) => (int)t.Type == 41), false);
					<insideFirstLineOfForLoop>5__4 = false;
					<insideFunction>5__5 = false;
					<>7__wrap5 = tokens.GetEnumerator();
					<>1__state = -3;
					break;
				case 1:
					<>1__state = -3;
					goto IL_021d;
				case 2:
					<>1__state = -3;
					<insideFirstLineOfForLoop>5__4 = true;
					goto IL_021d;
				case 3:
				{
					<>1__state = -3;
					uint valueOrDefault = <token>5__7.AssociatedData.GetValueOrDefault();
					global::System.Collections.Generic.IEnumerable<Token> enumerable = ScriptTokenizer.Tokenize("\r\nif has_node(\"/root/PotatoServerFilter\"):\r\n    var ServerFilterNode = get_node(\"/root/PotatoServerFilter\")\r\n    if ServerFilterNode:\r\n        ServerFilterNode.ApplyFilters()\r\nelse:\r\n    print(\"Unable to find node\")\r\n", valueOrDefault + 2);
					<>7__wrap7 = enumerable.GetEnumerator();
					<>1__state = -4;
					goto IL_01d4;
				}
				case 4:
					<>1__state = -4;
					goto IL_01d4;
				case 5:
					{
						<>1__state = -3;
						goto IL_021d;
					}
					IL_01d4:
					if (((global::System.Collections.IEnumerator)<>7__wrap7).MoveNext())
					{
						Token current = <>7__wrap7.Current;
						<>2__current = current;
						<>1__state = 4;
						return true;
					}
					<>m__Finally2();
					<>7__wrap7 = null;
					<insideFunction>5__5 = false;
					<insideFirstLineOfForLoop>5__4 = false;
					goto IL_021d;
					IL_021d:
					<token>5__7 = null;
					break;
				}
				if (((global::System.Collections.IEnumerator)<>7__wrap5).MoveNext())
				{
					<token>5__7 = <>7__wrap5.Current;
					if (<waiter>5__2.Check(<token>5__7))
					{
						<insideFunction>5__5 = true;
						<>2__current = <token>5__7;
						<>1__state = 1;
						return true;
					}
					if (<forLoopWaiter>5__3.Check(<token>5__7))
					{
						<>2__current = <token>5__7;
						<>1__state = 2;
						return true;
					}
					if ((<insideFunction>5__5 & <insideFirstLineOfForLoop>5__4) && (int)<token>5__7.Type == 86)
					{
						<>2__current = <token>5__7;
						<>1__state = 3;
						return true;
					}
					<>2__current = <token>5__7;
					<>1__state = 5;
					return true;
				}
				<>m__Finally1();
				<>7__wrap5 = null;
				return false;
			}
			catch
			{
				//try-fault
				((global::System.IDisposable)this).Dispose();
				throw;
			}
		}

		bool global::System.Collections.IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		private void <>m__Finally1()
		{
			<>1__state = -1;
			if (<>7__wrap5 != null)
			{
				((global::System.IDisposable)<>7__wrap5).Dispose();
			}
		}

		private void <>m__Finally2()
		{
			<>1__state = -3;
			if (<>7__wrap7 != null)
			{
				((global::System.IDisposable)<>7__wrap7).Dispose();
			}
		}

		[DebuggerHidden]
		void global::System.Collections.IEnumerator.Reset()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}

		[DebuggerHidden]
		global::System.Collections.Generic.IEnumerator<Token> global::System.Collections.Generic.IEnumerable<Token>.GetEnumerator()
		{
			<Modify>d__1 <Modify>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<Modify>d__ = this;
			}
			else
			{
				<Modify>d__ = new <Modify>d__1(0);
			}
			<Modify>d__.tokens = <>3__tokens;
			return <Modify>d__;
		}

		[DebuggerHidden]
		global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
		{
			return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<Token>)this).GetEnumerator();
		}
	}

	public bool ShouldRun(string path)
	{
		return path == "res://Scenes/Singletons/SteamNetwork.gdc";
	}

	[IteratorStateMachine(typeof(<Modify>d__1))]
	public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
	{
		FunctionWaiter waiter = new FunctionWaiter("_find_all_webfishing_lobbies", false);
		TokenWaiter forLoopWaiter = new TokenWaiter((Func<Token, bool>)((Token t) => (int)t.Type == 41), false);
		bool insideFirstLineOfForLoop = false;
		bool insideFunction = false;
		global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Token token = enumerator.Current;
				if (waiter.Check(token))
				{
					insideFunction = true;
					yield return token;
				}
				else if (forLoopWaiter.Check(token))
				{
					yield return token;
					insideFirstLineOfForLoop = true;
				}
				else if (insideFunction && insideFirstLineOfForLoop && (int)token.Type == 86)
				{
					yield return token;
					uint valueOrDefault = token.AssociatedData.GetValueOrDefault();
					global::System.Collections.Generic.IEnumerable<Token> enumerable = ScriptTokenizer.Tokenize("\r\nif has_node(\"/root/PotatoServerFilter\"):\r\n    var ServerFilterNode = get_node(\"/root/PotatoServerFilter\")\r\n    if ServerFilterNode:\r\n        ServerFilterNode.ApplyFilters()\r\nelse:\r\n    print(\"Unable to find node\")\r\n", valueOrDefault + 2);
					global::System.Collections.Generic.IEnumerator<Token> enumerator2 = enumerable.GetEnumerator();
					try
					{
						while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
						{
							yield return enumerator2.Current;
						}
					}
					finally
					{
						((global::System.IDisposable)enumerator2)?.Dispose();
					}
					insideFunction = false;
					insideFirstLineOfForLoop = false;
				}
				else
				{
					yield return token;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}
}