![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
Set and network team selection (supports peer to peer or client/server) More...
#include <TeamBalancer.h>
Inheritance diagram for RakNet::TeamBalancer:Automatically handles transmission and resolution of team selection, including team switching and balancing.
Usage: TODO
Definition at line 41 of file TeamBalancer.h.
| SMALLEST_TEAM |
Among all the teams, join the team with the smallest number of players. |
| FILL_IN_ORDER |
Join the team with the lowest index that has open slots. |
Definition at line 73 of file TeamBalancer.h.
{
SMALLEST_TEAM,
FILL_IN_ORDER
};
| RakNet::TeamBalancer::TeamBalancer | ( | ) |
| virtual RakNet::TeamBalancer::~TeamBalancer | ( | ) | [virtual] |
| unsigned int RakNet::TeamBalancer::AddTeamMember | ( | const TeamMember & | tm | ) | [protected] |
| void RakNet::TeamBalancer::CancelRequestSpecificTeam | ( | void | ) |
If ID_TEAM_BALANCER_REQUESTED_TEAM_CHANGE_PENDING is returned after a call to RequestSpecificTeam(), the request will stay in memory on the host and execute when available, or until the teams become locked. You can cancel the request by calling CancelRequestSpecificTeam(), in which case you will stay on your existing team.
| static void RakNet::TeamBalancer::DestroyInstance | ( | TeamBalancer * | i | ) | [static] |
| void RakNet::TeamBalancer::EvenTeams | ( | void | ) | [protected] |
| TeamId RakNet::TeamBalancer::GetFirstNonFullTeam | ( | void | ) | const [protected] |
| static TeamBalancer* RakNet::TeamBalancer::GetInstance | ( | void | ) | [static] |
| unsigned int RakNet::TeamBalancer::GetMemberIndex | ( | RakNetGUID | guid | ) | [protected] |
| unsigned int RakNet::TeamBalancer::GetMemberIndexToSwitchTeams | ( | const DataStructures::List< TeamId > & | sourceTeamNumbers, |
| TeamId | targetTeamNumber | ||
| ) | [protected] |
| void RakNet::TeamBalancer::GetMinMaxTeamMembers | ( | int & | minMembersOnASingleTeam, |
| int & | maxMembersOnASingleTeam | ||
| ) | [protected] |
| TeamId RakNet::TeamBalancer::GetMyTeam | ( | void | ) | const |
Returns your team. As your team changes, you are notified through the ID_TEAM_BALANCER_TEAM_ASSIGNED packet in byte 1. Returns UNASSIGNED_TEAM_ID initially
| TeamId RakNet::TeamBalancer::GetNextDefaultTeam | ( | void | ) | [protected] |
| void RakNet::TeamBalancer::GetOverpopulatedTeams | ( | DataStructures::List< TeamId > & | overpopulatedTeams, |
| int | maxTeamSize | ||
| ) | [protected] |
| TeamId RakNet::TeamBalancer::GetSmallestNonFullTeam | ( | void | ) | const [protected] |
| void RakNet::TeamBalancer::MoveMemberThatWantsToJoinTeam | ( | TeamId | teamId | ) | [protected] |
| void RakNet::TeamBalancer::NotifyNoTeam | ( | RakNetGUID | target | ) | [protected] |
| void RakNet::TeamBalancer::NotifyTeamAssigment | ( | unsigned int | teamMemberIndex | ) | [protected] |
| void RakNet::TeamBalancer::NotifyTeamsLocked | ( | RakNetGUID | target, |
| TeamId | requestedTeam | ||
| ) | [protected] |
| void RakNet::TeamBalancer::NotifyTeamSwitchPending | ( | RakNetGUID | target, |
| TeamId | requestedTeam | ||
| ) | [protected] |
| void RakNet::TeamBalancer::OnCancelTeamRequest | ( | Packet * | packet | ) | [protected] |
| virtual void RakNet::TeamBalancer::OnClosedConnection | ( | const SystemAddress & | systemAddress, |
| RakNetGUID | rakNetGUID, | ||
| PI2_LostConnectionReason | lostConnectionReason | ||
| ) | [protected, virtual] |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
| [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 RakNet::PluginInterface2.
| virtual PluginReceiveResult RakNet::TeamBalancer::OnReceive | ( | Packet * | packet | ) | [protected, virtual] |
OnReceive is called for every packet.
| [in] | packet | the packet that is being returned to the user |
Reimplemented from RakNet::PluginInterface2.
| void RakNet::TeamBalancer::OnRequestAnyTeam | ( | Packet * | packet | ) | [protected] |
| PluginReceiveResult RakNet::TeamBalancer::OnRequestedTeamChangePending | ( | Packet * | packet | ) | [protected] |
| void RakNet::TeamBalancer::OnRequestSpecificTeam | ( | Packet * | packet | ) | [protected] |
| void RakNet::TeamBalancer::OnStatusUpdateToNewHost | ( | Packet * | packet | ) | [protected] |
| PluginReceiveResult RakNet::TeamBalancer::OnTeamAssigned | ( | Packet * | packet | ) | [protected] |
| PluginReceiveResult RakNet::TeamBalancer::OnTeamsLocked | ( | Packet * | packet | ) | [protected] |
| void RakNet::TeamBalancer::RemoveByGuid | ( | RakNetGUID | rakNetGUID | ) | [protected] |
| void RakNet::TeamBalancer::RemoveTeamMember | ( | unsigned int | index | ) | [protected] |
| void RakNet::TeamBalancer::RequestAnyTeam | ( | void | ) |
Allow host to pick your team, based on whatever algorithm it uses for default team assignments. This only has an effect if you are not currently on a team (GetMyTeam() returns UNASSIGNED_TEAM_ID)
Set your requested team. UNASSIGNED_TEAM_ID means no team. After enough time for network communication, ID_TEAM_BALANCER_SET_TEAM will be returned with your current team, or If team switch is not possible, ID_TEAM_BALANCER_REQUESTED_TEAM_CHANGE_PENDING or ID_TEAM_BALANCER_TEAMS_LOCKED will be returned. In the case of ID_TEAM_BALANCER_REQUESTED_TEAM_CHANGE_PENDING the request will stay in memory. ID_TEAM_BALANCER_SET_TEAM will be returned when someone on the desired team leaves or wants to switch to your team. If SetLockTeams(true) is called while you have a request pending, you will get ID_TEAM_BALANCER_TEAMS_LOCKED
| [in] | desiredTeam | An index representing your team number. The index should range from 0 to one less than the size of the list passed to SetTeamSizeLimits() on the host. You can also pass UNASSIGNED_TEAM_ID to not be on any team (such as if spectating) |
| void RakNet::TeamBalancer::SetAllowHostMigration | ( | bool | allow | ) |
Allow systems to change the host If true, this is a security hole, but needed for peer to peer For client server, set to false Defaults to true param[in] allow True to allow host migration, false to not allow
| void RakNet::TeamBalancer::SetDefaultAssignmentAlgorithm | ( | DefaultAssigmentAlgorithm | daa | ) |
Based on the specified enumeration, a player will join a team automatically Defaults to SMALLEST_TEAM This function is only used by the host
| [in] | daa | Enumeration describing the algorithm to use |
| void RakNet::TeamBalancer::SetForceEvenTeams | ( | bool | force | ) |
If SetForceEvenTeams(true) is called on the host, then teams cannot be unbalanced by more than 1 player If teams are uneven at the time that SetForceEvenTeams(true) is called, players at randomly will be switched, and will be notified of ID_TEAM_BALANCER_TEAM_ASSIGNED If players disconnect from the host such that teams would not be even, and teams are not locked, then a player from the largest team is randomly moved to even the teams. Defaults to false
| [in] | force | True to force even teams. False to allow teams to not be evenly matched |
| void RakNet::TeamBalancer::SetHostGuid | ( | RakNetGUID | _hostGuid | ) |
One system is responsible for maintaining the team list and determining which system is on which team. For a client/server system, this would be the server. For a peer to peer system, this would be one of the peers. If using FullyConnectedMesh2, this would be called with the value returned by FullyConnectedMesh2::GetHostSystem(). Update when you get ID_FCM2_INFORM_FCMGUID
| [in] | _hostGuid | One system we are connected to that will resolve team assignments. |
| void RakNet::TeamBalancer::SetLockTeams | ( | bool | lock | ) |
However, if those functions are called and you do not have a team, then you will be assigned to a default team according to SetDefaultAssignmentAlgorithm() and possibly SetForceEvenTeams(true) If lock is false, and SetForceEvenTeams() was called with force as true, and teams are currently uneven, they will be made even, and those players randomly moved will get ID_TEAM_BALANCER_TEAM_ASSIGNED Defaults to false
| [in] | lock | True to lock teams, false to unlock |
| void RakNet::TeamBalancer::SetTeamSizeLimits | ( | const DataStructures::List< unsigned short > & | _teamLimits | ) |
SetTeamSizeLimits() must be called on the host, so the host can enforce the maximum number of players on each team. SetTeamSizeLimits() can be called on all systems if desired - for example, in a P2P environment you may wish to call it on all systems in advanced in case you become host. Calling this function when teams have already been created does not affect existing teams.
| [in] | teamLimits | The maximum number of people per team, by index. For example, a list of size 3 with values 1,2,3 would allow 1 person on team 0, 2 people on team 1, adn 3 people on team 2. |
| void RakNet::TeamBalancer::SetTeamSizeLimits | ( | unsigned short * | values, |
| int | valuesLength | ||
| ) |
SetTeamSizeLimits() must be called on the host, so the host can enforce the maximum number of players on each team. SetTeamSizeLimits() can be called on all systems if desired - for example, in a P2P environment you may wish to call it on all systems in advanced in case you become host. Calling this function when teams have already been created does not affect existing teams.
| [in] | values | The maximum number of people per team, by index. For example, a list of size 3 with values 1,2,3 would allow 1 person on team 0, 2 people on team 1, adn 3 people on team 2. |
| [in] | valuesLength | Length of the values array |
| void RakNet::TeamBalancer::SwapTeamMembersByRequest | ( | unsigned int | memberIndex1, |
| unsigned int | memberIndex2 | ||
| ) | [protected] |
| void RakNet::TeamBalancer::SwitchMemberTeam | ( | unsigned int | teamMemberIndex, |
| TeamId | destinationTeam | ||
| ) | [protected] |
| bool RakNet::TeamBalancer::TeamWouldBeOverpopulatedOnAddition | ( | TeamId | teamId, |
| unsigned int | teamMemberSize | ||
| ) | [protected] |
| bool RakNet::TeamBalancer::TeamWouldBeUnderpopulatedOnLeave | ( | TeamId | teamId, |
| unsigned int | teamMemberSize | ||
| ) | [protected] |
| bool RakNet::TeamBalancer::WeAreHost | ( | void | ) | const [protected] |
bool RakNet::TeamBalancer::allowHostMigration [protected] |
Definition at line 163 of file TeamBalancer.h.
TeamId RakNet::TeamBalancer::currentTeam [protected] |
Definition at line 157 of file TeamBalancer.h.
Definition at line 159 of file TeamBalancer.h.
Definition at line 162 of file TeamBalancer.h.
bool RakNet::TeamBalancer::forceTeamsToBeEven [protected] |
Definition at line 160 of file TeamBalancer.h.
RakNetGUID RakNet::TeamBalancer::hostGuid [protected] |
Definition at line 156 of file TeamBalancer.h.
bool RakNet::TeamBalancer::lockTeams [protected] |
Definition at line 161 of file TeamBalancer.h.
TeamId RakNet::TeamBalancer::requestedTeam [protected] |
Definition at line 158 of file TeamBalancer.h.
DataStructures::List<unsigned short> RakNet::TeamBalancer::teamLimits [protected] |
Definition at line 165 of file TeamBalancer.h.
DataStructures::List<unsigned short> RakNet::TeamBalancer::teamMemberCounts [protected] |
Definition at line 166 of file TeamBalancer.h.
Definition at line 167 of file TeamBalancer.h.
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.