// Command Sub-Functions
// =======================
-void GameCommand_adminmsg(float request, float argc)
+void GameCommand_adminmsg(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_allready(float request)
+void GameCommand_allready(int request)
{
switch (request)
{
}
}
-void GameCommand_allspec(float request, float argc)
+void GameCommand_allspec(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_anticheat(float request, float argc)
+void GameCommand_anticheat(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_bbox(float request)
+void GameCommand_bbox(int request)
{
switch (request)
{
}
}
-void GameCommand_bot_cmd(float request, float argc, string command)
+void GameCommand_bot_cmd(int request, int argc, string command)
{
switch (request)
{
{
cvar_settemp("bot_vs_human", "0");
cvar_settemp("minplayers", "0");
+ cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
bot_fixcount();
cvar_settemp("bot_number", argv(2));
{
cvar_settemp("bot_vs_human", "0");
cvar_settemp("minplayers", "0");
+ cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", "0");
bot_fixcount();
cvar_settemp("bot_number", argv(3));
}
}
-void GameCommand_cointoss(float request, float argc)
+void GameCommand_cointoss(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_database(float request, float argc)
+void GameCommand_database(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_defer_clear(float request, float argc)
+void GameCommand_defer_clear(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_defer_clear_all(float request)
+void GameCommand_defer_clear_all(int request)
{
switch (request)
{
case CMD_REQUEST_COMMAND:
{
int n = 0;
- float argc;
+ int argc;
FOREACH_CLIENT(true, {
argc = tokenize_console(strcat("defer_clear ", ftos(etof(it))));
}
}
-void GameCommand_delrec(float request, float argc) // perhaps merge later with records and printstats and such?
+void GameCommand_delrec(int request, int argc) // perhaps merge later with records and printstats and such?
{
switch (request)
{
}
}
-void GameCommand_effectindexdump(float request)
+void GameCommand_effectindexdump(int request)
{
switch (request)
{
}
}
-void GameCommand_extendmatchtime(float request)
+void GameCommand_extendmatchtime(int request)
{
switch (request)
{
}
}
-void GameCommand_gametype(float request, float argc)
+void GameCommand_gametype(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_gettaginfo(float request, float argc)
+void GameCommand_gettaginfo(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_animbench(float request, float argc)
+void GameCommand_animbench(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_gotomap(float request, float argc)
+void GameCommand_gotomap(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_lockteams(float request)
+void GameCommand_lockteams(int request)
{
switch (request)
{
}
}
-void GameCommand_make_mapinfo(float request)
+void GameCommand_make_mapinfo(int request)
{
switch (request)
{
}
}
-void GameCommand_moveplayer(float request, float argc)
+void GameCommand_moveplayer(int request, int argc)
{
switch (request)
{
{
// set up
float team_id;
- float save = client.team_forced;
- client.team_forced = 0;
+ int save = Player_GetForcedTeamIndex(client);
+ Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT);
// find the team to move the player to
team_id = Team_ColorToTeam(destination);
+ entity balance;
if (team_id == client.team) // already on the destination team
{
// keep the forcing undone
}
else if (team_id == 0) // auto team
{
- CheckAllowedTeams(client);
- team_id = Team_NumberToTeam(FindSmallestTeam(client, false));
+ balance = TeamBalance_CheckAllowedTeams(client);
+ team_id = Team_IndexToTeam(TeamBalance_FindBestTeam(balance, client, false));
}
else
{
- CheckAllowedTeams(client);
+ balance = TeamBalance_CheckAllowedTeams(client);
}
- client.team_forced = save;
+ Player_SetForcedTeamIndex(client, save);
// Check to see if the destination team is even available
switch (team_id)
{
- case NUM_TEAM_1: if (c1 == -1) { LOG_INFO("Sorry, can't move player to red team if it doesn't exist."); return; } break;
- case NUM_TEAM_2: if (c2 == -1) { LOG_INFO("Sorry, can't move player to blue team if it doesn't exist."); return; } break;
- case NUM_TEAM_3: if (c3 == -1) { LOG_INFO("Sorry, can't move player to yellow team if it doesn't exist."); return; } break;
- case NUM_TEAM_4: if (c4 == -1) { LOG_INFO("Sorry, can't move player to pink team if it doesn't exist."); return; } break;
-
- default: LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.");
+ case NUM_TEAM_1:
+ {
+ if (!TeamBalance_IsTeamAllowed(balance, 1))
+ {
+ LOG_INFO("Sorry, can't move player to red team if it doesn't exist.");
+ TeamBalance_Destroy(balance);
+ return;
+ }
+ TeamBalance_Destroy(balance);
+ break;
+ }
+ case NUM_TEAM_2:
+ {
+ if (!TeamBalance_IsTeamAllowed(balance, 2))
+ {
+ LOG_INFO("Sorry, can't move player to blue team if it doesn't exist.");
+ TeamBalance_Destroy(balance);
+ return;
+ }
+ TeamBalance_Destroy(balance);
+ break;
+ }
+ case NUM_TEAM_3:
+ {
+ if (!TeamBalance_IsTeamAllowed(balance, 3))
+ {
+ LOG_INFO("Sorry, can't move player to yellow team if it doesn't exist.");
+ TeamBalance_Destroy(balance);
+ return;
+ }
+ TeamBalance_Destroy(balance);
+ break;
+ }
+ case NUM_TEAM_4:
+ {
+ if (!TeamBalance_IsTeamAllowed(balance, 4))
+ {
+ LOG_INFO("Sorry, can't move player to pink team if it doesn't exist.");
+ TeamBalance_Destroy(balance);
+ return;
+ }
+ TeamBalance_Destroy(balance);
+ break;
+ }
+ default:
+ {
+ LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.");
return;
+ }
}
// If so, lets continue and finally move the player
- client.team_forced = 0;
- if (MoveToTeam(client, team_id, 6))
+ Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT);
+ if (MoveToTeam(client, Team_TeamToIndex(team_id), 6))
{
successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") has been moved to the ", Team_ColoredFullName(team_id), "^7.");
}
}
-void GameCommand_nospectators(float request)
+void GameCommand_nospectators(int request)
{
switch (request)
{
}
}
-void GameCommand_printstats(float request)
+void GameCommand_printstats(int request)
{
switch (request)
{
}
}
-void GameCommand_radarmap(float request, float argc)
+void GameCommand_radarmap(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_reducematchtime(float request)
+void GameCommand_reducematchtime(int request)
{
switch (request)
{
}
}
-void GameCommand_setbots(float request, float argc)
+void GameCommand_setbots(int request, int argc)
{
switch (request)
{
if (argc >= 2)
{
cvar_settemp("minplayers", "0");
+ cvar_settemp("minplayers_per_team", "0");
cvar_settemp("bot_number", argv(1));
bot_fixcount();
return;
}
}
-void GameCommand_shuffleteams(float request)
+void GameCommand_shuffleteams(int request)
{
switch (request)
{
}
FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
- if (it.team_forced) {
+ 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
// either all players or none are gonna have forced teams
});
int number_of_teams = 0;
- CheckAllowedTeams(NULL);
- if (c1 >= 0) number_of_teams = max(1, number_of_teams);
- if (c2 >= 0) number_of_teams = max(2, number_of_teams);
- if (c3 >= 0) number_of_teams = max(3, number_of_teams);
- if (c4 >= 0) number_of_teams = max(4, number_of_teams);
+ entity balance = TeamBalance_CheckAllowedTeams(NULL);
+ for (int i = 1; i <= NUM_TEAMS; ++i)
+ {
+ if (TeamBalance_IsTeamAllowed(balance, i))
+ {
+ number_of_teams = max(i, number_of_teams);
+ }
+ }
+ TeamBalance_Destroy(balance);
int team_index = 0;
FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
- int target_team_number = Team_NumberToTeam(team_index + 1);
- if (it.team != target_team_number) MoveToTeam(it, target_team_number, 6);
+ int target_team_index = team_index + 1;
+ if (Entity_GetTeamIndex(it) != target_team_index)
+ {
+ MoveToTeam(it, target_team_index, 6);
+ }
team_index = (team_index + 1) % number_of_teams;
});
}
}
-void GameCommand_stuffto(float request, float argc)
+void GameCommand_stuffto(int request, int argc)
{
// This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
// Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
#endif
}
-void GameCommand_trace(float request, float argc)
+void GameCommand_trace(int request, int argc)
{
switch (request)
{
}
}
-void GameCommand_unlockteams(float request)
+void GameCommand_unlockteams(int request)
{
switch (request)
{
}
}
-void GameCommand_warp(float request, float argc)
+void GameCommand_warp(int request, int argc)
{
switch (request)
{
/* use this when creating a new command, making sure to place it in alphabetical order... also,
** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
-void GameCommand_(float request)
+void GameCommand_(int request)
{
switch(request)
{
FOREACH(SERVER_COMMANDS, true, { LOG_INFOF(" ^2%s^7: %s", it.m_name, it.m_description); });
}
-float GameCommand_macro_command(float argc, string command)
+float GameCommand_macro_command(int argc, string command)
{
string c = strtolower(argv(0));
FOREACH(SERVER_COMMANDS, it.m_name == c, {
return false;
}
-float GameCommand_macro_usage(float argc)
+float GameCommand_macro_usage(int argc)
{
string c = strtolower(argv(1));
FOREACH(SERVER_COMMANDS, it.m_name == c, {
void GameCommand(string command)
{
- float argc = tokenize_console(command);
+ int argc = tokenize_console(command);
// Guide for working with argc arguments by example:
// argc: 1 - 2 - 3 - 4