Ejemplo n.º 1
0
void write_server_file(struct info_file *info_file) {

    if (file_exists("%sinfo/current", CVS_DIR)) {

        struct info_file* cur = read_server_file(-1);
        info_file->version = cur->version + 1;
    }

    char path[MAX_PATH_LENGTH];

    sprintf(path, "%sinfo/%d", CVS_DIR, info_file->version);

    __write_server_file(info_file, path);

    run_bash("rm %s/info/current 2> /dev/null", base_path());
    run_bash("ln %s/info/%d %s/info/current", base_path(), info_file->version, base_path());
}
Ejemplo n.º 2
0
Archivo: save.c Proyecto: jdolan/q2pro
static void SV_Loadgame_f(void)
{
    char *dir;

    if (Cmd_Argc() != 2) {
        Com_Printf("Usage: %s <directory>\n", Cmd_Argv(0));
        return;
    }

    if (dedicated->integer) {
        Com_Printf("Savegames are for listen servers only.\n");
        return;
    }

    dir = Cmd_Argv(1);
    if (!COM_IsPath(dir)) {
        Com_Printf("Bad savedir.\n");
        return;
    }

    // make sure the server files exist
    if (!FS_FileExistsEx(va("save/%s/server.ssv", dir), FS_TYPE_REAL | FS_PATH_GAME) ||
        !FS_FileExistsEx(va("save/%s/game.ssv", dir), FS_TYPE_REAL | FS_PATH_GAME)) {
        Com_Printf ("No such savegame: %s\n", dir);
        return;
    }

    // clear whatever savegames are there
    if (wipe_save_dir(SAVE_CURRENT)) {
        Com_Printf("Couldn't wipe '%s' directory.\n", SAVE_CURRENT);
        return;
    }

    // copy it off
    if (copy_save_dir(dir, SAVE_CURRENT)) {
        Com_Printf("Couldn't read '%s' directory.\n", dir);
        return;
    }

    // read server state
    if (read_server_file()) {
        Com_Printf("Couldn't read server file.\n");
        return;
    }
}