Multiplayer icon indicating copy to clipboard operation
Multiplayer copied to clipboard

Fix only one faction having access to Anomaly research in Multifaction

Open SokyranTheDragon opened this issue 1 year ago • 0 comments

In Multifaction, only one of the factions can access the Anomaly research tab. Anomaly tab is unlocked when awakening the monolith, but the Anomaly state is global (rather than per-player) which means that there should ever be 1 monolith, and awakening it progresses the Anomaly level for everyone. The issue here is that the code that unlocks Anomaly research tab runs for a single player, meaning that everyone besides the person triggering it will be locked out of it. It also won't unlock for factions unlocked after raising the Anomaly level either.

Changes:

  • Added a patch to ResearchManager.Notify_MonolithLevelChanged, and then called the method with faction repeater to ensure that unlocking research applies to all active factions
    • All that the patched method does is unlock all the research tabs locked behind a specific Anomaly level
    • However, this won't double some of the special events, like activating Gray Pall or the ending sequence
  • Added a call to ResearchManager:Notify_MonolithLevelChanged inside FactionCreator:InitNewGame to unlock Anomaly research for new factions
    • This will only apply if the Anomaly level is high enough to unlock it
  • Added code to call ResearchManager:Notify_MonolithLevelChanged inside MultiplayerWorldComp:DoBackCompat to unlock Anomaly research for factions created before the fix was introduced
    • Again, this will only apply if the Anomaly level is high enough to unlock it
    • I've picked DoBackCompat as it seemed fitting to me, but it could be moved to a different location if needed
    • As mentioned in the comments, the monolith is not spawned yet so the check isn't perfect - fixing it would require moving the code to a postfix for Building_VoidMonolith:SpawnSetup
  • Added copying of all anomaly knowledge, unlocked research projects, and tab visibility inside of HostUtil:SetupGameFromSingleplayer
    • This roughly matches with original code for normal research, where research progress and applied techprints were copied

@Zetrith if you'd like me to move the code fixing existing save files somewhere else that's not DoBackCompat, or make some other changes, just let me know.

SokyranTheDragon avatar Aug 20 '24 19:08 SokyranTheDragon