Harmony Transpiler Help (Solved)

Started by Kiame, October 27, 2017, 12:56:00 AM

Previous topic - Next topic

Kiame

Quote from: Nightinggale on November 01, 2017, 11:04:52 PM
Quote from: Kiame on November 01, 2017, 10:38:01 PMThe fun hack here was that I still needed to retrieve portrait variable which is an argument. The 'hack' i put in (because i don't know how to pass an argument variable in IL)
The code you replaced more or less provides the answer.
QuoteIL_0256: ldarg.s portrait
IL_0258: brfalse IL_0267

IL_025d: call bool Verse.Prefs::get_HatsOnlyOnMap()
IL_0262: brtrue IL_03b7
At the start of this, the stack is empty, then portrait is added. brfalse is removed, meaning it will not pull portrait off the stack and once the call line is reached, portrait is still there. According to what I read earlier (and haven't tested), this would cause portrait to be used as argument to the call. In case of multiple arguments, the first added to the stack is the first argument.

This is what i thought as well but i was getting an error. It was at a time when I was trying out a bunch of different combinations though so I may have written it off too soon. I'll see about re-writing it now that i have it working and see if that is how passing arguments works.

Nightinggale

#16
I just realized the problem in the first post.
IL_0256: ldarg.s portrait
IL_0258: brfalse IL_0267

IL_025d: call bool Verse.Prefs::get_HatsOnlyOnMap()
IL_0262: brtrue IL_03b7

// your code

IL_0267: nop

It goes 256->258->267 when portrait is false, meaning you did not end up with
if (!portrait || !Prefs.HatsOnlyOnMap)
{
    if (Settings.HideAllHats)

Instead you ended up with
if (!portrait || (!Prefs.HatsOnlyOnMap && Settings.HideAllHats)
On top of that, the keyword you use is gotoEndOfForLoopIfTrueInstruction, but you use it before the loop starts, which might be undefined. You should copy the existing (and working) statement "brtrue IL_03b7" because then you name the label you want to go to.

Also you need to inject the code after IL_0267 to avoid !portrait from skipping the next check. Alternatively you can add your own check before IL_0256 and branch to IL_03b7 on false.

However this isn't really important as there is a working solution now. I just wanted to add it in case somebody has Transpillar problems in the future and come across this thread.
ModCheck - boost your patch loading times and include patchmods in your main mod.

Nightinggale

Quote from: Kiame on November 01, 2017, 11:15:42 PMThis is what i thought as well but i was getting an error. It was at a time when I was trying out a bunch of different combinations though so I may have written it off too soon. I'll see about re-writing it now that i have it working and see if that is how passing arguments works.
ldarg.s is a byte while ldarg is an int. If one gives an error, try the other one ;)
ModCheck - boost your patch loading times and include patchmods in your main mod.

Kiame

I just added yield return instrcution (ie reinserting ldarg.s portrait) and it does work. So something else was broken when i was trying that   :P