SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Enumerations
TeamManager
Plugins

Automates networking and list management for teams. More...

## Classes

struct | SLNet::TeamSelection
| Parameter to TM_World::ReferenceTeamMember() More...
class | SLNet::TM_TeamMember
| A member of one or more teams. More...
class | SLNet::TM_Team
| A team, containing a list of TM_TeamMember instances. More...
class | SLNet::TM_World
| Stores a list of teams which may be enforcing a balanced number of members. More...
class | SLNet::TeamManager
| Automates networking and list management for teams. More...
struct | SLNet::TM_TeamMember::RequestedTeam
struct | SLNet::TM_World::JoinRequestHelper
union | SLNet::TeamSelection.teamParameter

## Typedefs

typedef unsigned char | SLNet::NoTeamId
| A subcategory of not being on a team. For example, 0 may mean no team for a player, while 1 may mean no team for a spectator. Defined by the user.
typedef uint16_t | SLNet::TeamMemberLimit

## Enumerations

enum | SLNet::JoinTeamType { SLNet::JOIN_ANY_AVAILABLE_TEAM, SLNet::JOIN_SPECIFIC_TEAM, SLNet::JOIN_NO_TEAM }
enum | SLNet::TMTopology { SLNet::TM_PEER_TO_PEER, SLNet::TM_CLIENT_SERVER }

## Detailed Description

Automates networking and list management for teams.

When used with ReplicaManager3 and FullyConnectedMesh2, provides a complete solution to managing a distributed list of teams and team member objects with support for host migration.

## Class Documentation

struct SLNet::TeamSelection

Parameter to TM_World::ReferenceTeamMember()

Use TeamSelection::AnyAvailable(), TeamSelection::SpecificTeam(), or TeamSelection::NoTeam()

Definition at line 103 of file TeamManager.h.

### Public Member Functions

| TeamSelection ()
| TeamSelection (JoinTeamType itt)
| TeamSelection (JoinTeamType itt, TM_Team *param)
| TeamSelection (JoinTeamType itt, NoTeamId param)

### Static Public Member Functions

static TeamSelection | AnyAvailable (void)
| Join any team that has available slots and is tagged with ALLOW_JOIN_ANY_AVAILABLE_TEAM.
static TeamSelection | SpecificTeam (TM_Team *specificTeamToJoin)
| Join a specific team if it has available slots, and is tagged with JOIN_SPECIFIC_TEAMS.
static TeamSelection | NoTeam (NoTeamId noTeamSubcategory)
| Do not join a team, or leave all current teams.

### Public Attributes

JoinTeamType | joinTeamType
union {
TM_Team * | specificTeamToJoin
NoTeamId | noTeamSubcategory
} | teamParameter

#### Constructor & Destructor Documentation

SLNet::TeamSelection::TeamSelection | ( |  | ) |

SLNet::TeamSelection::TeamSelection | ( | JoinTeamType | itt | ) |

SLNet::TeamSelection::TeamSelection | ( | JoinTeamType | itt,
|  | TM_Team * | param
| ) |  |

SLNet::TeamSelection::TeamSelection | ( | JoinTeamType | itt,
|  | NoTeamId | param
| ) |  |

#### Member Function Documentation

static TeamSelection SLNet::TeamSelection::AnyAvailable | ( | void |  | ) |

static

Join any team that has available slots and is tagged with ALLOW_JOIN_ANY_AVAILABLE_TEAM.

ID_TEAM_BALANCER_TEAM_ASSIGNED, ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, or ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED will be returned to all systems.

static TeamSelection SLNet::TeamSelection::NoTeam | ( | NoTeamId | noTeamSubcategory | ) |

static

Do not join a team, or leave all current teams.

This always succeeds. ID_TEAM_BALANCER_TEAM_ASSIGNED will be returned to all systems.

Parameters

  [in] | noTeamSubcategory | Even when not on a team, you can internally identify a subcategory of not being on a team, such as AI or spectator.

static TeamSelection SLNet::TeamSelection::SpecificTeam | ( | TM_Team * | specificTeamToJoin | ) |

static

Join a specific team if it has available slots, and is tagged with JOIN_SPECIFIC_TEAMS.

ID_TEAM_BALANCER_TEAM_ASSIGNED, ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, or ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED will be returned to all systems.

Parameters

  [in] | specificTeamToJoin | Which team to attempt to join.

#### Member Data Documentation

JoinTeamType SLNet::TeamSelection::joinTeamType

Definition at line 109 of file TeamManager.h.

union { ... } SLNet::TeamSelection::teamParameter

class SLNet::TM_TeamMember

A member of one or more teams.

Contains data and operations on data to manage which team your game's team members are on. Best used as a composite member of your "User" or "Player" class(es). When using with ReplicaManager3, call TM_TeamMember::ReferenceTeamMember() in Replica3::DeserializeConstruction() and TM_TeamMember::DeserializeConstruction() in Replica3::PostDeserializeConstruction() There is otherwise no need to manually serialize the class, as operations are networked internally.

Definition at line 136 of file TeamManager.h.

### Public Member Functions

| TM_TeamMember ()
virtual | ~TM_TeamMember ()
bool | RequestTeam (TeamSelection teamSelection)
| Request to join any team, a specific team, or to leave all teams.
bool | RequestTeamSwitch (TM_Team *teamToJoin, TM_Team *teamToLeave)
| Similar to RequestTeam with TeamSelection::SpecificTeam(), but leave a team simultaneously when the desired team is joinable.
TeamSelection | GetRequestedTeam (void) const
| Returns the first requested team in the list of requested teams, if you have a requested team at all.
void | GetRequestedSpecificTeams (DataStructures::List< TM_Team * > &requestedTeams) const
| Returns pending calls to RequestTeam() when using TeamSelection::JOIN_SPECIFIC_TEAM.
bool | HasRequestedTeam (TM_Team *team) const
| Returns if the specified team is in the list of pending requested teams.
unsigned int | GetRequestedTeamIndex (TM_Team *team) const
| Returns the index of team in the requested teams list.
unsigned int | GetRequestedTeamCount (void) const
bool | CancelTeamRequest (TM_Team *specificTeamToCancel)
| Cancels a request to join a specific team.
bool | LeaveTeam (TM_Team *team, NoTeamId _noTeamSubcategory)
| Leave a team.
bool | LeaveAllTeams (NoTeamId inNoTeamSubcategory)
| Leave all teams Leaves all teams you are on, and sets noTeamSubcategory.
TM_Team * | GetCurrentTeam (void) const
unsigned int | GetCurrentTeamCount (void) const
TM_Team * | GetCurrentTeamByIndex (unsigned int index)
void | GetCurrentTeams (DataStructures::List< TM_Team * > &_teams) const
void | GetLastTeams (DataStructures::List< TM_Team * > &_teams) const
bool | IsOnTeam (TM_Team *team) const
NetworkID | GetNetworkID (void) const
TM_World * | GetTM_World (void) const
void | SerializeConstruction (BitStream *constructionBitstream)
| Serializes the current state of this object.
bool | DeserializeConstruction (TeamManager *teamManager, BitStream *constructionBitstream)
| Deserializes the current state of this object.
void | SetOwner (void *o)
void * | GetOwner (void) const
NoTeamId | GetNoTeamId (void) const
unsigned int | GetWorldIndex (void) const
| Return world->GetTeamMemberIndex(this)

### Static Public Member Functions

static unsigned long | ToUint32 (const NetworkID &g)

### Protected Member Functions

void | UpdateListsToNoTeam (NoTeamId nti)
bool | JoinAnyTeamCheck (void) const
bool | JoinSpecificTeamCheck (TM_Team *specificTeamToJoin, bool ignoreRequested) const
bool | SwitchSpecificTeamCheck (TM_Team *teamToJoin, TM_Team *teamToLeave, bool ignoreRequested) const
bool | LeaveTeamCheck (TM_Team *team) const
void | UpdateTeamsRequestedToAny (void)
void | UpdateTeamsRequestedToNone (void)
void | AddToRequestedTeams (TM_Team *teamToJoin)
void | AddToRequestedTeams (TM_Team *teamToJoin, TM_Team *teamToLeave)
bool | RemoveFromRequestedTeams (TM_Team *team)
void | AddToTeamList (TM_Team *team)
void | RemoveFromSpecificTeamInternal (TM_Team *team)
void | RemoveFromAllTeamsInternal (void)
void | StoreLastTeams (void)

