From 44b19a9101514c2f7c60db341fc08bc677278901 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 3 Mar 2021 23:51:24 +0100 Subject: [PATCH] Print an error message if gametype and gotomap are executed when the server isn't running, rather than showing nonsense output (gametype in particular) --- qcsrc/server/command/sv_cmd.qc | 10 ++++++++++ qcsrc/server/world.qc | 1 - qcsrc/server/world.qh | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 200aafe2c..9cb909d54 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -715,6 +715,11 @@ void GameCommand_gametype(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_INFOF("This command works only when the server is running."); + return; + } if (argv(1) != "") { string s = argv(1); @@ -888,6 +893,11 @@ void GameCommand_gotomap(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_INFOF("This command works only when the server is running."); + return; + } if (argv(1)) { LOG_INFO(GotoMap(argv(1))); diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 864ac5dab..b61f75ceb 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -100,7 +100,6 @@ void PingPLReport_Spawn() } const float SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS = 1; -float world_initialized; void SetDefaultAlpha() { diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index 4141c99e2..e79a6f9df 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -35,6 +35,8 @@ float checkrules_overtimesadded; //how many overtimes have been already added // flag set on worldspawn so that the code knows if it is dedicated or not bool server_is_dedicated; +int world_initialized; + string cvar_changes; string cvar_purechanges; float cvar_purechanges_count; -- 2.39.2