Fixes for client network IDs

Fixed an off-by-one error on client IDs (these need to start at 1 as 0 is an invalid network ID). Morphing will now swap the client body's ID so it remains in the first 1 - MAXPLAYERS slots.
This commit is contained in:
Boondorl 2024-04-24 12:46:30 -04:00 committed by Ricardo Luís Vaz Silva
commit cf6bad97e8
3 changed files with 7 additions and 2 deletions

View file

@ -637,10 +637,11 @@ void NetworkEntityManager::InitializeNetworkEntities()
}
// Clients need special handling since they always go in slots 1 - MAXPLAYERS.
void NetworkEntityManager::SetClientNetworkEntity(DObject* mo, const uint32_t id)
void NetworkEntityManager::SetClientNetworkEntity(DObject* mo, const unsigned int playNum)
{
// If resurrecting, we need to swap the corpse's position with the new pawn's
// position so it's no longer considered the client's body.
const uint32_t id = ClientNetIDStart + playNum;
DObject* const oldBody = s_netEntities[id];
if (oldBody != nullptr)
{

View file

@ -502,7 +502,7 @@ public:
inline static uint32_t NetIDStart;// = MAXPLAYERS + 1u;
static void InitializeNetworkEntities();
static void SetClientNetworkEntity(DObject* mo, const uint32_t id);
static void SetClientNetworkEntity(DObject* mo, const unsigned int playNum);
static void AddNetworkEntity(DObject* const ent);
static void RemoveNetworkEntity(DObject* const ent);
static DObject* GetNetworkEntity(const uint32_t id);