diff --git a/src/common/objects/dobject.cpp b/src/common/objects/dobject.cpp index 15400ce239c..914579de3c7 100644 --- a/src/common/objects/dobject.cpp +++ b/src/common/objects/dobject.cpp @@ -218,8 +218,6 @@ CCMD (dumpclasses) // //========================================================================== -#include "d_net.h" - void DObject::InPlaceConstructor (void *mem) { new ((EInPlace *)mem) DObject; @@ -319,8 +317,6 @@ void DObject::Release() void DObject::Destroy () { - NetworkEntityManager::RemoveNetworkEntity(this); - // We cannot call the VM during shutdown because all the needed data has been or is in the process of being deleted. if (PClass::bVMOperational) { @@ -573,15 +569,8 @@ void DObject::Serialize(FSerializer &arc) SerializeFlag("justspawned", OF_JustSpawned); SerializeFlag("spawned", OF_Spawned); - SerializeFlag("networked", OF_Networked); - - ObjectFlags |= OF_SerialSuccess; - if (arc.isReading() && (ObjectFlags & OF_Networked)) - { - ClearNetworkID(); - EnableNetworking(true); - } + ObjectFlags |= OF_SerialSuccess; } void DObject::CheckIfSerialized () const @@ -596,73 +585,6 @@ void DObject::CheckIfSerialized () const } } -//========================================================================== -// -// -// -//========================================================================== - -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); -} - -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)); -} DEFINE_ACTION_FUNCTION(DObject, MSTime) { diff --git a/src/common/objects/dobject.h b/src/common/objects/dobject.h index ed5fc996b3e..77d197dac77 100644 --- a/src/common/objects/dobject.h +++ b/src/common/objects/dobject.h @@ -351,17 +351,6 @@ class DObject friend T* Create(Args&&... args); friend class JitCompiler; - -private: - // This is intentionally left unserialized. - uint32_t _networkID; - -public: - inline bool IsNetworked() const { return (ObjectFlags & OF_Networked); } - inline uint32_t GetNetworkID() const { return _networkID; } - void SetNetworkID(const uint32_t id); - void ClearNetworkID(); - virtual void EnableNetworking(const bool enable); }; // This is the only method aside from calling CreateNew that should be used for creating DObjects diff --git a/src/common/objects/dobjgc.h b/src/common/objects/dobjgc.h index 280c86273f5..39e7d88a85e 100644 --- a/src/common/objects/dobjgc.h +++ b/src/common/objects/dobjgc.h @@ -26,7 +26,6 @@ enum EObjectFlags OF_Transient = 1 << 11, // Object should not be archived (references to it will be nulled on disk) OF_Spawned = 1 << 12, // Thinker was spawned at all (some thinkers get deleted before spawning) OF_Released = 1 << 13, // Object was released from the GC system and should not be processed by GC function - OF_Networked = 1 << 14, // Object has a unique network identifier that makes it synchronizable between all clients. }; template class TObjPtr; diff --git a/src/common/objects/dobjtype.cpp b/src/common/objects/dobjtype.cpp index 0d1bfdf9a87..4c2a1bd4d09 100644 --- a/src/common/objects/dobjtype.cpp +++ b/src/common/objects/dobjtype.cpp @@ -667,8 +667,6 @@ PClass *PClass::FindClassTentative(FName name) // //========================================================================== -bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg); - int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType, bool ignorePointerReadOnly) { auto proto = variant->Proto; @@ -700,7 +698,7 @@ int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction break; } } - else if(!ShouldAllowGameSpecificVirtual(name, a, proto->ArgumentTypes[a], vproto->ArgumentTypes[a])) + else { fail = true; break; diff --git a/src/d_main.cpp b/src/d_main.cpp index c5b77942e7e..dff56da5b42 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3101,8 +3101,6 @@ static int FileSystemPrintf(FSMessageLevel level, const char* fmt, ...) static int D_InitGame(const FIWADInfo* iwad_info, std::vector& allwads, std::vector& pwads) { - NetworkEntityManager::InitializeNetworkEntities(); - if (!restart) { V_InitScreenSize(); diff --git a/src/d_net.cpp b/src/d_net.cpp index 2536739cf77..c43ae158b03 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2965,89 +2965,6 @@ int Net_GetLatency(int *ld, int *ad) return severity; } -void NetworkEntityManager::InitializeNetworkEntities() -{ - if (!s_netEntities.Size()) - s_netEntities.AppendFill(nullptr, NetIDStart); // Allocate the first 0-8 slots for the world and clients. -} - -// Clients need special handling since they always go in slots 1 - MAXPLAYERS. -void NetworkEntityManager::SetClientNetworkEntity(player_t* const client) -{ - AActor* const mo = client->mo; - const uint32_t id = ClientNetIDStart + mo->Level->PlayerNum(client); - - // 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. - DObject* const oldBody = s_netEntities[id]; - if (oldBody != nullptr) - { - if (oldBody == mo) - return; - - const uint32_t curID = mo->GetNetworkID(); - - s_netEntities[curID] = oldBody; - oldBody->ClearNetworkID(); - oldBody->SetNetworkID(curID); - - mo->ClearNetworkID(); - } - else - { - RemoveNetworkEntity(mo); // Free up its current id. - } - - s_netEntities[id] = mo; - mo->SetNetworkID(id); -} - -void NetworkEntityManager::AddNetworkEntity(DObject* const ent) -{ - if (ent->IsNetworked()) - return; - - // Slot 0 is reserved for the world. - // Clients go in the first 1 - MAXPLAYERS slots - // Everything else is first come first serve. - uint32_t id = WorldNetID; - if (s_openNetIDs.Size()) - { - s_openNetIDs.Pop(id); - s_netEntities[id] = ent; - } - else - { - id = s_netEntities.Push(ent); - } - - ent->SetNetworkID(id); -} - -void NetworkEntityManager::RemoveNetworkEntity(DObject* const ent) -{ - if (!ent->IsNetworked()) - return; - - const uint32_t id = ent->GetNetworkID(); - if (id == WorldNetID) - return; - - assert(s_netEntities[id] == ent); - if (id >= NetIDStart) - s_openNetIDs.Push(id); - s_netEntities[id] = nullptr; - ent->ClearNetworkID(); -} - -DObject* NetworkEntityManager::GetNetworkEntity(const uint32_t id) -{ - if (id == WorldNetID || id >= s_netEntities.Size()) - return nullptr; - - return s_netEntities[id]; -} - // [RH] List "ping" times CCMD (pings) { diff --git a/src/d_net.h b/src/d_net.h index e4029bd6602..f0c1606838c 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -95,29 +95,6 @@ extern int nodeforplayer[MAXPLAYERS]; extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; extern int ticdup; -class player_t; -class DObject; - -class NetworkEntityManager -{ -private: - inline static TArray s_netEntities = {}; - inline static TArray s_openNetIDs = {}; - -public: - NetworkEntityManager() = delete; - - inline static uint32_t WorldNetID = 0u; - inline static uint32_t ClientNetIDStart = 1u; - inline static uint32_t NetIDStart = MAXPLAYERS + 1u; - - static void InitializeNetworkEntities(); - static void SetClientNetworkEntity(player_t* const client); - static void AddNetworkEntity(DObject* const ent); - static void RemoveNetworkEntity(DObject* const ent); - static DObject* GetNetworkEntity(const uint32_t id); -}; - // [RH] // New generic packet structure: // diff --git a/src/g_game.cpp b/src/g_game.cpp index d2f85c11112..72b8b763afe 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1424,7 +1424,6 @@ void FLevelLocals::PlayerReborn (int player) p->oldbuttons = ~0, p->attackdown = true; p->usedown = true; // don't do anything immediately p->original_oldbuttons = ~0; p->playerstate = PST_LIVE; - NetworkEntityManager::SetClientNetworkEntity(p); if (gamestate != GS_TITLELEVEL) { diff --git a/src/namedef_custom.h b/src/namedef_custom.h index a62974bd03e..2da881531df 100644 --- a/src/namedef_custom.h +++ b/src/namedef_custom.h @@ -462,7 +462,6 @@ xx(WBobSpeed) xx(WBobFire) xx(PlayerClass) xx(MonsterClass) -xx(Morph) xx(MorphedMonster) xx(Wi_NoAutostartMap) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index de4f7c1c1e7..d5b0abe14c8 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -62,7 +62,6 @@ #include "fragglescript/t_script.h" #include "s_music.h" #include "model.h" -#include "d_net.h" EXTERN_CVAR(Bool, save_formatted) @@ -654,15 +653,6 @@ void FLevelLocals::SerializePlayers(FSerializer &arc, bool skipload) ReadMultiplePlayers(arc, numPlayers, numPlayersNow, skipload); } arc.EndArray(); - - if (!skipload) - { - for (unsigned int i = 0u; i < MAXPLAYERS; ++i) - { - if (PlayerInGame(i) && Players[i]->mo != nullptr) - NetworkEntityManager::SetClientNetworkEntity(Players[i]); - } - } } if (!skipload && numPlayersNow > numPlayers) { diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 8e562f12538..eac4b9f438b 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -804,7 +804,6 @@ class AActor final : public DThinker virtual void PostSerialize() override; virtual void PostBeginPlay() override; // Called immediately before the actor's first tick virtual void Tick() override; - void EnableNetworking(const bool enable) override; static AActor *StaticSpawn (FLevelLocals *Level, PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing = false); diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 7e6a1f7d750..1887d7dc877 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -100,7 +100,6 @@ #include "a_dynlight.h" #include "fragglescript/t_fs.h" #include "shadowinlines.h" -#include "d_net.h" #include "model.h" // MACROS ------------------------------------------------------------------ @@ -180,23 +179,6 @@ IMPLEMENT_POINTERS_START(AActor) IMPLEMENT_POINTER(boneComponentData) IMPLEMENT_POINTERS_END -//========================================================================== -// -// Make sure Actors can never have their networking disabled. -// -//========================================================================== - -void AActor::EnableNetworking(const bool enable) -{ - if (!enable) - { - ThrowAbortException(X_OTHER, "Cannot disable networking on Actors. Consider a Thinker instead."); - return; - } - - Super::EnableNetworking(true); -} - //========================================================================== // // AActor :: Serialize @@ -4848,7 +4830,6 @@ AActor *AActor::StaticSpawn(FLevelLocals *Level, PClassActor *type, const DVecto AActor *actor; actor = static_cast(Level->CreateThinker(type)); - actor->EnableNetworking(true); ConstructActor(actor, pos, SpawningMapThing); return actor; diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index 0e52790d723..60e0cc61411 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -57,19 +57,6 @@ PFunction* FindBuiltinFunction(FName funcname); // //========================================================================== -bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg) -{ - return (name == NAME_Morph && index == 3u && arg->isClassPointer() && varg->isClassPointer() - && PType::toClassPointer(varg)->ClassRestriction->TypeName == NAME_Actor - && PType::toClassPointer(arg)->ClassRestriction->TypeName == NAME_MorphedMonster); -} - -//========================================================================== -// -// -// -//========================================================================== - bool isActor(PContainerType *type) { auto cls = PType::toClass(type); diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index 829e7527075..7f8aab0edd1 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -137,9 +137,6 @@ extend class Object native static void MarkSound(Sound snd); native static uint BAM(double angle); native static void SetMusicVolume(float vol); - native clearscope static Object GetNetworkEntity(uint id); - native play void EnableNetworking(bool enable); - native clearscope uint GetNetworkID() const; } class Thinker : Object native play