Public Member Functions | Protected Attributes | Friends

NetworkIDManager Class Reference

#include <NetworkIDManager.h>

Collaboration diagram for NetworkIDManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NetworkIDManager (void)
virtual ~NetworkIDManager (void)
void SetIsNetworkIDAuthority (bool isAuthority)
bool IsNetworkIDAuthority (void) const
void SetExternalSystemAddress (SystemAddress systemAddress)
SystemAddress GetExternalSystemAddress (void)
void SetGuid (RakNetGUID g)
RakNetGUID GetGuid (void)
unsigned short GetSharedNetworkID (void)
void SetSharedNetworkID (unsigned short i)
NetworkIDObjectGET_BASE_OBJECT_FROM_ID (NetworkID x)
void * GET_OBJECT_FROM_ID (NetworkID x)
template<class returnType >
returnType GET_OBJECT_FROM_ID (NetworkID x)

Protected Attributes

RakNetGUID guid
SystemAddress externalSystemAddress
unsigned short sharedNetworkID
bool isNetworkIDAuthority
bool calledSetIsNetworkIDAuthority
DataStructures::AVLBalancedBinarySearchTree
< NetworkIDNode
IDTree
 This AVL tree holds the pointer to NetworkID mappings.

Friends

class NetworkIDObject

Detailed Description

This class is simply used to generate a unique number for a group of instances of NetworkIDObject An instance of this class is required to use the ObjectID to pointer lookup system You should have one instance of this class per game instance. Call SetIsNetworkIDAuthority before using any functions of this class, or of NetworkIDObject

Definition at line 34 of file NetworkIDManager.h.


Constructor & Destructor Documentation

NetworkIDManager::NetworkIDManager ( void   ) 

Definition at line 119 of file NetworkIDManager.cpp.

Here is the call graph for this function:

NetworkIDManager::~NetworkIDManager ( void   )  [virtual]

Definition at line 135 of file NetworkIDManager.cpp.


Member Function Documentation

NetworkIDObject * NetworkIDManager::GET_BASE_OBJECT_FROM_ID ( NetworkID  x  ) 

If you use a parent, returns this instance rather than the parent object.

Precondition:
You must first call SetNetworkIDManager before using this function

Definition at line 50 of file NetworkIDManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void * NetworkIDManager::GET_OBJECT_FROM_ID ( NetworkID  x  ) 

Returns the parent object, or this instance if you don't use a parent.

Deprecated:
, use the template form. This form requires that NetworkIDObject is the basemost derived class
Precondition:
You must first call SetNetworkIDManager before using this function

Definition at line 74 of file NetworkIDManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class returnType >
returnType NetworkIDManager::GET_OBJECT_FROM_ID ( NetworkID  x  )  [inline]

Returns the parent object, or this instance if you don't use a parent. Supports NetworkIDObject anywhere in the inheritance hierarchy

Precondition:
You must first call SetNetworkIDManager before using this function

Definition at line 92 of file NetworkIDManager.h.

Here is the call graph for this function:

SystemAddress NetworkIDManager::GetExternalSystemAddress ( void   ) 

Definition at line 181 of file NetworkIDManager.cpp.

RakNetGUID NetworkIDManager::GetGuid ( void   ) 

Definition at line 191 of file NetworkIDManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short NetworkIDManager::GetSharedNetworkID ( void   ) 

These function is only meant to be used when saving games as you should save the HIGHEST value staticItemID has achieved upon save and reload it upon load. Save AFTER you've created all the items derived from this class you are going to create.

Returns:
the HIGHEST Object Id currently used

Definition at line 159 of file NetworkIDManager.cpp.

bool NetworkIDManager::IsNetworkIDAuthority ( void   )  const
Returns:
Returns what was passed to SetIsNetworkIDAuthority()

Definition at line 151 of file NetworkIDManager.cpp.

Here is the caller graph for this function:

void NetworkIDManager::SetExternalSystemAddress ( SystemAddress  systemAddress  ) 
Deprecated:
Use NetworkIDManager::SetGuid() and NetworkIDManager::GetGuid() instead Necessary for peer to peer, as NetworkIDs are then composed of your external player Id (doesn't matter which, as long as unique) plus the usual object ID number. Get this from RakPeer::GetExternalSystemAddress) one time, the first time you make a connection.
Precondition:
You must first call SetNetworkIDManager before using this function
Parameters:
[in] systemAddress Your external systemAddress

Definition at line 174 of file NetworkIDManager.cpp.

Here is the call graph for this function:

void NetworkIDManager::SetGuid ( RakNetGUID  g  ) 

Necessary for peer to peer, as NetworkIDs are then composed of your external player Id (doesn't matter which, as long as unique) plus the usual object ID number. Get this from RakPeer::GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS) one time, the first time you make a connection.

Precondition:
You must first call SetNetworkIDManager before using this function

Definition at line 187 of file NetworkIDManager.cpp.

Here is the caller graph for this function:

void NetworkIDManager::SetIsNetworkIDAuthority ( bool  isAuthority  ) 

For every group of systems, one system needs to be responsible for creating unique IDs for all objects created on all systems. This way, systems can send that id in packets to refer to objects (you can't send pointers because the memory allocations may be different). In a client/server environment, the system that creates unique IDs would be the server. If you are using peer to peer or other situations where you don't have a single system to assign ids, set this to true, and be sure NETWORK_ID_SUPPORTS_PEER_TO_PEER is defined in RakNetDefines.h

Definition at line 143 of file NetworkIDManager.cpp.

void NetworkIDManager::SetSharedNetworkID ( unsigned short  i  ) 

These function is only meant to be used when loading games. Load BEFORE you create any new objects that are not SetIDed based on the save data.

Parameters:
[in] i the highest number of NetworkIDObject reached.

Definition at line 167 of file NetworkIDManager.cpp.


Friends And Related Function Documentation

friend class NetworkIDObject [friend]

Definition at line 108 of file NetworkIDManager.h.


Member Data Documentation

Definition at line 107 of file NetworkIDManager.h.

Definition at line 104 of file NetworkIDManager.h.

Definition at line 102 of file NetworkIDManager.h.

This AVL tree holds the pointer to NetworkID mappings.

Definition at line 113 of file NetworkIDManager.h.

Definition at line 106 of file NetworkIDManager.h.

unsigned short NetworkIDManager::sharedNetworkID [protected]

Definition at line 105 of file NetworkIDManager.h.


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