X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fsv_cmd.qc;h=8cd6125ab12cf38afa5ad4b4edb96081bb7c7521;hb=0a56f137a2821149693e7acafc28ff4e67b3fd60;hp=799c3426f61f9c6ac32e9f91170230b61491f650;hpb=15585913a7e3eb6bd1ec6fce51c8dca0f61ce672;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 799c3426f..8cd6125ab 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -90,6 +90,11 @@ void GameCommand_adminmsg(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } entity client; float accepted; @@ -142,7 +147,7 @@ void GameCommand_adminmsg(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd adminmsg \"\" []"); @@ -162,6 +167,11 @@ void GameCommand_allready(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } if(warmup_stage) { ReadyRestart(true); @@ -188,6 +198,11 @@ void GameCommand_allspec(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } string reason = argv(1); int n = 0; FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { @@ -216,6 +231,11 @@ void GameCommand_anticheat(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } entity client = GetIndexedEntity(argc, 1); float accepted = VerifyClientEntity(client, false, false); @@ -231,7 +251,7 @@ void GameCommand_anticheat(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd anticheat "); @@ -320,6 +340,11 @@ void GameCommand_bot_cmd(int request, int argc, string command) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } entity bot; if (argv(1) == "reset") @@ -433,14 +458,14 @@ void GameCommand_bot_cmd(int request, int argc, string command) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd bot_cmd []"); LOG_HELP(" can be either the name of the bot or a progressive number (not the entity number!)"); LOG_HELP(" can also be '*' or 'all' to allow sending the command to all the bots"); LOG_HELP(" For full list of commands, see bot_cmd help []."); - LOG_HELP("Examples: sv_cmd bot_cmd 1 cc \"say something\""); + LOG_HELP("Examples: sv_cmd bot_cmd 1 cc say something"); LOG_HELP(" sv_cmd bot_cmd 1 presskey jump"); LOG_HELP(" sv_cmd bot_cmd * pause"); return; @@ -454,6 +479,11 @@ void GameCommand_cointoss(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } string result1 = (argv(2) ? strcat("^7", argv(1)) : "^1HEADS"); string result2 = (argv(2) ? strcat("^7", argv(2)) : "^4TAILS"); string choice = ((random() > 0.5) ? result1 : result2); @@ -503,7 +533,7 @@ void GameCommand_database(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd database "); @@ -521,6 +551,11 @@ void GameCommand_defer_clear(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } entity client; float accepted; @@ -541,7 +576,7 @@ void GameCommand_defer_clear(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd defer_clear "); @@ -558,6 +593,11 @@ void GameCommand_defer_clear_all(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } int n = 0; int argc; @@ -596,7 +636,7 @@ void GameCommand_delrec(int request, int argc) // perhaps merge later with reco } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd delrec []"); @@ -700,6 +740,11 @@ void GameCommand_extendmatchtime(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } changematchtime(autocvar_timelimit_increment * 60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60); return; } @@ -723,43 +768,25 @@ void GameCommand_gametype(int request, int argc) { if (!world_initialized) { - LOG_INFOF("This command works only when the server is running."); + LOG_HELPF("This command works only when the server is running."); return; } if (argv(1) != "") { string s = argv(1); - Gametype t = MapInfo_Type_FromString(s, false, false), tsave = MapInfo_CurrentGametype(); + Gametype t = MapInfo_Type_FromString(s, false, false); if (t) - { - MapInfo_SwitchGameType(t); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); - if (MapInfo_count > 0) - { - // update lsmaps in case the gametype changed, this way people can easily list maps for it - if (lsmaps_reply != "") strunzone(lsmaps_reply); - lsmaps_reply = strzone(getlsmaps()); - bprint("Game type successfully switched to ", s, "\n"); - } - else - { - bprint("Cannot use this game type: no map for it found\n"); - MapInfo_SwitchGameType(tsave); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); - } - } + GameTypeVote_SetGametype(t); else - { bprint("Failed to switch to ", s, ": this game type does not exist!\n"); - } return; } } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd gametype "); @@ -824,7 +851,7 @@ void GameCommand_gettaginfo(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd gettaginfo [] []"); @@ -883,7 +910,7 @@ void GameCommand_animbench(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd animbench "); @@ -901,7 +928,7 @@ void GameCommand_gotomap(int request, int argc) { if (!world_initialized) { - LOG_INFOF("This command works only when the server is running."); + LOG_HELPF("This command works only when the server is running."); return; } if (argv(1)) @@ -912,7 +939,7 @@ void GameCommand_gotomap(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd gotomap "); @@ -929,6 +956,11 @@ void GameCommand_lockteams(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } if (teamplay) { lockteams = 1; @@ -984,6 +1016,11 @@ void GameCommand_moveplayer(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } float accepted; entity client; @@ -1014,7 +1051,7 @@ void GameCommand_moveplayer(int request, int argc) else if (destination == "spectator") { string pl_name = playername(client.netname, client.team, false); - if (!IS_SPEC(client) && !IS_OBSERVER(client)) + if (!(IS_SPEC(client) || IS_OBSERVER(client)) || INGAME(client)) { PutObserverInServer(client, true, true); @@ -1109,7 +1146,7 @@ void GameCommand_moveplayer(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd moveplayer "); @@ -1130,6 +1167,11 @@ void GameCommand_nospectators(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } blockSpectators = 1; // give every spectator seconds time to become a player FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !INGAME(it), { @@ -1156,6 +1198,11 @@ void GameCommand_printstats(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } DumpStats(false); LOG_INFO("stats dumped."); return; @@ -1181,7 +1228,7 @@ void GameCommand_radarmap(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]"); @@ -1199,6 +1246,11 @@ void GameCommand_reducematchtime(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } changematchtime(autocvar_timelimit_decrement * -60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60); return; } @@ -1231,7 +1283,7 @@ void GameCommand_setbots(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd setbots "); @@ -1290,6 +1342,11 @@ void GameCommand_shuffleteams(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } if (shuffleteams_on_reset_map) { bprint("Players will be shuffled when this round is over.\n"); @@ -1317,6 +1374,11 @@ void GameCommand_resetmatch(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } ReadyRestart(false); return; } @@ -1342,6 +1404,11 @@ void GameCommand_stuffto(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } if (argv(2)) { entity client = GetIndexedEntity(argc, 1); @@ -1362,7 +1429,7 @@ void GameCommand_stuffto(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd stuffto \"\""); @@ -1543,7 +1610,7 @@ void GameCommand_trace(int request, int argc) } default: - LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + LOG_HELPF("Incorrect parameters for ^2%s^7", argv(0)); case CMD_REQUEST_USAGE: { LOG_HELP("Usage:^3 sv_cmd trace [ ] []"); @@ -1562,6 +1629,11 @@ void GameCommand_unlockteams(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } if (teamplay) { lockteams = 0; @@ -1591,6 +1663,11 @@ void GameCommand_warp(int request, int argc) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } if (autocvar_g_campaign) { if (argc >= 2) @@ -1630,6 +1707,11 @@ void GameCommand_(int request) { case CMD_REQUEST_COMMAND: { + if (!world_initialized) + { + LOG_HELPF("This command works only when the server is running."); + return; + } return; }