Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync rename dialogs (sync IRenameable.RenamableLabel setter) #443

Merged
merged 2 commits into from
May 24, 2024

Conversation

SokyranTheDragon
Copy link
Member

Synced all implementations of IRenameable.RenamableLabel setter for types that can be synced.

I've decided to only apply the sync worker for types that can be synced for safety, as the rename dialogs are of low enough importance that encountering errors or other issues because of them would not be desirable. After all, if rename dialog is not synced then it should not cause any issues besides a minor visual desync (unless there's a mod that does something special with the name, which I've not really encountered).

I've wrapped the portion of the code registering it in a double call to LongEventHandler.ExecuteWhenFinished to ensure it runs after MP Compat's late patches, ensuring all Sync Workers will be registered by it at this point.

Because of no logging when there's IRenameable that can't be synced, I've included a debug action which will list all types implementing IRenameable.RenamableLabel setter, separated into synced and unsynced ones. This will allow us to easily check if we need to create a sync worker for any of the IRenameable implementations.

On top of that, I've also synced Dialog_RenameBuildingStorage_CreateNew:OnRenamed. It creates a storage group, which requires syncing on top of renaming. No other vanilla dialog needs syncing dialogs like those, but some mods may require it as well.

Synced all implementations of `IRenameable.RenamableLabel` setter for types that can be synced.

I've decided to only apply the sync worker for types that can be synced for safety, as the rename dialogs are of low enough importance that encountering errors or other issues because of them would not be desirable. After all, if rename dialog is not synced then it should not cause any issues besides a minor visual desync (unless there's a mod that does something special with the name, which I've not really encountered).

I've wrapped the portion of the code registering it in a double call to `LongEventHandler.ExecuteWhenFinished` to ensure it runs after MP Compat's late patches, ensuring all Sync Workers will be registered by it at this point.

Because of no logging when there's `IRenameable` that can't be synced, I've included a debug action which will list all types implementing `IRenameable.RenamableLabel` setter, separated into synced and unsynced ones. This will allow us to easily check if we need to create a sync worker for any of the `IRenameable` implementations.
`Dialog_RenameBuildingStorage_CreateNew:OnRenamed` creates a storage group, which requires syncing on top of renaming. No other vanilla dialog needs syncing dialogs like those, but some mods may require it as well.
@SokyranTheDragon SokyranTheDragon added the 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). label Apr 15, 2024
SokyranTheDragon added a commit to SokyranTheDragon/Multiplayer-Compatibility that referenced this pull request May 23, 2024
This should fix the issues I've found so far, along with a handful of changes/improvements.

Vanilla Expanded Framework:
- Slightly modified the modular patching
  - Changed where the patch method is called, so it'll include the try/catch block in late patches as well
  - Added a message log behind (for debug builds only) that will log what is being patched before applying the patch
- Vanilla Furniture Expanded patch was moved to late patch to prevent issues due to the mod accessing DefOfs in the patched methods

Vanilla Events Expanded:
- Stopped pushing/popping the RNG state where it's not needed
  - I've originally made those patches when I didn't fully understand how MP and RimWorld work, so I assumed that those would be needed

Vanilla Factions Expanded - Empire:
- Added a null map check to the quest generation
  - This is an issue with the mod itself which will happen if `TestRun` method is called for a faction without maps (Vanilla-Expanded/VanillaFactionsExpanded-Empire#8)
  - After deeper investigation I've realized it always happens in MP due to MP's `FactionRepeater` trying to repeat a quest generation for all factions, including spectator faction (which doesn't have any maps)

Vanilla Furniture Expanded - Security:
- Stopped pushing/popping the RNG state where it's not needed
  - Same reason as for Vanilla Events Expanded
- Changed patch target from `Draw` to `DrawAt`

Vanilla Psycasts Expanded:
- Changed the patching to work similar as Vanilla Expanded Framework - made it modular so if a single module fails then it won't break everything after it
- Removed an empty method (PatchCurrentMapUsage)
- Renamed PatchGizmosAndFlecks to PatchMotesAndFlecks
- Slightly reorganized where some of the patches are
- Completely reworked psyset renaming code (won't do anything meaningful until mering rwmt/Multiplayer#443)
  - Added `Dialog_RenamePsysetMp` class, which will handle renaming and allow MP to sync it
  - Added `PsysetRenameHolder` class, which hold the psyset and psycasting hediff and will be used for syncing psysets
    - We cannot sync psysets by themselves as they don't store any reference to their parent, and we need a workaround by using the hediff to sync them
  - Changed psycasting ITab code to create our rename dialog instead of the VPE one, as well as making the code pass the hediff to the constructor
notfood pushed a commit to rwmt/Multiplayer-Compatibility that referenced this pull request May 24, 2024
This should fix the issues I've found so far, along with a handful of changes/improvements.

Vanilla Expanded Framework:
- Slightly modified the modular patching
  - Changed where the patch method is called, so it'll include the try/catch block in late patches as well
  - Added a message log behind (for debug builds only) that will log what is being patched before applying the patch
- Vanilla Furniture Expanded patch was moved to late patch to prevent issues due to the mod accessing DefOfs in the patched methods

Vanilla Events Expanded:
- Stopped pushing/popping the RNG state where it's not needed
  - I've originally made those patches when I didn't fully understand how MP and RimWorld work, so I assumed that those would be needed

Vanilla Factions Expanded - Empire:
- Added a null map check to the quest generation
  - This is an issue with the mod itself which will happen if `TestRun` method is called for a faction without maps (Vanilla-Expanded/VanillaFactionsExpanded-Empire#8)
  - After deeper investigation I've realized it always happens in MP due to MP's `FactionRepeater` trying to repeat a quest generation for all factions, including spectator faction (which doesn't have any maps)

Vanilla Furniture Expanded - Security:
- Stopped pushing/popping the RNG state where it's not needed
  - Same reason as for Vanilla Events Expanded
- Changed patch target from `Draw` to `DrawAt`

Vanilla Psycasts Expanded:
- Changed the patching to work similar as Vanilla Expanded Framework - made it modular so if a single module fails then it won't break everything after it
- Removed an empty method (PatchCurrentMapUsage)
- Renamed PatchGizmosAndFlecks to PatchMotesAndFlecks
- Slightly reorganized where some of the patches are
- Completely reworked psyset renaming code (won't do anything meaningful until mering rwmt/Multiplayer#443)
  - Added `Dialog_RenamePsysetMp` class, which will handle renaming and allow MP to sync it
  - Added `PsysetRenameHolder` class, which hold the psyset and psycasting hediff and will be used for syncing psysets
    - We cannot sync psysets by themselves as they don't store any reference to their parent, and we need a workaround by using the hediff to sync them
  - Changed psycasting ITab code to create our rename dialog instead of the VPE one, as well as making the code pass the hediff to the constructor
@Zetrith Zetrith merged commit 9002361 into rwmt:master May 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants