Skip to content

Commit

Permalink
All Games: "endgame" supports bypassing user confirmation
Browse files Browse the repository at this point in the history
If the "confirm" argument is given then the game will end immediately,
bypassing the usual user confirmation step.
  • Loading branch information
danij-deng committed Apr 12, 2014
1 parent da59e2b commit e592630
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -343,6 +343,7 @@ cvartemplate_t gamestatusCVars[] =
ccmdtemplate_t gameCmds[] = {
{ "deletegamesave", "ss", CCmdDeleteSavedSession, 0 },
{ "deletegamesave", "s", CCmdDeleteSavedSession, 0 },
{ "endgame", "s", CCmdEndSession, 0 },
{ "endgame", "", CCmdEndSession, 0 },
{ "helpscreen", "", CCmdHelpScreen, 0 },
{ "listmaps", "", CCmdListMaps, 0 },
Expand Down Expand Up @@ -2933,14 +2934,7 @@ static int endSessionConfirmed(msgresponse_t response, int /*userValue*/, void *
{
if(response == MSG_YES)
{
if(IS_CLIENT)
{
DD_Executef(false, "net disconnect");
}
else
{
COMMON_GAMESESSION->endAndBeginTitle();
}
DD_Execute(true, "endgame confirm");
}
return true;
}
Expand All @@ -2964,14 +2958,23 @@ D_CMD(EndSession)
return true;
}

if(IS_NETGAME && IS_SERVER)
// Is user confirmation required? (Never if this is a network server).
bool const confirmed = (argc >= 2 && !stricmp(argv[argc-1], "confirm"));
if(confirmed || (IS_NETGAME && IS_SERVER))
{
// Just do it, no questions asked.
COMMON_GAMESESSION->endAndBeginTitle();
return true;
if(IS_NETGAME && IS_CLIENT)
{
DD_Executef(false, "net disconnect");
}
else
{
COMMON_GAMESESSION->endAndBeginTitle();
}
}
else
{
Hu_MsgStart(MSG_YESNO, IS_CLIENT? GET_TXT(TXT_DISCONNECT) : ENDGAME, endSessionConfirmed, 0, NULL);
}

Hu_MsgStart(MSG_YESNO, IS_CLIENT? GET_TXT(TXT_DISCONNECT) : ENDGAME, endSessionConfirmed, 0, NULL);

return true;
}
Expand Down

0 comments on commit e592630

Please sign in to comment.