RakNet  4.0
Public Member Functions | List of all members
RakNet::TM_World Class Reference

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

#include <TeamManager.h>

Public Member Functions

TeamManagerGetTeamManager (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_TeamGetTeamByIndex (unsigned int index) const
 
TM_TeamGetTeamByNetworkID (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_TeamMemberGetTeamMemberByIndex (unsigned int index) const
 
NetworkID GetTeamMemberIDByIndex (unsigned int index) const
 
TM_TeamMemberGetTeamMemberByNetworkID (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.
 

Detailed Description

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.

Member Function Documentation

void RakNet::TM_World::AddParticipant ( RakNetGUID  rakNetGUID)

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

Parameters
[in]rakNetGUIDGUID of the system you are adding. See Packet::rakNetGUID or RakPeerInterface::GetGUIDFromSystemAddress()
void RakNet::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 RakNet::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]teamWhich team instance to unregister
[in]noTeamSubcategoryAll players on this team are kicked off. If these players then have no team, they are set to this no team category.
void RakNet::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
bool RakNet::TM_World::GetBalanceTeams ( void  ) const
Returns
balanceTeams parameter of SetBalanceTeams(), or the default
RakNetGUID RakNet::TM_World::GetHost ( void  ) const
Returns
Returns the current host, or UNASSIGNED_RAKNET_GUID if unknown
void RakNet::TM_World::GetParticipantList ( DataStructures::List< RakNetGUID > &  participantList)

Get the participants added with AddParticipant()

Parameters
[out]participantListParticipants added with AddParticipant();
TM_Team* RakNet::TM_World::GetTeamByIndex ( unsigned int  index) const
Parameters
[in]indexA value between 0 and GetTeamCount()
Returns
Returns whatever was passed to team in the function ReferenceTeam() in the order it was called.
TM_Team* RakNet::TM_World::GetTeamByNetworkID ( NetworkID  teamId)
Parameters
[in]teamIdValue passed to ReferenceTeam()
Returns
Returns whatever was passed to team in the function ReferenceTeam() with this NetworkID.
unsigned int RakNet::TM_World::GetTeamCount ( void  ) const
Returns
Number of teams uniquely added with ReferenceTeam()
unsigned int RakNet::TM_World::GetTeamIndex ( const TM_Team team) const

Inverse of GetTeamByIndex()

Parameters
[in]teamWhich taem
Returns
The index of the specified team, or -1 if not found
TeamManager* RakNet::TM_World::GetTeamManager ( void  ) const
Returns
Returns the plugin that created this TM_World instance
TM_TeamMember* RakNet::TM_World::GetTeamMemberByIndex ( unsigned int  index) const
Parameters
[in]indexA value between 0 and GetTeamMemberCount()
Returns
Returns whatever was passed to team in the function ReferenceTeamMember() in the order it was called.
TM_TeamMember* RakNet::TM_World::GetTeamMemberByNetworkID ( NetworkID  teamMemberId)
Parameters
[in]teamIdValue passed to ReferenceTeamMember()
Returns
Returns Returns whatever was passed to team in the function ReferenceTeamMember() with this NetworkID
unsigned int RakNet::TM_World::GetTeamMemberCount ( void  ) const
Returns
Number of team members uniquely added with ReferenceTeamMember()
NetworkID RakNet::TM_World::GetTeamMemberIDByIndex ( unsigned int  index) const
Parameters
[in]indexA value between 0 and GetTeamMemberCount()
Returns
Returns whatever was passed to teamMemberID in the function ReferenceTeamMember() in the order it was called.
unsigned int RakNet::TM_World::GetTeamMemberIndex ( const TM_TeamMember teamMember) const

Inverse of GetTeamMemberByIndex()

Parameters
[in]teamWhich team member
Returns
The index of the specified team member, or -1 if not found
WorldId RakNet::TM_World::GetWorldId ( void  ) const
Returns
The worldId passed to TeamManagr::AddWorld()
void RakNet::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]teamThe instance you are registering
[in]networkIdIdentifies 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]applyBalancingWhether or not to include this team for balancing when calling SetBalanceTeams().
void RakNet::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]teamMemberThe instance you are registering
[in]networkIdIdentifies 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 RakNet::TM_World::RemoveParticipant ( RakNetGUID  rakNetGUID)

Remove a system that was previously added with AddParticipant()

Systems that disconnect are removed automatically

Parameters
[in]rakNetGUIDGUID of the system you are removing. See Packet::rakNetGUID or RakPeerInterface::GetGUIDFromSystemAddress()
void RakNet::TM_World::SetAutoManageConnections ( bool  autoAdd)

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

Defaults to true

Parameters
[in]autoAddSetting to set
bool RakNet::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]balanceTeamsWhether to activate or deactivate team balancing.
[in]noTeamSubcategoryIf a player is kicked off a team and is no longer on any team, his or her noTeamSubcategory is set to this value
void RakNet::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]_hostGuidThe host, which is the system that will serialize and resolve team disputes and calculate team balancing.

The documentation for this class was generated from the following file: