Shadowrun: Awakened 29 September 2011 - Build 871
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
RakNet::Connection_RM3 Class Reference

Each remote system is represented by Connection_RM3. Used to allocate Replica3 and track which instances have been allocated. More...

#include <ReplicaManager3.h>

List of all members.

Public Types

enum  ConstructionMode { QUERY_REPLICA_FOR_CONSTRUCTION, QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION, QUERY_CONNECTION_FOR_REPLICA_LIST }
 List of enumerations for how to get the list of valid objects for other systems. More...

Public Member Functions

virtual Replica3AllocReplica (RakNet::BitStream *allocationIdBitstream, ReplicaManager3 *replicaManager3)=0
 Class factory to create a Replica3 instance, given a user-defined identifier.
void AutoConstructByQuery (ReplicaManager3 *replicaManager3)
 Connection_RM3 (const SystemAddress &_systemAddress, RakNetGUID _guid)
void CullUniqueNewAndDeletedObjects (DataStructures::Multilist< ML_STACK, Replica3 * > &newObjectsIn, DataStructures::Multilist< ML_STACK, Replica3 * > &deletedObjectsIn, DataStructures::Multilist< ML_STACK, Replica3 * > &newObjectsOut, DataStructures::Multilist< ML_STACK, Replica3 * > &deletedObjectsOut)
virtual void DeserializeOnDownloadComplete (RakNet::BitStream *bitStream)
virtual void DeserializeOnDownloadStarted (RakNet::BitStream *bitStream)
virtual void GetConstructedReplicas (DataStructures::Multilist< ML_STACK, Replica3 * > &objectsTheyDoHave)
 Get list of all replicas that are constructed for this connection.
RakNetGUID GetRakNetGUID (void) const
SystemAddress GetSystemAddress (void) const
bool HasReplicaConstructed (RakNet::Replica3 *replica)
virtual ConstructionMode QueryConstructionMode (void) const
 Queries how to get the list of objects that exist on remote systems.
virtual bool QueryGroupDownloadMessages (void) const
 Return whether or not downloads to our system should all be processed the same tick (call to RakPeer::Receive() )
virtual void QueryReplicaList (DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * > newReplicasToCreate, DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * > existingReplicasToDestroy)
 Callback used when QueryConstructionMode() returns QUERY_CONNECTION_FOR_REPLICA_LIST.
virtual void SendConstruction (DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * > &newObjects, DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * > &deletedObjects, PRO sendParameters, RakNet::RakPeerInterface *rakPeer, unsigned char worldId, ReplicaManager3 *replicaManager3)
virtual
SendSerializeIfChangedResult 
SendSerialize (RakNet::Replica3 *replica, bool indicesToSend[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], RakNet::BitStream serializationData[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], RakNet::Time timestamp, PRO sendParameters[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], RakNet::RakPeerInterface *rakPeer, unsigned char worldId)
virtual
SendSerializeIfChangedResult 
SendSerializeIfChanged (DataStructures::DefaultIndexType queryToSerializeIndex, SerializeParameters *sp, RakNet::RakPeerInterface *rakPeer, unsigned char worldId, ReplicaManager3 *replicaManager)
void SendValidation (RakNet::RakPeerInterface *rakPeer, unsigned char worldId)
virtual void SerializeOnDownloadComplete (RakNet::BitStream *bitStream)
virtual void SerializeOnDownloadStarted (RakNet::BitStream *bitStream)
virtual ~Connection_RM3 ()

Public Attributes

bool isFirstConstruction
bool isValidated

Protected Member Functions

void ClearDownloadGroup (RakPeerInterface *rakPeerInterface)
void OnConstructToThisConnection (DataStructures::DefaultIndexType queryToConstructIdx, ReplicaManager3 *replicaManager)
void OnConstructToThisConnection (Replica3 *replica, ReplicaManager3 *replicaManager)
void OnDereference (Replica3 *replica3, ReplicaManager3 *replicaManager)
void OnDoNotQueryDestruction (DataStructures::DefaultIndexType queryToDestructIdx, ReplicaManager3 *replicaManager)
void OnDownloadExisting (Replica3 *replica3, ReplicaManager3 *replicaManager)
void OnDownloadFromOtherSystem (Replica3 *replica3, ReplicaManager3 *replicaManager)
void OnDownloadFromThisSystem (Replica3 *replica3, ReplicaManager3 *replicaManager)
void OnLocalReference (Replica3 *replica3, ReplicaManager3 *replicaManager)
void OnNeverConstruct (DataStructures::DefaultIndexType queryToConstructIdx, ReplicaManager3 *replicaManager)
void OnNeverSerialize (DataStructures::DefaultIndexType queryToSerializeIndex, ReplicaManager3 *replicaManager)
void OnReplicaAlreadyExists (DataStructures::DefaultIndexType queryToConstructIdx, ReplicaManager3 *replicaManager)
void OnSendDestructionFromQuery (DataStructures::DefaultIndexType queryToDestructIdx, ReplicaManager3 *replicaManager)
void SendSerializeHeader (RakNet::Replica3 *replica, RakNet::Time timestamp, RakNet::BitStream *bs, unsigned char worldId)
void ValidateLists (ReplicaManager3 *replicaManager) const

