@@ -218,6 +218,8 @@ CCMD (dumpclasses)
218
218
//
219
219
// ==========================================================================
220
220
221
+ #include " d_net.h"
222
+
221
223
void DObject::InPlaceConstructor (void *mem)
222
224
{
223
225
new ((EInPlace *)mem) DObject;
@@ -317,6 +319,8 @@ void DObject::Release()
317
319
318
320
void DObject::Destroy ()
319
321
{
322
+ NetworkEntityManager::RemoveNetworkEntity (this );
323
+
320
324
// We cannot call the VM during shutdown because all the needed data has been or is in the process of being deleted.
321
325
if (PClass::bVMOperational)
322
326
{
@@ -569,8 +573,15 @@ void DObject::Serialize(FSerializer &arc)
569
573
570
574
SerializeFlag (" justspawned" , OF_JustSpawned);
571
575
SerializeFlag (" spawned" , OF_Spawned);
572
-
576
+ SerializeFlag (" networked" , OF_Networked);
577
+
573
578
ObjectFlags |= OF_SerialSuccess;
579
+
580
+ if (arc.isReading () && (ObjectFlags & OF_Networked))
581
+ {
582
+ ClearNetworkID ();
583
+ EnableNetworking (true );
584
+ }
574
585
}
575
586
576
587
void DObject::CheckIfSerialized () const
@@ -585,6 +596,73 @@ void DObject::CheckIfSerialized () const
585
596
}
586
597
}
587
598
599
+ // ==========================================================================
600
+ //
601
+ //
602
+ //
603
+ // ==========================================================================
604
+
605
+ void DObject::SetNetworkID (const uint32_t id)
606
+ {
607
+ if (!IsNetworked ())
608
+ {
609
+ ObjectFlags |= OF_Networked;
610
+ _networkID = id;
611
+ }
612
+ }
613
+
614
+ void DObject::ClearNetworkID ()
615
+ {
616
+ ObjectFlags &= ~OF_Networked;
617
+ _networkID = NetworkEntityManager::WorldNetID;
618
+ }
619
+
620
+ void DObject::EnableNetworking (const bool enable)
621
+ {
622
+ if (enable)
623
+ NetworkEntityManager::AddNetworkEntity (this );
624
+ else
625
+ NetworkEntityManager::RemoveNetworkEntity (this );
626
+ }
627
+
628
+ static unsigned int GetNetworkID (DObject* const self)
629
+ {
630
+ return self->GetNetworkID ();
631
+ }
632
+
633
+ DEFINE_ACTION_FUNCTION_NATIVE (DObject, GetNetworkID, GetNetworkID)
634
+ {
635
+ PARAM_SELF_PROLOGUE (DObject);
636
+
637
+ ACTION_RETURN_INT (self->GetNetworkID ());
638
+ }
639
+
640
+ static void EnableNetworking (DObject* const self, const bool enable)
641
+ {
642
+ self->EnableNetworking (enable);
643
+ }
644
+
645
+ DEFINE_ACTION_FUNCTION_NATIVE (DObject, EnableNetworking, EnableNetworking)
646
+ {
647
+ PARAM_SELF_PROLOGUE (DObject);
648
+ PARAM_BOOL (enable);
649
+
650
+ self->EnableNetworking (enable);
651
+ return 0 ;
652
+ }
653
+
654
+ static DObject* GetNetworkEntity (const unsigned int id)
655
+ {
656
+ return NetworkEntityManager::GetNetworkEntity (id);
657
+ }
658
+
659
+ DEFINE_ACTION_FUNCTION_NATIVE (DObject, GetNetworkEntity, GetNetworkEntity)
660
+ {
661
+ PARAM_PROLOGUE;
662
+ PARAM_UINT (id);
663
+
664
+ ACTION_RETURN_OBJECT (NetworkEntityManager::GetNetworkEntity (id));
665
+ }
588
666
589
667
DEFINE_ACTION_FUNCTION (DObject, MSTime)
590
668
{
0 commit comments