### Protected Attributes

NetworkID | networkId
TM_World * | world
DataStructures::List< TM_Team * > | teams
NoTeamId | noTeamSubcategory
DataStructures::List < RequestedTeam > | teamsRequested
JoinTeamType | joinTeamType
DataStructures::List< TM_Team * > | lastTeams
SLNet::Time | whenJoinAnyRequested
unsigned int | joinAnyRequestIndex
void * | owner

#### Constructor & Destructor Documentation

SLNet::TM_TeamMember::TM_TeamMember | ( |  | ) |

virtual SLNet::TM_TeamMember::~TM_TeamMember | ( |  | ) |

virtual

#### Member Function Documentation

void SLNet::TM_TeamMember::AddToRequestedTeams | ( | TM_Team * | teamToJoin | ) |

protected

void SLNet::TM_TeamMember::AddToRequestedTeams | ( | TM_Team * | teamToJoin,
|  | TM_Team * | teamToLeave
| ) |  |

protected

void SLNet::TM_TeamMember::AddToTeamList | ( | TM_Team * | team | ) |

protected

bool SLNet::TM_TeamMember::CancelTeamRequest | ( | TM_Team * | specificTeamToCancel | ) |

Cancels a request to join a specific team.

Useful if you got ID_TEAM_BALANCER_REQUESTED_TEAM_FULL or ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED and changed your mind about joining the team.

Note
  This is not guaranteed to work due to latency. To clarify, If the host switches your team at the same time you call CancelRequestTeam() you may still get ID_TEAM_BALANCER_TEAM_ASSIGNED for the team you tried to cancel.

Parameters

  [in] | specificTeamToCancel | Which team to no longer join. Use 0 for all.

Returns
  false On invalid or unnecessary operation. Otherwise returns true

bool SLNet::TM_TeamMember::DeserializeConstruction | ( | TeamManager * | teamManager,
|  | BitStream * | constructionBitstream
| ) |  |

Deserializes the current state of this object.

See SerializeConstruction for more details()

Note
  DeserializeConstruction also calls ReferenceTeamMember on the passed teamManager instance, there is no need to do so yourself

Parameters

  [in] | teamManager | TeamManager instance
  [in] | constructionBitstream | This object serialized to a BitStream

TM_Team* SLNet::TM_TeamMember::GetCurrentTeam | ( | void |  | ) | const

Returns
  Get the first team we are on, or 0 if we are not on a team.

TM_Team* SLNet::TM_TeamMember::GetCurrentTeamByIndex | ( | unsigned int | index | ) |

Returns
  Returns one of the teams in the current team list, up to GetCurrentTeamCount()

unsigned int SLNet::TM_TeamMember::GetCurrentTeamCount | ( | void |  | ) | const

Returns
  How many teams we are on

void SLNet::TM_TeamMember::GetCurrentTeams | ( | DataStructures::List< TM_Team * > & | _teams | ) | const

Parameters

  [out] | Get | all teams we are on, as a list

void SLNet::TM_TeamMember::GetLastTeams | ( | DataStructures::List< TM_Team * > & | _teams | ) | const

For each team member, when you get ID_TEAM_BALANCER_TEAM_ASSIGNED for that member, the team list is saved. Use this function to get that list, for example to determine which teams we just left or joined

Parameters

  [out] | _teams | The previous list of teams we were on

NetworkID SLNet::TM_TeamMember::GetNetworkID | ( | void |  | ) | const

Returns
  The teamMemberID parameter passed to TM_World::ReferenceTeamMember()

NoTeamId SLNet::TM_TeamMember::GetNoTeamId | ( | void |  | ) | const

Returns
  If not on a team, returns the current NoTeamId value

void* SLNet::TM_TeamMember::GetOwner | ( | void |  | ) | const

Returns
  Whatever was passed to SetOwner()

void SLNet::TM_TeamMember::GetRequestedSpecificTeams | ( | DataStructures::List< TM_Team * > & | requestedTeams | ) | const

Returns pending calls to RequestTeam() when using TeamSelection::JOIN_SPECIFIC_TEAM.

Parameters

  [out] | All | pending requested teams

TeamSelection SLNet::TM_TeamMember::GetRequestedTeam | ( | void |  | ) | const

Returns the first requested team in the list of requested teams, if you have a requested team at all.

Returns
  TeamSelection::SpecificTeam(), TeamSelection::NoTeam(), or TeamSelection::AnyAvailable()

unsigned int SLNet::TM_TeamMember::GetRequestedTeamCount | ( | void |  | ) | const

Returns
  The number of teams that would be returned by a call to GetRequestedSpecificTeams()

unsigned int SLNet::TM_TeamMember::GetRequestedTeamIndex | ( | TM_Team * | team | ) | const

Returns the index of team in the requested teams list.

Parameters

  [in] | The | team we are checking

Returns
  -1 if we did not requested to join this team. Otherwise the index.

TM_World* SLNet::TM_TeamMember::GetTM_World | ( | void |  | ) | const

Returns
  The TM_World instance that was used when calling TM_World::ReferenceTeamMember()

unsigned int SLNet::TM_TeamMember::GetWorldIndex | ( | void |  | ) | const

Return world->GetTeamMemberIndex(this)

bool SLNet::TM_TeamMember::HasRequestedTeam | ( | TM_Team * | team | ) | const

Returns if the specified team is in the list of pending requested teams.

Parameters

  [in] | The | team we are checking

Returns
  Did we request to join this specific team?

bool SLNet::TM_TeamMember::IsOnTeam | ( | TM_Team * | team | ) | const

Parameters

  [in] | The | team we are checking

Returns
  Are we on this team?

bool SLNet::TM_TeamMember::JoinAnyTeamCheck | ( | void |  | ) | const

protected

bool SLNet::TM_TeamMember::JoinSpecificTeamCheck | ( | TM_Team * | specificTeamToJoin,
|  | bool | ignoreRequested
| ) |  | const

protected

bool SLNet::TM_TeamMember::LeaveAllTeams | ( | NoTeamId | inNoTeamSubcategory | ) |

Leave all teams Leaves all teams you are on, and sets noTeamSubcategory.

Note
  This is the same as and just calls RequestTeam(TeamSelection::NoTeam(noTeamSubcategory));

Returns
  false On invalid or unnecessary operation. Otherwise returns true

bool SLNet::TM_TeamMember::LeaveTeam | ( | TM_Team * | team,
|  | NoTeamId | _noTeamSubcategory
| ) |  |

Leave a team.

Leaves a team that you are on. Always succeeds provided you are on that team Generates ID_TEAM_BALANCER_TEAM_ASSIGNED on all systems on success. If you leave the last team you are on, noTeamSubcategory is set as well.

Parameters

  [in] | team | Which team to leave
  [in] | _noTeamSubcategory | If the team member has been removed from all teams, which subcategory of NoTeamId to set them to

Returns
  false On invalid or unnecessary operation. Otherwise returns true

bool SLNet::TM_TeamMember::LeaveTeamCheck | ( | TM_Team * | team | ) | const

protected

void SLNet::TM_TeamMember::RemoveFromAllTeamsInternal | ( | void |  | ) |

protected

bool SLNet::TM_TeamMember::RemoveFromRequestedTeams | ( | TM_Team * | team | ) |

protected

void SLNet::TM_TeamMember::RemoveFromSpecificTeamInternal | ( | TM_Team * | team | ) |

protected

bool SLNet::TM_TeamMember::RequestTeam | ( | TeamSelection | teamSelection | ) |

Request to join any team, a specific team, or to leave all teams.

Function will return false on invalid operations, such as joining a team you are already on. Will also fail with TeamSelection::JOIN_ANY_AVAILABLE_TEAM if you are currently on a team. On success, every system will get ID_TEAM_BALANCER_TEAM_ASSIGNED. Use TeamManager::DecomposeTeamAssigned() to get details of which team member the message refers to. On failure, all systems will get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL or ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED. Use TeamManager::DecomposeTeamFull() and TeamManager::DecomposeTeamLocked() to get details of which team member the message refers to.

