Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

NetworkIDObject Class Reference

Unique shared ids for each object instance. More...

#include <NetworkIDObject.h>

Inherited by RakNet::Replica2, RakNet::Replica3, and Replica.

Collaboration diagram for NetworkIDObject:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NetworkIDObject ()
virtual ~NetworkIDObject ()
virtual void SetNetworkIDManager (NetworkIDManager *manager)
virtual NetworkIDManagerGetNetworkIDManager (void)
 Returns what was passed to SetNetworkIDManager.
virtual NetworkID GetNetworkID (void)
virtual void SetNetworkID (NetworkID id)
virtual void SetParent (void *_parent)
virtual void * GetParent (void) const
virtual bool RequiresSetParent (void) const
uint32_t GetAllocationNumber (void) const
 Used so I can compare pointers in the ReplicaManager.

Protected Member Functions

void GenerateID (void)
 Internal function to generate an ID when needed. This is deferred until needed and is not called from the constructor.

Protected Attributes

NetworkID networkID
 The network ID of this object.
void * parent
 The parent set by SetParent().
uint32_t allocationNumber
bool callGenerationCode
 This is crap but is necessary because virtual functions don't work in the constructor.
NetworkIDManagernetworkIDManager

Static Protected Attributes

static uint32_t nextAllocationNumber = 0
 Used so I can compare pointers in the ReplicaManager.

Detailed Description

Unique shared ids for each object instance.

A class you can derive from to make it easier to represent every networked object with an integer. This way you can refer to objects over the network. One system should return true for IsNetworkIDAuthority() and the rest should return false. When an object needs to be created, have the the one system create the object. Then have that system send a message to all other systems, and include the value returned from GetNetworkID() in that packet. All other systems should then create the same class of object, and call SetNetworkID() on that class with the NetworkID in the packet.

See also:
the manual for more information on this.

Definition at line 24 of file NetworkIDObject.h.


Constructor & Destructor Documentation

NetworkIDObject::NetworkIDObject (  ) 

Definition at line 20 of file NetworkIDObject.cpp.

NetworkIDObject::~NetworkIDObject (  )  [virtual]

Definition at line 32 of file NetworkIDObject.cpp.

Here is the call graph for this function:


Member Function Documentation

void NetworkIDObject::GenerateID ( void   )  [protected]

Internal function to generate an ID when needed. This is deferred until needed and is not called from the constructor.

Definition at line 187 of file NetworkIDObject.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t NetworkIDObject::GetAllocationNumber ( void   )  const

Used so I can compare pointers in the ReplicaManager.

Definition at line 182 of file NetworkIDObject.cpp.

Here is the caller graph for this function:

NetworkID NetworkIDObject::GetNetworkID ( void   )  [virtual]

Returns the NetworkID that you can use to refer to this object over the network.

Precondition:
You must first call SetNetworkIDManager before using this function
Return values:
UNASSIGNED_NETWORK_ID UNASSIGNED_NETWORK_ID is returned IsNetworkIDAuthority() is false and SetNetworkID() was not previously called. This is also returned if you call this function in the constructor.
0-65534 Any other value is a valid NetworkID. NetworkIDs start at 0 and go to 65534, wrapping at that point.

Definition at line 66 of file NetworkIDObject.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NetworkIDManager * NetworkIDObject::GetNetworkIDManager ( void   )  [virtual]

Returns what was passed to SetNetworkIDManager.

Definition at line 59 of file NetworkIDObject.cpp.

Here is the caller graph for this function:

void * NetworkIDObject::GetParent ( void   )  const [virtual]

Return what was passed to SetParent

Returns:
The value passed to SetParent, or 0 if it was never called.

Definition at line 177 of file NetworkIDObject.cpp.

Here is the caller graph for this function:

bool NetworkIDObject::RequiresSetParent ( void   )  const [virtual]

Overload this function and return true if you require that SetParent is called before this object is used. This is a safety check you should do this if you want this to be a member object of another class rather than derive from this class.

Definition at line 80 of file NetworkIDObject.cpp.

Here is the caller graph for this function:

void NetworkIDObject::SetNetworkID ( NetworkID  id  )  [virtual]

Sets the NetworkID for this instance. Usually this is called by the clients and determined from the servers. However, if you save multiplayer games you would likely use This on load as well.

Definition at line 87 of file NetworkIDObject.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkIDObject::SetNetworkIDManager ( NetworkIDManager manager  )  [virtual]

Sets the manager class from which to request unique network IDs Unlike previous versions, the NetworkIDObject relies on a manager class to provide IDs, rather than using statics, So you can have more than one set of IDs on the same system.

Definition at line 52 of file NetworkIDObject.cpp.

Here is the caller graph for this function:

void NetworkIDObject::SetParent ( void *  _parent  )  [virtual]

Your class does not have to derive from NetworkIDObject, although that is the easiest way to implement this. If you want this to be a member object of another class, rather than inherit, then call SetParent() with a pointer to the parent class instance. GET_OBJECT_FROM_ID will then return the parent rather than this instance.

Definition at line 133 of file NetworkIDObject.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 77 of file NetworkIDObject.h.

This is crap but is necessary because virtual functions don't work in the constructor.

Definition at line 83 of file NetworkIDObject.h.

The network ID of this object.

Definition at line 70 of file NetworkIDObject.h.

Definition at line 85 of file NetworkIDObject.h.

Used so I can compare pointers in the ReplicaManager.

Definition at line 76 of file NetworkIDObject.h.

void* NetworkIDObject::parent [protected]

The parent set by SetParent().

Definition at line 73 of file NetworkIDObject.h.


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