SignatureBeef / Open-Terraria-API

Open Terraria API - Mac, Linux & Windows
GNU General Public License v3.0
97 stars 37 forks source link

Weird OpCode issues while hooking QuickStack in OTAPI.Patcher.Engine.Modifications.Hooks.Item #33

Closed EMREOYUN closed 3 years ago

EMREOYUN commented 3 years ago

Debugger Output: System.ArgumentNullException: 'Value can not be null. Parameter Name: parameter' at \OTAPI.Patcher.Engine\Extensions\ILProcessor\Insert.cs line 67

Console Output: -> Hooking Chest.PutItemInNearbyChest... Error executing modification QuickStack: Exception has been thrown by the target of an invocation. at: System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at: System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at: System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at: System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at: OTAPI.Patcher.Engine.Extensions.ILProcessor.InsertExtensions.AnonymousToInstruction(Object anon) \OTAPI.Patcher.Engine\Extensions\ILProcessor\Insert.cs: line 67 at: OTAPI.Patcher.Engine.Extensions.ILProcessor.InsertExtensions.InsertAfter(ILProcessor processor, Instruction target, Object[] instructions) \OTAPI.Patcher.Engine\Extensions\ILProcessor\Insert.cs: line 86 at: OTAPI.Patcher.Engine.Modifications.Hooks.Item.QuickStack.Run() \OTAPI.Modifications\OTAPI.Modifications.Chest.Item.Add\Modifications\QuickStack.cs: line 29 at: OTAPI.Patcher.Engine.Patcher.RunModifications() \OTAPI.Patcher.Engine\Patcher.cs: line 256

SignatureBeef commented 3 years ago

What assembly + version are you patching, and on what runtime? I am unable to replicate this using mono on osx, with terrariaserver 1.4.2.3 (default settings on a fresh clone)

EMREOYUN commented 3 years ago

Terraria Mobile Dedicated Server(1.4.0.5): Can be found bottom of the page at terraria.org

Using Commit: e2f2b6fa33fb9a8b11a378e77028035359273ac3 (Latest commit made for 1.4.0.5)

Using Assemblies for ILRepack: •TerrariaServer.exe •ReLogic.dll(must be extracted from TerrariaServer.exe) Do not use ReLogic.Native.dll, it does not include any .Net code at all and server can run without it.

Note: This is the only modification fails while patching. All other modifications patching without any issues.

hakusaro commented 3 years ago

Which versions of mono, macOS, etc are you using?

SignatureBeef commented 3 years ago

Terraria Mobile Dedicated Server(1.4.0.5): Can be found bottom of the page at terraria.org

Using Commit: e2f2b6f (Latest commit made for 1.4.0.5)

Using Assemblies for ILRepack: •TerrariaServer.exe •ReLogic.dll(must be extracted from TerrariaServer.exe) Do not use ReLogic.Native.dll, it does not include any .Net code at all and server can run without it.

Note: This is the only modification fails while patching. All other modifications patching without any issues.

for the most part, this branch is mainly for the PC version, so id assume some IL has a few inconsistencies in that version that would need to be accounted for.

EMREOYUN commented 3 years ago

Which versions of mono, macOS, etc are you using?

Device does not have mono i think. mono --version is not present. The patcher has Mono.Cecil 0.9.6.0 as dependency. .net Framework 4.8 is installed Device is Windows 10 Enterprise

EMREOYUN commented 3 years ago

Terraria Mobile Dedicated Server(1.4.0.5): Can be found bottom of the page at terraria.org Using Commit: e2f2b6f (Latest commit made for 1.4.0.5) Using Assemblies for ILRepack: •TerrariaServer.exe •ReLogic.dll(must be extracted from TerrariaServer.exe) Do not use ReLogic.Native.dll, it does not include any .Net code at all and server can run without it. Note: This is the only modification fails while patching. All other modifications patching without any issues.

for the most part, this branch is mainly for the PC version, so id assume some IL has a few inconsistencies in that version that would need to be accounted for.

Mobile server is also uses PC server, it is mostly same. All mobile servers can both accepts PC and mobile clients. Also all PC servers can both accepts PC and mobile clients as well.

SignatureBeef commented 3 years ago

Terraria Mobile Dedicated Server(1.4.0.5): Can be found bottom of the page at terraria.org Using Commit: e2f2b6f (Latest commit made for 1.4.0.5) Using Assemblies for ILRepack: •TerrariaServer.exe •ReLogic.dll(must be extracted from TerrariaServer.exe) Do not use ReLogic.Native.dll, it does not include any .Net code at all and server can run without it. Note: This is the only modification fails while patching. All other modifications patching without any issues.

for the most part, this branch is mainly for the PC version, so id assume some IL has a few inconsistencies in that version that would need to be accounted for.

Mobile server is also uses PC server, it is mostly same. All mobile servers can both accepts PC and mobile clients. Also all PC servers can both accepts PC and mobile clients as well.

i am aware this is possible but its not something i support on this branch, which is also why there are no patch targets for that assembly in recent commits; and using an old commit like that is likely where the IL issues are coming from.

however, ive done some quick tests using the latest commit and adding the extra assembly patch targets for 1.4.0.5 back. I can fully patch the mobile server after adding any missing dll's from the embedded resources, and then am also able to start and generate a world - just didn't test connecting due to client version mismatch. both tests ran on osx and windows.

in either case, to me this is still an enhancement, and ill aim to include it in the next upcoming version of otapi, however i have no plans to support it on older versions.

Screen Shot 2021-06-27 at 9 12 29 am Screen Shot 2021-06-27 at 9 16 18 am

EMREOYUN commented 3 years ago

Weird, latest commit with changing version codes back to 1.4.0.5 actually worked without adding any external sources, compiled and patched successfully. I tested it and it seems working well(expect TShock's SSC does not work, probably something from Mobile Server, i tried 3 times total and it didn't work all of them).

SignatureBeef commented 3 years ago

Weird, latest commit with changing version codes back to 1.4.0.5 actually worked without adding any external sources, compiled and patched successfully. I tested it and it seems working well(expect TShock's SSC does not work, probably something from Mobile Server, i tried 3 times total and it didn't work all of them).

did you run the OTAPI mobile through TSAPI patcher as well? TSAPI enables ssc, stock otapi2 wont.

since the issue is resolved here ill close this off shortly. official mobile support will be tracked in otapi3.

EMREOYUN commented 3 years ago

Weird, latest commit with changing version codes back to 1.4.0.5 actually worked without adding any external sources, compiled and patched successfully. I tested it and it seems working well(expect TShock's SSC does not work, probably something from Mobile Server, i tried 3 times total and it didn't work all of them).

did you run the OTAPI mobile through TSAPI patcher as well? TSAPI enables ssc, stock otapi2 wont.

since the issue is resolved here ill close this off shortly. official mobile support will be tracked in otapi3.

Positive, TSAPI's SSC modification used but it does not update inventories at all, while original OTAPI compiled for PC Terraria can.

EMREOYUN commented 3 years ago

closed #33