Note
  Joining a specific team with this function may result in being on more than one team at once, even if you call the function while locally only on one team. If your game depends on only being on one team at a team, use RequestTeamSwitch() instead with the parameter teamToLeave set to 0

Parameters

  [in] | TeamSelection::AnyAvailable(),TeamSelection::SpecificTeam(),or | TeamSelection::NoTeam()

Returns
  false On invalid or unnecessary operation. Otherwise returns true

bool SLNet::TM_TeamMember::RequestTeamSwitch | ( | TM_Team * | teamToJoin,
|  | TM_Team * | teamToLeave
| ) |  |

Similar to RequestTeam with TeamSelection::SpecificTeam(), but leave a team simultaneously when the desired team is joinable.

Parameters

  [in] | teamToJoin | Which team to join
  [in] | teamToLeave | If 0, means leave all current teams. Otherwise, leave the specified team.

Returns
  false On invalid or unnecessary operation. Otherwise returns true

void SLNet::TM_TeamMember::SerializeConstruction | ( | BitStream * | constructionBitstream | ) |

Serializes the current state of this object.

To replicate a TM_TeamMember on another system, first instantiate the object using your own code, or a system such as ReplicaManager3. Next, call SerializeConstruction() from whichever system owns the team member Last, call DeserializeConstruction() on the newly created TM_TeamMember

Note
  You must instantiate and deserialize all TM_Team instances that the team member refers to before calling DesrializeConstruction(). ReplicaManager3::PostSerializeConstruction() and ReplicaManager3::PostDeserializeConstruction() will ensure this.

Parameters

  [out] | constructionBitstream | This object serialized to a BitStream

void SLNet::TM_TeamMember::SetOwner | ( | void * | o | ) |

Parameters

  [in] | o | Stores a void* for your own use. If using composition, this is useful to store a pointer to the containing object.

void SLNet::TM_TeamMember::StoreLastTeams | ( | void |  | ) |

protected

bool SLNet::TM_TeamMember::SwitchSpecificTeamCheck | ( | TM_Team * | teamToJoin,
|  | TM_Team * | teamToLeave,
|  | bool | ignoreRequested
| ) |  | const

protected

static unsigned long SLNet::TM_TeamMember::ToUint32 | ( | const NetworkID & | g | ) |

static

void SLNet::TM_TeamMember::UpdateListsToNoTeam | ( | NoTeamId | nti | ) |

protected

void SLNet::TM_TeamMember::UpdateTeamsRequestedToAny | ( | void |  | ) |

protected

void SLNet::TM_TeamMember::UpdateTeamsRequestedToNone | ( | void |  | ) |

protected

#### Member Data Documentation

unsigned int SLNet::TM_TeamMember::joinAnyRequestIndex

protected

Definition at line 286 of file TeamManager.h.

JoinTeamType SLNet::TM_TeamMember::joinTeamType

protected

Definition at line 282 of file TeamManager.h.

DataStructures::List<TM_Team*> SLNet::TM_TeamMember::lastTeams

protected

Definition at line 284 of file TeamManager.h.

NetworkID SLNet::TM_TeamMember::networkId

protected

Definition at line 272 of file TeamManager.h.

NoTeamId SLNet::TM_TeamMember::noTeamSubcategory

protected

Definition at line 277 of file TeamManager.h.

void* SLNet::TM_TeamMember::owner

protected

Definition at line 287 of file TeamManager.h.

DataStructures::List<TM_Team*> SLNet::TM_TeamMember::teams

protected

Definition at line 275 of file TeamManager.h.

DataStructures::List<RequestedTeam> SLNet::TM_TeamMember::teamsRequested

protected

Definition at line 279 of file TeamManager.h.

SLNet::Time SLNet::TM_TeamMember::whenJoinAnyRequested

protected

Definition at line 285 of file TeamManager.h.

TM_World* SLNet::TM_TeamMember::world

protected

Definition at line 273 of file TeamManager.h.

class SLNet::TM_Team

A team, containing a list of TM_TeamMember instances.

Contains lists of TM_TeamMember instances Best used as a composite member of your "Team" or "PlayerList" class(es). When using with ReplicaManager3, call TM_Team::ReferenceTeam() in Replica3::DeserializeConstruction() and TM_Team::DeserializeConstruction() in Replica3::PostDeserializeConstruction() There is otherwise no need to manually serialize the class, as operations are networked internally.

Definition at line 316 of file TeamManager.h.

### Public Member Functions

| TM_Team ()
virtual | ~TM_Team ()
bool | SetMemberLimit (TeamMemberLimit _teamMemberLimit, NoTeamId noTeamSubcategory)

Set the maximum number of members that can join this team. Defaults to 65535 Setting the limit lower than the existing number of members kicks members out, and assigns noTeamSubcategory to them if they have no other team to go to Setting the limit higher allows members to join in. If a member has a pending request to join this team, they join automatically and ID_TEAM_BALANCER_TEAM_ASSIGNED will be returned for those members.

TeamMemberLimit | GetMemberLimit (void) const
TeamMemberLimit | GetMemberLimitSetting (void) const
bool | SetJoinPermissions (JoinPermissions _joinPermissions)
| Who can join this team under what conditions, while the team is not full To not allow new joins, pass 0 To allow all new joins under any circumstances, bitwise-OR all permission defines. For an invite-only team, use ALLOW_JOIN_SPECIFIC_TEAM only and only allow the requester to call TM_TeamMember::RequestTeam() upon invitiation through your game code. Defaults to allow all.
JoinPermissions | GetJoinPermissions (void) const
void | LeaveTeam (TM_TeamMember *teamMember, NoTeamId noTeamSubcategory)
| Removes a member from a team he or she is on.
bool | GetBalancingApplies (void) const
void | GetTeamMembers (DataStructures::List< TM_TeamMember * > &_teamMembers) const
unsigned int | GetTeamMembersCount (void) const
TM_TeamMember * | GetTeamMemberByIndex (unsigned int index) const
NetworkID | GetNetworkID (void) const
TM_World * | GetTM_World (void) const
void | SerializeConstruction (BitStream *constructionBitstream)
| Used by the host to serialize the initial state of this object to a new system.
bool | DeserializeConstruction (TeamManager *teamManager, BitStream *constructionBitstream)
| Used by non-host systems to read the bitStream written by SerializeConstruction()
void | SetOwner (void *o)
void * | GetOwner (void) const
unsigned int | GetWorldIndex (void) const
| Return world->GetTeamIndex(this)

### Static Public Member Functions

static unsigned long | ToUint32 (const NetworkID &g)

### Protected Member Functions

void | RemoveFromTeamMemberList (TM_TeamMember *teamMember)
unsigned int | GetMemberWithRequestedSingleTeamSwitch (TM_Team *team)

### Protected Attributes

NetworkID | ID
TM_World * | world
DataStructures::List < TM_TeamMember * > | teamMembers
JoinPermissions | joinPermissions
bool | balancingApplies
TeamMemberLimit | teamMemberLimit
void * | owner

#### Constructor & Destructor Documentation

SLNet::TM_Team::TM_Team | ( |  | ) |

virtual SLNet::TM_Team::~TM_Team | ( |  | ) |

virtual

#### Member Function Documentation

bool SLNet::TM_Team::DeserializeConstruction | ( | TeamManager * | teamManager,
|  | BitStream * | constructionBitstream
| ) |  |

Used by non-host systems to read the bitStream written by SerializeConstruction()

On non-host systems, after creating existing objects, call DeserializeConstruction() to read and setup that object Creating the actual Team and TeamMember objects should be handled by your game code, or a system such as ReplicaManager3

bool SLNet::TM_Team::GetBalancingApplies | ( | void |  | ) | const

Returns
  What was passed as the applyBalancing parameter TM_World::ReferenceTeam() when this team was added.

JoinPermissions SLNet::TM_Team::GetJoinPermissions | ( | void |  | ) | const

