Add a fix for TermInfoReader to prevent throws on boot #889
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix is directly taken from bepinex: https://github.com/BepInEx/BepInEx/blob/master/Runtimes/Unity/BepInEx.Unity.Mono.Preloader/RuntimeFixes/XTermFix.cs#L16
It was found to affect melon in a bad way particularly when trying to load UE on old unity mono on linux (seems the fix only was applied on 2020.2). What would happen is a throw early on that prevents the C# console to function. The throw would typically say something like "Magic number is wrong: 542".
You will notice a...really nasty hacky workaround with MonoMod on both this PR and the bepinex version which is that legacy MonoMod will eventually cause the Console cctor to run....which eventually gets the TermInfoReader to kick in. This is bad because it means it gets to kick in unpatched...when we are trying to patch it!
The nasty workaround is to set DetourHelper.Native directly instead of letting MonoMod determine it. Since we use ifdef for this, it's fine, it just looks ugly :(