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

267 fix new input system compatibility #272

Merged
merged 116 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
3332082
removed useless assembly exclusions
Eddio0141 Sep 15, 2023
dcd8310
ignore patching cctor on enum types
Eddio0141 Sep 15, 2023
a6dea84
ignore enum on readonly field removal too
Eddio0141 Sep 15, 2023
e26bab0
ignore cctor if type doesn't have one
Eddio0141 Sep 15, 2023
2bdd261
hide unused public method
Eddio0141 Sep 15, 2023
f04bc78
removed adding unused cctor
Eddio0141 Sep 15, 2023
35133ca
created extension replace and insert instruction
Eddio0141 Sep 15, 2023
d1c992f
null check and warns for safety
Eddio0141 Sep 15, 2023
a19b000
guarantee event method invoke
Eddio0141 Sep 15, 2023
c8b5378
updated
Eddio0141 Sep 15, 2023
d553c44
added fixing to be optional by flag
Eddio0141 Sep 15, 2023
1427c91
comment to make sure i dont flop it up
Eddio0141 Sep 15, 2023
49b7423
fixed inserting instructions
Eddio0141 Sep 15, 2023
b0ca7dd
return default value if return type isn't void
Eddio0141 Sep 15, 2023
49c4d4c
cleaner syntax
Eddio0141 Sep 16, 2023
69c37a7
include Unity.ResourceManager
Eddio0141 Sep 16, 2023
bf66774
changed to target the same assemblies
Eddio0141 Sep 16, 2023
2b42f8c
stupid code why did I remove this
Eddio0141 Sep 16, 2023
49a3dc4
made public for use
Eddio0141 Sep 16, 2023
3e5d877
clear tracked objects on restart
Eddio0141 Sep 16, 2023
401104d
reduce log spam to trace log
Eddio0141 Sep 16, 2023
52fc43c
include all target dlls I need
Eddio0141 Sep 16, 2023
6bb840a
removed broken code
Eddio0141 Sep 16, 2023
aaeca64
added Instruction match to skip dependency check
Eddio0141 Sep 16, 2023
1f01841
removed useless public modifier
Eddio0141 Sep 17, 2023
53d3aa4
addition of logging
Eddio0141 Sep 17, 2023
2086d65
additional logging
Eddio0141 Sep 17, 2023
2a5b5d1
cleaned input system handling to something better
Eddio0141 Sep 20, 2023
4e1382e
moved to appropriate namespace
Eddio0141 Sep 20, 2023
791fcc1
updated api to make sense
Eddio0141 Sep 20, 2023
a6ad8b3
added mouse pos overlay
Eddio0141 Sep 20, 2023
8fa387c
added implicit use attribute
Eddio0141 Sep 22, 2023
f32548b
addition of event for pre game restart
Eddio0141 Sep 23, 2023
69ff801
implicit use attribute added
Eddio0141 Sep 23, 2023
397e9c1
fixed mouse pos being inverted
Eddio0141 Sep 21, 2023
1ebb7e8
create plugins dir on init
Eddio0141 Sep 21, 2023
d869100
added UniTAS patcher change detection
Eddio0141 Sep 23, 2023
c68c488
added preload patcher caching
Eddio0141 Sep 23, 2023
6a7cc4c
removed TODOs
Eddio0141 Sep 23, 2023
b789841
updated
Eddio0141 Sep 23, 2023
31340d0
added implicit instantiates
Eddio0141 Oct 1, 2023
deea563
added scene load event callback
Eddio0141 Oct 1, 2023
6183dc5
added ScriptableObject save / load state
Eddio0141 Oct 1, 2023
6e72e61
additional ScriptableObject instantiation tracker
Eddio0141 Oct 1, 2023
e71c3b8
fixed dependency collision
Eddio0141 Oct 1, 2023
e550e28
destroy instantiated objects rather than storing
Eddio0141 Oct 1, 2023
6b3ba2e
destroy immediate instead of simply destroy
Eddio0141 Oct 1, 2023
5fe51dc
removed operation on scene load
Eddio0141 Oct 1, 2023
5b393d0
fixed warnings
Eddio0141 Oct 1, 2023
8789430
added OnDestroy error log
Eddio0141 Oct 1, 2023
a43d791
actually target methods to patch
Eddio0141 Oct 2, 2023
d11bb58
fixed const naming change
Eddio0141 Oct 2, 2023
55ee1bb
fixed self referencing to not recurse forever
Eddio0141 Oct 2, 2023
0b2f6a8
additional deep copy test
Eddio0141 Oct 2, 2023
3b8020f
use of reference cache dictionaries
Eddio0141 Oct 2, 2023
b575bd7
fixed found references to not include copy source
Eddio0141 Oct 2, 2023
1c177b4
fixed reference finding to uses ReferenceEquals
Eddio0141 Oct 2, 2023
5b9b2ae
fix reference adding order
Eddio0141 Oct 2, 2023
8d9ea5d
fixed edge cases throwing
Eddio0141 Oct 2, 2023
44ed194
additional logging just in case
Eddio0141 Oct 2, 2023
ec50485
addition of unsafe field test
Eddio0141 Oct 2, 2023
ee54f25
fixed handling unsafe fields
Eddio0141 Oct 2, 2023
f10ca43
removal of logs
Eddio0141 Oct 2, 2023
91b5459
malloc tracker and free service
Eddio0141 Oct 2, 2023
bbe31e6
try free malloc for any field that is a pointer type
Eddio0141 Oct 2, 2023
5023446
fixed possible null reference exception on field type get
Eddio0141 Oct 2, 2023
34804bd
removed logging
Eddio0141 Oct 2, 2023
b36fa5e
extension to get if field is unity serializable
Eddio0141 Oct 4, 2023
d4d0d11
added unity object referencing
Eddio0141 Oct 6, 2023
0c3fa84
added ToString to show inner content
Eddio0141 Oct 6, 2023
045e12b
fixed logic error
Eddio0141 Oct 6, 2023
f440617
added try free for field instead
Eddio0141 Oct 6, 2023
ec2c990
added getting fields recursively
Eddio0141 Oct 6, 2023
aae193f
addition of storing which fields to set default to
Eddio0141 Oct 6, 2023
8d55853
removed file
Eddio0141 Oct 6, 2023
5eb2bde
reverted referencing scene objects
Eddio0141 Oct 7, 2023
283ac62
don't clone if derived from UnityEngine.Object
Eddio0141 Oct 7, 2023
351d3c4
addition of a cool line call trace!!!
Eddio0141 Oct 8, 2023
8680217
addition of trace logging
Eddio0141 Oct 8, 2023
59870a7
addition of depth log
Eddio0141 Oct 8, 2023
8ef6d74
more logs
Eddio0141 Oct 8, 2023
9c4a4ca
cleaned up target dll info to be merged with TargetPatcherDlls
Eddio0141 Oct 12, 2023
b54cd44
extension to check if TypeDefinition is derived from MonoBehaviour
Eddio0141 Oct 12, 2023
f09ac4d
added 3 extra ways to init unitas
Eddio0141 Oct 12, 2023
4277ce2
Revert "cleaned up target dll info to be merged with TargetPatcherDlls"
Eddio0141 Oct 14, 2023
5173a80
changed unity init hook point
Eddio0141 Oct 17, 2023
7ad90f0
cleaned up target dll property
Eddio0141 Oct 17, 2023
241b38c
properly edited the changes reflected
Eddio0141 Oct 17, 2023
3d11aca
include resource manager
Eddio0141 Oct 17, 2023
027c6f6
applied reflected changes
Eddio0141 Oct 17, 2023
7caec96
fixed to match rebase
Eddio0141 Oct 17, 2023
29e2b83
imported missing using for the merged code
Eddio0141 Oct 17, 2023
e19935a
made AllDLLs private since no point
Eddio0141 Oct 17, 2023
68a26eb
fixed not deep cloning on setting value
Eddio0141 Oct 24, 2023
cccaa22
made debug print much more advanced
Eddio0141 Oct 27, 2023
4cc48aa
removed ns check and directly printing cuz c# std lib sucks
Eddio0141 Oct 27, 2023
2d7be90
fixed handling IEnumerable and system namespace cloning
Eddio0141 Oct 27, 2023
d50cbf1
made command shorter
Eddio0141 Oct 28, 2023
18a8046
init ScriptableObject instance properly
Eddio0141 Oct 28, 2023
ff76ae8
stop all audio sources on restart
Eddio0141 Oct 28, 2023
68931c9
added extra logging stuff
Eddio0141 Nov 3, 2023
af03d2e
changed order of event invoke to make sense
Eddio0141 Nov 3, 2023
6876473
changed API for TAS devices
Eddio0141 Nov 3, 2023
927e139
fixed exception from throwing
Eddio0141 Nov 3, 2023
7b5b21a
removal of a probably useless API
Eddio0141 Nov 3, 2023
774a936
removed annoying stack trace dump
Eddio0141 Nov 3, 2023
f40ca15
prevent crashing somehow
Eddio0141 Nov 3, 2023
f44ed5c
updated
Eddio0141 Nov 3, 2023
861f58b
fixed some weird code
Eddio0141 Nov 9, 2023
cb277df
fixed crashing trying to read pointer value
Eddio0141 Nov 16, 2023
4cd9f5a
fixed array formatting
Eddio0141 Nov 16, 2023
f642757
fixed some bits related to circular references
Eddio0141 Nov 16, 2023
2ef5c93
changed circular reference detection
Eddio0141 Nov 17, 2023
e5290c7
added basic backup font search and set for IMGUI
Eddio0141 Nov 17, 2023
e484f27
don't hook last resort
Eddio0141 Nov 17, 2023
7322a87
updated target assemblies
Eddio0141 Nov 17, 2023
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

# [Unreleased]

## Changed

### Performance

- Loading should be faster if you've opened the game before

## Fixed

### Games
Expand All @@ -16,12 +22,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### General

- Fixed TAS rendering popping up command prompt probably
- Fixed music overlaying on each other every restart

### Compatibility

- Fixed accidentally skipping over static constructors
- Fixed accidentally skipping over removing some readonly fields
- Fixed crash when trying to remove readonly fields
- Fixed sometimes UniTAS not receiving the first update, which might cause some movie desync by 1 frame

## Changed

Expand Down
2 changes: 2 additions & 0 deletions UniTAS/Patcher.Tests/Patcher.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
</RestoreAdditionalProjectSources>

<IsPackable>false</IsPackable>

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
27 changes: 26 additions & 1 deletion UniTAS/Patcher.Tests/Utils/DeepCopyTests.TestTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private class SimpleType
public static bool ThisShouldBeIgnored;

[SuppressMessage("ReSharper", "UnusedMember.Local")]
private const int ThisShouldBeIgnoredToo = 42;
private const int THIS_SHOULD_BE_IGNORED_TOO = 42;
}

private enum TestEnum
Expand Down Expand Up @@ -53,4 +53,29 @@ private class DictionaryType
public Dictionary<int, string> IntStringDictionary;
public Dictionary<string, int> StringIntDictionary;
}

private class SelfReferencing1
{
public SelfReferencing2 Nested;
}

private class SelfReferencing2
{
public SelfReferencing1 Nested;
}

private class SelfReferencing3
{
public SelfReferencing4 Nested;
}

private class SelfReferencing4
{
public List<SelfReferencing3> Nested;
}

private class PointerType
{
public unsafe void* Pointer;
}
}
58 changes: 57 additions & 1 deletion UniTAS/Patcher.Tests/Utils/DeepCopyTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UniTAS.Patcher.Utils;

namespace Patcher.Tests.Utils;
Expand Down Expand Up @@ -145,4 +147,58 @@ public void DictionaryTypeTest()
Assert.Equal(source.IntStringDictionary, result!.IntStringDictionary);
Assert.Equal(source.StringIntDictionary, result.StringIntDictionary);
}

[Fact]
public void SelfReferencingTest()
{
var source = new SelfReferencing1();
var reference2 = new SelfReferencing2();
source.Nested = reference2;
reference2.Nested = source;

var result = DeepCopy.MakeDeepCopy<SelfReferencing1>(source);
Assert.NotSame(source, result);
Assert.NotSame(source.Nested, result.Nested);
Assert.NotSame(source.Nested.Nested, result);

Assert.Same(result, result.Nested.Nested);
Assert.Same(result.Nested, result.Nested.Nested.Nested);
}

[Fact]
public void SelfReferencingTest2()
{
var source = new SelfReferencing3();
var reference2 = new SelfReferencing4();
source.Nested = reference2;
reference2.Nested = new() { source };

var result = DeepCopy.MakeDeepCopy<SelfReferencing3>(source);
Assert.NotSame(source, result);
Assert.NotSame(source.Nested, result.Nested);
Assert.NotSame(source.Nested.Nested.FirstOrDefault(), result);

Assert.Same(result, result.Nested.Nested.FirstOrDefault());
Assert.Same(result.Nested, result.Nested.Nested.FirstOrDefault()?.Nested);
}

[Fact]
public unsafe void PointerTypeTest()
{
var source = new PointerType
{
Pointer = (void*)0x12345678,
};
var result = DeepCopy.MakeDeepCopy<PointerType>(source);

Assert.Equal((IntPtr)source.Pointer, (IntPtr)result.Pointer);

result.Pointer = (void*)0x87654321;

Assert.NotEqual((IntPtr)source.Pointer, (IntPtr)result.Pointer);

DeepCopy.MakeDeepCopy(source, out result);

Assert.Equal((IntPtr)source.Pointer, (IntPtr)result!.Pointer);
}
}
20 changes: 20 additions & 0 deletions UniTAS/Patcher.Tests/Utils/EitherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,24 @@ public void Right()
Assert.Equal("test", either.Right);
Assert.Throws<InvalidOperationException>(() => either.Left);
}

