MCPcopy Create free account
hub / github.com/demoth/jake2 / spawnServerInstance

Method spawnServerInstance

server/src/main/java/jake2/server/SV_MAIN.java:1285–1377  ·  view source on GitHub ↗

SV_Map

(ChangeMapInfo changeMapInfo, int clientIndex)

Source from the content-addressed store, hash-verified

1283 * SV_Map
1284 */
1285 GameImportsImpl spawnServerInstance(ChangeMapInfo changeMapInfo, int clientIndex) {
1286 Globals.server_state = ServerStates.SS_DEAD; //fixme: used by the client code
1287
1288 GameExports oldGame = null;
1289 GameImportsImpl gameImports;
1290
1291 if (clientIndex != 0)
1292 gameImports = games.get(clients.get(clientIndex - 1).gameName);
1293 else
1294 gameImports = games.get("default");
1295
1296 if (gameImports != null) { //todo
1297 // store some entity data into gclient_t struct, will be restored in the next game
1298 oldGame = gameImports.gameExports;
1299 oldGame.SaveClientData();
1300 }
1301
1302 gameImports = createGameInstance(changeMapInfo);
1303
1304 Cvar.getInstance().Set("nextserver", "gamemap \"" + changeMapInfo.nextServer + "\"");
1305
1306 Cmd.ExecuteFunction("loading"); // for local system
1307
1308 if (clientIndex == 0) {
1309 // leave slots at start for clients only
1310 for (client_t cl : clients) { //todo
1311 // needs to reconnect
1312 if (cl.state == ClientStates.CS_SPAWNED)
1313 cl.state = ClientStates.CS_CONNECTED;
1314 cl.lastReceivedFrame = -1;
1315 }
1316 gameImports.SV_BroadcastCommand("changing");
1317
1318 } else {
1319 final client_t cl = clients.get(clientIndex - 1);
1320 if (cl.state == ClientStates.CS_SPAWNED)
1321 cl.state = ClientStates.CS_CONNECTED;
1322 cl.lastReceivedFrame = -1;
1323 gameImports.unicastMessage(clientIndex, new StuffTextMessage("changing"), true);
1324 }
1325
1326 SV_SendClientMessages();
1327
1328
1329 // precache and static commands can be issued during
1330 // map initialization
1331 Globals.server_state = gameImports.sv.state; // LOADING
1332
1333 if (oldGame != null) {
1334 // copy persistent data between instances.
1335 // after a 'map' command the persistent state will be empty
1336 gameImports.gameExports.fromPrevious(oldGame, changeMapInfo.spawnPoint);
1337 }
1338
1339
1340 // spawn fresh entities
1341 gameImports.gameExports.SpawnEntities(gameImports.sv.name, gameImports.cm.CM_EntityString(), changeMapInfo.spawnPoint);
1342

Callers 3

runGameMethod · 0.95
SV_Loadgame_fMethod · 0.95
SV_GameMap_fMethod · 0.95

Calls 15

SaveClientDataMethod · 0.95
createGameInstanceMethod · 0.95
getInstanceMethod · 0.95
ExecuteFunctionMethod · 0.95
SV_BroadcastCommandMethod · 0.95
unicastMessageMethod · 0.95
SV_SendClientMessagesMethod · 0.95
SV_ClearWorldMethod · 0.95
CopyToDeferMethod · 0.95
SetMethod · 0.80
CM_EntityStringMethod · 0.80
isPreviousLevelMethod · 0.80

Tested by 1

runGameMethod · 0.76