[01.190.101][ModAPI] MyAPIGateway.Session.Player is null for first 3 ticks for MP clients

Digi shared this bug 3 years ago

This behavior seems to be new as I suddenly got people reporting that a specific feature of a mod doesn't work, after some investigation it seems that MyAPIGateway.Session.Player is null when BeforeStart() is executed.

Also, I've added a test in an update method and it only goes non-null in the 4th tick.

This is an issue especially since MyAPIGateway.Session itself is not null way earlier than that and can break scripts that require player data early.

It's also a lot of work to go through a lot of scripts to track and avoid relying on Player in the first 3 ticks.

Steps to reproduce:

1. Add this mod to a DS: https://steamcommunity.com/sharedfiles/filedetails/?id=1738948316

2. Join the DS

3. Open SE log on the client side and search for "bugtest"

2019-05-12 02:44:04.114 - Thread:   1 ->  ### BugTest: BeforeStart() :: Player == NULL
2019-05-12 02:44:04.711 - Thread:   1 ->  ### BugTest: found Player != null at tick=4

If fixed, the BeforeStart() one should say that it's valid.

Replies (1)


Hello, Engineer!

Thank you for your feedback! Your topic has been added between considered issues.

Please keep voting for the issue as it will help us to identify the most serious bugs.

We really appreciate your patience.

Kind Regards

Keen Software House: QA Department

Leave a Comment
Attach a file