Skip to content

Teamplay overhaul - step 1

Ghost User requested to merge Lyberta/TeamplayOverhaul into master

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 became Team_IsValidIndex
  • Team_NumberToTeam became Team_IndexToTeam
  • Team_TeamToNumber became Team_TeamToIndex
  • Team_NumberToFullName became Team_IndexToFullName
  • Team_NumberToColoredFullName became Team_IndexToColoredFullName
  • MoveToTeam now uses team index instead of old team value. This is reflected in the documentation.
  • CheckAllowedTeams became TeamBalance_CheckAllowedTeams
  • GetTeamCounts became TeamBalance_GetTeamCounts
  • FindSmallestTeam became TeamBalance_FindBestTeam
  • FindBestTeams became TeamBalance_FindBestTeams
  • JoinBestTeam became TeamBalance_JoinBestTeam
  • AutoBalanceBots became TeamBalance_AutoBalanceBots

Changed hooks

  • CheckAllowedTeams became TeamBalance_CheckAllowedTeams. The return value handling became consistent with other hooks (return true to change default behavior) so it is a little bit faster now. The change is fully documented.
  • GetTeamCounts became TeamBalance_GetTeamCounts
  • GetTeamCount became TeamBalance_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 became TeamBalance_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 by Team_[GS]etTeamScore
  • redalive, bluealive, yellowalive, pinkalive superceded by Team_[GS]etNumberOfAlivePlayers
  • redowned, blueowned, yellowowned, pinkowned superceded by Team_[GS]etNumberOfControlPoints
  • PlayerValue - seemed to be the stub that was never implemented
  • SetPlayerTeamSimple superceded by Player_SetTeamIndex
  • IsTeamSmallerThanTeam, IsTeamEqualToTeam superceded by TeamBalance_CompareTeams
Edited by Ghost User

Merge request reports