Making mod compatible with Woohooer

Talk nerdy to us here.
aede_ofThuul
Reactions:
Posts: 50
Joined: April 26th, 2020, 5:37 am

Making mod compatible with Woohooer

Post by aede_ofThuul » August 26th, 2020, 12:36 am

Chain_Reaction post_id=76512 time=1598401491 user_id=2 wrote: It will cause me headaches if another user starts using our DLL names or namespaces
Hm yeah I can see how that would be a problem :P

In that case, I'll have my mod check on world load to see if Chemistry actually is installed and add the string to sAssemblies if it isn't, and also tell my version of CalculateAttraction not to run if Chemistry is there. Should handle both compatibility with Woohooer now and compatibility (at least in this one regard) with Chemistry later. Thanks for the help!

[EDIT: I'm actually having a little trouble accessing sAssemblies, presumably because it's a private field. This line always gives me a null:

Code: Select all

FieldInfo assembliesField = nestedType.GetField("sAssemblies", BindingFlags.NonPublic)
And I'm pretty sure it's just that line that's the problem, because I've got debug messages confirming that a method in the same class is able to be called from my script with no issues. Am I using the wrong binding flags for a private static dictionary? I tried BindingFlags.NonPublic| BindingFlags.Static as well to no avail.]

User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7617
Joined: December 30th, 2011, 6:00 pm
Answers: 82
Contact:

Making mod compatible with Woohooer

Post by Chain_Reaction » August 26th, 2020, 5:46 am

Hmm, theoretically it should work. Reflection can be a pain. How about just BindingFlags.Static?

aede_ofThuul
Reactions:
Posts: 50
Joined: April 26th, 2020, 5:37 am

Making mod compatible with Woohooer

Post by aede_ofThuul » August 26th, 2020, 9:36 am

No luck with just BindingFlags.Static either. A comment I found on StackOverflow says:
One thing that you need to be aware of when reflecting on private members is that if your application is running in medium trust (as, for instance, when you are running on a shared hosting environment), it won't find them -- the BindingFlags.NonPublic option will simply be ignored.
I don't know what hosting environments or trust are yet, but could that be relevant here? If so I may switch to just adding "using NRaas.Common", and give up on this mod being able to not crash the game if there's not at least something from the NRaas suite installed (assuming what would cause the crash is encountering a "using" statement for a class that doesn't exist when my assembly is loaded, which I wouldn't be able to get around by checking first to see if the class in question exists). It seems like most people probably have or are willing to get at least MasterController or ErrorTrap or Overwatch, so that's probably not even a stretch; or I could make NRaas/no NRaas versions like I think Zerbu did for Ultimate Careers. [Another edit: actually that second solution doesn't work with private variables either - seems I've backed myself into a corner, hmmm.]

aede_ofThuul
Reactions:
Posts: 50
Joined: April 26th, 2020, 5:37 am

Making mod compatible with Woohooer

Post by aede_ofThuul » August 28th, 2020, 11:23 am

Important update: due to, in retrospect, really irrational placement and interpretation of debugging messages, I had totally misdiagnosed the problem. I don't know what I was thinking, I was tired I guess. That's fixed, so I now realize the actual problem has been that the final step of all this, where I try to set my edited dictionary as the new value of AssemblyCheck.sAssemblies, is succeeding but not at what I had thought it would do - will continue to research/debug now that I have correctly identified the problem.

Edit: Success! This mod now checks for the presence of both Woohooer and Chemistry, and fakes the installation of Chemistry if it isn't actually installed. Then when its attraction scoring method is called, it yields control over attraction scoring to Chemistry if present; and if Chemistry isn't found but Woohooer is, it calculates attraction if Chemistry was successfully faked but otherwise yields to Woohooer. So should be good with both mods.

aede_ofThuul
Reactions:
Posts: 50
Joined: April 26th, 2020, 5:37 am

Making mod compatible with Woohooer

Post by aede_ofThuul » April 30th, 2021, 5:20 pm

Hello, I hope you're doing well! Eight months later I am back with another question, wow I've been slow.

I realized my strategy for making it so my attraction scoring method is the only one that runs only works on the unreleased version of Woohooer from Github, not on version 129, because Woohooer 129 doesn't check for Chemistry before it calculates attraction scores. So when I finally post the mod I'm just going to say it's not compatible with Woohooer in some minor ways, and people can decide whether to use it anyway or not (I give up XD)

For myself though, I just built the un-released version of Woohooer and stuck that in my game and that took care of it. So, the question: I think I'm going to keep the Github version of Woohooer in regardless, but do you remember if there are any major un-tested changes in that version that I might run afoul of? Don't go to any trouble if it's not an easy answer of course, I'm just curious if I'm flirting with danger :D

User avatar
igazor
Organizer
Reactions:
Posts: 17148
Joined: April 8th, 2013, 6:00 pm
Answers: 206
Location: Everyone should strive to find their inner platypus.

Making mod compatible with Woohooer

Post by igazor » April 30th, 2021, 5:39 pm

Sorry, I don't have a horse in this race (as the expression goes) and I may be missing the point, but wouldn't the version of Woohooer you used be the equivalent of v130a that is currently in Beta Testing? Since the testing versions of the mods are available to all, it's not inappropriate to insist that one of them is the required version to ensure cross-mod compatibility, for those who intend to use both mods.

aede_ofThuul
Reactions:
Posts: 50
Joined: April 26th, 2020, 5:37 am

Making mod compatible with Woohooer

Post by aede_ofThuul » April 30th, 2021, 5:53 pm

Whaaaat how did I miss that entire page! Hope is restored, full compatibility is possible after all :) Thanks a lot, I was totally going to just give up and call it a loss.

...also I should test out some of these!

Post Reply