# NetworkIDManager Class Reference

`#include <NetworkIDManager.h>`

List of all members.

## Public Member Functions
void | SetIsNetworkIDAuthority (bool isAuthority)
bool | IsNetworkIDAuthority (void) const
void | SetExternalSystemAddress (SystemAddress systemAddress)
void | SetGuid (RakNetGUID g)
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
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

## 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

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

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

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

bool NetworkIDManager::IsNetworkIDAuthority | ( | void |  | ) | const

Returns:
  Returns what was passed to SetIsNetworkIDAuthority()

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

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

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

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.

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

- d:/RakNet-3.x/Source/NetworkIDManager.h