Returns
  Whatever was passed to SetJoinPermissions(), or the default.

TeamMemberLimit SLNet::TM_Team::GetMemberLimit | ( | void |  | ) | const

Returns
  If team balancing is on, the most members that can be on this team that would not either unbalance it or exceed the value passed to SetMemberLimit(). If team balancing is off, the same as GetMemberLimitSetting()

TeamMemberLimit SLNet::TM_Team::GetMemberLimitSetting | ( | void |  | ) | const

Returns
  What was passed to SetMemberLimit() or the default

unsigned int SLNet::TM_Team::GetMemberWithRequestedSingleTeamSwitch | ( | TM_Team * | team | ) |

protected

NetworkID SLNet::TM_Team::GetNetworkID | ( | void |  | ) | const

Returns
  The teamID parameter passed to TM_World::ReferenceTeam()

void* SLNet::TM_Team::GetOwner | ( | void |  | ) | const

Returns
  Whatever was passed to SetOwner()

TM_TeamMember* SLNet::TM_Team::GetTeamMemberByIndex | ( | unsigned int | index | ) | const

Returns
  A team member on this team. Members are stored in the order they are added

Parameters

  [in] | index | A value between 0 and GetTeamMembersCount()

void SLNet::TM_Team::GetTeamMembers | ( | DataStructures::List< TM_TeamMember * > & | _teamMembers | ) | const

Parameters

  [out] | All | team members of this team

unsigned int SLNet::TM_Team::GetTeamMembersCount | ( | void |  | ) | const

Returns
  The number of team members on this team

TM_World* SLNet::TM_Team::GetTM_World | ( | void |  | ) | const

Returns
  The TM_World instance that was used when calling TM_World::ReferenceTeamMember()

unsigned int SLNet::TM_Team::GetWorldIndex | ( | void |  | ) | const

Return world->GetTeamIndex(this)

void SLNet::TM_Team::LeaveTeam | ( | TM_TeamMember * | teamMember,
|  | NoTeamId | noTeamSubcategory
| ) |  |

Removes a member from a team he or she is on.

Identical to teamMember->LeaveTeam(this, noTeamSubcategory); See TeamMember::LeaveTeam() for details.

Parameters

  [in] | teamMember | Which team member to remove
  [in] | noTeamSubcategory | If the team member has been removed from all teams, which subcategory of NoTeamId to set them to

void SLNet::TM_Team::RemoveFromTeamMemberList | ( | TM_TeamMember * | teamMember | ) |

protected

void SLNet::TM_Team::SerializeConstruction | ( | BitStream * | constructionBitstream | ) |

Used by the host to serialize the initial state of this object to a new system.

On the host, when sending existing objects to a new system, call SerializeConstruction() on each of those objects to serialize creation state. Creating the actual Team and TeamMember objects should be handled by your game code, or a system such as ReplicaManager3

bool SLNet::TM_Team::SetJoinPermissions | ( | JoinPermissions | _joinPermissions | ) |

Who can join this team under what conditions, while the team is not full To not allow new joins, pass 0 To allow all new joins under any circumstances, bitwise-OR all permission defines. For an invite-only team, use ALLOW_JOIN_SPECIFIC_TEAM only and only allow the requester to call TM_TeamMember::RequestTeam() upon invitiation through your game code. Defaults to allow all.

Parameters

  [in] | _joinPermissions | Bitwise combination of ALLOW_JOIN_ANY_AVAILABLE_TEAM, ALLOW_JOIN_SPECIFIC_TEAM, ALLOW_JOIN_REBALANCING

Returns
  false On invalid or unnecessary operation. Otherwise returns true

bool SLNet::TM_Team::SetMemberLimit | ( | TeamMemberLimit | _teamMemberLimit,
|  | NoTeamId | noTeamSubcategory
| ) |  |

Set the maximum number of members that can join this team. Defaults to 65535 Setting the limit lower than the existing number of members kicks members out, and assigns noTeamSubcategory to them if they have no other team to go to Setting the limit higher allows members to join in. If a member has a pending request to join this team, they join automatically and ID_TEAM_BALANCER_TEAM_ASSIGNED will be returned for those members.

Parameters

  [in] | _teamMemberLimit | The new limit
  [in] | noTeamSubcategory | Which noTeamSubcategory to assign to members that now have no team.

Returns
  false On invalid or unnecessary operation. Otherwise returns true

void SLNet::TM_Team::SetOwner | ( | void * | o | ) |

Parameters

  [in] | o | Stores a void* for your own use. If using composition, this is useful to store a pointer to the containing object.

static unsigned long SLNet::TM_Team::ToUint32 | ( | const NetworkID & | g | ) |

static

#### Member Data Documentation

bool SLNet::TM_Team::balancingApplies

protected

Definition at line 407 of file TeamManager.h.

NetworkID SLNet::TM_Team::ID

protected

Definition at line 400 of file TeamManager.h.

JoinPermissions SLNet::TM_Team::joinPermissions

protected

Definition at line 405 of file TeamManager.h.

void* SLNet::TM_Team::owner

protected

Definition at line 409 of file TeamManager.h.

TeamMemberLimit SLNet::TM_Team::teamMemberLimit

protected

Definition at line 408 of file TeamManager.h.

DataStructures::List<TM_TeamMember*> SLNet::TM_Team::teamMembers

protected

Definition at line 403 of file TeamManager.h.

TM_World* SLNet::TM_Team::world

protected

Definition at line 401 of file TeamManager.h.

class SLNet::TM_World

Stores a list of teams which may be enforcing a balanced number of members.

Each TM_World instance is independent of other TM_World world instances. This enables you to host multiple games on a single computer. Not currently supported to have the same TM_Team or TM_TeamMember in more than one world at a time, but easily added on request.

Definition at line 427 of file TeamManager.h.

### Public Member Functions

| TM_World ()
virtual | ~TM_World ()
TeamManager * | GetTeamManager (void) const
void | AddParticipant (RakNetGUID rakNetGUID)
| Add a new system to send team and team member updates to.
void | RemoveParticipant (RakNetGUID rakNetGUID)
| Remove a system that was previously added with AddParticipant()
void | SetAutoManageConnections (bool autoAdd)
| If true, all new connections are added to this world using AddParticipant()
void | GetParticipantList (DataStructures::List< RakNetGUID > &participantList)
void | ReferenceTeam (TM_Team *team, NetworkID networkId, bool applyBalancing)
| Register a TM_Team object with this system.
void | DereferenceTeam (TM_Team *team, NoTeamId noTeamSubcategory)
| Unregisters the associated TM_Team object with this system. Call when a TM_Team instance is no longer needed.
unsigned int | GetTeamCount (void) const
TM_Team * | GetTeamByIndex (unsigned int index) const
TM_Team * | GetTeamByNetworkID (NetworkID teamId)
unsigned int | GetTeamIndex (const TM_Team *team) const
| Inverse of GetTeamByIndex()
void | ReferenceTeamMember (TM_TeamMember *teamMember, NetworkID networkId)
| Register a TM_TeamMember object with this system.
void | DereferenceTeamMember (TM_TeamMember *teamMember)
| Unregisters the associated TM_TeamMember object with this system. Call when a TM_TeamMember instance is no longer needed.
unsigned int | GetTeamMemberCount (void) const
TM_TeamMember * | GetTeamMemberByIndex (unsigned int index) const
NetworkID | GetTeamMemberIDByIndex (unsigned int index) const
TM_TeamMember * | GetTeamMemberByNetworkID (NetworkID teamMemberId)
unsigned int | GetTeamMemberIndex (const TM_TeamMember *teamMember) const
| Inverse of GetTeamMemberByIndex()
bool | SetBalanceTeams (bool balanceTeams, NoTeamId noTeamSubcategory)
| Force or stop forcing teams to be balanced.
bool | GetBalanceTeams (void) const
void | SetHost (RakNetGUID _hostGuid)
| Set the host that will perform balancing calculations and send notifications.
RakNetGUID | GetHost (void) const
WorldId | GetWorldId (void) const
void | Clear (void)
| Clear all memory and reset everything.

### Static Public Member Functions

static int | JoinRequestHelperComp (const TM_World::JoinRequestHelper &key, const TM_World::JoinRequestHelper &data)

### Protected Member Functions

virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
void | EnforceTeamBalance (NoTeamId noTeamSubcategory)
void | KickExcessMembers (NoTeamId noTeamSubcategory)
void | FillRequestedSlots (void)
unsigned int | GetAvailableTeamIndexWithFewestMembers (TeamMemberLimit secondaryLimit, JoinPermissions joinPermissions)
void | GetSortedJoinRequests (DataStructures::OrderedList< JoinRequestHelper, JoinRequestHelper, JoinRequestHelperComp > &joinRequests)
void | BroadcastToParticipants (SLNet::BitStream *bsOut, RakNetGUID exclusionGuid)
void | BroadcastToParticipants (unsigned char *data, const int length, RakNetGUID exclusionGuid)
TM_Team * | JoinAnyTeam (TM_TeamMember *teamMember, int *resultCode)
int | JoinSpecificTeam (TM_TeamMember *teamMember, TM_Team *team, bool isTeamSwitch, TM_Team *teamToLeave, DataStructures::List< TM_Team * > &teamsWeAreLeaving)
TeamMemberLimit | GetBalancedTeamLimit (void) const

### Protected Attributes

DataStructures::Hash < NetworkID, TM_Team *, 256, TM_Team::ToUint32 > | teamsHash
DataStructures::Hash < NetworkID, TM_TeamMember *, 256, TM_TeamMember::ToUint32 > | teamMembersHash
TeamManager * | teamManager
DataStructures::List< RakNetGUID > | participants
DataStructures::List< TM_Team * > | teams
DataStructures::List < TM_TeamMember * > | teamMembers
bool | balanceTeamsIsActive
RakNetGUID | hostGuid
WorldId | worldId
bool | autoAddParticipants
int | teamRequestIndex

#### Constructor & Destructor Documentation

SLNet::TM_World::TM_World | ( |  | ) |

virtual SLNet::TM_World::~TM_World | ( |  | ) |

virtual

#### Member Function Documentation

void SLNet::TM_World::AddParticipant | ( | RakNetGUID | rakNetGUID | ) |

Add a new system to send team and team member updates to.

Parameters

  [in] | rakNetGUID | GUID of the system you are adding. See Packet::rakNetGUID or RakPeerInterface::GetGUIDFromSystemAddress()

void SLNet::TM_World::BroadcastToParticipants | ( | SLNet::BitStream * | bsOut,
|  | RakNetGUID | exclusionGuid
| ) |  |

protected

void SLNet::TM_World::BroadcastToParticipants | ( | unsigned char * | data,
|  | const int | length,
|  | RakNetGUID | exclusionGuid
| ) |  |

protected

void SLNet::TM_World::Clear | ( | void |  | ) |

Clear all memory and reset everything.

It is up to the user to deallocate pointers passed to ReferenceTeamMember() or ReferenceTeam(), if so desired.

void SLNet::TM_World::DereferenceTeam | ( | TM_Team * | team,
|  | NoTeamId | noTeamSubcategory
| ) |  |

Unregisters the associated TM_Team object with this system. Call when a TM_Team instance is no longer needed.

Parameters

  [in] | team | Which team instance to unregister
  [in] | noTeamSubcategory | All players on this team are kicked off. If these players then have no team, they are set to this no team category.

void SLNet::TM_World::DereferenceTeamMember | ( | TM_TeamMember * | teamMember | ) |

Unregisters the associated TM_TeamMember object with this system. Call when a TM_TeamMember instance is no longer needed.

Note
  This is called by the destructor of TM_TeamMember automatically, so you do not normally need to call this function

void SLNet::TM_World::EnforceTeamBalance | ( | NoTeamId | noTeamSubcategory | ) |

protected

void SLNet::TM_World::FillRequestedSlots | ( | void |  | ) |

protected

unsigned int SLNet::TM_World::GetAvailableTeamIndexWithFewestMembers | ( | TeamMemberLimit | secondaryLimit,
|  | JoinPermissions | joinPermissions
| ) |  |

protected

TeamMemberLimit SLNet::TM_World::GetBalancedTeamLimit | ( | void |  | ) | const

protected

bool SLNet::TM_World::GetBalanceTeams | ( | void |  | ) | const

Returns
  balanceTeams parameter of SetBalanceTeams(), or the default

RakNetGUID SLNet::TM_World::GetHost | ( | void |  | ) | const

Returns
  Returns the current host, or UNASSIGNED_RAKNET_GUID if unknown

void SLNet::TM_World::GetParticipantList | ( | DataStructures::List< RakNetGUID > & | participantList | ) |

Get the participants added with AddParticipant()

Parameters

  [out] | participantList | Participants added with AddParticipant();

void SLNet::TM_World::GetSortedJoinRequests | ( | DataStructures::OrderedList< JoinRequestHelper, JoinRequestHelper, JoinRequestHelperComp > & | joinRequests | ) |

protected

TM_Team* SLNet::TM_World::GetTeamByIndex | ( | unsigned int | index | ) | const

Parameters

  [in] | index | A value between 0 and GetTeamCount()

Returns
  Returns whatever was passed to team in the function ReferenceTeam() in the order it was called.

TM_Team* SLNet::TM_World::GetTeamByNetworkID | ( | NetworkID | teamId | ) |

Parameters

  [in] | teamId | Value passed to ReferenceTeam()

Returns
  Returns whatever was passed to team in the function ReferenceTeam() with this NetworkID.

unsigned int SLNet::TM_World::GetTeamCount | ( | void |  | ) | const

Returns
  Number of teams uniquely added with ReferenceTeam()

unsigned int SLNet::TM_World::GetTeamIndex | ( | const TM_Team * | team | ) | const

Inverse of GetTeamByIndex()

Parameters

  [in] | team | Which taem

Returns
  The index of the specified team, or -1 if not found

TeamManager* SLNet::TM_World::GetTeamManager | ( | void |  | ) | const

Returns
  Returns the plugin that created this TM_World instance

TM_TeamMember* SLNet::TM_World::GetTeamMemberByIndex | ( | unsigned int | index | ) | const

Parameters

  [in] | index | A value between 0 and GetTeamMemberCount()

Returns
  Returns whatever was passed to team in the function ReferenceTeamMember() in the order it was called.

TM_TeamMember* SLNet::TM_World::GetTeamMemberByNetworkID | ( | NetworkID | teamMemberId | ) |

Parameters

  [in] | teamId | Value passed to ReferenceTeamMember()

Returns
  Returns Returns whatever was passed to team in the function ReferenceTeamMember() with this NetworkID

unsigned int SLNet::TM_World::GetTeamMemberCount | ( | void |  | ) | const

Returns
  Number of team members uniquely added with ReferenceTeamMember()

NetworkID SLNet::TM_World::GetTeamMemberIDByIndex | ( | unsigned int | index | ) | const

Parameters

  [in] | index | A value between 0 and GetTeamMemberCount()

Returns
  Returns whatever was passed to teamMemberID in the function ReferenceTeamMember() in the order it was called.

unsigned int SLNet::TM_World::GetTeamMemberIndex | ( | const TM_TeamMember * | teamMember | ) | const

Inverse of GetTeamMemberByIndex()

Parameters

  [in] | team | Which team member

Returns
  The index of the specified team member, or -1 if not found

WorldId SLNet::TM_World::GetWorldId | ( | void |  | ) | const

Returns
  The worldId passed to TeamManagr::AddWorld()

TM_Team* SLNet::TM_World::JoinAnyTeam | ( | TM_TeamMember * | teamMember,
|  | int * | resultCode
| ) |  |

protected

static int SLNet::TM_World::JoinRequestHelperComp | ( | const TM_World::JoinRequestHelper & | key,
|  | const TM_World::JoinRequestHelper & | data
| ) |  |

static

int SLNet::TM_World::JoinSpecificTeam | ( | TM_TeamMember * | teamMember,
|  | TM_Team * | team,
|  | bool | isTeamSwitch,
|  | TM_Team * | teamToLeave,
|  | DataStructures::List< TM_Team * > & | teamsWeAreLeaving
| ) |  |

