Cavestory Mod API
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
CaveNet::DataStructures::NetTeam Class Reference

Player teams. More...

#include <CaveNet_ExportedTypes.h>

Classes

struct  NetTeamConfig
 Controls NetTeam configuration. More...
 
struct  NetTeamSpawnWeapon
 Stores information for spawning weapons. More...
 

Public Types

enum  TeamType { TEAM_YELLOW = 0 , TEAM_GREEN = 1 , TEAM_RED = 2 , TEAM_BLUE = 3 }
 

Public Member Functions

 NetTeam ()
 Constructor.
 
 NetTeam (NetTeamId iTeamId, bool bClientSide=true)
 Client-side constructor.
 
 ~NetTeam ()
 Deconstructor.
 
void ResetConfig ()
 Reset this team's configuration.
 
void SetName (const char *pNewName)
 Set the team's name. More...
 
void SetColor (GUI_COLOR pColor)
 Set the team's color. More...
 
void SetNpcSpawnIndex (int iIndex)
 Set the NPC spawn index. More...
 
const char * GetName ()
 Get this team's name. More...
 
GUI_COLOR GetColor ()
 Get this team's color. More...
 
const char * GetHexColor ()
 Get this team's color in hexidecimal. More...
 
NetTeamId GetTeamId ()
 Get this team's ID. More...
 
bool IsClientSide ()
 Get whether this team is client-sided or not. More...
 
int GetNpcSpawnIndex ()
 Get the spawn index. More...
 
bool AddSpawnPoint (int iNpcIdx)
 Add a spawn point to this team. More...
 
GUI_POINT GetSpawnPosition ()
 Get the spawn position for this team. More...
 
void SpawnClient (NetClient *pClient)
 Spawn a player. More...
 
bool IsMember (NetClient *pClient)
 Check if a client is a member of this team. More...
 
bool AddMember (NetClient *pClient, bool bAnnounce=true)
 Add a client to this team. More...
 
bool RemoveMember (NetClient *pClient, bool bAnnounce=true)
 Remove a member for this team. More...
 
int GetMemberCount ()
 Get this team's member count. More...
 
NetClientGetMember (int iIndex)
 Get a member of this team. More...
 
void ClearMembers ()
 Clear all members from this team.
 
void WritePacket (NetPacket *pPacket)
 Write a team packet. More...
 
unsigned int SizePacket ()
 Size up a team packet. More...
 
void ReadPacket (NetPacket *pPacket)
 Read a team packet. More...
 
void UpdateTeam ()
 Send a team update to all clients.
 

Static Public Member Functions

static void ClearAllTeams ()
 Delete all teams.
 
static NetTeamFindTeamByName (const char *pName, bool bClientSide)
 Find a team by name. More...
 
static NetTeamFindTeamById (NetTeamId iTeamId, bool bClientSide)
 Find a team by id. More...
 
static NetTeamFindTeamByType (TeamType iTeamType, bool bClientSide)
 Find a team by type. More...
 
static NetTeamGetTeamByIndex (int iTeamIndex, bool bClientSide)
 Fetch a team by index. More...
 
static bool AreTeamsUnbalanced (NetTeamId &iHighestTeam, NetTeamId &iLightestTeam)
 Check to see if teams are unbalanced. More...
 
static void BalanceTeams (bool bOnlySwitchDeadPlayers=false)
 Autobalance teams. More...
 
static NetTeamId GetNextFreeTeamId (bool bClientSide)
 Get the next free team ID. More...
 
static int OpenTeamListMenu ()
 Opens an easy-to-use dialog that will allow the host to go through teams. More...
 
static int OpenTeamEditMenu (NetTeam *pTeam=NULL)
 Opens an easy-to-use dialog that will allow the host to add or edit a team. More...
 

Public Attributes

NetTeamnext
 Next team in the link.
 
NetTeamprev
 Previous team in the link.
 
TeamType mTeamType
 The team type.
 
List< NPCHAR * > mSpawnPoints
 A list of NPCs that represent spawn points.
 
NPCHARmFlagNpc
 This team's CTP flag.
 
NPCHARmCaptureZoneNpc
 This team's CTP capture zone.
 
NetTeamConfig mConfig
 This team's configuration.
 

Static Public Attributes

static NetTeamclient_first
 First team in the client-sided link.
 
static NetTeamserver_first
 First team in the server-sided link.
 
static unsigned int server_count
 Total count of server-side teams.
 
static unsigned int client_count
 Total count of client-side teams.
 

Protected Member Functions

void Link ()
 Link this team to the rest.
 
void Unlink ()
 Unlink this team from the rest.
 

Protected Attributes

NetTeamId mTeamId
 The team net ID. More...
 
char * mName
 The team name.
 
GUI_COLOR mColor
 The team color.
 
char mHexColor [7]
 The team color in hex.
 
List< NetClient * > mClientList
 The clients in this team.
 
bool mIsClientSide
 Stores whether this team is clientside or serverside.
 
int mSpawnNpcIndex
 The NPC index of the spawn object.
 

Friends

class NetClient
 
class NetPlayer
 

Detailed Description

Player teams.

Member Function Documentation

◆ AddMember()

bool CaveNet::DataStructures::NetTeam::AddMember ( NetClient pClient,
bool  bAnnounce = true 
)

Add a client to this team.

Parameters
pClientThe client to add.
bAnnounceWhether to announce the client's join or not.
Returns
Returns true on success, false otherwise.

◆ AddSpawnPoint()

bool CaveNet::DataStructures::NetTeam::AddSpawnPoint ( int  iNpcIdx)

Add a spawn point to this team.

Parameters
iNpcIdxThe index of the NPC in gNPC.
Returns
Returns true on success, false otherwise.

◆ AreTeamsUnbalanced()

static bool CaveNet::DataStructures::NetTeam::AreTeamsUnbalanced ( NetTeamId &  iHighestTeam,
NetTeamId &  iLightestTeam 
)
static

Check to see if teams are unbalanced.

Parameters
iHighestTeamA reference to an int that will store the heaviest team's ID.
iHighestTeamA reference to an int that will store the lightest team's ID.
Returns
Returns true if teams are unbalanced, false otherwise.

◆ BalanceTeams()

static void CaveNet::DataStructures::NetTeam::BalanceTeams ( bool  bOnlySwitchDeadPlayers = false)
static

Autobalance teams.

Parameters
bOnlySwitchDeadPlayersOnly switch dead players.

◆ FindTeamById()

static NetTeam* CaveNet::DataStructures::NetTeam::FindTeamById ( NetTeamId  iTeamId,
bool  bClientSide 
)
static

Find a team by id.

Parameters
iTeamIdThe ID of the team we want to find.
bClientSideWhether to search the client-sided array or the server-sided array.
Returns
Returns the team if it exists, NULL otherwise.

◆ FindTeamByName()

static NetTeam* CaveNet::DataStructures::NetTeam::FindTeamByName ( const char *  pName,
bool  bClientSide 
)
static

Find a team by name.

Parameters
pNameThe name of the team we want to find.
bClientSideWhether to search the client-sided array or the server-sided array.
Returns
Returns the team if it exists, NULL otherwise.

◆ FindTeamByType()

static NetTeam* CaveNet::DataStructures::NetTeam::FindTeamByType ( TeamType  iTeamType,
bool  bClientSide 
)
static

Find a team by type.

Parameters
iTeamTypeThe type of the team we want to find.
bClientSideWhether to search the client-sided array or the server-sided array.
Returns
Returns the team if it exists, NULL otherwise.

◆ GetColor()

GUI_COLOR CaveNet::DataStructures::NetTeam::GetColor ( )
inline

Get this team's color.

Returns
Returns this team's color.

◆ GetHexColor()

const char* CaveNet::DataStructures::NetTeam::GetHexColor ( )
inline

Get this team's color in hexidecimal.

Returns
Returns this team's color in hexidecimal format.

◆ GetMember()

NetClient* CaveNet::DataStructures::NetTeam::GetMember ( int  iIndex)

Get a member of this team.

Parameters
iIndexThe index of the member.
Returns
Returns a pointer to a NetClient* on success, else returns NULL if index is out of bounds.

◆ GetMemberCount()

int CaveNet::DataStructures::NetTeam::GetMemberCount ( )

Get this team's member count.

Returns
Returns this team's member count.

◆ GetName()

