X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fsv_cmd.qc;h=1e5fedbcb65b79d209fff4de1fd2e7b11045a861;hp=33e9273bb5e44f9fc11b739d7419d03971eecba4;hb=a394baa72a77a2db64709e44caa89a6fb4aaf5f4;hpb=d95afcf1229a11a7198936683998d16a1c2500d7 diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 33e9273bb5..1e5fedbcb6 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1,4 +1,5 @@ -#include "all.qh" +#include "sv_cmd.qh" +#include "_mod.qh" #include "banning.qh" #include "cmd.qh" @@ -8,29 +9,28 @@ #include "../anticheat.qh" #include "../campaign.qh" -#include "../cl_client.qh" -#include "../cl_player.qh" +#include "../client.qh" +#include "../player.qh" #include "../g_world.qh" #include "../ipban.qh" #include "../playerdemo.qh" #include "../teamplay.qh" -#include "../bot/bot.qh" -#include "../bot/navigation.qh" -#include "../bot/scripting.qh" +#include "../bot/api.qh" -#include "../mutators/all.qh" +#include "../mutators/_mod.qh" #include +#include #include -#include +#include #include #include #include -void PutObserverInServer(); +void PutObserverInServer(entity this); // ===================================================== // Server side game commands code, reworked by Samual @@ -38,19 +38,18 @@ void PutObserverInServer(); // ===================================================== // used by GameCommand_make_mapinfo() -void make_mapinfo_Think() +void make_mapinfo_Think(entity this) { - SELFPARAM(); - if (MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1)) + if (_MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1)) { LOG_INFO("Done rebuiling mapinfos.\n"); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); - remove(self); + delete(this); } else { - self.think = make_mapinfo_Think; - self.nextthink = time; + setthink(this, make_mapinfo_Think); + this.nextthink = time; } } @@ -141,7 +140,7 @@ void GameCommand_adminmsg(float request, float argc) } successful = strcat(successful, (successful ? ", " : ""), client.netname); - LOG_TRACE("Message sent to ", client.netname, "\n"); + LOG_TRACE("Message sent to ", client.netname); continue; } @@ -189,7 +188,6 @@ void GameCommand_allready(float request) void GameCommand_allspec(float request, float argc) { - SELFPARAM(); switch (request) { case CMD_REQUEST_COMMAND: @@ -198,7 +196,7 @@ void GameCommand_allspec(float request, float argc) int n = 0; FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA( if (it.caplayer) it.caplayer = 0; - WITH(entity, self, it, PutObserverInServer()); + PutObserverInServer(it); ++n; )); if (n) bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); @@ -219,7 +217,6 @@ void GameCommand_allspec(float request, float argc) void GameCommand_anticheat(float request, float argc) { - SELFPARAM(); switch (request) { case CMD_REQUEST_COMMAND: @@ -229,7 +226,7 @@ void GameCommand_anticheat(float request, float argc) if (accepted > 0) { - WITH(entity, self, client, anticheat_report()); + anticheat_report_to_eventlog(client); return; } else @@ -266,7 +263,7 @@ void GameCommand_bbox(float request) '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z, '1 0 0' * world.absmax.x, MOVE_WORLDONLY, - world); + NULL); if (trace_startsolid) LOG_INFO(" ", ftos(world.absmin.x)); else LOG_INFO(" ", ftos(trace_endpos.x)); @@ -275,7 +272,7 @@ void GameCommand_bbox(float request) '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z, '0 1 0' * world.absmax.y, MOVE_WORLDONLY, - world); + NULL); if (trace_startsolid) LOG_INFO(" ", ftos(world.absmin.y)); else LOG_INFO(" ", ftos(trace_endpos.y)); @@ -284,7 +281,7 @@ void GameCommand_bbox(float request) '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y, '0 0 1' * world.absmax.z, MOVE_WORLDONLY, - world); + NULL); if (trace_startsolid) LOG_INFO(" ", ftos(world.absmin.z)); else LOG_INFO(" ", ftos(trace_endpos.z)); @@ -293,7 +290,7 @@ void GameCommand_bbox(float request) '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z, '1 0 0' * world.absmin.x, MOVE_WORLDONLY, - world); + NULL); if (trace_startsolid) LOG_INFO(" ", ftos(world.absmax.x)); else LOG_INFO(" ", ftos(trace_endpos.x)); @@ -302,7 +299,7 @@ void GameCommand_bbox(float request) '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z, '0 1 0' * world.absmin.y, MOVE_WORLDONLY, - world); + NULL); if (trace_startsolid) LOG_INFO(" ", ftos(world.absmax.y)); else LOG_INFO(" ", ftos(trace_endpos.y)); @@ -311,7 +308,7 @@ void GameCommand_bbox(float request) '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y, '0 0 1' * world.absmin.z, MOVE_WORLDONLY, - world); + NULL); if (trace_startsolid) LOG_INFO(" ", ftos(world.absmax.z)); else LOG_INFO(" ", ftos(trace_endpos.z)); @@ -388,7 +385,7 @@ void GameCommand_bot_cmd(float request, float argc, string command) { // let's start at token 2 so we can skip sv_cmd bot_cmd bot = find_bot_by_number(stof(argv(2))); - if (bot == world) bot = find_bot_by_name(argv(2)); + if (bot == NULL) bot = find_bot_by_name(argv(2)); if (bot) bot_queuecommand(bot, substring(s, argv_start_index(3), -1)); } } @@ -412,7 +409,7 @@ void GameCommand_bot_cmd(float request, float argc, string command) else if (argc >= 3) // this comes last { bot = find_bot_by_number(stof(argv(1))); - if (bot == world) bot = find_bot_by_name(argv(1)); + if (bot == NULL) bot = find_bot_by_name(argv(1)); if (bot) { LOG_INFO(strcat("Command '", substring(command, argv_start_index(2), -1), "' sent to bot ", bot.netname, "\n")); @@ -450,7 +447,7 @@ void GameCommand_cointoss(float request, float argc) string result2 = (argv(2) ? strcat("^7", argv(2)) : "^4TAILS"); string choice = ((random() > 0.5) ? result1 : result2); - Send_Notification(NOTIF_ALL, world, MSG_MULTI, MULTI_COINTOSS, choice); + Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, MULTI_COINTOSS, choice); return; } @@ -735,31 +732,6 @@ void GameCommand_extendmatchtime(float request) } } -void GameCommand_find(float request, float argc) // is this even needed? We have prvm_edicts command and such ANYWAY -{ - switch (request) - { - case CMD_REQUEST_COMMAND: - { - entity client; - - for (client = world; (client = find(client, classname, argv(1))); ) - LOG_INFO(etos(client), "\n"); - - return; - } - - default: - LOG_INFO("Incorrect parameters for ^2find^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 sv_cmd find classname\n"); - LOG_INFO(" Where 'classname' is the classname to search for.\n"); - return; - } - } -} - void GameCommand_gametype(float request, float argc) { switch (request) @@ -769,7 +741,7 @@ void GameCommand_gametype(float request, float argc) if (argv(1) != "") { string s = argv(1); - float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype(); + Gametype t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype(); if (t) { @@ -826,7 +798,7 @@ void GameCommand_gettaginfo(float request, float argc) if (argv(1) == "w") { .entity weaponentity = weaponentities[0]; - _setmodel(tmp_entity, (nextent(world)).(weaponentity).model); + _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model); } else { @@ -857,7 +829,7 @@ void GameCommand_gettaginfo(float request, float argc) LOG_INFO("bone not found\n"); } - remove(tmp_entity); + delete(tmp_entity); return; } } @@ -887,7 +859,7 @@ void GameCommand_animbench(float request, float argc) if (argv(1) == "w") { .entity weaponentity = weaponentities[0]; - _setmodel(tmp_entity, (nextent(world)).(weaponentity).model); + _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model); } else { @@ -916,7 +888,7 @@ void GameCommand_animbench(float request, float argc) LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f1), " animtime ", ftos(n / t1), "/s\n"); LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f2), " animtime ", ftos(n / t2), "/s\n"); - remove(tmp_entity); + delete(tmp_entity); return; } } @@ -995,7 +967,7 @@ void GameCommand_make_mapinfo(float request) entity tmp_entity; tmp_entity = new(make_mapinfo); - tmp_entity.think = make_mapinfo_Think; + setthink(tmp_entity, make_mapinfo_Think); tmp_entity.nextthink = time; MapInfo_Enumerate(); return; @@ -1014,7 +986,6 @@ void GameCommand_make_mapinfo(float request) void GameCommand_moveplayer(float request, float argc) { - SELFPARAM(); switch (request) { case CMD_REQUEST_COMMAND: @@ -1053,7 +1024,7 @@ void GameCommand_moveplayer(float request, float argc) if (!IS_SPEC(client) && !IS_OBSERVER(client)) { if (client.caplayer) client.caplayer = 0; - WITH(entity, self, client, PutObserverInServer()); + PutObserverInServer(client); successful = strcat(successful, (successful ? ", " : ""), client.netname); } @@ -1180,7 +1151,6 @@ void GameCommand_nospectators(float request) void GameCommand_playerdemo(float request, float argc) { - SELFPARAM(); switch (request) { case CMD_REQUEST_COMMAND: @@ -1203,7 +1173,7 @@ void GameCommand_playerdemo(float request, float argc) return; } - WITH(entity, self, client, playerdemo_open_read(argv(next_token))); + playerdemo_open_read(client, argv(next_token)); return; } @@ -1218,7 +1188,7 @@ void GameCommand_playerdemo(float request, float argc) return; } - WITH(entity, self, client, playerdemo_open_write(argv(next_token))); + playerdemo_open_write(client, argv(next_token)); return; } @@ -1352,14 +1322,13 @@ void GameCommand_setbots(float request, float argc) void GameCommand_shuffleteams(float request) { - SELFPARAM(); switch (request) { case CMD_REQUEST_COMMAND: { if (teamplay) { - float x, t_teams, t_players, team_color; + float t_teams, t_players, team_color; // count the total amount of players and total amount of teams t_players = 0; @@ -1397,21 +1366,25 @@ void GameCommand_shuffleteams(float request) for (int i = 1; i <= t_teams; ++i) { // find out how many players to assign to this team - x = (t_players / t_teams); - x = ((i == 1) ? ceil(x) : floor(x)); + int pnum = (t_players / t_teams); + pnum = ((i == 1) ? ceil(pnum) : floor(pnum)); team_color = Team_NumberToTeam(i); // sort through the random list of players made earlier for (int z = 1; z <= maxclients; ++z) { - if (!(shuffleteams_teams[i] >= x)) + if (!(shuffleteams_teams[i] >= pnum)) { if (!(shuffleteams_players[z])) continue; // not a player, move on to next random slot - if (VerifyClientNumber(shuffleteams_players[z])) setself(edict_num(shuffleteams_players[z])); + entity e = NULL; + if(VerifyClientNumber(shuffleteams_players[z])) + e = edict_num(shuffleteams_players[z]); + + if(!e) continue; // unverified - if (self.team != team_color) MoveToTeam(self, team_color, 6); + if (e.team != team_color) MoveToTeam(e, team_color, 6); shuffleteams_players[z] = 0; shuffleteams_teams[i] = shuffleteams_teams[i] + 1; @@ -1533,15 +1506,15 @@ void GameCommand_trace(float request, float argc) start = stov(vtos(start)); end = stov(vtos(end)); - tracebox(start, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), end, MOVE_NOMONSTERS, world); + tracebox(start, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), end, MOVE_NOMONSTERS, NULL); if (!trace_startsolid && trace_fraction < 1) { p = trace_endpos; - tracebox(p, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), p, MOVE_NOMONSTERS, world); + tracebox(p, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), p, MOVE_NOMONSTERS, NULL); if (trace_startsolid) { rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid - tracebox(start, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), end, MOVE_NOMONSTERS, world); + tracebox(start, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), end, MOVE_NOMONSTERS, NULL); // how much do we need to back off? safe = 1; @@ -1549,7 +1522,7 @@ void GameCommand_trace(float request, float argc) for ( ; ; ) { pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5); - tracebox(pos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), pos, MOVE_NOMONSTERS, world); + tracebox(pos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), pos, MOVE_NOMONSTERS, NULL); if (trace_startsolid) { if ((safe + unsafe) * 0.5 == unsafe) break; @@ -1565,7 +1538,7 @@ void GameCommand_trace(float request, float argc) LOG_INFO("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n"); LOG_INFO("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n"); - tracebox(p, STAT(PL_MIN, NULL) + '0.1 0.1 0.1', STAT(PL_MAX, NULL) - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world); + tracebox(p, STAT(PL_MIN, NULL) + '0.1 0.1 0.1', STAT(PL_MAX, NULL) - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, NULL); if (trace_startsolid) LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); else LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n"); if (++hitcount >= 10) break; @@ -1579,7 +1552,7 @@ void GameCommand_trace(float request, float argc) { q = p + normalize(end - p) * (dq + dqf); if (q == q0) break; - tracebox(p, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), q, MOVE_NOMONSTERS, world); + tracebox(p, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), q, MOVE_NOMONSTERS, NULL); if (trace_startsolid) error("THIS ONE cannot happen"); if (trace_fraction > 0) dq += dqf * trace_fraction; dqf *= 0.5; @@ -1600,7 +1573,7 @@ void GameCommand_trace(float request, float argc) case "debug2": { - e = nextent(world); + e = nextent(NULL); tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e); vv = trace_endpos; if (trace_fraction == 1) @@ -1633,7 +1606,7 @@ void GameCommand_trace(float request, float argc) { if (argc == 4) { - e = nextent(world); + e = nextent(NULL); if (tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), MOVE_NORMAL)) LOG_INFO("can walk\n"); else LOG_INFO("cannot walk\n"); return; @@ -1646,9 +1619,9 @@ void GameCommand_trace(float request, float argc) { vv = stov(argv(2)); dv = stov(argv(3)); - traceline(vv, dv, MOVE_NORMAL, world); - __trailparticles(world, particleeffectnum(EFFECT_TR_NEXUIZPLASMA), vv, trace_endpos); - __trailparticles(world, particleeffectnum(EFFECT_TR_CRYLINKPLASMA), trace_endpos, dv); + traceline(vv, dv, MOVE_NORMAL, NULL); + __trailparticles(NULL, particleeffectnum(EFFECT_TR_NEXUIZPLASMA), vv, trace_endpos); + __trailparticles(NULL, particleeffectnum(EFFECT_TR_CRYLINKPLASMA), trace_endpos, dv); return; } } @@ -1778,7 +1751,6 @@ SERVER_COMMAND(defer_clear_all, "Clear all queued defer commands for all clients SERVER_COMMAND(delrec, "Delete race time record for a map") { GameCommand_delrec(request, arguments); } SERVER_COMMAND(effectindexdump, "Dump list of effects from code and effectinfo.txt") { GameCommand_effectindexdump(request); } SERVER_COMMAND(extendmatchtime, "Increase the timelimit value incrementally") { GameCommand_extendmatchtime(request); } -SERVER_COMMAND(find, "Search through entities for matching classname") { GameCommand_find(request, arguments); } SERVER_COMMAND(gametype, "Simple command to change the active gametype") { GameCommand_gametype(request, arguments); } SERVER_COMMAND(gettaginfo, "Get specific information about a weapon model") { GameCommand_gettaginfo(request, arguments); } SERVER_COMMAND(gotomap, "Simple command to switch to another map") { GameCommand_gotomap(request, arguments); } @@ -1806,7 +1778,7 @@ float GameCommand_macro_command(float argc, string command) { string c = strtolower(argv(0)); FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA( - it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command); + it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command); return true; )); return false; @@ -1816,7 +1788,7 @@ float GameCommand_macro_usage(float argc) { string c = strtolower(argv(1)); FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA( - it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, ""); + it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, ""); return true; )); return false; @@ -1853,7 +1825,7 @@ void GameCommand(string command) BanCommand_macro_help(); LOG_INFO("\nCommon networked commands:\n"); - CommonCommand_macro_help(world); + CommonCommand_macro_help(NULL); LOG_INFO("\nGeneric commands shared by all programs:\n"); GenericCommand_macro_help(); @@ -1867,7 +1839,7 @@ void GameCommand(string command) { return; } - else if (CommonCommand_macro_usage(argc, world)) // same here, but for common commands instead + else if (CommonCommand_macro_usage(argc, NULL)) // same here, but for common commands instead { return; } @@ -1888,7 +1860,7 @@ void GameCommand(string command) { return; // handled by server/command/ipban.qc } - else if (CommonCommand_macro_command(argc, world, command)) + else if (CommonCommand_macro_command(argc, NULL, command)) { return; // handled by server/command/common.qc }