Protected Attributes

DataStructures::Multilist
< ML_ORDERED_LIST,
LastSerializationResult
*, Replica3 * > 
constructedReplicaList
DataStructures::Multilist
< ML_STACK, Replica3
*, Replica3 * > 
constructedReplicasCulled
DataStructures::Multilist
< ML_STACK, Replica3
*, Replica3 * > 
destroyedReplicasCulled
DataStructures::Multilist
< ML_QUEUE, Packet *, Packet * > 
downloadGroup
bool groupConstructionAndSerialize
RakNetGUID guid
DataStructures::Multilist
< ML_STACK,
LastSerializationResult
*, Replica3 * > 
queryToConstructReplicaList
DataStructures::Multilist
< ML_STACK,
LastSerializationResult
*, Replica3 * > 
queryToDestructReplicaList
DataStructures::Multilist
< ML_STACK,
LastSerializationResult
*, Replica3 * > 
queryToSerializeReplicaList
SystemAddress systemAddress

Private Member Functions

 Connection_RM3 ()

Private Attributes

ConstructionMode constructionMode

Friends

class ReplicaManager3

Detailed Description

Important function: AllocReplica() - must be overridden to create an object given an identifier for that object, which you define for all objects in your game

Definition at line 356 of file ReplicaManager3.h.


Member Enumeration Documentation

Enumerator:
QUERY_REPLICA_FOR_CONSTRUCTION 

For every object that does not exist on the remote system, call Replica3::QueryConstruction() every tick. Do not call Replica3::QueryDestruction() Do not call Connection_RM3::QueryReplicaList()

QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION 

For every object that does not exist on the remote system, call Replica3::QueryConstruction() every tick. Based on the call, the object may be sent to the other system. For every object that does exist on the remote system, call Replica3::QueryDestruction() every tick. Based on the call, the object may be deleted on the other system. Do not call Connection_RM3::QueryReplicaList()

QUERY_CONNECTION_FOR_REPLICA_LIST 

Do not call Replica3::QueryConstruction() or Replica3::QueryDestruction() Call Connection_RM3::QueryReplicaList() to determine which objects exist on remote systems This can be faster than QUERY_REPLICA_FOR_CONSTRUCTION and QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION for large worlds See GridSectorizer.h under /Source for code that can help with this

Definition at line 408 of file ReplicaManager3.h.


Constructor & Destructor Documentation

RakNet::Connection_RM3::Connection_RM3 ( const SystemAddress _systemAddress,
RakNetGUID  _guid 
)
virtual RakNet::Connection_RM3::~Connection_RM3 ( ) [virtual]
RakNet::Connection_RM3::Connection_RM3 ( ) [inline, private]

Definition at line 606 of file ReplicaManager3.h.

{};

Member Function Documentation

virtual Replica3* RakNet::Connection_RM3::AllocReplica ( RakNet::BitStream allocationIdBitstream,
ReplicaManager3 replicaManager3 
) [pure virtual]

Identifier is returned by Replica3::WriteAllocationID() for what type of class to create.
This is called when you download a replica from another system.
See Replica3::Dealloc for the corresponding destruction message.
Return 0 if unable to create the intended object. Note, in that case the other system will still think we have the object and will try to serialize object updates to us. Generally, you should not send objects the other system cannot create.

See also:
Replica3::WriteAllocationID(). Sample implementation:
{RakNet::RakString typeName; allocationIdBitstream->Read(typeName); if (typeName=="Soldier") return new Soldier; return 0;}
Parameters:
[in]allocationIdBitstreamuser-defined bitstream uniquely identifying a game object type
[in]replicaManager3Instance of ReplicaManager3 that controls this connection
Returns:
The new replica instance
void RakNet::Connection_RM3::AutoConstructByQuery ( ReplicaManager3 replicaManager3)
void RakNet::Connection_RM3::ClearDownloadGroup ( RakPeerInterface rakPeerInterface) [protected]
void RakNet::Connection_RM3::CullUniqueNewAndDeletedObjects ( DataStructures::Multilist< ML_STACK, Replica3 * > &  newObjectsIn,
DataStructures::Multilist< ML_STACK, Replica3 * > &  deletedObjectsIn,
DataStructures::Multilist< ML_STACK, Replica3 * > &  newObjectsOut,
DataStructures::Multilist< ML_STACK, Replica3 * > &  deletedObjectsOut 
)
virtual void RakNet::Connection_RM3::DeserializeOnDownloadComplete ( RakNet::BitStream bitStream) [inline, virtual]

