diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index f2195f890f..852d389f5a 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -749,9 +749,8 @@ sfxinfo_t *SoundEngine::LoadSound(sfxinfo_t *sfx) { auto sfxp = sfxdata.data(); int32_t dmxlen = LittleLong(((int32_t *)sfxp)[1]); - // If the sound is voc, use the custom loader. - if (memcmp (sfxp, "Creative Voice File", 19) == 0) + if (size > 19 && memcmp (sfxp, "Creative Voice File", 19) == 0) { sfx->data = GSnd->LoadSoundVoc(sfxp, size); } diff --git a/source/common/filesystem/source/file_directory.cpp b/source/common/filesystem/source/file_directory.cpp index c2ac8624f2..0b9b7cd45e 100644 --- a/source/common/filesystem/source/file_directory.cpp +++ b/source/common/filesystem/source/file_directory.cpp @@ -132,7 +132,7 @@ int FDirectory::AddDirectory(const char *dirpath, LumpFilterInfo* filter, FileSy // On Linux this is important because its file system is case sensitive, // but even on Windows the Unicode normalization is destructive // for some characters and cannot be used for file names. - // Examples for this are the Turkish 'i's or the German ß. + // Examples for this are the Turkish 'i's or the German ß. SystemFilePath[count] = stringpool->Strdup(entry.FilePathRel.c_str()); // for internal access we use the normalized form of the relative path. // this is fine because the paths that get compared against this will also be normalized. diff --git a/source/common/objects/dobject.cpp b/source/common/objects/dobject.cpp index 914579de3c..b66029a535 100644 --- a/source/common/objects/dobject.cpp +++ b/source/common/objects/dobject.cpp @@ -317,6 +317,8 @@ void DObject::Release() void DObject::Destroy () { + RemoveFromNetwork(); + // 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) { @@ -569,8 +571,15 @@ 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); + } } void DObject::CheckIfSerialized () const @@ -585,7 +594,6 @@ void DObject::CheckIfSerialized () const } } - DEFINE_ACTION_FUNCTION(DObject, MSTime) { ACTION_RETURN_INT((uint32_t)I_msTime()); diff --git a/source/common/objects/dobject.h b/source/common/objects/dobject.h index 77d197dac7..f193379c11 100644 --- a/source/common/objects/dobject.h +++ b/source/common/objects/dobject.h @@ -351,6 +351,18 @@ 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(); + void RemoveFromNetwork(); + 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/source/common/objects/dobjgc.h b/source/common/objects/dobjgc.h index 969551d371..f5514255db 100644 --- a/source/common/objects/dobjgc.h +++ b/source/common/objects/dobjgc.h @@ -26,6 +26,7 @@ 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/source/core/vmstubs.cpp b/source/core/vmstubs.cpp index 9b77eccb06..dbad66e779 100644 --- a/source/core/vmstubs.cpp +++ b/source/core/vmstubs.cpp @@ -1,8 +1,22 @@ -#include "common/engine/palettecontainer.h" #include "name.h" #include "dobject.h" bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg) { - return false; + return false; } + +void DObject::EnableNetworking(const bool enable) +{ + return; +} + +void DObject::RemoveFromNetwork(void) +{ + return; +} + +void DObject::ClearNetworkID() +{ + return; +} \ No newline at end of file