X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fsv_cmd.qc;h=b35f4fb53ae4e6ad52687a964a8782a58889d701;hb=f601dbac886cf2ca1e8adbdc7977abbf60ea5274;hp=d1946b63660904b88307787d36baeeabe9e24995;hpb=f2b27d4b960a11b7c0dd45dc4439edab40bcbfcb;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index d1946b636..b35f4fb53 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -163,8 +164,7 @@ void GameCommand_allready(int request) { if(warmup_stage) { - warmup_stage = 0; - ReadyRestart(); + ReadyRestart(true); } else LOG_INFO("Not in warmup."); @@ -191,7 +191,7 @@ void GameCommand_allspec(int request, int argc) string reason = argv(1); int n = 0; FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { - PutObserverInServer(it, true); + PutObserverInServer(it, true, true); ++n; }); if (n) bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); @@ -333,9 +333,9 @@ void GameCommand_bot_cmd(int request, int argc, string command) cvar_settemp("minplayers", "0"); cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", "0"); - bot_fixcount(); + bot_fixcount(false); // Kill all bots. cvar_settemp("bot_number", argv(2)); - if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count"); + if (!bot_fixcount(true)) LOG_INFO("Sorry, could not set requested bot count"); return; } else if (argv(1) == "load" && argc == 3) @@ -366,9 +366,9 @@ void GameCommand_bot_cmd(int request, int argc, string command) cvar_settemp("minplayers", "0"); cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", "0"); - bot_fixcount(); + bot_fixcount(false); // Kill all bots. cvar_settemp("bot_number", argv(3)); - if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count"); + if (!bot_fixcount(true)) LOG_INFO("Sorry, could not set requested bot count"); } else { @@ -1005,6 +1005,7 @@ void GameCommand_moveplayer(int request, int argc) // Check to see if the player is a valid target client = GetFilteredEntity(t); accepted = VerifyClientEntity(client, false, false); + string client_num_str = ftos(etof(client)); if (accepted <= 0) { @@ -1015,13 +1016,13 @@ void GameCommand_moveplayer(int request, int argc) string pl_name = playername(client.netname, client.team, false); if (!IS_SPEC(client) && !IS_OBSERVER(client)) { - PutObserverInServer(client, true); + PutObserverInServer(client, true, true); successful = strcat(successful, (successful ? ", " : ""), pl_name); } else { - LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already spectating."); + LOG_INFO("Player #", client_num_str, " (", pl_name, ") is already spectating."); } } else @@ -1036,7 +1037,7 @@ void GameCommand_moveplayer(int request, int argc) if (IS_SPEC(client) || IS_OBSERVER(client)) { // well technically we could, but should we allow that? :P - LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is not in the game."); + LOG_INFO("Player #", client_num_str, " (", pl_name, ") is not in the game."); continue; } @@ -1050,7 +1051,7 @@ void GameCommand_moveplayer(int request, int argc) if (team_num == client.team) // already on the destination team { // keep the forcing undone - LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), "."); + LOG_INFO("Player #", client_num_str, " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), "^7."); continue; } else if (team_num == 0) // auto team @@ -1068,16 +1069,22 @@ void GameCommand_moveplayer(int request, int argc) int team_id = Team_TeamToIndex(team_num); if (team_id == -1) { - LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist."); + LOG_INFO("Can't move player to ", destination, " team because it doesn't exist."); TeamBalance_Destroy(balance); return; } - if (!TeamBalance_IsTeamAllowed(balance, team_id)) + if (!IsTeamAvailable(team_num)) { - LOG_INFOF("Sorry, can't move player to %s team if it doesn't exist.", destination); + LOG_INFO("Can't move player to ", destination, " team because it isn't available."); TeamBalance_Destroy(balance); return; } + if (!TeamBalance_IsTeamAllowed(balance, team_id)) + { + LOG_INFO("Player #", client_num_str, " (", pl_name, ") is not allowed to join the ", Team_ColoredFullName(team_num), "^7."); + TeamBalance_Destroy(balance); + continue; + } TeamBalance_Destroy(balance); // If so, lets continue and finally move the player @@ -1085,11 +1092,11 @@ void GameCommand_moveplayer(int request, int argc) if (MoveToTeam(client, team_id, 6)) { successful = strcat(successful, (successful ? ", " : ""), pl_name); - LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") has been moved to the ", Team_ColoredFullName(team_num), "^7."); + LOG_INFO("Player #", client_num_str, " (", pl_name, ") has been moved to the ", Team_ColoredFullName(team_num), "^7."); } else { - LOG_INFO("Unable to move player ", ftos(GetFilteredNumber(t)), " (", pl_name, ")"); + LOG_INFO("Unable to move player #", client_num_str, " (", pl_name, ")"); } } } // loop end @@ -1125,12 +1132,9 @@ void GameCommand_nospectators(int request) { blockSpectators = 1; // give every spectator seconds time to become a player - FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, { - if(!it.caplayer) - { - CS(it).spectatortime = time; - Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); - } + FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !INGAME(it), { + CS(it).spectatortime = time; + Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); }); bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n")); return; @@ -1221,7 +1225,7 @@ void GameCommand_setbots(int request, int argc) cvar_settemp("minplayers", "0"); cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", argv(1)); - bot_fixcount(); + bot_fixcount(true); return; } } @@ -1246,7 +1250,7 @@ void shuffleteams() return; } - FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, { + FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), { if (Player_HasRealForcedTeam(it)) { // we could theoretically assign forced players to their teams // and shuffle the rest to fill the empty spots but in practise @@ -1268,7 +1272,7 @@ void shuffleteams() TeamBalance_Destroy(balance); int team_index = 0; - FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, { + FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || INGAME(it), { int target_team_index = team_index + 1; if (Entity_GetTeamIndex(it) != target_team_index) { @@ -1307,21 +1311,20 @@ void GameCommand_shuffleteams(int request) } } -void GameCommand_srestart(int request) +void GameCommand_resetmatch(int request) { switch (request) { case CMD_REQUEST_COMMAND: { - warmup_stage = cvar("g_warmup"); - ReadyRestart(); + ReadyRestart(false); return; } default: case CMD_REQUEST_USAGE: { - LOG_HELP("Usage:^3 sv_cmd srestart"); + LOG_HELP("Usage:^3 sv_cmd resetmatch"); LOG_HELP(" No arguments required."); return; } @@ -1672,9 +1675,9 @@ SERVER_COMMAND(nospectators, "Automatically remove spectators from a match") { G SERVER_COMMAND(printstats, "Dump eventlog player stats and other score information") { GameCommand_printstats(request); } SERVER_COMMAND(radarmap, "Generate a radar image of the map") { GameCommand_radarmap(request, arguments); } SERVER_COMMAND(reducematchtime, "Decrease the timelimit value incrementally") { GameCommand_reducematchtime(request); } +SERVER_COMMAND(resetmatch, "Soft restart the game without changing teams; goes back to warmup if enabled") { GameCommand_resetmatch(request); } SERVER_COMMAND(setbots, "Adjust how many bots are in the match") { GameCommand_setbots(request, arguments); } SERVER_COMMAND(shuffleteams, "Randomly move players to different teams") { GameCommand_shuffleteams(request); } -SERVER_COMMAND(srestart, "Soft restart the server and reset the players") { GameCommand_srestart(request); } SERVER_COMMAND(stuffto, "Send a command to be executed on a client") { GameCommand_stuffto(request, arguments); } SERVER_COMMAND(trace, "Various debugging tools with tracing") { GameCommand_trace(request, arguments); } SERVER_COMMAND(unlockteams, "Enable the ability for players to switch or enter teams") { GameCommand_unlockteams(request); }