// =====================================================
// Server side game commands code, reworked by Samual
-// Last updated: December 28th, 2011
+// Last updated: December 29th, 2011
// =====================================================
// used by GameCommand_make_mapinfo()
float infobartime = stof(argv(3));
string successful, t;
+ successful = string_null;
if((targets) && (admin_message))
{
{
entity client;
string reason = argv(1);
- float i;
+ float i = 0;
FOR_EACH_REALPLAYER(client)
{
{
case CMD_REQUEST_COMMAND:
{
- entity client = GetFilteredEntity(argv(1));
+ entity client = GetIndexedEntity(argc, 1);
float accepted = VerifyClientEntity(client, FALSE, FALSE);
if(accepted > 0)
}
}
-void GameCommand_bbox(float request) // legacy
+void GameCommand_bbox(float request)
{
switch(request)
{
{
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)
{
}
}
-void GameCommand_database(float request, float argc) // legacy
+void GameCommand_database(float request, float argc)
{
switch(request)
{
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"); }
case CMD_REQUEST_COMMAND:
{
entity client;
- float i;
+ float i = 0;
float argc;
FOR_EACH_CLIENT(client)
}
}
-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)
{
}
}
-void GameCommand_effectindexdump(float request) // legacy
+void GameCommand_effectindexdump(float request)
{
switch(request)
{
}
}
-void GameCommand_extendmatchtime(float request) // legacy
+void GameCommand_extendmatchtime(float request)
{
switch(request)
{
}
}
-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)
{
}
}
-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:
}
}
-void GameCommand_gettaginfo(float request, float argc) // legacy
+void GameCommand_gettaginfo(float request, float argc)
{
switch(request)
{
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)
{
}
}
-void GameCommand_make_mapinfo(float request) // legacy
+void GameCommand_make_mapinfo(float request)
{
switch(request)
{
{
print("\nUsage:^3 sv_cmd make_mapinfo\n");
print(" No arguments required.\n");
+ print("See also: ^2radarmap^7\n");
return;
}
}
string notify = argv(3);
string successful, t;
+ successful = string_null;
// lets see if the target(s) even actually exist.
if((targets) && (destination))
}
}
-void GameCommand_nospectators(float request) // legacy
+void GameCommand_nospectators(float request)
{
switch(request)
{
}
}
-void GameCommand_playerdemo(float request, float argc) // mostly legacy
+void GameCommand_playerdemo(float request, float argc)
{
switch(request)
{
{
case "read":
{
- client = GetFilteredEntity(argv(2));
+ client = GetIndexedEntity(argc, 2);
accepted = VerifyClientEntity(client, FALSE, TRUE);
if not(accepted > 0)
}
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)
}
self = client;
- playerdemo_open_write(argv(3));
+ playerdemo_open_write(argv(next_token));
return;
}
}
}
-void GameCommand_printstats(float request) // legacy
+void GameCommand_printstats(float request)
{
switch(request)
{
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)
{
{
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);
{
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");
{
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;
{
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)
{
{
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;
}
}
}
}
-void GameCommand_warp(float request, float argc) // mostly legacy
+void GameCommand_warp(float request, float argc)
{
switch (request)
{
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();
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;
}
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
}
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
+}