/* ================== SV_Map_f Goes directly to a given map without any savegame archiving. For development work ================== */ static void SV_Map_f (void) { char *map; char expanded[MAX_QPATH]; if (Cmd_Argc() != 2) { Com_Printf ("USAGE: map <mapname>\n"); return; } // if not a pcx, demo, or cinematic, check to make sure the level exists map = Cmd_Argv(1); if (!strchr(map, '.') && !strchr(map, '$')) { Com_sprintf (expanded, sizeof(expanded), "maps/%s.bsp", map); if (FS_LoadFile (expanded, NULL) == -1) { Com_Printf ("Can't find %s\n", expanded); return; } } sv.state = ss_dead; // don't save current level when changing SV_WipeSavegame("current"); SV_GameMap_f (); }
/* ================== SV_GameMap_f Saves the state of the map just being exited and goes to a new map. If the initial character of the map string is '*', the next map is in a new unit, so the current savegame directory is cleared of map files. Example: *inter.cin+jail Clears the archived maps, plays the inter.cin cinematic, then goes to map jail.bsp. ================== */ void SV_GameMap_f (void) { char *map; int i; client_t *cl; qboolean *savedInuse; if (Cmd_Argc() != 2) { Com_Printf ("USAGE: gamemap <map>\n"); return; } Com_DPrintf("SV_GameMap(%s)\n", Cmd_Argv(1)); FS_CreatePath (va("%s/save/current/", FS_Gamedir())); // check for clearing the current savegame map = Cmd_Argv(1); if (map[0] == '*') { // wipe all the *.sav files SV_WipeSavegame ("current"); } else { // save the map just exited if (sv.state == ss_game) { // clear all the client inuse flags before saving so that // when the level is re-entered, the clients will spawn // at spawn points instead of occupying body shells savedInuse = malloc(maxclients->value * sizeof(qboolean)); for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++) { savedInuse[i] = cl->edict->inuse; cl->edict->inuse = false; } SV_WriteLevelFile (); // we must restore these for clients to transfer over correctly for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++) cl->edict->inuse = savedInuse[i]; free (savedInuse); } } // start up the next map SV_Map (false, Cmd_Argv(1), false ); // archive server state strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1); // copy off the level to the autosave slot if (!dedicated->value) { SV_WriteServerFile (true); SV_CopySaveGame ("current", "save0"); } }
/* ================== SV_Map_f Goes directly to a given map without any savegame archiving. For development work ================== */ void SV_Map_f (void) { char *map; char expanded[MAX_QPATH]; if (Cmd_Argc() != 2) { Com_Printf ("USAGE: map <mapname>\n"); return; } // if not a pcx, demo, or cinematic, check to make sure the level exists map = Cmd_Argv(1); if (!strstr (map, ".")) { Com_sprintf (expanded, sizeof(expanded), "maps/%s.bsp", map); if (FS_LoadFile (expanded, NULL) == -1) { Com_Printf ("Can't find %s\n", expanded); //if (!dedicated->value && cls.state != ca_connected) // Knightmare added // CL_Drop (); return; } } sv.state = ss_dead; // don't save current level when changing SV_WipeSavegame("current"); SV_GameMap_f (); }
/* ================ SV_CopySaveGame ================ */ void SV_CopySaveGame (char *src, char *dst) { char name[MAX_OSPATH], name2[MAX_OSPATH]; int l, len; char *found; Com_DPrintf("SV_CopySaveGame(%s, %s)\n", src, dst); SV_WipeSavegame (dst); // copy the savegame over Com_sprintf (name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir(), src); Com_sprintf (name2, sizeof(name2), "%s/save/%s/server.ssv", FS_Gamedir(), dst); FS_CreatePath (name2); CopyFile (name, name2); Com_sprintf (name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir(), src); Com_sprintf (name2, sizeof(name2), "%s/save/%s/game.ssv", FS_Gamedir(), dst); CopyFile (name, name2); // Knightmare- copy screenshot if (strcmp(dst, "kmq2save0")) // no screenshot for start of level autosaves { Com_sprintf (name, sizeof(name), "%s/save/%s/shot.jpg", FS_Gamedir(), src); Com_sprintf (name2, sizeof(name2), "%s/save/%s/shot.jpg", FS_Gamedir(), dst); CopyFile (name, name2); } Com_sprintf (name, sizeof(name), "%s/save/%s/", FS_Gamedir(), src); len = strlen(name); Com_sprintf (name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir(), src); found = Sys_FindFirst(name, 0, 0 ); while (found) { // strncpy (name+len, found+len); Q_strncpyz (name+len, found+len, sizeof(name)-len); Com_sprintf (name2, sizeof(name2), "%s/save/%s/%s", FS_Gamedir(), dst, found+len); CopyFile (name, name2); // change sav to sv2 l = strlen(name); // strncpy (name+l-3, "sv2"); Q_strncpyz (name+l-3, "sv2", sizeof(name)-l+3); l = strlen(name2); // strncpy (name2+l-3, "sv2"); Q_strncpyz (name2+l-3, "sv2", sizeof(name2)-l+3); CopyFile (name, name2); found = Sys_FindNext( 0, 0 ); } Sys_FindClose (); }
void SV_CopySaveGame(char *src, char *dst) { char name[MAX_OSPATH], name2[MAX_OSPATH]; size_t l, len; char *found; Com_DPrintf("SV_CopySaveGame(%s, %s)\n", src, dst); SV_WipeSavegame(dst); /* copy the savegame over */ Com_sprintf(name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir(), src); Com_sprintf(name2, sizeof(name2), "%s/save/%s/server.ssv", FS_Gamedir(), dst); FS_CreatePath(name2); CopyFile(name, name2); Com_sprintf(name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir(), src); Com_sprintf(name2, sizeof(name2), "%s/save/%s/game.ssv", FS_Gamedir(), dst); CopyFile(name, name2); Com_sprintf(name, sizeof(name), "%s/save/%s/", FS_Gamedir(), src); len = strlen(name); Com_sprintf(name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir(), src); found = Sys_FindFirst(name, 0, 0); while (found) { strcpy(name + len, found + len); Com_sprintf(name2, sizeof(name2), "%s/save/%s/%s", FS_Gamedir(), dst, found + len); CopyFile(name, name2); /* change sav to sv2 */ l = strlen(name); strcpy(name + l - 3, "sv2"); l = strlen(name2); strcpy(name2 + l - 3, "sv2"); CopyFile(name, name2); found = Sys_FindNext(0, 0); } Sys_FindClose(); }
/* * ================== SV_Map_f * * Goes directly to a given map without any savegame archiving. For development * work ================== */ void SV_Map_f(void) { char *map; char expanded[MAX_QPATH]; /* * if not a pcx, demo, or cinematic, check to make sure the level * exists */ map = Cmd_Argv(1); if (!strstr(map, ".")) { Com_sprintf(expanded, sizeof(expanded), "maps/%s.bsp", map); if (FS_LoadFile(expanded, NULL) == -1) { Com_Printf("Can't find %s\n", expanded); return; } } sv.state = ss_dead; /* don't save current level when changing */ SV_WipeSavegame("current"); SV_GameMap_f(); }
/* ================== SV_GameMap_f Saves the state of the map just being exited and goes to a new map. If the initial character of the map string is '*', the next map is in a new unit, so the current savegame directory is cleared of map files. Example: *inter.cin+jail Clears the archived maps, plays the inter.cin cinematic, then goes to map jail.bsp. ================== */ static void SV_GameMap_f (void) { char *map, expanded[MAX_QPATH], tMap[MAX_QPATH]; int i; client_t *cl; //qboolean *savedInuse; if (Cmd_Argc() != 2) { Com_Printf ("USAGE: gamemap <map>\n"); return; } Q_strncpyz(tMap, Cmd_Argv(1), sizeof(tMap)); map = tMap; Com_DPrintf("SV_GameMap(%s)\n", map); FS_CreatePath (va("%s/save/current/", FS_Gamedir())); // check for clearing the current savegame if (map[0] == '*') { // wipe all the *.sav files SV_WipeSavegame("current"); } else { // save the map just exited if (!strchr(map, '.') && !strchr(map, '$')) { Com_sprintf (expanded, sizeof(expanded), "maps/%s.bsp", map); if (FS_LoadFile (expanded, NULL) == -1) { Com_Printf ("Can't find %s\n", expanded); return; } } if (sv.state == ss_game) { qboolean savedInuse[MAX_CLIENTS]; // clear all the client inuse flags before saving so that // when the level is re-entered, the clients will spawn // at spawn points instead of occupying body shells //savedInuse = malloc(maxclients->integer * sizeof(qboolean)); for (i=0,cl=svs.clients ; i<maxclients->integer; i++,cl++) { savedInuse[i] = cl->edict->inuse; cl->edict->inuse = false; } SV_WriteLevelFile (); // we must restore these for clients to transfer over correctly for (i=0,cl=svs.clients ; i<maxclients->integer; i++,cl++) cl->edict->inuse = savedInuse[i]; //free (savedInuse); } } // start up the next map SV_Map (false, map, false ); // archive server state Q_strncpyz (svs.mapcmd, map, sizeof(svs.mapcmd)); // copy off the level to the autosave slot if (!dedicated->integer && !Cvar_VariableIntValue("deathmatch")) { SV_WriteServerFile(true); SV_CopySaveGame("current", "save0"); } }
/* ================== SV_GameMap_f Saves the state of the map just being exited and goes to a new map. If the initial character of the map string is '*', the next map is in a new unit, so the current savegame directory is cleared of map files. Example: *inter.cin+jail Clears the archived maps, plays the inter.cin cinematic, then goes to map jail.bsp. ================== */ void SV_GameMap_f (void) { char *map; int32_t i, l; client_t *cl; qboolean *savedInuse; if (Cmd_Argc() != 2) { Com_Printf ("USAGE: gamemap <map>\n"); return; } Com_DPrintf("SV_GameMap(%s)\n", Cmd_Argv(1)); FS_CreatePath (va("%s/save/current/", FS_Gamedir())); // check for clearing the current savegame map = Cmd_Argv(1); if (map[0] == '*') { // wipe all the *.sav files SV_WipeSavegame ("current"); } else { // save the map just exited if (sv.state == ss_game) { // clear all the client inuse flags before saving so that // when the level is re-entered, the clients will spawn // at spawn points instead of occupying body shells savedInuse = (qboolean*)Z_TagMalloc(maxclients->value * sizeof(qboolean), TAG_SERVER); for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++) { savedInuse[i] = cl->edict->inuse; cl->edict->inuse = false; } SV_WriteLevelFile (); // we must restore these for clients to transfer over correctly for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++) cl->edict->inuse = savedInuse[i]; Z_Free (savedInuse); } } // start up the next map SV_Map (false, Cmd_Argv(1), false ); // archive server state strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1); // copy off the level to the autosave slot // Knightmare- don't do this in deathmatch or for cinematics l = strlen(map); //l = strcspn(map, "+"); if (!dedicated->value && !Cvar_VariableValue("deathmatch") && Q_strcasecmp (map+l-4, ".cin") && Q_strcasecmp (map+l-4, ".roq") && Q_strcasecmp (map+l-4, ".pcx")) { SV_WriteServerFile (true); SV_CopySaveGame ("current", "vrsave00"); } }