Teamplay overhaul - step 1
Known issues
- Auto balancing of bots doesn't work in all cases. Deferred to step 2.
The biggest change here is that server-side teams are now entities which makes the code so much better. All fields are hidden behind a documented API so now there are barely any hacks in the code. Most functions no longer modify any global state and have very thorough sanitation of arguments so they should catch much more bugs.
Team indexes are now always preferred to raw team values because team values make no sense and will only be left for map compatibility in the future.
Team balance API now uses a special team balance entity that is created by TeamBalance_CheckAllowedTeams
and destroyed by TeamBalance_Destroy
. This is required to implement correct team balance because balance information can be different for each player and even vary over time without any team changes due to special mutator rules.
New constants
NUM_TEAMS
New functions
Team_TeamToBit
Team_IndexToBit
Team_GetTeamFromIndex
Team_GetTeam
Team_GetTeamScore
Team_SetTeamScore
Team_GetNumberOfAlivePlayers
Team_SetNumberOfAlivePlayers
Team_GetNumberOfAliveTeams
Team_GetNumberOfControlPoints
Team_SetNumberOfControlPoints
Team_GetNumberOfTeamsWithControlPoints
Entity_HasValidTeam
Entity_GetTeamIndex
Entity_GetTeam
Player_SetTeamIndex
TeamBalance_Destroy
TeamBalance_GetAllowedTeams
TeamBalance_IsTeamAllowed
TeamBalance_GetNumberOfPlayers
TeamBalance_CompareTeams
TeamBalance_IsTeamAllowedInternal
TeamBalance_BanTeamsExcept
TeamBalance_GetTeamFromIndex
TeamBalance_GetTeam
TeamBalanceTeam_IsAllowed
TeamBalanceTeam_GetNumberOfPlayers
TeamBalanceTeam_GetNumberOfBots
TeamBalance_CompareTeamsInternal
Changed functions
-
Team_IsValidNumber
becameTeam_IsValidIndex
-
Team_NumberToTeam
becameTeam_IndexToTeam
-
Team_TeamToNumber
becameTeam_TeamToIndex
-
Team_NumberToFullName
becameTeam_IndexToFullName
-
Team_NumberToColoredFullName
becameTeam_IndexToColoredFullName
-
MoveToTeam
now uses team index instead of old team value. This is reflected in the documentation. -
CheckAllowedTeams
becameTeamBalance_CheckAllowedTeams
-
GetTeamCounts
becameTeamBalance_GetTeamCounts
-
FindSmallestTeam
becameTeamBalance_FindBestTeam
-
FindBestTeams
becameTeamBalance_FindBestTeams
-
JoinBestTeam
becameTeamBalance_JoinBestTeam
-
AutoBalanceBots
becameTeamBalance_AutoBalanceBots
Changed hooks
-
CheckAllowedTeams
becameTeamBalance_CheckAllowedTeams
. The return value handling became consistent with other hooks (returntrue
to change default behavior) so it is a little bit faster now. The change is fully documented. -
GetTeamCounts
becameTeamBalance_GetTeamCounts
-
GetTeamCount
becameTeamBalance_GetTeamCount
. It now uses team index instead of old team value. It also no longer handles players with lowest score. This is reflected in the documentation. -
FindBestTeams
becameTeamBalance_FindBestTeams
-
Player_ChangedTeam
now uses team indexes instead of old team values. This is reflected in the documentation.
Removed stuff
-
c1
,c2
,c3
,c4
- the source of the most unmaintainable mess -
num_bots_teamN
,lowest_human_teamN
,lowest_bot_teamN
- same -
teamN_score
superceded byTeam_[GS]etTeamScore
-
redalive
,bluealive
,yellowalive
,pinkalive
superceded byTeam_[GS]etNumberOfAlivePlayers
-
redowned
,blueowned
,yellowowned
,pinkowned
superceded byTeam_[GS]etNumberOfControlPoints
-
PlayerValue
- seemed to be the stub that was never implemented -
SetPlayerTeamSimple
superceded byPlayer_SetTeamIndex
-
IsTeamSmallerThanTeam
,IsTeamEqualToTeam
superceded byTeamBalance_CompareTeams