Space Engineers

Space Engineers

Eat. Drink. Sleep. Repeat!
Kami-Kaze 29 Sep, 2023 @ 7:58am
Mod should un-register PlayerSpawend Hook
Hey,
I got this warning/error message from BuildInfo:
2023-09-29 14:43:17.043 - Thread: 1 -> ### Build Info.CheckVSLPEvents: Warning: 'MyVisualScriptLogicProvider.PlayerSpawned' was assigned before mods loaded. If hooks are from plugins or game itself then you can ignore this. Hooks: - target=DrinkWater.Session+<>c / method=Void <Init>b__5_0(Int64) / deeperDelegates=False 2023-09-29 14:43:17.050 - Thread: 1 -> ### Build Info.CheckVSLPEvents: Done checking events; preAssigned=1; erased=0; total events=56 2023-09-29 14:43:17.051 - Thread: 1 -> ### Build Info.CheckVSLPEvents: If the above involve your mod, you need to use += to hook and -= to unhook the events, don't use = If they are not your mods, send this info to the author if you can identify the mods, otherwise contact BuildInfo's author for help tracking down the problematic mod(s). 2023-09-29 14:43:17.051 - Thread: 1 -> MOD_ERROR: 514062285 2023-09-29 14:43:17.051 - Thread: 1 -> in file: Unknown 2023-09-29 14:43:17.051 - Thread: 1 -> Script mods might have issues from VSLP events being leaked or unhooked by other mods, see SE log for details.

Turns out this mod was causing the warning.
Reason being that the hook you register for player spawns never gets unhooked once the game is unloaded, meaning the hook is triggered in a save-file w/o EDSR if a world with EDSR was loaded beforehand.
As far as I can tell this is not actually causing any issues, but it is good practice unhook these events as they can cause silly, hard to debug, errors.

A simple solution would look like this (replacement for part of Session.cs):
public override void Init(MyObjectBuilder_SessionComponent sessionComponent) { isServer = MyAPIGateway.Multiplayer.IsServer; if (!isServer) { return; } MyVisualScriptLogicProvider.PlayerSpawned += PlayerSpawnedHook; MyAPIGateway.Session.SessionSettings.AutoHealing = false; UpdateAfterSimulation100(); } protected override void UnloadData() { MyVisualScriptLogicProvider.PlayerSpawned -= PlayerSpawnedHook; } private void PlayerSpawnedHook(long playerId) { justSpawned.Add(playerId); }
Where the hook is properly removed in
UnloadData()
Last edited by Kami-Kaze; 29 Sep, 2023 @ 8:00am
< >
Showing 1-3 of 3 comments
Ki Shuya 29 Sep, 2023 @ 8:59pm 
I've not seen this error, but if it's there then this is good to know. How would this look once implemented? Could you share a corrected file?
BarelyZen 19 Jan, 2024 @ 10:07pm 
I can confirm the suggestion and fix by Kami-Kaze. To test/verify (provided for those who may not know how):

Step 0 (pre-fix step): Because the error is most plainly visible in BuildInfo's log file (%appdata%\SpaceEngineers\Storage\2392775805.sbm_BuildInfo\info.log), I recommend installing BuildInfo and it's dependency Text HUD API. Load your game to assess the relatively minor error for yourself.

---

Step 1: I copied the workshop folder (\Program Files (x86)\Steam\steamapps\workshop\content\244850\2547246713) to (%appdata%\SpaceEngineers\Mods\).

Step 2: Changed the name of the copied (destination) folder to EDSR-2547246713 to be more human readable in-game mod selection.

Step 3: Decended the tree of the new folder to (%appdata%\SpaceEngineers\Mods\EDSR-2547246713\Data\Scripts\).

Step 4: Opened Session.cs in notepad++ (my preferred editor).

Step 5: Located the Init method and replace the code block with the code suggested by @Kami-Kaze.

Step 6: Saved and closed editor.

The next step assumes a test world. Any world will do, but it should be one you are willing to edit the mods for...

Step 7: Start Space Engineers > Load Game > Select a world > Edit Settings > Mods

NOTE: Local mods are typically sorted to the top on the left column of mods.

ADD the LOCAL version of the mod you created and edited for EDSR-2547246713.

IMPORTANT: If the official workshop version of EDSR presently exists (is added to) your test world, REMOVE it from the right column of mods.

This is the reason to have a test world, one that you typically run with zero mods except for those you are specifically testing.

You can then load up your game. The reason I suggested Step 0, is that, without a baseline that demonstrated the leak error, it is impossible to prove a negative. Play until you are satisfied. With the edits suggest by Kami-Kaze, the error was resolved for me without negative pin action (deleterious side-effects).

Thank you, Kami-Kaze for this. Since the author did not respond to you in a timely fashion (and I believe several months grace exceeds polite consideration), I chose to locally override the workshop version (as the license to use suggests) until such time as the author provides an update. The @Kami-Kaze provided code snippet satisfies the letter and intent of the GNU license. I'm not interested in publishing or maintaining a fork, so I shan't.

Finally, thank you, @Bačiulis for the hard work you put into this worthy alternative to the other mod whose name and litigious author (by the man on the Clapham omnibus, legal fiction standard) shall not be shared here.

[edited for speling and the gramer]
Last edited by BarelyZen; 19 Jan, 2024 @ 10:13pm
Duncanois 31 May, 2024 @ 3:00am 
Could this cause an issue with contracts/stores not refreshing? I know it's a long shot, but I just have a feeling based off errors I've been getting
< >
Showing 1-3 of 3 comments
Per page: 1530 50