Tell me a little more about what is going on.
You start a game with mapname?listen
and several clients join somehow? Via open someipaddr
on the console window?
Now you have several clients connected to an existing server and you want to have the map switch?
You should be using seamless travel (bUseSeamlessTravel
set on the AGameMode
class) and then do this
FString UrlString = TEXT("nextmapname?otheroptionsyouwant");
GetWorld()->ServerTravel(UrlString);
This will keep connections alive for all existing clients, load a transition map, unload your old map, then load the new map. This keeps high memory watermarks from causing Out Of Memory conditions.
To do seamless travel you need some settings in DefaultEngine.ini
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/Maps/MyGameEntry
ServerDefaultMap=/Game/Maps/MyGameEntry
GlobalDefaultGameMode="/Script/MyGame.MyGameMode"
GlobalDefaultServerGameMode="/Script/MyGame.MyGameMode"
TransitionMap=/Game/Maps/MyGameTransition
The transition map can be anything; a blank, empty map is best. You can actually have things load and display during the map transition (like the Gears of War scoreboard with particles floating in the background), which will go away when the new map is loaded. I don’t know much about how the content is setup for that, but an empty map should suffice for now.
Clients shouldn’t have to do anything special during seamless travel. If you see
LogNet: NotifyAcceptingConnection: Server Chess refused
It’s most likely because seamless travel is off, the clients were disconnected, and they are trying to get back in. If you “hard travel” back to another world and didn’t include the ?listen then the new server destination won’t be setup to receive clients. Seamless travel handles this for you.
Also, during seamless travel there is a garbage collection step that takes place between loading the new world and unloading the old. We make sure nothing references the old world (causing a memory leak). If you have any AActors or UObjects that refer to the old UWorld that get carried over to the new map then you’ll get an assert about the old world still staying around. Hopefully this won’t be the case for you, but if it does we can talk about that too.
I hope this helps. This stuff isn’t that straightforward and documentation is on the way.