[Fact]
public void ImplicitLeft()
{
Either<int, string> either = 5;
Assert.True(either.IsLeft);
Assert.False(either.IsRight);
Assert.Equal(5, either.Left);
Assert.Throws<InvalidOperationException>(() => either.Right);
}

[Fact]
public void ImplicitRight()
{
Either<int, string> either = "test";
Assert.False(either.IsLeft);
Assert.True(either.IsRight);
Assert.Equal("test", either.Right);
Assert.Throws<InvalidOperationException>(() => either.Left);
}
}
93 changes: 46 additions & 47 deletions UniTAS/Patcher.Tests/Utils/LegacyInputSystemUtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,134 +8,133 @@ public class LegacyInputSystemUtilsTest
[Fact]
public void Alphabet()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("a", out var keyCode);
Assert.True(ret);
var keyCode = InputSystemUtils.KeyCodeParse("a");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.A, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("z", out keyCode);
Assert.True(ret);
keyCode = InputSystemUtils.KeyCodeParse("z");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.Z, keyCode);
}

[Fact]
public void AlphabetFail()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("aa", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("aa");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}

[Fact]
public void Number()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("0", out var keyCode);
Assert.True(ret);
var keyCode = InputSystemUtils.KeyCodeParse("0");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.Alpha0, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("9", out keyCode);
Assert.True(ret);
keyCode = InputSystemUtils.KeyCodeParse("9");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.Alpha9, keyCode);
}

[Fact]
public void NumberFail()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("10", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("10");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("-1", out keyCode);
Assert.False(ret);
keyCode = InputSystemUtils.KeyCodeParse("-1");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}

[Fact]
public void Numpad()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("[0]", out var keyCode);
Assert.True(ret);
var keyCode = InputSystemUtils.KeyCodeParse("[0]");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.Keypad0, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("[9]", out keyCode);
Assert.True(ret);
keyCode = InputSystemUtils.KeyCodeParse("[9]");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.Keypad9, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("[+]", out keyCode);
Assert.True(ret);
keyCode = InputSystemUtils.KeyCodeParse("[+]");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.KeypadPlus, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("[-]", out keyCode);
Assert.True(ret);
keyCode = InputSystemUtils.KeyCodeParse("[-]");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.KeypadMinus, keyCode);
}

[Fact]
public void NumpadFail()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("[-1]", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("[-1]");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("[10]", out keyCode);
Assert.False(ret);
keyCode = InputSystemUtils.KeyCodeParse("[10]");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("[+1]", out keyCode);
Assert.False(ret);
keyCode = InputSystemUtils.KeyCodeParse("[+1]");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}

[Fact]
public void FunctionKey()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("f1", out var keyCode);
Assert.True(ret);
var keyCode = InputSystemUtils.KeyCodeParse("f1");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.F1, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("f15", out keyCode);
Assert.True(ret);
keyCode = InputSystemUtils.KeyCodeParse("f15");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.F15, keyCode);
}

[Fact]
public void FunctionKeyFail()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("f0", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("f0");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
ret = LegacyInputSystemUtils.KeyStringToKeyCode("f16", out keyCode);
Assert.False(ret);
keyCode = InputSystemUtils.KeyCodeParse("f16");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}

[Fact]
public void MostOtherKey()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("backspace", out var keyCode);
Assert.True(ret);
var keyCode = InputSystemUtils.KeyCodeParse("backspace");
Assert.NotNull(keyCode);
Assert.Equal(KeyCode.Backspace, keyCode);
}

[Fact]
public void OutOfRangeEnum()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("%", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("%");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}

[Fact]
public void Empty()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}

[Fact]
public void Null()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode(null, out var keyCode);
Assert.False(ret);
Assert.Equal(default, keyCode);
var keyCode = InputSystemUtils.KeyCodeParse(null);
Assert.Null(keyCode);
}

[Fact]
public void Invalid()
{
var ret = LegacyInputSystemUtils.KeyStringToKeyCode("foo", out var keyCode);
Assert.False(ret);
var keyCode = InputSystemUtils.KeyCodeParse("foo");
Assert.Null(keyCode);
Assert.Equal(default, keyCode);
}
}
31 changes: 0 additions & 31 deletions UniTAS/Patcher.Tests/VirtualEnv/KeyEqualityCheck.cs

This file was deleted.

Loading
Loading