From: Samual Date: Wed, 14 Dec 2011 14:31:30 +0000 (-0500) Subject: Now sv_cmd.qc uses common commands too -- plus some extra fixes. X-Git-Tag: xonotic-v0.6.0~188^2~28^2~145 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=84720276c44cf003a56c00cb0da8f91c2bd6f09f;p=xonotic%2Fxonotic-data.pk3dir.git Now sv_cmd.qc uses common commands too -- plus some extra fixes. --- diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 9aaca5b92..c6c7101ce 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -550,7 +550,7 @@ void ClientCommand_(float request) CLIENT_COMMAND("ladder", CommonCommand_ladder(request), "Get information about top players if supported") \ CLIENT_COMMAND("lsmaps", CommonCommand_lsmaps(request), "List maps which can be used with the current game mode") \ CLIENT_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request), "List maps which TODO") \ - CLIENT_COMMAND("maplist", CommonCommand_maplist(request), "Full server maplist reply") \ + CLIENT_COMMAND("maplist", CommonCommand_maplist(request), "Display full server maplist reply") \ CLIENT_COMMAND("rankings", CommonCommand_rankings(request), "Print information about rankings") \ CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \ CLIENT_COMMAND("records", CommonCommand_records(request), "List top 10 records for the current map") \ @@ -562,7 +562,7 @@ void ClientCommand_(float request) CLIENT_COMMAND("sentcvar", ClientCommand_sentcvar(request, arguments, command), "New system for sending a client cvar to the server") \ CLIENT_COMMAND("spectate", ClientCommand_spectate(request), "Become an observer") \ CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(request, arguments), "Suggest a map to the mapvote at match end") \ - CLIENT_COMMAND("teamstatus", CommonCommand_teamstatus(request), "Print detailed score information for all players") \ + CLIENT_COMMAND("teamstatus", CommonCommand_teamstatus(request), "Show information about player and team scores") \ CLIENT_COMMAND("tell", ClientCommand_tell(request, arguments, command), "Send a message directly to a player") \ CLIENT_COMMAND("timein", CommonCommand_timein(request), "Resume the game from being paused with a timeout") \ CLIENT_COMMAND("timeout", CommonCommand_timeout(request), "Call a timeout which pauses the game for certain amount of time unless unpaused") \ diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 67538cc94..1b7b34ead 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -49,16 +49,16 @@ void CommonCommand_cvar_changes(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, cvar_changes); + print_to(self, cvar_changes); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 sv_cmd cvar_changes\n"); - sprint(self, " No arguments required.\n"); - //sprint(self, "See also: ^2cvar_purechanges^7\n"); + print_to(self, "\nUsage:^3 sv_cmd cvar_changes\n"); + print_to(self, " No arguments required.\n"); + //print_to(self, "See also: ^2cvar_purechanges^7\n"); return; } } @@ -70,16 +70,16 @@ void CommonCommand_cvar_purechanges(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, cvar_purechanges); + print_to(self, cvar_purechanges); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 sv_cmd cvar_purechanges\n"); - sprint(self, " No arguments required.\n"); - //sprint(self, "See also: ^2cvar_changes^7\n"); + print_to(self, "\nUsage:^3 sv_cmd cvar_purechanges\n"); + print_to(self, " No arguments required.\n"); + //print_to(self, "See also: ^2cvar_changes^7\n"); return; } } @@ -97,7 +97,7 @@ void CommonCommand_info(float request, float argc) if(command) wordwrap_sprint(command, 1111); // why 1111? else - sprint(self, "ERROR: unsupported info command\n"); + print_to(self, "ERROR: unsupported info command\n"); return; // never fall through to usage } @@ -105,8 +105,8 @@ void CommonCommand_info(float request, float argc) default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd info request\n"); - sprint(self, " Where 'request' is the suffixed string appended onto the request for cvar.\n"); + print_to(self, "\nUsage:^3 cmd info request\n"); + print_to(self, " Where 'request' is the suffixed string appended onto the request for cvar.\n"); return; } } @@ -118,15 +118,15 @@ void CommonCommand_ladder(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, ladder_reply); + print_to(self, ladder_reply); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd ladder\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd ladder\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -138,15 +138,15 @@ void CommonCommand_lsmaps(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, lsmaps_reply); + print_to(self, lsmaps_reply); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd lsmaps\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd lsmaps\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -158,15 +158,15 @@ void CommonCommand_lsnewmaps(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, lsnewmaps_reply); + print_to(self, lsnewmaps_reply); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd lsnewmaps\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd lsnewmaps\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -178,15 +178,37 @@ void CommonCommand_maplist(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, maplist_reply); + print_to(self, maplist_reply); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd maplist\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd maplist\n"); + print_to(self, " No arguments required.\n"); + return; + } + } +} + +void GameCommand_rankings(float request) // this is OLD.... jeez. +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + strunzone(rankings_reply); + rankings_reply = strzone(getrankings()); + print(rankings_reply); + return; + } + + default: + case CMD_REQUEST_USAGE: + { + print("\nUsage:^3 sv_cmd rankings\n"); + print(" No arguments required.\n"); return; } } @@ -198,15 +220,15 @@ void CommonCommand_rankings(float request) { case CMD_REQUEST_COMMAND: { - sprint(self, rankings_reply); + print_to(self, rankings_reply); return; // never fall through to usage } default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd rankings\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd rankings\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -221,7 +243,7 @@ void CommonCommand_records(float request) // TODO: Isn't this flooding with the float i; for(i = 0; i < 10; ++i) - sprint(self, records_reply[i]); + print_to(self, records_reply[i]); return; // never fall through to usage } @@ -229,8 +251,8 @@ void CommonCommand_records(float request) // TODO: Isn't this flooding with the default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd records\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd records\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -249,8 +271,8 @@ void CommonCommand_teamstatus(float request) default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd teamstatus\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd teamstatus\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -268,9 +290,9 @@ void CommonCommand_timein(float request) if(autocvar_sv_timeout) { if (!timeoutStatus) - return sprint(self, "^7Error: There is no active timeout which could be aborted!\n"); + return print_to(self, "^7Error: There is no active timeout which could be aborted!\n"); if (self != timeoutInitiator) - return sprint(self, "^7Error: You may not abort the active timeout. Only the player who called it can do that!\n"); + return print_to(self, "^7Error: You may not abort the active timeout. Only the player who called it can do that!\n"); if (timeoutStatus == 1) { @@ -288,7 +310,7 @@ void CommonCommand_timein(float request) timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately } else - sprint(self, "^7Error: Your resumegame call was discarded!\n"); + print_to(self, "^7Error: Your resumegame call was discarded!\n"); } } } @@ -298,8 +320,8 @@ void CommonCommand_timein(float request) default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd timein\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd timein\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -318,13 +340,13 @@ void CommonCommand_timeout(float request) // DEAR GOD THIS COMMAND IS TERRIBLE. if(self.classname == "player") { if(votecalled) - sprint(self, "^7Error: you can not call a timeout while a vote is active!\n"); + print_to(self, "^7Error: you can not call a timeout while a vote is active!\n"); else { if (inWarmupStage && !g_warmup_allow_timeout) - return sprint(self, "^7Error: You can not call a timeout in warmup-stage!\n"); + return print_to(self, "^7Error: You can not call a timeout in warmup-stage!\n"); if (time < game_starttime ) - return sprint(self, "^7Error: You can not call a timeout while the map is being restarted!\n"); + return print_to(self, "^7Error: You can not call a timeout while the map is being restarted!\n"); if (timeoutStatus != 2) { //if the map uses a timelimit make sure that timeout cannot be called right before the map ends @@ -337,13 +359,13 @@ void CommonCommand_timeout(float request) // DEAR GOD THIS COMMAND IS TERRIBLE. lastPossibleTimeout = (myTl*60) - autocvar_sv_timeout_leadtime - 1; if (lastPossibleTimeout < time - game_starttime) - return sprint(self, "^7Error: It is too late to call a timeout now!\n"); + return print_to(self, "^7Error: It is too late to call a timeout now!\n"); } } //player may not call a timeout if he has no calls left if (self.allowedTimeouts < 1) - return sprint(self, "^7Error: You already used all your timeout calls for this map!\n"); + return print_to(self, "^7Error: You already used all your timeout calls for this map!\n"); //now all required checks are passed @@ -365,7 +387,7 @@ void CommonCommand_timeout(float request) // DEAR GOD THIS COMMAND IS TERRIBLE. } } else - sprint(self, "^7Error: only players can call a timeout!\n"); + print_to(self, "^7Error: only players can call a timeout!\n"); } } return; // never fall through to usage @@ -374,8 +396,8 @@ void CommonCommand_timeout(float request) // DEAR GOD THIS COMMAND IS TERRIBLE. default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd timeout\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd timeout\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -391,8 +413,8 @@ void CommonCommand_who(float request) entity tmp_player; //string tmp_player_name; - sprint(self, strcat("List of client information", (autocvar_sv_status_privacy ? " (some data is hidden for privacy)" : string_null), ":\n")); - sprint(self, sprintf(" %-4s %-20s %-5s %-3s %-9s %-16s %s\n", "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id")); + print_to(self, strcat("List of client information", (autocvar_sv_status_privacy ? " (some data is hidden for privacy)" : string_null), ":\n")); + print_to(self, sprintf(" %-4s %-20s %-5s %-3s %-9s %-16s %s\n", "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id")); FOR_EACH_CLIENT(tmp_player) { @@ -411,7 +433,7 @@ void CommonCommand_who(float request) if(tmp_hours) { tmp_minutes -= (tmp_hours * 60); } } - sprint(self, sprintf(" %-4s %-20s %-5d %-3d %-9s %-16s %s\n", + print_to(self, sprintf(" %-4s %-20s %-5d %-3d %-9s %-16s %s\n", strcat("#", ftos(num_for_edict(tmp_player))), tmp_player.netname, //strcat(tmp_player_name, sprintf("%*s", (20 - strlen(strdecolorize(tmp_player_name))), "")), tmp_player.ping, tmp_player.ping_packetloss, @@ -422,7 +444,7 @@ void CommonCommand_who(float request) ++total_listed_players; } - sprint(self, strcat("Finished listing ", ftos(total_listed_players), " client(s). \n")); + print_to(self, strcat("Finished listing ", ftos(total_listed_players), " client(s). \n")); return; // never fall through to usage } @@ -430,8 +452,8 @@ void CommonCommand_who(float request) default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd who\n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd who\n"); + print_to(self, " No arguments required.\n"); return; } } @@ -451,8 +473,8 @@ void CommonCommand_(float request) default: case CMD_REQUEST_USAGE: { - sprint(self, "\nUsage:^3 cmd \n"); - sprint(self, " No arguments required.\n"); + print_to(self, "\nUsage:^3 cmd \n"); + print_to(self, " No arguments required.\n"); return; } } diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 9a99fd196..6cb8b228b 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -465,48 +465,6 @@ void GameCommand_cointoss(float request, float argc) } } -void GameCommand_cvar_changes(float request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - print(cvar_changes); - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd cvar_changes\n"); - print(" No arguments required.\n"); - print("See also: ^2cvar_purechanges^7\n"); - return; - } - } -} - -void GameCommand_cvar_purechanges(float request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - print(cvar_purechanges); - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd cvar_purechanges\n"); - print(" No arguments required.\n"); - print("See also: ^2cvar_changes^7\n"); - return; - } - } -} - void GameCommand_database(float request, float argc) { switch(request) @@ -902,26 +860,6 @@ void GameCommand_gotomap(float request, float argc) } } -void GameCommand_ladder(float request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - print(ladder_reply); - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd ladder\n"); - print(" No arguments required.\n"); - return; - } - } -} - void GameCommand_lockteams(float request) { switch(request) @@ -1312,52 +1250,6 @@ void GameCommand_radarmap(float request, float argc) } } -void GameCommand_rankings(float request) // this is OLD.... jeez. -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - strunzone(rankings_reply); - rankings_reply = strzone(getrankings()); - print(rankings_reply); - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd rankings\n"); - print(" No arguments required.\n"); - return; - } - } -} - -void GameCommand_records(float request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - float i; - - for (i = 0; i < 10; ++i) - print(records_reply[i]); - - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd records\n"); - print(" No arguments required.\n"); - return; - } - } -} - void GameCommand_reducematchtime(float request) { switch(request) @@ -1559,26 +1451,6 @@ void GameCommand_stuffto(float request, float argc) #endif } -void GameCommand_teamstatus(float request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - Score_NicePrint(world); - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 sv_cmd teamstatus\n"); - print(" No arguments required.\n"); - return; - } - } -} - void GameCommand_time(float request) { switch(request) @@ -1881,8 +1753,8 @@ void GameCommand_(float request) SERVER_COMMAND("bbox", GameCommand_bbox(request), "Print detailed information about world size") \ SERVER_COMMAND("bot_cmd", GameCommand_bot_cmd(request, arguments), "Control and send commands to bots") \ SERVER_COMMAND("cointoss", GameCommand_cointoss(request, arguments), "Flip a virtual coin and give random result") \ - SERVER_COMMAND("cvar_changes", GameCommand_cvar_changes(request), "Prints a list of all changed server cvars") \ - SERVER_COMMAND("cvar_purechanges", GameCommand_cvar_purechanges(request), "Prints a list of all changed gameplay cvars") \ + SERVER_COMMAND("cvar_changes", CommonCommand_cvar_changes(request), "Prints a list of all changed server cvars") \ + SERVER_COMMAND("cvar_purechanges", CommonCommand_cvar_purechanges(request), "Prints a list of all changed gameplay cvars") \ SERVER_COMMAND("database", GameCommand_database(request, arguments), "Extra controls of the serverprogs database") \ SERVER_COMMAND("defer_clear", GameCommand_defer_clear(request, arguments), "Clear all queued defer commands for a specific client") \ SERVER_COMMAND("defer_clear_all", GameCommand_defer_clear_all(request), "Clear all queued defer commands for all clients") \ @@ -1893,9 +1765,13 @@ void GameCommand_(float request) SERVER_COMMAND("gametype", GameCommand_gametype(request, arguments), "Simple command to change the active gametype") \ SERVER_COMMAND("gettaginfo", GameCommand_gettaginfo(request, arguments), "Get specific information about a weapon model") \ SERVER_COMMAND("gotomap", GameCommand_gotomap(request, arguments), "Simple command to switch to another map") \ - SERVER_COMMAND("ladder", GameCommand_ladder(request), "Get information about top players if supported") \ + SERVER_COMMAND("info", CommonCommand_info(request, arguments), "todo") \ + SERVER_COMMAND("ladder", CommonCommand_ladder(request), "Get information about top players if supported") \ SERVER_COMMAND("lockteams", GameCommand_lockteams(request), "Disable the ability for players to switch or enter teams") \ + SERVER_COMMAND("lsmaps", CommonCommand_lsmaps(request), "List maps which can be used with the current game mode") \ + SERVER_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request), "todo") \ SERVER_COMMAND("make_mapinfo", GameCommand_make_mapinfo(request), "Automatically rebuild mapinfo files") \ + SERVER_COMMAND("maplist", CommonCommand_maplist(request), "Display full server maplist reply") \ SERVER_COMMAND("modelbug", GameCommand_modelbug(request), "TODO foobar") \ SERVER_COMMAND("moveplayer", GameCommand_moveplayer(request, arguments), "Change the team/status of a player") \ SERVER_COMMAND("nospectators", GameCommand_nospectators(request), "Automatically remove spectators from a match") \ @@ -1903,18 +1779,21 @@ void GameCommand_(float request) SERVER_COMMAND("playerdemo", GameCommand_playerdemo(request, arguments), "Control the ability to save demos of players") \ SERVER_COMMAND("printstats", GameCommand_printstats(request), "TODO foobar") \ SERVER_COMMAND("radarmap", GameCommand_radarmap(request, arguments), "Generate a radar image of the map") \ - SERVER_COMMAND("rankings", GameCommand_rankings(request), "Print information about rankings") \ - SERVER_COMMAND("records", GameCommand_records(request), "List top 10 records for the current map") \ + SERVER_COMMAND("rankings", CommonCommand_rankings(request), "Print information about rankings") \ + SERVER_COMMAND("records", CommonCommand_records(request), "List top 10 records for the current map") \ SERVER_COMMAND("reducematchtime", GameCommand_reducematchtime(request), "Decrease the timelimit value incrementally") \ SERVER_COMMAND("setbots", GameCommand_setbots(request, arguments), "Adjust how many bots are in the match") \ SERVER_COMMAND("shuffleteams", GameCommand_shuffleteams(request), "Randomly move players to different teams") \ SERVER_COMMAND("stuffto", GameCommand_stuffto(request, arguments), "Send a command to be executed on a client") \ - SERVER_COMMAND("teamstatus", GameCommand_teamstatus(request), "Show information about player and team scores") \ + SERVER_COMMAND("teamstatus", CommonCommand_teamstatus(request), "Show information about player and team scores") \ SERVER_COMMAND("time", GameCommand_time(request), "Print different formats/readouts of time") \ + SERVER_COMMAND("timein", CommonCommand_timein(request), "Resume the game from being paused with a timeout") \ + SERVER_COMMAND("timeout", CommonCommand_timeout(request), "Call a timeout which pauses the game for certain amount of time unless unpaused") \ SERVER_COMMAND("trace", GameCommand_trace(request, arguments), "Various debugging tools with tracing") \ SERVER_COMMAND("unlockteams", GameCommand_unlockteams(request), "Enable the ability for players to switch or enter teams") \ SERVER_COMMAND("warp", GameCommand_warp(request, arguments), "Choose different level in campaign") \ - SERVER_COMMAND("vote", VoteCommand(request, world, arguments, command), "Server side control of voting") /* handled in server/vote.qc */ \ + SERVER_COMMAND("who", CommonCommand_who(request), "Display detailed client information about all players") \ + SERVER_COMMAND("vote", VoteCommand(request, world, arguments, command), "Server side control of voting") \ /* nothing */ void GameCommand_macro_help()