Multiplayer icon indicating copy to clipboard operation
Multiplayer copied to clipboard

Use a Faction's storyteller instead of the AsyncTimeComp's

Open mibac138 opened this issue 2 months ago • 6 comments

Fixes delayed storyteller events not showing up. Events were added to the storyteller (IncidentQueue) of AsyncTimeComp, which was never ticked because of StorytellerTickPatch which made the method run per-faction, using the faction's storyteller. This caused a bunch of delayed events to just not work, e.g. requesting traders from the comms console, psychic rituals (summon animals, summon shamblers, void provocation), naturally spawning harbinger trees, and possibly others.

mibac138 avatar Oct 06 '25 12:10 mibac138

For some reason this patch is breaking areas in my testing save. It's not clear to me why as I can't reproduce it on a clean save. I'm suspecting it dislikes old saves. This save is working fine on dev. Out is the name of a zone. I'm trying to make a reproducible save.

System.Collections.Generic.KeyNotFoundException: The given key 'Out' was not present in the dictionary.
[Ref E463C88F]
 [0x00010] in <e3b07672ffbd43c1838e1ebbe94cbdf5>:0 
 [0x00000] in <e3b07672ffbd43c1838e1ebbe94cbdf5>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <e3b07672ffbd43c1838e1ebbe94cbdf5>:0 
  at Verse.AreaSource.DataForArea (Verse.Area area) [0x00000] in <31482697ada14932981abc5e76101d5d>:0 
  at Verse.PathFinderMapData.ParameterizeGridJob (Verse.PathRequest request, Verse.PathFinder+MapGridRequest& query, Verse.PathGridJob& job, Verse.PathFinder+GridJobOutput& output) [0x001b1] in <31482697ada14932981abc5e76101d5d>:0 
  at Verse.PathFinder.ScheduleGridJob (Verse.PathRequest request, Unity.Jobs.JobHandle handle) [0x00034] in <31482697ada14932981abc5e76101d5d>:0 
  at Verse.PathFinder.ScheduleGridJobs () [0x00040] in <31482697ada14932981abc5e76101d5d>:0 
  at Verse.PathFinder.PathFinderTick () [0x00042] in <31482697ada14932981abc5e76101d5d>:0 
  at Verse.Map.MapPreTick () [0x000b2] in <31482697ada14932981abc5e76101d5d>:0 
    - PREFIX multiplayer: Boolean Multiplayer.Client.AsyncTime.CancelMapManagersTick:Prefix()
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Map.MapPreTick_Patch1 (Verse.Map)
Multiplayer.Client.AsyncTimeComp:Tick () (at /media/Hakugyokurou/opt/SteamLibrary/steamapps/common/RimWorld/ModsDev/Multiplayer/Source/Client/AsyncTime/AsyncTimeComp.cs:120)
Multiplayer.Client.TickPatch:TickTickable (Multiplayer.Client.ITickable) (at /media/Hakugyokurou/opt/SteamLibrary/steamapps/common/RimWorld/ModsDev/Multiplayer/Source/Client/Patches/TickPatch.cs:251)
Multiplayer.Client.TickPatch:DoTick (bool&) (at /media/Hakugyokurou/opt/SteamLibrary/steamapps/common/RimWorld/ModsDev/Multiplayer/Source/Client/Patches/TickPatch.cs:221)
Multiplayer.Client.TickPatch:DoUpdate (bool&) (at /media/Hakugyokurou/opt/SteamLibrary/steamapps/common/RimWorld/ModsDev/Multiplayer/Source/Client/Patches/TickPatch.cs:196)
Multiplayer.Client.TickPatch:Prefix () (at /media/Hakugyokurou/opt/SteamLibrary/steamapps/common/RimWorld/ModsDev/Multiplayer/Source/Client/Patches/TickPatch.cs:115)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.TickManagerUpdate_Patch1 (Verse.TickManager)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Game.UpdatePlay_Patch1 (Verse.Game)
Verse.Root_Play:Update ()

notfood avatar Oct 06 '25 15:10 notfood

Testing required here. Preferable with old saves.

Multiplayer-v0.11.0-beta-storyteller-faction-fix.zip

notfood avatar Oct 09 '25 16:10 notfood

Hi me and my friend are playing on a build with this merged (rebased on latest dev) and I wonder why is this actually still not merged. Are you aware that Anomaly DLC is like literally unplayable without this because psychic rituals are not functioning without it at all?

It is getting annoying to apply on top of the dev every damn update.

If there is no repro then why not move this forward until we get a repo and then roll this back?

maxsupermanhd avatar Nov 03 '25 08:11 maxsupermanhd

It errors for me and I've gotten no feedback whatsoever.

notfood avatar Nov 03 '25 20:11 notfood

I was unable to reproduce the issue, and I was under the impression that you weren't able to either (I thought it perhaps might've been a spurious issue), as you did not provide a save file. I'd be happy to have a look at a broken save and fix it

mibac138 avatar Nov 04 '25 09:11 mibac138

I feel like it is starting to get lost in the Discord so I will repost trivial repro here from our coop odyssey playthrough.

  1. Load SpaceFox134-repro739.zip singleplayer save (unpack the zip because too fat...) and host it (no issues observed, logs are crystal clean everything works as intended)
  2. Start gravship launch and jump to orbital imperial satelite
  3. Confirm landing location (any location)
  4. Observe zones present in the gui and set on pawns, animals and mechs
  5. Upon unpause errors will begin piling into the debug log and ai on animals and mechs refuses to path anywhere unless zone restriction is unset.

maxsupermanhd avatar Nov 23 '25 21:11 maxsupermanhd

I have been able to reproduce this issue and determine the root cause. I believe this PR just made it more likely to encounter a pre-existing bug, that's likely been introduced with 1.6's pathing changes. Even without this PR you can trigger this bug by

  1. starting a multifaction server
  2. have 2 people on the server, each with their own faction
  3. one person must have a pawn on the other player's map, then create a zone and restrict a pawn to that zone. When pathing updates, this should trigger the problem.

This issue is caused by the PathFinder having faction-related data, such as areas, which can break when another faction's pawn uses it. I'm yet unsure what's the best way to fix the root issue. I don't want to have this PR blocked on this issue, so for now I have fixed this behavior on single-faction and reversed multi-faction behavior to how it was before the PR (using areas in a different faction's map still does not work, but that's how it is already).

mibac138 avatar Dec 27 '25 03:12 mibac138