sinbad / SPUD

Steve's Persistent Unreal Data library
MIT License
327 stars 47 forks source link

The Reason OnPreLoadMap Stores Level Data? #81

Closed dyanikoglu closed 1 week ago

dyanikoglu commented 1 month ago

Hi 👋🏻

While testing seamless travelling in multiplayer environment, I noticed an issue with OnPreLoadMap callback in SpudSubsystem.

When a seamless travel happens in a dedicated server environment, OnPreLoadMap is called before client transitions back to target level. This is causing player data to get lost because of USpudSubsystem::OnPreLoadMap executing the code block below:

// Map and all streaming level data will be released.
// Block while doing it so they all get written predictably
StoreWorld(World, true, true);

Is there any purpose on storing/saving world state during level pre load?

for (auto && Level : World->GetLevels())
{
    GetActiveState()->ReleaseLevelData(USpudState::GetLevelName(Level), true);
}   

Replacing StoreWorld call with the code block above should be doing same required memory cleanup stuff, and seamless travel game load works properly. Not sure if this may cause some side effects though.

sinbad commented 1 month ago

The StoreWorld is there so that the contents of the current map are saved when travelling to a new level while still in the current game (as opposed to loading a game). The test if (CurrentState == ESpudSystemState::RunningIdle) is to identify this case. Without StoreWorld the state of the (persistent) level you're leaving would be lost.