예제 #1
0
/*
 * =================
 * UI_PushMenu
 * =================
 */
void UI_PushMenu(void (*draw)(void), const char *(*key)(int k))
{
    int i;

    if ((Cvar_VariableValue("maxclients") == 1) && Com_ServerState() && !cls.consoleActive)     // Knightmare added
    {
        Cvar_Set("paused", "1");
    }

    // Knightmare- if just opened menu, and ingame and not DM, grab screen first
    if ((cls.key_dest != key_menu) && !Cvar_VariableValue("deathmatch") &&
        (Com_ServerState() == 2))          //ss_game
    {           //&& !cl.cinematictime && Com_ServerState())
        R_GrabScreen();
    }

    // if this menu is already present, drop back to that level
    // to avoid stacking menus by hotkeys
    for (i = 0; i < m_menudepth; i++)
    {
        if ((m_layers[i].draw == draw) &&
            (m_layers[i].key == key))
        {
            m_menudepth = i;
        }
    }

    if (i == m_menudepth)
    {
        if (m_menudepth >= MAX_MENU_DEPTH)
        {
            Com_Error(ERR_FATAL, "UI_PushMenu: MAX_MENU_DEPTH");
        }
        m_layers[m_menudepth].draw = m_drawfunc;
        m_layers[m_menudepth].key  = m_keyfunc;
        m_menudepth++;
    }

    m_drawfunc = draw;
    m_keyfunc  = key;

    m_entersound = true;

    // Knightmare- added Psychospaz's mouse support
    UI_RefreshCursorLink();
    UI_RefreshCursorButtons();

    cls.key_dest = key_menu;
}
예제 #2
0
void SV_Savegame_f (void)
{
	char	*dir;

	if (sv.state != ss_game)
	{
		Com_Printf ("You must be in a game to save.\n");
		return;
	}

	// Knightmare- fs_gamedir may be getting messed up, causing it to occasinally save in the root dir,
	// thus leading to a hang on game loads, so we reset it here.
	if (!fs_gamedir[0])
	{
		if (fs_gamedirvar->string[0])
			Com_sprintf (fs_gamedir, sizeof(fs_gamedir), "%s/%s", fs_basedir->string, fs_gamedirvar->string);
	}

	if (Cmd_Argc() != 2)
	{
		Com_Printf ("USAGE: savegame <directory>\n");
		return;
	}

	if (Cvar_VariableValue("deathmatch"))
	{
		Com_Printf ("Can't savegame in a deathmatch\n");
		return;
	}

	if (!strcmp (Cmd_Argv(1), "current"))
	{
		Com_Printf ("Can't save to 'current'\n");
		return;
	}

	// Knightmare- grab screen for quicksave
	if ( !dedicated->value && (!strcmp(Cmd_Argv(1), "quick") || !strcmp(Cmd_Argv(1), "quik")) )
		R_GrabScreen();

	if (maxclients->value == 1 && svs.clients[0].edict->client->ps.stats[STAT_HEALTH] <= 0)
	{
		Com_Printf ("\nCan't savegame while dead!\n");
		return;
	}

	dir = Cmd_Argv(1);
	if (strstr (dir, "..") || strstr (dir, "/") || strstr (dir, "\\") )
	{
		Com_Printf ("Bad savedir.\n");
	}

	Com_Printf (S_COLOR_CYAN"Saving game \"%s\"...\n", dir);

	// archive current level, including all client edicts.
	// when the level is reloaded, they will be shells awaiting
	// a connecting client
	SV_WriteLevelFile ();

	// save server state
	SV_WriteServerFile (false);

	// take screenshot
	SV_WriteScreenshot ();

	// copy it off
	SV_CopySaveGame ("current", dir);

	Com_Printf (S_COLOR_CYAN"Done.\n");
}