protected

void SLNet::TM_World::KickExcessMembers | ( | NoTeamId | noTeamSubcategory | ) |

protected

virtual void SLNet::TM_World::OnClosedConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason
| ) |  |

protectedvirtual

virtual void SLNet::TM_World::OnNewConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | bool | isIncoming
| ) |  |

protectedvirtual

void SLNet::TM_World::ReferenceTeam | ( | TM_Team * | team,
|  | NetworkID | networkId,
|  | bool | applyBalancing
| ) |  |

Register a TM_Team object with this system.

Your game should contain instances of TM_Team, for example by using composition with your game's Team or PlayerList class Tell TeamManager about these instances using ReferenceTeam().

Note
  The destrutor of TM_Team calls DereferenceTeam() automatically.

Parameters

  [in] | team | The instance you are registering
  [in] | networkId | Identifies this instance. This value is independent of values used by NetworkIDManager. You can use the same value as the object that contains this instance.
  [in] | applyBalancing | Whether or not to include this team for balancing when calling SetBalanceTeams().

void SLNet::TM_World::ReferenceTeamMember | ( | TM_TeamMember * | teamMember,
|  | NetworkID | networkId
| ) |  |

Register a TM_TeamMember object with this system.

Your game should contain instances of TM_TeamMember, for example by using composition with your game's User or Player classes Tell TeamManager about these instances using ReferenceTeamMember().

Note
  The destrutor of TM_TeamMember calls DereferenceTeamMember() automatically.

Parameters

  [in] | teamMember | The instance you are registering
  [in] | networkId | Identifies this instance. This value is independent of values used by NetworkIDManager. You can use the same value as the object that contains this instance

void SLNet::TM_World::RemoveParticipant | ( | RakNetGUID | rakNetGUID | ) |

Remove a system that was previously added with AddParticipant()

Systems that disconnect are removed automatically

Parameters

  [in] | rakNetGUID | GUID of the system you are removing. See Packet::rakNetGUID or RakPeerInterface::GetGUIDFromSystemAddress()

void SLNet::TM_World::SetAutoManageConnections | ( | bool | autoAdd | ) |

If true, all new connections are added to this world using AddParticipant()

Defaults to true

Parameters

  [in] | autoAdd | Setting to set

bool SLNet::TM_World::SetBalanceTeams | ( | bool | balanceTeams,
|  | NoTeamId | noTeamSubcategory
| ) |  |

Force or stop forcing teams to be balanced.

For each team added with ReferenceTeam() and applyBalancing set to true, players on unbalanced teams will be redistributed While active, players can only join balanced teams if doing so would not cause that team to become unbalanced. If a player on the desired team also wants to switch, then both players will switch simultaneously. Otherwise, ID_TEAM_BALANCER_REQUESTED_TEAM_FULL will be returned to the requester and switching will occur when possible. If balanceTeams is true and later set to false, players waiting on ID_TEAM_BALANCER_REQUESTED_TEAM_FULL will be able to join the desired team immediately provided it is not full.

Parameters

  [in] | balanceTeams | Whether to activate or deactivate team balancing.
  [in] | noTeamSubcategory | If a player is kicked off a team and is no longer on any team, his or her noTeamSubcategory is set to this value

void SLNet::TM_World::SetHost | ( | RakNetGUID | _hostGuid | ) |

Set the host that will perform balancing calculations and send notifications.

Operations that can cause conflicts due to latency, such as joining teams, are operated on by the host. The result is sent to all systems added with AddParticipant() For a client/server game, call SetHost() with the server's RakNetGUID value on all systems (including the server itself). If you call TeamManager::SetTopology(TM_CLIENT_SERVER), the server will also relay messages between participants. For a peer to peer game, call SetHost() on the same peer when host migration occurs. Use TeamManager::SetTopology(TM_PEER_TO_PEER) in this case.

Note
  If using FullyConnectedMesh2, SetHost() is called automatically when ID_FCM2_NEW_HOST is returned.

Parameters

  [in] | _hostGuid | The host, which is the system that will serialize and resolve team disputes and calculate team balancing.

#### Member Data Documentation

bool SLNet::TM_World::autoAddParticipants

protected

Definition at line 599 of file TeamManager.h.

bool SLNet::TM_World::balanceTeamsIsActive

protected

Definition at line 596 of file TeamManager.h.

RakNetGUID SLNet::TM_World::hostGuid

protected

Definition at line 597 of file TeamManager.h.

DataStructures::List<RakNetGUID> SLNet::TM_World::participants

protected

Definition at line 593 of file TeamManager.h.

TeamManager* SLNet::TM_World::teamManager

protected

Definition at line 592 of file TeamManager.h.

DataStructures::List<TM_TeamMember*> SLNet::TM_World::teamMembers

protected

Definition at line 595 of file TeamManager.h.

DataStructures::Hash<NetworkID, TM_TeamMember*, 256, TM_TeamMember::ToUint32> SLNet::TM_World::teamMembersHash

protected

Definition at line 590 of file TeamManager.h.

int SLNet::TM_World::teamRequestIndex

protected

Definition at line 600 of file TeamManager.h.

DataStructures::List<TM_Team*> SLNet::TM_World::teams

protected

Definition at line 594 of file TeamManager.h.

DataStructures::Hash<NetworkID, TM_Team*, 256, TM_Team::ToUint32> SLNet::TM_World::teamsHash

protected

Definition at line 588 of file TeamManager.h.

WorldId SLNet::TM_World::worldId

protected

Definition at line 598 of file TeamManager.h.

class SLNet::TeamManager

Automates networking and list management for teams.

TeamManager provides support for teams. A team is a list of team members. Teams contain properties including the number of team members per team, whether or not tagged teams must have equal numbers of members, and if a team is locked or not to certain entry conditions Team members contain properties including which teams they are on and which teams they want to join if a team is not immediately joinable Advanced functionality includes the ability for a team member to be on multiple teams simultaneously, the ability to swap teams with other members, and the ability to resize the number of members supported per team The architecture is designed for easy integration with ReplicaManager3

Usage:

1. Define your game classes to represent teams and team members. Your game classes should hold game-specific information such as team name and color.
2. Have those game classes contain a corresponding TM_Team or TM_TeamMember instance. Operations on teams will be performed by those instances. Use SetOwner() to refer to the parent object when using composition.
3. Call TeamManager::SetTopology() for client/server or peer to peer.
4. Call AddWorld() to instantiate a TM_World object which will contain references to your TM_TeamMember and TM_Team instances.
5. When you instantiate a TM_TeamMember or TM_Team object, call ReferenceTeam() and ReferenceTeamMember() for each corresponding object
6. When sending world state to a new connection, for example in ReplicaManager3::SerializeConstruction(), call TM_SerializeConstruction() on the corresponding TM_TeamMember and TM_Team objects. TM_Team instances on the new connection must be created before TM_TeamMember instances.
7. Call TM_DeserializeConstruction() on your new corresponding TM_TeamMember and TM_Team instances.
8. Execute team operations. ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, ID_TEAM_BALANCER_TEAM_REQUESTED_CANCELLED, and ID_TEAM_BALANCER_TEAM_ASSIGNED are returned to all systems when the corresponding event occurs for a team member.
9. As the peer to peer session host changes, call SetHost() (Not necessary if using FullyConnectedMesh2). If using client/server, you must set the host
   Note
     This replaces TeamBalancer. You cannot use TeamBalancer and TeamManager at the same time.

Definition at line 626 of file TeamManager.h.

Inheritance diagram for SLNet::TeamManager:

### Public Member Functions

