mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-20 16:31:19 +00:00
Fix changing the game / mod through the 'game' console command.
The 'game' command was more or less functional after the last commit. We just need to reset the initialGame (renamed to userGivenGame) so we don't revert back to the old game at server disconnect.
This commit is contained in:
parent
f0e21e2ab4
commit
2db01319a1
4 changed files with 18 additions and 12 deletions
|
@ -364,8 +364,7 @@ CL_Disconnect(void)
|
|||
CL_WriteConfiguration();
|
||||
|
||||
// we disconnected, so revert to default game/mod (might have been different mod on MP server)
|
||||
const char* game = Qcommon_GetInitialGame();
|
||||
Cvar_Set("game", (char*)game);
|
||||
Cvar_Set("game", userGivenGame);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -452,6 +452,14 @@ Cvar_Command(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Another evil hack: The user has just changed 'game' trough
|
||||
the console. We reset userGivenGame to that value, otherwise
|
||||
we would revert to the initialy given game at disconnect. */
|
||||
if (strcmp(v->name, "game") == 0)
|
||||
{
|
||||
Q_strlcpy(userGivenGame, Cmd_Argv(1), sizeof(userGivenGame));
|
||||
}
|
||||
|
||||
Cvar_Set(v->name, Cmd_Argv(1));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ void SCR_EndLoadingPlaque(void);
|
|||
// Is the game portable?
|
||||
qboolean is_portable;
|
||||
|
||||
// Game given by user
|
||||
char userGivenGame[MAX_QPATH];
|
||||
|
||||
// ----
|
||||
|
||||
static void
|
||||
|
@ -192,13 +195,6 @@ void Qcommon_ExecConfigs(qboolean gameStartUp)
|
|||
Cbuf_Execute();
|
||||
}
|
||||
|
||||
static char initialGame[MAX_QPATH];
|
||||
|
||||
const char* Qcommon_GetInitialGame(void)
|
||||
{
|
||||
return initialGame;
|
||||
}
|
||||
|
||||
void
|
||||
Qcommon_Init(int argc, char **argv)
|
||||
{
|
||||
|
@ -239,11 +235,13 @@ Qcommon_Init(int argc, char **argv)
|
|||
{
|
||||
cvar_t* gameCvar = Cvar_Get("game", "", CVAR_LATCH | CVAR_SERVERINFO);
|
||||
const char* game = "";
|
||||
|
||||
if(gameCvar->string && gameCvar->string[0])
|
||||
{
|
||||
game = gameCvar->string;
|
||||
}
|
||||
Q_strlcpy(initialGame, game, sizeof(initialGame));
|
||||
|
||||
Q_strlcpy(userGivenGame, game, sizeof(userGivenGame));
|
||||
}
|
||||
|
||||
// The filesystems needs to be initialized after the cvars.
|
||||
|
@ -262,8 +260,6 @@ Qcommon_Init(int argc, char **argv)
|
|||
developer = Cvar_Get("developer", "0", 0);
|
||||
fixedtime = Cvar_Get("fixedtime", "0", 0);
|
||||
|
||||
|
||||
|
||||
logfile_active = Cvar_Get("logfile", "1", CVAR_ARCHIVE);
|
||||
modder = Cvar_Get("modder", "0", 0);
|
||||
timescale = Cvar_Get("timescale", "1", 0);
|
||||
|
|
|
@ -735,6 +735,9 @@ extern qboolean is_portable;
|
|||
/* Hack fo external datadir */
|
||||
extern char datadir[MAX_OSPATH];
|
||||
|
||||
/* Hack for working 'game' cmd */
|
||||
extern char userGivenGame[MAX_QPATH];
|
||||
|
||||
extern FILE *log_stats_file;
|
||||
|
||||
/* host_speeds times */
|
||||
|
|
Loading…
Reference in a new issue