Receives whatever was written in DeserializeOnDownloadComplete()

Parameters:
[in]bitStreamWritten in SerializeOnDownloadComplete()

Definition at line 399 of file ReplicaManager3.h.

{(void) bitStream;}
virtual void RakNet::Connection_RM3::DeserializeOnDownloadStarted ( RakNet::BitStream bitStream) [inline, virtual]

Receives whatever was written in SerializeOnDownloadStarted()

Parameters:
[in]bitStreamWritten in SerializeOnDownloadStarted()

Definition at line 391 of file ReplicaManager3.h.

{(void) bitStream;}
virtual void RakNet::Connection_RM3::GetConstructedReplicas ( DataStructures::Multilist< ML_STACK, Replica3 * > &  objectsTheyDoHave) [virtual]
Parameters:
[out]objectsTheyDoHaveDestination list. Returned in sorted ascending order, sorted on the value of the Replica3 pointer.
RakNetGUID RakNet::Connection_RM3::GetRakNetGUID ( void  ) const [inline]
Returns:
Returns the RakNetGUID passed to the constructor of this object

Definition at line 405 of file ReplicaManager3.h.

{return guid;}
SystemAddress RakNet::Connection_RM3::GetSystemAddress ( void  ) const [inline]
Returns:
The system address passed to the constructor of this object

Definition at line 402 of file ReplicaManager3.h.

{return systemAddress;}
bool RakNet::Connection_RM3::HasReplicaConstructed ( RakNet::Replica3 replica)

Returns true if we think this remote connection has this replica constructed

