X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fcmd.qc;h=d1d79981182ceb91e560895f22f7f3d2e4c3a3df;hb=6c3362162e191402de680067e86ced4331550117;hp=af8d60310c6cbdded900a82aae82f83df35ad04b;hpb=3b4e6bcd28b6b3d16304f54fc584c52ce2e57e49;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index af8d60310..d1d799811 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -1,4 +1,8 @@ #include "cmd.qh" + +#include +#include + #include #include "common.qh" @@ -101,11 +105,11 @@ void ClientCommand_clientversion(entity caller, float request, float argc) // i { if (IS_CLIENT(caller)) { - caller.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1))); + CS(caller).version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1))); - if (caller.version < autocvar_gameversion_min || caller.version > autocvar_gameversion_max) + if (CS(caller).version < autocvar_gameversion_min || CS(caller).version > autocvar_gameversion_max) { - caller.version_mismatch = 1; + CS(caller).version_mismatch = true; ClientKill_TeamChange(caller, -2); // observe } else if (autocvar_g_campaign || autocvar_g_balance_teams) @@ -159,33 +163,19 @@ void ClientCommand_mv_getpicture(entity caller, float request, float argc) // i } } +bool joinAllowed(entity this); +void Join(entity this); void ClientCommand_join(entity caller, float request) { switch (request) { case CMD_REQUEST_COMMAND: { - if (IS_CLIENT(caller)) - { - if (!IS_PLAYER(caller) && !lockteams && !gameover) - { - if (caller.caplayer) return; - if (nJoinAllowed(caller, caller)) - { - if (autocvar_g_campaign) campaign_bots_may_start = true; - TRANSMUTE(Player, caller); - PlayerScore_Clear(caller); - Kill_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CPID_PREVENT_JOIN); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && caller.team != -1) ? APP_TEAM_ENT(caller, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), caller.netname); - PutClientInServer(caller); - } - else - { - // player may not join because of g_maxplayers is set - Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_JOIN_PREVENT); - } - } - } + if (!game_stopped) + if (IS_CLIENT(caller) && !IS_PLAYER(caller)) + if (joinAllowed(caller)) + Join(caller); + return; // never fall through to usage } @@ -256,12 +246,12 @@ void ClientCommand_ready(entity caller, float request) // todo: anti-spam for t if (caller.ready) // toggle { caller.ready = false; - bprint(caller.netname, "^2 is ^1NOT^2 ready\n"); + bprint(playername(caller, false), "^2 is ^1NOT^2 ready\n"); } else { caller.ready = true; - bprint(caller.netname, "^2 is ready\n"); + bprint(playername(caller, false), "^2 is ready\n"); } // cannot reset the game while a timeout is active! @@ -326,6 +316,7 @@ void ClientCommand_say_team(entity caller, float request, float argc, string com } } +.bool team_selected; void ClientCommand_selectteam(entity caller, float request, float argc) { switch (request) @@ -363,11 +354,11 @@ void ClientCommand_selectteam(entity caller, float request, float argc) if (selection) { - if (caller.team == selection && !IS_DEAD(caller)) + if (caller.team == selection && selection != -1 && !IS_DEAD(caller)) { sprint(caller, "^7You already are on that team.\n"); } - else if (caller.wasplayer && autocvar_g_changeteam_banned) + else if (CS(caller).wasplayer && autocvar_g_changeteam_banned) { sprint(caller, "^1You cannot change team, forbidden by the server.\n"); } @@ -385,6 +376,8 @@ void ClientCommand_selectteam(entity caller, float request, float argc) } ClientKill_TeamChange(caller, selection); } + if(!IS_PLAYER(caller)) + caller.team_selected = true; // avoids asking again for team selection on join } } else @@ -482,8 +475,19 @@ void ClientCommand_spectate(entity caller, float request) { case CMD_REQUEST_COMMAND: { - if (IS_CLIENT(caller)) + if (!intermission_running && IS_CLIENT(caller)) { + if((IS_SPEC(caller) || IS_OBSERVER(caller)) && argv(1) != "") + { + entity client = GetFilteredEntity(argv(1)); + int spec_accepted = VerifyClientEntity(client, false, false); + if(spec_accepted > 0 && IS_PLAYER(client)) + { + if(Spectate(caller, client)) + return; // fall back to regular handling + } + } + int mutator_returnvalue = MUTATOR_CALLHOOK(ClientCommand_Spectate, caller); if (mutator_returnvalue == MUT_SPECCMD_RETURN) return; @@ -498,8 +502,8 @@ void ClientCommand_spectate(entity caller, float request) default: case CMD_REQUEST_USAGE: { - sprint(caller, "\nUsage:^3 cmd spectate\n"); - sprint(caller, " No arguments required.\n"); + sprint(caller, "\nUsage:^3 cmd spectate \n"); + sprint(caller, " Where 'client' can be the player to spectate.\n"); return; } } @@ -537,6 +541,12 @@ void ClientCommand_tell(entity caller, float request, float argc, string command { if (argc >= 3) { + if(!IS_CLIENT(caller) && IS_REAL_CLIENT(caller)) // connecting + { + print_to(caller, "You can't ^2tell^7 a message while connecting."); + return; + } + entity tell_to = GetIndexedEntity(argc, 1); float tell_accepted = VerifyClientEntity(tell_to, true, false);