SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ReplicaManager3.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20
21 #include "NativeFeatureIncludes.h"
22 #if _RAKNET_SUPPORT_ReplicaManager3==1
23
24 #ifndef __REPLICA_MANAGER_3
25 #define __REPLICA_MANAGER_3
26
27 #include "types.h"
28 #include "time.h"
29 #include "BitStream.h"
30 #include "PacketPriority.h"
31 #include "PluginInterface2.h"
32 #include "NetworkIDObject.h"
33 #include "DS_OrderedList.h"
34 #include "DS_Queue.h"
35
40
41 namespace SLNet
42 {
43 class Connection_RM3;
44 class Replica3;
45
48 typedef uint8_t WorldId;
49
50
53 struct PRO
54 {
56 PacketPriority priority;
57
59 PacketReliability reliability;
60
62 char orderingChannel;
63
65 uint32_t sendReceipt;
66
67 bool operator==( const PRO& right ) const;
68 bool operator!=( const PRO& right ) const;
69 };
70
71
86 class RAK_DLL_EXPORT ReplicaManager3 : public PluginInterface2
87 {
88 public:
89 ReplicaManager3();
90 virtual ~ReplicaManager3();
91
102 virtual Connection_RM3* AllocConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID) const=0;
103
108 virtual void DeallocConnection(Connection_RM3 *connection) const=0;
109
117 void SetAutoManageConnections(bool autoCreate, bool autoDestroy);
118
120 bool GetAutoCreateConnections(void) const;
121
123 bool GetAutoDestroyConnections(void) const;
124
129 void AutoCreateConnectionList(
130 DataStructures::List<RakNetGUID> &participantListIn,
131 DataStructures::List<Connection_RM3*> &participantListOut,
132 WorldId worldId=0);
133
139 bool PushConnection(SLNet::Connection_RM3 *newConnection, WorldId worldId=0);
140
146 SLNet::Connection_RM3 * PopConnection(RakNetGUID guid, WorldId worldId=0);
147
154 void Reference(SLNet::Replica3 *replica3, WorldId worldId=0);
155
161 void Dereference(SLNet::Replica3 *replica3, WorldId worldId=0);
162
168 void DereferenceList(DataStructures::List<Replica3*> &replicaListIn, WorldId worldId=0);
169
176 void GetReplicasCreatedByGuid(RakNetGUID guid, DataStructures::List<Replica3*> &replicaListOut, WorldId worldId=0);
177
182 void GetReplicasCreatedByMe(DataStructures::List<Replica3*> &replicaListOut, WorldId worldId=0);
183
188 void GetReferencedReplicaList(DataStructures::List<Replica3*> &replicaListOut, WorldId worldId=0);
189
194 unsigned GetReplicaCount(WorldId worldId=0) const;
195
201 Replica3 *GetReplicaAtIndex(unsigned index, WorldId worldId=0);
202
207 unsigned int GetConnectionCount(WorldId worldId=0) const;
208
213 Connection_RM3* GetConnectionAtIndex(unsigned index, WorldId worldId=0) const;
214
219 Connection_RM3* GetConnectionBySystemAddress(const SystemAddress &sa, WorldId worldId=0) const;
220
225 Connection_RM3* GetConnectionByGUID(RakNetGUID guid, WorldId worldId=0) const;
226
228 void SetDefaultOrderingChannel(char def);
229
231 void SetDefaultPacketPriority(PacketPriority def);
232
234 void SetDefaultPacketReliability(PacketReliability def);
235
241 void SetAutoSerializeInterval(SLNet::Time intervalMS);
242
248 void GetConnectionsThatHaveReplicaConstructed(Replica3 *replica, DataStructures::List<Connection_RM3*> &connectionsThatHaveConstructedThisReplica, WorldId worldId=0);
249
253 bool GetAllConnectionDownloadsCompleted(WorldId worldId=0) const;
254
258 void AddWorld(WorldId worldId);
259
263 void RemoveWorld(WorldId worldId);
264
269 WorldId GetWorldIdAtIndex(unsigned int index);
270
273 unsigned int GetWorldCount(void) const;
274
280 void SetNetworkIDManager(NetworkIDManager *_networkIDManager, WorldId worldId=0);
281
284 NetworkIDManager *GetNetworkIDManager(WorldId worldId=0) const;
285
292 void BroadcastDestructionList(DataStructures::List<Replica3*> &replicaListSource, const SystemAddress &exclusionAddress, WorldId worldId=0);
293
297 void BroadcastDestruction(Replica3 *replica, const SystemAddress &exclusionAddress);
298
303 void Clear(bool deleteWorlds=false);
304
306 PRO GetDefaultSendParameters(void) const;
307
309 virtual void Update(void);
310
312 struct RM3World
313 {
314 RM3World();
315 void Clear(ReplicaManager3 *replicaManager3);
316
317 DataStructures::List<Connection_RM3*> connectionList;
318 DataStructures::List<Replica3*> userReplicaList;
319 WorldId worldId;
320 NetworkIDManager *networkIDManager;
321 };
322 protected:
323 virtual PluginReceiveResult OnReceive(Packet *packet);
324 virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
325 virtual void OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming);
326 virtual void OnRakPeerShutdown(void);
327 virtual void OnDetach(void);
328
329 PluginReceiveResult OnConstruction(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, unsigned char packetDataOffset, WorldId worldId);
330 PluginReceiveResult OnSerialize(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, SLNet::Time timestamp, unsigned char packetDataOffset, WorldId worldId);
331 PluginReceiveResult OnDownloadStarted(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, unsigned char packetDataOffset, WorldId worldId);
332 PluginReceiveResult OnDownloadComplete(Packet *packet, unsigned char *packetData, int packetDataLength, RakNetGUID senderGuid, unsigned char packetDataOffset, WorldId worldId);
333
334 void DeallocReplicaNoBroadcastDestruction(SLNet::Connection_RM3 *connection, SLNet::Replica3 *replica3);
335 SLNet::Connection_RM3 * PopConnection(unsigned int index, WorldId worldId);
336 Replica3* GetReplicaByNetworkID(NetworkID networkId, WorldId worldId);
337 unsigned int ReferenceInternal(SLNet::Replica3 *replica3, WorldId worldId);
338
339 PRO defaultSendParameters;
340 SLNet::Time autoSerializeInterval;
341 SLNet::Time lastAutoSerializeOccurance;
342 bool autoCreateConnections, autoDestroyConnections;
343 Replica3 *currentlyDeallocatingReplica;
344 // Set on the first call to ReferenceInternal(), and should never be changed after that
345 // Used to lookup in Replica3LSRComp. I don't want to rely on GetNetworkID() in case it changes at runtime
346 uint32_t nextReferenceIndex;
347
348 // For O(1) lookup
349 RM3World *worldsArray[255];
350 // For fast traversal
351 DataStructures::List<RM3World *> worldsList;
352
353 friend class Connection_RM3;
354 };
355
356 static const int RM3_NUM_OUTPUT_BITSTREAM_CHANNELS=16;
357
359 struct LastSerializationResultBS
360 {
361 SLNet::BitStream bitStream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
362 bool indicesToSend[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
363 };
364
367 struct LastSerializationResult
368 {
369 LastSerializationResult();
370 ~LastSerializationResult();
371
374 SLNet::Replica3 *replica;
375 //bool neverSerialize;
376 // bool isConstructed;
377 SLNet::Time whenLastSerialized;
378
379 void AllocBS(void);
380 LastSerializationResultBS* lastSerializationResultBS;
381 };
382
385 struct SerializeParameters
386 {
390 SLNet::BitStream outputBitstream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
391
394 SLNet::BitStream* lastSentBitstream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
395
399 SLNet::Time messageTimestamp;
400
404 PRO pro[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
405
407 SLNet::Connection_RM3 *destinationConnection;
408
411 BitSize_t bitsWrittenSoFar;
412
415 SLNet::Time whenLastSerialized;
416
419 SLNet::Time curTime;
420 };
421
423 struct DeserializeParameters
424 {
425 SLNet::BitStream serializationBitstream[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
426 bool bitstreamWrittenTo[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS];
427 SLNet::Time timeStamp;
428 SLNet::Connection_RM3 *sourceConnection;
429 };
430
432 enum SendSerializeIfChangedResult
433 {
434 SSICR_SENT_DATA,
435 SSICR_DID_NOT_SEND_DATA,
436 SSICR_NEVER_SERIALIZE,
437 };
438
442 class RAK_DLL_EXPORT Connection_RM3
443 {
444 public:
445
446 Connection_RM3(const SystemAddress &_systemAddress, RakNetGUID _guid);
447 virtual ~Connection_RM3();
448
460 virtual Replica3 *AllocReplica(SLNet::BitStream *allocationIdBitstream, ReplicaManager3 *replicaManager3)=0;
461
464 virtual void GetConstructedReplicas(DataStructures::List<Replica3*> &objectsTheyDoHave);
465
469 bool HasReplicaConstructed(SLNet::Replica3 *replica);
470
473 virtual void SerializeOnDownloadStarted(SLNet::BitStream *bitStream) {(void) bitStream;}
474
477 virtual void DeserializeOnDownloadStarted(SLNet::BitStream *bitStream) {(void) bitStream;}
478
481 virtual void SerializeOnDownloadComplete(SLNet::BitStream *bitStream) {(void) bitStream;}
482
485 virtual void DeserializeOnDownloadComplete(SLNet::BitStream *bitStream) {(void) bitStream;}
486
488 SystemAddress GetSystemAddress(void) const {return systemAddress;}
489
491 RakNetGUID GetRakNetGUID(void) const {return guid;}
492
494 bool GetDownloadWasCompleted(void) const {return gotDownloadComplete;}
495
497 enum ConstructionMode
498 {
502 QUERY_REPLICA_FOR_CONSTRUCTION,
503
507 QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION,
508
513 QUERY_CONNECTION_FOR_REPLICA_LIST
514 };
515
524 virtual bool QueryGroupDownloadMessages(void) const {return false;}
525
531 virtual ConstructionMode QueryConstructionMode(void) const {return QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION;}
532
541 virtual void QueryReplicaList(
542 DataStructures::List<Replica3*> &newReplicasToCreate,
543 DataStructures::List<Replica3*> &existingReplicasToDestroy) {(void) newReplicasToCreate; (void) existingReplicasToDestroy;}
544
557 virtual bool QuerySerializationList(DataStructures::List<Replica3*> &replicasToSerialize) {(void) replicasToSerialize; return false;}
558
569 virtual SendSerializeIfChangedResult SendSerialize(SLNet::Replica3 *replica, bool indicesToSend[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], SLNet::BitStream serializationData[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], SLNet::Time timestamp, PRO sendParameters[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], SLNet::RakPeerInterface *rakPeer, unsigned char worldId, SLNet::Time curTime);
570
579 virtual SendSerializeIfChangedResult SendSerializeIfChanged(LastSerializationResult *lsr, SerializeParameters *sp, SLNet::RakPeerInterface *rakPeer, unsigned char worldId, ReplicaManager3 *replicaManager, SLNet::Time curTime);
580
589 virtual void SendConstruction(DataStructures::List<Replica3*> &newObjects, DataStructures::List<Replica3*> &deletedObjects, PRO sendParameters, SLNet::RakPeerInterface *rakPeer, unsigned char worldId, ReplicaManager3 *replicaManager3);
590
592 void SendValidation(SLNet::RakPeerInterface *rakPeer, WorldId worldId);
593
595 void AutoConstructByQuery(ReplicaManager3 *replicaManager3, WorldId worldId);
596
597
598 // Internal - does the other system have this connection too? Validated means we can now use it
599 bool isValidated;
600 // Internal - Used to see if we should send download started
601 bool isFirstConstruction;
602
603 static int Replica3LSRComp( Replica3 * const &replica3, LastSerializationResult * const &data );
604
605 // Internal
606 void ClearDownloadGroup(RakPeerInterface *rakPeerInterface);
607 protected:
608
609 SystemAddress systemAddress;
610 RakNetGUID guid;
611
612 /*
613 Operations:
614
615 Locally reference a new replica:
616 Add to queryToConstructReplicaList for all objects
617
618 Add all objects to queryToConstructReplicaList
619
620 Download:
621 Add to constructedReplicaList for connection that send the object to us
622 Add to queryToSerializeReplicaList for connection that send the object to us
623 Add to queryToConstructReplicaList for all other connections
624
625 Never construct for this connection:
626 Remove from queryToConstructReplicaList
627
628 Construct to this connection
629 Remove from queryToConstructReplicaList
630 Add to constructedReplicaList for this connection
631 Add to queryToSerializeReplicaList for this connection
632
633 Serialize:
634 Iterate through queryToSerializeReplicaList
635
636 Never serialize for this connection
637 Remove from queryToSerializeReplicaList
638
639 Reference (this system has this object already)
640 Remove from queryToConstructReplicaList
641 Add to constructedReplicaList for this connection
642 Add to queryToSerializeReplicaList for this connection
643
644 Downloaded an existing object
645 if replica is in queryToConstructReplicaList, OnConstructToThisConnection()
646 else ignore
647
648 Send destruction from query
649 Remove from queryToDestructReplicaList
650 Remove from queryToSerializeReplicaList
651 Remove from constructedReplicaList
652 Add to queryToConstructReplicaList
653
654 Do not query destruction again
655 Remove from queryToDestructReplicaList
656 */
657 void OnLocalReference(Replica3* replica3, ReplicaManager3 *replicaManager);
658 void OnDereference(Replica3* replica3, ReplicaManager3 *replicaManager);
659 void OnDownloadFromThisSystem(Replica3* replica3, ReplicaManager3 *replicaManager);
660 void OnDownloadFromOtherSystem(Replica3* replica3, ReplicaManager3 *replicaManager);
661 void OnNeverConstruct(unsigned int queryToConstructIdx, ReplicaManager3 *replicaManager);
662 void OnConstructToThisConnection(unsigned int queryToConstructIdx, ReplicaManager3 *replicaManager);
663 void OnConstructToThisConnection(Replica3 *replica, ReplicaManager3 *replicaManager);
664 void OnNeverSerialize(LastSerializationResult *lsr, ReplicaManager3 *replicaManager);
665 void OnReplicaAlreadyExists(unsigned int queryToConstructIdx, ReplicaManager3 *replicaManager);
666 void OnDownloadExisting(Replica3* replica3, ReplicaManager3 *replicaManager);
667 void OnSendDestructionFromQuery(unsigned int queryToDestructIdx, ReplicaManager3 *replicaManager);
668 void OnDoNotQueryDestruction(unsigned int queryToDestructIdx, ReplicaManager3 *replicaManager);
669 void ValidateLists(ReplicaManager3 *replicaManager) const;
670 void SendSerializeHeader(SLNet::Replica3 *replica, SLNet::Time timestamp, SLNet::BitStream *bs, WorldId worldId);
671
672 // The list of objects that our local system and this remote system both have
673 // Either we sent this object to them, or they sent this object to us
674 // A given Replica can be either in queryToConstructReplicaList or constructedReplicaList but not both at the same time
675 DataStructures::OrderedList<Replica3*, LastSerializationResult*, Connection_RM3::Replica3LSRComp> constructedReplicaList;
676
677 // Objects that we have, but this system does not, and we will query each tick to see if it should be sent to them
678 // If we do send it to them, the replica is moved to constructedReplicaList
679 // A given Replica can be either in queryToConstructReplicaList or constructedReplicaList but not both at the same time
680 DataStructures::List<LastSerializationResult*> queryToConstructReplicaList;
681
682 // Objects that this system has constructed are added at the same time to queryToSerializeReplicaList
683 // This list is used to serialize all objects that this system has to this connection
684 DataStructures::List<LastSerializationResult*> queryToSerializeReplicaList;
685
686 // Objects that are constructed on this system are also queried if they should be destroyed to this system
687 DataStructures::List<LastSerializationResult*> queryToDestructReplicaList;
688
689 // Working lists
690 DataStructures::List<Replica3*> constructedReplicasCulled, destroyedReplicasCulled;
691
692 // This is used if QueryGroupDownloadMessages() returns true when ID_REPLICA_MANAGER_DOWNLOAD_STARTED arrives
693 // Packets will be gathered and not returned until ID_REPLICA_MANAGER_DOWNLOAD_COMPLETE arrives
694 bool groupConstructionAndSerialize;
695 DataStructures::Queue<Packet*> downloadGroup;
696
697 // Stores if we got download complete for this connection
698 bool gotDownloadComplete;
699
700 friend class ReplicaManager3;
701 private:
702 Connection_RM3() {};
703
704 ConstructionMode constructionMode;
705 };
706
710 enum RM3ConstructionState
711 {
715 RM3CS_SEND_CONSTRUCTION,
716
722 RM3CS_ALREADY_EXISTS_REMOTELY,
723
725 RM3CS_ALREADY_EXISTS_REMOTELY_DO_NOT_CONSTRUCT,
726
729 RM3CS_NEVER_CONSTRUCT,
730
732 RM3CS_NO_ACTION,
733
735 RM3CS_MAX,
736 };
737
740 enum RM3DestructionState
741 {
743 RM3DS_SEND_DESTRUCTION,
744
746 RM3DS_DO_NOT_QUERY_DESTRUCTION,
747
749 RM3DS_NO_ACTION,
750
752 RM3DS_MAX,
753 };
754
757 enum RM3SerializationResult
758 {
762 RM3SR_BROADCAST_IDENTICALLY,
763
769 RM3SR_BROADCAST_IDENTICALLY_FORCE_SERIALIZATION,
770
774 RM3SR_SERIALIZED_UNIQUELY,
775
780 RM3SR_SERIALIZED_ALWAYS,
781
783 RM3SR_SERIALIZED_ALWAYS_IDENTICALLY,
784
786 RM3SR_DO_NOT_SERIALIZE,
787
791 RM3SR_NEVER_SERIALIZE_FOR_THIS_CONNECTION,
792
794 RM3SR_MAX,
795 };
796
799 enum RM3QuerySerializationResult
800 {
802 RM3QSR_CALL_SERIALIZE,
804 RM3QSR_DO_NOT_CALL_SERIALIZE,
806 RM3QSR_NEVER_CALL_SERIALIZE,
808 RM3QSR_MAX,
809 };
810
812 enum RM3ActionOnPopConnection
813 {
814 RM3AOPC_DO_NOTHING,
815 RM3AOPC_DELETE_REPLICA,
816 RM3AOPC_DELETE_REPLICA_AND_BROADCAST_DESTRUCTION,
817 RM3AOPC_MAX,
818 };
819
822 enum Replica3P2PMode
823 {
826 R3P2PM_SINGLE_OWNER,
830 R3P2PM_MULTI_OWNER_CURRENTLY_AUTHORITATIVE,
834 R3P2PM_MULTI_OWNER_NOT_CURRENTLY_AUTHORITATIVE,
837 R3P2PM_STATIC_OBJECT_CURRENTLY_AUTHORITATIVE,
840 R3P2PM_STATIC_OBJECT_NOT_CURRENTLY_AUTHORITATIVE,
841
842 };
843
847 class RAK_DLL_EXPORT Replica3 : public NetworkIDObject
848 {
849 public:
850 Replica3();
851
854 virtual ~Replica3();
855
861 virtual void WriteAllocationID(SLNet::Connection_RM3 *destinationConnection, SLNet::BitStream *allocationIdBitstream) const=0;
862
872 virtual RM3ConstructionState QueryConstruction(SLNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3)=0;
873
883 virtual RM3DestructionState QueryDestruction(SLNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3) {(void) destinationConnection; (void) replicaManager3; return RM3DS_DO_NOT_QUERY_DESTRUCTION;}
884
892 virtual bool QueryRemoteConstruction(SLNet::Connection_RM3 *sourceConnection)=0;
893
900 virtual bool QueryRelayDestruction(Connection_RM3 *sourceConnection) const {(void) sourceConnection; return true;}
901
909 virtual void SerializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection)=0;
910
916 virtual bool DeserializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection)=0;
917
920 virtual void SerializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {(void) constructionBitstream; (void) destinationConnection;};
921
924 virtual void DeserializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {(void) constructionBitstream; (void) sourceConnection;};
925
931 virtual void SerializeDestruction(SLNet::BitStream *destructionBitstream, SLNet::Connection_RM3 *destinationConnection)=0;
932
936 virtual bool DeserializeDestruction(SLNet::BitStream *destructionBitstream, SLNet::Connection_RM3 *sourceConnection)=0;
937
940 virtual SLNet::RM3ActionOnPopConnection QueryActionOnPopConnection(SLNet::Connection_RM3 *droppedConnection) const=0;
941
943 virtual void OnPoppedConnection(SLNet::Connection_RM3 *droppedConnection) {(void) droppedConnection;}
944
955 virtual void DeallocReplica(SLNet::Connection_RM3 *sourceConnection)=0;
956
962 virtual SLNet::RM3QuerySerializationResult QuerySerialization(SLNet::Connection_RM3 *destinationConnection)=0;
963
966 virtual void OnUserReplicaPreSerializeTick(void) {}
967
975 virtual RM3SerializationResult Serialize(SLNet::SerializeParameters *serializeParameters)=0;
976
979 virtual void OnSerializeTransmission(SLNet::BitStream *bitStream, SLNet::Connection_RM3 *destinationConnection, BitSize_t bitsPerChannel[RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], SLNet::Time curTime) {(void) bitStream; (void) destinationConnection; (void) bitsPerChannel; (void) curTime;}
980
987 virtual void Deserialize(SLNet::DeserializeParameters *deserializeParameters)=0;
988
992 virtual void PostSerializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {(void) constructionBitstream; (void) destinationConnection;}
993
1000 virtual void PostDeserializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {(void) constructionBitstream; (void) sourceConnection;}
1001
1003 virtual void PostSerializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {(void) constructionBitstream; (void) destinationConnection;}
1004
1006 virtual void PostDeserializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {(void) constructionBitstream; (void) sourceConnection;}
1007
1011 virtual void PreDestruction(SLNet::Connection_RM3 *sourceConnection) {(void) sourceConnection;}
1012
1017 virtual RM3ConstructionState QueryConstruction_ClientConstruction(SLNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
1018
1024 virtual bool QueryRemoteConstruction_ClientConstruction(SLNet::Connection_RM3 *sourceConnection, bool isThisTheServer);
1025
1030 virtual RM3ConstructionState QueryConstruction_ServerConstruction(SLNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
1031
1037 virtual bool QueryRemoteConstruction_ServerConstruction(SLNet::Connection_RM3 *sourceConnection, bool isThisTheServer);
1038
1043 virtual RM3ConstructionState QueryConstruction_PeerToPeer(SLNet::Connection_RM3 *destinationConnection, Replica3P2PMode p2pMode=R3P2PM_SINGLE_OWNER);
1047 virtual bool QueryRemoteConstruction_PeerToPeer(SLNet::Connection_RM3 *sourceConnection);
1048
1053 virtual SLNet::RM3QuerySerializationResult QuerySerialization_ClientSerializable(SLNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
1058 virtual SLNet::RM3QuerySerializationResult QuerySerialization_ServerSerializable(SLNet::Connection_RM3 *destinationConnection, bool isThisTheServer);
1063 virtual SLNet::RM3QuerySerializationResult QuerySerialization_PeerToPeer(SLNet::Connection_RM3 *destinationConnection, Replica3P2PMode p2pMode=R3P2PM_SINGLE_OWNER);
1064
1066 virtual RM3ActionOnPopConnection QueryActionOnPopConnection_Client(SLNet::Connection_RM3 *droppedConnection) const;
1068 virtual RM3ActionOnPopConnection QueryActionOnPopConnection_Server(SLNet::Connection_RM3 *droppedConnection) const;
1070 virtual RM3ActionOnPopConnection QueryActionOnPopConnection_PeerToPeer(SLNet::Connection_RM3 *droppedConnection) const;
1071
1074 virtual void BroadcastDestruction(void);
1075
1078 RakNetGUID GetCreatingSystemGUID(void) const;
1079
1081 bool WasReferenced(void) const {return replicaManager!=0;}
1082
1085 RakNetGUID creatingSystemGUID;
1087 RakNetGUID deletingSystemGUID;
1088
1091 ReplicaManager3 *replicaManager;
1092
1093 LastSerializationResultBS lastSentSerialization;
1094 bool forceSendUntilNextUpdate;
1095 LastSerializationResult *lsr;
1096 uint32_t referenceIndex;
1097 };
1098
1103 template <class parent_type>
1104 class RAK_DLL_EXPORT Replica3Composite : public Replica3
1105 {
1106 protected:
1107 parent_type *r3CompositeOwner;
1108 public:
1109 void SetCompositeOwner(parent_type *p) {r3CompositeOwner=p;}
1110 parent_type* GetCompositeOwner(void) const {return r3CompositeOwner;};
1111 virtual void WriteAllocationID(SLNet::Connection_RM3 *destinationConnection, SLNet::BitStream *allocationIdBitstream) const {r3CompositeOwner->WriteAllocationID(destinationConnection, allocationIdBitstream);}
1112 virtual SLNet::RM3ConstructionState QueryConstruction(SLNet::Connection_RM3 *destinationConnection, SLNet::ReplicaManager3 *replicaManager3) {return r3CompositeOwner->QueryConstruction(destinationConnection, replicaManager3);}
1113 virtual SLNet::RM3DestructionState QueryDestruction(SLNet::Connection_RM3 *destinationConnection, SLNet::ReplicaManager3 *replicaManager3) {return r3CompositeOwner->QueryDestruction(destinationConnection, replicaManager3);}
1114 virtual bool QueryRemoteConstruction(SLNet::Connection_RM3 *sourceConnection) {return r3CompositeOwner->QueryRemoteConstruction(sourceConnection);}
1115 virtual bool QueryRelayDestruction(SLNet::Connection_RM3 *sourceConnection) const {return r3CompositeOwner->QueryRelayDestruction(sourceConnection);}
1116 virtual void SerializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->SerializeConstruction(constructionBitstream, destinationConnection);}
1117 virtual bool DeserializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {return r3CompositeOwner->DeserializeConstruction(constructionBitstream, sourceConnection);}
1118 virtual void SerializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->SerializeConstructionExisting(constructionBitstream, destinationConnection);}
1119 virtual void DeserializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->DeserializeConstructionExisting(constructionBitstream, sourceConnection);}
1120 virtual void SerializeDestruction(SLNet::BitStream *destructionBitstream, SLNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->SerializeDestruction(destructionBitstream, destinationConnection);}
1121 virtual bool DeserializeDestruction(SLNet::BitStream *destructionBitstream, SLNet::Connection_RM3 *sourceConnection) {return r3CompositeOwner->DeserializeDestruction(destructionBitstream, sourceConnection);}
1122 virtual SLNet::RM3ActionOnPopConnection QueryActionOnPopConnection(SLNet::Connection_RM3 *droppedConnection) const {return r3CompositeOwner->QueryActionOnPopConnection(droppedConnection);}
1123 virtual void OnPoppedConnection(SLNet::Connection_RM3 *droppedConnection) {r3CompositeOwner->OnPoppedConnection(droppedConnection);}
1124 virtual void DeallocReplica(SLNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->DeallocReplica(sourceConnection);}
1125 virtual SLNet::RM3QuerySerializationResult QuerySerialization(SLNet::Connection_RM3 *destinationConnection) {return r3CompositeOwner->QuerySerialization(destinationConnection);}
1126 virtual void OnUserReplicaPreSerializeTick(void) {r3CompositeOwner->OnUserReplicaPreSerializeTick();}
1127 virtual SLNet::RM3SerializationResult Serialize(SLNet::SerializeParameters *serializeParameters) {return r3CompositeOwner->Serialize(serializeParameters);}
1128 virtual void OnSerializeTransmission(SLNet::BitStream *bitStream, SLNet::Connection_RM3 *destinationConnection, SLNet::BitSize_t bitsPerChannel[SLNet::RM3_NUM_OUTPUT_BITSTREAM_CHANNELS], SLNet::Time curTime) {r3CompositeOwner->OnSerializeTransmission(bitStream, destinationConnection, bitsPerChannel, curTime);}
1129 virtual void Deserialize(SLNet::DeserializeParameters *deserializeParameters) {r3CompositeOwner->Deserialize(deserializeParameters);}
1130 virtual void PostSerializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->PostSerializeConstruction(constructionBitstream, destinationConnection);}
1131 virtual void PostDeserializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->PostDeserializeConstruction(constructionBitstream, sourceConnection);}
1132 virtual void PostSerializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection) {r3CompositeOwner->PostSerializeConstructionExisting(constructionBitstream, destinationConnection);}
1133 virtual void PostDeserializeConstructionExisting(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->PostDeserializeConstructionExisting(constructionBitstream, sourceConnection);}
1134 virtual void PreDestruction(SLNet::Connection_RM3 *sourceConnection) {r3CompositeOwner->PreDestruction(sourceConnection);}
1135 };
1136
1137 } // namespace SLNet
1138
1139
1140 #endif
1141
1142 #endif // _RAKNET_SUPPORT_*