Shadowrun: Awakened 29 September 2011 - Build 871
ReplicaManager3.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "NativeFeatureIncludes.h"
00009 #if _RAKNET_SUPPORT_ReplicaManager3==1
00010 
00011 #ifndef __REPLICA_MANAGER_3
00012 #define __REPLICA_MANAGER_3
00013 
00014 #include "DS_Multilist.h"
00015 #include "RakNetTypes.h"
00016 #include "RakNetTime.h"
00017 #include "BitStream.h"
00018 #include "PacketPriority.h"
00019 #include "PluginInterface2.h"
00020 #include "NetworkIDObject.h"
00021 
00026 
00027 namespace RakNet
00028 {
00029 class Connection_RM3;
00030 class Replica3;
00031 
00032 
00035 struct PRO
00036 {
00038     PacketPriority priority;
00039 
00041     PacketReliability reliability;
00042 
00044     char orderingChannel;
00045 
00047     uint32_t sendReceipt;
00048 
00049     bool operator==( const PRO& right ) const;
00050     bool operator!=( const PRO& right ) const;
00051 };
00052 
00053 
00068 class RAK_DLL_EXPORT ReplicaManager3 : public PluginInterface2
00069 {
00070 public:
00071     ReplicaManager3();
00072     virtual ~ReplicaManager3();
00073 
00084     virtual Connection_RM3* AllocConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID) const=0;
00085 
00090     virtual void DeallocConnection(Connection_RM3 *connection) const=0;
00091 
00099     void SetAutoManageConnections(bool autoCreate, bool autoDestroy);
00100 
00105     bool PushConnection(RakNet::Connection_RM3 *newConnection);
00106 
00111     RakNet::Connection_RM3 * PopConnection(RakNetGUID guid);
00112 
00118     void Reference(RakNet::Replica3 *replica3);
00119 
00124     void Dereference(RakNet::Replica3 *replica3);
00125 
00130     void DereferenceList(DataStructures::Multilist<ML_STACK, Replica3*> &replicaListIn);
00131 
00137     void GetReplicasCreatedByGuid(RakNetGUID guid, DataStructures::Multilist<ML_STACK, Replica3*> &replicaListOut);
00138 
00142     void GetReplicasCreatedByMe(DataStructures::Multilist<ML_STACK, Replica3*> &replicaListOut);
00143 
00147     void GetReferencedReplicaList(DataStructures::Multilist<ML_STACK, Replica3*> &replicaListOut);
00148 
00152     unsigned GetReplicaCount(void) const;
00153 
00158     Replica3 *GetReplicaAtIndex(unsigned index);
00159 
00163     DataStructures::DefaultIndexType GetConnectionCount(void) const;
00164 
00168     Connection_RM3* GetConnectionAtIndex(unsigned index) const;
00169 
00173     Connection_RM3* GetConnectionBySystemAddress(const SystemAddress &sa) const;
00174 
00178     Connection_RM3* GetConnectionByGUID(RakNetGUID guid) const;
00179 
00181     void SetDefaultOrderingChannel(char def);
00182 
00184     void SetDefaultPacketPriority(PacketPriority def);
00185 
00187     void SetDefaultPacketReliability(PacketReliability def);
00188 
00194     void SetAutoSerializeInterval(RakNet::Time intervalMS);
00195 
00200     void GetConnectionsThatHaveReplicaConstructed(Replica3 *replica, DataStructures::Multilist<ML_STACK, Connection_RM3*> &connectionsThatHaveConstructedThisReplica);
00201 
00207     void SetWorldID(unsigned char id);
00208 
00210     unsigned char GetWorldID(void) const;
00211 
00216     void SetNetworkIDManager(NetworkIDManager *_networkIDManager);
00217 
00219     NetworkIDManager *GetNetworkIDManager(void) const;
00220 
00226     void BroadcastDestructionList(DataStructures::Multilist<ML_STACK, Replica3*> &replicaList, const SystemAddress &exclusionAddress);
00227 
00231     void BroadcastDestruction(Replica3 *replica, const SystemAddress &exclusionAddress);
00232 
00236     void Clear(void);
00237 
00239     PRO GetDefaultSendParameters(void) const;
00240 
00242     virtual void Update(void);
00243 protected:
00244     virtual PluginReceiveResult OnReceive(Packet *packet);
00245     virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
00246     virtual void OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming);
00247     virtual void OnRakPeerShutdown(void);
00248     virtual void OnDetach(void);
00249 
00250     PluginReceiveResult OnConstruction(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, unsigned char packetDataOffset);
00251     PluginReceiveResult OnSerialize(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, RakNet::Time timestamp, unsigned char packetDataOffset);
00252     PluginReceiveResult OnDownloadStarted(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, unsigned char packetDataOffset);
00253     PluginReceiveResult OnDownloadComplete(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, unsigned char packetDataOffset);
00254 
00255     RakNet::Connection_RM3 * PopConnection(DataStructures::DefaultIndexType index);
00256     Replica3* GetReplicaByNetworkID(NetworkID networkId);
00257     DataStructures::DefaultIndexType ReferenceInternal(RakNet::Replica3 *replica3);
00258 
00259     DataStructures::Multilist<ML_STACK, Connection_RM3*> connectionList;
00260     DataStructures::Multilist<ML_STACK, Replica3*> userReplicaList;
00261 
00262     PRO defaultSendParameters;
00263     RakNet::Time autoSerializeInterval;
00264     RakNet::Time lastAutoSerializeOccurance;
00265     unsigned char worldId;
00266     NetworkIDManager *networkIDManager;
00267     bool autoCreateConnections, autoDestroyConnections;
00268 
00269     friend class Connection_RM3;
00270 };
00271 
00272 static const int RM3_NUM_OUTPUT_BITSTREAM_CHANNELS=8;
00273 
00275 struct LastSerializationResultBS
00276 {
00277     RakNet::BitStream bitStream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00278     bool indicesToSend[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00279 };
00280 
00283 struct LastSerializationResult
00284 {
00285     LastSerializationResult();
00286     ~LastSerializationResult();
00287     
00289     RakNet::Replica3 *replica;
00290     //bool neverSerialize;
00291 //  bool isConstructed;
00292 
00293     void AllocBS(void);
00294     LastSerializationResultBS* lastSerializationResultBS;
00295 };
00296 
00299 struct SerializeParameters
00300 {
00304     RakNet::BitStream outputBitstream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00305 
00308     RakNet::BitStream* lastSentBitstream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00309 
00313     RakNet::Time messageTimestamp;
00314 
00318     PRO pro[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00319 
00321     RakNet::Connection_RM3 *destinationConnection;
00322 
00325     BitSize_t bitsWrittenSoFar;
00326 
00329     RakNet::Time whenLastSerialized;
00330 
00333     RakNet::Time curTime;
00334 };
00335 
00337 struct DeserializeParameters
00338 {
00339     RakNet::BitStream serializationBitstream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00340     bool bitstreamWrittenTo[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
00341     RakNet::Time timeStamp;
00342     RakNet::Connection_RM3 *sourceConnection;
00343 };
00344 
00346 enum SendSerializeIfChangedResult
00347 {
00348     SSICR_SENT_DATA,
00349     SSICR_DID_NOT_SEND_DATA,
00350     SSICR_NEVER_SERIALIZE,
00351 };
00352 
00356 class RAK_DLL_EXPORT Connection_RM3
00357 {
00358 public:
00359 
00360     Connection_RM3(const SystemAddress &_systemAddress, RakNetGUID _guid);
00361     virtual ~Connection_RM3();
00362 
00374     virtual Replica3 *AllocReplica(RakNet::BitStream *allocationIdBitstream, ReplicaManager3 *replicaManager3)=0;
00375 
00378     virtual void GetConstructedReplicas(DataStructures::Multilist<ML_STACK, Replica3*> &objectsTheyDoHave);
00379 
00383     bool HasReplicaConstructed(RakNet::Replica3 *replica);
00384 
00387     virtual void SerializeOnDownloadStarted(RakNet::BitStream *bitStream) {(void) bitStream;}
00388 
00391     virtual void DeserializeOnDownloadStarted(RakNet::BitStream *bitStream) {(void) bitStream;}
00392 
00395     virtual void SerializeOnDownloadComplete(RakNet::BitStream *bitStream) {(void) bitStream;}
00396 
00399     virtual void DeserializeOnDownloadComplete(RakNet::BitStream *bitStream) {(void) bitStream;}
00400 
00402     SystemAddress GetSystemAddress(void) const {return systemAddress;}
00403 
00405     RakNetGUID GetRakNetGUID(void) const {return guid;}
00406 
00408     enum ConstructionMode
00409     {
00413         QUERY_REPLICA_FOR_CONSTRUCTION,
00414 
00418         QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION,
00419 
00424         QUERY_CONNECTION_FOR_REPLICA_LIST
00425     };
00426 
00435     virtual bool QueryGroupDownloadMessages(void) const {return false;}
00436 
00442     virtual ConstructionMode QueryConstructionMode(void) const {return QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION;}
00443 
00459     virtual void QueryReplicaList(
00460         DataStructures::Multilist<ML_STACK, Replica3*, Replica3*> newReplicasToCreate,
00461         DataStructures::Multilist<ML_STACK, Replica3*, Replica3*> existingReplicasToDestroy) {}
00462 
00472     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);
00473 
00481     virtual SendSerializeIfChangedResult SendSerializeIfChanged(DataStructures::DefaultIndexType queryToSerializeIndex, SerializeParameters *sp, RakNet::RakPeerInterface *rakPeer, unsigned char worldId, ReplicaManager3 *replicaManager);
00482 
00491     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);
00492 
00496     void CullUniqueNewAndDeletedObjects(DataStructures::Multilist<ML_STACK, Replica3*> &newObjectsIn,
00497         DataStructures::Multilist<ML_STACK, Replica3*> &deletedObjectsIn,
00498         DataStructures::Multilist<ML_STACK, Replica3*> &newObjectsOut,
00499         DataStructures::Multilist<ML_STACK, Replica3*> &deletedObjectsOut);
00500 
00502     void SendValidation(RakNet::RakPeerInterface *rakPeer, unsigned char worldId);
00503 
00505     void AutoConstructByQuery(ReplicaManager3 *replicaManager3);
00506 
00507 
00508     // Internal - does the other system have this connection too? Validated means we can now use it
00509     bool isValidated;
00510     // Internal - Used to see if we should send download started
00511     bool isFirstConstruction;
00512 
00513 protected:
00514 
00515     SystemAddress systemAddress;
00516     RakNetGUID guid;
00517 
00518     /*
00519         Operations:
00520 
00521         Locally reference a new replica:
00522         Add to queryToConstructReplicaList for all objects
00523 
00524         Add all objects to queryToConstructReplicaList
00525 
00526         Download:
00527         Add to constructedReplicaList for connection that send the object to us
00528         Add to queryToSerializeReplicaList for connection that send the object to us
00529         Add to queryToConstructReplicaList for all other connections
00530 
00531         Never construct for this connection:
00532         Remove from queryToConstructReplicaList
00533 
00534         Construct to this connection
00535         Remove from queryToConstructReplicaList
00536         Add to constructedReplicaList for this connection
00537         Add to queryToSerializeReplicaList for this connection
00538 
00539         Serialize:
00540         Iterate through queryToSerializeReplicaList
00541 
00542         Never serialize for this connection
00543         Remove from queryToSerializeReplicaList
00544 
00545         Reference (this system has this object already)
00546         Remove from queryToConstructReplicaList
00547         Add to constructedReplicaList for this connection
00548         Add to queryToSerializeReplicaList for this connection
00549 
00550         Downloaded an existing object
00551         if replica is in queryToConstructReplicaList, OnConstructToThisConnection()
00552         else ignore
00553 
00554         Send destruction from query
00555         Remove from queryToDestructReplicaList
00556         Remove from queryToSerializeReplicaList
00557         Remove from constructedReplicaList
00558         Add to queryToConstructReplicaList
00559 
00560         Do not query destruction again
00561         Remove from queryToDestructReplicaList
00562     */
00563     void OnLocalReference(Replica3* replica3, ReplicaManager3 *replicaManager);
00564     void OnDereference(Replica3* replica3, ReplicaManager3 *replicaManager);
00565     void OnDownloadFromThisSystem(Replica3* replica3, ReplicaManager3 *replicaManager);
00566     void OnDownloadFromOtherSystem(Replica3* replica3, ReplicaManager3 *replicaManager);
00567     void OnNeverConstruct(DataStructures::DefaultIndexType queryToConstructIdx, ReplicaManager3 *replicaManager);
00568     void OnConstructToThisConnection(DataStructures::DefaultIndexType queryToConstructIdx, ReplicaManager3 *replicaManager);
00569     void OnConstructToThisConnection(Replica3 *replica, ReplicaManager3 *replicaManager);
00570     void OnNeverSerialize(DataStructures::DefaultIndexType queryToSerializeIndex, ReplicaManager3 *replicaManager);
00571     void OnReplicaAlreadyExists(DataStructures::DefaultIndexType queryToConstructIdx, ReplicaManager3 *replicaManager);
00572     void OnDownloadExisting(Replica3* replica3, ReplicaManager3 *replicaManager);
00573     void OnSendDestructionFromQuery(DataStructures::DefaultIndexType queryToDestructIdx, ReplicaManager3 *replicaManager);
00574     void OnDoNotQueryDestruction(DataStructures::DefaultIndexType queryToDestructIdx, ReplicaManager3 *replicaManager);
00575     void ValidateLists(ReplicaManager3 *replicaManager) const;
00576     void SendSerializeHeader(RakNet::Replica3 *replica, RakNet::Time timestamp, RakNet::BitStream *bs, unsigned char worldId);
00577     
00578     // The list of objects that our local system and this remote system both have
00579     // Either we sent this object to them, or they sent this object to us
00580     // A given Replica can be either in queryToConstructReplicaList or constructedReplicaList but not both at the same time
00581     DataStructures::Multilist<ML_ORDERED_LIST, LastSerializationResult*, Replica3*> constructedReplicaList;
00582 
00583     // Objects that we have, but this system does not, and we will query each tick to see if it should be sent to them
00584     // If we do send it to them, the replica is moved to constructedReplicaList
00585     // A given Replica can be either in queryToConstructReplicaList or constructedReplicaList but not both at the same time
00586     DataStructures::Multilist<ML_STACK, LastSerializationResult*, Replica3*> queryToConstructReplicaList;
00587 
00588     // Objects that this system has constructed are added at the same time to queryToSerializeReplicaList
00589     // This list is used to serialize all objects that this system has to this connection
00590     DataStructures::Multilist<ML_STACK, LastSerializationResult*, Replica3*> queryToSerializeReplicaList;
00591 
00592     // Objects that are constructed on this system are also queried if they should be destroyed to this system
00593     DataStructures::Multilist<ML_STACK, LastSerializationResult*, Replica3*> queryToDestructReplicaList;
00594 
00595     // Working lists
00596     DataStructures::Multilist<ML_STACK, Replica3*, Replica3*> constructedReplicasCulled, destroyedReplicasCulled;
00597 
00598     // This is used if QueryGroupDownloadMessages() returns true when ID_REPLICA_MANAGER_DOWNLOAD_STARTED arrives
00599     // Packets will be gathered and not returned until ID_REPLICA_MANAGER_DOWNLOAD_COMPLETE arrives
00600     bool groupConstructionAndSerialize;
00601     DataStructures::Multilist<ML_QUEUE, Packet*, Packet*> downloadGroup;
00602     void ClearDownloadGroup(RakPeerInterface *rakPeerInterface);
00603 
00604     friend class ReplicaManager3;
00605 private:
00606     Connection_RM3() {};
00607 
00608     ConstructionMode constructionMode;
00609 };
00610 
00614 enum RM3ConstructionState
00615 {
00619     RM3CS_SEND_CONSTRUCTION,
00620 
00626     RM3CS_ALREADY_EXISTS_REMOTELY,
00627 
00629     RM3CS_ALREADY_EXISTS_REMOTELY_DO_NOT_CONSTRUCT,
00630 
00632     RM3CS_NEVER_CONSTRUCT,
00633     
00635     RM3CS_NO_ACTION,
00636 };
00637 
00640 enum RM3DestructionState
00641 {
00643     RM3DS_SEND_DESTRUCTION,
00644 
00646     RM3DS_DO_NOT_QUERY_DESTRUCTION,
00647 
00649     RM3DS_NO_ACTION,
00650 };
00651 
00654 enum RM3SerializationResult
00655 {
00659     RM3SR_BROADCAST_IDENTICALLY,
00660 
00666     RM3SR_BROADCAST_IDENTICALLY_FORCE_SERIALIZATION,
00667 
00671     RM3SR_SERIALIZED_UNIQUELY,
00672 
00677     RM3SR_SERIALIZED_ALWAYS,
00678 
00681     RM3SR_SERIALIZED_ALWAYS_IDENTICALLY,
00682 
00684     RM3SR_DO_NOT_SERIALIZE,
00685 
00689     RM3SR_NEVER_SERIALIZE_FOR_THIS_CONNECTION,
00690 };
00691 
00694 enum RM3QuerySerializationResult
00695 {
00697     RM3QSR_CALL_SERIALIZE,
00699     RM3QSR_DO_NOT_CALL_SERIALIZE,
00701     RM3QSR_NEVER_CALL_SERIALIZE,
00702 };
00703 
00705 enum RM3ActionOnPopConnection
00706 {
00707     RM3AOPC_DO_NOTHING,
00708     RM3AOPC_DELETE_REPLICA,
00709     RM3AOPC_DELETE_REPLICA_AND_BROADCAST_DESTRUCTION,
00710 };
00711 
00715 class RAK_DLL_EXPORT Replica3 : public NetworkIDObject
00716 {
00717 public:
00718     Replica3();
00719 
00722     virtual ~Replica3();
00723 
00729     virtual void WriteAllocationID(RakNet::Connection_RM3 *destinationConnection, RakNet::BitStream *allocationIdBitstream) const=0;
00730 
00740     virtual RM3ConstructionState QueryConstruction(RakNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3)=0;
00741 
00751     virtual RM3DestructionState QueryDestruction(RakNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3) {(void) destinationConnection; (void) replicaManager3; return RM3DS_DO_NOT_QUERY_DESTRUCTION;}
00752 
00760     virtual bool QueryRemoteConstruction(RakNet::Connection_RM3 *sourceConnection)=0;
00761 
00769     virtual void SerializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection)=0;
00770 
00776     virtual bool DeserializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection)=0;
00777 
00780     virtual void SerializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {(void) constructionBitstream; (void) destinationConnection;};
00781 
00784     virtual void DeserializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {(void) constructionBitstream; (void) sourceConnection;};
00785 
00791     virtual void SerializeDestruction(RakNet::BitStream *destructionBitstream, RakNet::Connection_RM3 *destinationConnection)=0;
00792 
00796     virtual bool DeserializeDestruction(RakNet::BitStream *destructionBitstream, RakNet::Connection_RM3 *sourceConnection)=0;
00797 
00800     virtual RakNet::RM3ActionOnPopConnection QueryActionOnPopConnection(RakNet::Connection_RM3 *droppedConnection) const=0;
00801 
00803     virtual void OnPoppedConnection(RakNet::Connection_RM3 *droppedConnection) {(void) droppedConnection;}
00804 
00815     virtual void DeallocReplica(RakNet::Connection_RM3 *sourceConnection)=0;
00816 
00822     virtual RakNet::RM3QuerySerializationResult QuerySerialization(RakNet::Connection_RM3 *destinationConnection)=0;
00823 
00826     virtual void OnUserReplicaPreSerializeTick(void) {}
00827 
00835     virtual RM3SerializationResult Serialize(RakNet::SerializeParameters *serializeParameters)=0;
00836 
00839     virtual void OnSerializeTransmission(RakNet::BitStream *bitStream, const SystemAddress &systemAddress) {(void) bitStream; (void) systemAddress; }
00840 
00847     virtual void Deserialize(RakNet::DeserializeParameters *deserializeParameters)=0;
00848 
00852     virtual void PostSerializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {(void) constructionBitstream; (void) destinationConnection;}
00853 
00860     virtual void PostDeserializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {(void) constructionBitstream; (void) sourceConnection;}
00861 
00863     virtual void PostSerializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {(void) constructionBitstream; (void) destinationConnection;}
00864 
00866     virtual void PostDeserializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {(void) constructionBitstream; (void) sourceConnection;}
00867 
00871     virtual void PreDestruction(RakNet::Connection_RM3 *sourceConnection) {(void) sourceConnection;}
00872 
00877     virtual RM3ConstructionState QueryConstruction_ClientConstruction(RakNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
00882     virtual bool QueryRemoteConstruction_ClientConstruction(RakNet::Connection_RM3 *sourceConnection, bool isThisTheServer);
00883 
00888     virtual RM3ConstructionState QueryConstruction_ServerConstruction(RakNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
00893     virtual bool QueryRemoteConstruction_ServerConstruction(RakNet::Connection_RM3 *sourceConnection, bool isThisTheServer);
00894 
00898     virtual RM3ConstructionState QueryConstruction_PeerToPeer(RakNet::Connection_RM3 *destinationConnection);
00902     virtual bool QueryRemoteConstruction_PeerToPeer(RakNet::Connection_RM3 *sourceConnection);
00903 
00908     virtual RakNet::RM3QuerySerializationResult QuerySerialization_ClientSerializable(RakNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
00913     virtual RakNet::RM3QuerySerializationResult QuerySerialization_ServerSerializable(RakNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
00917     virtual RakNet::RM3QuerySerializationResult QuerySerialization_PeerToPeer(RakNet::Connection_RM3 *destinationConnection);
00918 
00920     virtual RM3ActionOnPopConnection QueryActionOnPopConnection_Client(RakNet::Connection_RM3 *droppedConnection) const;
00922     virtual RM3ActionOnPopConnection QueryActionOnPopConnection_Server(RakNet::Connection_RM3 *droppedConnection) const;
00924     virtual RM3ActionOnPopConnection QueryActionOnPopConnection_PeerToPeer(RakNet::Connection_RM3 *droppedConnection) const;
00925 
00928     virtual void BroadcastDestruction(void);
00929 
00932     RakNetGUID GetCreatingSystemGUID(void) const;
00933 
00935     bool WasReferenced(void) const {return replicaManager!=0;}
00936 
00939     RakNetGUID creatingSystemGUID;
00941     RakNetGUID deletingSystemGUID;
00942 
00945     ReplicaManager3 *replicaManager;
00946 
00947     LastSerializationResultBS lastSentSerialization;
00948     RakNet::Time whenLastSerialized;
00949     bool forceSendUntilNextUpdate;
00950 };
00951 
00956 template <class parent_type>
00957 class RAK_DLL_EXPORT Replica3Composite : public Replica3
00958 {
00959 protected:
00960     parent_type *r3CompositeOwner;
00961 public:
00962     void SetCompositeOwner(parent_type *p) {r3CompositeOwner=p;}
00963     parent_type* GetCompositeOwner(void) const {return r3CompositeOwner;};
00964     virtual void WriteAllocationID(RakNet::Connection_RM3 *destinationConnection, RakNet::BitStream *allocationIdBitstream) const {r3CompositeOwner->WriteAllocationID(destinationConnection, allocationIdBitstream);}
00965     virtual RM3ConstructionState QueryConstruction(RakNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3) {return r3CompositeOwner->QueryConstruction(destinationConnection, replicaManager3);}
00966     virtual RM3DestructionState QueryDestruction(RakNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3) {return r3CompositeOwner->QueryDestruction(destinationConnection, replicaManager3);}
00967     virtual bool QueryRemoteConstruction(RakNet::Connection_RM3 *sourceConnection) {return r3CompositeOwner->QueryRemoteConstruction(sourceConnection);}
00968     virtual void SerializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->SerializeConstruction(constructionBitstream, destinationConnection);}
00969     virtual bool DeserializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {return r3CompositeOwner->DeserializeConstruction(constructionBitstream, sourceConnection);}
00970     virtual void SerializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->SerializeConstructionExisting(constructionBitstream, destinationConnection);}
00971     virtual void DeserializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->DeserializeConstructionExisting(constructionBitstream, sourceConnection);}
00972     virtual void SerializeDestruction(RakNet::BitStream *destructionBitstream, RakNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->SerializeDestruction(destructionBitstream, destinationConnection);}
00973     virtual bool DeserializeDestruction(RakNet::BitStream *destructionBitstream, RakNet::Connection_RM3 *sourceConnection) {return r3CompositeOwner->DeserializeDestruction(destructionBitstream, sourceConnection);}
00974     virtual RakNet::RM3ActionOnPopConnection QueryActionOnPopConnection(RakNet::Connection_RM3 *droppedConnection) const {return r3CompositeOwner->QueryActionOnPopConnection(droppedConnection);}
00975     virtual void OnPoppedConnection(RakNet::Connection_RM3 *droppedConnection) {r3CompositeOwner->OnPoppedConnection(droppedConnection);}
00976     virtual void DeallocReplica(RakNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->DeallocReplica(sourceConnection);}
00977     virtual RakNet::RM3QuerySerializationResult QuerySerialization(RakNet::Connection_RM3 *destinationConnection) {return r3CompositeOwner->QuerySerialization(destinationConnection);}
00978     virtual void OnUserReplicaPreSerializeTick(void) {r3CompositeOwner->OnUserReplicaPreSerializeTick();}
00979     virtual RM3SerializationResult Serialize(RakNet::SerializeParameters *serializeParameters) {return r3CompositeOwner->Serialize(serializeParameters);}
00980     virtual void OnSerializeTransmission(RakNet::BitStream *bitStream, const SystemAddress &systemAddress) {r3CompositeOwner->OnSerializeTransmission(bitStream, systemAddress);}
00981     virtual void Deserialize(RakNet::DeserializeParameters *deserializeParameters) {r3CompositeOwner->Deserialize(deserializeParameters);}
00982     virtual void PostSerializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->PostSerializeConstruction(constructionBitstream, destinationConnection);}
00983     virtual void PostDeserializeConstruction(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->PostDeserializeConstruction(constructionBitstream, sourceConnection);}
00984     virtual void PostSerializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->PostSerializeConstructionExisting(constructionBitstream, destinationConnection);}
00985     virtual void PostDeserializeConstructionExisting(RakNet::BitStream *constructionBitstream, RakNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->PostDeserializeConstructionExisting(constructionBitstream, sourceConnection);}
00986     virtual void PreDestruction(RakNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->PreDestruction(sourceConnection);}
00987 };
00988 
00989 } // namespace RakNet
00990 
00991 
00992 #endif
00993 
00994 #endif // _RAKNET_SUPPORT_*

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