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

Method SV_GameMap_f

server/src/main/java/jake2/server/SV_MAIN.java:1194–1280  ·  view source on GitHub ↗
(List<String> args)

Source from the content-addressed store, hash-verified

1192Spins up a new game instance, to be used with either `map` or `join` (TBD)
1193*/
1194 void SV_GameMap_f(List<String> args) {
1195
1196 if (args.size() < 2) {
1197 Com.Printf("USAGE: gamemap <map>\n <client>");
1198 return;
1199 }
1200
1201 String mapName = args.get(1);
1202
1203 final int clientIndex;
1204 if (args.size() > 2)
1205 clientIndex = Integer.parseInt(args.get(2));
1206 else
1207 clientIndex = 0;
1208
1209 Com.DPrintf("SV_GameMap(" + mapName + ")\n");
1210
1211 FS.CreatePath(FS.getWriteDir() + "/save/current/");
1212
1213 // check for clearing the current savegame
1214 if (mapName.charAt(0) == '*') {
1215 // wipe all the *.sav files
1216 SV_WipeSavegame("current");
1217 } else { // save the map just exited
1218 // note: only applicable to the default instance (subject to change in future)
1219 var gameImports = games.get("default");
1220 if (gameImports != null && gameImports.sv.state == ServerStates.SS_GAME) {
1221 // clear all the client inuse flags before saving so that
1222 // when the level is re-entered, the clients will spawn
1223 // at spawn points instead of occupying body shells
1224 // todo: only relevant to this gameImports clients
1225 boolean[] savedInuse = new boolean[clients.size()];
1226 int i = 0;
1227 for (client_t cl : clients) {
1228 if (cl.edict != null) { // free client slots will have null values
1229 savedInuse[i] = cl.edict.inuse;
1230 cl.edict.inuse = false;
1231 }
1232 i++;
1233 }
1234
1235 gameImports.SV_WriteLevelFile();
1236
1237 // we must restore these for clients to transfer over correctly
1238 i = 0;
1239 for (client_t cl: clients) {
1240 if (cl.edict != null) { // free client slots will have null values
1241 cl.edict.inuse = savedInuse[i];
1242 }
1243 i++;
1244 }
1245 }
1246 }
1247
1248 final GameImportsImpl game = spawnServerInstance(new ChangeMapInfo(mapName, false, false), clientIndex);
1249
1250 if (clientIndex == 0) {
1251 // server just started, `map` cmd was used

Callers 2

SV_MAINMethod · 0.95
SV_Map_fMethod · 0.95

Calls 13

PrintfMethod · 0.95
DPrintfMethod · 0.95
CreatePathMethod · 0.95
getWriteDirMethod · 0.95
spawnServerInstanceMethod · 0.95
SV_WriteServerFileMethod · 0.95
sizeMethod · 0.80
SV_WipeSavegameMethod · 0.80
SV_WriteLevelFileMethod · 0.80
SV_CopySaveGameMethod · 0.80
ClientDisconnectMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected