Tweaked net ID file management

Should now be easier to stub network entity functions for Raze.
This commit is contained in:
Boondorl 2024-04-20 10:43:34 -04:00 committed by Rachael Alexanderson
commit 38f14ccd56
No known key found for this signature in database
GPG key ID: 26A8ACCE97115EE0
3 changed files with 87 additions and 71 deletions

View file

@ -2965,6 +2965,12 @@ int Net_GetLatency(int *ld, int *ad)
return severity;
}
//==========================================================================
//
//
//
//==========================================================================
void NetworkEntityManager::InitializeNetworkEntities()
{
if (!s_netEntities.Size())
@ -3048,6 +3054,85 @@ DObject* NetworkEntityManager::GetNetworkEntity(const uint32_t id)
return s_netEntities[id];
}
//==========================================================================
//
//
//
//==========================================================================
void DObject::SetNetworkID(const uint32_t id)
{
if (!IsNetworked())
{
ObjectFlags |= OF_Networked;
_networkID = id;
}
}
void DObject::ClearNetworkID()
{
ObjectFlags &= ~OF_Networked;
_networkID = NetworkEntityManager::WorldNetID;
}
void DObject::EnableNetworking(const bool enable)
{
if (enable)
NetworkEntityManager::AddNetworkEntity(this);
else
NetworkEntityManager::RemoveNetworkEntity(this);
}
void DObject::RemoveFromNetwork()
{
NetworkEntityManager::RemoveNetworkEntity(this);
}
static unsigned int GetNetworkID(DObject* const self)
{
return self->GetNetworkID();
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, GetNetworkID, GetNetworkID)
{
PARAM_SELF_PROLOGUE(DObject);
ACTION_RETURN_INT(self->GetNetworkID());
}
static void EnableNetworking(DObject* const self, const bool enable)
{
self->EnableNetworking(enable);
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, EnableNetworking, EnableNetworking)
{
PARAM_SELF_PROLOGUE(DObject);
PARAM_BOOL(enable);
self->EnableNetworking(enable);
return 0;
}
static DObject* GetNetworkEntity(const unsigned int id)
{
return NetworkEntityManager::GetNetworkEntity(id);
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, GetNetworkEntity, GetNetworkEntity)
{
PARAM_PROLOGUE;
PARAM_UINT(id);
ACTION_RETURN_OBJECT(NetworkEntityManager::GetNetworkEntity(id));
}
//==========================================================================
//
//
//
//==========================================================================
// [RH] List "ping" times
CCMD (pings)
{