More Awesome Than You!

Awesomeware => AwesomeMod! => Topic started by: jeffro on 2010 November 03, 14:24:23



Title: What am I missing here? Calling private fncs...
Post by: jeffro on 2010 November 03, 14:24:23
I've been reviewing the code for the awesome.dll. I've noticed a number of calls to 'private' functions within the gameplay.systems dll.

When I try accessing a private function in my own dll, I get a 'does not contain a definition for'.

Short of setting those fncs to public, how are these private members accessed? Is it a C# Studio setting I'm missing. I'm using the 3.5 platform.

For instance,  MartialArts.GetScoreForMartialArtist. This is a privately declared fnc. I can't compile if I try calling it.

Any help?

Thanks.


Title: Re: What am I missing here? Calling private fncs...
Post by: J. M. Pescado on 2010 November 03, 16:06:30
AwesomeMod is written with MSIL and is not required to adhere to encapsulation rules, as MSIL ignores all of these things. It also explodes spectacularly when misused. As mentioned in another thread, the code we deal in looks a lot like this:
Code:
    L_0000: ldarg.0 
    L_0001: callvirt instance class Sims3.Gameplay.CAS.SimDescription Sims3.Gameplay.Actors.Sim::get_SimDescription()
    L_0006: callvirt instance bool Sims3.Gameplay.CAS.SimDescription::get_TeenOrBelow()
    L_000b: ldarg.1
    L_000c: callvirt instance class Sims3.Gameplay.CAS.SimDescription Sims3.Gameplay.Actors.Sim::get_SimDescription()
    L_0011: callvirt instance bool Sims3.Gameplay.CAS.SimDescription::get_TeenOrBelow()
    L_0016: bne.un.s L_002b
    L_0018: ldarg.1
    L_0019: callvirt instance class Sims3.Gameplay.Socializing.Genealogy Sims3.Gameplay.Actors.Sim::get_Genealogy()
    L_001e: ldarg.0
    L_001f: callvirt instance class Sims3.Gameplay.Socializing.Genealogy Sims3.Gameplay.Actors.Sim::get_Genealogy()
    L_0024: callvirt instance bool Sims3.Gameplay.Socializing.Genealogy::IsParentOrStepParent(class Sims3.Gameplay.Socializing.Genealogy)
    L_0029: brfalse.s L_002d
To make a C# compiler accept such craziness involves armtwisting it into believing those are public functions, by rebuilding it from the MSIL with the private bits exposed.


Title: Re: What am I missing here? Calling private fncs...
Post by: jeffro on 2010 November 03, 16:32:31
Driving home this morning I was wondering if I were to make my calls and references to the private stuff from Reflector, instead of C# studio, if I might circumvent the problem, being just the Microsoft compiler complaining at me.

Sounds like it from what you're saying.

Thank you Mr. Awesome. I'll give that a shot.

edit: on second thought, once I make the call using Reflector, I won't ever be able to compile in C# studio again without commenting stuff out.  hmm...


Title: Re: What am I missing here? Calling private fncs...
Post by: jeffro on 2010 November 03, 18:17:58
I just loaded Reflexil 1.1.

It allows changing constants as well as functions to public.

So I'll just go that route until the game throws up on it. Hopefully it won't.