X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fcmd.qc;h=363bb7c4c33bad339e121ae9e8be4456f5b546c8;hb=3b2bc1bdee04f4c454279bf14ac8ed6b37c6ddb5;hp=c357cf689ccd093d762b6cc7d24658550a2eb4f7;hpb=6c3104a65005223002dfb708d4dec7481722c355;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index c357cf689..363bb7c4c 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -5,7 +5,7 @@ float SV_ParseClientCommand_floodcheck() { - if not(timeout_status) // not while paused + if (!timeout_status) // not while paused { if(time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time)) { @@ -39,13 +39,13 @@ void ClientCommand_autoswitch(float request, float argc) return; } } - + default: sprint(self, "Incorrect parameters for ^2autoswitch^7\n"); case CMD_REQUEST_USAGE: { sprint(self, "\nUsage:^3 cmd autoswitch selection\n"); - sprint(self, " Where 'selection' controls if autoswitch is on or off.\n"); + sprint(self, " Where 'selection' controls if autoswitch is on or off.\n"); return; } } @@ -61,7 +61,7 @@ void ClientCommand_checkfail(float request, string command) // internal command, self.checkfail = 1; return; // never fall through to usage } - + default: sprint(self, "Incorrect parameters for ^2checkfail^7\n"); case CMD_REQUEST_USAGE: @@ -81,30 +81,30 @@ void ClientCommand_clientversion(float request, float argc) // internal command, { if(argv(1) != "") { - if(self.flags & FL_CLIENT) + if(IS_CLIENT(self)) { self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1))); - + if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max) { self.version_mismatch = 1; ClientKill_TeamChange(-2); // observe - } - else if(autocvar_g_campaign || autocvar_g_balance_teams) + } + else if(autocvar_g_campaign || autocvar_g_balance_teams) { //JoinBestTeam(self, FALSE, TRUE); - } - else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0)) + } + else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0)) { self.classname = "observer"; // really? stuffcmd(self, "menu_showteamselect\n"); } } - + return; } } - + default: sprint(self, "Incorrect parameters for ^2clientversion^7\n"); case CMD_REQUEST_USAGE: @@ -124,13 +124,13 @@ void ClientCommand_mv_getpicture(float request, float argc) // internal command, { if(argv(1) != "") { - if(intermission_running) + if(intermission_running) MapVote_SendPicture(stof(argv(1))); return; } } - + default: sprint(self, "Incorrect parameters for ^2mv_getpicture^7\n"); case CMD_REQUEST_USAGE: @@ -142,35 +142,36 @@ void ClientCommand_mv_getpicture(float request, float argc) // internal command, } } -void ClientCommand_join(float request) +void ClientCommand_join(float request) { switch(request) { case CMD_REQUEST_COMMAND: { - if(self.flags & FL_CLIENT) + if(IS_CLIENT(self)) { - if(self.classname != "player" && !lockteams && !g_arena) + if(!IS_PLAYER(self) && !lockteams) { - if(nJoinAllowed(self)) + if(nJoinAllowed(self)) { if(autocvar_g_campaign) { campaign_bots_may_start = 1; } self.classname = "player"; PlayerScore_Clear(self); - bprint ("^4", self.netname, "^4 is playing now\n"); + Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname); PutClientInServer(); } - else + else { //player may not join because of g_maxplayers is set - centerprint(self, PREVENT_JOIN_TEXT); + Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_PREVENT); } } } return; // never fall through to usage } - + default: case CMD_REQUEST_USAGE: { @@ -187,13 +188,13 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes { case CMD_REQUEST_COMMAND: { - if(self.flags & FL_CLIENT) + if(IS_CLIENT(self)) { - if(inWarmupStage || autocvar_sv_ready_restart || g_race_qualifying == 2) + if(warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2) { if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable) { - if(time < game_starttime + 1) // game is already restarting + if(time < game_starttime) // game is already restarting return; if (self.ready) // toggle { @@ -207,7 +208,7 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes } // cannot reset the game while a timeout is active! - if not(timeout_status) + if (!timeout_status) ReadyCount(); } else { sprint(self, "^1Game has already been restarted\n"); @@ -216,7 +217,7 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes } return; // never fall through to usage } - + default: case CMD_REQUEST_USAGE: { @@ -236,7 +237,7 @@ void ClientCommand_say(float request, float argc, string command) if(argc >= 2) { Say(self, FALSE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); } return; // never fall through to usage } - + default: case CMD_REQUEST_USAGE: { @@ -256,7 +257,7 @@ void ClientCommand_say_team(float request, float argc, string command) if(argc >= 2) { Say(self, TRUE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); } return; // never fall through to usage } - + default: case CMD_REQUEST_USAGE: { @@ -275,25 +276,25 @@ void ClientCommand_selectteam(float request, float argc) { if(argv(1) != "") { - if(self.flags & FL_CLIENT) + if(IS_CLIENT(self)) { if(teamplay) - if not(self.team_forced > 0) - if not(lockteams) + if(self.team_forced <= 0) + if (!lockteams) { float selection; - + switch(argv(1)) { - case "red": selection = COLOR_TEAM1; break; - case "blue": selection = COLOR_TEAM2; break; - case "yellow": selection = COLOR_TEAM3; break; - case "pink": selection = COLOR_TEAM4; break; + case "red": selection = NUM_TEAM_1; break; + case "blue": selection = NUM_TEAM_2; break; + case "yellow": selection = NUM_TEAM_3; break; + case "pink": selection = NUM_TEAM_4; break; case "auto": selection = (-1); break; - + default: selection = 0; break; } - + if(selection) { if(self.team == selection && self.deadflag == DEAD_NO) @@ -311,7 +312,7 @@ void ClientCommand_selectteam(float request, float argc) else sprint(self, "^7selectteam can only be used in teamgames\n"); } - return; + return; } } @@ -339,7 +340,7 @@ void ClientCommand_selfstuff(float request, string command) return; } } - + default: sprint(self, "Incorrect parameters for ^2selectteam^7\n"); case CMD_REQUEST_USAGE: @@ -361,19 +362,19 @@ void ClientCommand_sentcvar(float request, float argc, string command) { //float tokens; string s; - + if(argc == 2) // undefined cvar: use the default value on the server then { s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\""); tokenize_console(s); } - + GetCvars(1); - + return; } } - + default: sprint(self, "Incorrect parameters for ^2sentcvar^7\n"); case CMD_REQUEST_USAGE: @@ -385,19 +386,20 @@ void ClientCommand_sentcvar(float request, float argc, string command) } } -void ClientCommand_spectate(float request) +void ClientCommand_spectate(float request) { switch(request) { case CMD_REQUEST_COMMAND: { - if(self.flags & FL_CLIENT) + if(IS_CLIENT(self)) { - if(g_arena) { return; } if(g_lms) { if(self.lms_spectate_warning) { + // for the forfeit message... + self.lms_spectate_warning = 2; // mark player as spectator PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0)); } @@ -408,13 +410,13 @@ void ClientCommand_spectate(float request) return; } } - - if(self.classname == "player" && autocvar_sv_spectate == 1) + + if(IS_PLAYER(self) && autocvar_sv_spectate == 1) ClientKill_TeamChange(-2); // observe - + // in CA, allow a dead player to move to spectators (without that, caplayer!=0 will be moved back to the player list) // note: if arena game mode is ever done properly, this needs to be removed. - if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer")) + if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self))) { sprint(self, "WARNING: you will spectate in the next round.\n"); self.caplayer = 0; @@ -422,7 +424,7 @@ void ClientCommand_spectate(float request) } return; // never fall through to usage } - + default: case CMD_REQUEST_USAGE: { @@ -445,7 +447,7 @@ void ClientCommand_suggestmap(float request, float argc) return; } } - + default: sprint(self, "Incorrect parameters for ^2suggestmap^7\n"); case CMD_REQUEST_USAGE: @@ -467,7 +469,7 @@ void ClientCommand_tell(float request, float argc, string command) { entity tell_to = GetIndexedEntity(argc, 1); float tell_accepted = VerifyClientEntity(tell_to, TRUE, FALSE); - + if(tell_accepted > 0) // the target is a real client { if(tell_to != self) // and we're allowed to send to them :D @@ -477,15 +479,15 @@ void ClientCommand_tell(float request, float argc, string command) } else { print_to(self, "You can't ^2tell^7 a message to yourself."); return; } } - else if(argv(1) == "#0") - { + else if(argv(1) == "#0") + { trigger_magicear_processmessage_forallears(self, -1, world, substring(command, argv_start_index(next_token), argv_end_index(-1) - argv_start_index(next_token))); return; } else { print_to(self, strcat("tell: ", GetClientErrorString(tell_accepted, argv(1)), ".")); return; } } } - + default: sprint(self, "Incorrect parameters for ^2tell^7\n"); case CMD_REQUEST_USAGE: @@ -497,7 +499,7 @@ void ClientCommand_tell(float request, float argc, string command) } } -void ClientCommand_voice(float request, float argc, string command) +void ClientCommand_voice(float request, float argc, string command) { switch(request) { @@ -509,11 +511,11 @@ void ClientCommand_voice(float request, float argc, string command) VoiceMessage(argv(1), substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2))); else VoiceMessage(argv(1), ""); - + return; } } - + default: sprint(self, "Incorrect parameters for ^2voice^7\n"); case CMD_REQUEST_USAGE: @@ -534,10 +536,10 @@ void ClientCommand_(float request) { case CMD_REQUEST_COMMAND: { - + return; // never fall through to usage } - + default: case CMD_REQUEST_USAGE: { @@ -572,15 +574,15 @@ void ClientCommand_(float request) CLIENT_COMMAND("tell", ClientCommand_tell(request, arguments, command), "Send a message directly to a player") \ CLIENT_COMMAND("voice", ClientCommand_voice(request, arguments, command), "Send voice message via sound") \ /* nothing */ - + void ClientCommand_macro_help() { #define CLIENT_COMMAND(name,function,description) \ { sprint(self, " ^2", name, "^7: ", description, "\n"); } - + CLIENT_COMMANDS(0, 0, "") #undef CLIENT_COMMAND - + return; } @@ -588,10 +590,10 @@ float ClientCommand_macro_command(float argc, string command) { #define CLIENT_COMMAND(name,function,description) \ { if(name == strtolower(argv(0))) { function; return TRUE; } } - + CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc, command) #undef CLIENT_COMMAND - + return FALSE; } @@ -599,21 +601,21 @@ float ClientCommand_macro_usage(float argc) { #define CLIENT_COMMAND(name,function,description) \ { if(name == strtolower(argv(1))) { function; return TRUE; } } - + CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, "") #undef CLIENT_COMMAND - + return FALSE; } void ClientCommand_macro_write_aliases(float fh) { #define CLIENT_COMMAND(name,function,description) \ - { CMD_Write_Alias("qc_cmd_cmd", name, description); } - + { CMD_Write_Alias("qc_cmd_cmd", name, description); } + CLIENT_COMMANDS(0, 0, "") #undef CLIENT_COMMAND - + return; } @@ -629,17 +631,17 @@ void SV_ParseClientCommand(string command) return; float argc = tokenize_console(command); - + // for the mutator hook system cmd_name = strtolower(argv(0)); cmd_argc = argc; cmd_string = command; - + // Guide for working with argc arguments by example: // argc: 1 - 2 - 3 - 4 - // argv: 0 - 1 - 2 - 3 + // argv: 0 - 1 - 2 - 3 // cmd vote - master - login - password - + // for floodcheck switch(strtolower(argv(0))) { @@ -651,29 +653,29 @@ void SV_ParseClientCommand(string command) case "prespawn": break; // handled by engine in host_cmd.c case "sentcvar": break; // handled by server in this file case "spawn": break; // handled by engine in host_cmd.c - - default: + + default: if(SV_ParseClientCommand_floodcheck()) break; // "TRUE": continue, as we're not flooding yet else return; // "FALSE": not allowed to continue, halt // print("^1ERROR: ^7ANTISPAM CAUGHT: ", command, ".\n"); } - + /* NOTE: should this be disabled? It can be spammy perhaps, but hopefully it's okay for now */ - if(argv(0) == "help") + if(argv(0) == "help") { - if(argc == 1) + if(argc == 1) { sprint(self, "\nClient networked commands:\n"); ClientCommand_macro_help(); - + sprint(self, "\nCommon networked commands:\n"); CommonCommand_macro_help(self); - + sprint(self, "\nUsage:^3 cmd COMMAND...^7, where possible commands are listed above.\n"); sprint(self, "For help about a specific command, type cmd help COMMAND\n"); return; - } + } else if(CommonCommand_macro_usage(argc, self)) // Instead of trying to call a command, we're going to see detailed information about it { return; @@ -682,12 +684,12 @@ void SV_ParseClientCommand(string command) { return; } - } + } else if(MUTATOR_CALLHOOK(SV_ParseClientCommand)) { return; // handled by a mutator } - else if(CheatCommand(argc)) + else if(CheatCommand(argc)) { return; // handled by server/cheats.qc }