#include <DistributedNetworkObject.h>
Inheritance diagram for DistributedNetworkObject:
Public Member Functions | |
DistributedNetworkObject () | |
virtual | ~DistributedNetworkObject () |
virtual void | UpdateDistributedObject (char *classID, bool isClassIDEncoded=false) |
virtual void | SetMaximumUpdateFrequency (unsigned long frequency) |
virtual void | DestroyObjectOnNetwork (void) |
virtual bool | AllowSpectatorUpdate (PlayerID sender) |
void | SynchronizeMemory (unsigned char memoryBlockIndex, char *memoryBlock, unsigned short memoryBlockSize, bool serverAuthority) |
void | DesynchronizeMemory (unsigned char memoryBlockIndex) |
void | SetAuthority (unsigned char memoryBlockIndex, bool serverAuthority) |
bool | IsMemoryBlockIndexUsed (unsigned char memoryBlockIndex) |
void | SetMaxMemoryBlockUpdateFrequency (unsigned char memoryBlockIndex, int max) |
virtual void | WriteCreationData (RakNet::BitStream *initialData) |
virtual void | ReadCreationData (RakNet::BitStream *initialData) |
virtual void | OnNetworkUpdate (PlayerID sender) |
virtual bool | OnDistributedObjectCreation (PlayerID senderID) |
virtual void | OnDistributedObjectDestruction (PlayerID senderID) |
virtual void | OnDistributedObjectRejection (void) |
virtual void | BroadcastSerializedClass (RakNet::BitStream *bitStream, PlayerID doNotSendTo) |
virtual void | SerializeClassHeader (RakNet::BitStream *bitStream, char *classIdentifier, int action, bool localObject, unsigned char localObjectIndex) |
bool | IsLocalObject (void) const |
void | SetLocalObject (bool b) |
virtual bool | ProcessDistributedMemoryStack (RakNet::BitStream *bitStream, bool isWrite, bool forceWrite, bool isServerAuthoritative) |
bool | WriteToBitstreamFromHeap (RakNet::BitStream *bitStream, bool forceWrite) |
void | WriteToHeapFromBitstream (RakNet::BitStream *bitStream) |
unsigned char | GetLocalObjectIdentifier (void) const |
PlayerID | GetClientOwnerID (void) const |
void | SetClientOwnerID (PlayerID id) |
Static Public Member Functions | |
static bool | DeserializeClassHeader (RakNet::BitStream *bitStream, int &action, ObjectID &objectId, char classIdentifier[MAXIMUM_CLASS_IDENTIFIER_LENGTH], bool &localObject, unsigned char &localObjectIndex, PlayerID &pid) |
Protected Member Functions | |
virtual void | DistributedMemoryInit (bool isServerAuthoritative) |
virtual void | InterpolateDistributedMemory (bool isServerAuthoritative) |
Protected Attributes | |
unsigned long | maximumUpdateFrequency |
unsigned long | lastBroadcastTime |
bool | localObject |
unsigned char | localObjectIdentifier |
bool | distributedMemoryInitialized |
PlayerID | clientOwnerID |
struct { | |
char * watchedData | |
char * lastWriteValue | |
int allocatedBlockSize | |
int maximumUpdateInterval | |
unsigned short usedBlockSize | |
bool serverAuthority | |
unsigned long nextUpdateTime | |
} | heapNodeList [256] |
The ditributed Network Object System rely mostly on this class. It's the base class for all Distributed Object. You should specialize this class to define DNO objects.
|
Default Constructor |
|
Destructor |
|
Server only function By default, when a client creates an object only it can update the client authoritative members Of the class it creates. You can also set this manually with SetClientOwnerID This function is called when a client that does not own an object tries to change any fields in that object Return true to allow the update. Return false (default) to not allow the update. |
|
-------------------------------------------------------------------------- All functions below are used by the API and do not need to be called or modified -------------------------------------------------------------------------- You don't need to modify this Sends the bitstream to other systems |
|
You don't need to modify this Writes the header identifying the class, objectID, and whether the object is being created or destroyed action of 0 means destruction, 1 means update, 2 means create |
|
This broadcasts a request to destroy an object on the network. OnDistrubtedObjectDestruction will be called. If you wish to block deletion, override OnDistributedObjectDestruction |
|
Untags memory that was formerly synchronized. |
|
You don't need to modify this Initializes distributed object the first time it is used |
|
This is set to who created this object. On the server, this also determines who can update the client authoritative members of this object. You can manually set it to UNASSIGNED_PLAYER_ID so no client owns the object, so any client can update the object. |
|
You don't need to modify this Returns the identifier for an object that has not yet had SetID called on it |
|
You don't need to modify this Interpolates between all variables on the network that are set to interpolate. This function does not need to be modified by the end-user |
|
You don't need to modify this Returns true if this object was locally created, as opposed to created by the network |
|
Tells you if a block of memory was formerly used. You probably will never need this. |
|
This is called when the object is created by the network. Return true to accept the new object, false to reject it. The return value is primarily useful for the server to reject objects created by the client. On the client you would normally return true senderID is the playerID of the player that created the object (or the server, which you can get from RakClientInterface::GetServerID) |
|
This is called when the object is destroyed by the network. Default behavior is to delete itself. You can override this if you want to delete it elsewhere, or at a later time. If you don't delete the object, you should call DestroyObjectOnNetwork manually to remove it from the network Note it is important to override this on the server for objects you don't want clients to delete senderID is the playerID of the player that created the object (or the server, which you can get from RakClientInterface::GetServerID) |
|
This is called when the server rejects an object the client created. Default behavior is to destroy the object. You can override this to destroy the object yourself. |
|
When distributed data changes for an object, this function gets called. Default behavior is to do nothing. Override it if you want to perform updates when data is changed On the server it is also important to override this to make sure the data the client just sent you is reasonable. |
|
Writes to or reads from a bitstream for all distributed memory on the stack. This function does not need to be modified by the end-user Returns true if any data was written |
|
When an object is created, ReadCreationData is called immediately after a successful call to OnDistributedObjectCreation This function is for you to read any data written from WriteCreationData on remote systems. If the object is created by the client, this function is also called by the creator of the object when sent back from the server in case the server overrode any settings |
|
You don't need to modify this Writes the header identifying the class, objectID, and whether the object is being created or destroyed action of 0 means destruction, 1 means update, 2 means create |
|
Changes the authority for memory. You probably will never need this. |
|
This is set to who created this object. On the server, this also determines who can update the client authoritative members of this object. You can manually set it to UNASSIGNED_PLAYER_ID so no client owns the object, so any client can update the object. |
|
You don't need to modify this Returns true if this object was locally created, as opposed to created by the network |
|
Sets the maximum frequency with which memory synchronization packets can be sent. Lower values increase granularity but require more bandwidth |
|
Use this to set a maximum update frequency higher than what was specified to SetMaximumUpdateFrequency Lower values have no effect. |
|
Runtime memory synchronization This system allows you to flag blocks of memory for synchronization between systems. This is different from REGISTER_X_DISTRIBUTED_OBJECT_MEMBERS in that you can set this up at runtime. All synchronized blocks of memory are identified by a unique unsigned char. This char should match between systems for the same memory block. You can use any value for the identifier as long as it is unique. Tags memory to be synchronized. You can set the server or the client as the authority for this block. Only the authority will write this memory to the network when it is changed. |
|
Call this every update cycle for every distributed object that you want updated over the network and to interpolate classID should be a unique identifier for the class that matches the parameter to REGISTER_DISTRIBUTED_CLASS The obvious choice is the name of the class - however you can use something shorter if you wish to save a bit of bandwidth |
|
-------------------------------------------------------------------------- Events -------------------------------------------------------------------------- When object creation data is needed, WriteCreationData is called. This function is for you to write any data that is needed to create or initialize the object On remote systems |
|
Same as ProcessDistributedMemoryStack with isWrite to false, but for the heapNodeList. Returns true if data was written |
|
Same as ProcessDistributedMemoryStack with isWrite to true, but for the heapNodeList. |
|
|
|
Which client is allowed to change the client authoritative members of this object |
|
This records if the distributed memory was initialized via DistributedMemoryInit |
|
|
|
lastBroadcastTime is the last time we sent a packet from this class |
|
|
|
localObject means this object was created on the local system. If false, it means it was created by the network |
|
If this is a local object, this identifies it uniquely |
|
lastBroadcastTime is the last time we sent a packet from this class |
|
|
|
|
|
|
|
|
|
|