| TeamManager ()
virtual | ~TeamManager ()
TM_World * | AddWorld (WorldId worldId)
| Allocate a world to hold a list of teams and players for that team. Use the returned TM_World object for actual team functionality.
void | RemoveWorld (WorldId worldId)
| Deallocate a world created with AddWorld()
unsigned int | GetWorldCount (void) const
TM_World * | GetWorldAtIndex (unsigned int index) const
TM_World * | GetWorldWithId (WorldId worldId) const
void | SetAutoManageConnections (bool autoAdd)
| When auto managing connections, call TM_World::AddParticipant() on all worlds for all new connections automatically Defaults to true.
void | SetTopology (TMTopology _topology)
| If _topology is set to TM_CLIENT_SERVER, the host will relay messages to participants.
void | DecomposeTeamFull (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t &currentMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions)
| When you get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, pass the packet to this function to read out parameters.
void | DecomposeTeamLocked (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t &currentMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions)
| When you get ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, pass the packet to this function to read out parameters.
void | Clear (void)
| Clear all memory and reset everything.
void | DecodeTeamAssigned (Packet *packet, TM_World **world, TM_TeamMember **teamMember)
| Reads out the world and teamMember from ID_TEAM_BALANCER_TEAM_ASSIGNED.
void | DecodeTeamCancelled (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **teamCancelled)
Public Member Functions inherited from SLNet::PluginInterface2
| PluginInterface2 ()
virtual | ~PluginInterface2 ()
virtual void | OnAttach (void)
| Called when the interface is attached.
virtual void | OnDetach (void)
| Called when the interface is detached.
virtual void | OnRakPeerStartup (void)
| Called when RakPeer is initialized.
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.
virtual void | OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
virtual bool | UsesReliabilityLayer (void) const
virtual void | OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
virtual void | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, int isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
RakPeerInterface * | GetRakPeerInterface (void) const
RakNetGUID | GetMyGUIDUnified (void) const
void | SetRakPeerInterface (RakPeerInterface *ptr)
void | SetTCPInterface (TCPInterface *ptr)

### Protected Member Functions

virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
void | Send (const SLNet::BitStream *bitStream, const AddressOrGUID systemIdentifier, bool broadcast)
void | EncodeTeamFullOrLocked (SLNet::BitStream *bitStream, TM_TeamMember *teamMember, TM_Team *team)
void | DecomposeTeamFullOrLocked (SLNet::BitStream *bsIn, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t &currentMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions)
void | ProcessTeamAssigned (SLNet::BitStream *bsIn)
void | EncodeTeamAssigned (SLNet::BitStream *bitStream, TM_TeamMember *teamMember)
void | RemoveFromTeamsRequestedAndAddTeam (TM_TeamMember *teamMember, TM_Team *team, bool isTeamSwitch, TM_Team *teamToLeave)
void | PushTeamAssigned (TM_TeamMember *teamMember)
void | PushBitStream (SLNet::BitStream *bitStream)
void | OnUpdateListsToNoTeam (Packet *packet, TM_World *world)
void | OnUpdateTeamsRequestedToAny (Packet *packet, TM_World *world)
void | OnJoinAnyTeam (Packet *packet, TM_World *world)
void | OnJoinRequestedTeam (Packet *packet, TM_World *world)
void | OnUpdateTeamsRequestedToNoneAndAddTeam (Packet *packet, TM_World *world)
void | OnRemoveFromTeamsRequestedAndAddTeam (Packet *packet, TM_World *world)
void | OnAddToRequestedTeams (Packet *packet, TM_World *world)
bool | OnRemoveFromRequestedTeams (Packet *packet, TM_World *world)
void | OnLeaveTeam (Packet *packet, TM_World *world)
void | OnSetMemberLimit (Packet *packet, TM_World *world)
void | OnSetJoinPermissions (Packet *packet, TM_World *world)
void | OnSetBalanceTeams (Packet *packet, TM_World *world)
void | OnSetBalanceTeamsInitial (Packet *packet, TM_World *world)
void | EncodeTeamFull (SLNet::BitStream *bitStream, TM_TeamMember *teamMember, TM_Team *team)
void | EncodeTeamLocked (SLNet::BitStream *bitStream, TM_TeamMember *teamMember, TM_Team *team)
void | DecodeTeamAssigned (SLNet::BitStream *bsIn, TM_World **world, TM_TeamMember **teamMember, NoTeamId &noTeamSubcategory, JoinTeamType &joinTeamType, DataStructures::List< TM_Team * > &newTeam, DataStructures::List< TM_Team * > &teamsLeft, DataStructures::List< TM_Team * > &teamsJoined)
| When you get ID_TEAM_BALANCER_TEAM_ASSIGNED, pass the packet to this function to read out parameters.
Protected Member Functions inherited from SLNet::PluginInterface2
void | SendUnified (const SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
void | SendUnified (const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
bool | SendListUnified (const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
Packet * | AllocatePacketUnified (unsigned dataSize)
void | PushBackPacketUnified (Packet *packet, bool pushAtHead)
void | DeallocPacketUnified (Packet *packet)

### Protected Attributes

TM_World * | worldsArray [255]
DataStructures::List< TM_World * > | worldsList
bool | autoAddParticipants
TMTopology | topology
Protected Attributes inherited from SLNet::PluginInterface2
RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

#### Constructor & Destructor Documentation

SLNet::TeamManager::TeamManager | ( |  | ) |

virtual SLNet::TeamManager::~TeamManager | ( |  | ) |

virtual

#### Member Function Documentation

TM_World* SLNet::TeamManager::AddWorld | ( | WorldId | worldId | ) |

Allocate a world to hold a list of teams and players for that team. Use the returned TM_World object for actual team functionality.

Note
  The world is tracked by TeamManager and deallocated by calling Clear()

Parameters

  [in] | worldId | Arbitrary user-defined id of the world to create. Each world instance must have a unique id.

void SLNet::TeamManager::Clear | ( | void |  | ) |

Clear all memory and reset everything.

Deallocates TM_World instances. It is up to the user to deallocate pointers passed to ReferenceTeamMember() or ReferenceTeam(), if so desired.

void SLNet::TeamManager::DecodeTeamAssigned | ( | Packet * | packet,
|  | TM_World ** | world,
|  | TM_TeamMember ** | teamMember
| ) |  |

Reads out the world and teamMember from ID_TEAM_BALANCER_TEAM_ASSIGNED.

Note
  You can get the current and prior team list from the teamMember itself

Parameters

  [in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_ASSIGNED
  [out] | world | Set to the world this teamMember is on. 0 on bad lookup.
  [out] | teamMember | Set to the teamMember affected. 0 on bad lookup.

void SLNet::TeamManager::DecodeTeamAssigned | ( | SLNet::BitStream * | bsIn,
|  | TM_World ** | world,
|  | TM_TeamMember ** | teamMember,
|  | NoTeamId & | noTeamSubcategory,
|  | JoinTeamType & | joinTeamType,
|  | DataStructures::List< TM_Team * > & | newTeam,
|  | DataStructures::List< TM_Team * > & | teamsLeft,
|  | DataStructures::List< TM_Team * > & | teamsJoined
| ) |  |

protected

When you get ID_TEAM_BALANCER_TEAM_ASSIGNED, pass the packet to this function to read out parameters.

Parameters

  [in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_ASSIGNED

Returns
  true on success, false on read error

void SLNet::TeamManager::DecodeTeamCancelled | ( | Packet * | packet,
|  | TM_World ** | world,
|  | TM_TeamMember ** | teamMember,
|  | TM_Team ** | teamCancelled
| ) |  |

Note
  You can get the requested team list from the teamMember itself

Parameters

  [in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_REQUESTED_CANCELLED
  [out] | world | Set to the world this teamMember is on. 0 on bad lookup.
  [out] | teamMember | Set to the teamMember affected. 0 on bad lookup.
  [out] | teamCancelled | Set to the team that was cancelled. 0 for all teams.

void SLNet::TeamManager::DecomposeTeamFull | ( | Packet * | packet,
|  | TM_World ** | world,
|  | TM_TeamMember ** | teamMember,
|  | TM_Team ** | team,
|  | uint16_t & | currentMembers,
|  | uint16_t & | memberLimitIncludingBalancing,
|  | bool & | balancingIsActive,
|  | JoinPermissions & | joinPermissions
| ) |  |

When you get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, pass the packet to this function to read out parameters.

Parameters

  [in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_REQUESTED_TEAM_FULL

Returns
  true on success, false on read error

void SLNet::TeamManager::DecomposeTeamFullOrLocked | ( | SLNet::BitStream * | bsIn,
|  | TM_World ** | world,
|  | TM_TeamMember ** | teamMember,
|  | TM_Team ** | team,
|  | uint16_t & | currentMembers,
|  | uint16_t & | memberLimitIncludingBalancing,
|  | bool & | balancingIsActive,
|  | JoinPermissions & | joinPermissions
| ) |  |

protected

void SLNet::TeamManager::DecomposeTeamLocked | ( | Packet * | packet,
|  | TM_World ** | world,
|  | TM_TeamMember ** | teamMember,
|  | TM_Team ** | team,
|  | uint16_t & | currentMembers,
|  | uint16_t & | memberLimitIncludingBalancing,
|  | bool & | balancingIsActive,
|  | JoinPermissions & | joinPermissions
| ) |  |

When you get ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, pass the packet to this function to read out parameters.

Parameters

  [in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED

Returns
  true on success, false on read error

void SLNet::TeamManager::EncodeTeamAssigned | ( | SLNet::BitStream * | bitStream,
|  | TM_TeamMember * | teamMember
| ) |  |

protected

void SLNet::TeamManager::EncodeTeamFull | ( | SLNet::BitStream * | bitStream,
|  | TM_TeamMember * | teamMember,
|  | TM_Team * | team
| ) |  |

protected

void SLNet::TeamManager::EncodeTeamFullOrLocked | ( | SLNet::BitStream * | bitStream,
|  | TM_TeamMember * | teamMember,
|  | TM_Team * | team
| ) |  |

protected

void SLNet::TeamManager::EncodeTeamLocked | ( | SLNet::BitStream * | bitStream,
|  | TM_TeamMember * | teamMember,
|  | TM_Team * | team
| ) |  |

protected

TM_World* SLNet::TeamManager::GetWorldAtIndex | ( | unsigned int | index | ) | const

Parameters

  [in] | index | A value beteween 0 and GetWorldCount()-1 inclusive.

Returns
  Returns a world created with AddWorld()

unsigned int SLNet::TeamManager::GetWorldCount | ( | void |  | ) | const

Returns
  Returns the number of worlds created with AddWorld()

TM_World* SLNet::TeamManager::GetWorldWithId | ( | WorldId | worldId | ) | const

Parameters

  [in] | worldId | worldId value passed to AddWorld()

Returns
  Returns a world created with AddWorld(), or 0 if no such worldId

void SLNet::TeamManager::OnAddToRequestedTeams | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

virtual void SLNet::TeamManager::OnClosedConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason
| ) |  |

protectedvirtual

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters

  [in] | systemAddress | The system whose connection was closed
  [in] | rakNetGuid | The guid of the specified system
  [in] | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from SLNet::PluginInterface2.

void SLNet::TeamManager::OnJoinAnyTeam | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnJoinRequestedTeam | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnLeaveTeam | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

virtual void SLNet::TeamManager::OnNewConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | bool | isIncoming
| ) |  |

protectedvirtual

Called when we got a new connection

Parameters

  [in] | systemAddress | Address of the new connection
  [in] | rakNetGuid | The guid of the specified system
  [in] | isIncoming | If true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent

Reimplemented from SLNet::PluginInterface2.

virtual PluginReceiveResult SLNet::TeamManager::OnReceive | ( | Packet * | packet | ) |

protectedvirtual

OnReceive is called for every packet.

Parameters

  [in] | packet | the packet that is being returned to the user

Returns
  True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from SLNet::PluginInterface2.

bool SLNet::TeamManager::OnRemoveFromRequestedTeams | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnRemoveFromTeamsRequestedAndAddTeam | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnSetBalanceTeams | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnSetBalanceTeamsInitial | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnSetJoinPermissions | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnSetMemberLimit | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnUpdateListsToNoTeam | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnUpdateTeamsRequestedToAny | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::OnUpdateTeamsRequestedToNoneAndAddTeam | ( | Packet * | packet,
|  | TM_World * | world
| ) |  |

protected

void SLNet::TeamManager::ProcessTeamAssigned | ( | SLNet::BitStream * | bsIn | ) |

protected

void SLNet::TeamManager::PushBitStream | ( | SLNet::BitStream * | bitStream | ) |

protected

void SLNet::TeamManager::PushTeamAssigned | ( | TM_TeamMember * | teamMember | ) |

protected

void SLNet::TeamManager::RemoveFromTeamsRequestedAndAddTeam | ( | TM_TeamMember * | teamMember,
|  | TM_Team * | team,
|  | bool | isTeamSwitch,
|  | TM_Team * | teamToLeave
| ) |  |

protected

void SLNet::TeamManager::RemoveWorld | ( | WorldId | worldId | ) |

Deallocate a world created with AddWorld()

Parameters

  [in] | worldId | The world to deallocate

void SLNet::TeamManager::Send | ( | const SLNet::BitStream * | bitStream,
|  | const AddressOrGUID | systemIdentifier,
|  | bool | broadcast
| ) |  |

protected

void SLNet::TeamManager::SetAutoManageConnections | ( | bool | autoAdd | ) |

When auto managing connections, call TM_World::AddParticipant() on all worlds for all new connections automatically Defaults to true.

Note
  You probably want this set to false if using multiple worlds

Parameters

  [in] | autoAdd | Automatically call TM_World::AddParticipant() all worlds each new connection. Defaults to true.

void SLNet::TeamManager::SetTopology | ( | TMTopology | _topology | ) |

If _topology is set to TM_CLIENT_SERVER, the host will relay messages to participants.

If topology is set to TM_PEER_TO_PEER, the host assumes the original message source was connected to all other participants and does not relay messages.

Note
  If TM_PEER_TO_PEER, this plugin will listen for ID_FCM2_NEW_HOST and call SetHost() on all worlds automatically
  Defaults to TM_PEER_TO_PEER

Parameters

  [in] | _topology | Topology to use

virtual void SLNet::TeamManager::Update | ( | void |  | ) |

protectedvirtual

Update is called every time a packet is checked for .

Reimplemented from SLNet::PluginInterface2.

#### Member Data Documentation

bool SLNet::TeamManager::autoAddParticipants

protected

Definition at line 749 of file TeamManager.h.

TMTopology SLNet::TeamManager::topology

protected

Definition at line 750 of file TeamManager.h.

TM_World* SLNet::TeamManager::worldsArray[255]

protected

Definition at line 746 of file TeamManager.h.

DataStructures::List<TM_World*> SLNet::TeamManager::worldsList

protected

Definition at line 748 of file TeamManager.h.

struct SLNet::TM_TeamMember::RequestedTeam

Definition at line 262 of file TeamManager.h.

Class Members
bool | isTeamSwitch |
TM_Team * | requested |
unsigned int | requestIndex |
TM_Team * | teamToLeave |
Time | whenRequested |

struct SLNet::TM_World::JoinRequestHelper

Definition at line 549 of file TeamManager.h.

Class Members
unsigned int | indexIntoTeamsRequested |
unsigned int | requestIndex |
unsigned int | teamMemberIndex |
Time | whenRequestMade |

union SLNet::TeamSelection.teamParameter

Definition at line 111 of file TeamManager.h.

Class Members
NoTeamId | noTeamSubcategory |
TM_Team * | specificTeamToJoin |

## Typedef Documentation

typedef unsigned char SLNet::NoTeamId

A subcategory of not being on a team. For example, 0 may mean no team for a player, while 1 may mean no team for a spectator. Defined by the user.

Definition at line 53 of file TeamManager.h.

typedef uint16_t SLNet::TeamMemberLimit

Maximum number of members on one team. Use 65535 for unlimited.

Definition at line 61 of file TeamManager.h.

## Enumeration Type Documentation

enum SLNet::JoinTeamType

Enumerator:

  JOIN_ANY_AVAILABLE_TEAM | Attempt to join the first available team.
  JOIN_SPECIFIC_TEAM | Attempt to join a specific team, previously added with TM_World::ReferenceTeam()
  JOIN_NO_TEAM | No team. Always succeeds.

Definition at line 80 of file TeamManager.h.

enum SLNet::TMTopology

Enumerator:

  TM_PEER_TO_PEER |
  TM_CLIENT_SERVER |

Definition at line 91 of file TeamManager.h.