hedge-dev / HMMCodes

Hedge Mod Manager community codes repository
14 stars 16 forks source link

[Sonic Origins] Legacy global functions & GameStartup library #127

Closed MegAmi24 closed 4 months ago

MegAmi24 commented 5 months ago

This PR removes the structs for legacy game global variables and replaces them with GetLegacyGlobalID, GetLegacyGlobalByName, and SetLegacyGlobalByName functions, similar to what's found inside RSDK itself. GetLegacyGlobalID looks up the numerical ID of a global variable based off of its name, and the other two functions use that to get or set the value of the variable. The benefits to these functions are:

The Bridge.SetGlobalVariables library is also updated and renamed to GameStartup. The updated library allows codes to add their own global variables to a list that the library then uses to set those variables in-game.

This PR also marks the Enable 7th Chaos Emerald code as experimental and adds the Enable Original Camera Tracking code.

thesupersonic16 commented 5 months ago

Sorry for the late reply, do we really need to keep Bridge.SetGlobalVariables when RSDK.SetLegacyGlobalByName exists?

MegAmi24 commented 5 months ago

Sorry for the late reply, do we really need to keep Bridge.SetGlobalVariables when RSDK.SetLegacyGlobalByName exists?

Simply setting the variables every frame causes issues with the shield/item related codes, as since HMM only runs its code at the end of each frame, and loading the game loads both the GameConfig and the starting scene on the same frame (there is relevant shield and monitor code that runs in ObjectStartup), the codes will not properly apply when initially loading the game from a save file or My Data.

The unmanaged function within the Bridge is ran when HE2 is setting Origins specific variables (e.g. playMode and coinMode), which fixes this issue. Since there are six codes for setting variables like this, I use a Bridge to keep things clean. Also, if it's possible, I'd eventually like to make it so codes can specify their own variables to set other than the ones currently supported in the Bridge.

MegAmi24 commented 4 months ago

Apologies if I sound impatient, but is there a reason this two month old PR hasn't been merged yet despite the changes being approved twice now? Is someone else other than SS16 supposed to approve the changes as well?

thesupersonic16 commented 4 months ago

I was expecting someone else to merge it, but I can do it.