Parameters:
[in]replica3Which replica we are querying
Returns:
True if constructed, false othewise
void RakNet::Connection_RM3::OnConstructToThisConnection ( DataStructures::DefaultIndexType  queryToConstructIdx,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnConstructToThisConnection ( Replica3 replica,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnDereference ( Replica3 replica3,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnDoNotQueryDestruction ( DataStructures::DefaultIndexType  queryToDestructIdx,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnDownloadExisting ( Replica3 replica3,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnDownloadFromOtherSystem ( Replica3 replica3,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnDownloadFromThisSystem ( Replica3 replica3,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnLocalReference ( Replica3 replica3,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnNeverConstruct ( DataStructures::DefaultIndexType  queryToConstructIdx,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnNeverSerialize ( DataStructures::DefaultIndexType  queryToSerializeIndex,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnReplicaAlreadyExists ( DataStructures::DefaultIndexType  queryToConstructIdx,
ReplicaManager3 replicaManager 
) [protected]
void RakNet::Connection_RM3::OnSendDestructionFromQuery ( DataStructures::DefaultIndexType  queryToDestructIdx,
ReplicaManager3 replicaManager 
) [protected]
virtual ConstructionMode RakNet::Connection_RM3::QueryConstructionMode ( void  ) const [inline, virtual]

The default of calling QueryConstruction for every known object is easy to use, but not efficient, especially for large worlds where many objects are outside of the player's circle of influence.
QueryDestruction is also not necessarily useful or efficient, as object destruction tends to happen in known cases, and can be accomplished by calling Replica3::BroadcastDestruction() QueryConstructionMode() allows you to specify more efficient algorithms than the default when overriden.

Returns:
How to get the list of objects that exist on the remote system. You should always return the same value for a given connection

Definition at line 442 of file ReplicaManager3.h.

virtual bool RakNet::Connection_RM3::QueryGroupDownloadMessages ( void  ) const [inline, virtual]

Normally the system will send ID_REPLICA_MANAGER_DOWNLOAD_STARTED, ID_REPLICA_MANAGER_CONSTRUCTION for all downloaded objects, ID_REPLICA_MANAGER_SERIALIZE for each downloaded object, and lastly ID_REPLICA_MANAGER_DOWNLOAD_COMPLETE. This enables the application to show a downloading splash screen on ID_REPLICA_MANAGER_DOWNLOAD_STARTED, a progress bar, and to close the splash screen and activate all objects on ID_REPLICA_MANAGER_DOWNLOAD_COMPLETE However, if the application was not set up for this then it would result in incomplete objects spread out over time, and cause problems If you return true from QueryGroupDownloadMessages(), then these messages will be returned all in one tick, returned only when the download is complete

Note:
ID_REPLICA_MANAGER_DOWNLOAD_STARTED calls the callback DeserializeOnDownloadStarted()
ID_REPLICA_MANAGER_DOWNLOAD_COMPLETE calls the callback DeserializeOnDownloadComplete()

Definition at line 435 of file ReplicaManager3.h.

{return false;}
virtual void RakNet::Connection_RM3::QueryReplicaList ( DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * >  newReplicasToCreate,
DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * >  existingReplicasToDestroy 
) [inline, virtual]

This advantage of this callback is if that there are many objects that a particular connection does not have, then we do not have to iterate through those objects calling QueryConstruction() for each of them.
BR> The following code uses a sorted merge sort to quickly find new and deleted objects, given a list of objects we know should exist.
BR> DataStructures::Multilist<ML_STACK, Replica3*, Replica3*> objectsTheyShouldHave; // You have to fill in this list
DataStructures::Multilist<ML_STACK, Replica3*, Replica3*> objectsTheyCurrentlyHave,objectsTheyStillHave,existingReplicasToDestro,newReplicasToCreatey;
GetConstructedReplicas(objectsTheyCurrentlyHave);
DataStructures::Multilist::FindIntersection(objectsTheyCurrentlyHave, objectsTheyShouldHave, objectsTheyStillHave, existingReplicasToDestroy, newReplicasToCreate);
BR> See GridSectorizer in the Source directory as a method to find all objects within a certain radius in a fast way.
BR>

Parameters:
[out]newReplicasToCreateAnything in this list will be created on the remote system
[out]existingReplicasToDestroyAnything in this list will be destroyed on the remote system

Definition at line 459 of file ReplicaManager3.h.

                                                                                           {}
virtual void RakNet::Connection_RM3::SendConstruction ( DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * > &  newObjects,
DataStructures::Multilist< ML_STACK, Replica3 *, Replica3 * > &  deletedObjects,
PRO  sendParameters,
RakNet::RakPeerInterface rakPeer,
unsigned char  worldId,
ReplicaManager3 replicaManager3 
) [virtual]
virtual SendSerializeIfChangedResult RakNet::Connection_RM3::SendSerialize ( RakNet::Replica3 replica,
bool  indicesToSend[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS],
RakNet::BitStream  serializationData[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS],
RakNet::Time  timestamp,
PRO  sendParameters[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS],
RakNet::RakPeerInterface rakPeer,
unsigned char  worldId 
) [virtual]
void RakNet::Connection_RM3::SendSerializeHeader ( RakNet::Replica3 replica,
RakNet::Time  timestamp,
RakNet::BitStream bs,
unsigned char  worldId 
) [protected]
virtual SendSerializeIfChangedResult RakNet::Connection_RM3::SendSerializeIfChanged ( DataStructures::DefaultIndexType  queryToSerializeIndex,
SerializeParameters sp,
RakNet::RakPeerInterface rakPeer,
unsigned char  worldId,
ReplicaManager3 replicaManager 
) [virtual]
void RakNet::Connection_RM3::SendValidation ( RakNet::RakPeerInterface rakPeer,
unsigned char  worldId 
)
virtual void RakNet::Connection_RM3::SerializeOnDownloadComplete ( RakNet::BitStream bitStream) [inline, virtual]

When a new connection connects, after constructing and serialization all objects, SerializeOnDownloadComplete() is called

Parameters:
[out]bitStreamPassed to DeserializeOnDownloadComplete()

Definition at line 395 of file ReplicaManager3.h.

{(void) bitStream;}
virtual void RakNet::Connection_RM3::SerializeOnDownloadStarted ( RakNet::BitStream bitStream) [inline, virtual]

When a new connection connects, before sending any objects, SerializeOnDownloadStarted() is called

Parameters:
[out]bitStreamPassed to DeserializeOnDownloadStarted()

Definition at line 387 of file ReplicaManager3.h.

{(void) bitStream;}
void RakNet::Connection_RM3::ValidateLists ( ReplicaManager3 replicaManager) const [protected]

Friends And Related Function Documentation

friend class ReplicaManager3 [friend]

Definition at line 604 of file ReplicaManager3.h.


Member Data Documentation

Definition at line 581 of file ReplicaManager3.h.

Definition at line 596 of file ReplicaManager3.h.

Definition at line 606 of file ReplicaManager3.h.

Definition at line 596 of file ReplicaManager3.h.

Definition at line 601 of file ReplicaManager3.h.

Definition at line 600 of file ReplicaManager3.h.

Definition at line 516 of file ReplicaManager3.h.

Definition at line 511 of file ReplicaManager3.h.

Definition at line 509 of file ReplicaManager3.h.

Definition at line 586 of file ReplicaManager3.h.

Definition at line 593 of file ReplicaManager3.h.

Definition at line 590 of file ReplicaManager3.h.

Definition at line 515 of file ReplicaManager3.h.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net