const char* CaveNet::DataStructures::NetTeam::GetName ( )
inline

Get this team's name.

Returns
Returns this team's color.

◆ GetNextFreeTeamId()

static NetTeamId CaveNet::DataStructures::NetTeam::GetNextFreeTeamId ( bool  bClientSide)
static

Get the next free team ID.

Parameters
bClientSideWhether to reference the client-side array or the server-side array.
Returns
Returns the next free Team ID.

◆ GetNpcSpawnIndex()

int CaveNet::DataStructures::NetTeam::GetNpcSpawnIndex ( )
inline

Get the spawn index.

Returns
Returns the spawn npc index.

◆ GetSpawnPosition()

GUI_POINT CaveNet::DataStructures::NetTeam::GetSpawnPosition ( )

Get the spawn position for this team.

Returns
Returns a spawn position.

◆ GetTeamByIndex()

static NetTeam* CaveNet::DataStructures::NetTeam::GetTeamByIndex ( int  iTeamIndex,
bool  bClientSide 
)
static

Fetch a team by index.

Parameters
iTeamIndexThe index of the team to get.
bClientSideWhether to search the client-sided array or the server-sided array.
Returns
Returns the team if it exists, NULL otherwise.

◆ GetTeamId()

NetTeamId CaveNet::DataStructures::NetTeam::GetTeamId ( )
inline

Get this team's ID.

Returns
Returns this team's ID.

◆ IsClientSide()

bool CaveNet::DataStructures::NetTeam::IsClientSide ( )
inline

Get whether this team is client-sided or not.

Returns
Returns true if this team exists client-side, false if it exists server-side.

◆ IsMember()

bool CaveNet::DataStructures::NetTeam::IsMember ( NetClient pClient)

Check if a client is a member of this team.

Parameters
pClientThe client to check.
Returns
Returns true if the given client is apart of this team.

◆ OpenTeamEditMenu()

static int CaveNet::DataStructures::NetTeam::OpenTeamEditMenu ( NetTeam pTeam = NULL)
static

Opens an easy-to-use dialog that will allow the host to add or edit a team.

Parameters
pTeamThe team to edit. If NULL, a new team will be created.
Returns
Returns the resulting error code.

◆ OpenTeamListMenu()

static int CaveNet::DataStructures::NetTeam::OpenTeamListMenu ( )
static

Opens an easy-to-use dialog that will allow the host to go through teams.

Returns
Returns the resulting error code.

◆ ReadPacket()

void CaveNet::DataStructures::NetTeam::ReadPacket ( NetPacket *  pPacket)

Read a team packet.

Parameters
pPacketThe packet to read from.

◆ RemoveMember()

bool CaveNet::DataStructures::NetTeam::RemoveMember ( NetClient pClient,
bool  bAnnounce = true 
)

Remove a member for this team.

Parameters
pClientThe client to remove.
bAnnounceWhether to announce the client's departure or not.
Returns
Returns true on success, false otherwise.

◆ SetColor()

void CaveNet::DataStructures::NetTeam::SetColor ( GUI_COLOR  pColor)

Set the team's color.

Parameters
pColorThe new team color.

◆ SetName()

void CaveNet::DataStructures::NetTeam::SetName ( const char *  pNewName)

Set the team's name.

Parameters
pNewNameThe new team name.

◆ SetNpcSpawnIndex()

void CaveNet::DataStructures::NetTeam::SetNpcSpawnIndex ( int  iIndex)

Set the NPC spawn index.

Parameters
iIndexThe index of the spawn NPC.

◆ SizePacket()

unsigned int CaveNet::DataStructures::NetTeam::SizePacket ( )

Size up a team packet.

Returns
Returns the size of the packet, in bits.

◆ SpawnClient()

void CaveNet::DataStructures::NetTeam::SpawnClient ( NetClient pClient)

Spawn a player.

Parameters
pClientThe team member to spawn.

◆ WritePacket()

void CaveNet::DataStructures::NetTeam::WritePacket ( NetPacket *  pPacket)

Write a team packet.

Parameters
pPacketThe packet to write to.

Member Data Documentation

◆ mTeamId

NetTeamId CaveNet::DataStructures::NetTeam::mTeamId
protected

The team net ID.

This is sent over the network instead of the team name (if we can help it).


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