Skip to content

Commit 38f14cc

Browse files
Boondorlmadame-rachelle
authored andcommitted
Tweaked net ID file management
Should now be easier to stub network entity functions for Raze.
1 parent 8d0d130 commit 38f14cc

File tree

3 files changed

+87
-71
lines changed

3 files changed

+87
-71
lines changed

src/common/objects/dobject.cpp

+1-71
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ CCMD (dumpclasses)
218218
//
219219
//==========================================================================
220220

221-
#include "d_net.h"
222-
223221
void DObject::InPlaceConstructor (void *mem)
224222
{
225223
new ((EInPlace *)mem) DObject;
@@ -319,7 +317,7 @@ void DObject::Release()
319317

320318
void DObject::Destroy ()
321319
{
322-
NetworkEntityManager::RemoveNetworkEntity(this);
320+
RemoveFromNetwork();
323321

324322
// We cannot call the VM during shutdown because all the needed data has been or is in the process of being deleted.
325323
if (PClass::bVMOperational)
@@ -596,74 +594,6 @@ void DObject::CheckIfSerialized () const
596594
}
597595
}
598596

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-
}
666-
667597
DEFINE_ACTION_FUNCTION(DObject, MSTime)
668598
{
669599
ACTION_RETURN_INT((uint32_t)I_msTime());

src/common/objects/dobject.h

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ class DObject
361361
inline uint32_t GetNetworkID() const { return _networkID; }
362362
void SetNetworkID(const uint32_t id);
363363
void ClearNetworkID();
364+
void RemoveFromNetwork();
364365
virtual void EnableNetworking(const bool enable);
365366
};
366367

src/d_net.cpp

+85
Original file line numberDiff line numberDiff line change
@@ -2965,6 +2965,12 @@ int Net_GetLatency(int *ld, int *ad)
29652965
return severity;
29662966
}
29672967

2968+
//==========================================================================
2969+
//
2970+
//
2971+
//
2972+
//==========================================================================
2973+
29682974
void NetworkEntityManager::InitializeNetworkEntities()
29692975
{
29702976
if (!s_netEntities.Size())
@@ -3048,6 +3054,85 @@ DObject* NetworkEntityManager::GetNetworkEntity(const uint32_t id)
30483054
return s_netEntities[id];
30493055
}
30503056

3057+
//==========================================================================
3058+
//
3059+
//
3060+
//
3061+
//==========================================================================
3062+
3063+
void DObject::SetNetworkID(const uint32_t id)
3064+
{
3065+
if (!IsNetworked())
3066+
{
3067+
ObjectFlags |= OF_Networked;
3068+
_networkID = id;
3069+
}
3070+
}
3071+
3072+
void DObject::ClearNetworkID()
3073+
{
3074+
ObjectFlags &= ~OF_Networked;
3075+
_networkID = NetworkEntityManager::WorldNetID;
3076+
}
3077+
3078+
void DObject::EnableNetworking(const bool enable)
3079+
{
3080+
if (enable)
3081+
NetworkEntityManager::AddNetworkEntity(this);
3082+
else
3083+
NetworkEntityManager::RemoveNetworkEntity(this);
3084+
}
3085+
3086+
void DObject::RemoveFromNetwork()
3087+
{
3088+
NetworkEntityManager::RemoveNetworkEntity(this);
3089+
}
3090+
3091+
static unsigned int GetNetworkID(DObject* const self)
3092+
{
3093+
return self->GetNetworkID();
3094+
}
3095+
3096+
DEFINE_ACTION_FUNCTION_NATIVE(DObject, GetNetworkID, GetNetworkID)
3097+
{
3098+
PARAM_SELF_PROLOGUE(DObject);
3099+
3100+
ACTION_RETURN_INT(self->GetNetworkID());
3101+
}
3102+
3103+
static void EnableNetworking(DObject* const self, const bool enable)
3104+
{
3105+
self->EnableNetworking(enable);
3106+
}
3107+
3108+
DEFINE_ACTION_FUNCTION_NATIVE(DObject, EnableNetworking, EnableNetworking)
3109+
{
3110+
PARAM_SELF_PROLOGUE(DObject);
3111+
PARAM_BOOL(enable);
3112+
3113+
self->EnableNetworking(enable);
3114+
return 0;
3115+
}
3116+
3117+
static DObject* GetNetworkEntity(const unsigned int id)
3118+
{
3119+
return NetworkEntityManager::GetNetworkEntity(id);
3120+
}
3121+
3122+
DEFINE_ACTION_FUNCTION_NATIVE(DObject, GetNetworkEntity, GetNetworkEntity)
3123+
{
3124+
PARAM_PROLOGUE;
3125+
PARAM_UINT(id);
3126+
3127+
ACTION_RETURN_OBJECT(NetworkEntityManager::GetNetworkEntity(id));
3128+
}
3129+
3130+
//==========================================================================
3131+
//
3132+
//
3133+
//
3134+
//==========================================================================
3135+
30513136
// [RH] List "ping" times
30523137
CCMD (pings)
30533138
{

0 commit comments

Comments
 (0)