#include "../bot/api.qh"
-#include "../mutators/_mod.qh"
+#include <server/mutators/_mod.qh>
+#include <common/gamemodes/_mod.qh>
#include <common/constants.qh>
#include <common/net_linked.qh>
#include <common/monsters/sv_monsters.qh>
-
-void PutObserverInServer(entity this);
-
-// =====================================================
-// Server side game commands code, reworked by Samual
-// =====================================================
-
// used by GameCommand_make_mapinfo()
void make_mapinfo_Think(entity this)
{
// 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(FindBestTeam(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;
// Check to see if the destination team is even available
switch (team_id)
{
- case NUM_TEAM_1: if (Team_IsAllowed(Team_GetTeamFromIndex(1))) { LOG_INFO("Sorry, can't move player to red team if it doesn't exist."); return; } break;
- case NUM_TEAM_2: if (Team_IsAllowed(Team_GetTeamFromIndex(2))) { LOG_INFO("Sorry, can't move player to blue team if it doesn't exist."); return; } break;
- case NUM_TEAM_3: if (Team_IsAllowed(Team_GetTeamFromIndex(3))) { LOG_INFO("Sorry, can't move player to yellow team if it doesn't exist."); return; } break;
- case NUM_TEAM_4: if (Team_IsAllowed(Team_GetTeamFromIndex(4))) { 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))
+ 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.");
});
int number_of_teams = 0;
- CheckAllowedTeams(NULL);
- for (int i = 1; i < 5; ++i)
+ entity balance = TeamBalance_CheckAllowedTeams(NULL);
+ for (int i = 1; i <= NUM_TEAMS; ++i)
{
- if (Team_IsAllowed(Team_GetTeamFromIndex(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;
});
if (argc == 4 || argc == 5)
{
e = nextent(NULL);
+ int dphitcontentsmask_save = e.dphitcontentsmask;
+ e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
if (tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), stof(argv(4)), MOVE_NORMAL))
LOG_INFO("can walk");
else
LOG_INFO("cannot walk");
+ e.dphitcontentsmask = dphitcontentsmask_save;
return;
}
}