X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fsv_cmd.qc;h=f3d6d5999ff6ed65f76674f5903b93f2e642ee3e;hb=958c74ba81e1be956cc7d6f863b30820458bb289;hp=ec756d45189aceb9b3fe6793847b1eb3abb79e4f;hpb=0ed85c3c8c82a079b023eb2874ec4ae9c7e90757;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index ec756d451..f3d6d5999 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1,6 +1,6 @@ // ===================================================== // Server side game commands code, reworked by Samual -// Last updated: December 28th, 2011 +// Last updated: December 29th, 2011 // ===================================================== // used by GameCommand_make_mapinfo() @@ -81,6 +81,7 @@ void GameCommand_adminmsg(float request, float argc) float infobartime = stof(argv(3)); string successful, t; + successful = string_null; if((targets) && (admin_message)) { @@ -117,7 +118,7 @@ void GameCommand_adminmsg(float request, float argc) if(successful) bprint("Successfully sent message '", admin_message, "' to ", successful, ".\n"); else - print("No players given (", original_targets, ") could recieve the message.\n"); + print("No players given (", original_targets, ") could receive the message.\n"); return; } @@ -166,7 +167,7 @@ void GameCommand_allspec(float request, float argc) { entity client; string reason = argv(1); - float i; + float i = 0; FOR_EACH_REALPLAYER(client) { @@ -196,7 +197,7 @@ void GameCommand_anticheat(float request, float argc) { case CMD_REQUEST_COMMAND: { - entity client = GetFilteredEntity(argv(1)); + entity client = GetIndexedEntity(argc, 1); float accepted = VerifyClientEntity(client, FALSE, FALSE); if(accepted > 0) @@ -222,7 +223,7 @@ void GameCommand_anticheat(float request, float argc) } } -void GameCommand_bbox(float request) // legacy +void GameCommand_bbox(float request) { switch(request) { @@ -309,13 +310,13 @@ void GameCommand_bbox(float request) // legacy { print("\nUsage:^3 sv_cmd bbox\n"); print(" No arguments required.\n"); - print("See also: ^2gettaginfo^7\n"); + print("See also: ^2gettaginfo, trace^7\n"); return; } } } -void GameCommand_bot_cmd(float request, float argc) // mostly legacy +void GameCommand_bot_cmd(float request, float argc) { switch(request) { @@ -441,7 +442,7 @@ void GameCommand_cointoss(float request, float argc) } } -void GameCommand_database(float request, float argc) // legacy +void GameCommand_database(float request, float argc) { switch(request) { @@ -493,15 +494,15 @@ void GameCommand_defer_clear(float request, float argc) entity client; float accepted; - if(argc == 2) + if(argc >= 2) { - client = GetFilteredEntity(argv(1)); + client = GetIndexedEntity(argc, 1); accepted = VerifyClientEntity(client, TRUE, FALSE); if(accepted > 0) { stuffcmd(client, "defer clear\n"); - print("defer clear stuffed to ", argv(1), " (", client.netname, ")\n"); + print("defer clear stuffed to ", client.netname, "\n"); } else { print("defer_clear: ", GetClientErrorString(accepted, argv(1)), ".\n"); } @@ -528,7 +529,7 @@ void GameCommand_defer_clear_all(float request) case CMD_REQUEST_COMMAND: { entity client; - float i; + float i = 0; float argc; FOR_EACH_CLIENT(client) @@ -552,7 +553,7 @@ void GameCommand_defer_clear_all(float request) } } -void GameCommand_delrec(float request, float argc) // legacy // perhaps merge later with records and printstats and such? +void GameCommand_delrec(float request, float argc) // perhaps merge later with records and printstats and such? { switch(request) { @@ -581,7 +582,7 @@ void GameCommand_delrec(float request, float argc) // legacy // perhaps merge la } } -void GameCommand_effectindexdump(float request) // legacy +void GameCommand_effectindexdump(float request) { switch(request) { @@ -659,7 +660,7 @@ void GameCommand_effectindexdump(float request) // legacy } } -void GameCommand_extendmatchtime(float request) // legacy +void GameCommand_extendmatchtime(float request) { switch(request) { @@ -680,7 +681,7 @@ void GameCommand_extendmatchtime(float request) // legacy } } -void GameCommand_find(float request, float argc) // legacy // is this even needed? We have prvm_edicts command and such ANYWAY +void GameCommand_find(float request, float argc) // is this even needed? We have prvm_edicts command and such ANYWAY { switch(request) { @@ -705,31 +706,35 @@ void GameCommand_find(float request, float argc) // legacy // is this even neede } } -void GameCommand_gametype(float request, float argc) // legacy +void GameCommand_gametype(float request, float argc) { switch(request) { case CMD_REQUEST_COMMAND: { - string s = argv(1); - float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype(); - - if(t) + if(argv(1) != "") { - MapInfo_SwitchGameType(t); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); - if(MapInfo_count > 0) - bprint("Game type successfully switched to ", s, "\n"); - else + string s = argv(1); + float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype(); + + if(t) { - bprint("Cannot use this game type: no map for it found\n"); - MapInfo_SwitchGameType(tsave); + MapInfo_SwitchGameType(t); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); + if(MapInfo_count > 0) + 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); + } } + else + bprint("Game type switch to ", s, " failed: this type does not exist!\n"); + + return; } - else - bprint("Game type switch to ", s, " failed: this type does not exist!\n"); - return; } default: @@ -744,7 +749,7 @@ void GameCommand_gametype(float request, float argc) // legacy } } -void GameCommand_gettaginfo(float request, float argc) // legacy +void GameCommand_gettaginfo(float request, float argc) { switch(request) { @@ -798,13 +803,13 @@ void GameCommand_gettaginfo(float request, float argc) // legacy case CMD_REQUEST_USAGE: { print("\nUsage:^3 sv_cmd gettaginfo model frame index [command one] [command two]\n"); - print("See also: ^2bbox^7\n"); + print("See also: ^2bbox, trace^7\n"); return; } } } -void GameCommand_gotomap(float request, float argc) // mostly legacy +void GameCommand_gotomap(float request, float argc) { switch(request) { @@ -858,7 +863,7 @@ void GameCommand_lockteams(float request) } } -void GameCommand_make_mapinfo(float request) // legacy +void GameCommand_make_mapinfo(float request) { switch(request) { @@ -879,6 +884,7 @@ void GameCommand_make_mapinfo(float request) // legacy { print("\nUsage:^3 sv_cmd make_mapinfo\n"); print(" No arguments required.\n"); + print("See also: ^2radarmap^7\n"); return; } } @@ -899,6 +905,7 @@ void GameCommand_moveplayer(float request, float argc) string notify = argv(3); string successful, t; + successful = string_null; // lets see if the target(s) even actually exist. if((targets) && (destination)) @@ -1022,7 +1029,7 @@ void GameCommand_moveplayer(float request, float argc) } } -void GameCommand_nospectators(float request) // legacy +void GameCommand_nospectators(float request) { switch(request) { @@ -1052,7 +1059,7 @@ void GameCommand_nospectators(float request) // legacy } } -void GameCommand_playerdemo(float request, float argc) // mostly legacy +void GameCommand_playerdemo(float request, float argc) { switch(request) { @@ -1067,7 +1074,7 @@ void GameCommand_playerdemo(float request, float argc) // mostly legacy { case "read": { - client = GetFilteredEntity(argv(2)); + client = GetIndexedEntity(argc, 2); accepted = VerifyClientEntity(client, FALSE, TRUE); if not(accepted > 0) @@ -1077,13 +1084,13 @@ void GameCommand_playerdemo(float request, float argc) // mostly legacy } self = client; - playerdemo_open_read(argv(3)); + playerdemo_open_read(argv(next_token)); return; } case "write": { - client = GetFilteredEntity(argv(2)); + client = GetIndexedEntity(argc, 2); accepted = VerifyClientEntity(client, FALSE, FALSE); if not(accepted > 0) @@ -1093,7 +1100,7 @@ void GameCommand_playerdemo(float request, float argc) // mostly legacy } self = client; - playerdemo_open_write(argv(3)); + playerdemo_open_write(argv(next_token)); return; } @@ -1133,7 +1140,7 @@ void GameCommand_playerdemo(float request, float argc) // mostly legacy } } -void GameCommand_printstats(float request) // legacy +void GameCommand_printstats(float request) { switch(request) { @@ -1171,12 +1178,13 @@ void GameCommand_radarmap(float request, float argc) print("\nUsage:^3 sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]\n"); print(" The quality factor Q is roughly proportional to the time taken.\n"); print(" trace supports no quality factor; its result should look like --block with infinite quality factor.\n"); + print("See also: ^2make_mapinfo^7\n"); return; } } } -void GameCommand_reducematchtime(float request) // legacy +void GameCommand_reducematchtime(float request) { switch(request) { @@ -1232,10 +1240,12 @@ void GameCommand_shuffleteams(float request) { if(teamplay) { - entity tmp_player, client; - float i, x, z, t_teams, t_players, team_color, accepted; + entity tmp_player; + float i, x, z, t_teams, t_players, team_color; // count the total amount of players and total amount of teams + t_players = 0; + t_teams = 0; FOR_EACH_PLAYER(tmp_player) { CheckAllowedTeams(tmp_player); @@ -1341,13 +1351,13 @@ void GameCommand_stuffto(float request, float argc) { if(argv(2)) { - entity client = GetFilteredEntity(argv(1)); + entity client = GetIndexedEntity(argc, 1); float accepted = VerifyClientEntity(client, TRUE, FALSE); if(accepted > 0) { - stuffcmd(client, strcat("\n", argv(2), "\n")); - print(strcat("Command: \"", argv(2), "\" sent to ", GetCallerName(client), " (", argv(1) ,").\n")); + stuffcmd(client, strcat("\n", argv(next_token), "\n")); + print(strcat("Command: \"", argv(next_token), "\" sent to ", GetCallerName(client), " (", argv(1) ,").\n")); } else print("stuffto: ", GetClientErrorString(accepted, argv(1)), ".\n"); @@ -1381,7 +1391,6 @@ void GameCommand_trace(float request, float argc) { case CMD_REQUEST_COMMAND: { - // This is kinda a mess, a lot of it is legacy and thus not rewritten/optimized. entity e; vector org, delta, start, end, p, q, q0, pos, vv, dv; float i, f, safe, unsafe, dq, dqf; @@ -1416,7 +1425,6 @@ void GameCommand_trace(float request, float argc) { rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world); - tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world); if(trace_startsolid) { @@ -1547,6 +1555,7 @@ void GameCommand_trace(float request, float argc) { print("\nUsage:^3 sv_cmd trace command (startpos endpos)\n"); print(" Full list of commands here: \"debug, debug2, walk, showline.\"\n"); + print("See also: ^2bbox, gettaginfo^7\n"); return; } } @@ -1581,7 +1590,7 @@ void GameCommand_unlockteams(float request) } } -void GameCommand_warp(float request, float argc) // mostly legacy +void GameCommand_warp(float request, float argc) { switch (request) { @@ -1711,6 +1720,17 @@ float GameCommand_macro_usage(float argc) return FALSE; } + +void GameCommand_macro_write_aliases(float fh) +{ + #define SERVER_COMMAND(name,function,description) \ + { CMD_Write_Alias("qc_cmd_sv", name, description); } + + SERVER_COMMANDS(0, 0, "") + #undef SERVER_COMMAND + + return; +} // ========================================= @@ -1735,10 +1755,10 @@ void GameCommand(string command) GameCommand_macro_help(); print("\nBanning commands:\n"); - GameCommand_Ban("help"); + BanCommand_macro_help(); print("\nCommon networked commands:\n"); - CommonCommand_macro_help(); + CommonCommand_macro_help(world); print("\nGeneric commands shared by all programs:\n"); GenericCommand_macro_help(); @@ -1748,7 +1768,11 @@ void GameCommand(string command) return; } - else if(CommonCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it + else if(BanCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it + { + return; + } + else if(CommonCommand_macro_usage(argc, world)) // same here, but for common commands instead { return; } @@ -1761,11 +1785,11 @@ void GameCommand(string command) return; } } - else if(GameCommand_Ban(command)) + else if(BanCommand(command)) { return; // handled by server/command/ipban.qc } - else if(CommonCommand_macro_command(argc, command)) + else if(CommonCommand_macro_command(argc, world, command)) { return; // handled by server/command/common.qc } @@ -1782,4 +1806,4 @@ void GameCommand(string command) print(((command != "") ? strcat("Unknown server command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try sv_cmd help.\n"); return; -} \ No newline at end of file +}