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

Issue Using Mono.Cecil To Modify TModLoader #204

Closed
RomSteady opened this Issue Jul 1, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@RomSteady

Description

If you use another modification package (like RomTerraria/RTRewriter) to modify TModLoader 0.10.0.2, NGEN fails on the generated assembly.

Steps to Reproduce

  1. Install TModLoader 0.10.0.2. Verify that it is working.
  2. Run RTResolution 0.2 from http://romsteady.blogspot.com/2017/06/rtresolution-v02-available-now.html. While this version of the mod tries to modify two methods (DoDraw and SetGraphicsProfileInternal), only SetGraphicsProfileInternal will be modified due to how TModLoader moves everything over to do_Draw.
  3. Move the patched Terraria.exe into the Terraria folder.
  4. Launch Terraria.
  5. Application crashes with the following error: Method not found: 'System.__Canon System.__Canon[,].Get(Int32, Int32)'.

Expected behavior

Application should not crash.

Actual behavior

The version of Mono.Cecil being used predates the version of the .NET Framework used for TModLoader's compilation. As a result, things don't work quite right.

Reproduction frequency

Consistently.

Versions

v0.10.0.2

Mods

None

Additional Information

If you guys want to embed what RTResolution does inside TModLoader, it's easy enough to do.

Inside your revised Terraria.Main::do_Draw(GameTime), there are two constants (1920f and 1200f). Replace both with 8192f.

Inside Terraria.Main::SetGraphicsProfileInternal(), replace each instance of the constant 4096 with the constant 8192.

@horsemanV

This comment has been minimized.

Show comment
Hide comment
@horsemanV

horsemanV Sep 29, 2017

Just commenting to show interest, I love Rom's resolution fix, would love to see it work with TModLoader.

Just commenting to show interest, I love Rom's resolution fix, would love to see it work with TModLoader.

@Jofairden Jofairden assigned Jofairden and unassigned Jofairden Sep 29, 2017

@Jofairden

This comment has been minimized.

Show comment
Hide comment
@Jofairden

Jofairden Sep 29, 2017

Collaborator

Isn't this something the patcher should do? (support tModLoader)

Collaborator

Jofairden commented Sep 29, 2017

Isn't this something the patcher should do? (support tModLoader)

@PoroCYon

This comment has been minimized.

Show comment
Hide comment
@PoroCYon

PoroCYon Sep 29, 2017

Method not found: 'System.__Canon System.__Canon[,].Get(Int32, Int32)'

Sounds like a runtime bogosity: System.__Canon is part of the standard runtime.

The runtime version used by Mono.Cecil shouldn't be a problem, as it doesn't need any runtime being present for the written assembly -- the work done by Cecil could've been done in native code just fine. It just happens to be written in C#.

@RomSteady You could try using dnlib instead of Mono.Cecil as a last resort, as it seems to be more robust (talking from Prism experience).


OTOH, a stack trace could be useful, as __Canon seems to be a runtime utility for a vtable, so it's easier to guess which Get method it actually is (i.e. by which type it is owned).

Another solution is to simply apply the changes in tModLoader itself.

PoroCYon commented Sep 29, 2017

Method not found: 'System.__Canon System.__Canon[,].Get(Int32, Int32)'

Sounds like a runtime bogosity: System.__Canon is part of the standard runtime.

The runtime version used by Mono.Cecil shouldn't be a problem, as it doesn't need any runtime being present for the written assembly -- the work done by Cecil could've been done in native code just fine. It just happens to be written in C#.

@RomSteady You could try using dnlib instead of Mono.Cecil as a last resort, as it seems to be more robust (talking from Prism experience).


OTOH, a stack trace could be useful, as __Canon seems to be a runtime utility for a vtable, so it's easier to guess which Get method it actually is (i.e. by which type it is owned).

Another solution is to simply apply the changes in tModLoader itself.

Jofairden added a commit that referenced this issue May 11, 2018

Adresses #204
Adds options to remove forced minimum zoom, and allow greater resolution in internal graphics device.
@Jofairden

This comment has been minimized.

Show comment
Hide comment
@Jofairden

Jofairden May 11, 2018

Collaborator

Commended

Collaborator

Jofairden commented May 11, 2018

Commended

@Jofairden Jofairden closed this May 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment