#include <NetworkIDManager.h>
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) |
NetworkIDObject * | GET_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 |
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.
NetworkIDManager::NetworkIDManager | ( | void | ) |
NetworkIDManager::~NetworkIDManager | ( | void | ) | [virtual] |
Definition at line 135 of file NetworkIDManager.cpp.
NetworkIDObject * NetworkIDManager::GET_BASE_OBJECT_FROM_ID | ( | NetworkID | x | ) |
If you use a parent, returns this instance rather than the parent object.
Definition at line 50 of file NetworkIDManager.cpp.
void * NetworkIDManager::GET_OBJECT_FROM_ID | ( | NetworkID | x | ) |
Returns the parent object, or this instance if you don't use a parent.
Definition at line 74 of file NetworkIDManager.cpp.
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
Definition at line 92 of file NetworkIDManager.h.
SystemAddress NetworkIDManager::GetExternalSystemAddress | ( | void | ) |
Definition at line 181 of file NetworkIDManager.cpp.
RakNetGUID NetworkIDManager::GetGuid | ( | void | ) |
Definition at line 191 of file NetworkIDManager.cpp.
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.
Definition at line 159 of file NetworkIDManager.cpp.
bool NetworkIDManager::IsNetworkIDAuthority | ( | void | ) | const |
Definition at line 151 of file NetworkIDManager.cpp.
void NetworkIDManager::SetExternalSystemAddress | ( | SystemAddress | systemAddress | ) |
[in] | systemAddress | Your external systemAddress |
Definition at line 174 of file NetworkIDManager.cpp.
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.
Definition at line 187 of file NetworkIDManager.cpp.
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.
[in] | i | the highest number of NetworkIDObject reached. |
Definition at line 167 of file NetworkIDManager.cpp.
friend class NetworkIDObject [friend] |
Definition at line 108 of file NetworkIDManager.h.
bool NetworkIDManager::calledSetIsNetworkIDAuthority [protected] |
Definition at line 107 of file NetworkIDManager.h.
SystemAddress NetworkIDManager::externalSystemAddress [protected] |
Definition at line 104 of file NetworkIDManager.h.
RakNetGUID NetworkIDManager::guid [protected] |
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.
bool NetworkIDManager::isNetworkIDAuthority [protected] |
Definition at line 106 of file NetworkIDManager.h.
unsigned short NetworkIDManager::sharedNetworkID [protected] |
Definition at line 105 of file NetworkIDManager.h.