diff --git a/Core/Libraries/Source/WWVegas/CMakeLists.txt b/Core/Libraries/Source/WWVegas/CMakeLists.txt index e5d051d795f..3934b8b1997 100644 --- a/Core/Libraries/Source/WWVegas/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/CMakeLists.txt @@ -19,7 +19,6 @@ add_subdirectory(WWDebug) add_subdirectory(WWDownload) add_subdirectory(WWLib) add_subdirectory(WWMath) -add_subdirectory(WWSaveLoad) add_subdirectory(WWStub) # Helpful interface to bundle the ww modules together. @@ -36,5 +35,4 @@ target_link_libraries(core_wwvegas INTERFACE # core_wwdownload core_wwlib core_wwmath - core_wwsaveload ) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index 0bc089fa5f0..64020339598 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -231,7 +231,6 @@ set(WW3D2_SRC ww3d.h ww3dformat.cpp ww3dformat.h - ww3dids.h ww3dtrig.h ) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp index 1466cbfc981..ceab3dc62de 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp @@ -42,9 +42,6 @@ #include "WWLib/inisup.h" #include "WWLib/ffactory.h" #include "WWLib/WWFILE.h" -#include "WWSaveLoad/definition.h" -#include "WWSaveLoad/definitionmgr.h" -#include "WWSaveLoad/definitionclassids.h" #include "WWAudio/WWAudio.h" #include "WWAudio/AudibleSound.h" #include "htree.h" diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp index e2f3f6aaeeb..c320f78a988 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp @@ -87,9 +87,6 @@ #include "camera.h" #include "ww3d.h" #include "WWLib/chunkio.h" -#include "WWSaveLoad/persistfactory.h" -#include "WWSaveLoad/saveload.h" -#include "ww3dids.h" #include "intersec.h" #include @@ -1177,140 +1174,3 @@ void RenderObjClass::Add_Dependencies_To_List } - -/**************************************************************************************** - - - RenderObjClass - Persistent object support. - - NOTE: For now, the render obj PersistFactory is going to cheat by simply storing - the name of the render object that was saved. At load time, it will ask the - asset manager for that object again. If the asset manager fails to re-create the - object, - - -****************************************************************************************/ - -class RenderObjPersistFactoryClass : public PersistFactoryClass -{ - virtual uint32 Chunk_ID() const override; - virtual PersistClass * Load(ChunkLoadClass & cload) const override; - virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const override; - - enum - { - RENDOBJFACTORY_CHUNKID_VARIABLES = 0x00555040, - RENDOBJFACTORY_VARIABLE_OBJPOINTER = 0x00, - RENDOBJFACTORY_VARIABLE_NAME, - RENDOBJFACTORY_VARIABLE_TRANSFORM - }; -}; - -static RenderObjPersistFactoryClass _RenderObjPersistFactory; - -uint32 RenderObjPersistFactoryClass::Chunk_ID() const -{ - return WW3D_PERSIST_CHUNKID_RENDEROBJ; -} - -PersistClass * RenderObjPersistFactoryClass::Load(ChunkLoadClass & cload) const -{ - RenderObjClass * old_obj = nullptr; - Matrix3D tm(1); - char name[64]; - name[0] = '\0'; - - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - - case RENDOBJFACTORY_CHUNKID_VARIABLES: - - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,RENDOBJFACTORY_VARIABLE_OBJPOINTER,old_obj); - READ_MICRO_CHUNK(cload,RENDOBJFACTORY_VARIABLE_TRANSFORM,tm); - READ_MICRO_CHUNK_STRING(cload,RENDOBJFACTORY_VARIABLE_NAME,name,sizeof(name)); - } - cload.Close_Micro_Chunk(); - } - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - }; - cload.Close_Chunk(); - } - - // if the object we saved didn't have a name, replace it with null - if (strlen(name) == 0) { - static int count = 0; - if ( count++ < 10 ) { - WWDEBUG_SAY(("RenderObjPersistFactory attempted to load an un-named render object!")); - WWDEBUG_SAY(("Replacing it with a null render object!")); - } - strcpy(name,"NULL"); - } - - RenderObjClass * new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - - if (new_obj == nullptr) { - static int count = 0; - if ( count++ < 10 ) { - WWDEBUG_SAY(("RenderObjPersistFactory failed to create object: %s!!",name)); - WWDEBUG_SAY(("Either the asset for this object is gone or you tried to save a procedural object.")); - WWDEBUG_SAY(("Replacing it with a null render object!")); - } - strcpy(name,"NULL"); - new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - } - - WWASSERT(new_obj != nullptr); - if (new_obj) { - new_obj->Set_Transform(tm); - } - - SaveLoadSystemClass::Register_Pointer(old_obj,new_obj); - return new_obj; -} - -void RenderObjPersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj) const -{ - RenderObjClass * robj = (RenderObjClass *)obj; - const char * name = robj->Get_Name(); - const Matrix3D& tm = robj->Get_Transform(); - - csave.Begin_Chunk(RENDOBJFACTORY_CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK(csave,RENDOBJFACTORY_VARIABLE_OBJPOINTER,robj); - WRITE_MICRO_CHUNK_STRING(csave,RENDOBJFACTORY_VARIABLE_NAME,name); - WRITE_MICRO_CHUNK(csave,RENDOBJFACTORY_VARIABLE_TRANSFORM,tm); - csave.End_Chunk(); -} - - -/* -** RenderObj save-load. -*/ -const PersistFactoryClass & RenderObjClass::Get_Factory () const -{ - return _RenderObjPersistFactory; -} - -bool RenderObjClass::Save (ChunkSaveClass &csave) -{ - // This should never hit with the persist factory we're using... - // Yes this looks like a design flaw but the way we're saving render objects is - // a "shortcut". We specifically designed this capability into the persistent - // object system so that we could avoid making all render object's save and - // load themselves if possible. - WWASSERT(0); - return true; -} - -bool RenderObjClass::Load (ChunkLoadClass &cload) -{ - WWASSERT(0); // this should never hit with the persist factory we're using. - return true; -} - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h index 31a986f08c4..04aa32f14d6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h @@ -44,7 +44,6 @@ #include "WWMath/sphere.h" #include "coltype.h" #include "WWMath/aabox.h" -#include "WWSaveLoad/persist.h" #include "WWLib/multilist.h" #include "robjlist.h" #include @@ -148,7 +147,7 @@ class RenderHookClass }; // RenderObjClass definition -class RenderObjClass : public RefCountClass , public PersistClass, public MultiListObjectClass +class RenderObjClass : public RefCountClass , public MultiListObjectClass { public: @@ -482,13 +481,6 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL void Unset_Is_Self_Shadowed() { Bits&=~IS_SELF_SHADOWED; } int Is_Self_Shadowed() const { return (Bits&IS_SELF_SHADOWED); } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Persistent object save-load interface - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual const PersistFactoryClass & Get_Factory () const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - // Application-specific render hook: RenderHookClass * Get_Render_Hook() { return RenderHook; } void Set_Render_Hook(RenderHookClass *hook) { if (RenderHook) delete RenderHook; RenderHook = hook; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp index 648af77cb82..71b83b342dd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp @@ -53,6 +53,57 @@ SoundRenderObjLoaderClass _SoundRenderObjLoader; +////////////////////////////////////////////////////////////////////////////////// +// Save/Load constants of W3D_CHUNK_SOUNDROBJ_DEFINITION +////////////////////////////////////////////////////////////////////////////////// +namespace SOUND_DEFINITION_SAVELOAD +{ + enum + { + CHUNKID_VARIABLES = 0x00000100, + CHUNKID_BASE_CLASS = 0x00000200, + }; + + enum + { + VARID_UNUSED1 = 0x01, + VARID_UNUSED2, + VARID_PRIORITY, + VARID_VOLUME, + VARID_PAN, + VARID_LOOP_COUNT, + VARID_DROP_OFF, + VARID_MAX_VOL, + VARID_TYPE, + VARID_IS3D, + VARID_FILENAME, + VARID_DISPLAY_TEXT, + VARID_LOGICAL_MASK, + VARID_LOGICAL_DELAY, + VARID_CREATE_LOGICAL, + VARID_LOGICAL_DROP_OFF, + VARID_SPHERE_COLOR, + VARID_START_OFFSET, + VARID_PITCH_FACTOR + }; + + // + // CHUNKID_BASE_CLASS holds the ID and name that the sound had in Renegade's definition database. + // + enum + { + CHUNKID_BASE_VARIABLES = 0x00000100, + }; + + enum + { + VARID_BASE_INSTANCEID = 0x01, + VARID_BASE_XXX_PARENTID, + VARID_BASE_NAME, + }; +} + + ////////////////////////////////////////////////////////////////////////////////// // // SoundRenderObjClass @@ -107,15 +158,13 @@ const SoundRenderObjClass & SoundRenderObjClass::operator= (const SoundRenderObjClass &src) { // - // Create a definition from the src sound object - // - AudibleSoundDefinitionClass definition; - definition.Initialize_From_Sound (src.Sound); - - // - // Create the internal sound object from the definition + // Create the internal sound object from the settings of the src sound object // - Set_Sound (&definition); + SoundRenderObjDefClass *definition = NEW_REF (SoundRenderObjDefClass, (src)); + AudibleSoundClass *sound = definition->Create_Sound (); + Set_Sound (sound); + REF_PTR_RELEASE (sound); + REF_PTR_RELEASE (definition); // // Copy the other misc settings @@ -131,22 +180,16 @@ SoundRenderObjClass::operator= (const SoundRenderObjClass &src) // ////////////////////////////////////////////////////////////////////////////////// void -SoundRenderObjClass::Set_Sound (AudibleSoundDefinitionClass *definition) +SoundRenderObjClass::Set_Sound (AudibleSoundClass *sound) { // // Remove the old sound from the world (if necessary) // if (Sound != nullptr) { Sound->Remove_From_Scene (); - REF_PTR_RELEASE (Sound); } - // - // Create the sound object from its definition - // - if (definition != nullptr) { - Sound = (AudibleSoundClass *)definition->Create (); - } + REF_PTR_SET (Sound, sound); } @@ -403,6 +446,32 @@ SoundRenderObjClass::Set_Position (const Vector3 &pos) //********************************************************************************* +////////////////////////////////////////////////////////////////////////////////// +// +// SoundSettingsStruct +// +////////////////////////////////////////////////////////////////////////////////// +SoundRenderObjDefClass::SoundSettingsStruct::SoundSettingsStruct () + : Priority (0.5F), + Volume (1.0F), + Pan (0.5F), + LoopCount (1), + DropOffRadius (40.0F), + MaxVolRadius (20.0F), + Is3D (true), + Type (AudibleSoundClass::TYPE_SOUND_EFFECT), + StartOffset (0), + PitchFactor (1.0F), + LogicalTypeMask (0), + LogicalNotifyDelay (2), + LogicalDropOffRadius (-1.0F), + CreateLogical (false), + AttenuationSphereColor (0, 0.75F, 0.75F), + DefinitionID (0) +{ +} + + ////////////////////////////////////////////////////////////////////////////////// // // SoundRenderObjDefClass @@ -420,7 +489,7 @@ SoundRenderObjDefClass::SoundRenderObjDefClass () // SoundRenderObjDefClass // ////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjDefClass::SoundRenderObjDefClass (SoundRenderObjClass &render_obj) +SoundRenderObjDefClass::SoundRenderObjDefClass (const SoundRenderObjClass &render_obj) : Version (W3D_CURRENT_SOUNDROBJ_VERSION), Flags (SoundRenderObjClass::FLAG_STOP_WHEN_HIDDEN) { @@ -459,7 +528,7 @@ SoundRenderObjDefClass::~SoundRenderObjDefClass () const SoundRenderObjDefClass & SoundRenderObjDefClass::operator= (const SoundRenderObjDefClass &src) { - Definition = src.Definition; + Settings = src.Settings; Version = src.Version; Name = src.Name; return (*this); @@ -479,25 +548,114 @@ SoundRenderObjDefClass::Create () // SoundRenderObjClass *render_obj = W3DNEW SoundRenderObjClass; render_obj->Set_Name (Name); - render_obj->Set_Sound (&Definition); + + AudibleSoundClass *sound = Create_Sound (); + render_obj->Set_Sound (sound); + REF_PTR_RELEASE (sound); + render_obj->Set_Flags (Flags); return render_obj; } +////////////////////////////////////////////////////////////////////////////////// +// +// Create_Sound +// +////////////////////////////////////////////////////////////////////////////////// +AudibleSoundClass * +SoundRenderObjDefClass::Create_Sound () const +{ + AudibleSoundClass *new_sound = nullptr; + + // + // If this is a relative path, strip it off and assume + // the current directory is set correctly. + // + StringClass real_filename(Settings.Filename,true); + const char *dir_delimiter = ::strrchr (Settings.Filename, '\\'); + if (dir_delimiter != nullptr && Settings.Filename.Get_Length () > 2 && Settings.Filename[1] != ':') { + real_filename = (dir_delimiter + 1); + } + + // + // Should we create a 2D or 3D sound? + // + if (Settings.Is3D) { + new_sound = WWAudioClass::Get_Instance ()->Create_3D_Sound (real_filename, CLASSID_3D); + } else { + new_sound = WWAudioClass::Get_Instance ()->Create_Sound_Effect (real_filename); + } + + // + // Did we successfully create the sound? + // + if (new_sound != nullptr) { + + // + // Configure the sound + // + new_sound->Set_Type ((AudibleSoundClass::SOUND_TYPE)Settings.Type); + new_sound->Set_Priority (Settings.Priority); + new_sound->Set_Volume (Settings.Volume); + new_sound->Set_Loop_Count (Settings.LoopCount); + new_sound->Set_DropOff_Radius (Settings.DropOffRadius); + new_sound->Set_Start_Offset (Settings.StartOffset); + new_sound->Set_Pitch_Factor (Settings.PitchFactor); + + if (Settings.Is3D) { + ((Sound3DClass *)new_sound)->Set_Max_Vol_Radius (Settings.MaxVolRadius); + } + } + + return new_sound; +} + + ////////////////////////////////////////////////////////////////////////////////// // // Initialize // ////////////////////////////////////////////////////////////////////////////////// void -SoundRenderObjDefClass::Initialize (SoundRenderObjClass &render_obj) +SoundRenderObjDefClass::Initialize (const SoundRenderObjClass &render_obj) { // - // Copy the settings from the sound object into our definition + // Read the settings from the sound object // - Definition.Initialize_From_Sound (render_obj.Peek_Sound ()); + AudibleSoundClass *sound = render_obj.Peek_Sound (); + if (sound != nullptr) { + Sound3DClass *sound_3d = sound->As_Sound3DClass (); + + // + // Choose defaults for the values that we can't get from + // the sound. + // + Settings.LogicalDropOffRadius = -1.0F; + Settings.LogicalNotifyDelay = 2; + Settings.LogicalTypeMask = 0; + Settings.CreateLogical = false; + Settings.Pan = 0.5F; + Settings.DisplayText = ""; + + // + // Copy the values that we can from the sound object + // + Settings.Filename = sound->Get_Filename (); + Settings.DropOffRadius = sound->Get_DropOff_Radius (); + Settings.Priority = sound->Peek_Priority (); + Settings.Is3D = (sound_3d != nullptr); + Settings.Type = sound->Get_Type (); + Settings.LoopCount = sound->Get_Loop_Count (); + Settings.Volume = sound->Get_Volume (); + Settings.StartOffset = sound->Get_Start_Offset (); + Settings.PitchFactor = sound->Get_Pitch_Factor (); + + if (sound_3d != nullptr) { + Settings.MaxVolRadius = sound_3d->Get_Max_Vol_Radius (); + } + } // // Copy the flags from the render object @@ -619,13 +777,24 @@ SoundRenderObjDefClass::Read_Definition (ChunkLoadClass &cload) if (cload.Open_Chunk () && (cload.Cur_Chunk_ID () == W3D_CHUNK_SOUNDROBJ_DEFINITION)) { - // - // Ask the definition to load its settings from the chunk - // - if (Definition.Load (cload)) { - retval = WW3D_ERROR_OK; + using namespace SOUND_DEFINITION_SAVELOAD; + + while (cload.Open_Chunk ()) { + switch (cload.Cur_Chunk_ID ()) { + + case CHUNKID_VARIABLES: + Read_Settings (cload); + break; + + case CHUNKID_BASE_CLASS: + Read_Base_Class (cload); + break; + } + + cload.Close_Chunk (); } + retval = WW3D_ERROR_OK; cload.Close_Chunk (); } @@ -633,6 +802,77 @@ SoundRenderObjDefClass::Read_Definition (ChunkLoadClass &cload) } +/////////////////////////////////////////////////////////////////////////////////// +// +// Read_Settings +// +/////////////////////////////////////////////////////////////////////////////////// +void +SoundRenderObjDefClass::Read_Settings (ChunkLoadClass &cload) +{ + using namespace SOUND_DEFINITION_SAVELOAD; + + // + // Loop through all the microchunks that define the variables + // + while (cload.Open_Micro_Chunk ()) { + switch (cload.Cur_Micro_Chunk_ID ()) { + + READ_MICRO_CHUNK (cload, VARID_PRIORITY, Settings.Priority) + READ_MICRO_CHUNK (cload, VARID_VOLUME, Settings.Volume) + READ_MICRO_CHUNK (cload, VARID_PAN, Settings.Pan) + READ_MICRO_CHUNK (cload, VARID_LOOP_COUNT, Settings.LoopCount) + READ_MICRO_CHUNK (cload, VARID_DROP_OFF, Settings.DropOffRadius) + READ_MICRO_CHUNK (cload, VARID_MAX_VOL, Settings.MaxVolRadius) + READ_MICRO_CHUNK (cload, VARID_TYPE, Settings.Type) + READ_MICRO_CHUNK (cload, VARID_IS3D, Settings.Is3D) + READ_MICRO_CHUNK_WWSTRING (cload, VARID_FILENAME, Settings.Filename) + READ_MICRO_CHUNK_WWSTRING (cload, VARID_DISPLAY_TEXT, Settings.DisplayText) + READ_MICRO_CHUNK (cload, VARID_LOGICAL_MASK, Settings.LogicalTypeMask) + READ_MICRO_CHUNK (cload, VARID_LOGICAL_DELAY, Settings.LogicalNotifyDelay) + READ_MICRO_CHUNK (cload, VARID_CREATE_LOGICAL, Settings.CreateLogical) + READ_MICRO_CHUNK (cload, VARID_LOGICAL_DROP_OFF, Settings.LogicalDropOffRadius) + READ_MICRO_CHUNK (cload, VARID_SPHERE_COLOR, Settings.AttenuationSphereColor) + READ_MICRO_CHUNK (cload, VARID_START_OFFSET, Settings.StartOffset); + READ_MICRO_CHUNK (cload, VARID_PITCH_FACTOR, Settings.PitchFactor); + } + + cload.Close_Micro_Chunk (); + } +} + + +/////////////////////////////////////////////////////////////////////////////////// +// +// Read_Base_Class +// +/////////////////////////////////////////////////////////////////////////////////// +void +SoundRenderObjDefClass::Read_Base_Class (ChunkLoadClass &cload) +{ + using namespace SOUND_DEFINITION_SAVELOAD; + + while (cload.Open_Chunk ()) { + switch (cload.Cur_Chunk_ID ()) { + + case CHUNKID_BASE_VARIABLES: + while (cload.Open_Micro_Chunk ()) { + switch (cload.Cur_Micro_Chunk_ID ()) { + + READ_MICRO_CHUNK (cload, VARID_BASE_INSTANCEID, Settings.DefinitionID) + READ_MICRO_CHUNK_WWSTRING (cload, VARID_BASE_NAME, Settings.DefinitionName) + } + + cload.Close_Micro_Chunk (); + } + break; + } + + cload.Close_Chunk (); + } +} + + /////////////////////////////////////////////////////////////////////////////////// // // Write_Header @@ -686,9 +926,17 @@ SoundRenderObjDefClass::Write_Definition (ChunkSaveClass &csave) // Save the definition to its own chunk // if (csave.Begin_Chunk (W3D_CHUNK_SOUNDROBJ_DEFINITION) == TRUE) { - if (Definition.Save (csave)) { - retval = WW3D_ERROR_OK; - } + using namespace SOUND_DEFINITION_SAVELOAD; + + csave.Begin_Chunk (CHUNKID_VARIABLES); + Write_Settings (csave); + csave.End_Chunk (); + + csave.Begin_Chunk (CHUNKID_BASE_CLASS); + Write_Base_Class (csave); + csave.End_Chunk (); + + retval = WW3D_ERROR_OK; csave.End_Chunk (); } @@ -696,6 +944,60 @@ SoundRenderObjDefClass::Write_Definition (ChunkSaveClass &csave) } +/////////////////////////////////////////////////////////////////////////////////// +// +// Write_Settings +// +/////////////////////////////////////////////////////////////////////////////////// +void +SoundRenderObjDefClass::Write_Settings (ChunkSaveClass &csave) +{ + using namespace SOUND_DEFINITION_SAVELOAD; + + // + // Save the audible variables + // + WRITE_MICRO_CHUNK (csave, VARID_PRIORITY, Settings.Priority) + WRITE_MICRO_CHUNK (csave, VARID_VOLUME, Settings.Volume) + WRITE_MICRO_CHUNK (csave, VARID_PAN, Settings.Pan) + WRITE_MICRO_CHUNK (csave, VARID_LOOP_COUNT, Settings.LoopCount) + WRITE_MICRO_CHUNK (csave, VARID_DROP_OFF, Settings.DropOffRadius) + WRITE_MICRO_CHUNK (csave, VARID_MAX_VOL, Settings.MaxVolRadius) + WRITE_MICRO_CHUNK (csave, VARID_TYPE, Settings.Type) + WRITE_MICRO_CHUNK (csave, VARID_IS3D, Settings.Is3D) + WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_FILENAME, Settings.Filename) + WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_DISPLAY_TEXT, Settings.DisplayText) + WRITE_MICRO_CHUNK (csave, VARID_START_OFFSET, Settings.StartOffset); + WRITE_MICRO_CHUNK (csave, VARID_PITCH_FACTOR, Settings.PitchFactor); + + // + // Save the logical variables + // + WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_MASK, Settings.LogicalTypeMask) + WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_DELAY, Settings.LogicalNotifyDelay) + WRITE_MICRO_CHUNK (csave, VARID_CREATE_LOGICAL, Settings.CreateLogical) + WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_DROP_OFF, Settings.LogicalDropOffRadius) + WRITE_MICRO_CHUNK (csave, VARID_SPHERE_COLOR, Settings.AttenuationSphereColor) +} + + +/////////////////////////////////////////////////////////////////////////////////// +// +// Write_Base_Class +// +/////////////////////////////////////////////////////////////////////////////////// +void +SoundRenderObjDefClass::Write_Base_Class (ChunkSaveClass &csave) +{ + using namespace SOUND_DEFINITION_SAVELOAD; + + csave.Begin_Chunk (CHUNKID_BASE_VARIABLES); + WRITE_MICRO_CHUNK (csave, VARID_BASE_INSTANCEID, Settings.DefinitionID); + WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_BASE_NAME, Settings.DefinitionName); + csave.End_Chunk (); +} + + //********************************************************************************* // // Start of SoundRenderObjDefClass diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h index 4ca84795fc0..8342bd34e39 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h @@ -118,7 +118,7 @@ class SoundRenderObjClass : public RenderObjClass // // SoundRenderObjClass specific // - virtual void Set_Sound (AudibleSoundDefinitionClass *definition); + virtual void Set_Sound (AudibleSoundClass *sound); virtual AudibleSoundClass * Get_Sound () const; virtual AudibleSoundClass * Peek_Sound () const { return Sound; } @@ -163,7 +163,7 @@ class SoundRenderObjDefClass : public RefCountClass // Public constructors/destructors /////////////////////////////////////////////////////////// SoundRenderObjDefClass (); - SoundRenderObjDefClass (SoundRenderObjClass &render_obj); + SoundRenderObjDefClass (const SoundRenderObjClass &render_obj); SoundRenderObjDefClass (const SoundRenderObjDefClass &src); virtual ~SoundRenderObjDefClass () override; @@ -176,6 +176,7 @@ class SoundRenderObjDefClass : public RefCountClass // Public methods /////////////////////////////////////////////////////////// RenderObjClass * Create (); + AudibleSoundClass * Create_Sound () const; WW3DErrorType Load_W3D (ChunkLoadClass &cload); WW3DErrorType Save_W3D (ChunkSaveClass &csave); const char * Get_Name () const { return Name; } @@ -185,7 +186,7 @@ class SoundRenderObjDefClass : public RefCountClass // // Initialization // - void Initialize (SoundRenderObjClass &render_obj); + void Initialize (const SoundRenderObjClass &render_obj); protected: @@ -198,21 +199,61 @@ class SoundRenderObjDefClass : public RefCountClass // WW3DErrorType Read_Header (ChunkLoadClass &cload); WW3DErrorType Read_Definition (ChunkLoadClass &cload); + void Read_Settings (ChunkLoadClass &cload); + void Read_Base_Class (ChunkLoadClass &cload); // // Saving methods // WW3DErrorType Write_Header (ChunkSaveClass &csave); WW3DErrorType Write_Definition (ChunkSaveClass &csave); + void Write_Settings (ChunkSaveClass &csave); + void Write_Base_Class (ChunkSaveClass &csave); private: + /////////////////////////////////////////////////////////// + // Private data types + /////////////////////////////////////////////////////////// + + // + // The settings of the sound that Create_Sound builds. The logical sound settings, the display text, the sphere + // color and the definition ID and name have no effect; they are kept so that a save writes them back. + // + struct SoundSettingsStruct + { + SoundSettingsStruct (); + + float Priority; + float Volume; + float Pan; + int LoopCount; + float DropOffRadius; + float MaxVolRadius; + bool Is3D; + StringClass Filename; + int Type; + StringClass DisplayText; + float StartOffset; + float PitchFactor; + + int LogicalTypeMask; + float LogicalNotifyDelay; + float LogicalDropOffRadius; + bool CreateLogical; + + Vector3 AttenuationSphereColor; + + uint32 DefinitionID; + StringClass DefinitionName; + }; + /////////////////////////////////////////////////////////// // Private member data /////////////////////////////////////////////////////////// uint32 Version; StringClass Name; - AudibleSoundDefinitionClass Definition; + SoundSettingsStruct Settings; SoundRenderObjClass::FLAGS Flags; }; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h deleted file mode 100644 index 7fc696a8650..00000000000 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ww3dids.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWSaveLoad/saveloadids.h" - -/* -** These are the chunk-id's used by all persistent objects in WW3D. The persistent object -** framework is defined in the WWSaveLoad library. -** -** Sept 23, 1999 -** - Initial implementation of making the Commando engine persistent included making some -** of WW3D persistent. For this initial implementation, we're going to assume that we -** can re-create all of our game objects from the asset manager and patch up any state -** changes with custom game object code. Therefore, the base class RenderObjClass has -** a persist manager which simply saves the name of the render object and its transform -** and re-creates that render object from the asset manager. -** -** - Currently lights are procedurally created rather than created from the asset manager. -** For this reason, I'm implementing a persist manager and save-load functionality for -** light class. In the future lights may come from the asset manager in which case we -** could remove this code. -** -** - It is also possible that later on when we make the save game stuff more robust we may -** need to implement actual save load calls for more render objects but hopefully we can -** avoid that since it will at least double the size of our files and just seems like a -** lot of work to solve a few specific problems. -*/ -enum -{ - WW3D_PERSIST_CHUNKID_RENDEROBJ = CHUNKID_WW3D_BEGIN, - WW3D_PERSIST_CHUNKID_LIGHT, - WW3D_PERSIST_CHUNKID_DAZZLE, -}; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h b/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h deleted file mode 100644 index ebd6acc4feb..00000000000 --- a/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWAudio * - * * - * $Archive:: /Commando/Code/WWAudio/AABTreeSoundCullClass.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 4/12/99 11:07a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWMath/aabtreecull.h" - - -///////////////////////////////////////////////////////////////////////////////// -// -// AABTreeSoundCullClass -// -// Simple derived class that implements 2 required methods from AABTreeCullClass. -// -class AABTreeSoundCullClass : public AABTreeCullClass -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - AABTreeSoundCullClass () - : AABTreeCullClass (nullptr) { } - - virtual ~AABTreeSoundCullClass () { } - - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - void Load (ChunkLoadClass & cload) { } - void Save (ChunkSaveClass & csave) { } - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////////// - virtual void Load_Node_Contents (AABTreeNodeClass * node,ChunkLoadClass & cload) { }; - virtual void Save_Node_Contents (AABTreeNodeClass * node,ChunkSaveClass & csave) { }; - -}; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp index 7e9bdc689d0..d3fda9fee71 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp @@ -43,93 +43,11 @@ #include "SoundScene.h" #include "FilteredSound.h" #include "Threads.h" -#include "SoundChunkIDs.h" -#include "WWSaveLoad/simpledefinitionfactory.h" -#include "WWSaveLoad/persistfactory.h" #include "LogicalSound.h" -#include "WWSaveLoad/definitionclassids.h" #include "soundstreamhandle.h" #include "sound2dhandle.h" -////////////////////////////////////////////////////////////////////////////////// -// Static factories -////////////////////////////////////////////////////////////////////////////////// -DECLARE_DEFINITION_FACTORY(AudibleSoundDefinitionClass, CLASSID_SOUND_DEF, "Sound") _SoundDefFactory; -SimplePersistFactoryClass _AudibleSoundDefPersistFactory; -SimplePersistFactoryClass _AudibleSoundPersistFactory; - - -////////////////////////////////////////////////////////////////////////////////// -// Save/Load constants -////////////////////////////////////////////////////////////////////////////////// - -namespace AUDIBLE_SOUND_SAVELOAD -{ - enum - { - CHUNKID_VARIABLES = 0x00000100, - CHUNKID_BASE_CLASS - }; - - enum - { - VARID_STATE = 0x01, - VARID_TYPE, - - VARID_PRIORITY, - VARID_VOLUME, - VARID_PAN, - VARID_LOOP_COUNT, - VARID_LOOPS_LEFT, - VARID_SOUND_LENGTH, - VARID_CURR_POS, - VARID_TRANSFORM, - VARID_PREV_TRANSFORM, - VARID_IS_CULLED, - VARID_IS_DIRTY, - VARID_DROP_OFF, - VARID_FILENAME, - VARID_THIS_PTR, - VARID_START_OFFSET, - VARID_LISTENER_TRANSFORM, - VARID_PITCH_FACTOR - }; -} - -namespace AUDIBLE_SOUND_DEF_SAVELOAD -{ - enum - { - CHUNKID_VARIABLES = 0x00000100, - CHUNKID_BASE_CLASS = 0x00000200, - }; - - enum - { - VARID_UNUSED1 = 0x01, - VARID_UNUSED2, - VARID_PRIORITY, - VARID_VOLUME, - VARID_PAN, - VARID_LOOP_COUNT, - VARID_DROP_OFF, - VARID_MAX_VOL, - VARID_TYPE, - VARID_IS3D, - VARID_FILENAME, - VARID_DISPLAY_TEXT, - VARID_LOGICAL_MASK, - VARID_LOGICAL_DELAY, - VARID_CREATE_LOGICAL, - VARID_LOGICAL_DROP_OFF, - VARID_SPHERE_COLOR, - VARID_START_OFFSET, - VARID_PITCH_FACTOR - }; -} - - //////////////////////////////////////////////////////////////////////////////////////////////// // // AudibleSoundClass @@ -156,7 +74,6 @@ AudibleSoundClass::AudibleSoundClass () m_PrevTransform (1), m_Transform (1), m_ListenerTransform (1), - m_Definition (nullptr), m_LogicalSound (nullptr), m_StartOffset (0), m_PitchFactor (1.0F) @@ -189,7 +106,6 @@ AudibleSoundClass::AudibleSoundClass (const AudibleSoundClass &src) m_pConvertedFormat (nullptr), m_PrevTransform (1), m_Transform (1), - m_Definition (nullptr), m_LogicalSound (nullptr), m_StartOffset (0), m_PitchFactor (1.0F) @@ -357,13 +273,6 @@ AudibleSoundClass::Play (bool alloc_handle) // Fire an event On_Event (AudioCallbackClass::EVENT_SOUND_STARTED); - // - // Create the associate logical sound (if necessary) - // - if (m_LogicalSound == nullptr && m_Definition != nullptr) { - m_LogicalSound = m_Definition->Create_Logical (); - } - // // Add this logical sound to the scene // @@ -372,14 +281,6 @@ AudibleSoundClass::Play (bool alloc_handle) m_LogicalSound->Set_Transform (m_Transform); m_LogicalSound->Add_To_Scene (); } - - // - // Should we send off the text notification? - // - if (m_IsCulled == false && m_Definition != nullptr) { - const StringClass &text = m_Definition->Get_Display_Text (); - WWAudioClass::Get_Instance ()->Fire_Text_Callback (this, text); - } } return true; @@ -1234,509 +1135,3 @@ AudibleSoundClass::As_Converted_Format () return m_pConvertedFormat; } - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -//////////////////////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -AudibleSoundClass::Get_Factory () const -{ - return _AudibleSoundPersistFactory; -} - - -//************************************************************************************************ -//* -//* Start of AudibleSoundDefinitionClass -//* -//************************************************************************************************ - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// AudibleSoundDefinitionClass -// -//////////////////////////////////////////////////////////////////////////////////////////////// -AudibleSoundDefinitionClass::AudibleSoundDefinitionClass () - : m_Priority (0.5F), - m_Volume (1.0F), - m_Pan (0.5F), - m_LoopCount (1), - m_DropOffRadius (40.0F), - m_LogicalDropOffRadius (-1.0F), - m_MaxVolRadius (20.0F), - m_Is3D (true), - m_Type (AudibleSoundClass::TYPE_SOUND_EFFECT), - m_LogicalTypeMask (0), - m_LogicalNotifyDelay (2), - m_CreateLogical (false), - m_AttenuationSphereColor (0, 0.75F, 0.75F), - m_StartOffset (0), - m_PitchFactor (1.0F) -{ - // - // Audible sound params - // - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_SOUND_FILENAME, m_Filename, "Filename"); - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_FLOAT, m_DropOffRadius, "Drop-off Radius"); - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_FLOAT, m_MaxVolRadius, "Max-Vol Radius"); - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_BOOL, m_Is3D, "Is 3D Sound"); - INT_EDITABLE_PARAM (AudibleSoundDefinitionClass, m_LoopCount, 0, 1000000); - FLOAT_EDITABLE_PARAM (AudibleSoundDefinitionClass, m_Volume, 0, 1.0F); - FLOAT_EDITABLE_PARAM (AudibleSoundDefinitionClass, m_Pan, 0, 1.0F); - FLOAT_EDITABLE_PARAM (AudibleSoundDefinitionClass, m_Priority, 0, 1.0F); - ENUM_PARAM (AudibleSoundDefinitionClass, m_Type, ("Sound Effect", AudibleSoundClass::TYPE_SOUND_EFFECT, "Music", AudibleSoundClass::TYPE_MUSIC, 0)); - FLOAT_EDITABLE_PARAM (AudibleSoundDefinitionClass, m_StartOffset, 0, 1.0F); - FLOAT_EDITABLE_PARAM (AudibleSoundDefinitionClass, m_PitchFactor, 0, 1.0F); - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_STRING, m_DisplayText, "Display Text"); - - // - // Logical sound params - // - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_BOOL, m_CreateLogical, "Create Logical Sound"); - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_FLOAT, m_LogicalDropOffRadius, "Logical Drop-off Radius"); - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_FLOAT, m_LogicalNotifyDelay, "Logical Notif Delay"); - -#ifdef PARAM_EDITING_ON - // - // Configure the logical type mask enumeration - // - EnumParameterClass *param = W3DNEW EnumParameterClass (&m_LogicalTypeMask); - param->Set_Name ("Logical Type"); - int count = WWAudioClass::Get_Instance ()->Get_Logical_Type_Count (); - for (int index = 0; index < count; index ++) { - StringClass display_name(0,true); - int id = WWAudioClass::Get_Instance ()->Get_Logical_Type (index, display_name); - param->Add_Value (display_name, id); - } - GENERIC_EDITABLE_PARAM(AudibleSoundDefinitionClass, param); -#endif - - NAMED_EDITABLE_PARAM (AudibleSoundDefinitionClass, ParameterClass::TYPE_COLOR, m_AttenuationSphereColor, "Sphere Color"); -} - -// SKB: Put here because of conficts with CLASSID_???? with other projects. -uint32 AudibleSoundDefinitionClass::Get_Class_ID () const -{ - return CLASSID_SOUND; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Initialize_From_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -void -AudibleSoundDefinitionClass::Initialize_From_Sound (AudibleSoundClass *sound) -{ - // - // Read the settings from the sound object - // - if (sound != nullptr) { - Sound3DClass *sound_3d = sound->As_Sound3DClass (); - - // - // Choose defaults for the values that we can't get from - // the sound. - // - m_LogicalDropOffRadius = -1.0F; - m_LogicalNotifyDelay = 2; - m_LogicalTypeMask = 0; - m_CreateLogical = false; - m_Pan = 0.5F; - m_DisplayText = ""; - - // - // Copy the values that we can from the sound object - // - m_Filename = sound->Get_Filename (); - m_DropOffRadius = sound->Get_DropOff_Radius (); - m_Priority = sound->Peek_Priority (); - m_Is3D = (sound_3d != nullptr); - m_Type = sound->Get_Type (); - m_LoopCount = sound->Get_Loop_Count (); - m_Volume = sound->Get_Volume (); - m_StartOffset = sound->Get_Start_Offset (); - m_PitchFactor = sound->Get_Pitch_Factor (); - - if (sound_3d != nullptr) { - m_MaxVolRadius = sound_3d->Get_Max_Vol_Radius (); - } - } -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -//////////////////////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -AudibleSoundDefinitionClass::Get_Factory () const -{ - return _AudibleSoundDefPersistFactory; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -AudibleSoundDefinitionClass::Save (ChunkSaveClass &csave) -{ - using namespace AUDIBLE_SOUND_DEF_SAVELOAD; - bool retval = true; - - csave.Begin_Chunk (CHUNKID_VARIABLES); - retval &= Save_Variables (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - retval &= DefinitionClass::Save (csave); - csave.End_Chunk (); - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -AudibleSoundDefinitionClass::Load (ChunkLoadClass &cload) -{ - using namespace AUDIBLE_SOUND_DEF_SAVELOAD; - bool retval = true; - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_VARIABLES: - retval &= Load_Variables (cload); - break; - - case CHUNKID_BASE_CLASS: - retval &= DefinitionClass::Load (cload); - break; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -AudibleSoundDefinitionClass::Save_Variables (ChunkSaveClass &csave) -{ - using namespace AUDIBLE_SOUND_DEF_SAVELOAD; - - // - // Save the audible variables - // - WRITE_MICRO_CHUNK (csave, VARID_PRIORITY, m_Priority) - WRITE_MICRO_CHUNK (csave, VARID_VOLUME, m_Volume) - WRITE_MICRO_CHUNK (csave, VARID_PAN, m_Pan) - WRITE_MICRO_CHUNK (csave, VARID_LOOP_COUNT, m_LoopCount) - WRITE_MICRO_CHUNK (csave, VARID_DROP_OFF, m_DropOffRadius) - WRITE_MICRO_CHUNK (csave, VARID_MAX_VOL, m_MaxVolRadius) - WRITE_MICRO_CHUNK (csave, VARID_TYPE, m_Type) - WRITE_MICRO_CHUNK (csave, VARID_IS3D, m_Is3D) - WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_FILENAME, m_Filename) - WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_DISPLAY_TEXT, m_DisplayText) - WRITE_MICRO_CHUNK (csave, VARID_START_OFFSET, m_StartOffset); - WRITE_MICRO_CHUNK (csave, VARID_PITCH_FACTOR, m_PitchFactor); - - // - // Save the logical variables - // - WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_MASK, m_LogicalTypeMask) - WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_DELAY, m_LogicalNotifyDelay) - WRITE_MICRO_CHUNK (csave, VARID_CREATE_LOGICAL, m_CreateLogical) - WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_DROP_OFF, m_LogicalDropOffRadius) - WRITE_MICRO_CHUNK (csave, VARID_SPHERE_COLOR, m_AttenuationSphereColor) - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -AudibleSoundDefinitionClass::Load_Variables (ChunkLoadClass &cload) -{ - using namespace AUDIBLE_SOUND_DEF_SAVELOAD; - - // - // Loop through all the microchunks that define the variables - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_PRIORITY, m_Priority) - READ_MICRO_CHUNK (cload, VARID_VOLUME, m_Volume) - READ_MICRO_CHUNK (cload, VARID_PAN, m_Pan) - READ_MICRO_CHUNK (cload, VARID_LOOP_COUNT, m_LoopCount) - READ_MICRO_CHUNK (cload, VARID_DROP_OFF, m_DropOffRadius) - READ_MICRO_CHUNK (cload, VARID_MAX_VOL, m_MaxVolRadius) - READ_MICRO_CHUNK (cload, VARID_TYPE, m_Type) - READ_MICRO_CHUNK (cload, VARID_IS3D, m_Is3D) - READ_MICRO_CHUNK_WWSTRING (cload, VARID_FILENAME, m_Filename) - READ_MICRO_CHUNK_WWSTRING (cload, VARID_DISPLAY_TEXT, m_DisplayText) - READ_MICRO_CHUNK (cload, VARID_LOGICAL_MASK, m_LogicalTypeMask) - READ_MICRO_CHUNK (cload, VARID_LOGICAL_DELAY, m_LogicalNotifyDelay) - READ_MICRO_CHUNK (cload, VARID_CREATE_LOGICAL, m_CreateLogical) - READ_MICRO_CHUNK (cload, VARID_LOGICAL_DROP_OFF, m_LogicalDropOffRadius) - READ_MICRO_CHUNK (cload, VARID_SPHERE_COLOR, m_AttenuationSphereColor) - READ_MICRO_CHUNK (cload, VARID_START_OFFSET, m_StartOffset); - READ_MICRO_CHUNK (cload, VARID_PITCH_FACTOR, m_PitchFactor); - } - - cload.Close_Micro_Chunk (); - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Create -// -////////////////////////////////////////////////////////////////////////////////// -PersistClass * -AudibleSoundDefinitionClass::Create () const -{ - return Create_Sound (CLASSID_3D); -} - -////////////////////////////////////////////////////////////////////////////////// -// -// Create_Sound -// -////////////////////////////////////////////////////////////////////////////////// -AudibleSoundClass * -AudibleSoundDefinitionClass::Create_Sound (int classid_hint) const -{ - AudibleSoundClass *new_sound = nullptr; - - // - // If this is a relative path, strip it off and assume - // the current directory is set correctly. - // - StringClass real_filename(m_Filename,true); - const char *dir_delimiter = ::strrchr (m_Filename, '\\'); - if (dir_delimiter != nullptr && m_Filename.Get_Length () > 2 && m_Filename[1] != ':') { - real_filename = (dir_delimiter + 1); - } - - // - // Should we create a 2D or 3D sound? - // - if (m_Is3D) { - new_sound = WWAudioClass::Get_Instance ()->Create_3D_Sound (real_filename, classid_hint); - } else { - new_sound = WWAudioClass::Get_Instance ()->Create_Sound_Effect (real_filename); - } - - // - // Did we successfully create the sound? - // - if (new_sound != nullptr) { - - // - // Configure the sound - // - new_sound->Set_Type ((AudibleSoundClass::SOUND_TYPE)m_Type); - new_sound->Set_Priority (m_Priority); - new_sound->Set_Volume (m_Volume); - new_sound->Set_Loop_Count (m_LoopCount); - new_sound->Set_DropOff_Radius (m_DropOffRadius); - new_sound->Set_Definition ((AudibleSoundDefinitionClass *)this); - new_sound->Set_Start_Offset (m_StartOffset); - new_sound->Set_Pitch_Factor (m_PitchFactor); - - if (m_Is3D) { - ((Sound3DClass *)new_sound)->Set_Max_Vol_Radius (m_MaxVolRadius); - } - } - - return new_sound; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Create_Logical -// -////////////////////////////////////////////////////////////////////////////////// -LogicalSoundClass * -AudibleSoundDefinitionClass::Create_Logical () -{ - LogicalSoundClass *logical_sound = nullptr; - - if (m_CreateLogical) { - - // - // Create and configure the logical sound - // - logical_sound = W3DNEW LogicalSoundClass; - logical_sound->Set_Type_Mask (m_LogicalTypeMask); - logical_sound->Set_Notify_Delay (m_LogicalNotifyDelay); - logical_sound->Set_Single_Shot (m_LoopCount != 0); - - // - // Use the audible sound's drop-off radius if the logical - // isn't set... - // - if (m_LogicalDropOffRadius < 0) { - logical_sound->Set_DropOff_Radius (m_DropOffRadius); - } else { - logical_sound->Set_DropOff_Radius (m_LogicalDropOffRadius); - } - } - - return logical_sound; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -AudibleSoundClass::Save (ChunkSaveClass &csave) -{ - using namespace AUDIBLE_SOUND_SAVELOAD; - - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - SoundSceneObjClass::Save (csave); - csave.End_Chunk (); - - uint32 temp_position = 0; - csave.Begin_Chunk (CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK (csave, VARID_STATE, m_State); - WRITE_MICRO_CHUNK (csave, VARID_TYPE, m_Type); - - WRITE_MICRO_CHUNK (csave, VARID_PRIORITY, m_Priority); - WRITE_MICRO_CHUNK (csave, VARID_VOLUME, m_Volume); - WRITE_MICRO_CHUNK (csave, VARID_PAN, m_Pan); - WRITE_MICRO_CHUNK (csave, VARID_LOOP_COUNT, m_LoopCount); - WRITE_MICRO_CHUNK (csave, VARID_LOOPS_LEFT, m_LoopsLeft); - WRITE_MICRO_CHUNK (csave, VARID_SOUND_LENGTH, m_Length); - WRITE_MICRO_CHUNK (csave, VARID_CURR_POS, temp_position); - WRITE_MICRO_CHUNK (csave, VARID_TRANSFORM, m_Transform); - WRITE_MICRO_CHUNK (csave, VARID_PREV_TRANSFORM, m_PrevTransform); - WRITE_MICRO_CHUNK (csave, VARID_IS_CULLED, m_IsCulled); - WRITE_MICRO_CHUNK (csave, VARID_IS_DIRTY, m_bDirty); - WRITE_MICRO_CHUNK (csave, VARID_DROP_OFF, m_DropOffRadius); - WRITE_MICRO_CHUNK (csave, VARID_START_OFFSET, m_StartOffset); - WRITE_MICRO_CHUNK (csave, VARID_PITCH_FACTOR, m_PitchFactor); - WRITE_MICRO_CHUNK (csave, VARID_LISTENER_TRANSFORM, m_ListenerTransform); - - if (m_Buffer != nullptr) { - WRITE_MICRO_CHUNK_STRING (csave, VARID_FILENAME, m_Buffer->Get_Filename ()); - } - - AudibleSoundClass *this_ptr = this; - WRITE_MICRO_CHUNK (csave, VARID_THIS_PTR, this_ptr); - - csave.End_Chunk (); - - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -AudibleSoundClass::Load (ChunkLoadClass &cload) -{ - using namespace AUDIBLE_SOUND_SAVELOAD; - - StringClass filename(0,true); - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_BASE_CLASS: - SoundSceneObjClass::Load (cload); - break; - - case CHUNKID_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_STATE, m_State); - READ_MICRO_CHUNK (cload, VARID_TYPE, m_Type); - - READ_MICRO_CHUNK (cload, VARID_PRIORITY, m_Priority); - READ_MICRO_CHUNK (cload, VARID_VOLUME, m_Volume); - READ_MICRO_CHUNK (cload, VARID_PAN, m_Pan); - READ_MICRO_CHUNK (cload, VARID_LOOP_COUNT, m_LoopCount); - READ_MICRO_CHUNK (cload, VARID_LOOPS_LEFT, m_LoopsLeft); - READ_MICRO_CHUNK (cload, VARID_SOUND_LENGTH, m_Length); - READ_MICRO_CHUNK (cload, VARID_CURR_POS, m_CurrentPosition); - READ_MICRO_CHUNK (cload, VARID_TRANSFORM, m_Transform); - READ_MICRO_CHUNK (cload, VARID_PREV_TRANSFORM, m_PrevTransform); - READ_MICRO_CHUNK (cload, VARID_IS_CULLED, m_IsCulled); - READ_MICRO_CHUNK (cload, VARID_IS_DIRTY, m_bDirty); - READ_MICRO_CHUNK (cload, VARID_DROP_OFF, m_DropOffRadius); - READ_MICRO_CHUNK (cload, VARID_START_OFFSET, m_StartOffset); - READ_MICRO_CHUNK (cload, VARID_PITCH_FACTOR, m_PitchFactor); - READ_MICRO_CHUNK (cload, VARID_LISTENER_TRANSFORM, m_ListenerTransform); - - READ_MICRO_CHUNK_WWSTRING (cload, VARID_FILENAME, filename); - - case VARID_THIS_PTR: - { - AudibleSoundClass *old_ptr = nullptr; - cload.Read(&old_ptr, sizeof (old_ptr)); - SaveLoadSystemClass::Register_Pointer (old_ptr, this); - } - break; - } - - cload.Close_Micro_Chunk (); - } - } - break; - } - - cload.Close_Chunk (); - } - - // - // Reconstruct the sound buffer we had before we saved - // - if (!filename.Is_Empty()) { - bool is_3d = (As_Sound3DClass () != nullptr); - SoundBufferClass *buffer = WWAudioClass::Get_Instance ()->Get_Sound_Buffer (filename, is_3d); - Set_Buffer (buffer); - REF_PTR_RELEASE (buffer); - } - - return true; -} diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h index 36205805613..30ad8fd13c5 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h @@ -48,7 +48,6 @@ #include "SoundSceneObj.h" #include "WWLib/Vector.h" #include "WWLib/wwstring.h" -#include "WWSaveLoad/definition.h" ///////////////////////////////////////////////////////////////////////////////// @@ -57,7 +56,6 @@ class SoundBufferClass; class RenderObjClass; class LogicalSoundClass; -class AudibleSoundDefinitionClass; class Sound3DClass; class SoundPseudo3DClass; class FilteredSoundClass; @@ -270,12 +268,6 @@ class AudibleSoundClass : public SoundSceneObjClass virtual void Set_Dirty (bool dirty = true) { m_bDirty = dirty; } virtual bool Is_Dirty () const { return m_bDirty; } - ////////////////////////////////////////////////////////////////////// - // Definition managmenent - ////////////////////////////////////////////////////////////////////// - virtual void Set_Definition (AudibleSoundDefinitionClass *def) { m_Definition = def; } - virtual AudibleSoundDefinitionClass * Get_Definition () { return m_Definition; } - ////////////////////////////////////////////////////////////////////// // Conversion methods ////////////////////////////////////////////////////////////////////// @@ -284,13 +276,6 @@ class AudibleSoundClass : public SoundSceneObjClass virtual void Convert_To_Filtered (); virtual AudibleSoundClass *As_Converted_Format (); - ////////////////////////////////////////////////////////////////////// - // From PersistClass - ////////////////////////////////////////////////////////////////////// - virtual const PersistFactoryClass & Get_Factory () const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - protected: ////////////////////////////////////////////////////////////////////// @@ -361,96 +346,6 @@ class AudibleSoundClass : public SoundSceneObjClass // Conversion data AudibleSoundClass * m_pConvertedFormat; - // Definition pointer - AudibleSoundDefinitionClass * m_Definition; - // Logical sound information LogicalSoundClass * m_LogicalSound; }; - - -////////////////////////////////////////////////////////////////////////////////// -// -// AudibleSoundDefinitionClass -// -////////////////////////////////////////////////////////////////////////////////// -class AudibleSoundDefinitionClass : public DefinitionClass -{ - -public: - - ///////////////////////////////////////////////////////////////////// - // Editable interface requirements - ///////////////////////////////////////////////////////////////////// - DECLARE_EDITABLE(AudibleSoundDefinitionClass, DefinitionClass); - - ////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////// - AudibleSoundDefinitionClass (); - virtual ~AudibleSoundDefinitionClass () override { } - - // From DefinitionClass - virtual uint32 Get_Class_ID () const override; - - // From PersistClass - virtual const PersistFactoryClass & Get_Factory () const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual PersistClass * Create () const override; - virtual AudibleSoundClass * Create_Sound (int classid_hint) const; - - // Initialization - virtual void Initialize_From_Sound (AudibleSoundClass *sound); - - // Accessors - virtual const StringClass & Get_Filename () const { return m_Filename; } - virtual const StringClass & Get_Display_Text () const { return m_DisplayText; } - virtual float Get_Max_Vol_Radius () const { return m_MaxVolRadius; } - virtual float Get_DropOff_Radius () const { return m_DropOffRadius; } - virtual const Vector3 & Get_Sphere_Color () const { return m_AttenuationSphereColor; } - virtual float Get_Volume () const { return m_Volume; } - virtual float Get_Start_Offset () const { return m_StartOffset; } - virtual float Get_Pitch_Factor () const { return m_PitchFactor; } - - virtual void Set_Volume (float volume) { m_Volume = volume; } - virtual void Set_Max_Vol_Radius (float radius){ m_MaxVolRadius = radius; } - virtual void Set_DropOff_Radius (float radius){ m_DropOffRadius = radius; } - virtual void Set_Start_Offset (float offset) { m_StartOffset = offset; } - virtual void Set_Pitch_Factor (float factor) { m_PitchFactor = factor; } - - // Logical sound creation - virtual LogicalSoundClass * Create_Logical (); - -protected: - - ///////////////////////////////////////////////////////////////////// - // Private methods - ///////////////////////////////////////////////////////////////////// - bool Save_Variables (ChunkSaveClass &csave); - bool Load_Variables (ChunkLoadClass &cload); - - ////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////// - float m_Priority; - float m_Volume; - float m_Pan; - int m_LoopCount; - float m_DropOffRadius; - float m_MaxVolRadius; - bool m_Is3D; - StringClass m_Filename; - int m_Type; - StringClass m_DisplayText; - float m_StartOffset; - float m_PitchFactor; - - int m_LogicalTypeMask; - float m_LogicalNotifyDelay; - float m_LogicalDropOffRadius; - bool m_CreateLogical; - - // Misc UI info - Vector3 m_AttenuationSphereColor; -}; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp b/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp deleted file mode 100644 index e5d5375f109..00000000000 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : LevelEdit * - * * - * $Archive:: /Commando/Code/WWAudio/AudioSaveLoad.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 8/14/01 11:46a $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "WWLib/always.h" -#include "AudioSaveLoad.h" -#include "WWSaveLoad/persist.h" -#include "WWSaveLoad/persistfactory.h" -#include "WWSaveLoad/definition.h" -#include "SoundChunkIDs.h" -#include "WWLib/chunkio.h" -#include "SoundScene.h" -#include "WWDebug/wwmemlog.h" - - -/////////////////////////////////////////////////////////////////////// -// Global singleton instance -/////////////////////////////////////////////////////////////////////// -StaticAudioSaveLoadClass _StaticAudioSaveLoadSubsystem; -DynamicAudioSaveLoadClass _DynamicAudioSaveLoadSubsystem; - - -/////////////////////////////////////////////////////////////////////// -// Constants -/////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_STATIC_SCENE = 0x10291220, - CHUNKID_DYNAMIC_SCENE, - CHUNKID_DYNAMIC_VARIABLES -}; - - -enum -{ - VARID_INCLUDE_FILE = 0x01, - VARID_CAMERA_TM, - VARID_BACK_COLOR, - VARID_LOGICAL_LISTENER_GLOBAL_SCALE -}; - - -/////////////////////////////////////////////////////////////////////// -// -// Chunk_ID -// -/////////////////////////////////////////////////////////////////////// -uint32 -StaticAudioSaveLoadClass::Chunk_ID () const -{ - return CHUNKID_STATIC_SAVELOAD; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Contains_Data -// -/////////////////////////////////////////////////////////////////////// -bool -StaticAudioSaveLoadClass::Contains_Data () const -{ - return true; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Save -// -/////////////////////////////////////////////////////////////////////// -bool -StaticAudioSaveLoadClass::Save (ChunkSaveClass &csave) -{ - WWMEMLOG(MEM_SOUND); - - bool retval = true; - - // - // Save the static sounds - // - SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != nullptr) { - csave.Begin_Chunk (CHUNKID_STATIC_SCENE); - scene->Save_Static (csave); - csave.End_Chunk (); - } - - return retval; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Load -// -/////////////////////////////////////////////////////////////////////// -bool -StaticAudioSaveLoadClass::Load (ChunkLoadClass &cload) -{ - WWMEMLOG(MEM_SOUND); - - bool retval = true; - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - // - // Load the static scene information - // - case CHUNKID_STATIC_SCENE: - { - SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != nullptr) { - scene->Load_Static (cload); - } - } - break; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -//*******************************************************************// -//* -//* Start of DynamicAudioSaveLoadClass -//* -//*******************************************************************// - - - -/////////////////////////////////////////////////////////////////////// -// -// Chunk_ID -// -/////////////////////////////////////////////////////////////////////// -uint32 -DynamicAudioSaveLoadClass::Chunk_ID () const -{ - return CHUNKID_DYNAMIC_SAVELOAD; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Contains_Data -// -/////////////////////////////////////////////////////////////////////// -bool -DynamicAudioSaveLoadClass::Contains_Data () const -{ - return true; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Save -// -/////////////////////////////////////////////////////////////////////// -bool -DynamicAudioSaveLoadClass::Save (ChunkSaveClass &csave) -{ - bool retval = true; - - // - // Save the static sounds - // - SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != nullptr) { - - csave.Begin_Chunk (CHUNKID_DYNAMIC_VARIABLES); - float global_scale = LogicalListenerClass::Get_Global_Scale (); - WRITE_MICRO_CHUNK (csave, VARID_LOGICAL_LISTENER_GLOBAL_SCALE, global_scale); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_DYNAMIC_SCENE); - scene->Save_Dynamic (csave); - csave.End_Chunk (); - } - - return retval; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Load -// -/////////////////////////////////////////////////////////////////////// -bool -DynamicAudioSaveLoadClass::Load (ChunkLoadClass &cload) -{ - bool retval = true; - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_DYNAMIC_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - // - // Load the global scale for logical listeners - // - case VARID_LOGICAL_LISTENER_GLOBAL_SCALE: - { - float global_scale = 1.0F; - LOAD_MICRO_CHUNK (cload, global_scale); - LogicalListenerClass::Set_Global_Scale (global_scale); - break; - } - } - - cload.Close_Micro_Chunk (); - } - } - break; - - // - // Load the static scene information - // - case CHUNKID_DYNAMIC_SCENE: - { - SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != nullptr) { - scene->Load_Dynamic (cload); - } - } - break; - } - - cload.Close_Chunk (); - } - - return retval; -} diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h b/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h deleted file mode 100644 index 04a8cc416f1..00000000000 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : LevelEdit * - * * - * $Archive:: /Commando/Code/WWAudio/AudioSaveLoad.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 6/12/00 4:29p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWSaveLoad/saveloadsubsystem.h" -#include "WWLib/Vector.h" -#include "WWLib/bittype.h" - - -// Singleton instances -extern class StaticAudioSaveLoadClass _StaticAudioSaveLoadSubsystem; -extern class DynamicAudioSaveLoadClass _DynamicAudioSaveLoadSubsystem; - - -////////////////////////////////////////////////////////////////////////// -// -// StaticAudioSaveLoadClass -// -////////////////////////////////////////////////////////////////////////// -class StaticAudioSaveLoadClass : public SaveLoadSubSystemClass -{ -public: - - ////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////// - StaticAudioSaveLoadClass () { } - virtual ~StaticAudioSaveLoadClass () override { } - - ////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////// - - // From SaveLoadSubSystemClass - virtual uint32 Chunk_ID () const override; - -protected: - - ////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////// - virtual bool Contains_Data() const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual const char* Name() const override { return "StaticAudioSaveLoadClass"; } -}; - - -////////////////////////////////////////////////////////////////////////// -// -// DynamicAudioSaveLoadClass -// -////////////////////////////////////////////////////////////////////////// -class DynamicAudioSaveLoadClass : public SaveLoadSubSystemClass -{ -public: - - ////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////// - DynamicAudioSaveLoadClass () { } - virtual ~DynamicAudioSaveLoadClass () override { } - - ////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////// - - // From SaveLoadSubSystemClass - virtual uint32 Chunk_ID () const override; - -protected: - - ////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////// - virtual bool Contains_Data() const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual const char* Name() const override { return "DynamicAudioSaveLoadClass"; } - - //bool Save_Micro_Chunks (ChunkSaveClass &csave); - //bool Load_Micro_Chunks (ChunkLoadClass &cload); -}; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWAudio/CMakeLists.txt index 2ecd5adbdb2..c2933db7d28 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWAudio/CMakeLists.txt @@ -1,10 +1,7 @@ set(WWAUDIO_SRC - AABTreeSoundCullClass.h AudibleSound.cpp AudibleSound.h AudioEvents.h - AudioSaveLoad.cpp - AudioSaveLoad.h FilteredSound.cpp FilteredSound.h Listener.cpp @@ -24,7 +21,6 @@ set(WWAUDIO_SRC sound3dhandle.h SoundBuffer.cpp SoundBuffer.h - SoundChunkIDs.h SoundCullObj.h soundhandle.cpp soundhandle.h diff --git a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp index 912620df148..578dd8e2c51 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp @@ -38,19 +38,9 @@ #include "FilteredSound.h" #include "WWAudio.h" #include "SoundScene.h" -#include "SoundChunkIDs.h" -#include "WWSaveLoad/persistfactory.h" #include "soundhandle.h" -////////////////////////////////////////////////////////////////////////////////// -// -// Static factories -// -////////////////////////////////////////////////////////////////////////////////// -SimplePersistFactoryClass _FilteredSoundPersistFactory; - - ///////////////////////////////////////////////////////////////////////////////// // // FilteredSoundClass @@ -164,15 +154,3 @@ FilteredSoundClass::Update_Volume () } } - -///////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -///////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -FilteredSoundClass::Get_Factory () const -{ - return _FilteredSoundPersistFactory; -} - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h index 9bf3eb283a4..a1711b54a5e 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h @@ -77,9 +77,6 @@ class FilteredSoundClass : public SoundPseudo3DClass ////////////////////////////////////////////////////////////////////// virtual void Update_Volume () override; - // From PersistClass - virtual const PersistFactoryClass & Get_Factory () const override; - protected: ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp index eace51dfbb1..5bc37b3af92 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp @@ -35,8 +35,6 @@ #include "LogicalListener.h" #include "WWAudio.h" #include "SoundScene.h" -#include "SoundChunkIDs.h" -#include "WWSaveLoad/persistfactory.h" ////////////////////////////////////////////////////////////////////////////////// @@ -47,31 +45,6 @@ uint32 LogicalListenerClass::m_NewestTimestamp = 1; float LogicalListenerClass::m_GlobalScale = 1.0F; -////////////////////////////////////////////////////////////////////////////////// -// Static factories -////////////////////////////////////////////////////////////////////////////////// -SimplePersistFactoryClass _LogicalListenerPersistFactory; - - -////////////////////////////////////////////////////////////////////////////////// -// Save/Load constants -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_VARIABLES = 0x03270542, - CHUNKID_BASE_CLASS -}; - -enum -{ - XXXVARID_DROP_OFF_RADIUS = 0x01, - VARID_TYPE_MASK, - VARID_XXX1, - VARID_POSITION, - VARID_SCALE -}; - - //////////////////////////////////////////////////////////////////////////////////////////////// // // LogicalListenerClass @@ -135,79 +108,3 @@ LogicalListenerClass::Remove_From_Scene () } } - -///////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -///////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -LogicalListenerClass::Get_Factory () const -{ - return _LogicalListenerPersistFactory; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -LogicalListenerClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - SoundSceneObjClass::Save (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_VARIABLES); - - WRITE_MICRO_CHUNK (csave, VARID_SCALE, m_Scale); - WRITE_MICRO_CHUNK (csave, VARID_TYPE_MASK, m_TypeMask); - WRITE_MICRO_CHUNK (csave, VARID_POSITION, m_Position); - - csave.End_Chunk (); - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -LogicalListenerClass::Load (ChunkLoadClass &cload) -{ - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_BASE_CLASS: - PersistClass::Load (cload); - break; - - case CHUNKID_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_SCALE, m_Scale); - READ_MICRO_CHUNK (cload, VARID_TYPE_MASK, m_TypeMask); - READ_MICRO_CHUNK (cload, VARID_POSITION, m_Position); - } - - cload.Close_Micro_Chunk (); - } - } - break; - } - - cload.Close_Chunk (); - } - - return true; -} - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h index 875b87a7020..e328b632933 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h @@ -103,14 +103,6 @@ class LogicalListenerClass : public SoundSceneObjClass virtual void Set_DropOff_Radius (float radius = 1) override {} virtual float Get_DropOff_Radius () const override { return 1.0F; } - ////////////////////////////////////////////////////////////////////// - // From PersistClass - ////////////////////////////////////////////////////////////////////// - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual const PersistFactoryClass & Get_Factory () const override; - - ////////////////////////////////////////////////////////////////////// // Timestamp ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp index 00894d97b17..264075f5765 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp @@ -33,36 +33,6 @@ #include "LogicalSound.h" #include "WWAudio.h" #include "SoundScene.h" -#include "SoundChunkIDs.h" -#include "WWSaveLoad/persistfactory.h" - - -////////////////////////////////////////////////////////////////////////////////// -// Static factories -////////////////////////////////////////////////////////////////////////////////// -SimplePersistFactoryClass _LogicalSoundPersistFactory; - - -////////////////////////////////////////////////////////////////////////////////// -// Save/Load constants -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_VARIABLES = 0x03270459, - CHUNKID_BASE_CLASS -}; - -enum -{ - VARID_DROP_OFF_RADIUS = 0x01, - VARID_IS_SINGLE_SHOT, - VARID_TYPE_MASK, - VARID_XXX1, - VARID_POSITION, - VARID_MAX_LISTENERS, - VARID_NOTIFY_DELAY, - VARID_LAST_NOTIFY, -}; //////////////////////////////////////////////////////////////////////////////////////////////// @@ -168,87 +138,3 @@ LogicalSoundClass::On_Frame_Update (unsigned int milliseconds) return SoundSceneObjClass::On_Frame_Update (milliseconds); } - -///////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -///////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -LogicalSoundClass::Get_Factory () const -{ - return _LogicalSoundPersistFactory; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -LogicalSoundClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - SoundSceneObjClass::Save (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_VARIABLES); - - WRITE_MICRO_CHUNK (csave, VARID_DROP_OFF_RADIUS, m_DropOffRadius); - WRITE_MICRO_CHUNK (csave, VARID_IS_SINGLE_SHOT, m_IsSingleShot); - WRITE_MICRO_CHUNK (csave, VARID_TYPE_MASK, m_TypeMask); - WRITE_MICRO_CHUNK (csave, VARID_POSITION, m_Position); - WRITE_MICRO_CHUNK (csave, VARID_MAX_LISTENERS, m_MaxListeners); - WRITE_MICRO_CHUNK (csave, VARID_NOTIFY_DELAY, m_NotifyDelayInMS); - WRITE_MICRO_CHUNK (csave, VARID_LAST_NOTIFY, m_LastNotification); - - csave.End_Chunk (); - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -LogicalSoundClass::Load (ChunkLoadClass &cload) -{ - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_BASE_CLASS: - PersistClass::Load (cload); - break; - - case CHUNKID_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_DROP_OFF_RADIUS, m_DropOffRadius); - READ_MICRO_CHUNK (cload, VARID_IS_SINGLE_SHOT, m_IsSingleShot); - READ_MICRO_CHUNK (cload, VARID_TYPE_MASK, m_TypeMask); - READ_MICRO_CHUNK (cload, VARID_POSITION, m_Position); - READ_MICRO_CHUNK (cload, VARID_MAX_LISTENERS, m_MaxListeners); - READ_MICRO_CHUNK (cload, VARID_NOTIFY_DELAY, m_NotifyDelayInMS); - READ_MICRO_CHUNK (cload, VARID_LAST_NOTIFY, m_LastNotification); - } - - cload.Close_Micro_Chunk (); - } - } - break; - } - - cload.Close_Chunk (); - } - - return true; -} - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h index 5eb7b013db3..b6549e60d33 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h @@ -115,13 +115,6 @@ class LogicalSoundClass : public SoundSceneObjClass virtual void Set_DropOff_Radius (float radius = 1) override { m_DropOffRadius = radius; } virtual float Get_DropOff_Radius () const override { return m_DropOffRadius; } - ////////////////////////////////////////////////////////////////////// - // From PersistClass - ////////////////////////////////////////////////////////////////////// - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual const PersistFactoryClass & Get_Factory () const override; - protected: ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp index b73658dd1f6..64744c350c7 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp @@ -40,38 +40,9 @@ #include "WWAudio.h" #include "SoundScene.h" #include "Utils.h" -#include "SoundChunkIDs.h" -#include "WWSaveLoad/persistfactory.h" -#include "WWLib/chunkio.h" #include "sound3dhandle.h" -////////////////////////////////////////////////////////////////////////////////// -// -// Static factories -// -////////////////////////////////////////////////////////////////////////////////// -SimplePersistFactoryClass _Sound3DPersistFactory; - - -enum -{ - CHUNKID_VARIABLES = 0x11090955, - CHUNKID_BASE_CLASS -}; - -enum -{ - VARID_AUTO_CALC_VEL = 0x01, - VARID_CURR_VEL, - VARID_XXX1, - VARID_XXX2, - VARID_MAX_VOL_RADIUS, - VARID_IS_STATIC, -}; - - - //////////////////////////////////////////////////////////////////////////////////////////////// // // Sound3DClass @@ -596,86 +567,6 @@ Sound3DClass::On_Loop_End () AudibleSoundClass::On_Loop_End (); } -///////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -///////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -Sound3DClass::Get_Factory () const -{ - return _Sound3DPersistFactory; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -Sound3DClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - AudibleSoundClass::Save (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_VARIABLES); - - WRITE_MICRO_CHUNK (csave, VARID_AUTO_CALC_VEL, m_bAutoCalcVel); - WRITE_MICRO_CHUNK (csave, VARID_CURR_VEL, m_CurrentVelocity); - - WRITE_MICRO_CHUNK (csave, VARID_MAX_VOL_RADIUS, m_MaxVolRadius); - WRITE_MICRO_CHUNK (csave, VARID_IS_STATIC, m_IsStatic); - - csave.End_Chunk (); - - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -Sound3DClass::Load (ChunkLoadClass &cload) -{ - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_BASE_CLASS: - AudibleSoundClass::Load (cload); - break; - - case CHUNKID_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_AUTO_CALC_VEL, m_bAutoCalcVel); - READ_MICRO_CHUNK (cload, VARID_CURR_VEL, m_CurrentVelocity); - READ_MICRO_CHUNK (cload, VARID_MAX_VOL_RADIUS, m_MaxVolRadius); - READ_MICRO_CHUNK (cload, VARID_IS_STATIC, m_IsStatic); - } - - cload.Close_Micro_Chunk (); - } - } - break; - } - - cload.Close_Chunk (); - } - - return true; -} - - //////////////////////////////////////////////////////////////////////////////////////////////// // // Set_Miles_Handle diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h index 1891c2e8570..df7fab63775 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h @@ -147,15 +147,6 @@ class Sound3DClass : public AudibleSoundClass virtual void Set_DropOff_Radius (float radius = 1) override; virtual float Get_DropOff_Radius () const override {return(m_DropOffRadius);} - // From PersistClass - virtual const PersistFactoryClass & Get_Factory () const override; - - // - // From PersistClass - // - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - protected: ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h deleted file mode 100644 index 5437f2f1135..00000000000 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : LevelEdit * - * * - * $Archive:: /Commando/Code/WWAudio/SoundChunkIDs.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 3/27/00 5:43p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWSaveLoad/saveloadids.h" -#include "WWSaveLoad/definitionclassids.h" - - -////////////////////////////////////////////////////////////////////////////////// -// -// These are the chunk IDs that serve as 'globally-unique' persist identifiers for -// all persist objects inside the editor. These are used when building the -// PersistFactoryClass's for definitions. -// -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_SOUND_DEF = CHUNKID_WWAUDIO_BEGIN, - CHUNKID_AUDIBLE_SOUND, - CHUNKID_FILTERED_SOUND, - CHUNKID_SOUND3D, - CHUNKID_PSEUDO_SOUND3D, - CHUNKID_STATIC_SAVELOAD, - CHUNKID_DYNAMIC_SAVELOAD, - CHUNKID_LOGICALSOUND, - CHUNKID_LOGICALLISTENER -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// These are the globally-unique class identifiers that the definition system -// uses inside the editor. -// -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CLASSID_SOUND_DEF = CLASSID_SOUND, -}; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp index 3805659b907..996a6aee50e 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp @@ -39,17 +39,9 @@ #include "WWAudio.h" #include "SoundScene.h" #include "Utils.h" -#include "SoundChunkIDs.h" -#include "WWSaveLoad/persistfactory.h" #include "soundhandle.h" -////////////////////////////////////////////////////////////////////////////////// -// Static factories -////////////////////////////////////////////////////////////////////////////////// -SimplePersistFactoryClass _PseudoSound3DPersistFactory; - - //////////////////////////////////////////////////////////////////////////////////////////////// // // SoundPseudo3DClass @@ -267,15 +259,3 @@ SoundPseudo3DClass::On_Frame_Update (unsigned int milliseconds) // Allow the base Sound3DClass to process this call return Sound3DClass::On_Frame_Update (milliseconds); } - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -//////////////////////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -SoundPseudo3DClass::Get_Factory () const -{ - return _PseudoSound3DPersistFactory; -} diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h index 3374502241d..97318db090b 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h @@ -126,9 +126,6 @@ class SoundPseudo3DClass : public Sound3DClass ////////////////////////////////////////////////////////////////////// virtual void Update_Pseudo_Pan (); - // From PersistClass - virtual const PersistFactoryClass & Get_Factory () const override; - protected: ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp index 4427f3d7bff..6c139507e64 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp @@ -39,8 +39,6 @@ #include "SoundCullObj.h" #include "LogicalSound.h" #include "LogicalListener.h" -#include "WWLib/chunkio.h" -#include "WWSaveLoad/persistfactory.h" #include "WWDebug/wwprofile.h" #include "Threads.h" #include "WWDebug/wwmemlog.h" @@ -55,23 +53,6 @@ DEFINE_AUTO_POOL(SoundSceneClass::AudibleInfoClass, 64); const int MAX_LOGICAL_LISTENER_UPDATES_PER_FRAME = 4; -////////////////////////////////////////////////////////////////////////////////// -// Save/Load constants -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_VARIABLES = 0x00000100, - CHUNKID_STATIC_SOUNDS, - CHUNKID_DYNAMIC_SOUNDS -}; - -enum -{ - VARID_MIN_DIM = 0x01, - VARID_MAX_DIM, -}; - - //////////////////////////////////////////////////////////////////////////////////////////////// // // SoundSceneClass @@ -1038,160 +1019,6 @@ SoundSceneClass::Is_Logical_Sound_In_Scene } -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Save_Static -// -//////////////////////////////////////////////////////////////////////////////////////////////// -bool -SoundSceneClass::Save_Static (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK (csave, VARID_MIN_DIM, m_MinExtents); - WRITE_MICRO_CHUNK (csave, VARID_MAX_DIM, m_MaxExtents); - csave.End_Chunk (); - - // - // Save the list of static sounds that are currently in the scene - // - csave.Begin_Chunk (CHUNKID_STATIC_SOUNDS); - Save_Static_Sounds (csave); - csave.End_Chunk (); - - return true; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Save_Static_Sounds -// -//////////////////////////////////////////////////////////////////////////////////////////////// -void -SoundSceneClass::Save_Static_Sounds (ChunkSaveClass &csave) -{ - Re_Partition (m_MinExtents, m_MaxExtents); - - // - // Loop over all the static sounds that are in the scene - // and save each to its own chunk. - // - MultiListIterator static_iterator (&m_StaticSounds); - for (static_iterator.First (); !static_iterator.Is_Done (); static_iterator.Next ()) { - SoundCullObjClass *cull_obj = static_iterator.Peek_Obj (); - - // - // Get the sound from its cull object - // - AudibleSoundClass *sound_obj = (AudibleSoundClass *)cull_obj->Peek_Sound_Obj (); - if (sound_obj != nullptr) { - - // - // Have the sound's factory save it - // - csave.Begin_Chunk (sound_obj->Get_Factory ().Chunk_ID ()); - sound_obj->Get_Factory ().Save (csave, sound_obj); - csave.End_Chunk (); - } - } -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Load_Static_Sounds -// -//////////////////////////////////////////////////////////////////////////////////////////////// -void -SoundSceneClass::Load_Static_Sounds (ChunkLoadClass &cload) -{ - while (cload.Open_Chunk ()) { - - // - // Load this sound from the chunk (if possible) - // - PersistFactoryClass *factory = SaveLoadSystemClass::Find_Persist_Factory (cload.Cur_Chunk_ID ()); - if (factory != nullptr) { - AudibleSoundClass *sound_obj = (AudibleSoundClass *)factory->Load (cload); - if (sound_obj != nullptr) { - sound_obj->Add_To_Scene (true); - REF_PTR_RELEASE (sound_obj); - } - } - - cload.Close_Chunk (); - } -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Load_Static -// -//////////////////////////////////////////////////////////////////////////////////////////////// -bool -SoundSceneClass::Load_Static (ChunkLoadClass &cload) -{ - m_IsBatchMode = true; - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_STATIC_SOUNDS: - Load_Static_Sounds (cload); - break; - - case CHUNKID_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - READ_MICRO_CHUNK (cload, VARID_MIN_DIM, m_MinExtents); - READ_MICRO_CHUNK (cload, VARID_MAX_DIM, m_MaxExtents); - } - - cload.Close_Micro_Chunk (); - } - } - break; - } - - cload.Close_Chunk (); - } - - Re_Partition (m_MinExtents, m_MaxExtents); - On_Frame_Update (0); - m_IsBatchMode = false; - return true; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Save_Dynamic -// -//////////////////////////////////////////////////////////////////////////////////////////////// -bool -SoundSceneClass::Save_Dynamic (ChunkSaveClass &csave) -{ - return true; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Load_Dynamic -// -//////////////////////////////////////////////////////////////////////////////////////////////// -bool -SoundSceneClass::Load_Dynamic (ChunkLoadClass &cload) -{ - return true; -} - - //////////////////////////////////////////////////////////////////////////////////////////////// // // Flush_Scene diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h index d25a5a87069..8c21c81e1c5 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h @@ -47,8 +47,6 @@ // Forward declarations class RenderObjClass; -class ChunkSaveClass; -class ChunkLoadClass; ////////////////////////////////////////////////////////////////////////////////// @@ -139,14 +137,6 @@ class SoundSceneClass virtual void Add_Logical_Listener (LogicalListenerClass *listener_obj); virtual void Remove_Logical_Listener (LogicalListenerClass *listener_obj); - ////////////////////////////////////////////////////////////////////// - // Save/Load - ////////////////////////////////////////////////////////////////////// - bool Save_Static (ChunkSaveClass &csave); - bool Load_Static (ChunkLoadClass &cload); - bool Save_Dynamic (ChunkSaveClass &csave); - bool Load_Dynamic (ChunkLoadClass &cload); - bool Is_Batch_Mode () const { return m_IsBatchMode; } void Set_Batch_Mode (bool batch_mode) { m_IsBatchMode = batch_mode; } @@ -165,10 +155,6 @@ class SoundSceneClass virtual bool Is_Logical_Sound_In_Scene (LogicalSoundClass *sound_obj, bool single_shot = false); - // Save/load methods - virtual void Save_Static_Sounds (ChunkSaveClass &csave); - virtual void Load_Static_Sounds (ChunkLoadClass &cload); - ////////////////////////////////////////////////////////////////////// // Collection methods ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp index edd132300f4..563951d87c3 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp @@ -36,30 +36,9 @@ #include "SoundSceneObj.h" #include "WW3D2/camera.h" #include "WW3D2/rendobj.h" -#include "WWSaveLoad/persistfactory.h" -#include "SoundChunkIDs.h" #include "Utils.h" -////////////////////////////////////////////////////////////////////////////////// -// Save/Load constants -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_VARIABLES = 0x03270459, - CHUNKID_BASE_CLASS -}; - -enum -{ - VARID_ATTACHED_OBJ = 0x01, - VARID_ATTACHED_BONE, - VARID_USER_DATA, - VARID_USER_OBJ, - VARID_ID -}; - - ////////////////////////////////////////////////////////////////////////////////// // Static member initialization ////////////////////////////////////////////////////////////////////////////////// @@ -111,8 +90,7 @@ SoundSceneObjClass::SoundSceneObjClass () // //////////////////////////////////////////////////////////////////////////////////////////////// SoundSceneObjClass::SoundSceneObjClass (const SoundSceneObjClass &src) - : PersistClass(static_cast(src)), - m_Scene (src.m_Scene), + : m_Scene (src.m_Scene), m_PhysWrapper (nullptr), m_pCallback (src.m_pCallback), m_AttachedObject (nullptr), @@ -156,7 +134,6 @@ SoundSceneObjClass::operator= (const SoundSceneObjClass &src) Attach_To_Object (src.m_AttachedObject, src.m_AttachedBone); - PersistClass::operator= ((const PersistClass &)src); return (*this); } @@ -249,95 +226,6 @@ SoundSceneObjClass::Apply_Auto_Position () } -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -SoundSceneObjClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - PersistClass::Save (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK (csave, VARID_ATTACHED_OBJ, m_AttachedObject); - WRITE_MICRO_CHUNK (csave, VARID_ATTACHED_BONE, m_AttachedBone); - WRITE_MICRO_CHUNK (csave, VARID_USER_DATA, m_UserData); - WRITE_MICRO_CHUNK (csave, VARID_USER_OBJ, m_UserObj); - WRITE_MICRO_CHUNK (csave, VARID_ID, m_ID); - csave.End_Chunk (); - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -SoundSceneObjClass::Load (ChunkLoadClass &cload) -{ - uint32 id = SOUND_OBJ_DEFAULT_ID; - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_BASE_CLASS: - PersistClass::Load (cload); - break; - - case CHUNKID_VARIABLES: - { - // - // Read all the variables from their micro-chunks - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_ATTACHED_OBJ, m_AttachedObject); - READ_MICRO_CHUNK (cload, VARID_ATTACHED_BONE, m_AttachedBone); - READ_MICRO_CHUNK (cload, VARID_USER_DATA, m_UserData); - READ_MICRO_CHUNK (cload, VARID_USER_OBJ, m_UserObj); - READ_MICRO_CHUNK (cload, VARID_ID, id); - } - - cload.Close_Micro_Chunk (); - } - } - break; - } - - cload.Close_Chunk (); - } - - // - // Set the ID (this will cause the sound object to - // be re-inserted in the master sorted list) - // - if (id != SOUND_OBJ_DEFAULT_ID) { - Set_ID (id); - } - - // - // Max sure the next available ID is the largest ID in existence - // - m_NextAvailableID = max (m_NextAvailableID, m_ID + 1); - - // - // We need to 'swizzle' the attached object pointer. We saved the pointer's - // value, and need to map it (hopefully) to the new value. - // - if (m_AttachedObject != nullptr) { - SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap ((RefCountClass **)&m_AttachedObject); - } - - return true; -} - - ////////////////////////////////////////////////////////////////////////////////// // // On_Frame_Update diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h index a5d6f7d0b0a..9c2f34b13fa 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h @@ -37,7 +37,6 @@ #include "WWLib/always.h" #include "WWAudio.h" #include "WWLib/bittype.h" -#include "WWSaveLoad/persist.h" #include "WWLib/multilist.h" #include "WWLib/mutex.h" @@ -73,7 +72,7 @@ const uint32 SOUND_OBJ_START_ID = 1000000000; // object that will be inserted in the culling system. // ///////////////////////////////////////////////////////////////////////////////// -class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, public RefCountClass +class SoundSceneObjClass : public MultiListObjectClass, public RefCountClass { public: @@ -175,12 +174,6 @@ class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, pub virtual void Set_DropOff_Radius (float radius = 1) = 0; virtual float Get_DropOff_Radius () const = 0; - ////////////////////////////////////////////////////////////////////// - // From PersistClass - ////////////////////////////////////////////////////////////////////// - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - protected: ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp index 828dae58c55..f67028f43d2 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp @@ -52,7 +52,6 @@ #include "Threads.h" #include "LogicalSound.h" #include "LogicalListener.h" -#include "WWSaveLoad/definitionclassids.h" #include "WWDebug/wwmemlog.h" #include "WWDebug/wwprofile.h" #include "MilesLoader.h" @@ -874,225 +873,6 @@ WWAudioClass::Create_3D_Sound } -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -AudibleSoundClass * -WWAudioClass::Create_Sound -( - int definition_id, - RefCountClass *user_obj, - uint32 user_data, - int classid_hint -) -{ - AudibleSoundClass *sound = nullptr; - - // - // Find the definition - // - DefinitionClass *definition = DefinitionMgrClass::Find_Definition (definition_id); - if (definition != nullptr ) { - - // - // Make sure this is really a sound definition - // - WWASSERT (definition->Get_Class_ID () == CLASSID_SOUND); - if (definition->Get_Class_ID () == CLASSID_SOUND) { - AudibleSoundDefinitionClass *sound_def = reinterpret_cast (definition); - - // - // Create an instance of the sound - // - sound = sound_def->Create_Sound (classid_hint); - if (sound != nullptr) { - sound->Set_User_Data (user_obj, user_data); - } - } - } - - return sound; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -AudibleSoundClass * -WWAudioClass::Create_Sound -( - const char * def_name, - RefCountClass *user_obj, - uint32 user_data, - int classid_hint -) -{ - AudibleSoundClass *sound = nullptr; - - // - // Find the definition - // - DefinitionClass *definition = DefinitionMgrClass::Find_Typed_Definition (def_name, CLASSID_SOUND, true); - if (definition != nullptr ) { - - // - // Make sure this is really a sound definition - // - WWASSERT (definition->Get_Class_ID () == CLASSID_SOUND); - if (definition->Get_Class_ID () == CLASSID_SOUND) { - AudibleSoundDefinitionClass *sound_def = reinterpret_cast (definition); - - // - // Create an instance of the sound - // - sound = sound_def->Create_Sound (classid_hint); - if (sound != nullptr) { - sound->Set_User_Data (user_obj, user_data); - } - } - } - - return sound; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Continuous_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -AudibleSoundClass * -WWAudioClass::Create_Continuous_Sound -( - int definition_id, - RefCountClass *user_obj, - uint32 user_data, - int classid_hint -) -{ - // - // Create an instance of the sound and play it - // - AudibleSoundClass *sound = Create_Sound (definition_id, user_obj, user_data, classid_hint); - if (sound != nullptr) { - - if (sound->Get_Loop_Count () != INFINITE_LOOPS) { - WWDEBUG_SAY (("Audio Error: Creating a continuous sound with a finite loop count!")); - } - } - - return sound; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Instant_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -int -WWAudioClass::Create_Instant_Sound -( - int definition_id, - const Matrix3D & tm, - RefCountClass * user_obj, - uint32 user_data, - int classid_hint -) -{ - int sound_id = 0; - - // - // Create an instance of the sound and play it - // - AudibleSoundClass *sound = Create_Sound (definition_id, user_obj, user_data, classid_hint); - if (sound != nullptr) { - - if (sound->Get_Loop_Count () == INFINITE_LOOPS) { - WWDEBUG_SAY (("Audio Error: Creating an instant sound %s with an infinite loop count!",sound->Get_Definition()->Get_Name())); - } - - sound_id = sound->Get_ID (); - sound->Set_Transform (tm); - sound->Add_To_Scene (); - sound->Release_Ref (); - } - - return sound_id; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Continuous_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -AudibleSoundClass * -WWAudioClass::Create_Continuous_Sound -( - const char * def_name, - RefCountClass *user_obj, - uint32 user_data, - int classid_hint -) -{ - // - // Create an instance of the sound and play it - // - AudibleSoundClass *sound = Create_Sound (def_name, user_obj, user_data, classid_hint); - if (sound != nullptr) { - - if (sound->Get_Loop_Count () != INFINITE_LOOPS) { - WWDEBUG_SAY (("Audio Error: Creating a continuous sound with a finite loop count!")); - } - - } - - return sound; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Instant_Sound -// -//////////////////////////////////////////////////////////////////////////////////////////////// -int -WWAudioClass::Create_Instant_Sound -( - const char * def_name, - const Matrix3D & tm, - RefCountClass * user_obj, - uint32 user_data, - int classid_hint -) -{ - int sound_id = 0; - - // - // Create an instance of the sound and play it - // - AudibleSoundClass *sound = Create_Sound (def_name, user_obj, user_data, classid_hint); - if (sound != nullptr) { - - if (sound->Get_Loop_Count () == INFINITE_LOOPS) { - WWDEBUG_SAY (("Audio Error: Creating an instant sound %s with an infinite loop count!",sound->Get_Definition()->Get_Name())); - } - - sound_id = sound->Get_ID (); - sound->Set_Transform (tm); - sound->Add_To_Scene (); - sound->Release_Ref (); - } - - return sound_id; -} - - //////////////////////////////////////////////////////////////////////////////////////////////// // // Flush_Playlist diff --git a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h index 52f544f5d65..62bd53f2139 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h @@ -349,20 +349,6 @@ class WWAudioClass int Get_Logical_Type_Count () const { return m_LogicalTypes.Count (); } int Get_Logical_Type (int index, StringClass &name); - ////////////////////////////////////////////////////////////////////// - // Definition related methods - ////////////////////////////////////////////////////////////////////// - - // - // Sound creation methods - // - int Create_Instant_Sound (int definition_id, const Matrix3D &tm, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); - int Create_Instant_Sound (const char *def_name, const Matrix3D &tm, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Continuous_Sound (int definition_id, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Continuous_Sound (const char *def_name, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Sound (int definition_id, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Sound (const char *def_name, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); - ////////////////////////////////////////////////////////////////////// // Sound object lookup ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt index fb1c164f7b0..5a21ef6d348 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt @@ -77,7 +77,6 @@ set(WWMATH_SRC vp.h wwmath.cpp wwmath.h - wwmathids.h ) add_library(core_wwmath STATIC) @@ -88,7 +87,6 @@ target_sources(core_wwmath PRIVATE ${WWMATH_SRC}) target_link_libraries(core_wwmath PRIVATE core_wwcommon corei_always - core_wwsaveload ) target_link_libraries(core_wwmath PUBLIC diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp index b0af47534dd..7dab424a96b 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp @@ -36,8 +36,6 @@ #include "aabtreecull.h" -#include "WWLib/chunkio.h" -#include "WWLib/iostruct.h" #include "sphere.h" #include "colmath.h" #include "colmathinlines.h" @@ -51,45 +49,6 @@ DEFINE_AUTO_POOL(AABTreeLinkClass,256); DEFINE_AUTO_POOL(AABTreeNodeClass,256); -/* -** Current version of the file format -*/ -const uint32 AABTREE_CURRENT_VERSION = 0x00010000; - - -/* -** Chunk Id's used by the aabtree code to save itself into a file -*/ -enum -{ - AABTREE_CHUNK_VERSION = 0x00000001, // version wrapper, contains 32bit version # - AABTREE_CHUNK_AABNODE = 0x00000101, // generic aab-node wrapper - AABTREE_CHUNK_AABNODE_INFO, // OBSOLETE! generic aab-node definition (IOAABNodeStruct) - AABTREE_CHUNK_AABNODE_CONTENTS, // wrapper around contents of the node - AABTREE_CHUNK_AABNODE_VARIABLES, // wrapper around variables for a node - - AABTREE_CHUNK_NODE_INDEX = 0x00000200, // wrapper around the node index for an object - - AABTREE_VARIABLE_NODESTRUCT = 0x00, - AABTREE_VARIABLE_USERDATA -}; - - -/* -** IOAABNodeStruct -** Data structure for the contents of a node in the AAB-Tree -*/ -#define AABNODE_ATTRIBUTE_FRONT_CHILD 0x00000001 -#define AABNODE_ATTRIBUTE_BACK_CHILD 0x00000002 - -struct IOAABNodeStruct -{ - IOVector3Struct Center; - IOVector3Struct Extent; - uint32 Attributes; -}; - - /************************************************************************* ** ** Utility functions for walking the object list in an AABTree Node @@ -693,192 +652,6 @@ void AABTreeCullSystemClass::Update_Bounding_Boxes_Recursive(AABTreeNodeClass * } -void AABTreeCullSystemClass::Load(ChunkLoadClass & cload) -{ - WWASSERT_PRINT(Object_Count() == 0, "Remove all objects from AAB-Culling system before loading!"); - - delete RootNode; - RootNode = new AABTreeNodeClass; - - // The first chunk should be a version chunk - cload.Open_Chunk(); - if (cload.Cur_Chunk_ID() != AABTREE_CHUNK_VERSION) { - WWDEBUG_SAY(("Attempting to read an obsolete AAB-Tree!")); - cload.Close_Chunk(); - return; - } - - // read in the version and verify that it is the current version - uint32 version; - cload.Read(&version,sizeof(version)); - if (version != AABTREE_CURRENT_VERSION) { - WWDEBUG_SAY(("Attempting to read an obsolete AAB-Tree!")); - cload.Close_Chunk(); - return; - } - cload.Close_Chunk(); - - // read in the tree - Load_Nodes(RootNode,cload); - - // re-index all nodes - Re_Index_Nodes(); - - // reset the statistics - Reset_Statistics(); -} - -void AABTreeCullSystemClass::Load_Nodes(AABTreeNodeClass * node,ChunkLoadClass & cload) -{ - // Open the node description - cload.Open_Chunk(); - WWASSERT(cload.Cur_Chunk_ID() == AABTREE_CHUNK_AABNODE); - - // Load the node description. - // Older files will contain a chunk named AABTREE_CHUNK_AABNODE_INFO while newer - // files will contain AABTREE_CHUNK_AABNODE_VARIABLES which contains the IOAABNodeStruct - // in a micro-chunk. - IOAABNodeStruct node_desc; - memset(&node_desc,0,sizeof(IOAABNodeStruct)); - - cload.Open_Chunk(); - if (cload.Cur_Chunk_ID() == AABTREE_CHUNK_AABNODE_INFO) { - - // Loading the legacy format... - WWASSERT(cload.Cur_Chunk_ID() == AABTREE_CHUNK_AABNODE_INFO); - cload.Read(&node_desc,sizeof(node_desc)); - - } else if (cload.Cur_Chunk_ID() == AABTREE_CHUNK_AABNODE_VARIABLES) { - - // Loading the new format, contains micro chunks... - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,AABTREE_VARIABLE_NODESTRUCT,node_desc); - READ_MICRO_CHUNK(cload,AABTREE_VARIABLE_USERDATA,node->UserData); - } - cload.Close_Micro_Chunk(); - } - } - cload.Close_Chunk(); - - // Initialize the node bounds. - node->Box.Center.X = node_desc.Center.X; - node->Box.Center.Y = node_desc.Center.Y; - node->Box.Center.Z = node_desc.Center.Z; - - node->Box.Extent.X = node_desc.Extent.X; - node->Box.Extent.Y = node_desc.Extent.Y; - node->Box.Extent.Z = node_desc.Extent.Z; - - // Load the contents of the node. - cload.Open_Chunk(); - WWASSERT(cload.Cur_Chunk_ID() == AABTREE_CHUNK_AABNODE_CONTENTS); - Load_Node_Contents(node,cload); - cload.Close_Chunk(); - - // Close the node description - cload.Close_Chunk(); - - // if we are supposed to have a front child, load it - if (node_desc.Attributes & AABNODE_ATTRIBUTE_FRONT_CHILD) { - WWASSERT(node->Front == nullptr); - node->Front = new AABTreeNodeClass(); - node->Front->Parent = node; - Load_Nodes(node->Front,cload); - } - - // if we have a back child, load it - if (node_desc.Attributes & AABNODE_ATTRIBUTE_BACK_CHILD) { - WWASSERT(node->Back == nullptr); - node->Back = new AABTreeNodeClass(); - node->Back->Parent = node; - Load_Nodes(node->Back,cload); - } -} - -void AABTreeCullSystemClass::Save(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(AABTREE_CHUNK_VERSION); - uint32 version = AABTREE_CURRENT_VERSION; - csave.Write(&version,sizeof(uint32)); - csave.End_Chunk(); - - Save_Nodes(RootNode,csave); -} - -void AABTreeCullSystemClass::Save_Nodes(AABTreeNodeClass * node,ChunkSaveClass & csave) -{ - WWASSERT(node); - csave.Begin_Chunk(AABTREE_CHUNK_AABNODE); - - csave.Begin_Chunk(AABTREE_CHUNK_AABNODE_VARIABLES); - IOAABNodeStruct node_desc; - memset(&node_desc,0,sizeof(node_desc)); - - node_desc.Center.X = node->Box.Center.X; - node_desc.Center.Y = node->Box.Center.Y; - node_desc.Center.Z = node->Box.Center.Z; - - node_desc.Extent.X = node->Box.Extent.X; - node_desc.Extent.Y = node->Box.Extent.Y; - node_desc.Extent.Z = node->Box.Extent.Z; - - if (node->Front) { - node_desc.Attributes |= AABNODE_ATTRIBUTE_FRONT_CHILD; - } - - if (node->Back) { - node_desc.Attributes |= AABNODE_ATTRIBUTE_BACK_CHILD; - } - - WRITE_MICRO_CHUNK(csave,AABTREE_VARIABLE_NODESTRUCT,node_desc); - WRITE_MICRO_CHUNK(csave,AABTREE_VARIABLE_USERDATA,node->UserData); - csave.End_Chunk(); - - csave.Begin_Chunk(AABTREE_CHUNK_AABNODE_CONTENTS); - Save_Node_Contents(node,csave); - csave.End_Chunk(); - - csave.End_Chunk(); - - if (node->Front) { - Save_Nodes(node->Front,csave); - } - - if (node->Back) { - Save_Nodes(node->Back,csave); - } -} - -void AABTreeCullSystemClass::Load_Object_Linkage(ChunkLoadClass & cload,CullableClass * obj) -{ - uint32 index; - cload.Open_Chunk(); - WWASSERT(cload.Cur_Chunk_ID() == AABTREE_CHUNK_NODE_INDEX); - cload.Read(&index,sizeof(index)); - cload.Close_Chunk(); - - Add_Object_Internal(obj,index); -} - -void AABTreeCullSystemClass::Save_Object_Linkage(ChunkSaveClass & csave,CullableClass * obj) -{ - WWASSERT(obj); - WWASSERT(obj->Get_Culling_System() == this); - - AABTreeLinkClass * link = (AABTreeLinkClass *)obj->Get_Cull_Link(); - WWASSERT(link); - - AABTreeNodeClass * node = link->Node; - WWASSERT(node); - - uint32 index = node->Index; - csave.Begin_Chunk(AABTREE_CHUNK_NODE_INDEX); - csave.Write(&index,sizeof(index)); - csave.End_Chunk(); -} - - void AABTreeCullSystemClass::Re_Index_Nodes() { delete[] IndexedNodes; diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h index c190799d0a0..7c5d09bb127 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h +++ b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h @@ -45,8 +45,6 @@ #include class AABTreeNodeClass; -class ChunkLoadClass; -class ChunkSaveClass; class SphereClass; /** @@ -100,18 +98,6 @@ class AABTreeCullSystemClass : public CullSystemClass virtual void Collect_Objects(const FrustumClass & frustum) override; virtual void Collect_Objects(const SphereClass & sphere); - /* - ** Load and Save a description of this AAB-Tree and its contents - */ - virtual void Load(ChunkLoadClass & cload); - virtual void Save(ChunkSaveClass & csave); - - /* - ** Save an objects linkage, load the linkage and re-link the object - */ - void Load_Object_Linkage(ChunkLoadClass & cload,CullableClass * obj); - void Save_Object_Linkage(ChunkSaveClass & csave,CullableClass * obj); - /* ** Bounding box of the entire tree */ @@ -171,12 +157,6 @@ class AABTreeCullSystemClass : public CullSystemClass void Update_Bounding_Boxes_Recursive(AABTreeNodeClass * node); - void Load_Nodes(AABTreeNodeClass * node,ChunkLoadClass & cload); - void Save_Nodes(AABTreeNodeClass * node,ChunkSaveClass & csave); - - virtual void Load_Node_Contents(AABTreeNodeClass * /*node*/,ChunkLoadClass & /*cload*/) { } - virtual void Save_Node_Contents(AABTreeNodeClass * /*node*/,ChunkSaveClass & /*csave*/) { } - AABTreeNodeClass * RootNode; // root of the AAB-Tree int ObjectCount; // number of objects in the system diff --git a/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.cpp b/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.cpp index 1717ff23a04..ee8cb616f34 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.cpp @@ -37,33 +37,6 @@ #include "cardinalspline.h" #include "WWDebug/wwdebug.h" -#include "WWSaveLoad/persistfactory.h" -#include "wwmathids.h" -#include "WWDebug/wwhack.h" - -/* -** Force-Link this module because the linker can't detect that we actually need it... -*/ -DECLARE_FORCE_LINK(cardinalspline); - - -/* -** Save-Load stuff -*/ -SimplePersistFactoryClass _CardinalSpline3DFactory; -SimplePersistFactoryClass _CardinalSpline1DFactory; - -enum -{ - // ID's used by CardinalSpline3D - CARDINAL3D_CHUNK_HERMITE3D = 0x02070957, - CARDINAL3D_CHUNK_TIGHTNESSKEYS, - - // ID's used by CardinalSpline1D - CARDINAL1D_CHUNK_HERMITE1D = 0x02070959, - CARDINAL1D_CHUNK_TIGHTNESSKEYS -}; - /* ** CardinalSpline3DClass Implementation @@ -160,61 +133,6 @@ void CardinalSpline3DClass::Update_Tangents() TangentsDirty = false; } -const PersistFactoryClass & CardinalSpline3DClass::Get_Factory() const -{ - return _CardinalSpline3DFactory; -} - -bool CardinalSpline3DClass::Save(ChunkSaveClass &csave) -{ - csave.Begin_Chunk(CARDINAL3D_CHUNK_HERMITE3D); - HermiteSpline3DClass::Save(csave); - csave.End_Chunk(); - - csave.Begin_Chunk(CARDINAL3D_CHUNK_TIGHTNESSKEYS); - for (int i=0; i Tightness; @@ -83,11 +78,6 @@ class CardinalSpline1DClass : public HermiteSpline1DClass virtual void Update_Tangents() override; - // save-load support - virtual const PersistFactoryClass & Get_Factory() const override; - virtual bool Save(ChunkSaveClass &csave) override; - virtual bool Load(ChunkLoadClass &cload) override; - protected: DynamicVectorClass Tightness; diff --git a/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.cpp b/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.cpp index 9a593875d88..7e9856b06a7 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.cpp @@ -33,41 +33,11 @@ *---------------------------------------------------------------------------------------------* * Functions: * * CatmullRomSpline3DClass::Update_Tangents -- computes the tangents at each key * - * CatmullRomSpline3DClass::Get_Factory -- returns the factory for CatmullRomSpline3D * - * CatmullRomSpline3DClass::Save -- save this curve * - * CatmullRomSpline3DClass::Load -- load this curve * * CatmullRomSpline1DClass::Update_Tangents -- Computes the tangents at each key * - * CatmullRomSpline1DClass::Get_Factory -- returns the factory for CatmullRomSpline1D * - * CatmullRomSpline1DClass::Save -- Save this curve * - * CatmullRomSpline1DClass::Load -- Load this curve * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "catmullromspline.h" -#include "WWSaveLoad/persistfactory.h" -#include "wwmathids.h" -#include "WWDebug/wwhack.h" - -/* -** Force-Link this module because the linker can't detect that we actually need it... -*/ -DECLARE_FORCE_LINK(catmullromspline); - -/* -** Save-Load stuff -*/ -SimplePersistFactoryClass _CatmullRomSpline3DFactory; -SimplePersistFactoryClass _CatmullRomSpline1DFactory; - -enum -{ - // ID's used by CatmullRomSpline3D - CATMULLROM3D_CHUNK_HERMITE3D = 0x00020727, - - // ID's used by CatmullRomSpline1D - CATMULLROM1D_CHUNK_HERMITE1D = 0x00020729, -}; - /* ** Catmull-Rom 3D spline implementation @@ -143,78 +113,6 @@ void CatmullRomSpline3DClass::Update_Tangents() } -/*********************************************************************************************** - * CatmullRomSpline3DClass::Get_Factory -- returns the factory for CatmullRomSpline3D * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/7/2000 gth : Created. * - *=============================================================================================*/ -const PersistFactoryClass & CatmullRomSpline3DClass::Get_Factory() const -{ - return _CatmullRomSpline3DFactory; -} - - -/*********************************************************************************************** - * CatmullRomSpline3DClass::Save -- save this curve * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/7/2000 gth : Created. * - *=============================================================================================*/ -bool CatmullRomSpline3DClass::Save(ChunkSaveClass &csave) -{ - csave.Begin_Chunk(CATMULLROM3D_CHUNK_HERMITE3D); - HermiteSpline3DClass::Save(csave); - csave.End_Chunk(); - return true; -} - - -/*********************************************************************************************** - * CatmullRomSpline3DClass::Load -- load this curve * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/7/2000 gth : Created. * - *=============================================================================================*/ -bool CatmullRomSpline3DClass::Load(ChunkLoadClass &cload) -{ - while (cload.Open_Chunk()) { - - switch(cload.Cur_Chunk_ID()) - { - case CATMULLROM3D_CHUNK_HERMITE3D: - HermiteSpline3DClass::Load(cload); - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - } - cload.Close_Chunk(); - } - - return true; -} - - /* ** The 1D Catmull-Rom implementation. */ @@ -280,75 +178,3 @@ void CatmullRomSpline1DClass::Update_Tangents() } TangentsDirty = false; } - - -/*********************************************************************************************** - * CatmullRomSpline1DClass::Get_Factory -- returns the factory for CatmullRomSpline1D * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/7/2000 gth : Created. * - *=============================================================================================*/ -const PersistFactoryClass & CatmullRomSpline1DClass::Get_Factory() const -{ - return _CatmullRomSpline1DFactory; -} - - -/*********************************************************************************************** - * CatmullRomSpline1DClass::Save -- Save this curve * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/7/2000 gth : Created. * - *=============================================================================================*/ -bool CatmullRomSpline1DClass::Save(ChunkSaveClass &csave) -{ - csave.Begin_Chunk(CATMULLROM1D_CHUNK_HERMITE1D); - HermiteSpline1DClass::Save(csave); - csave.End_Chunk(); - return true; -} - - -/*********************************************************************************************** - * CatmullRomSpline1DClass::Load -- Load this curve * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/7/2000 gth : Created. * - *=============================================================================================*/ -bool CatmullRomSpline1DClass::Load(ChunkLoadClass &cload) -{ - while (cload.Open_Chunk()) { - - switch(cload.Cur_Chunk_ID()) - { - case CATMULLROM1D_CHUNK_HERMITE1D: - HermiteSpline1DClass::Load(cload); - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - } - cload.Close_Chunk(); - } - - return true; -} diff --git a/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h b/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h index 21ec4b147bf..b8897537b98 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h +++ b/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h @@ -46,11 +46,6 @@ class CatmullRomSpline3DClass : public HermiteSpline3DClass { public: virtual void Update_Tangents() override; - - // save-load support - virtual const PersistFactoryClass & Get_Factory() const override; - virtual bool Save(ChunkSaveClass &csave) override; - virtual bool Load(ChunkLoadClass &cload) override; }; @@ -62,9 +57,4 @@ class CatmullRomSpline1DClass : public HermiteSpline1DClass { public: virtual void Update_Tangents() override; - - // save-load support - virtual const PersistFactoryClass & Get_Factory() const override; - virtual bool Save(ChunkSaveClass &csave) override; - virtual bool Load(ChunkLoadClass &cload) override; }; diff --git a/Core/Libraries/Source/WWVegas/WWMath/curve.cpp b/Core/Libraries/Source/WWVegas/WWMath/curve.cpp index f230fb36cc2..44b228a4eaa 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/curve.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/curve.cpp @@ -39,45 +39,6 @@ #include "curve.h" #include "WWDebug/wwdebug.h" -#include "WWSaveLoad/persistfactory.h" -#include "wwmathids.h" -#include "WWDebug/wwhack.h" - -/* -** Force-Link this module because the linker can't detect that we actually need it... -*/ -DECLARE_FORCE_LINK(curve); - -/* -** Persist factories and chunk-id's used to save and load. -*/ -SimplePersistFactoryClass _LinearCurve3DFactory; -SimplePersistFactoryClass _LinearCurve1DFactory; - -enum -{ - // ID's used by Curve3D - CURVE3D_CHUNK_VARIABLES = 0x00020651, - CURVE3D_CHUNK_KEYS, - - CURVE3D_VARIABLE_ISLOOPING = 0x00, - CURVE3D_VARIABLE_KEYCOUNT, - - // ID's used by LinearCurve3D - LINEARCURVE3D_CHUNK_CURVE3D = 0x00020653, - - // ID's used by Curve1D - CURVE1D_CHUNK_VARIABLES = 0x00020655, - CURVE1D_CHUNK_KEYS, - - CURVE1D_VARIABLE_ISLOOPING = 0x00, - CURVE1D_VARIABLE_KEYCOUNT, - - // ID's used by LinearCurve1D - LINEARCURVE1D_CHUNK_CURVE1D = 0x00020657, - -}; - /*********************************************************************************************** ** @@ -199,70 +160,6 @@ void Curve3DClass::Find_Interval(float time,int * i0,int * i1,float * t) *t = (time - Keys[i].Time) / (Keys[i+1].Time - Keys[i].Time); } -bool Curve3DClass::Save(ChunkSaveClass & csave) -{ - int keycount = Keys.Count(); - csave.Begin_Chunk(CURVE3D_CHUNK_VARIABLES); - WRITE_MICRO_CHUNK(csave,CURVE3D_VARIABLE_ISLOOPING,IsLooping); - WRITE_MICRO_CHUNK(csave,CURVE3D_VARIABLE_KEYCOUNT,keycount); - csave.End_Chunk(); - - // Saving the keys, Note that if the format of a key changes we'll - // need a new chunk. (I didn't wrap each variable in its own chunk) - csave.Begin_Chunk(CURVE3D_CHUNK_KEYS); - for (int i=0; i _HermiteSpline3DFactory; -SimplePersistFactoryClass _HermiteSpline1DFactory; - -enum -{ - // ID's used by HermiteSpline3D - HERMITE3D_CHUNK_CURVE3D = 0x00020727, - HERMITE3D_CHUNK_TANGENTS, - - // ID's used by HermiteSpline1D - HERMITE1D_CHUNK_CURVE1D = 0x00020729, - HERMITE1D_CHUNK_TANGENTS, -}; /* @@ -212,65 +186,6 @@ void HermiteSpline3DClass::Get_Tangents(int i,Vector3 * set_in,Vector3 * set_out *set_out = Tangents[i].OutTangent; } -const PersistFactoryClass & HermiteSpline3DClass::Get_Factory() const -{ - return _HermiteSpline3DFactory; -} - -bool HermiteSpline3DClass::Save(ChunkSaveClass &csave) -{ - csave.Begin_Chunk(HERMITE3D_CHUNK_CURVE3D); - Curve3DClass::Save(csave); - csave.End_Chunk(); - - csave.Begin_Chunk(HERMITE3D_CHUNK_TANGENTS); - for (int i=0; i LookupTableMgrClass::Tables; -/* -** Save-Load stuff. Lookup tables are basically saved 1D curve classes. They are turned -** into tables at load time. For future expansion, the curve is wrapped in a chunk. -*/ -enum -{ - LOOKUPTABLE_CHUNK_CURVE = 03071200, - LOOKUPTABLE_CHUNK_EXTENTS, -}; - /*********************************************************************************************** ** @@ -140,9 +125,9 @@ bool LookupTableMgrClass::Remove_Table(LookupTableClass * table) return Tables.Remove(table); } -LookupTableClass * LookupTableMgrClass::Get_Table(const char * name,bool try_to_load) +LookupTableClass * LookupTableMgrClass::Get_Table(const char * name) { - // check if we already have this table loaded... + // find the table with this name... RefMultiListIterator it(&Tables); for (it.First(); !it.Is_Done(); it.Next()) { if (stricmp(it.Peek_Obj()->Get_Name(),name) == 0) { @@ -150,100 +135,7 @@ LookupTableClass * LookupTableMgrClass::Get_Table(const char * name,bool try_to_ } } - // otherwise we can try to load it. - LookupTableClass * new_table = nullptr; - if (try_to_load) { - - FileClass * file = _TheFileFactory->Get_File(name); - if (file && file->Open()) { - - ChunkLoadClass cload(file); - - Curve1DClass * curve = nullptr; - Load_Table_Desc(cload,&curve); - if (curve != nullptr) { - new_table = NEW_REF(LookupTableClass,()); - new_table->Init(name,curve); - Add_Table(new_table); - delete curve; - } - } - _TheFileFactory->Return_File(file); - } - - return new_table; // constructor ref is returned to user. -} - -void LookupTableMgrClass::Save_Table_Desc -( - ChunkSaveClass & csave, - Curve1DClass * curve, - const Vector2 & min_corner, - const Vector2 & max_corner -) -{ - // save the curve - csave.Begin_Chunk(LOOKUPTABLE_CHUNK_CURVE); - csave.Begin_Chunk(curve->Get_Factory().Chunk_ID()); - curve->Get_Factory().Save(csave,curve); - csave.End_Chunk(); - csave.End_Chunk(); - - // save the extents - csave.Begin_Chunk(LOOKUPTABLE_CHUNK_EXTENTS); - csave.Write(&(min_corner.X),sizeof(float)); - csave.Write(&(min_corner.Y),sizeof(float)); - csave.Write(&(max_corner.X),sizeof(float)); - csave.Write(&(max_corner.Y),sizeof(float)); - csave.End_Chunk(); -} - -void LookupTableMgrClass::Load_Table_Desc -( - ChunkLoadClass & cload, - Curve1DClass ** curve_ptr, - Vector2 * set_min_corner, - Vector2 * set_max_corner -) -{ - *curve_ptr = nullptr; - PersistFactoryClass * factory; - - float xmin,xmax; - float ymin,ymax; - xmin = xmax = ymin = ymax = 0.0f; - - while (cload.Open_Chunk()) { - switch(cload.Cur_Chunk_ID()) { - case LOOKUPTABLE_CHUNK_CURVE: - cload.Open_Chunk(); - factory = SaveLoadSystemClass::Find_Persist_Factory(cload.Cur_Chunk_ID()); - WWASSERT(factory != nullptr); - if (factory != nullptr) { - *curve_ptr = (Curve1DClass *)factory->Load(cload); - } - cload.Close_Chunk(); - break; - case LOOKUPTABLE_CHUNK_EXTENTS: - cload.Read(&xmin,sizeof(xmin)); - cload.Read(&ymin,sizeof(ymin)); - cload.Read(&xmax,sizeof(xmax)); - cload.Read(&ymax,sizeof(ymax)); - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - } - cload.Close_Chunk(); - } - - if (set_min_corner != nullptr) { - set_min_corner->Set(xmin,ymin); - } - if (set_max_corner != nullptr) { - set_max_corner->Set(xmax,ymax); - } + return nullptr; } diff --git a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h index 0eb6d064c35..14de4d28720 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h +++ b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h @@ -45,10 +45,7 @@ #include "wwmath.h" -class Vector2; class Curve1DClass; -class ChunkSaveClass; -class ChunkLoadClass; /** @@ -68,7 +65,7 @@ class LookupTableClass : public RefCountClass, public MultiListObjectClass const char * Get_Name() { return Name; } protected: - StringClass Name; // name of this table, if it came from a file, this is also the filename + StringClass Name; // name of this table float MinInputValue; float MaxInputValue; float OOMaxMinusMin; @@ -111,13 +108,7 @@ inline float LookupTableClass::Get_Value_Quick(float input) /** ** LookupTableMgrClass -** This class tracks all of the LookupTableClass's that have been loaded or installed. -** LookupTables can be created using the "SimpleGraph" tool. It basically allows you -** to edit a curve which will be used to generate the table. These curves are stored -** in .TBL files. -** -** NOTE: Use the SimpleGraph program to create lookup tables! Then just ask for them -** by filename and it will load the table for you (unless it is already loaded). +** This class tracks all of the LookupTableClass's that have been installed. ** ** NOTE: I add a table called "DefaultTable" so that you can revert to that if ** your table isn't found. @@ -134,17 +125,7 @@ class LookupTableMgrClass static bool Add_Table(LookupTableClass * table); static bool Remove_Table(LookupTableClass * table); - static LookupTableClass * Get_Table(const char * name,bool try_to_load = true); - - static void Save_Table_Desc( ChunkSaveClass & csave, - Curve1DClass * curve, - const Vector2 & min, - const Vector2 & max ); - - static void Load_Table_Desc( ChunkLoadClass & cload, - Curve1DClass ** curve_ptr, - Vector2 * set_min = nullptr, - Vector2 * set_max = nullptr ); + static LookupTableClass * Get_Table(const char * name); static void Reset(); diff --git a/Core/Libraries/Source/WWVegas/WWMath/tcbspline.cpp b/Core/Libraries/Source/WWVegas/WWMath/tcbspline.cpp index 27014851868..65f045ee588 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/tcbspline.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/tcbspline.cpp @@ -37,27 +37,6 @@ #include "tcbspline.h" #include "WWDebug/wwdebug.h" -#include "WWSaveLoad/persistfactory.h" -#include "wwmathids.h" -#include "WWDebug/wwhack.h" - - -/* -** Force-Link this module because the linker can't detect that we actually need it... -*/ -DECLARE_FORCE_LINK(tcbspline); - -/* -** Save-Load stuff -*/ -SimplePersistFactoryClass _TCBSpline3DFactory; - -enum -{ - // ID's used by TCBSpline3D - TCB3D_CHUNK_HERMITE3D = 0x02071009, - TCB3D_CHUNK_PARAMS, -}; /* @@ -189,60 +168,3 @@ void TCBSpline3DClass::Update_Tangents() } TangentsDirty = false; } - -const PersistFactoryClass & TCBSpline3DClass::Get_Factory() const -{ - return _TCBSpline3DFactory; -} - -bool TCBSpline3DClass::Save(ChunkSaveClass &csave) -{ - csave.Begin_Chunk(TCB3D_CHUNK_HERMITE3D); - HermiteSpline3DClass::Save(csave); - csave.End_Chunk(); - - csave.Begin_Chunk(TCB3D_CHUNK_PARAMS); - for (int i=0; i _VehicleCurveFactory; - -//////////////////////////////////////////////////////////////// -// Save/Load constants -//////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_PARENT = 0x11071217, - CHUNKID_ARC_INFO, - CHUNKID_VARIABLES -}; - -enum -{ - VARID_IS_DIRTY = 1, - VARID_RADIUS, -}; - - ////////////////////////////////////////////////////////////////////// // Local prototypes ////////////////////////////////////////////////////////////////////// @@ -577,103 +553,3 @@ VehicleCurveClass::Evaluate (float time, Vector3 *set_val) // set_val->Z = Keys[index0].Point.Z + (Keys[index1].Point.Z - Keys[index0].Point.Z) * seg_time; } - -const PersistFactoryClass & VehicleCurveClass::Get_Factory() const -{ - return _VehicleCurveFactory; -} - - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -//////////////////////////////////////////////////////////////////////////////////////////// -bool -VehicleCurveClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_PARENT); - Curve3DClass::Save (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_VARIABLES); - - // - // Save each variable to its own microchunk - // - WRITE_MICRO_CHUNK (csave, VARID_IS_DIRTY, m_IsDirty); - WRITE_MICRO_CHUNK (csave, VARID_RADIUS, m_Radius); - - csave.End_Chunk (); - - // - // Save each arc info struct to its own chunk - // - for (int index = 0; index < m_ArcList.Count (); index ++) { - ArcInfoStruct &arc_info = m_ArcList[index]; - - csave.Begin_Chunk (CHUNKID_ARC_INFO); - csave.Write (&arc_info, sizeof (arc_info)); - csave.End_Chunk (); - } - - return true; -} - - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -//////////////////////////////////////////////////////////////////////////////////////////// -bool -VehicleCurveClass::Load (ChunkLoadClass &cload) -{ - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_PARENT: - Curve3DClass::Load (cload); - break; - - case CHUNKID_ARC_INFO: - { - ArcInfoStruct arc_info; - cload.Read (&arc_info, sizeof (arc_info)); - m_ArcList.Add (arc_info); - } - break; - - case CHUNKID_VARIABLES: - Load_Variables (cload); - break; - } - - cload.Close_Chunk (); - } - - return true; -} - - -/////////////////////////////////////////////////////////////////////// -// -// Load_Variables -// -/////////////////////////////////////////////////////////////////////// -void -VehicleCurveClass::Load_Variables (ChunkLoadClass &cload) -{ - // - // Loop through all the microchunks that define the variables - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_IS_DIRTY, m_IsDirty); - READ_MICRO_CHUNK (cload, VARID_RADIUS, m_Radius); - } - - cload.Close_Micro_Chunk (); - } -} diff --git a/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h b/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h index 81e7fd120cc..6dc1c7627c6 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h @@ -99,20 +99,12 @@ class VehicleCurveClass : public Curve3DClass float Get_Current_Sharpness (Vector3 *position) const { *position = m_SharpnessPos; return m_Sharpness; } float Get_Last_Eval_Time () const { return m_LastTime; } - // - // Save-load support - // - virtual const PersistFactoryClass & Get_Factory() const override; - virtual bool Save(ChunkSaveClass &csave) override; - virtual bool Load(ChunkLoadClass &cload) override; - protected: /////////////////////////////////////////////////////////////////////////// // Protected methods /////////////////////////////////////////////////////////////////////////// void Update_Arc_List (); - void Load_Variables (ChunkLoadClass &cload); /////////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWMath/wwmath.cpp b/Core/Libraries/Source/WWVegas/WWMath/wwmath.cpp index 62e29520f38..a96ac0b68fb 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/wwmath.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/wwmath.cpp @@ -36,7 +36,6 @@ #include "wwmath.h" -#include "WWDebug/wwhack.h" #include "lookuptable.h" #include #include "WWDebug/wwdebug.h" @@ -90,16 +89,3 @@ float WWMath::Random_Float() return ((float)(rand() & 0xFFF)) / (float)(0xFFF); } - -/* -** Force link some modules from this library. -*/ -void Do_Force_Links() -{ - FORCE_LINK(curve); - FORCE_LINK(hermitespline); - FORCE_LINK(catmullromspline); - FORCE_LINK(cardinalspline); - FORCE_LINK(tcbspline); -} - diff --git a/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h b/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h deleted file mode 100644 index d6adb14b421..00000000000 --- a/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/wwmath/wwmathids.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 8:42p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWSaveLoad/saveloadids.h" - -/* -** Persist Factory ID's for WWMATH -*/ -enum -{ - WWMATH_CHUNKID_LINEARCURVE1D = CHUNKID_WWMATH_BEGIN, - WWMATH_CHUNKID_HERMITESPLINE1D, - WWMATH_CHUNKID_CATMULLROMSPLINE1D, - WWMATH_CHUNKID_CARDINALSPLINE1D, - WWMATH_CHUNKID_TCBSPLINE1D, - - WWMATH_CHUNKID_LINEARCURVE3D = CHUNKID_WWMATH_BEGIN + 0x100, - WWMATH_CHUNKID_HERMITESPLINE3D, - WWMATH_CHUNKID_CATMULLROMSPLINE3D, - WWMATH_CHUNKID_CARDINALSPLINE3D, - WWMATH_CHUNKID_TCBSPLINE3D, - WWMATH_CHUNKID_VEHICLECURVE -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt deleted file mode 100644 index df618b0489a..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -set(WWSAVELOAD_SRC - definition.cpp - definition.h - definitionclassids.h - definitionfactory.cpp - definitionfactory.h - definitionfactorymgr.cpp - definitionfactorymgr.h - definitionmgr.cpp - definitionmgr.h - editable.h - parameter.cpp - parameter.h - parameterlist.h - parametertypes.h - persist.h - persistfactory.cpp - persistfactory.h - pointerremap.cpp - pointerremap.h - postloadable.h - saveload.cpp - saveload.h - saveloadids.h - saveloadstatus.cpp - saveloadstatus.h - saveloadstatus.h - saveloadsubsystem.cpp - saveloadsubsystem.h - simpledefinitionfactory.h - simpleparameter.h - twiddler.cpp - twiddler.h - wwsaveload.cpp - wwsaveload.h -) - -add_library(core_wwsaveload STATIC) -set_target_properties(core_wwsaveload PROPERTIES OUTPUT_NAME wwsaveload) - -target_sources(core_wwsaveload PRIVATE ${WWSAVELOAD_SRC}) - -target_link_libraries(core_wwsaveload PRIVATE - core_wwcommon - corei_always -) diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.cpp deleted file mode 100644 index a41095ab897..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definition.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 8/24/01 4:35p $* - * * - * $Revision:: 10 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "definition.h" -#include "WWLib/chunkio.h" - -////////////////////////////////////////////////////////////////////////////////// -// Constants -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_VARIABLES = 0x00000100, -}; - -enum -{ - VARID_INSTANCEID = 0x01, - XXX_VARID_PARENTID, - VARID_NAME, -}; - - -///////////////////////////////////////////////////////// -// -// Save -// -///////////////////////////////////////////////////////// -bool -DefinitionClass::Save (ChunkSaveClass &csave) -{ - bool retval = true; - - csave.Begin_Chunk (CHUNKID_VARIABLES); - retval &= Save_Variables (csave); - csave.End_Chunk (); - - return retval; -} - - -///////////////////////////////////////////////////////// -// -// Load -// -///////////////////////////////////////////////////////// -bool -DefinitionClass::Load (ChunkLoadClass &cload) -{ - bool retval = true; - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_VARIABLES: - Load_Variables (cload); - break; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionClass::Save_Variables (ChunkSaveClass &csave) -{ - bool retval = true; - - WRITE_MICRO_CHUNK (csave, VARID_INSTANCEID, m_ID); - WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_NAME, m_Name); - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionClass::Load_Variables (ChunkLoadClass &cload) -{ - bool retval = true; - - // - // Loop through all the microchunks that define the variables - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_INSTANCEID, m_ID) - READ_MICRO_CHUNK_WWSTRING (cload, VARID_NAME, m_Name) - } - - cload.Close_Micro_Chunk (); - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_ID -// -////////////////////////////////////////////////////////////////////////////////// -void -DefinitionClass::Set_ID (uint32 id) -{ - m_ID = id; - - // - // If we are registered with the definition manager, then we need to - // re-link ourselves back into the list - // - if (m_DefinitionMgrLink != -1) { - DefinitionMgrClass::Unregister_Definition (this); - DefinitionMgrClass::Register_Definition (this); - } -} - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h deleted file mode 100644 index d7913a70f32..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h +++ /dev/null @@ -1,183 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definition.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 8/24/01 4:57p $* - * * - * $Revision:: 20 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -// SKB Remove because of G conflicts with CLASSID_?? -#include "definitionclassids.h" -#include "definitionmgr.h" -#include "editable.h" -#include "WWLib/wwstring.h" - -// Forward declarations -class ChunkSaveClass; -class ChunkLoadClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// DefinitionClass -// -////////////////////////////////////////////////////////////////////////////////// -class DefinitionClass : public PersistClass, public EditableClass -{ -public: - - ///////////////////////////////////////////////////////////////////// - // Editable interface requirements - ///////////////////////////////////////////////////////////////////// - DECLARE_EDITABLE(DefinitionClass, EditableClass); - - ///////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ///////////////////////////////////////////////////////////////////// - DefinitionClass (); - virtual ~DefinitionClass () override; - - ///////////////////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////////////////// - - // Type identification - virtual uint32 Get_Class_ID () const = 0; - virtual uint32 Get_ID () const; - virtual void Set_ID (uint32 id); - virtual PersistClass * Create () const = 0; - - // Display name methods - virtual const char * Get_Name () const; - virtual void Set_Name (const char *new_name); - - // Validation methods - virtual bool Is_Valid_Config (StringClass &message); - - // From PersistClass - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - - // User data support - uint32 Get_User_Data () const { return m_GenericUserData; } - void Set_User_Data (uint32 data) { m_GenericUserData = data; } - - // Save support - bool Is_Save_Enabled () const { return m_SaveEnabled; } - void Enable_Save (bool onoff) { m_SaveEnabled = onoff; } - -protected: - - ///////////////////////////////////////////////////////////////////// - // Protected member data - ///////////////////////////////////////////////////////////////////// - int m_DefinitionMgrLink; - -private: - - ///////////////////////////////////////////////////////////////////// - // Private methods - ///////////////////////////////////////////////////////////////////// - bool Save_Variables (ChunkSaveClass &csave); - bool Load_Variables (ChunkLoadClass &cload); - - ///////////////////////////////////////////////////////////////////// - // Private member data - ///////////////////////////////////////////////////////////////////// - StringClass m_Name; - uint32 m_ID; - uint32 m_GenericUserData; - bool m_SaveEnabled; - - ///////////////////////////////////////////////////////////////////// - // Friends - ///////////////////////////////////////////////////////////////////// - friend class DefinitionMgrClass; -}; - - -///////////////////////////////////////////////////////////////////// -// DefinitionClass -///////////////////////////////////////////////////////////////////// -inline -DefinitionClass::DefinitionClass () - : m_ID (0), - m_SaveEnabled (true), - m_DefinitionMgrLink (-1) -{ -} - -///////////////////////////////////////////////////////////////////// -// DefinitionClass -///////////////////////////////////////////////////////////////////// -inline -DefinitionClass::~DefinitionClass () -{ -} - -////////////////////////////////////////////////////////////////////////////////// -// Get_Name -////////////////////////////////////////////////////////////////////////////////// -inline const char * -DefinitionClass::Get_Name () const -{ - return m_Name; -} - -////////////////////////////////////////////////////////////////////////////////// -// Set_Name -////////////////////////////////////////////////////////////////////////////////// -inline void -DefinitionClass::Set_Name (const char *new_name) -{ - m_Name = new_name; -} - -////////////////////////////////////////////////////////////////////////////////// -// Get_ID -////////////////////////////////////////////////////////////////////////////////// -inline uint32 -DefinitionClass::Get_ID () const -{ - return m_ID; -} - -////////////////////////////////////////////////////////////////////////////////// -// Is_Valid_Config -////////////////////////////////////////////////////////////////////////////////// -inline bool -DefinitionClass::Is_Valid_Config (StringClass &message) -{ - return true; -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h deleted file mode 100644 index 91da59dd559..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definitionclassids.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 8/03/00 5:44p $* - * * - * $Revision:: 15 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/bittype.h" - -////////////////////////////////////////////////////////////////////////////////// -// -// Constants -// -////////////////////////////////////////////////////////////////////////////////// -const int DEF_CLASSID_START = 0x00001000; -const int DEF_CLASSID_RANGE = 0x00001000; -#define NEXT_SUPER_CLASSID(n) DEF_CLASSID_START + (n * DEF_CLASSID_RANGE) - - -////////////////////////////////////////////////////////////////////////////////// -// -// DefinitionClassID -// -// Note: The following enum should contain ALL of the class ids for -// definitions in the entire system (to guarantee they are unique). Each -// super-class is allocated a range of class ids. Use the -// SuperClassID_From_ClassID function to determine which super class -// a particular class id belongs to. -// -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CLASSID_TERRAIN = NEXT_SUPER_CLASSID(0), - CLASSID_TILE = NEXT_SUPER_CLASSID(1), - CLASSID_GAME_OBJECTS = NEXT_SUPER_CLASSID(2), - CLASSID_LIGHT = NEXT_SUPER_CLASSID(3), - CLASSID_SOUND = NEXT_SUPER_CLASSID(4), - CLASSID_WAYPATH = NEXT_SUPER_CLASSID(5), - CLASSID_ZONE = NEXT_SUPER_CLASSID(6), - CLASSID_TRANSITION = NEXT_SUPER_CLASSID(7), - CLASSID_PHYSICS = NEXT_SUPER_CLASSID(8), - CLASSID_EDITOR_OBJECTS = NEXT_SUPER_CLASSID(9), - CLASSID_MUNITIONS = NEXT_SUPER_CLASSID(10), - CLASSID_DUMMY_OBJECTS = NEXT_SUPER_CLASSID(11), - CLASSID_BUILDINGS = NEXT_SUPER_CLASSID(12), - CLASSID_TWIDDLERS = NEXT_SUPER_CLASSID(13), - CLASSID_GLOBAL_SETTINGS = NEXT_SUPER_CLASSID(14), -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// SuperClassID_From_ClassID -// -////////////////////////////////////////////////////////////////////////////////// -inline uint32 -SuperClassID_From_ClassID (uint32 class_id) -{ - // - // Which id-range does it fall under? - // - int delta = class_id - DEF_CLASSID_START; - int num_ranges = delta / DEF_CLASSID_RANGE; - - return DEF_CLASSID_START + (num_ranges * DEF_CLASSID_RANGE); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp deleted file mode 100644 index 0b152f05e97..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definitionfactory.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 9/09/99 7:12p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "definitionfactory.h" -#include "definitionfactorymgr.h" - - -///////////////////////////////////////////////////////// -// -// DefinitionFactoryClass -// -///////////////////////////////////////////////////////// -DefinitionFactoryClass::DefinitionFactoryClass () - : m_NextFactory (nullptr), - m_PrevFactory (nullptr) -{ - DefinitionFactoryMgrClass::Register_Factory (this); -} - - -///////////////////////////////////////////////////////// -// -// ~DefinitionFactoryClass -// -///////////////////////////////////////////////////////// -DefinitionFactoryClass::~DefinitionFactoryClass () -{ - DefinitionFactoryMgrClass::Unregister_Factory (this); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h deleted file mode 100644 index 6b2c4221d6c..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definitionfactory.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 2/22/01 6:18p $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/bittype.h" -#include "definitionclassids.h" - -// Forward declarations -class DefinitionClass; - -////////////////////////////////////////////////////////////////////////////////// -// -// DefinitionFactoryClass -// -// Definition factories act as virtual constructors for object definitions. They -// are responsible for creating new definitions for a particular class of objects. -// -////////////////////////////////////////////////////////////////////////////////// -class DefinitionFactoryClass -{ -public: - - ////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////// - DefinitionFactoryClass (); - virtual ~DefinitionFactoryClass (); - - ////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////// - virtual DefinitionClass * Create () const = 0; - virtual const char * Get_Name () const = 0; - virtual uint32 Get_Class_ID () const = 0; - virtual bool Is_Displayed () const = 0; - -protected: - - ////////////////////////////////////////////////////////////// - // Protected member data - ////////////////////////////////////////////////////////////// - DefinitionFactoryClass * m_NextFactory; - DefinitionFactoryClass * m_PrevFactory; - - - ////////////////////////////////////////////////////////////// - // Friends - ////////////////////////////////////////////////////////////// - friend class DefinitionFactoryMgrClass; -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp deleted file mode 100644 index d742ed7a3d7..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /VSS_Sync/wwsaveload/definitionfactorymgr.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "definitionfactorymgr.h" -#include "definitionfactory.h" -#include "WWDebug/wwdebug.h" - -#ifdef _UNIX -#include "osdep.h" -#endif - -//////////////////////////////////////////////////////////////////////////// -// Static member initialization -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass *DefinitionFactoryMgrClass::_FactoryListHead = nullptr; - - -//////////////////////////////////////////////////////////////////////////// -// -// Find_Factory -// -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass * -DefinitionFactoryMgrClass::Find_Factory (uint32 class_id) -{ - DefinitionFactoryClass *factory = nullptr; - - // - // Loop through all the factories and see if we can - // find the one who owns the corresponding class-id. - // - for ( DefinitionFactoryClass *curr_factory = _FactoryListHead; - (factory == nullptr) && (curr_factory != nullptr); - curr_factory = curr_factory->m_NextFactory) { - - // - // Is this the factory we were looking for? - // - if (curr_factory->Get_Class_ID () == class_id) { - factory = curr_factory; - } - } - - return factory; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Find_Factory -// -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass * -DefinitionFactoryMgrClass::Find_Factory (const char *name) -{ - DefinitionFactoryClass *factory = nullptr; - - // - // Loop through all the factories and see if we can - // find the one who owns the corresponding class-id. - // - for ( DefinitionFactoryClass *curr_factory = _FactoryListHead; - (factory == nullptr) && (curr_factory != nullptr); - curr_factory = curr_factory->m_NextFactory) { - - // - // Is this the factory we were looking for? - // - if (::stricmp (curr_factory->Get_Name (), name) == 0) { - factory = curr_factory; - } - } - - return factory; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Get_First -// -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass * -DefinitionFactoryMgrClass::Get_First (uint32 superclass_id) -{ - DefinitionFactoryClass *factory = nullptr; - - // - // Loop through all the factories and see if we can - // find the next one that belongs to the given superclass - // - for ( DefinitionFactoryClass *curr_factory = _FactoryListHead; - (factory == nullptr) && (curr_factory != nullptr); - curr_factory = curr_factory->m_NextFactory) { - - // - // Is this the factory we were looking for? - // - if (::SuperClassID_From_ClassID (curr_factory->Get_Class_ID ()) == superclass_id) { - factory = curr_factory; - } - } - - return factory; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Get_Next -// -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass * -DefinitionFactoryMgrClass::Get_Next -( - DefinitionFactoryClass *curr_factory, - uint32 superclass_id -) -{ - DefinitionFactoryClass *factory = nullptr; - - // - // Loop through all the factories and see if we can - // find the next one that belongs to the given superclass - // - while ((factory == nullptr) && ((curr_factory = curr_factory->m_NextFactory) != nullptr)) { - - // - // Is this the factory we were looking for? - // - if (::SuperClassID_From_ClassID (curr_factory->Get_Class_ID ()) == superclass_id) { - factory = curr_factory; - } - } - - return factory; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Get_First -// -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass * -DefinitionFactoryMgrClass::Get_First () -{ - return _FactoryListHead; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Get_Next -// -//////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass * -DefinitionFactoryMgrClass::Get_Next (DefinitionFactoryClass *curr_factory) -{ - DefinitionFactoryClass *factory = nullptr; - - // - // Simply return the next factory in the chain - // - if (curr_factory != nullptr) { - factory = curr_factory->m_NextFactory; - } - - return factory; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Register_Factory -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionFactoryMgrClass::Register_Factory (DefinitionFactoryClass *factory) -{ - WWASSERT (factory->m_NextFactory == 0); - WWASSERT (factory->m_PrevFactory == 0); - Link_Factory (factory); -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Unregister_Factory -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionFactoryMgrClass::Unregister_Factory (DefinitionFactoryClass *factory) -{ - WWASSERT (factory != 0); - Unlink_Factory (factory); -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Link_Factory -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionFactoryMgrClass::Link_Factory (DefinitionFactoryClass *factory) -{ - WWASSERT (factory->m_NextFactory == 0); - WWASSERT (factory->m_PrevFactory == 0); - - // Adding this factory in front of the current head of the list - factory->m_NextFactory = _FactoryListHead; - - // If the list wasn't empty, link the next factory back to this factory - if (factory->m_NextFactory != nullptr) { - factory->m_NextFactory->m_PrevFactory = factory; - } - - // Point the head of the list at this factory now - _FactoryListHead = factory; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Unlink_Factory -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionFactoryMgrClass::Unlink_Factory (DefinitionFactoryClass *factory) -{ - WWASSERT(factory != 0); - - // Handle the factory's prev pointer: - if (factory->m_PrevFactory == nullptr) { - - // this factory is the head - WWASSERT (_FactoryListHead == factory); - _FactoryListHead = factory->m_NextFactory; - - } else { - - // link it's prev with it's next - factory->m_PrevFactory->m_NextFactory = factory->m_NextFactory; - - } - - // Handle the factory's next pointer if its not at the end of the list: - if (factory->m_NextFactory != nullptr) { - - factory->m_NextFactory->m_PrevFactory = factory->m_PrevFactory; - - } - - // factory is now un-linked - factory->m_NextFactory = nullptr; - factory->m_PrevFactory = nullptr; -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h deleted file mode 100644 index cacef49f30c..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definitionfactorymgr.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 7/07/00 11:55a $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/bittype.h" -#include "definitionclassids.h" - -class DefinitionFactoryClass; - -////////////////////////////////////////////////////////////////////////////////// -// -// DefinitionFactoryMgrClass -// -////////////////////////////////////////////////////////////////////////////////// -class DefinitionFactoryMgrClass -{ -public: - - ///////////////////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////////////////// - static DefinitionFactoryClass * Find_Factory (uint32 class_id); - static DefinitionFactoryClass * Find_Factory (const char *name); - static void Register_Factory (DefinitionFactoryClass *factory); - static void Unregister_Factory (DefinitionFactoryClass *factory); - - // Class enumeration - static DefinitionFactoryClass * Get_First (uint32 superclass_id); - static DefinitionFactoryClass * Get_Next (DefinitionFactoryClass *current, uint32 superclass_id); - - // Factory enumeration - static DefinitionFactoryClass * Get_First (); - static DefinitionFactoryClass * Get_Next (DefinitionFactoryClass *current); - -private: - - ///////////////////////////////////////////////////////////////////// - // Private methods - ///////////////////////////////////////////////////////////////////// - static void Link_Factory (DefinitionFactoryClass *factory); - static void Unlink_Factory (DefinitionFactoryClass *factory); - - ///////////////////////////////////////////////////////////////////// - // Static member data - ///////////////////////////////////////////////////////////////////// - static DefinitionFactoryClass * _FactoryListHead; -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp deleted file mode 100644 index 468bab109ad..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp +++ /dev/null @@ -1,932 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definitionmgr.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 12/10/01 2:37p $* - * * - * $Revision:: 35 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "definitionmgr.h" -#include "definition.h" -#include "definitionfactory.h" -#include "definitionfactorymgr.h" -#include "definitionclassids.h" -#include "WWLib/chunkio.h" -#include "persistfactory.h" -#include "WWDebug/wwdebug.h" -#include "WWDebug/wwmemlog.h" -#include "twiddler.h" -#include "WWDebug/wwprofile.h" - - -////////////////////////////////////////////////////////////////////////////////// -// Global instance -////////////////////////////////////////////////////////////////////////////////// -DefinitionMgrClass _TheDefinitionMgr; - -////////////////////////////////////////////////////////////////////////////////// -// Constants -////////////////////////////////////////////////////////////////////////////////// -static const int DEFINTION_LIST_GROW_SIZE = 1000; -static const uint32 IDRANGE_PER_CLASS = 10000; - -enum -{ - CHUNKID_VARIABLES = 0x00000100, - CHUNKID_OBJECTS, - CHUNKID_OBJECT -}; - -enum -{ - VARID_NEXTDEFID = 0x01 -}; - -////////////////////////////////////////////////////////////////////////////////// -// Static member initialization -////////////////////////////////////////////////////////////////////////////////// -DefinitionClass ** DefinitionMgrClass::_SortedDefinitionArray = nullptr; -int DefinitionMgrClass::_DefinitionCount = 0; -int DefinitionMgrClass::_MaxDefinitionCount = 0; -HashTemplateClass*>* DefinitionMgrClass::DefinitionHash; - -////////////////////////////////////////////////////////////////////////////////// -// -// DefinitionMgrClass -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionMgrClass::DefinitionMgrClass () -{ -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// ~DefinitionMgrClass -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionMgrClass::~DefinitionMgrClass () -{ - Free_Definitions (); -} - -////////////////////////////////////////////////////////////////////////////////// -// -// Find_Definition -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionClass * -DefinitionMgrClass::Find_Definition (uint32 id, bool twiddle) -{ - DefinitionClass *definition = nullptr; - - int lower_index = 0; - int upper_index = _DefinitionCount - 1; - int index = upper_index / 2; - bool keep_going = (_DefinitionCount > 0); - - // - // Binary search the list until we've found the definition - // - while (keep_going) { - - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - WWASSERT (curr_def != nullptr); - - // - // Is this the definition we are looking for? - // - if (curr_def->Get_ID () == id) { - definition = _SortedDefinitionArray[index]; - keep_going = false; - } else if (upper_index <= lower_index + 1) { - - // - // When the window get's too small, our divide by two won't catch - // both entries, so just go ahead and do them both now. - // - keep_going = false; - if (_SortedDefinitionArray[lower_index]->Get_ID () == id) { - definition = _SortedDefinitionArray[lower_index]; - } else if (_SortedDefinitionArray[upper_index]->Get_ID () == id) { - definition = _SortedDefinitionArray[upper_index]; - } - - } else { - - // - // Cut our 'window' in half - // - if (id > curr_def->Get_ID ()) { - lower_index = index; - index += (upper_index - index) / 2; - } else { - upper_index = index; - index -= (index - lower_index) / 2; - } - } - } - - // - // Should we twiddle this definition? (Twiddling refers to our randomizing - // framework for definitions) - // - if ( twiddle && - definition != nullptr && - definition->Get_Class_ID () == CLASSID_TWIDDLERS) - { - definition = ((TwiddlerClass *)definition)->Twiddle (); - } - - return definition; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Find_Named_Definition -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionClass * -DefinitionMgrClass::Find_Named_Definition (const char *name, bool twiddle) -{ - DefinitionClass *definition = nullptr; - - // - // Loop through all the definitions and see if we can - // find the one with the requested name - // - for (int index = 0; index < _DefinitionCount; index ++) { - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - - // - // Is this the definition we were looking for? - // - if (curr_def != nullptr && ::stricmp (curr_def->Get_Name (), name) == 0) { - definition = curr_def; - break; - } - } - - // - // Should we twiddle this definition? (Twiddling refers to our randomizing - // framework for definitions) - // - if ( twiddle && - definition != nullptr && - definition->Get_Class_ID () == CLASSID_TWIDDLERS) - { - definition = ((TwiddlerClass *)definition)->Twiddle (); - } - - return definition; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Find_Typed_Definition -// -////////////////////////////////////////////////////////////////////////////////// - -DefinitionClass * -DefinitionMgrClass::Find_Typed_Definition (const char *name, uint32 class_id, bool twiddle) -{ - // - // Sanity check - // - if (DefinitionHash == nullptr) { - WWDEBUG_SAY (("DefinitionMgrClass::Find_Typed_Definition () failed due to a null DefinitionHash.")); - return nullptr; - } - - DefinitionClass *definition = nullptr; - - // Check the hash table first. The hash table is built as we need the definitions, so if definition is not - // in the table, it will be added there. - - // - // TSS null deref on this sucker 08/03/01 - // - WWASSERT(DefinitionHash != nullptr); - - StringClass lower_case_name(name,true); - _strlwr(lower_case_name.Peek_Buffer()); - DynamicVectorClass* defs = DefinitionHash->Get(lower_case_name); - - if (defs) { - for (int i=0;iLength();++i) { - DefinitionClass* curr_def=(*defs)[i]; - WWASSERT(curr_def); - uint32 curr_class_id = curr_def->Get_Class_ID (); - if ( (curr_class_id == class_id) || - (::SuperClassID_From_ClassID (curr_class_id) == class_id) || - (twiddle && (curr_def->Get_Class_ID () == CLASSID_TWIDDLERS))) - { - definition = curr_def; - break; - } - } - } - - // - // Loop through all the definitions and see if we can - // find the one with the requested name - // - if (!definition) { - for (int index = 0; index < _DefinitionCount; index ++) { - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != nullptr) { - - // - // Is this the correct class of definition? - // - uint32 curr_class_id = curr_def->Get_Class_ID (); - if ( (curr_class_id == class_id) || - (::SuperClassID_From_ClassID (curr_class_id) == class_id) || - (twiddle && (curr_def->Get_Class_ID () == CLASSID_TWIDDLERS))) - { - // - // Is this the definition we were looking for? - // - if (::stricmp (curr_def->Get_Name (), name) == 0) { - definition = curr_def; - // Add the definition to the hash table, so that it can be quickly accessed the next time it is needed. - if (!defs) { - defs=W3DNEW DynamicVectorClass; - DefinitionHash->Insert(lower_case_name,defs); - } - defs->Add(definition); - break; - } - } - } - } - } - - // - // Should we twiddle this definition? (Twiddling refers to our randomizing - // framework for definitions) - // - if ( twiddle && - definition != nullptr && - definition->Get_Class_ID () == CLASSID_TWIDDLERS) - { - definition = ((TwiddlerClass *)definition)->Twiddle (); - } - - return definition; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// List_Available_Definitions -// -////////////////////////////////////////////////////////////////////////////////// -void -DefinitionMgrClass::List_Available_Definitions () -{ - // - // Loop through all the definitions and print the definition name - // - WWDEBUG_SAY(("Available definitions:")); - for (int index = 0; index < _DefinitionCount; index ++) { - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != nullptr) { - WWDEBUG_SAY((" >%s<", curr_def->Get_Name ())); - } - } -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// List_Available_Definitions -// -////////////////////////////////////////////////////////////////////////////////// -void -DefinitionMgrClass::List_Available_Definitions (int superclass_id) -{ - // - // Loop through all the definitions and print the definition name - // - WWDEBUG_SAY(("Available superclass definitions for 0x%8X:", superclass_id)); - DefinitionClass *definition = nullptr; - for ( definition = Get_First (superclass_id, DefinitionMgrClass::ID_SUPERCLASS); - definition != nullptr; - definition = Get_Next (definition, superclass_id, DefinitionMgrClass::ID_SUPERCLASS)) - { - WWDEBUG_SAY((" >%s<", definition->Get_Name ())); - } -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Get_First -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionClass * -DefinitionMgrClass::Get_First (uint32 id, ID_TYPE type) -{ - DefinitionClass *definition = nullptr; - - // - // Loop through all the definitions and find the first - // one that belongs to the requested class - // - for ( int index = 0; - (definition == nullptr) && (index < _DefinitionCount); - index ++) - { - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != nullptr) { - - // - // Is this the definition we were looking for? - // - if ( (type == ID_SUPERCLASS) && - (::SuperClassID_From_ClassID (curr_def->Get_Class_ID ()) == id)) { - definition = curr_def; - } else if ( (type == ID_CLASS) && - (curr_def->Get_Class_ID () == id)) { - definition = curr_def; - } - } - } - - return definition; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Get_Next -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionClass * -DefinitionMgrClass::Get_Next -( - DefinitionClass * curr_def, - uint32 id, - ID_TYPE type -) -{ - DefinitionClass *definition = nullptr; - - // - // Loop through all the definitions and find the first - // one that belongs to the requested class - // - for ( int index = curr_def->m_DefinitionMgrLink + 1; - (definition == nullptr) && (index < _DefinitionCount); - index ++) - { - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != nullptr) { - - // - // Is this the definition we were looking for? - // - if ( (type == ID_SUPERCLASS) && - (::SuperClassID_From_ClassID (curr_def->Get_Class_ID ()) == id)) { - definition = curr_def; - } else if ( (type == ID_CLASS) && - (curr_def->Get_Class_ID () == id)) { - definition = curr_def; - } - } - } - - return definition; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Get_Next -// -//////////////////////////////////////////////////////////////////////////// -DefinitionClass * -DefinitionMgrClass::Get_Next (DefinitionClass *curr_def) -{ - WWASSERT (curr_def != nullptr); - DefinitionClass *definition = nullptr; - - int index = curr_def->m_DefinitionMgrLink + 1; - if (index < _DefinitionCount) { - definition = _SortedDefinitionArray[index]; - } - - return definition; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Free_Definitions -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionMgrClass::Free_Definitions () -{ - // Clear the hash table - if (DefinitionHash) { - HashTemplateIterator*> ite(*DefinitionHash); - for (ite.First();!ite.Is_Done();ite.Next()) { - DynamicVectorClass* defs=ite.Peek_Value(); -// delete ite.Peek_Value(); - delete defs; - } - DefinitionHash->Remove_All(); - delete DefinitionHash; - DefinitionHash=nullptr; - } - - // - // Free the definition array - // - if (_SortedDefinitionArray != nullptr) { - // - // Free each of the definition objects - // - for (int index = 0; index < _DefinitionCount; index ++) { - delete _SortedDefinitionArray[index]; - } - delete [] _SortedDefinitionArray; - _SortedDefinitionArray = nullptr; - _MaxDefinitionCount = 0; - _DefinitionCount = 0; - } -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Prepare_Definition_Array -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionMgrClass::Prepare_Definition_Array () -{ - if (_DefinitionCount + 1 > _MaxDefinitionCount) { - - // - // Allocate a new, bigger array - // - int new_size = _MaxDefinitionCount + DEFINTION_LIST_GROW_SIZE; - DefinitionClass **new_array = W3DNEWARRAY DefinitionClass *[new_size]; - - // - // Copy the entries from the old array to the new array - // - ::memcpy (new_array, _SortedDefinitionArray, _DefinitionCount * sizeof (DefinitionClass *)); - - // - // Free the old array and start using the new array - // - delete [] _SortedDefinitionArray; - _SortedDefinitionArray = new_array; - _MaxDefinitionCount = new_size; - } - if (!DefinitionHash) DefinitionHash=W3DNEW HashTemplateClass*>; -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Register_Definition -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionMgrClass::Register_Definition (DefinitionClass *definition) -{ - WWASSERT (definition != nullptr); - if (definition != nullptr && definition->m_DefinitionMgrLink == -1 && definition->Get_ID () != 0) { - // - // Make sure the definition array is large enough - // - Prepare_Definition_Array (); - - // - // Calculate where in the list we should insert this definition - // - uint32 id = definition->Get_ID (); - int lower_index = 0; - int upper_index = _DefinitionCount - 1; - int index = upper_index / 2; - int insert_index = _DefinitionCount; - bool keep_going = (_DefinitionCount > 0); - bool is_valid = true; - - while (keep_going) { - - DefinitionClass *curr_def = _SortedDefinitionArray[index]; - WWASSERT (curr_def != nullptr); - - // - // Check to make sure we aren't trying to register a definition - // that has the same ID as a definition that is already in the list. - // - if (curr_def->Get_ID () == id) { - insert_index = index; - keep_going = false; - is_valid = false; - } else { - - // - // Cut our 'window' in half - // - if (id > curr_def->Get_ID ()) { - lower_index = index; - index += (upper_index - index) / 2; - } else { - upper_index = index; - index -= (index - lower_index) / 2; - } - - // - // If we've narrowed down the window to 2 entries, then quick check - // the different possibilities. - // - if (upper_index <= lower_index + 1) { - if (_SortedDefinitionArray[upper_index]->Get_ID () <= id) { - insert_index = upper_index + 1; - } else if (_SortedDefinitionArray[lower_index]->Get_ID () <= id) { - insert_index = upper_index; - } else { - insert_index = lower_index; - } - keep_going = false; - } - } - } - - //WWASSERT (is_valid); - if (is_valid) { - - // - // Re-index all the definitions that got bumped one cell due to this insertion. - // - for (index = _DefinitionCount - 1; index >= insert_index; index --) { - _SortedDefinitionArray[index + 1] = _SortedDefinitionArray[index]; - _SortedDefinitionArray[index + 1]->m_DefinitionMgrLink = index + 1; - } - - // - // Insert this definition into the list - // - definition->m_DefinitionMgrLink = insert_index; - _SortedDefinitionArray[insert_index] = definition; - _DefinitionCount ++; - } - } -} - - -//////////////////////////////////////////////////////////////////////////// -// -// Unregister_Definition -// -//////////////////////////////////////////////////////////////////////////// -void -DefinitionMgrClass::Unregister_Definition (DefinitionClass *definition) -{ - WWASSERT (definition != 0); - //WWASSERT (definition->m_DefinitionMgrLink >= 0 && definition->m_DefinitionMgrLink < _DefinitionCount); - - if (definition != nullptr && definition->m_DefinitionMgrLink != -1) { - - // - // Re-index the definitions that come after this definition in the list - // - for (int index = definition->m_DefinitionMgrLink; index < _DefinitionCount - 1; index ++) { - _SortedDefinitionArray[index] = _SortedDefinitionArray[index + 1]; - _SortedDefinitionArray[index]->m_DefinitionMgrLink = index; - } - - _SortedDefinitionArray[_DefinitionCount - 1] = nullptr; - definition->m_DefinitionMgrLink = -1; - _DefinitionCount --; - } -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionMgrClass::Save -( - ChunkSaveClass & csave -) -{ - WWMEMLOG(MEM_GAMEDATA); - - bool retval = true; - - // - // Create a chunk to contain the class variables we need to serialize. - // - csave.Begin_Chunk (CHUNKID_VARIABLES); - Save_Variables (csave); - csave.End_Chunk (); - - // - // Have the base class write the objects to their own chunk. - // - csave.Begin_Chunk (CHUNKID_OBJECTS); - retval &= Save_Objects (csave); - csave.End_Chunk (); - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionMgrClass::Load (ChunkLoadClass &cload) -{ - WWMEMLOG(MEM_GAMEDATA); - bool retval = true; - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - // - // If this is the chunk that contains the class variables, then - // loop through and read each microchunk - // - case CHUNKID_VARIABLES: - retval &= Load_Variables (cload); - break; - - // - // Load all the definition objects from this chunk - // - case CHUNKID_OBJECTS: - retval &= Load_Objects (cload); - break; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save_Objects -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionMgrClass::Save_Objects -( - ChunkSaveClass & csave -) -{ - bool retval = true; - - // - // Loop through all the definition objects - // - for (int index = 0; index < _DefinitionCount; index ++) { - DefinitionClass *definition = _SortedDefinitionArray[index]; - if (definition != nullptr && definition->Is_Save_Enabled ()) { - - // - // Save this definition object - // - csave.Begin_Chunk (definition->Get_Factory ().Chunk_ID ()); - definition->Get_Factory ().Save (csave, definition); - csave.End_Chunk (); - } - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionMgrClass::Save_Variables (ChunkSaveClass &csave) -{ - bool retval = true; - return retval; -} - -float _alloc_time; -float _load_time; -float _reg_time; - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load_Objects -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionMgrClass::Load_Objects (ChunkLoadClass &cload) -{ - bool retval = true; - - while (cload.Open_Chunk ()) { - - // - // Load this definition from the chunk (if possible) - // - PersistFactoryClass *factory = SaveLoadSystemClass::Find_Persist_Factory (cload.Cur_Chunk_ID ()); - if (factory != nullptr) { - - DefinitionClass *definition = (DefinitionClass *)factory->Load (cload); - if (definition != nullptr) { - - // - // Add this definition to our array - // - Prepare_Definition_Array (); - _SortedDefinitionArray[_DefinitionCount ++] = definition; - } - } - - cload.Close_Chunk (); - } - - // - // Sort the definitions - // - if (_DefinitionCount > 0) { - ::qsort (_SortedDefinitionArray, _DefinitionCount, sizeof (DefinitionClass *), fnCompareDefinitionsCallback); - } - - // - // Assign a mgr link to each definition - // - for (int index = 0; index < _DefinitionCount; index ++) { - _SortedDefinitionArray[index]->m_DefinitionMgrLink = index; - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -DefinitionMgrClass::Load_Variables (ChunkLoadClass &cload) -{ - bool retval = true; - - // - // Loop through all the microchunks that define the variables - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - case VARID_NEXTDEFID: - break; - } - - cload.Close_Micro_Chunk (); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Get_New_ID -// -///////////////////////////////////////////////////////////////////// -uint32 -DefinitionMgrClass::Get_New_ID (uint32 class_id) -{ - uint32 idrange_start = (class_id - DEF_CLASSID_START) * IDRANGE_PER_CLASS; - uint32 idrange_end = (idrange_start + IDRANGE_PER_CLASS); - - uint32 new_id = idrange_start + 1; - - // - // Try to find the first empty slot in this ID range - // - for (int index = 0; index < _DefinitionCount; index ++) { - DefinitionClass *definition = _SortedDefinitionArray[index]; - if (definition != nullptr) { - - // - // Get this definition's ID - // - uint32 curr_id = definition->Get_ID (); - - // - // Is this id in the range we are looking for? - // - if (curr_id >= idrange_start && curr_id < idrange_end) { - - bool is_ok = false; - if (index < _DefinitionCount - 1) { - - // - // Check to see if the next definition in our array leaves a hole in the - // ID range. - // - DefinitionClass *next_definition = _SortedDefinitionArray[index + 1]; - if (next_definition != nullptr && next_definition->Get_ID () > (curr_id + 1)) { - is_ok = true; - } - - } else { - is_ok = true; - } - - // - // Return the new ID - // - if (is_ok) { - new_id = curr_id + 1; - break; - } - } - } - } - - return new_id; -} - - -//////////////////////////////////////////////////////////////// -// -// fnCompareDefinitionsCallback -// -//////////////////////////////////////////////////////////////// -int __cdecl -DefinitionMgrClass::fnCompareDefinitionsCallback -( - const void *elem1, - const void *elem2 -) -{ - WWASSERT (elem1 != nullptr); - WWASSERT (elem2 != nullptr); - DefinitionClass *definition1 = *((DefinitionClass **)elem1); - DefinitionClass *definition2 = *((DefinitionClass **)elem2); - - // - // Sort the definitions based on ID - // - int result = 0; - if (definition1->Get_ID () > definition2->Get_ID ()) { - result = 1; - } else if (definition1->Get_ID () < definition2->Get_ID ()) { - result = -1; - } else { - result = 0; - } - - return result; -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h deleted file mode 100644 index 9a05209eacd..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h +++ /dev/null @@ -1,177 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/definitionmgr.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 8/24/01 5:13p $* - * * - * $Revision:: 24 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "saveload.h" -#include "saveloadsubsystem.h" -#include "saveloadids.h" -#include "WWDebug/wwdebug.h" -#include "WWLib/wwstring.h" -#include "WWLib/hashtemplate.h" -#include "WWLib/Vector.h" - - -// Forward declarations -class DefinitionClass; - -////////////////////////////////////////////////////////////////////////////////// -// Global declarations -////////////////////////////////////////////////////////////////////////////////// -extern class DefinitionMgrClass _TheDefinitionMgr; - -////////////////////////////////////////////////////////////////////////////////// -// -// DefinitionMgrClass -// -////////////////////////////////////////////////////////////////////////////////// -class DefinitionMgrClass : public SaveLoadSubSystemClass -{ -public: - - ///////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ///////////////////////////////////////////////////////////////////// - DefinitionMgrClass (); - virtual ~DefinitionMgrClass () override; - - ///////////////////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////////////////// - - // From SaveLoadSubSystemClass - virtual uint32 Chunk_ID () const override; - - // Type identification - static DefinitionClass * Find_Definition (uint32 id, bool twiddle = true); - static DefinitionClass * Find_Named_Definition (const char *name, bool twiddle = true); - static DefinitionClass * Find_Typed_Definition (const char *name, uint32 class_id, bool twiddle = true); - static void List_Available_Definitions (); - static void List_Available_Definitions (int superclass_id); - static uint32 Get_New_ID (uint32 class_id); - - // Definition registration - static void Register_Definition (DefinitionClass *definition); - static void Unregister_Definition (DefinitionClass *definition); - - // - // Definition enumeration - // - typedef enum - { - ID_CLASS = 1, - ID_SUPERCLASS, - } ID_TYPE; - - static DefinitionClass * Get_First (); - static DefinitionClass * Get_First (uint32 id, ID_TYPE type = ID_CLASS); - static DefinitionClass * Get_Next (DefinitionClass *curr_def); - static DefinitionClass * Get_Next (DefinitionClass *curr_def, uint32 id, ID_TYPE type = ID_CLASS); - - static void Free_Definitions (); - -protected: - - ///////////////////////////////////////////////////////////////////// - // Protected methods - ///////////////////////////////////////////////////////////////////// - - // From SaveLoadSubSystemClass - virtual bool Contains_Data () const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual const char* Name () const override { return "DefinitionMgrClass"; } - - // Persistence methods - bool Save_Objects (ChunkSaveClass &csave); - bool Load_Objects (ChunkLoadClass &cload); - bool Save_Variables (ChunkSaveClass &csave); - bool Load_Variables (ChunkLoadClass &cload); - -private: - static HashTemplateClass*>* DefinitionHash; - - ///////////////////////////////////////////////////////////////////// - // Private methods - ///////////////////////////////////////////////////////////////////// - static void Prepare_Definition_Array (); - static int __cdecl fnCompareDefinitionsCallback (const void *elem1, const void *elem2); - - ///////////////////////////////////////////////////////////////////// - // Static member data - ///////////////////////////////////////////////////////////////////// - static DefinitionClass ** _SortedDefinitionArray; - static int _MaxDefinitionCount; - static int _DefinitionCount; - - ///////////////////////////////////////////////////////////////////// - // Friend classes - ///////////////////////////////////////////////////////////////////// - friend class DefinitionClass; -}; - -///////////////////////////////////////////////////////////////////// -// Chunk_ID -///////////////////////////////////////////////////////////////////// -inline uint32 -DefinitionMgrClass::Chunk_ID () const -{ - return CHUNKID_SAVELOAD_DEFMGR; -} - -///////////////////////////////////////////////////////////////////// -// Contains_Data -///////////////////////////////////////////////////////////////////// -inline bool -DefinitionMgrClass::Contains_Data () const -{ - return true; // TODO: check if we have any definitions... -} - -///////////////////////////////////////////////////////////////////// -// Get_First_Definition -///////////////////////////////////////////////////////////////////// -inline DefinitionClass * -DefinitionMgrClass::Get_First () -{ - DefinitionClass *definition = nullptr; - if (_DefinitionCount > 0) { - definition = _SortedDefinitionArray[0]; - } - - return definition; -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h deleted file mode 100644 index c29482ab843..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h +++ /dev/null @@ -1,324 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/editable.h $* - * * - * * - * Org Author:: Patrick Smith * - * * - * Author:: Kenny Mitchell * - * * - * $Modtime:: 5/29/02 11:00a $* - * * - * $Revision:: 29 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * 5/27/02 KM Added named filename parameter declaration - * 5/29/02 KM Added specific texture filename parameter support - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "persist.h" -#include "parameter.h" -#include "simpleparameter.h" -#include "parameterlist.h" -#include "WWDebug/wwdebug.h" - -////////////////////////////////////////////////////////////////////////////////// -// -// EditableClass -// -////////////////////////////////////////////////////////////////////////////////// -class EditableClass -{ -public: - - ///////////////////////////////////////////////////////////////////// - // Public methods - // - // Note: These methods can be implemented in derived classes - // by the DECLARE_EDITABLE macro. - // - ///////////////////////////////////////////////////////////////////// - virtual int Get_Parameter_Count () const; - virtual ParameterClass * Lock_Parameter (int i); - virtual void Unlock_Parameter (int i); -}; - -///////////////////////////////////////////////////////////////////// -// Get_Parameter_Count -///////////////////////////////////////////////////////////////////// -inline int -EditableClass::Get_Parameter_Count () const -{ - return 0; -} - -///////////////////////////////////////////////////////////////////// -// Get_Parameter -///////////////////////////////////////////////////////////////////// -inline ParameterClass * -EditableClass::Lock_Parameter (int i) -{ - WWASSERT (0); - return nullptr; -} - -///////////////////////////////////////////////////////////////////// -// Set_Parameter -///////////////////////////////////////////////////////////////////// -inline void -EditableClass::Unlock_Parameter (int i) -{ -} - -//#define PARAM_EDITING_ON -#ifdef PARAM_EDITING_ON - - ////////////////////////////////////////////////////////////////////////////////// - // - // DECLARE_EDITABLE - // - ////////////////////////////////////////////////////////////////////////////////// - #define DECLARE_EDITABLE(_class, _parent) \ - ParameterListClass plist_##_class; \ - virtual int _class::Get_Parameter_Count() const \ - { \ - return plist_##_class.Count () + _parent::Get_Parameter_Count (); \ - } \ - virtual ParameterClass *_class::Lock_Parameter(int i) \ - { \ - if (i < _parent::Get_Parameter_Count()) { \ - return _parent::Lock_Parameter (i); \ - } \ - return plist_##_class[i - _parent::Get_Parameter_Count()]; \ - } \ - - ////////////////////////////////////////////////////////////////////////////////// - // - // EDITABLE_PARAM - // - // The following macros are used inside the constructor for an editable - // object to map member data to abstract parameter objects. - // - // Some examples: - // - // To register the player's name (a string): - // EDITABLE_PARAM(GameClass, ParameterClass::TYPE_STRING, Name) - // - // To register the player's name using a more descriptive display string: - // NAMED_EDITABLE_PARAM(GameClass, ParameterClass::TYPE_STRING, Name, "Player Name") - // - // To register a unit's maximum health - // INT_EDITABLE_PARAM(GameClass, MaxHeatlh, 0, 500) - // - // To register a complex variable (such as an enumerated type: - // #ifdef PARAM_EDITING_ON - // EnumParameterClass *param = new EnumParameterClass(GangID); - // param->Set_Name ("Gang"); - // param->Add_Value ("GDI", ID_GDI); - // param->Add_Value ("NOD", ID_NOD); - // param->Add_Value ("Neutral", ID_NEUTRAL); - // GENERIC_EDITABLE_PARAM(param) - // #endif - // - ////////////////////////////////////////////////////////////////////////////////// - - - #define EDITABLE_PARAM(_class, type, data) plist_##_class.Add (&(data), #data, type); - #define NAMED_EDITABLE_PARAM(_class, type, data, name) plist_##_class.Add (&(data), name, type); - - #define INT_EDITABLE_PARAM(_class, data, min, max) { \ - IntParameterClass *param = W3DNEW IntParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - plist_##_class.Add (param); } \ - - #define INT_UNITS_PARAM(_class, data, min, max, unitsname) { \ - IntParameterClass *param = W3DNEW IntParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - param->Set_Units_Name(unitsname); \ - plist_##_class.Add (param); } \ - - #define NAMED_INT_UNITS_PARAM(_class,data,min,max,unitsname,name) { \ - IntParameterClass *param = W3DNEW IntParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - param->Set_Units_Name(unitsname); \ - param->Set_Name(name); \ - plist_##_class.Add (param); } \ - - #define FLOAT_EDITABLE_PARAM(_class, data, min, max) { \ - FloatParameterClass *param = W3DNEW FloatParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - plist_##_class.Add (param); } \ - - #define FLOAT_UNITS_PARAM(_class, data, min, max, unitsname) { \ - FloatParameterClass *param = W3DNEW FloatParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - param->Set_Units_Name(unitsname); \ - plist_##_class.Add (param); } - - #define NAMED_FLOAT_UNITS_PARAM(_class, data, min, max, unitsname,name) { \ - FloatParameterClass *param = W3DNEW FloatParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - param->Set_Units_Name(unitsname); \ - param->Set_Name(name); \ - plist_##_class.Add (param); } - - #define ANGLE_EDITABLE_PARAM(_class, data, min, max) { \ - AngleParameterClass *param = W3DNEW AngleParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - param->Set_Units_Name ("degrees"); \ - plist_##_class.Add (param); } \ - - #define NAMED_ANGLE_EDITABLE_PARAM(_class, data, min, max, name) { \ - AngleParameterClass *param = W3DNEW AngleParameterClass( &data, #data); \ - param->Set_Range (min, max); \ - param->Set_Units_Name ("degrees"); \ - param->Set_Name(name); \ - plist_##_class.Add (param); } \ - - #define GENERIC_EDITABLE_PARAM(_class, param) \ - plist_##_class.Add (param); \ - - #define MODEL_DEF_PARAM(_class, data, name) { \ - ModelDefParameterClass *param = W3DNEW ModelDefParameterClass (&data); \ - param->Set_Name (#data); \ - param->Set_Base_Class (name); \ - GENERIC_EDITABLE_PARAM(_class, param); } - - #define PHYS_DEF_PARAM(_class, data, name) { \ - PhysDefParameterClass *param = W3DNEW PhysDefParameterClass (&data); \ - param->Set_Name (#data); \ - param->Set_Base_Class (name); \ - GENERIC_EDITABLE_PARAM(_class, param); } - - #define SCRIPT_PARAM(_class, name, params) { \ - ScriptParameterClass *param = W3DNEW ScriptParameterClass (&name, ¶ms); \ - param->Set_Name (#name); \ - GENERIC_EDITABLE_PARAM(_class, param); } - - #define SCRIPTLIST_PARAM(_class, name, name_list, param_list) { \ - ScriptListParameterClass *param = W3DNEW ScriptListParameterClass (&name_list, ¶m_list); \ - param->Set_Name (name); \ - GENERIC_EDITABLE_PARAM(_class, param); } - - #define ENUM_PARAM(_class, data, params) { \ - EnumParameterClass *param = W3DNEW EnumParameterClass (&data); \ - param->Set_Name (#data); \ - param->Add_Values params; \ - plist_##_class.Add (param); } \ - - #define FILENAME_PARAM(_class, data, desc, extension) { \ - FilenameParameterClass *param = W3DNEW FilenameParameterClass (&data); \ - param->Set_Name (#data); \ - param->Set_Description (desc); \ - param->Set_Extension (extension); \ - plist_##_class.Add (param); } \ - - #define NAMED_FILENAME_PARAM(_class, data, name, desc, extension) { \ - FilenameParameterClass *param = new FilenameParameterClass (&data); \ - param->Set_Name (name); \ - param->Set_Description (desc); \ - param->Set_Extension (extension); \ - plist_##_class.Add (param); } \ - - #define TEXTURE_FILENAME_PARAM(_class, data, desc, extension) { \ - TextureFilenameParameterClass *param = new TextureFilenameParameterClass (&data); \ - param->Set_Name (#data); \ - param->Set_Description (desc); \ - param->Set_Extension (extension); \ - plist_##_class.Add (param); } \ - - #define NAMED_TEXTURE_FILENAME_PARAM(_class, data, name, desc, extension) { \ - TextureFilenameParameterClass *param = new TextureFilenameParameterClass (&data); \ - param->Set_Name (name); \ - param->Set_Description (desc); \ - param->Set_Extension (extension); \ - plist_##_class.Add (param); } \ - - #define DEFIDLIST_PARAM(_class, data, root_class_id) { \ - DefIDListParameterClass *param = W3DNEW DefIDListParameterClass (&data); \ - param->Set_Name (#data); \ - param->Set_Class_ID (root_class_id); \ - plist_##_class.Add (param); } \ - - #define CLASSID_DEFIDLIST_PARAM(_class, data, root_class_id, class_id, name) { \ - DefIDListParameterClass *param = W3DNEW DefIDListParameterClass (&data); \ - param->Set_Name (name); \ - param->Set_Class_ID (root_class_id); \ - param->Set_Selected_Class_ID (&class_id); \ - plist_##_class.Add (param); } - - #define ZONE_PARAM(_class, data, name) { \ - ZoneParameterClass *param = W3DNEW ZoneParameterClass (&data); \ - param->Set_Name (name); \ - GENERIC_EDITABLE_PARAM(_class, param); } - - #define PARAM_SEPARATOR(_class, name) { \ - SeparatorParameterClass *param = W3DNEW SeparatorParameterClass; \ - param->Set_Name (name); \ - GENERIC_EDITABLE_PARAM(_class, param); } - - #define GENERIC_DEFID_PARAM(_class, data, root_class_id) { \ - GenericDefParameterClass *param = W3DNEW GenericDefParameterClass (&data); \ - param->Set_Class_ID (root_class_id); \ - param->Set_Name (#data); \ - plist_##_class.Add (param); } - - -#else - - #define DECLARE_EDITABLE(_class, _parent) - #define EDITABLE_PARAM(_class, type, data) - #define NAMED_EDITABLE_PARAM(_class, type, data, name) - #define INT_EDITABLE_PARAM(_class, data, min, max) - #define INT_UNITS_PARAM(_class, data, min, max, unitsname) - #define NAMED_INT_UNITS_PARAM(_class,data,min,max,unitsname,name) - #define FLOAT_EDITABLE_PARAM(_class, data, min, max) - #define FLOAT_UNITS_PARAM(_class, data, min, max, unitsname) - #define NAMED_FLOAT_UNITS_PARAM(_class, data, min, max, unitsname,name) - #define ANGLE_EDITABLE_PARAM(_class, data, min, max) - #define NAMED_ANGLE_EDITABLE_PARAM(_class, data, min, max, name) - #define GENERIC_EDITABLE_PARAM(_class, param) - #define MODEL_DEF_PARAM(_class, data, name) - #define PHYS_DEF_PARAM(_class, data, name) - #define SCRIPT_PARAM(_class, name, params) - #define SCRIPTLIST_PARAM(_class, name, name_list, param_list) - #define ENUM_PARAM(_class, data, params) - #define FILENAME_PARAM(_class, data, desc, extension) - #define NAMED_FILENAME_PARAM(_class, data, name, desc, extension) - #define TEXTURE_FILENAME_PARAM(_class, data, desc, extension) - #define NAMED_TEXTURE_FILENAME_PARAM(_class, data, name, desc, extension) - #define DEFIDLIST_PARAM(_class, data, root_class_id) - #define CLASSID_DEFIDLIST_PARAM(_class, data, root_class_id, class_id, name) - #define ZONE_PARAM(_class, data, name) - #define PARAM_SEPARATOR(_class, name) - #define GENERIC_DEFID_PARAM(_class, data, root_class_id) - -#endif //PARAM_EDITING_ON diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp deleted file mode 100644 index 26e8ef21ff0..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp +++ /dev/null @@ -1,2184 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/parameter.cpp $* - * * - * Org Author:: Patrick Smith * - * * - * Author:: Kenny Mitchell * - * * - * $Modtime:: 5/29/02 11:00a $* - * * - * $Revision:: 33 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "parameter.h" -#include "parametertypes.h" -#include "simpleparameter.h" -#include "WWLib/wwstring.h" -#include "definitionclassids.h" - - -///////////////////////////////////////////////////////////////////// -// -// Construct -// -// This is a virtual constructor that is capable of creating a new -// instance of any type of parameter used in the Editable system. -// -///////////////////////////////////////////////////////////////////// -ParameterClass * -ParameterClass::Construct (Type type, void *data, const char *name) -{ - ParameterClass *new_param = nullptr; - switch (type) { - - case TYPE_INT: - new_param = W3DNEW IntParameterClass (data, name); - break; - - case TYPE_FLOAT: - new_param = W3DNEW FloatParameterClass (data, name); - break; - - case TYPE_VECTOR2: - new_param = W3DNEW Vector2ParameterClass (data, name); - break; - - case TYPE_VECTOR3: - new_param = W3DNEW Vector3ParameterClass (data, name); - break; - - case TYPE_RECT: - new_param = W3DNEW RectParameterClass (data, name); - break; - - case TYPE_COLOR: - new_param = W3DNEW ColorParameterClass (data, name); - break; - - case TYPE_MATRIX3D: - new_param = W3DNEW Matrix3DParameterClass (data, name); - break; - - case TYPE_BOOL: - new_param = W3DNEW BoolParameterClass (data, name); - break; - - case TYPE_STRINGSDB_ID: - new_param = W3DNEW StringsDBEntryParameterClass (data, name); - break; - - case TYPE_ANGLE: - new_param = W3DNEW AngleParameterClass (data, name); - break; - - case TYPE_STRING: - new_param = W3DNEW StringParameterClass ((StringClass *)data); - new_param->Set_Name (name); - break; - - case TYPE_FILENAME: - new_param = W3DNEW FilenameParameterClass ((StringClass *)data); - new_param->Set_Name (name); - break; - - case TYPE_TEXTURE_FILENAME: - new_param = new TextureFilenameParameterClass ((StringClass *)data); - new_param->Set_Name (name); - break; - - case TYPE_SOUND_FILENAME: - new_param = W3DNEW SoundFilenameParameterClass ((StringClass *)data); - new_param->Set_Name (name); - break; - - case TYPE_ENUM: - new_param = W3DNEW EnumParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_GENERICDEFINITIONID: - new_param = W3DNEW GenericDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_GAMEOBJDEFINITIONID: - new_param = W3DNEW GameObjDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_WEAPONOBJDEFINITIONID: - new_param = W3DNEW WeaponObjDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_AMMOOBJDEFINITIONID: - new_param = W3DNEW AmmoObjDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_EXPLOSIONDEFINITIONID: - new_param = W3DNEW ExplosionObjDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_SOUNDDEFINITIONID: - new_param = W3DNEW SoundDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_MODELDEFINITIONID: - new_param = W3DNEW ModelDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_PHYSDEFINITIONID: - new_param = W3DNEW PhysDefParameterClass ((int *)data); - new_param->Set_Name (name); - break; - - case TYPE_DEFINITIONIDLIST: - new_param = W3DNEW DefIDListParameterClass ((DynamicVectorClass *)data); - new_param->Set_Name (name); - ((DefIDListParameterClass *)new_param)->Set_Class_ID (CLASSID_GAME_OBJECTS); - break; - - case TYPE_ZONE: - new_param = W3DNEW ZoneParameterClass ((OBBoxClass *)data); - new_param->Set_Name (name); - break; - - case TYPE_FILENAMELIST: - new_param = W3DNEW FilenameListParameterClass ((DynamicVectorClass *)data); - new_param->Set_Name (name); - break; - - case TYPE_SEPARATOR: - new_param = W3DNEW SeparatorParameterClass; - new_param->Set_Name (name); - break; - } - - return new_param; -} - -//*******************************************************************************************// -// -// Start of StringParameterClass -// -//*******************************************************************************************// - -///////////////////////////////////////////////////////////////////// -// -// StringParameterClass -// -///////////////////////////////////////////////////////////////////// -StringParameterClass::StringParameterClass (StringClass *string) - : m_String (string) -{ -} - -///////////////////////////////////////////////////////////////////// -// -// StringParameterClass -// -///////////////////////////////////////////////////////////////////// -StringParameterClass::StringParameterClass (const StringParameterClass &src) - : m_String (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const StringParameterClass & -StringParameterClass::operator= (const StringParameterClass &src) -{ - m_String = src.m_String; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -StringParameterClass::operator== (const StringParameterClass &src) -{ - bool retval = false; - - if (m_String != nullptr && src.m_String != nullptr && - (m_String->Compare (*(src.m_String)) == 0)) { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -StringParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = StringParameterClass::operator== ((const StringParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -StringParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_STRING)) { - (*m_String) = ((StringParameterClass &)src).Get_String (); - } - - ParameterClass::Copy_Value (src); -} - - -///////////////////////////////////////////////////////////////////// -// -// Get_String -// -///////////////////////////////////////////////////////////////////// -const char * -StringParameterClass::Get_String () const -{ - const char * string = nullptr; - if (m_String != nullptr) { - string = (*m_String); - } - return string; -} - - -///////////////////////////////////////////////////////////////////// -// -// Set_String -// -///////////////////////////////////////////////////////////////////// -void -StringParameterClass::Set_String (const char * string) -{ - if (m_String != nullptr) { - Set_Modified (); - (*m_String) = string; - } -} - - -//*******************************************************************************************// -// -// Start of FilenameParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// FilenameParameterClass -// -///////////////////////////////////////////////////////////////////// -FilenameParameterClass::FilenameParameterClass (StringClass *string) - : StringParameterClass (string) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// FilenameParameterClass -// -///////////////////////////////////////////////////////////////////// -FilenameParameterClass::FilenameParameterClass (const FilenameParameterClass &src) - : StringParameterClass (src) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const FilenameParameterClass & -FilenameParameterClass::operator= (const FilenameParameterClass &src) -{ - StringParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -FilenameParameterClass::operator== (const FilenameParameterClass &src) -{ - return StringParameterClass::operator== (src); -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -FilenameParameterClass::operator== (const ParameterClass &src) -{ - return StringParameterClass::operator== (src); -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -FilenameParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_FILENAME)) { - Set_String (((FilenameParameterClass &)src).Get_String ()); - } - - StringParameterClass::Copy_Value (src); -} - -//*******************************************************************************************// -// -// Start of TextureFilenameParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// TextureFilenameParameterClass -// -///////////////////////////////////////////////////////////////////// -TextureFilenameParameterClass::TextureFilenameParameterClass (StringClass *string) -: FilenameParameterClass (string), - Show_Alpha(false), - Show_Texture(false) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// TextureFilenameParameterClass -// -///////////////////////////////////////////////////////////////////// -TextureFilenameParameterClass::TextureFilenameParameterClass (const TextureFilenameParameterClass &src) -: FilenameParameterClass (src), - Show_Alpha(false), - Show_Texture(false) -{ -} - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void TextureFilenameParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_TEXTURE_FILENAME)) - { - Set_String (((FilenameParameterClass &)src).Get_String ()); - } - - StringParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of SoundFilenameParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// SoundFilenameParameterClass -// -///////////////////////////////////////////////////////////////////// -SoundFilenameParameterClass::SoundFilenameParameterClass (StringClass *string) - : FilenameParameterClass (string) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// SoundFilenameParameterClass -// -///////////////////////////////////////////////////////////////////// -SoundFilenameParameterClass::SoundFilenameParameterClass (const SoundFilenameParameterClass &src) - : FilenameParameterClass (src) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const SoundFilenameParameterClass & -SoundFilenameParameterClass::operator= (const SoundFilenameParameterClass &src) -{ - FilenameParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -SoundFilenameParameterClass::operator== (const SoundFilenameParameterClass &src) -{ - return FilenameParameterClass::operator== (src); -} - - - -//*******************************************************************************************// -// -// Start of EnumParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// EnumParameterClass -// -///////////////////////////////////////////////////////////////////// -EnumParameterClass::EnumParameterClass (int *value) - : m_Value (value) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// EnumParameterClass -// -///////////////////////////////////////////////////////////////////// -EnumParameterClass::EnumParameterClass (const EnumParameterClass &src) - : m_Value (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const EnumParameterClass & -EnumParameterClass::operator= (const EnumParameterClass &src) -{ - m_List.Delete_All (); - - m_Value = src.m_Value; - m_List = src.m_List; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -EnumParameterClass::operator== (const EnumParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -EnumParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = EnumParameterClass::operator== ((const EnumParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -EnumParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_ENUM)) { - (*m_Value) = ((EnumParameterClass &)src).Get_Selected_Value (); - } - - ParameterClass::Copy_Value (src); -} - - -///////////////////////////////////////////////////////////////////// -// -// Add_Value -// -///////////////////////////////////////////////////////////////////// -void -EnumParameterClass::Add_Value (const char *display_name, int value) -{ - m_List.Add (ENUM_VALUE(display_name, value)); -} - - -///////////////////////////////////////////////////////////////////// -// -// Add_Value -// -///////////////////////////////////////////////////////////////////// -void __cdecl -EnumParameterClass::Add_Values (const char *first_name, int first_value, ...) -{ - m_List.Add (ENUM_VALUE(first_name, first_value)); - - va_list arg_list; - va_start (arg_list, first_value); - - // - // Add all the params on the stack (until we found - // the terminator) - // - bool more_params = true; - while (more_params) { - - // - // Get the string param - // - const char *name = va_arg (arg_list, const char *); - if (name == nullptr) { - more_params = false; - } else { - - // - // Add the string/id pair to the enum list - // - int value = va_arg (arg_list, int); - m_List.Add (ENUM_VALUE(name, value)); - } - } - - va_end (arg_list); -} - - - -//*******************************************************************************************// -// -// Start of PhysDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// PhysDefParameterClass -// -///////////////////////////////////////////////////////////////////// -PhysDefParameterClass::PhysDefParameterClass (int *id) - : m_Value (id) -{ -} - -///////////////////////////////////////////////////////////////////// -// -// PhysDefParameterClass -// -///////////////////////////////////////////////////////////////////// -PhysDefParameterClass::PhysDefParameterClass (const PhysDefParameterClass &src) - : m_Value (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const PhysDefParameterClass & -PhysDefParameterClass::operator= (const PhysDefParameterClass &src) -{ - m_Value = src.m_Value; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -PhysDefParameterClass::operator== (const PhysDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -PhysDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = PhysDefParameterClass::operator== ((const PhysDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -PhysDefParameterClass::Copy_Value (const ParameterClass &/*src*/) -{ - // - // We don't allow the value to be copied - // -} - - -//*******************************************************************************************// -// -// Start of ModelDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// ModelDefParameterClass -// -///////////////////////////////////////////////////////////////////// -ModelDefParameterClass::ModelDefParameterClass (int *id) - : m_Value (id) -{ -} - -///////////////////////////////////////////////////////////////////// -// -// ModelDefParameterClass -// -///////////////////////////////////////////////////////////////////// -ModelDefParameterClass::ModelDefParameterClass (const ModelDefParameterClass &src) - : m_Value (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const ModelDefParameterClass & -ModelDefParameterClass::operator= (const ModelDefParameterClass &src) -{ - m_Value = src.m_Value; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ModelDefParameterClass::operator== (const ModelDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ModelDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = ModelDefParameterClass::operator== ((const ModelDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -ModelDefParameterClass::Copy_Value (const ParameterClass &/*src*/) -{ - // - // We don't allow the value to be copied - // -} - - -//*******************************************************************************************// -// -// Start of DefParameterClass -// -//*******************************************************************************************// - -///////////////////////////////////////////////////////////////////// -// -// DefParameterClass -// -///////////////////////////////////////////////////////////////////// -DefParameterClass::DefParameterClass (int *id) - : m_Value (id) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// DefParameterClass -// -///////////////////////////////////////////////////////////////////// -DefParameterClass::DefParameterClass (const DefParameterClass &src) - : m_Value (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const DefParameterClass & -DefParameterClass::operator= (const DefParameterClass &src) -{ - m_Value = src.m_Value; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -DefParameterClass::operator== (const DefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -DefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = DefParameterClass::operator== ((const DefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -DefParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Get_Type () == Get_Type ()) { - (*m_Value) = ((DefParameterClass &)src).Get_Value (); - } - - ParameterClass::Copy_Value (src); -} - - - -//*******************************************************************************************// -// -// Start of GenericDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// GenericDefParameterClass -// -///////////////////////////////////////////////////////////////////// -GenericDefParameterClass::GenericDefParameterClass (int *id) - : m_ClassID (0), - DefParameterClass (id) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// GenericDefParameterClass -// -///////////////////////////////////////////////////////////////////// -GenericDefParameterClass::GenericDefParameterClass (const GenericDefParameterClass &src) - : m_ClassID (0), - DefParameterClass (src) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const GenericDefParameterClass & -GenericDefParameterClass::operator= (const GenericDefParameterClass &src) -{ - DefParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -GenericDefParameterClass::operator== (const GenericDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -GenericDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = GenericDefParameterClass::operator== ((const GenericDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -GenericDefParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_GENERICDEFINITIONID)) { - (*m_Value) = ((GenericDefParameterClass &)src).Get_Value (); - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of GameObjDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// GameObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -GameObjDefParameterClass::GameObjDefParameterClass (int *id) - : DefParameterClass (id) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// GameObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -GameObjDefParameterClass::GameObjDefParameterClass (const GameObjDefParameterClass &src) - : DefParameterClass (src) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const GameObjDefParameterClass & -GameObjDefParameterClass::operator= (const GameObjDefParameterClass &src) -{ - DefParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -GameObjDefParameterClass::operator== (const GameObjDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -GameObjDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = GameObjDefParameterClass::operator== ((const GameObjDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -GameObjDefParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_GAMEOBJDEFINITIONID)) { - (*m_Value) = ((GameObjDefParameterClass &)src).Get_Value (); - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of WeaponObjDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// WeaponObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -WeaponObjDefParameterClass::WeaponObjDefParameterClass (int *id) - : GameObjDefParameterClass (id) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// WeaponObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -WeaponObjDefParameterClass::WeaponObjDefParameterClass (const WeaponObjDefParameterClass &src) - : GameObjDefParameterClass (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const WeaponObjDefParameterClass & -WeaponObjDefParameterClass::operator= (const WeaponObjDefParameterClass &src) -{ - m_Value = src.m_Value; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -WeaponObjDefParameterClass::operator== (const WeaponObjDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -WeaponObjDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = WeaponObjDefParameterClass::operator== ((const WeaponObjDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -WeaponObjDefParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_WEAPONOBJDEFINITIONID)) { - (*m_Value) = ((WeaponObjDefParameterClass &)src).Get_Value (); - } - - GameObjDefParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of AmmoObjDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// AmmoObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -AmmoObjDefParameterClass::AmmoObjDefParameterClass (int *id) - : GameObjDefParameterClass (id) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// AmmoObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -AmmoObjDefParameterClass::AmmoObjDefParameterClass (const AmmoObjDefParameterClass &src) - : GameObjDefParameterClass (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const AmmoObjDefParameterClass & -AmmoObjDefParameterClass::operator= (const AmmoObjDefParameterClass &src) -{ - m_Value = src.m_Value; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -AmmoObjDefParameterClass::operator== (const AmmoObjDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -AmmoObjDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = AmmoObjDefParameterClass::operator== ((const AmmoObjDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -AmmoObjDefParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_AMMOOBJDEFINITIONID)) { - (*m_Value) = ((AmmoObjDefParameterClass &)src).Get_Value (); - } - - GameObjDefParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of ExplosionObjDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// ExplosionObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -ExplosionObjDefParameterClass::ExplosionObjDefParameterClass (int *id) - : GameObjDefParameterClass (id) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// ExplosionObjDefParameterClass -// -///////////////////////////////////////////////////////////////////// -ExplosionObjDefParameterClass::ExplosionObjDefParameterClass (const ExplosionObjDefParameterClass &src) - : GameObjDefParameterClass (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const ExplosionObjDefParameterClass & -ExplosionObjDefParameterClass::operator= (const ExplosionObjDefParameterClass &src) -{ - m_Value = src.m_Value; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ExplosionObjDefParameterClass::operator== (const ExplosionObjDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ExplosionObjDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = ExplosionObjDefParameterClass::operator== ((const ExplosionObjDefParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -ExplosionObjDefParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_AMMOOBJDEFINITIONID)) { - (*m_Value) = ((ExplosionObjDefParameterClass &)src).Get_Value (); - } - - GameObjDefParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of SoundDefParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// SoundDefParameterClass -// -///////////////////////////////////////////////////////////////////// -SoundDefParameterClass::SoundDefParameterClass (int *id) - : DefParameterClass (id) -{ -} - -///////////////////////////////////////////////////////////////////// -// -// SoundDefParameterClass -// -///////////////////////////////////////////////////////////////////// -SoundDefParameterClass::SoundDefParameterClass (const SoundDefParameterClass &src) - : DefParameterClass (src) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const SoundDefParameterClass & -SoundDefParameterClass::operator= (const SoundDefParameterClass &src) -{ - DefParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -SoundDefParameterClass::operator== (const SoundDefParameterClass &src) -{ - bool retval = false; - - if (m_Value != nullptr && src.m_Value != nullptr && - (*m_Value) == (*src.m_Value)) - { - retval = true; - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -SoundDefParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = SoundDefParameterClass::operator== ((const SoundDefParameterClass &)src); - } - - return retval; -} - - -//*******************************************************************************************// -// -// Start of ScriptParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// ScriptParameterClass -// -///////////////////////////////////////////////////////////////////// -ScriptParameterClass::ScriptParameterClass (StringClass *name, StringClass *params) - : m_ScriptName (name), - m_ScriptParams (params) -{ -} - -///////////////////////////////////////////////////////////////////// -// -// ScriptParameterClass -// -///////////////////////////////////////////////////////////////////// -ScriptParameterClass::ScriptParameterClass (const ScriptParameterClass &src) - : m_ScriptName (nullptr), - m_ScriptParams (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const ScriptParameterClass & -ScriptParameterClass::operator= (const ScriptParameterClass &src) -{ - m_ScriptName = src.m_ScriptName; - m_ScriptParams = src.m_ScriptParams; - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ScriptParameterClass::operator== (const ScriptParameterClass &src) -{ - bool retval = false; - - // - // Data valid? - // - if ( (m_ScriptName != nullptr) && (src.m_ScriptName != nullptr) && - (m_ScriptParams != nullptr) && (src.m_ScriptParams != nullptr)) - { - - // - // Simple string compares should workd - // - if ( (m_ScriptName->Compare (*(src.m_ScriptName)) == 0) && - (m_ScriptParams->Compare (*(src.m_ScriptParams)) == 0)) - { - retval = true; - } - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ScriptParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = ScriptParameterClass::operator== ((const ScriptParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -ScriptParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_SCRIPT)) { - (*m_ScriptName) = ((ScriptParameterClass &)src).Get_Script_Name (); - (*m_ScriptParams) = ((ScriptParameterClass &)src).Get_Params (); - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of DefIDListParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// DefIDListParameterClass -// -///////////////////////////////////////////////////////////////////// -DefIDListParameterClass::DefIDListParameterClass (DynamicVectorClass *list) - : m_IDList (list), - m_ClassID (0), - m_SelectedClassID (nullptr) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// DefIDListParameterClass -// -///////////////////////////////////////////////////////////////////// -DefIDListParameterClass::DefIDListParameterClass (const DefIDListParameterClass &src) - : m_IDList (nullptr), - m_ClassID (0), - m_SelectedClassID (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const DefIDListParameterClass & -DefIDListParameterClass::operator= (const DefIDListParameterClass &src) -{ - m_IDList = src.m_IDList; - m_ClassID = src.m_ClassID; - m_SelectedClassID = src.m_SelectedClassID; - - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -DefIDListParameterClass::operator== (const DefIDListParameterClass &src) -{ - bool retval = false; - - // - // Data valid? - // - if ((m_IDList != nullptr) && (src.m_IDList != nullptr)) - { - // - // Class IDs the same? - // - if (m_ClassID == src.m_ClassID) { - - int count1 = m_IDList->Count (); - int count2 = src.m_IDList->Count (); - - // - // Are the lists the same? - // - retval = (count1 == count2); - for (int index = 0; (index < count1) && retval; index ++) { - int value1 = (*m_IDList)[index]; - int value2 = (*src.m_IDList)[index]; - retval &= (value1 == value2); - } - } - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -DefIDListParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = DefIDListParameterClass::operator== ((const DefIDListParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -DefIDListParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_DEFINITIONIDLIST)) { - DefIDListParameterClass real_src = (DefIDListParameterClass &)src; - - m_ClassID = real_src.m_ClassID; - (*m_IDList) = (*real_src.m_IDList); - - if (m_SelectedClassID != nullptr && real_src.m_SelectedClassID != nullptr) { - (*m_SelectedClassID) = (*real_src.m_SelectedClassID); - } - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of ZoneParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// ZoneParameterClass -// -///////////////////////////////////////////////////////////////////// -ZoneParameterClass::ZoneParameterClass (OBBoxClass *box) - : m_OBBox (box) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// ZoneParameterClass -// -///////////////////////////////////////////////////////////////////// -ZoneParameterClass::ZoneParameterClass (const ZoneParameterClass &src) - : m_OBBox (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const ZoneParameterClass & -ZoneParameterClass::operator= (const ZoneParameterClass &src) -{ - m_OBBox = src.m_OBBox; - - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ZoneParameterClass::operator== (const ZoneParameterClass &src) -{ - bool retval = false; - - // - // Are the OBBoxes the same? - // - if ((m_OBBox != nullptr) && (src.m_OBBox != nullptr)) { - retval = (*m_OBBox) == (*src.m_OBBox); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ZoneParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = ZoneParameterClass::operator== ((const ZoneParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -ZoneParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_ZONE)) { - ZoneParameterClass real_src = (ZoneParameterClass &)src; - - (*m_OBBox) = (*real_src.m_OBBox); - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of FilenameListParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// FilenameListParameterClass -// -///////////////////////////////////////////////////////////////////// -FilenameListParameterClass::FilenameListParameterClass (DynamicVectorClass *list) - : m_FilenameList (list) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// FilenameListParameterClass -// -///////////////////////////////////////////////////////////////////// -FilenameListParameterClass::FilenameListParameterClass (const FilenameListParameterClass &src) - : m_FilenameList (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const FilenameListParameterClass & -FilenameListParameterClass::operator= (const FilenameListParameterClass &src) -{ - m_FilenameList = src.m_FilenameList; - - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -FilenameListParameterClass::operator== (const FilenameListParameterClass &src) -{ - bool retval = false; - - // - // Data valid? - // - if ((m_FilenameList != nullptr) && (src.m_FilenameList != nullptr)) - { - int count1 = m_FilenameList->Count (); - int count2 = src.m_FilenameList->Count (); - - // - // Are the lists the same? - // - retval = (count1 == count2); - for (int index = 0; (index < count1) && retval; index ++) { - StringClass &filename1 = (*m_FilenameList)[index]; - StringClass &filename2 = (*src.m_FilenameList)[index]; - retval &= (::stricmp (filename1, filename2) == 0); - } - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -FilenameListParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = FilenameListParameterClass::operator== ((const FilenameListParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -FilenameListParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_FILENAMELIST)) { - FilenameListParameterClass real_src = (FilenameListParameterClass &)src; - (*m_FilenameList) = (*real_src.m_FilenameList); - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of ScriptListParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// ScriptListParameterClass -// -///////////////////////////////////////////////////////////////////// -ScriptListParameterClass::ScriptListParameterClass -( - DynamicVectorClass *name_list, - DynamicVectorClass *param_list -) - : m_NameList (name_list), - m_ParamList (param_list) -{ -} - - -///////////////////////////////////////////////////////////////////// -// -// ScriptListParameterClass -// -///////////////////////////////////////////////////////////////////// -ScriptListParameterClass::ScriptListParameterClass (const ScriptListParameterClass &src) - : m_NameList (nullptr), - m_ParamList (nullptr) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const ScriptListParameterClass & -ScriptListParameterClass::operator= (const ScriptListParameterClass &src) -{ - m_NameList = src.m_NameList; - m_ParamList = src.m_ParamList; - - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ScriptListParameterClass::operator== (const ScriptListParameterClass &src) -{ - bool retval = false; - - // - // Data valid? - // - if ( (m_NameList != nullptr) && (src.m_NameList != nullptr) && - (m_ParamList != nullptr) && (src.m_ParamList != nullptr)) - { - retval = Are_Lists_Identical (*m_NameList, *(src.m_NameList)); - retval &= Are_Lists_Identical (*m_ParamList, *(src.m_ParamList)); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Are_Lists_Identical -// -///////////////////////////////////////////////////////////////////// -bool -ScriptListParameterClass::Are_Lists_Identical -( - DynamicVectorClass &list1, - DynamicVectorClass &list2 -) -{ - int count1 = list1.Count (); - int count2 = list2.Count (); - - // - // Do a string compare on every entry - // - bool retval = (count1 == count2); - for (int index = 0; (index < count1) && retval; index ++) { - StringClass &string1 = list1[index]; - StringClass &string2 = list2[index]; - retval &= (::stricmp (string1, string2) == 0); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -ScriptListParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = ScriptListParameterClass::operator== ((const ScriptListParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -ScriptListParameterClass::Copy_Value (const ParameterClass &src) -{ - if (src.Is_Type (ParameterClass::TYPE_SCRIPTLIST)) { - ScriptListParameterClass &real_src = (ScriptListParameterClass &)src; - (*m_NameList) = (*real_src.m_NameList); - (*m_ParamList) = (*real_src.m_ParamList); - } - - ParameterClass::Copy_Value (src); -} - - -//*******************************************************************************************// -// -// Start of SeparatorParameterClass -// -//*******************************************************************************************// - - -///////////////////////////////////////////////////////////////////// -// -// SeparatorParameterClass -// -///////////////////////////////////////////////////////////////////// -SeparatorParameterClass::SeparatorParameterClass (const SeparatorParameterClass &src) -{ - (*this) = src; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator= -// -///////////////////////////////////////////////////////////////////// -const SeparatorParameterClass & -SeparatorParameterClass::operator= (const SeparatorParameterClass &src) -{ - ParameterClass::operator= (src); - return *this; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -SeparatorParameterClass::operator== (const SeparatorParameterClass &src) -{ - return true; -} - - -///////////////////////////////////////////////////////////////////// -// -// operator== -// -///////////////////////////////////////////////////////////////////// -bool -SeparatorParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - - if (src.Get_Type () == Get_Type ()) { - retval = SeparatorParameterClass::operator== ((const SeparatorParameterClass &)src); - } - - return retval; -} - - -///////////////////////////////////////////////////////////////////// -// -// Copy_Value -// -///////////////////////////////////////////////////////////////////// -void -SeparatorParameterClass::Copy_Value (const ParameterClass &src) -{ - ParameterClass::Copy_Value (src); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h deleted file mode 100644 index c7838c49bad..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h +++ /dev/null @@ -1,1139 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/parameter.h $* - * * - * Org Author:: Patrick Smith * - * * - * Author:: Kenny Mitchell * - * * - * $Modtime:: 5/29/02 11:00a $* - * * - * $Revision:: 38 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include -#include "parametertypes.h" -#include "WWLib/Vector.h" -#include "WWLib/wwstring.h" -#include "WWLib/bittype.h" -#include "WWMath/obbox.h" - - -////////////////////////////////////////////////////////////////////////////////// -// Forward declarations -////////////////////////////////////////////////////////////////////////////////// -class DefParameterClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// ParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class ParameterClass -{ -public: - - typedef enum - { - TYPE_INT = 0, - TYPE_FLOAT, - TYPE_STRING, - TYPE_VECTOR3, - TYPE_MATRIX3D, - TYPE_BOOL, - TYPE_TRANSITION, - TYPE_MODELDEFINITIONID, - TYPE_FILENAME, - TYPE_ENUM, - TYPE_GAMEOBJDEFINITIONID, - TYPE_SCRIPT, - TYPE_SOUND_FILENAME, - TYPE_ANGLE, - TYPE_WEAPONOBJDEFINITIONID, - TYPE_AMMOOBJDEFINITIONID, - TYPE_SOUNDDEFINITIONID, - TYPE_COLOR, - TYPE_PHYSDEFINITIONID, - TYPE_EXPLOSIONDEFINITIONID, - TYPE_DEFINITIONIDLIST, - TYPE_ZONE, - TYPE_FILENAMELIST, - TYPE_SEPARATOR, - TYPE_GENERICDEFINITIONID, - TYPE_SCRIPTLIST, - TYPE_VECTOR2, - TYPE_RECT, - TYPE_TEXTURE_FILENAME, - TYPE_STRINGSDB_ID - - } Type; - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - ParameterClass (); - ParameterClass (const ParameterClass &src); - virtual ~ParameterClass (); - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const ParameterClass & operator= (const ParameterClass &src); - virtual bool operator== (const ParameterClass &src) = 0; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // RTTI - virtual DefParameterClass * As_DefParameterClass () { return nullptr; } - - // Type identification (see paramtypes.h in wwsaveload) - virtual Type Get_Type () const = 0; - virtual bool Is_Type (Type type) const { return false; } - - // Modification - virtual bool Is_Modifed () const { return IsModified; } - virtual void Set_Modified (bool onoff = true) { IsModified = onoff; } - - // Display name methods - virtual const char * Get_Name () const; - virtual void Set_Name (const char *new_name); - - // Units display methods - virtual const char * Get_Units_Name () const; - virtual void Set_Units_Name (const char *units_name); - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) { }; - - ////////////////////////////////////////////////////////////////////////////// - // Static methods - ////////////////////////////////////////////////////////////////////////////// - - // Virtual constructor used to create a new instance of any parameter type - static ParameterClass * Construct (ParameterClass::Type type, void *data, const char *param_name); - -private: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - bool IsModified; - const char * m_Name; - StringClass m_UnitsName; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// ParameterClass -////////////////////////////////////////////////////////////////////////////////// -inline -ParameterClass::ParameterClass () - : m_Name (nullptr), - IsModified (false) -{ -} - -////////////////////////////////////////////////////////////////////////////////// -// ParameterClass -////////////////////////////////////////////////////////////////////////////////// -inline -ParameterClass::ParameterClass (const ParameterClass &src) - : m_Name (nullptr), - IsModified (false) -{ - (*this) = src; -} - -////////////////////////////////////////////////////////////////////////////////// -// ~ParameterClass -////////////////////////////////////////////////////////////////////////////////// -inline -ParameterClass::~ParameterClass () -{ - Set_Name (nullptr); -} - -////////////////////////////////////////////////////////////////////////////////// -// operator= -////////////////////////////////////////////////////////////////////////////////// -inline const ParameterClass & -ParameterClass::operator= (const ParameterClass &src) -{ - IsModified = src.IsModified; - Set_Name (src.m_Name); - return *this; -} - -////////////////////////////////////////////////////////////////////////////////// -// Get_Name -////////////////////////////////////////////////////////////////////////////////// -inline const char * -ParameterClass::Get_Name () const -{ - return m_Name; -} - -////////////////////////////////////////////////////////////////////////////////// -// Set_Name -////////////////////////////////////////////////////////////////////////////////// -inline void -ParameterClass::Set_Name (const char* new_name) -{ - char* name = new_name ? ::strdup(new_name) : nullptr; - ::free((void*)m_Name); - m_Name = name; -} - - -////////////////////////////////////////////////////////////////////////////////// -// Get_Units_Name -////////////////////////////////////////////////////////////////////////////////// -inline const char * -ParameterClass::Get_Units_Name () const -{ - return m_UnitsName; -} - -////////////////////////////////////////////////////////////////////////////////// -// Set_Units_Name -////////////////////////////////////////////////////////////////////////////////// -inline void -ParameterClass::Set_Units_Name (const char *new_name) -{ - m_UnitsName = new_name; -} - -////////////////////////////////////////////////////////////////////////////////// -// -// StringParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class StringParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - StringParameterClass (StringClass *string); - StringParameterClass (const StringParameterClass &src); - virtual ~StringParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const StringParameterClass & operator= (const StringParameterClass &src); - bool operator== (const StringParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_STRING; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_STRING) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual const char * Get_String () const; - virtual void Set_String (const char *string); - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - StringClass * m_String; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// FilenameParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class FilenameParameterClass : public StringParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - FilenameParameterClass (StringClass *string); - FilenameParameterClass (const FilenameParameterClass &src); - virtual ~FilenameParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const FilenameParameterClass & operator= (const FilenameParameterClass &src); - bool operator== (const FilenameParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_FILENAME; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_FILENAME) || StringParameterClass::Is_Type (type); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - - virtual void Set_Extension (const char *extension) { m_Extension = extension; } - virtual const char * Get_Extension () const { return m_Extension; } - - virtual void Set_Description (const char *desc) { m_Description = desc; } - virtual const char * Get_Description () const { return m_Description; } - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Protected member data - ////////////////////////////////////////////////////////////////////////////// - StringClass m_Extension; - StringClass m_Description; -}; - -////////////////////////////////////////////////////////////////////////////////// -// -// TextureFilenameParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class TextureFilenameParameterClass : public FilenameParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - TextureFilenameParameterClass(StringClass *string); - TextureFilenameParameterClass(const TextureFilenameParameterClass& src); - virtual ~TextureFilenameParameterClass() override {} - - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_TEXTURE_FILENAME; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_TEXTURE_FILENAME) || StringParameterClass::Is_Type (type); } - - void Set_Show_Alpha(bool show) { Show_Alpha=show; } - bool Get_Show_Alpha() const { return Show_Alpha; } - - void Set_Show_Texture(bool show) { Show_Texture=show; } - bool Get_Show_Texture() const { return Show_Texture; } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - bool Show_Alpha; - bool Show_Texture; -}; - - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundFilenameParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class SoundFilenameParameterClass : public FilenameParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - SoundFilenameParameterClass (StringClass *string); - SoundFilenameParameterClass (const SoundFilenameParameterClass &src); - virtual ~SoundFilenameParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const SoundFilenameParameterClass & operator= (const SoundFilenameParameterClass &src); - bool operator== (const SoundFilenameParameterClass &src); - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_SOUND_FILENAME; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_SOUND_FILENAME) || FilenameParameterClass::Is_Type (type); } -}; - -////////////////////////////////////////////////////////////////////////////////// -// -// EnumParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class EnumParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - EnumParameterClass (int *value); - EnumParameterClass (const EnumParameterClass &src); - virtual ~EnumParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const EnumParameterClass & operator= (const EnumParameterClass &src); - bool operator== (const EnumParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_ENUM; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_ENUM) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void __cdecl Add_Values (const char *first_name, int first_value, ...); - virtual void Add_Value (const char *display_name, int value); - virtual int Get_Count () const { return m_List.Count (); } - virtual const char * Get_Entry_Name (int index) const { return m_List[index].name; } - virtual int Get_Entry_Value (int index) const { return m_List[index].value; } - - virtual void Set_Selected_Value (int value) { (*m_Value) = value; Set_Modified (); } - virtual int Get_Selected_Value () const { return (*m_Value); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private data types - ////////////////////////////////////////////////////////////////////////////// - typedef struct _ENUM_VALUE - { - StringClass name; - int value; - - _ENUM_VALUE (const char *_name=nullptr, int _value=0) : name (_name), value (_value) {} - bool operator== (const _ENUM_VALUE &) { return false; } - bool operator!= (const _ENUM_VALUE &) { return true; } - } ENUM_VALUE; - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - DynamicVectorClass m_List; - int * m_Value; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// PhysDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class PhysDefParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - PhysDefParameterClass (int *id); - PhysDefParameterClass (const PhysDefParameterClass &src); - virtual ~PhysDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const PhysDefParameterClass & operator= (const PhysDefParameterClass &src); - bool operator== (const PhysDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_PHYSDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_PHYSDEFINITIONID) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void Set_Value (int id) { (*m_Value) = id; Set_Modified (); } - virtual int Get_Value () const { return (*m_Value); } - virtual void Set_Base_Class (const char *name) { m_BaseClass = name; } - virtual const char * Get_Base_Class () const { return m_BaseClass; } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - int * m_Value; - StringClass m_BaseClass; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// ModelDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class ModelDefParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - ModelDefParameterClass (int *id); - ModelDefParameterClass (const ModelDefParameterClass &src); - virtual ~ModelDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const ModelDefParameterClass & operator= (const ModelDefParameterClass &src); - bool operator== (const ModelDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_MODELDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_MODELDEFINITIONID) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void Set_Value (int id) { (*m_Value) = id; Set_Modified (); } - virtual int Get_Value () const { return (*m_Value); } - virtual void Set_Base_Class (const char *name) { m_BaseClass = name; } - virtual const char * Get_Base_Class () const { return m_BaseClass; } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - int * m_Value; - StringClass m_BaseClass; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// DefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class DefParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - DefParameterClass (int *id); - DefParameterClass (const DefParameterClass &src); - virtual ~DefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const DefParameterClass & operator= (const DefParameterClass &src); - bool operator== (const DefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // RTTI - virtual DefParameterClass * As_DefParameterClass () override { return this; } - - // Data manipulation - virtual void Set_Value (int id) { (*m_Value) = id; Set_Modified (); } - virtual int Get_Value () const { return (*m_Value); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - int * m_Value; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// GenericDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class GenericDefParameterClass : public DefParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - GenericDefParameterClass (int *id); - GenericDefParameterClass (const GenericDefParameterClass &src); - virtual ~GenericDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const GenericDefParameterClass & operator= (const GenericDefParameterClass &src); - bool operator== (const GenericDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_GENERICDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_GENERICDEFINITIONID) || ParameterClass::Is_Type (type); } - - // Class ID control - virtual void Set_Class_ID (int class_id) { m_ClassID = class_id; Set_Modified (); } - virtual int Get_Class_ID () const { return m_ClassID; } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - int m_ClassID; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// GameObjDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class GameObjDefParameterClass : public DefParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - GameObjDefParameterClass (int *id); - GameObjDefParameterClass (const GameObjDefParameterClass &src); - virtual ~GameObjDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const GameObjDefParameterClass & operator= (const GameObjDefParameterClass &src); - bool operator== (const GameObjDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_GAMEOBJDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_GAMEOBJDEFINITIONID) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void Set_Base_Class (const char *name) { m_BaseClass = name; Set_Modified (); } - virtual const char * Get_Base_Class () const { return m_BaseClass; } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - StringClass m_BaseClass; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// AmmoObjDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class AmmoObjDefParameterClass : public GameObjDefParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - AmmoObjDefParameterClass (int *id); - AmmoObjDefParameterClass (const AmmoObjDefParameterClass &src); - virtual ~AmmoObjDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const AmmoObjDefParameterClass & operator= (const AmmoObjDefParameterClass &src); - bool operator== (const AmmoObjDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_AMMOOBJDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_AMMOOBJDEFINITIONID) || GameObjDefParameterClass::Is_Type (type); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// WeaponObjDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class WeaponObjDefParameterClass : public GameObjDefParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - WeaponObjDefParameterClass (int *id); - WeaponObjDefParameterClass (const WeaponObjDefParameterClass &src); - virtual ~WeaponObjDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const WeaponObjDefParameterClass & operator= (const WeaponObjDefParameterClass &src); - bool operator== (const WeaponObjDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_WEAPONOBJDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_WEAPONOBJDEFINITIONID) || GameObjDefParameterClass::Is_Type (type); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// ExplosionObjDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class ExplosionObjDefParameterClass : public GameObjDefParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - ExplosionObjDefParameterClass (int *id); - ExplosionObjDefParameterClass (const ExplosionObjDefParameterClass &src); - virtual ~ExplosionObjDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const ExplosionObjDefParameterClass & operator= (const ExplosionObjDefParameterClass &src); - bool operator== (const ExplosionObjDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_EXPLOSIONDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_EXPLOSIONDEFINITIONID) || GameObjDefParameterClass::Is_Type (type); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; -}; - - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundDefParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class SoundDefParameterClass : public DefParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - SoundDefParameterClass (int *id); - SoundDefParameterClass (const SoundDefParameterClass &src); - virtual ~SoundDefParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const SoundDefParameterClass & operator= (const SoundDefParameterClass &src); - bool operator== (const SoundDefParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_SOUNDDEFINITIONID; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_SOUNDDEFINITIONID) || ParameterClass::Is_Type (type); } -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// ScriptParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class ScriptParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - ScriptParameterClass (StringClass *name, StringClass *params); - ScriptParameterClass (const ScriptParameterClass &src); - virtual ~ScriptParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const ScriptParameterClass & operator= (const ScriptParameterClass &src); - bool operator== (const ScriptParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_SCRIPT; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_SCRIPT) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void Set_Script_Name (const char *name) { (*m_ScriptName) = name; Set_Modified (); } - virtual const char * Get_Script_Name () const { return (*m_ScriptName); } - virtual void Set_Params (const char *params) { (*m_ScriptParams) = params; Set_Modified (); } - virtual const char * Get_Params () const { return (*m_ScriptParams); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - StringClass * m_ScriptName; - StringClass * m_ScriptParams; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// DefIDListParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class DefIDListParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - DefIDListParameterClass (DynamicVectorClass *list); - DefIDListParameterClass (const DefIDListParameterClass &src); - virtual ~DefIDListParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const DefIDListParameterClass & operator= (const DefIDListParameterClass &src); - bool operator== (const DefIDListParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_DEFINITIONIDLIST; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_DEFINITIONIDLIST) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void Set_Selected_Class_ID (uint32 *id) { m_SelectedClassID = id; } - virtual uint32 * Get_Selected_Class_ID () const { return m_SelectedClassID; } - virtual void Set_Class_ID (uint32 id) { m_ClassID = id; } - virtual uint32 Get_Class_ID () const { return m_ClassID; } - - virtual DynamicVectorClass &Get_List () const { return (*m_IDList); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - DynamicVectorClass * m_IDList; - uint32 m_ClassID; - uint32 * m_SelectedClassID; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// ZoneParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class ZoneParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - ZoneParameterClass (OBBoxClass *box); - ZoneParameterClass (const ZoneParameterClass &src); - virtual ~ZoneParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const ZoneParameterClass & operator= (const ZoneParameterClass &src); - bool operator== (const ZoneParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_ZONE; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_ZONE) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual void Set_Zone (const OBBoxClass &box) { (*m_OBBox) = box; Set_Modified (); } - virtual const OBBoxClass & Get_Zone () const { return (*m_OBBox); } - - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - OBBoxClass *m_OBBox; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// FilenameListParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class FilenameListParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - FilenameListParameterClass (DynamicVectorClass *list); - FilenameListParameterClass (const FilenameListParameterClass &src); - virtual ~FilenameListParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const FilenameListParameterClass & operator= (const FilenameListParameterClass &src); - bool operator== (const FilenameListParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_FILENAMELIST; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_FILENAMELIST) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual DynamicVectorClass &Get_List () const { return (*m_FilenameList); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - DynamicVectorClass * m_FilenameList; -}; - - - -////////////////////////////////////////////////////////////////////////////////// -// -// ScriptListParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class ScriptListParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - ScriptListParameterClass (DynamicVectorClass *name_list, DynamicVectorClass *param_list); - ScriptListParameterClass (const ScriptListParameterClass &src); - virtual ~ScriptListParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const ScriptListParameterClass & operator= (const ScriptListParameterClass &src); - bool operator== (const ScriptListParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_SCRIPTLIST; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_SCRIPTLIST) || ParameterClass::Is_Type (type); } - - // Data manipulation - virtual DynamicVectorClass &Get_Name_List () const { return (*m_NameList); } - virtual DynamicVectorClass &Get_Param_List () const { return (*m_ParamList); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; - -protected: - - ////////////////////////////////////////////////////////////////////////////// - // Protected members - ////////////////////////////////////////////////////////////////////////////// - bool Are_Lists_Identical (DynamicVectorClass &list1, DynamicVectorClass &list2); - - ////////////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////////////// - DynamicVectorClass * m_NameList; - DynamicVectorClass * m_ParamList; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// SeparatorParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -class SeparatorParameterClass : public ParameterClass -{ -public: - - ////////////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////////////// - SeparatorParameterClass () {} - SeparatorParameterClass (const SeparatorParameterClass &src); - virtual ~SeparatorParameterClass () override {} - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - const SeparatorParameterClass & operator= (const SeparatorParameterClass &src); - bool operator== (const SeparatorParameterClass &src); - virtual bool operator== (const ParameterClass &src) override; - - ////////////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////////////// - - // Type identification - virtual Type Get_Type () const override { return TYPE_SEPARATOR; } - virtual bool Is_Type (Type type) const override { return (type == TYPE_SEPARATOR) || ParameterClass::Is_Type (type); } - - // Copy methods - virtual void Copy_Value (const ParameterClass &src) override; -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h deleted file mode 100644 index cca68aff8ba..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/parameterlist.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 10/06/99 2:52p $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/Vector.h" -#include "parameter.h" -#include "WWDebug/wwdebug.h" - -////////////////////////////////////////////////////////////////////////////////// -// -// ParameterListClass -// -////////////////////////////////////////////////////////////////////////////////// -class ParameterListClass : public DynamicVectorClass -{ - using DynamicVectorClass::Vector; - -public: - - ///////////////////////////////////////////////////////////////////// - // Public constructurs/destructors - ///////////////////////////////////////////////////////////////////// - virtual ~ParameterListClass () override; - - ///////////////////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////////////////// - void Add (void *data, const char *param_name, ParameterClass::Type type); - void Add (ParameterClass *parameter); - -protected: - - ///////////////////////////////////////////////////////////////////// - // Protected methods - ///////////////////////////////////////////////////////////////////// - void Free_Parameters (); - -private: - - ///////////////////////////////////////////////////////////////////// - // Private member data - ///////////////////////////////////////////////////////////////////// - //DynamicVectorClass m_Parameters; -}; - - -///////////////////////////////////////////////////////////////////// -// ~ParameterListClass -///////////////////////////////////////////////////////////////////// -inline -ParameterListClass::~ParameterListClass () -{ - Free_Parameters (); -} - -///////////////////////////////////////////////////////////////////// -// Add -///////////////////////////////////////////////////////////////////// -inline void -ParameterListClass::Add (void *data, const char *param_name, ParameterClass::Type type) -{ - // - // Create a new parameter object - // - ParameterClass *new_param = ParameterClass::Construct (type, data, param_name); - - // - // Add the new parameter object to our list - // - WWASSERT (new_param != nullptr); - if (new_param != nullptr) { - DynamicVectorClass::Add (new_param); - } -} - -///////////////////////////////////////////////////////////////////// -// Add -///////////////////////////////////////////////////////////////////// -inline void -ParameterListClass::Add (ParameterClass *new_param) -{ - // - // Add the new parameter object to our list - // - if (new_param != nullptr) { - DynamicVectorClass::Add (new_param); - } -} - -///////////////////////////////////////////////////////////////////// -// Free_Parameters -///////////////////////////////////////////////////////////////////// -inline void -ParameterListClass::Free_Parameters () -{ - for (int index = 0; index < Count (); index ++) { - ParameterClass *param = Vector[index]; - - // - // Free the parameter object - // - delete param; - } - - Delete_All(); -// m_Parameters.Delete_All (); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h deleted file mode 100644 index 48f23362763..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/parametertypes.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 9/10/99 3:38p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" - -////////////////////////////////////////////////////////////////////////////////// -// -// ParameterType -// -////////////////////////////////////////////////////////////////////////////////// -/*typedef enum -{ - TYPE_INT = 0, - TYPE_FLOAT, - TYPE_STRING, - TYPE_VECTOR3, - TYPE_MATRIX3D, - TYPE_TRANSITION, - TYPE_PRESETID, - TYPE_MODELFILENAME - -} ParameterType;*/ diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h deleted file mode 100644 index 7fa8e8ae7f8..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/persist.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/04/01 8:42p $* - * * - * $Revision:: 13 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "postloadable.h" - -class PersistFactoryClass; -class ChunkSaveClass; -class ChunkLoadClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// PersistClass -// -// PersistClass defines the interface for an object to the save load system. -// Each concrete derived type of PersistClass must have an associated -// PersistFactoryClass that basically maps a chunk_id to a constructor, -// a save function, a load function, and a on_post_load function (taken from -// PostLoadableClass ) -// -////////////////////////////////////////////////////////////////////////////////// -class PersistClass : public PostLoadableClass -{ -public: - - virtual const PersistFactoryClass & Get_Factory () const = 0; - virtual bool Save (ChunkSaveClass &csave) { return true; } - virtual bool Load (ChunkLoadClass &cload) { return true; } - -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp deleted file mode 100644 index 67dcda7155b..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/persistfactory.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 9/09/99 9:50a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "persistfactory.h" -#include "saveload.h" - -PersistFactoryClass::PersistFactoryClass() : - NextFactory(nullptr) -{ - SaveLoadSystemClass::Register_Persist_Factory(this); -} - -PersistFactoryClass::~PersistFactoryClass() -{ - SaveLoadSystemClass::Unregister_Persist_Factory(this); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h deleted file mode 100644 index ca763198a82..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/persistfactory.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/04/01 8:42p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/bittype.h" -#include "WWLib/chunkio.h" -#include "WWDebug/wwdebug.h" -#include "saveload.h" -#include "persist.h" - -/* -** PersistFactoryClass -** Create a PersistFactoryClass for each concrete derived PersistClass. These -** factories automatically register with the SaveLoadSystem in their constructors -** and should be accessible through the virtual Get_Factory method of any -** derived PersistClass. -*/ - -class PersistFactoryClass -{ -public: - - PersistFactoryClass(); - virtual ~PersistFactoryClass(); - - virtual uint32 Chunk_ID() const = 0; - virtual PersistClass * Load(ChunkLoadClass & cload) const = 0; - virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const = 0; - -private: - - PersistFactoryClass * NextFactory; - friend class SaveLoadSystemClass; -}; - - - - -/* -** SimplePersistFactoryClass -** This template automates the creation of a PersistFactory for any type of Persist -** object. Simply instantiate a single static instance of this template with the -** type and chunkid in the .cpp file of your class. -*/ -template class SimplePersistFactoryClass : public PersistFactoryClass -{ -public: - - virtual uint32 Chunk_ID() const override { return CHUNKID; } - virtual PersistClass * Load(ChunkLoadClass & cload) const override; - virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const override; - - /* - ** Internal chunk id's - */ - enum - { - SIMPLEFACTORY_CHUNKID_OBJPOINTER = 0x00100100, - SIMPLEFACTORY_CHUNKID_OBJDATA - }; -}; - - -template PersistClass * -SimplePersistFactoryClass::Load(ChunkLoadClass & cload) const -{ - T * new_obj = W3DNEW T; - uintptr_t old_obj = 0; - - cload.Open_Chunk(); - WWASSERT(cload.Cur_Chunk_ID() == SIMPLEFACTORY_CHUNKID_OBJPOINTER); - uint32 old_obj_size = cload.Cur_Chunk_Length(); - cload.Read(&old_obj,old_obj_size < sizeof(old_obj) ? old_obj_size : sizeof(old_obj)); - cload.Close_Chunk(); - - cload.Open_Chunk(); - WWASSERT(cload.Cur_Chunk_ID() == SIMPLEFACTORY_CHUNKID_OBJDATA); - new_obj->Load(cload); - cload.Close_Chunk(); - - SaveLoadSystemClass::Register_Pointer((void *)old_obj,new_obj); - return new_obj; -} - - -template void -SimplePersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj) const -{ - uintptr_t objptr = (uintptr_t)obj; - csave.Begin_Chunk(SIMPLEFACTORY_CHUNKID_OBJPOINTER); - csave.Write(&objptr,sizeof(objptr)); - csave.End_Chunk(); - - csave.Begin_Chunk(SIMPLEFACTORY_CHUNKID_OBJDATA); - obj->Save(csave); - csave.End_Chunk(); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp deleted file mode 100644 index 9715f377590..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/pointerremap.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/09/01 11:36a $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "pointerremap.h" -#include "WWDebug/wwdebug.h" - - -const int POINTER_TABLES_GROWTH_STEP = 4096; - - -PointerRemapClass::PointerRemapClass() -{ - PointerPairTable.Set_Growth_Step(POINTER_TABLES_GROWTH_STEP); - PointerRequestTable.Set_Growth_Step(POINTER_TABLES_GROWTH_STEP); - RefCountRequestTable.Set_Growth_Step(POINTER_TABLES_GROWTH_STEP); -} - -PointerRemapClass::~PointerRemapClass() -{ -} - -void PointerRemapClass::Reset() -{ - PointerPairTable.Delete_All(); - PointerRequestTable.Delete_All(); - RefCountRequestTable.Delete_All(); -} - -void PointerRemapClass::Process() -{ - if ( PointerPairTable.Count() > 0 ) { - qsort(&PointerPairTable[0], PointerPairTable.Count(), sizeof(PointerPairTable[0]), ptr_pair_compare_function); - } - - if ( PointerRequestTable.Count() > 0 ) { - WWASSERT( PointerPairTable.Count() > 0 ); - qsort(&PointerRequestTable[0],PointerRequestTable.Count(), sizeof(PointerRequestTable[0]), ptr_request_compare_function); - Process_Request_Table(PointerRequestTable,false); - } - - // remap the ref-counted pointers - if ( RefCountRequestTable.Count() > 0 ) { - WWASSERT( PointerPairTable.Count() > 0 ); - qsort(&RefCountRequestTable[0],RefCountRequestTable.Count(), sizeof(RefCountRequestTable[0]), ptr_request_compare_function); - Process_Request_Table(RefCountRequestTable,true); - } -} - -void PointerRemapClass::Process_Request_Table(DynamicVectorClass & request_table,bool refcount) -{ - // Remap the pointers - int pointer_index = 0; - int pair_index = 0; - - for (pointer_index = 0; pointer_index < request_table.Count(); pointer_index++) { - - void * pointer_to_remap = *(request_table[pointer_index].PointerToRemap); - int pre_search_index = pair_index; - - // Find the pair which contains the pointer we are looking for as its "old" pointer - while ( (pair_index < PointerPairTable.Count()) && - (PointerPairTable[pair_index].OldPointer < pointer_to_remap) ) - { - pair_index++; - } - - if ((pair_index < PointerPairTable.Count()) && (PointerPairTable[pair_index].OldPointer == pointer_to_remap)) { - - // we found the match, plug in the new pointer and add a ref if needed. - *request_table[pointer_index].PointerToRemap = PointerPairTable[pair_index].NewPointer; - - if (refcount) { - RefCountClass * refptr = (RefCountClass *)(*request_table[pointer_index].PointerToRemap); - refptr->Add_Ref(); - } - - } else { - - // Failed to re-map the pointer. - // warn the user, set pointer to null, reset index to the pre_search_index. - // If this happens, things could be going very wrong. (find out why its happening!) - pair_index = pre_search_index; - *request_table[pointer_index].PointerToRemap = nullptr; -#ifdef DEBUG_LOGGING - const char * file = request_table[pointer_index].File; - int line = request_table[pointer_index].Line; - WWDEBUG_SAY(("Warning! Failed to re-map pointer! old_ptr = 0x%X file = %s line = %d",(unsigned int)pointer_to_remap,file,line)); -#endif - WWASSERT( 0 ); - } - } -} - -void PointerRemapClass::Register_Pointer (void *old_pointer, void *new_pointer) -{ - PointerPairTable.Add(PtrPairStruct(old_pointer,new_pointer)); -} - -#ifdef DEBUG_LOGGING -void PointerRemapClass::Request_Pointer_Remap(void **pointer_to_convert,const char * file,int line) -{ - PtrRemapStruct remap; - remap.PointerToRemap = pointer_to_convert; - remap.File = file; - remap.Line = line; - PointerRequestTable.Add(remap); -} - -void PointerRemapClass::Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file, int line) -{ - PtrRemapStruct remap; - remap.PointerToRemap = (void**)pointer_to_convert; - remap.File = file; - remap.Line = line; - RefCountRequestTable.Add(remap); -} - -#else - -void PointerRemapClass::Request_Pointer_Remap (void **pointer_to_convert) -{ - PtrRemapStruct remap; - remap.PointerToRemap = pointer_to_convert; - PointerRequestTable.Add(remap); -} - -void PointerRemapClass::Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert) -{ - PtrRemapStruct remap; - remap.PointerToRemap = (void**)pointer_to_convert; - RefCountRequestTable.Add(remap); -} - -#endif - -/* -** sort compare function for pointer pair structures -** sorts by the old pointer value -*/ -int __cdecl PointerRemapClass::ptr_pair_compare_function(void const * ptr1, void const * ptr2) -{ - void * old1 = ((PointerRemapClass::PtrPairStruct const *)ptr1)->OldPointer; - void * old2 = ((PointerRemapClass::PtrPairStruct const *)ptr2)->OldPointer; - - if (old1 == old2) { - return(0); - } - if (old1 < old2) { - return(-1); - } - return(1); -} - -/* -** sort compare function for pointer remap structures -** sorts by the old pointer value -*/ -int __cdecl PointerRemapClass::ptr_request_compare_function(void const * ptr1, void const * ptr2) -{ - PtrRemapStruct * remap1 = (PtrRemapStruct *)ptr1; - PtrRemapStruct * remap2 = (PtrRemapStruct *)ptr2; - - void * old1 = *(remap1->PointerToRemap); - void * old2 = *(remap2->PointerToRemap); - - if (old1 == old2) { - return(0); - } - if (old1 < old2) { - return(-1); - } - return(1); -} - - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h deleted file mode 100644 index 103be876ae8..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/pointerremap.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 4/30/01 1:54p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#ifdef _UNIX -#include "osdep/osdep.h" -#endif - -#include "WWLib/always.h" -#include "WWLib/Vector.h" - -class RefCountClass; - - -class PointerRemapClass -{ - public: - - PointerRemapClass(); - ~PointerRemapClass(); - - void Reset(); - void Process(); - - void Register_Pointer (void *old_pointer, void *new_pointer); - -#ifdef DEBUG_LOGGING - void Request_Pointer_Remap (void **pointer_to_convert,const char * file,int line); - void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file, int line); -#else - void Request_Pointer_Remap (void **pointer_to_convert); - void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert); -#endif - - private: - - struct PtrPairStruct - { - PtrPairStruct() {} - PtrPairStruct(void * oldptr,void * newptr) : OldPointer(oldptr),NewPointer(newptr) {} - bool operator == (const PtrPairStruct & that) { return ((OldPointer == that.OldPointer) && (NewPointer == that.NewPointer)); } - bool operator != (const PtrPairStruct & that) { return !(*this == that); } - - void * OldPointer; - void * NewPointer; - }; - - struct PtrRemapStruct - { - PtrRemapStruct() {} - bool operator == (const PtrRemapStruct & that) { return (PointerToRemap == that.PointerToRemap); } - bool operator != (const PtrRemapStruct & that) { return !(*this == that); } - - void ** PointerToRemap; -#ifdef DEBUG_LOGGING - const char * File; - int Line; -#endif - }; - - void Process_Request_Table(DynamicVectorClass & request_table,bool refcount); - static int __cdecl ptr_pair_compare_function(void const * ptr1, void const * ptr2); - static int __cdecl ptr_request_compare_function(void const * ptr1, void const * ptr2); - - /* - ** Array of pointers associated with ID values to assist in swizzling. - */ - DynamicVectorClass PointerPairTable; - DynamicVectorClass PointerRequestTable; - DynamicVectorClass RefCountRequestTable; -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h deleted file mode 100644 index cb4e1cae69a..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/postloadable.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/09/01 11:46a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -////////////////////////////////////////////////////////////////////////////////// -// -// PostLoadableClass -// -// PostLoadableClass allows a lower level for non-Persist objects to On_Post_Load -// without requiring Get_Factory or other requirements of PersistClass. Objects -// derived from this class can be added to the post-load list in the SaveLoadSystem -// -////////////////////////////////////////////////////////////////////////////////// -class PostLoadableClass -{ -public: - PostLoadableClass() : IsPostLoadRegistered(false) { } - virtual ~PostLoadableClass() { } - - virtual void On_Post_Load () { } - - bool Is_Post_Load_Registered() { return IsPostLoadRegistered; } - void Set_Post_Load_Registered(bool onoff) { IsPostLoadRegistered = onoff; } - -private: - - bool IsPostLoadRegistered; -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp deleted file mode 100644 index 920b7ccc632..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/saveload.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 12/09/01 6:42p $* - * * - * $Revision:: 19 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "saveload.h" -#include "saveloadsubsystem.h" -#include "persist.h" -#include "persistfactory.h" -#include "WWLib/chunkio.h" -#include "WWDebug/wwdebug.h" -#include "saveloadstatus.h" -#include "WWDebug/wwhack.h" -#include "WWDebug/wwprofile.h" - -#pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union -#include -#include "WWLib/systimer.h" - - -SaveLoadSubSystemClass * SaveLoadSystemClass::SubSystemListHead = nullptr; -PersistFactoryClass * SaveLoadSystemClass::FactoryListHead = nullptr; -SList SaveLoadSystemClass::PostLoadList; -PointerRemapClass SaveLoadSystemClass::PointerRemapper; - - - -bool SaveLoadSystemClass::Save (ChunkSaveClass &csave,SaveLoadSubSystemClass & subsystem) -{ - bool ok = true; - - if (subsystem.Contains_Data()) { - csave.Begin_Chunk (subsystem.Chunk_ID ()); - ok &= subsystem.Save (csave); - csave.End_Chunk (); - } - - return ok; -} - -bool SaveLoadSystemClass::Load (ChunkLoadClass &cload,bool auto_post_load) -{ - WWLOG_PREPARE_TIME_AND_MEMORY("SaveLoadSystemClass::Load"); - PointerRemapper.Reset(); - WWLOG_INTERMEDIATE("PointerRemapper.Reset()"); - bool ok = true; - - // Load each chunk we encounter and link the manager into the PostLoad list - while (cload.Open_Chunk ()) { - SaveLoadStatus::Inc_Status_Count(); // Count the sub systems loaded - SaveLoadSubSystemClass *sys = Find_Sub_System(cload.Cur_Chunk_ID ()); - WWLOG_INTERMEDIATE("Find_Sub_System"); - if (sys != nullptr) { -//WWRELEASE_SAY((" Name: %s",sys->Name())); - INIT_SUB_STATUS(sys->Name()); - ok &= sys->Load(cload); - WWLOG_INTERMEDIATE(sys->Name()); - } - cload.Close_Chunk(); - } - - // Process all of the pointer remap requests - PointerRemapper.Process(); - WWLOG_INTERMEDIATE("PointerRemapper.Process()"); - PointerRemapper.Reset(); - WWLOG_INTERMEDIATE("PointerRemapper.Reset()"); - - // Call PostLoad on each PersistClass that wanted post-load - if (auto_post_load) { - Post_Load_Processing(nullptr); - } - WWLOG_INTERMEDIATE("PostLoadProcessing"); - - return ok; -} - -// Nework update macro for post loader. -#define UPDATE_NETWORK \ - if (network_callback) { \ - unsigned long time2 = TIMEGETTIME(); \ - if (time2 - time > 20) { \ - network_callback(); \ - time = time2; \ - } \ - } \ - -bool SaveLoadSystemClass::Post_Load_Processing (void(*network_callback)()) -{ - unsigned long time = TIMEGETTIME(); - - // Call PostLoad on each PersistClass that wanted post-load - PostLoadableClass * obj = PostLoadList.Remove_Head(); - while (obj) { - UPDATE_NETWORK; - obj->On_Post_Load(); - obj->Set_Post_Load_Registered(false); - obj = PostLoadList.Remove_Head(); - } - - return true; -} - -void SaveLoadSystemClass::Register_Sub_System (SaveLoadSubSystemClass * sys) -{ - WWASSERT(sys != nullptr); - Link_Sub_System(sys); -} - - -void SaveLoadSystemClass::Unregister_Sub_System (SaveLoadSubSystemClass * sys) -{ - WWASSERT(sys != nullptr); - Unlink_Sub_System(sys); -} - - -SaveLoadSubSystemClass * SaveLoadSystemClass::Find_Sub_System (uint32 chunk_id) -{ - // TODO: need a d-s that gives fast searching based on chunk_id!! - SaveLoadSubSystemClass * sys; - for ( sys = SubSystemListHead; sys != nullptr; sys = sys->NextSubSystem ) { - if ( sys->Chunk_ID() == chunk_id ) { - break; - } - } - return sys; -} - -void SaveLoadSystemClass::Register_Persist_Factory(PersistFactoryClass * factory) -{ - WWASSERT(factory != nullptr); - Link_Factory(factory); -} - -void SaveLoadSystemClass::Unregister_Persist_Factory(PersistFactoryClass * factory) -{ - WWASSERT(factory != nullptr); - Unlink_Factory(factory); -} - -PersistFactoryClass * SaveLoadSystemClass::Find_Persist_Factory(uint32 chunk_id) -{ - // TODO: need a d-s that gives fast searching based on chunk_id!! - PersistFactoryClass * fact; - for ( fact = FactoryListHead; fact != nullptr; fact = fact->NextFactory ) { - if ( fact->Chunk_ID() == chunk_id ) { - break; - } - } - return fact; -} - -bool SaveLoadSystemClass::Is_Post_Load_Callback_Registered(PostLoadableClass * obj) -{ - // obsolete! - bool retval = false; - - SLNode *list_node = nullptr; - for ( list_node = PostLoadList.Head(); - retval == false && list_node != nullptr; - list_node = list_node->Next()) - { - retval = (list_node->Data() == obj); - } - - return retval; -} - -void SaveLoadSystemClass::Register_Post_Load_Callback(PostLoadableClass * obj) -{ - WWASSERT(obj != nullptr); - if (!obj->Is_Post_Load_Registered()) { - obj->Set_Post_Load_Registered(true); - PostLoadList.Add_Head(obj); - } -} - -void SaveLoadSystemClass::Register_Pointer (void *old_pointer, void *new_pointer) -{ - PointerRemapper.Register_Pointer(old_pointer,new_pointer); -} - -#ifdef DEBUG_LOGGING - -void SaveLoadSystemClass::Request_Pointer_Remap (void **pointer_to_convert,const char * file,int line) -{ - PointerRemapper.Request_Pointer_Remap(pointer_to_convert,file,line); -} - -void SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file,int line) -{ - PointerRemapper.Request_Ref_Counted_Pointer_Remap(pointer_to_convert,file,line); -} - -#else - -void SaveLoadSystemClass::Request_Pointer_Remap (void **pointer_to_convert) -{ - PointerRemapper.Request_Pointer_Remap(pointer_to_convert); -} - -void SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert) -{ - PointerRemapper.Request_Ref_Counted_Pointer_Remap(pointer_to_convert); -} - -#endif - -void SaveLoadSystemClass::Link_Sub_System(SaveLoadSubSystemClass * sys) -{ - WWASSERT(sys != nullptr); - if (sys != nullptr) { - WWASSERT(sys->NextSubSystem == nullptr); // sys should never be registered twice! - sys->NextSubSystem = SubSystemListHead; - SubSystemListHead = sys; - } -} - -void SaveLoadSystemClass::Unlink_Sub_System(SaveLoadSubSystemClass * sys) -{ - WWASSERT(sys != nullptr); - SaveLoadSubSystemClass * cursys = SubSystemListHead; - SaveLoadSubSystemClass * prev = nullptr; - - while (cursys != sys) { - prev = cursys; - cursys = cursys->NextSubSystem; - } - - if (prev == nullptr) { - SubSystemListHead = sys->NextSubSystem; - } else { - prev->NextSubSystem = sys->NextSubSystem; - } - - sys->NextSubSystem = nullptr; -} - - -void SaveLoadSystemClass::Link_Factory(PersistFactoryClass * fact) -{ - WWASSERT(fact != nullptr); - if (fact != nullptr) { - WWASSERT(fact->NextFactory == nullptr); // factories should never be registered twice! - fact->NextFactory = FactoryListHead; - FactoryListHead = fact; - } -} - -void SaveLoadSystemClass::Unlink_Factory(PersistFactoryClass * fact) -{ - WWASSERT(fact != nullptr); - - PersistFactoryClass * curfact = FactoryListHead; - PersistFactoryClass * prev = nullptr; - - while (curfact != fact) { - prev = curfact; - curfact = curfact->NextFactory; - } - - if (prev == nullptr) { - FactoryListHead = fact->NextFactory; - } else { - prev->NextFactory = fact->NextFactory; - } - - fact->NextFactory = nullptr; -} - -void Force_Link_WWSaveLoad () -{ - FORCE_LINK( Twiddler ); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h deleted file mode 100644 index e8a5b872c21..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h +++ /dev/null @@ -1,212 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/saveload.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 9/19/01 4:13p $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "pointerremap.h" -#include "WWLib/bittype.h" -#include "WWLib/SLIST.h" - -class RefCountClass; -class SaveLoadSubSystemClass; -class PersistFactoryClass; -class PersistClass; -class PostLoadableClass; -class ChunkSaveClass; -class ChunkLoadClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// WWSaveLoad -// -// The WWSaveLoad library is a framework for saving and loading. The main -// goals that we attempted to achieve in designing this system are: -// -// - Save things in a form that could adapt as our code evolves. We want -// to be able to load files which were created with a previous version of the -// application into the current version. -// - Use the same framework throughout all of our libraries with as small an -// impact on them as possible -// - Automate as much of the implementation of save-load as possible. -// - Make this a generic hunk of code which contains no commando-specific parts -// so that it can be used by other applications. -// - Make this system capable of generating the file formats for our level editor, -// the game's level definition file, and player save files. -// -// To achive this, we developed several core concepts: -// -// - Persistent Objects: Most of the state of the game is contained in the objects -// active at any given time. PersistClass is an abstract interface which will allow -// objects to be used with the save-load system. It was also important to keep the -// overhead caused by inheriting this class to an absolute minimum. -// -// - PersistFactories: We need an automatic "virtual-constructor" or "abstract-factory" -// system for all objects that get saved. This is the PersistFactoryClass and the -// automated SimplePersistFactory template. All objects that "persist" are derived from -// PersistClass and all concrete derived PersistClasses have an associated static -// instance of a PersistFactory which handles their saving and construction upon encountering -// them while loading. In certain cases these PersistFactories can also serve as -// a "shortcut" where we cheat by not actually telling the object to save but simply save -// a small piece of data that allows us to recreate an identical object when we load. This -// is used in WW3D sometimes; we just save a render object name and then ask the WW3D asset -// manager to recreate that model for us. -// -// - SaveLoadSubSystems: The overall file structure will be governed by many sub-systems -// (derived from SaveLoadSubSystemClass). The application in-effect creates file formats -// by simply having the sub-systems that it wants write into a file. In this way you can -// achieve things like saving only static data into one file and dynamic into another, etc. -// All persistent objects that get saved will be told to save by some sub-system. For -// example: in Commando, I have a PhysicsDynamicDataSubSystem which saves all of the -// dynamic physics objects. In saving those objects I use the built-in PersistFactories -// and am therefore completely safe from new object types being added to the system, it will just -// automatically work -// -// - Pointer re-mapping: A pointer remaping system is built into the save-load system. There -// are several things that happen in this system. Each object, as it is saved and loaded, -// registers with the system its old address and its new address. (the old address is saved -// and the new address is available once the object is created). This is automated by the -// SimplePersistFactory for all but classes that use multiple inheritance. During the load -// process a table is built which contains all of these pointer pairs (old address, new address). -// Whenever an object loads a pointer, it gives a "pointer to that pointer" to the save load system. -// Then, after all of the objects have been loaded, the system goes through that list of pointers -// and finds them in the pointer pair table. NOTE: use the macros for re-mapping your -// pointers to enable automatic debugging information when you build with DEBUG_LOGGING defined. -// -// - Chunks: The file format will be chunk based since that gives us the flexibility to -// add new data and remove obsolete data without necessarily losing the ability -// to read old files. We will use a "high-granularity" of chunks. In many cases, each -// member variable will be in its own chunk for maximum flexibility. To help soften -// the memory usage for this approach, we developed the concept of "micro-chunks". -// Micro-chunks are just like chunks in that they have an id and a size but -// each of these fields are only a single byte and they are never hierarchical. -// -// - ChunkID's: The chunk ID's used by Subsystems and PersistFactories must be unique -// but all others can be considered local to the object that is saving itself. Unique -// ids for the subsystems and factories are achieved by saveloadids.h defining ranges -// of ids for various libraries and then those libraries maintaining a single header -// file internally which gives unique id's within that range to all of their sub-systems -// and persist factories. Never re-use an id or you will break compatibility with older -// versions of your files... -// -////////////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////////////// -// -// SaveLoadSystemClass -// -////////////////////////////////////////////////////////////////////////////////// -class SaveLoadSystemClass -{ -public: - - /* - ** Save-Load interface. To create a file, ask each sub-system to save itself. - ** To load a file just open it and pass it to the load method. - */ - static bool Save (ChunkSaveClass &csave, SaveLoadSubSystemClass & subsystem); - static bool Load (ChunkLoadClass &cload,bool auto_post_load = true); - static bool Post_Load_Processing (void(*network_callback)()); - /* - ** Look up the persist factory for a given chunk id - */ - static PersistFactoryClass * Find_Persist_Factory(uint32 chunk_id); - - /* - ** Post-Load interface. An object being loaded can ask for a callback after - ** all objects have been loaded and pointers re-mapped. - */ - static void Register_Post_Load_Callback(PostLoadableClass * obj); - - /* - ** Pointer Remapping interface. NOTE: use the macros defined below to - ** get debug info with your pointers when doing a debug build. - */ - static void Register_Pointer (void *old_pointer, void *new_pointer); - -#ifdef DEBUG_LOGGING - static void Request_Pointer_Remap (void **pointer_to_convert,const char * file = nullptr,int line = 0); - static void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file = nullptr,int line = 0); -#else - static void Request_Pointer_Remap (void **pointer_to_convert); - static void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert); -#endif - -protected: - - /* - ** Internal SaveLoadSystem functions - */ - static void Register_Sub_System (SaveLoadSubSystemClass * subsys); - static void Unregister_Sub_System (SaveLoadSubSystemClass * subsys); - static SaveLoadSubSystemClass * Find_Sub_System (uint32 chunk_id); - - static void Register_Persist_Factory(PersistFactoryClass * factory); - static void Unregister_Persist_Factory(PersistFactoryClass * factory); - - static void Link_Sub_System(SaveLoadSubSystemClass * subsys); - static void Unlink_Sub_System(SaveLoadSubSystemClass * subsys); - static void Link_Factory(PersistFactoryClass * factory); - static void Unlink_Factory(PersistFactoryClass * factory); - - static bool Is_Post_Load_Callback_Registered(PostLoadableClass * obj); - - static SaveLoadSubSystemClass * SubSystemListHead; - static PersistFactoryClass * FactoryListHead; - static PointerRemapClass PointerRemapper; - static SList PostLoadList; - - /* - ** these are friends so that they can register themselves at construction time. - */ - friend class SaveLoadSubSystemClass; - friend class PersistFactoryClass; -}; - - -/* -** Use the following macros to automatically enable pointer-remap DEBUG code. Remember that -** in all cases you submit a pointer to the pointer you want re-mapped. -*/ -#ifdef DEBUG_LOGGING -#define REQUEST_POINTER_REMAP(pp) SaveLoadSystemClass::Request_Pointer_Remap(pp,__FILE__,__LINE__) -#define REQUEST_REF_COUNTED_POINTER_REMAP(pp) SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap(pp,__FILE__,__LINE__) -#else -#define REQUEST_POINTER_REMAP(pp) SaveLoadSystemClass::Request_Pointer_Remap(pp) -#define REQUEST_REF_COUNTED_POINTER_REMAP(pp) SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap(pp) -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h deleted file mode 100644 index ee8e111ce14..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/saveloadids.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/04/01 8:42p $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -////////////////////////////////////////////////////////////////////////////////// -// -// Chunk ID Ranges. -// Here are the ranges to use for SubSystem and PersistFactory chunk id's -// and also the chunk id's used by the save-load system itself. If you are -// creating a new library that is going to take advantage of this system, -// create a new range for it here. -// -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_SAVELOAD_BEGIN = 0x00000100, - CHUNKID_SAVELOAD_DEFMGR, - CHUNKID_TWIDDLER, - CHUNKID_WW3D_BEGIN = 0x00010000, - CHUNKID_WWPHYS_BEGIN = 0x00020000, - CHUNKID_WWAUDIO_BEGIN = 0x00030000, - CHUNKID_COMBAT_BEGIN = 0x00040000, - CHUNKID_COMMANDO_EDITOR_BEGIN = 0x00050000, - CHUNKID_PHYSTEST_BEGIN = 0x00060000, - CHUNKID_COMMANDO_BEGIN = 0x00070000, - CHUNKID_WWMATH_BEGIN = 0x00080000, - CHUNKID_WWTRANSLATEDB_BEGIN = 0x00090000 -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.cpp deleted file mode 100644 index 11998389a39..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "saveloadstatus.h" -#include "WWLib/mutex.h" - -#define MAX_STATUS_TEXT_ID 2 - -static CriticalSectionClass text_mutex; -static StringClass status_text[MAX_STATUS_TEXT_ID]; - -void SaveLoadStatus::Set_Status_Text(const char* text,int id) -{ - CriticalSectionClass::LockClass m(text_mutex); - WWASSERT(id. -*/ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/wwstring.h" - -namespace SaveLoadStatus -{ - void Set_Status_Text(const char* text,int id); - - void Reset_Status_Count(); - void Inc_Status_Count(); - int Get_Status_Count(); - void Get_Status_Text(StringClass& text, int id); -}; - -#define INIT_STATUS(t) SaveLoadStatus::Set_Status_Text(t,0) -#define INIT_SUB_STATUS(t) SaveLoadStatus::Set_Status_Text(t,1) diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp deleted file mode 100644 index 2c93fdb794e..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/saveloadsubsystem.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 9/09/99 9:50a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "saveloadsubsystem.h" -#include "saveload.h" - - -SaveLoadSubSystemClass::SaveLoadSubSystemClass() : - NextSubSystem(nullptr) -{ - // All Sub-Systems are automatically registered with the SaveLoadSystem - SaveLoadSystemClass::Register_Sub_System (this); -} - -SaveLoadSubSystemClass::~SaveLoadSubSystemClass () -{ - SaveLoadSystemClass::Unregister_Sub_System (this); -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h deleted file mode 100644 index 01efb4eb727..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/saveloadsubsystem.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 6/12/00 4:25p $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "WWLib/bittype.h" -#include "postloadable.h" - -class ChunkLoadClass; -class ChunkSaveClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// SaveLoadSubSystemClass -// -// Each SaveLoadSubSystem will automatically be registered with the SaveLoadSystem -// at construction time. The plan is to have a single static instance of each -// sub-system so that it automatically registers when the global constructors -// are executed. -// -// When an application wants to create a file it does so by asking the -// SaveLoadSystem to save the particular set of SaveLoadSubSystems that contain -// that data. -// -////////////////////////////////////////////////////////////////////////////////// -class SaveLoadSubSystemClass : public PostLoadableClass -{ -public: - - SaveLoadSubSystemClass (); - virtual ~SaveLoadSubSystemClass () override; - - virtual uint32 Chunk_ID () const = 0; - -protected: - - virtual bool Contains_Data() const { return true; } - virtual bool Save (ChunkSaveClass &csave) = 0; - virtual bool Load (ChunkLoadClass &cload) = 0; - - virtual const char* Name() const = 0; - -private: - - SaveLoadSubSystemClass * NextSubSystem; // managed by SaveLoadSystem - - friend class SaveLoadSystemClass; -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h deleted file mode 100644 index e9762bbfa12..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -#include "definitionfactory.h" - -////////////////////////////////////////////////////////////////////////////////// -// -// SimpleDefinitionFactoryClass -// -// Template class to automate the creation of simple definition factories. -// -////////////////////////////////////////////////////////////////////////////////// -template -class SimpleDefinitionFactoryClass : public DefinitionFactoryClass -{ -public: - - ////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////// - SimpleDefinitionFactoryClass (bool is_displayed = true) : - IsDisplayed (is_displayed) {} - - ////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////// - virtual DefinitionClass * Create () const override; - virtual const char * Get_Name () const override; - virtual uint32 Get_Class_ID () const override; - virtual bool Is_Displayed () const override { return IsDisplayed; } - -protected: - - ////////////////////////////////////////////////////////////// - // Protected member data - ////////////////////////////////////////////////////////////// - bool IsDisplayed; -}; - -template -inline DefinitionClass * -SimpleDefinitionFactoryClass::Create () const -{ - return W3DNEW T; -} - -template -inline const char * -SimpleDefinitionFactoryClass::Get_Name () const -{ - return name; -} - -template -inline uint32 -SimpleDefinitionFactoryClass::Get_Class_ID () const -{ - return class_id; -} - -#define DECLARE_DEFINITION_FACTORY(_class, _id, _name) \ -char _class ## Name[] = _name; \ -SimpleDefinitionFactoryClass<_class, _id, _class ## Name> diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h deleted file mode 100644 index a08dd171996..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h +++ /dev/null @@ -1,232 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/simpleparameter.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 7/16/01 11:12a $* - * * - * $Revision:: 17 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "WWLib/always.h" -#include "parameter.h" -#include "WWMath/vector2.h" -#include "WWMath/vector3.h" -#include "WWMath/matrix3d.h" -#include "WWMath/rect.h" -#include - - -////////////////////////////////////////////////////////////////////////////////// -// -// SimpleParameterClass -// -////////////////////////////////////////////////////////////////////////////////// -template -class SimpleParameterClass : public ParameterClass -{ -public: - - /////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - /////////////////////////////////////////////////////////////////////// - SimpleParameterClass (void *data, const char *name); - - ////////////////////////////////////////////////////////////////////////////// - // Public operators - ////////////////////////////////////////////////////////////////////////////// - virtual bool operator== (const ParameterClass &src) override; - - /////////////////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////////////////// - const T & Get_Value () const; - void Set_Value (const T &new_value); - - // From Parameter class - virtual ParameterClass::Type Get_Type () const override; - virtual void Copy_Value (const ParameterClass &src) override; - -private: - - /////////////////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////////////////// - T * m_Data; - T m_Min; - T m_Max; -}; - -////////////////////////////////////////////////////////////////////////////////// -// SimpleParameterClass -////////////////////////////////////////////////////////////////////////////////// -template inline -SimpleParameterClass::SimpleParameterClass (void *data, const char *name) -{ - Set_Name (name); - m_Data = (T *)data; -} - -////////////////////////////////////////////////////////////////////////////////// -// Get_Value -////////////////////////////////////////////////////////////////////////////////// -template inline bool -SimpleParameterClass::operator== (const ParameterClass &src) -{ - bool retval = false; - if (src.Get_Type () == Get_Type ()) { - retval = ((*m_Data) == *(((const SimpleParameterClass &)src).m_Data)); - } - - return retval; -} - -////////////////////////////////////////////////////////////////////////////////// -// Get_Value -////////////////////////////////////////////////////////////////////////////////// -template inline const T & -SimpleParameterClass::Get_Value () const -{ - return (*m_Data); -} - -////////////////////////////////////////////////////////////////////////////////// -// Set_Value -////////////////////////////////////////////////////////////////////////////////// -template inline void -SimpleParameterClass::Set_Value (const T &new_value) -{ - (*m_Data) = new_value; - Set_Modified (); -} - -////////////////////////////////////////////////////////////////////////////////// -// Get_Type -////////////////////////////////////////////////////////////////////////////////// -template inline ParameterClass::Type -SimpleParameterClass::Get_Type () const -{ - return type; -} - -////////////////////////////////////////////////////////////////////////////////// -// Copy_Value -////////////////////////////////////////////////////////////////////////////////// -template inline void -SimpleParameterClass::Copy_Value (const ParameterClass &src) -{ - if (Get_Type () == src.Get_Type ()) { - (*m_Data) = ((SimpleParameterClass &)src).Get_Value (); - } - - ParameterClass::Copy_Value (src); -} - -////////////////////////////////////////////////////////////////////////////////// -// -// Simple parameter types -// -////////////////////////////////////////////////////////////////////////////////// -typedef SimpleParameterClass BoolParameterClass; -typedef SimpleParameterClass Vector2ParameterClass; -typedef SimpleParameterClass Vector3ParameterClass; -typedef SimpleParameterClass Matrix3DParameterClass; -typedef SimpleParameterClass RectParameterClass; -typedef SimpleParameterClass ColorParameterClass; -typedef SimpleParameterClass StringsDBEntryParameterClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// RangedParameterClass -// -// Extends simple parameter types so they can have minimum/maximum values. -// -////////////////////////////////////////////////////////////////////////////////// -template -class RangedParameterClass : public SimpleParameterClass -{ -public: - /////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - /////////////////////////////////////////////////////////////////////// - RangedParameterClass (void *data, const char *name) - : SimpleParameterClass (data, name) { } - - /////////////////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////////////////// - void Set_Range (const T &min, const T &max) { m_Min = min; m_Max = max; } - const T & Get_Min () const { return m_Min; } - const T & Get_Max () const { return m_Max; } - -private: - - /////////////////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////////////////// - T m_Min; - T m_Max; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// IntParameterClass -////////////////////////////////////////////////////////////////////////////////// -class IntParameterClass : public RangedParameterClass -{ -public: - IntParameterClass (void *data, const char *name) - : RangedParameterClass (data, name) - { Set_Range (-1000000000L, 1000000000L); } -}; - -////////////////////////////////////////////////////////////////////////////////// -// FloatParameterClass -////////////////////////////////////////////////////////////////////////////////// -class FloatParameterClass : public RangedParameterClass -{ -public: - FloatParameterClass (void *data, const char *name) - : RangedParameterClass (data, name) - { Set_Range (-100000.0F, 100000.0F); } -}; - -////////////////////////////////////////////////////////////////////////////////// -// AngleParameterClass -////////////////////////////////////////////////////////////////////////////////// -class AngleParameterClass : public RangedParameterClass -{ -public: - AngleParameterClass (void *data, const char *name) - : RangedParameterClass (data, name) - { Set_Range (0.0F, 6.283185307F); } -}; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp deleted file mode 100644 index 0ab0673f6d6..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/twiddler.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 12/10/01 12:40p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "twiddler.h" -#include "WWLib/RANDOM.h" -#include "saveloadids.h" -#include "simpledefinitionfactory.h" -#include "persistfactory.h" -#include "WWLib/win.h" -#include "WWDebug/wwhack.h" -#include "WWLib/systimer.h" - - -DECLARE_FORCE_LINK( Twiddler ) - -////////////////////////////////////////////////////////////////////////////////// -// Constants -////////////////////////////////////////////////////////////////////////////////// -enum -{ - CHUNKID_VARIABLES = 0x00000100, - CHUNKID_BASE_CLASS = 0x00000200, -}; - -enum -{ - VARID_DEFINTION_ID = 0x01, - VARID_INDIRECT_CLASSID, -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// Static factories -// -////////////////////////////////////////////////////////////////////////////////// -DECLARE_DEFINITION_FACTORY(TwiddlerClass, CLASSID_TWIDDLERS, "Twiddler") _TwiddlerFactory; -SimplePersistFactoryClass _TwiddlerPersistFactory; - - -////////////////////////////////////////////////////////////////////////////////// -// -// TwiddlerClass -// -////////////////////////////////////////////////////////////////////////////////// -TwiddlerClass::TwiddlerClass () - : m_IndirectClassID (0) - -{ - CLASSID_DEFIDLIST_PARAM (TwiddlerClass, m_DefinitionList, 0, m_IndirectClassID, "Preset List"); -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// ~TwiddlerClass -// -////////////////////////////////////////////////////////////////////////////////// -TwiddlerClass::~TwiddlerClass () -{ -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Twiddle -// -////////////////////////////////////////////////////////////////////////////////// -DefinitionClass * -TwiddlerClass::Twiddle () const -{ - DefinitionClass *definition = nullptr; - - if (m_DefinitionList.Count () > 0) { - - // - // Get a random index into our definition list - // - RandomClass randomizer (TIMEGETTIME ()); - int index = randomizer (0, m_DefinitionList.Count () - 1); - - // - // Lookup the definition this entry represents - // - int def_id = m_DefinitionList[index]; - definition = DefinitionMgrClass::Find_Definition (def_id); - } - - return definition; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Create -// -////////////////////////////////////////////////////////////////////////////////// -PersistClass * -TwiddlerClass::Create () const -{ - PersistClass *retval = nullptr; - - // - // Pick a random definition - // - DefinitionClass *definition = Twiddle (); - if (definition != nullptr) { - - // - // Indirect the creation to the definition we randomly selected - // - retval = definition->Create (); - - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Get_Factory -// -////////////////////////////////////////////////////////////////////////////////// -const PersistFactoryClass & -TwiddlerClass::Get_Factory () const -{ - return _TwiddlerPersistFactory; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -////////////////////////////////////////////////////////////////////////////////// -bool -TwiddlerClass::Save (ChunkSaveClass &csave) -{ - bool retval = true; - - csave.Begin_Chunk (CHUNKID_VARIABLES); - retval &= Save_Variables (csave); - csave.End_Chunk (); - - csave.Begin_Chunk (CHUNKID_BASE_CLASS); - retval &= DefinitionClass::Save (csave); - csave.End_Chunk (); - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -////////////////////////////////////////////////////////////////////////////////// -bool -TwiddlerClass::Load (ChunkLoadClass &cload) -{ - bool retval = true; - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_VARIABLES: - retval &= Load_Variables (cload); - break; - - case CHUNKID_BASE_CLASS: - retval &= DefinitionClass::Load (cload); - break; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -TwiddlerClass::Save_Variables (ChunkSaveClass &csave) -{ - WRITE_MICRO_CHUNK (csave, VARID_INDIRECT_CLASSID, m_IndirectClassID) - - for (int index = 0; index < m_DefinitionList.Count (); index ++) { - - // - // Save this definition ID to the chunk - // - int def_id = m_DefinitionList[index]; - WRITE_MICRO_CHUNK (csave, VARID_DEFINTION_ID, def_id) - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Load_Variables -// -////////////////////////////////////////////////////////////////////////////////// -bool -TwiddlerClass::Load_Variables (ChunkLoadClass &cload) -{ - // - // Start fresh - // - m_DefinitionList.Delete_All (); - - // - // Loop through all the microchunks that define the variables - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - READ_MICRO_CHUNK (cload, VARID_INDIRECT_CLASSID, m_IndirectClassID) - - case VARID_DEFINTION_ID: - { - // - // Read the definition ID from the chunk and add it - // to our list - // - int def_id = 0; - cload.Read (&def_id, sizeof (def_id)); - m_DefinitionList.Add (def_id); - } - break; - } - - cload.Close_Micro_Chunk (); - } - - return true; -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h deleted file mode 100644 index 849fdf69593..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/twiddler.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 6/27/00 2:34p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -#include "definition.h" -#include "definitionclassids.h" - - -////////////////////////////////////////////////////////////////////////////////// -// -// TwiddlerClass -// -////////////////////////////////////////////////////////////////////////////////// -class TwiddlerClass : public DefinitionClass -{ -public: - - ///////////////////////////////////////////////////////////////////// - // Editable interface requirements - ///////////////////////////////////////////////////////////////////// - DECLARE_EDITABLE(TwiddlerClass, DefinitionClass); - - ///////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ///////////////////////////////////////////////////////////////////// - TwiddlerClass (); - virtual ~TwiddlerClass () override; - - ///////////////////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////////////////// - - // - // Type identification - // - virtual uint32 Get_Class_ID () const override { return CLASSID_TWIDDLERS; } - virtual PersistClass * Create () const override; - - // - // From PersistClass - // - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; - virtual const PersistFactoryClass & Get_Factory () const override; - - // - // Twiddler specific - // - virtual DefinitionClass * Twiddle () const; - virtual uint32 Get_Indirect_Class_ID () const; - virtual void Set_Indirect_Class_ID (uint32 class_id); - -private: - - ///////////////////////////////////////////////////////////////////// - // Private methods - ///////////////////////////////////////////////////////////////////// - bool Save_Variables (ChunkSaveClass &csave); - bool Load_Variables (ChunkLoadClass &cload); - - ///////////////////////////////////////////////////////////////////// - // Private member data - ///////////////////////////////////////////////////////////////////// - uint32 m_IndirectClassID; - DynamicVectorClass m_DefinitionList; -}; - - -///////////////////////////////////////////////////////////////////// -// Get_Indirect_Class_ID -///////////////////////////////////////////////////////////////////// -inline uint32 -TwiddlerClass::Get_Indirect_Class_ID () const -{ - return m_IndirectClassID; -} - - -///////////////////////////////////////////////////////////////////// -// Set_Indirect_Class_ID -///////////////////////////////////////////////////////////////////// -inline void -TwiddlerClass::Set_Indirect_Class_ID (uint32 class_id) -{ - m_IndirectClassID = class_id; -} diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.cpp deleted file mode 100644 index ac5179896f6..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : wwsaveload * - * * - * $Archive:: /Commando/Code/wwsaveload/wwsaveload.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 3/28/00 9:18a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "wwsaveload.h" -#include "definitionmgr.h" - - -void WWSaveLoad::Init() -{ -} - -void WWSaveLoad::Shutdown() -{ - _TheDefinitionMgr.Free_Definitions(); -} - - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h deleted file mode 100644 index 79336fcbe70..00000000000 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWSaveLoad * - * * - * $Archive:: /Commando/Code/wwsaveload/wwsaveload.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 3/28/00 9:20a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#pragma once - -/** -** WWSaveLoad -** The Init and Shutdown functions should be called once by the App. -*/ - -class WWSaveLoad -{ -public: - static void Init(); - static void Shutdown(); -}; diff --git a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp index a0874d0eece..84d98ebbc0d 100644 --- a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp +++ b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp @@ -25,11 +25,6 @@ #include "AnimatedSoundOptionsDialog.h" #include "WWLib/ffactory.h" #include "WW3D2/animatedsoundmgr.h" -#include "WWSaveLoad/wwsaveload.h" -#include "WWSaveLoad/definitionmgr.h" -#include "WWLib/WWFILE.h" -#include "WWLib/chunkio.h" -#include "WWDebug/wwdebug.h" #include "RestrictedFileDialog.h" #include "Utils.h" @@ -64,37 +59,12 @@ void AnimatedSoundOptionsDialogClass::DoDataExchange(CDataExchange* pDX) BEGIN_MESSAGE_MAP(AnimatedSoundOptionsDialogClass, CDialog) //{{AFX_MSG_MAP(AnimatedSoundOptionsDialogClass) - ON_BN_CLICKED(IDC_SOUND_DEFINITION_LIBRARY_BROWSE_BUTTON, OnSoundDefinitionLibraryBrowseButton) ON_BN_CLICKED(IDC_SOUND_INI_BROWSE_BUTTON, OnSoundIniBrowseButton) ON_BN_CLICKED(IDC_SOUND_PATH_BROWSE_BUTTON, OnSoundPathBrowseButton) //}}AFX_MSG_MAP END_MESSAGE_MAP() -///////////////////////////////////////////////////////////////////////////// -// -// OnSoundDefinitionLibraryBrowseButton -// -///////////////////////////////////////////////////////////////////////////// -void -AnimatedSoundOptionsDialogClass::OnSoundDefinitionLibraryBrowseButton () -{ - CFileDialog dialog ( TRUE, - ".ddb", - "20480.ddb", - OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, - "Definition Database Files(*.ddb)|*.ddb||", - this); - - // - // Prompt the user - // - if (dialog.DoModal () == IDOK) { - SetDlgItemText (IDC_SOUND_DEFINITION_LIBRARY_EDIT, dialog.GetPathName ()); - } -} - - ///////////////////////////////////////////////////////////////////////////// // // OnSoundIniBrowseButton @@ -132,17 +102,14 @@ AnimatedSoundOptionsDialogClass::OnOK () // // Get the user's response // - CString sound_def_lib_path; CString sound_ini_path; CString sound_data_path; - GetDlgItemText (IDC_SOUND_DEFINITION_LIBRARY_EDIT, sound_def_lib_path); GetDlgItemText (IDC_SOUND_INI_EDIT, sound_ini_path); GetDlgItemText (IDC_SOUND_FILE_PATH_EDIT, sound_data_path); // // Store this information in the registry // - theApp.WriteProfileString ("Config", "SoundDefLibPath", sound_def_lib_path); theApp.WriteProfileString ("Config", "AnimSoundINIPath", sound_ini_path); theApp.WriteProfileString ("Config", "AnimSoundDataPath", sound_data_path); @@ -160,14 +127,12 @@ AnimatedSoundOptionsDialogClass::OnInitDialog () { CDialog::OnInitDialog (); - StringClass sound_def_lib_path = static_cast(theApp.GetProfileString ("Config", "SoundDefLibPath")); StringClass sound_ini_path = static_cast(theApp.GetProfileString ("Config", "AnimSoundINIPath")); StringClass sound_data_path = static_cast(theApp.GetProfileString ("Config", "AnimSoundDataPath")); // // Fill in the default values // - SetDlgItemText (IDC_SOUND_DEFINITION_LIBRARY_EDIT, sound_def_lib_path); SetDlgItemText (IDC_SOUND_INI_EDIT, sound_ini_path); SetDlgItemText (IDC_SOUND_FILE_PATH_EDIT, sound_data_path); @@ -183,32 +148,12 @@ AnimatedSoundOptionsDialogClass::OnInitDialog () void AnimatedSoundOptionsDialogClass::Load_Animated_Sound_Settings () { - // - // Start fresh - // - DefinitionMgrClass::Free_Definitions (); - // // Get the data from the registry // - StringClass sound_def_lib_path = static_cast(theApp.GetProfileString ("Config", "SoundDefLibPath")); StringClass sound_ini_path = static_cast(theApp.GetProfileString ("Config", "AnimSoundINIPath")); StringClass sound_data_path = static_cast(theApp.GetProfileString ("Config", "AnimSoundDataPath")); - // - // Try to load the definitions into the definition mgr - // - FileClass *file = _TheFileFactory->Get_File (sound_def_lib_path); - if (file != nullptr) { - file->Open (FileClass::READ); - ChunkLoadClass cload (file); - SaveLoadSystemClass::Load (cload); - file->Close (); - _TheFileFactory->Return_File (file); - } else { - WWDEBUG_SAY (("Failed to load file %s", sound_def_lib_path.str ())); - } - // // Load the sound settings from the ini file // diff --git a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h index 53322030790..e20c7c9f1e9 100644 --- a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h +++ b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h @@ -49,7 +49,6 @@ class AnimatedSoundOptionsDialogClass : public CDialog // Generated message map functions //{{AFX_MSG(AnimatedSoundOptionsDialogClass) - afx_msg void OnSoundDefinitionLibraryBrowseButton(); afx_msg void OnSoundIniBrowseButton(); virtual void OnOK() override; virtual BOOL OnInitDialog() override; diff --git a/Core/Tools/W3DView/SoundEditDialog.cpp b/Core/Tools/W3DView/SoundEditDialog.cpp index dc3c8ada537..ecabbdbe6b7 100644 --- a/Core/Tools/W3DView/SoundEditDialog.cpp +++ b/Core/Tools/W3DView/SoundEditDialog.cpp @@ -234,18 +234,12 @@ SoundEditDialogClass::OnOK () } // - // Create a sound definition from the settings on the dialog + // Pass a sound with the settings on the dialog onto the render object // AudibleSoundClass *sound = Create_Sound_Object (); - AudibleSoundDefinitionClass definition; - definition.Initialize_From_Sound (sound); + SoundRObj->Set_Sound (sound); REF_PTR_RELEASE (sound); - // - // Pass the sound definition onto the render object - // - SoundRObj->Set_Sound (&definition); - // // Pass the flags onto the render object // diff --git a/Core/Tools/W3DView/W3DView.rc b/Core/Tools/W3DView/W3DView.rc index 3c640bc25bd..6a98cf4a95f 100644 --- a/Core/Tools/W3DView/W3DView.rc +++ b/Core/Tools/W3DView/W3DView.rc @@ -2041,24 +2041,19 @@ BEGIN LTEXT "Instructions",IDC_INSTRUCTIONS,7,13,217,88 END -IDD_ANIMATED_SOUND_DIALOG DIALOG DISCARDABLE 0, 0, 286, 162 +IDD_ANIMATED_SOUND_DIALOG DIALOG DISCARDABLE 0, 0, 286, 127 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Animated Sound Options" FONT 8, "MS Sans Serif" BEGIN - LTEXT "&Sound Preset Library Path:",IDC_STATIC,7,37,119,8 - EDITTEXT IDC_SOUND_DEFINITION_LIBRARY_EDIT,7,47,217,14, - ES_AUTOHSCROLL - PUSHBUTTON "&Browse...",IDC_SOUND_DEFINITION_LIBRARY_BROWSE_BUTTON, - 229,47,50,14 - LTEXT "&Animated Sound INI Path:",IDC_STATIC,7,72,119,8 - EDITTEXT IDC_SOUND_INI_EDIT,7,82,217,14,ES_AUTOHSCROLL - PUSHBUTTON "Bro&wse...",IDC_SOUND_INI_BROWSE_BUTTON,229,82,50,14 - LTEXT "Sound &File(s) Path:",IDC_STATIC,7,105,119,8 - EDITTEXT IDC_SOUND_FILE_PATH_EDIT,7,115,217,14,ES_AUTOHSCROLL - PUSHBUTTON "B&rowse...",IDC_SOUND_PATH_BROWSE_BUTTON,229,115,50,14 - DEFPUSHBUTTON "OK",IDOK,82,141,50,14 - PUSHBUTTON "Cancel",IDCANCEL,153,141,50,14 + LTEXT "&Animated Sound INI Path:",IDC_STATIC,7,37,119,8 + EDITTEXT IDC_SOUND_INI_EDIT,7,47,217,14,ES_AUTOHSCROLL + PUSHBUTTON "Bro&wse...",IDC_SOUND_INI_BROWSE_BUTTON,229,47,50,14 + LTEXT "Sound &File(s) Path:",IDC_STATIC,7,70,119,8 + EDITTEXT IDC_SOUND_FILE_PATH_EDIT,7,80,217,14,ES_AUTOHSCROLL + PUSHBUTTON "B&rowse...",IDC_SOUND_PATH_BROWSE_BUTTON,229,80,50,14 + DEFPUSHBUTTON "OK",IDOK,82,106,50,14 + PUSHBUTTON "Cancel",IDCANCEL,153,106,50,14 ICON IDI_SOUND,IDC_STATIC,7,7,21,20 LTEXT "Use the controls below to configure the animation-triggered sound effect settings for the viewer.", IDC_STATIC,40,7,239,23 @@ -2587,7 +2582,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 279 TOPMARGIN, 7 - BOTTOMMARGIN, 155 + BOTTOMMARGIN, 120 END END #endif // APSTUDIO_INVOKED diff --git a/Core/Tools/W3DView/resource.h b/Core/Tools/W3DView/resource.h index f43e33eb37c..b8d6fcd1bd9 100644 --- a/Core/Tools/W3DView/resource.h +++ b/Core/Tools/W3DView/resource.h @@ -8,7 +8,6 @@ #define IDC_RESTORE 3 #define IDC_RESET 3 #define IDOK2 3 -#define IDC_SOUND_DEFINITION_LIBRARY_BROWSE_BUTTON 3 #define IDC_ADVANCED 4 #define IDC_APPLY 4 #define IDC_SOUND_INI_BROWSE_BUTTON 4 @@ -183,7 +182,6 @@ #define IDC_HFOV_EDIT 1020 #define IDC_PATH1 1020 #define IDC_SIZE_X_EDIT 1020 -#define IDC_SOUND_DEFINITION_LIBRARY_EDIT 1020 #define IDC_EDIT2 1021 #define IDC_PROGRAMMER_SETTINGS_EDIT 1021 #define IDC_GREEN_EDIT 1021 diff --git a/Core/Tools/WW3D/max2w3d/w3d_file.h b/Core/Tools/WW3D/max2w3d/w3d_file.h index df9e22a1237..bc4d937e7f9 100644 --- a/Core/Tools/WW3D/max2w3d/w3d_file.h +++ b/Core/Tools/WW3D/max2w3d/w3d_file.h @@ -2054,8 +2054,8 @@ struct W3dNullObjectStruct // // Note: This structure is follwed directly by a chunk (W3D_CHUNK_SOUNDROBJ_DEFINITION) -// that contains an embedded AudibleSoundDefinitionClass's storage. See audibledound.h -// for details. +// that contains the settings of the sound. See SoundRenderObjDefClass::Write_Definition +// in soundrobj.cpp for details. // struct W3dSoundRObjHeaderStruct { diff --git a/Generals/.gitignore b/Generals/.gitignore index 2aeb61280a3..da1b4ececb4 100644 --- a/Generals/.gitignore +++ b/Generals/.gitignore @@ -67,13 +67,6 @@ Max4Hybrid /Code/Libraries/Lib/WWMathDebugW3D.lib /Code/Libraries/Lib/WWMathInternal.lib /Code/Libraries/Lib/WWMathProfile.lib -/Code/Libraries/Lib/WWSaveLoad.lib -/Code/Libraries/Lib/WWSaveLoadDebug.lib -/Code/Libraries/Lib/WWSaveLoadDebugE.lib -/Code/Libraries/Lib/WWSaveLoadDebugW3D.lib -/Code/Libraries/Lib/WWSaveLoadInternal.lib -/Code/Libraries/Lib/WWSaveLoadProfile.lib -/Code/Libraries/Lib/WWSaveLoadProfileE.lib /Code/Libraries/Lib/WWUtil.lib /Code/Libraries/Lib/WWUtilDebug.lib /Code/Libraries/Lib/WWUtilDebugW3D.lib diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index 4891c069ee6..b76acf6ea41 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -224,7 +224,6 @@ set(WW3D2_SRC # ww3d.h #ww3dformat.cpp #ww3dformat.h - #ww3dids.h #ww3dtrig.h ) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index 3f0dd3302ab..9f87b70015a 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -55,8 +55,6 @@ #include "WWLib/chunkio.h" #include "WWLib/WWFILE.h" #include "WWLib/inisup.h" -#include "WWSaveLoad/persistfactory.h" -#include "ww3dids.h" #include "dx8wrapper.h" #include "dx8vertexbuffer.h" #include "dx8indexbuffer.h" @@ -1308,130 +1306,6 @@ void DazzleRenderObjClass::Special_Render(SpecialRenderInfoClass & rinfo) -/**************************************************************************************** - - - DazzleRenderObjClass - Persistent object support. - - Dazzles are going to save their type and their transform and simply - re-create another dazzle of the same type when loaded. - - -****************************************************************************************/ - -class DazzlePersistFactoryClass : public PersistFactoryClass -{ - virtual uint32 Chunk_ID() const override; - virtual PersistClass * Load(ChunkLoadClass & cload) const override; - virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const override; - - enum - { - DAZZLEFACTORY_CHUNKID_VARIABLES = 1212000336, - DAZZLEFACTORY_VARIABLE_OBJPOINTER = 0x00, - OBSOLETE_DAZZLEFACTORY_VARIABLE_TYPE, - DAZZLEFACTORY_VARIABLE_TRANSFORM, - DAZZLEFACTORY_VARIABLE_TYPENAME, - }; -}; - -static DazzlePersistFactoryClass _DazzleFactory; - -uint32 DazzlePersistFactoryClass::Chunk_ID() const -{ - return WW3D_PERSIST_CHUNKID_DAZZLE; -} - -PersistClass * DazzlePersistFactoryClass::Load(ChunkLoadClass & cload) const -{ - DazzleRenderObjClass * old_obj = nullptr; - Matrix3D tm(1); - char dazzle_type[256]; - dazzle_type[0] = 0; - - /* - ** Load the dazzle parameters - */ - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - - case DAZZLEFACTORY_CHUNKID_VARIABLES: - - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,DAZZLEFACTORY_VARIABLE_OBJPOINTER,old_obj); - READ_MICRO_CHUNK(cload,DAZZLEFACTORY_VARIABLE_TRANSFORM,tm); - READ_MICRO_CHUNK_STRING(cload,DAZZLEFACTORY_VARIABLE_TYPENAME,dazzle_type,sizeof(dazzle_type)); - } - cload.Close_Micro_Chunk(); - } - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - }; - cload.Close_Chunk(); - } - - /* - ** Create a new dazzle object - */ - int type_index = 0; - if (strlen(dazzle_type) > 0) { - type_index = DazzleRenderObjClass::Get_Type_ID(dazzle_type); - } - RenderObjClass * new_obj = NEW_REF(DazzleRenderObjClass,(dazzle_type)); - - /* - ** If we failed to create it, replace it with a nullptr - */ - if (new_obj == nullptr) { - static int count = 0; - if ( count++ < 10 ) { - WWDEBUG_SAY(("DazzlePersistFactory failed to create dazzle of type: %s!!",dazzle_type)); - WWDEBUG_SAY(("Replacing it with a null render object!")); - } - new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj("NULL"); - } - - WWASSERT(new_obj != nullptr); - if (new_obj) { - new_obj->Set_Transform(tm); - } - - /* - ** Register the old pointer for re-mapping to the new pointer - */ - SaveLoadSystemClass::Register_Pointer(old_obj,new_obj); - return new_obj; -} - -void DazzlePersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj) const -{ - DazzleRenderObjClass * robj = (DazzleRenderObjClass *)obj; - unsigned int dazzle_type = robj->Get_Dazzle_Type(); - const char * dazzle_type_name = DazzleRenderObjClass::Get_Type_Name(dazzle_type); - const Matrix3D& tm = robj->Get_Transform(); - - csave.Begin_Chunk(DAZZLEFACTORY_CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK(csave,DAZZLEFACTORY_VARIABLE_OBJPOINTER,robj); - WRITE_MICRO_CHUNK(csave,DAZZLEFACTORY_VARIABLE_TRANSFORM,tm); - WRITE_MICRO_CHUNK_STRING(csave,DAZZLEFACTORY_VARIABLE_TYPENAME,dazzle_type_name); - - csave.End_Chunk(); -} - - -/* -** DazzleRenderObj save-load. -*/ -const PersistFactoryClass & DazzleRenderObjClass::Get_Factory () const -{ - return _DazzleFactory; -} - - /********************************************************************************************** ** diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h index f83e7e65678..d453539e42f 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h @@ -298,10 +298,6 @@ class DazzleRenderObjClass : public RenderObjClass // internally by the Render() function. void Set_Layer(DazzleLayerClass *layer); - // Persistent object save-load interface - // Dazzles save their "dazzle-type" and transform - virtual const PersistFactoryClass & Get_Factory () const override; - // Set the static "current layer" variable. This variable is used in the // Render() call so that the dazzle knows which list to add itself to if // it is visible. This function must be called before rendering the diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.cpp index f9afda2138c..dd40e6ceab5 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.cpp @@ -48,9 +48,6 @@ * LightClass::Notify_Removed -- lights remove themselves from the VP list when removed * * LightClass::Load_W3D -- Initialize this light from a W3D file * * LightClass::Save_W3D -- Save this light's settings into a W3D file * - * LightClass::Get_Factory -- get the PersistFactory for LightClass * - * LightClass::Save -- persistent object support * - * LightClass::Load -- persistent object support * * LightImpClass::LightImpClass -- constructor * * LightImpClass::Process_Push -- exposes the "push" process for an srLight * * LightImpClass::Process_Pop -- exposes the "pop" process for an srLight * @@ -58,36 +55,16 @@ #include "light.h" #include "ww3d.h" -#include "ww3dids.h" #include "w3d_file.h" #include "w3d_util.h" #include "w3derr.h" #include "WWLib/chunkio.h" #include "rinfo.h" #include "scene.h" -#include "WWSaveLoad/persistfactory.h" #include "statistics.h" -/* -** PersistFactory for LightClasses - lights have custom save-load support -*/ -SimplePersistFactoryClass _LightFactory; - -/* -** Chunk ID's used by LightClass's save-load support (different from the W3D file format...) -*/ -enum -{ - LIGHT_CHUNK_W3DFILE = 0x02157100, // (w3d format light) - LIGHT_CHUNK_VARIABLES, // other state not stored in the w3d format - - LIGHT_VARIABLE_TRANSFORM = 0x00, // transform for the light -}; - - - /*********************************************************************************************** * LightClass::LightClass -- Constructor * * * @@ -488,94 +465,3 @@ WW3DErrorType LightClass::Save_W3D(ChunkSaveClass & csave) return WW3D_ERROR_OK; } - -/*********************************************************************************************** - * LightClass::Get_Factory -- get the PersistFactory for LightClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/23/99 GTH : Created. * - *=============================================================================================*/ -const PersistFactoryClass & LightClass::Get_Factory () const -{ - return _LightFactory; -} - - -/*********************************************************************************************** - * LightClass::Save -- persistent object support * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/23/99 GTH : Created. * - *=============================================================================================*/ -bool LightClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk(LIGHT_CHUNK_W3DFILE); - Save_W3D(csave); - csave.End_Chunk(); - - const Matrix3D& tm = Get_Transform(); - csave.Begin_Chunk(LIGHT_CHUNK_VARIABLES); - WRITE_MICRO_CHUNK(csave,LIGHT_VARIABLE_TRANSFORM,tm); - csave.End_Chunk(); - - return true; -} - - -/*********************************************************************************************** - * LightClass::Load -- persistent object support * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/23/99 GTH : Created. * - *=============================================================================================*/ -bool LightClass::Load (ChunkLoadClass &cload) -{ - Matrix3D tm(1); - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - - case LIGHT_CHUNK_W3DFILE: - // The W3D code is non-symmetrical, the Save function writes a W3D_LIGHT chunk - // but the load function expects the external user to have opened it. So open it here... - cload.Open_Chunk(); - Load_W3D(cload); - cload.Close_Chunk(); - break; - - case LIGHT_CHUNK_VARIABLES: - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,LIGHT_VARIABLE_TRANSFORM,tm); - } - cload.Close_Micro_Chunk(); - } - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - } - cload.Close_Chunk(); - } - Set_Transform(tm); - return true; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.h index fc83c136f36..937fec413f7 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.h +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/light.h @@ -142,12 +142,6 @@ class LightClass : public RenderObjClass WW3DErrorType Load_W3D(ChunkLoadClass & cload); WW3DErrorType Save_W3D(ChunkSaveClass & csave); - ///////////////////////////////////////////////////////////////////////////// - // Persistent object save-load interface - ///////////////////////////////////////////////////////////////////////////// - virtual const PersistFactoryClass & Get_Factory () const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; //bool isDonut() {return Donut; }; //void setDonut(bool donut) { Donut = donut; }; diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp index e89f444b283..85e5c755d0f 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp @@ -50,8 +50,6 @@ * SimpleSceneClass::Render -- Render this scene * * SimpleSceneClass::Create_Iterator -- create an iterator for this scene * * SimpleSceneClass::Destroy_Iterator -- destroy an iterater of this scene * - * SceneClass::Save -- saves scene settings into a chunk * - * SceneClass::Load -- loads scene settings from a chunk * * SimpleSceneClass::Compute_Point_Visibility -- returns visibility of a point * * SimpleSceneClass::Remove_All_Render_Objects -- Removes all render objects from the scene * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -63,28 +61,12 @@ #include "ww3d.h" #include "Renderer.h" #include "rinfo.h" -#include "WWLib/chunkio.h" #include "dx8renderer.h" #include "dx8wrapper.h" #include "sortingrenderer.h" #include "coltest.h" -/* -** Chunk ID's used by SceneClass -*/ -enum -{ - SCENECLASS_CHUNK_VARIABLES = 0x00042300, - - SCENECLASS_VARIABLE_AMBIENTLIGHT = 0x00, - SCENECLASS_VARIABLE_POLYRENDERMODE, - SCENECLASS_VARIABLE_FOGCOLOR, - SCENECLASS_VARIABLE_FOGENABLED, - SCENECLASS_VARIABLE_FOGSTART, - SCENECLASS_VARIABLE_FOGEND, -}; - /* ** SimpleSceneIterator ** This iterator is used by the SimpleSceneClass to allow @@ -239,64 +221,6 @@ void SceneClass::Render(RenderInfoClass & rinfo) } } -/*********************************************************************************************** - * SceneClass::Save -- saves scene settings into a chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void SceneClass::Save(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(SCENECLASS_CHUNK_VARIABLES); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_AMBIENTLIGHT,AmbientLight); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_POLYRENDERMODE,PolyRenderMode); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGCOLOR,FogColor); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGENABLED,FogEnabled); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGSTART,FogStart); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGEND,FogEnd); - csave.End_Chunk(); -} - - -/*********************************************************************************************** - * SceneClass::Load -- loads scene settings from a chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void SceneClass::Load(ChunkLoadClass & cload) -{ - cload.Open_Chunk(); - if (cload.Cur_Chunk_ID() == SCENECLASS_CHUNK_VARIABLES) { - - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_AMBIENTLIGHT,AmbientLight); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_POLYRENDERMODE,PolyRenderMode); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGCOLOR,FogColor); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGENABLED,FogEnabled); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGSTART,FogStart); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGEND,FogEnd); - } - cload.Close_Micro_Chunk(); - } - - } else { - WWDEBUG_SAY(("Unhandled Chunk: 0x%X in file: %s line: %d",cload.Cur_Chunk_ID(),__FILE__,__LINE__)); - } - cload.Close_Chunk(); -} - /*********************************************************************************************** * SimpleSceneClass -- Constructor * diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.h index 7aa548c39e3..5812aea289d 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.h +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.h @@ -44,8 +44,6 @@ class RenderObjClass; class RenderInfoClass; class CameraClass; -class ChunkLoadClass; -class ChunkSaveClass; /* ** SceneIterator @@ -169,13 +167,6 @@ class SceneClass : public RefCountClass virtual float Compute_Point_Visibility( RenderInfoClass & rinfo, const Vector3 & point) { return 1.0f; } - - /////////////////////////////////////////////////////////////////////////////////// - // Save-Load, records the fog, depth cue, etc settings into a chunk - /////////////////////////////////////////////////////////////////////////////////// - virtual void Save(ChunkSaveClass & csave); - virtual void Load(ChunkLoadClass & cload); - protected: virtual void Render(RenderInfoClass & rinfo); //Made virtual so we can override -MW diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h index 35588ab84b0..e1ce997ce5f 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h @@ -2189,8 +2189,8 @@ struct W3dNullObjectStruct // // Note: This structure is followed directly by a chunk (W3D_CHUNK_SOUNDROBJ_DEFINITION) -// that contains an embedded AudibleSoundDefinitionClass's storage. See audibledound.h -// for details. +// that contains the settings of the sound. See SoundRenderObjDefClass::Write_Definition +// in soundrobj.cpp for details. // struct W3dSoundRObjHeaderStruct { diff --git a/GeneralsMD/.gitignore b/GeneralsMD/.gitignore index 4841958c6c8..4ab0a25be27 100644 --- a/GeneralsMD/.gitignore +++ b/GeneralsMD/.gitignore @@ -69,13 +69,6 @@ Max4Hybrid /Code/Libraries/Lib/WWMathDebugW3D.lib /Code/Libraries/Lib/WWMathInternal.lib /Code/Libraries/Lib/WWMathProfile.lib -/Code/Libraries/Lib/WWSaveLoad.lib -/Code/Libraries/Lib/WWSaveLoadDebug.lib -/Code/Libraries/Lib/WWSaveLoadDebugE.lib -/Code/Libraries/Lib/WWSaveLoadDebugW3D.lib -/Code/Libraries/Lib/WWSaveLoadInternal.lib -/Code/Libraries/Lib/WWSaveLoadProfile.lib -/Code/Libraries/Lib/WWSaveLoadProfileE.lib /Code/Libraries/Lib/WWShade.lib /Code/Libraries/Lib/WWShadeDebug.lib /Code/Libraries/Lib/WWShadeDebugW3D.lib diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index 0c2da708f7c..d80ec07910e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -229,7 +229,6 @@ set(WW3D2_SRC # ww3d.h #ww3dformat.cpp #ww3dformat.h - #ww3dids.h #ww3dtrig.h ) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index cfe2e251433..f6eb30dad35 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -55,8 +55,6 @@ #include "WWLib/chunkio.h" #include "WWLib/WWFILE.h" #include "WWLib/inisup.h" -#include "WWSaveLoad/persistfactory.h" -#include "ww3dids.h" #include "dx8wrapper.h" #include "dx8vertexbuffer.h" #include "dx8indexbuffer.h" @@ -1411,130 +1409,6 @@ void DazzleRenderObjClass::Special_Render(SpecialRenderInfoClass & rinfo) -/**************************************************************************************** - - - DazzleRenderObjClass - Persistent object support. - - Dazzles are going to save their type and their transform and simply - re-create another dazzle of the same type when loaded. - - -****************************************************************************************/ - -class DazzlePersistFactoryClass : public PersistFactoryClass -{ - virtual uint32 Chunk_ID() const override; - virtual PersistClass * Load(ChunkLoadClass & cload) const override; - virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const override; - - enum - { - DAZZLEFACTORY_CHUNKID_VARIABLES = 1212000336, - DAZZLEFACTORY_VARIABLE_OBJPOINTER = 0x00, - OBSOLETE_DAZZLEFACTORY_VARIABLE_TYPE, - DAZZLEFACTORY_VARIABLE_TRANSFORM, - DAZZLEFACTORY_VARIABLE_TYPENAME, - }; -}; - -static DazzlePersistFactoryClass _DazzleFactory; - -uint32 DazzlePersistFactoryClass::Chunk_ID() const -{ - return WW3D_PERSIST_CHUNKID_DAZZLE; -} - -PersistClass * DazzlePersistFactoryClass::Load(ChunkLoadClass & cload) const -{ - DazzleRenderObjClass * old_obj = nullptr; - Matrix3D tm(1); - char dazzle_type[256]; - dazzle_type[0] = 0; - - /* - ** Load the dazzle parameters - */ - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - - case DAZZLEFACTORY_CHUNKID_VARIABLES: - - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,DAZZLEFACTORY_VARIABLE_OBJPOINTER,old_obj); - READ_MICRO_CHUNK(cload,DAZZLEFACTORY_VARIABLE_TRANSFORM,tm); - READ_MICRO_CHUNK_STRING(cload,DAZZLEFACTORY_VARIABLE_TYPENAME,dazzle_type,sizeof(dazzle_type)); - } - cload.Close_Micro_Chunk(); - } - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - }; - cload.Close_Chunk(); - } - - /* - ** Create a new dazzle object - */ - int type_index = 0; - if (strlen(dazzle_type) > 0) { - type_index = DazzleRenderObjClass::Get_Type_ID(dazzle_type); - } - RenderObjClass * new_obj = NEW_REF(DazzleRenderObjClass,(dazzle_type)); - - /* - ** If we failed to create it, replace it with a nullptr - */ - if (new_obj == nullptr) { - static int count = 0; - if ( count++ < 10 ) { - WWDEBUG_SAY(("DazzlePersistFactory failed to create dazzle of type: %s!!",dazzle_type)); - WWDEBUG_SAY(("Replacing it with a null render object!")); - } - new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj("NULL"); - } - - WWASSERT(new_obj != nullptr); - if (new_obj) { - new_obj->Set_Transform(tm); - } - - /* - ** Register the old pointer for re-mapping to the new pointer - */ - SaveLoadSystemClass::Register_Pointer(old_obj,new_obj); - return new_obj; -} - -void DazzlePersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj) const -{ - DazzleRenderObjClass * robj = (DazzleRenderObjClass *)obj; - unsigned int dazzle_type = robj->Get_Dazzle_Type(); - const char * dazzle_type_name = DazzleRenderObjClass::Get_Type_Name(dazzle_type); - const Matrix3D& tm = robj->Get_Transform(); - - csave.Begin_Chunk(DAZZLEFACTORY_CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK(csave,DAZZLEFACTORY_VARIABLE_OBJPOINTER,robj); - WRITE_MICRO_CHUNK(csave,DAZZLEFACTORY_VARIABLE_TRANSFORM,tm); - WRITE_MICRO_CHUNK_STRING(csave,DAZZLEFACTORY_VARIABLE_TYPENAME,dazzle_type_name); - - csave.End_Chunk(); -} - - -/* -** DazzleRenderObj save-load. -*/ -const PersistFactoryClass & DazzleRenderObjClass::Get_Factory () const -{ - return _DazzleFactory; -} - - /********************************************************************************************** ** diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h index de8e7190bb5..5fea86704dd 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.h @@ -298,10 +298,6 @@ class DazzleRenderObjClass : public RenderObjClass // internally by the Render() function. void Set_Layer(DazzleLayerClass *layer); - // Persistent object save-load interface - // Dazzles save their "dazzle-type" and transform - virtual const PersistFactoryClass & Get_Factory () const override; - // Set the static "current layer" variable. This variable is used in the // Render() call so that the dazzle knows which list to add itself to if // it is visible. This function must be called before rendering the diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.cpp index f0fe0185f04..fe955dac69e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.cpp @@ -48,9 +48,6 @@ * LightClass::Notify_Removed -- lights remove themselves from the VP list when removed * * LightClass::Load_W3D -- Initialize this light from a W3D file * * LightClass::Save_W3D -- Save this light's settings into a W3D file * - * LightClass::Get_Factory -- get the PersistFactory for LightClass * - * LightClass::Save -- persistent object support * - * LightClass::Load -- persistent object support * * LightImpClass::LightImpClass -- constructor * * LightImpClass::Process_Push -- exposes the "push" process for an srLight * * LightImpClass::Process_Pop -- exposes the "pop" process for an srLight * @@ -58,36 +55,16 @@ #include "light.h" #include "ww3d.h" -#include "ww3dids.h" #include "w3d_file.h" #include "w3d_util.h" #include "w3derr.h" #include "WWLib/chunkio.h" #include "rinfo.h" #include "scene.h" -#include "WWSaveLoad/persistfactory.h" #include "statistics.h" -/* -** PersistFactory for LightClasses - lights have custom save-load support -*/ -SimplePersistFactoryClass _LightFactory; - -/* -** Chunk ID's used by LightClass's save-load support (different from the W3D file format...) -*/ -enum -{ - LIGHT_CHUNK_W3DFILE = 0x02157100, // (w3d format light) - LIGHT_CHUNK_VARIABLES, // other state not stored in the w3d format - - LIGHT_VARIABLE_TRANSFORM = 0x00, // transform for the light -}; - - - /*********************************************************************************************** * LightClass::LightClass -- Constructor * * * @@ -488,94 +465,3 @@ WW3DErrorType LightClass::Save_W3D(ChunkSaveClass & csave) return WW3D_ERROR_OK; } - -/*********************************************************************************************** - * LightClass::Get_Factory -- get the PersistFactory for LightClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/23/99 GTH : Created. * - *=============================================================================================*/ -const PersistFactoryClass & LightClass::Get_Factory () const -{ - return _LightFactory; -} - - -/*********************************************************************************************** - * LightClass::Save -- persistent object support * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/23/99 GTH : Created. * - *=============================================================================================*/ -bool LightClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk(LIGHT_CHUNK_W3DFILE); - Save_W3D(csave); - csave.End_Chunk(); - - const Matrix3D& tm = Get_Transform(); - csave.Begin_Chunk(LIGHT_CHUNK_VARIABLES); - WRITE_MICRO_CHUNK(csave,LIGHT_VARIABLE_TRANSFORM,tm); - csave.End_Chunk(); - - return true; -} - - -/*********************************************************************************************** - * LightClass::Load -- persistent object support * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/23/99 GTH : Created. * - *=============================================================================================*/ -bool LightClass::Load (ChunkLoadClass &cload) -{ - Matrix3D tm(1); - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - - case LIGHT_CHUNK_W3DFILE: - // The W3D code is non-symmetrical, the Save function writes a W3D_LIGHT chunk - // but the load function expects the external user to have opened it. So open it here... - cload.Open_Chunk(); - Load_W3D(cload); - cload.Close_Chunk(); - break; - - case LIGHT_CHUNK_VARIABLES: - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,LIGHT_VARIABLE_TRANSFORM,tm); - } - cload.Close_Micro_Chunk(); - } - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d",__FILE__,__LINE__)); - break; - } - cload.Close_Chunk(); - } - Set_Transform(tm); - return true; -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.h index 605cae0115b..be7f774e80f 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/light.h @@ -143,12 +143,6 @@ class LightClass : public RenderObjClass WW3DErrorType Load_W3D(ChunkLoadClass & cload); WW3DErrorType Save_W3D(ChunkSaveClass & csave); - ///////////////////////////////////////////////////////////////////////////// - // Persistent object save-load interface - ///////////////////////////////////////////////////////////////////////////// - virtual const PersistFactoryClass & Get_Factory () const override; - virtual bool Save (ChunkSaveClass &csave) override; - virtual bool Load (ChunkLoadClass &cload) override; //bool isDonut() {return Donut; }; //void setDonut(bool donut) { Donut = donut; }; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp index a8993708be2..3e091867147 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp @@ -54,8 +54,6 @@ * SimpleSceneClass::Render -- Render this scene * * SimpleSceneClass::Create_Iterator -- create an iterator for this scene * * SimpleSceneClass::Destroy_Iterator -- destroy an iterator of this scene * - * SceneClass::Save -- saves scene settings into a chunk * - * SceneClass::Load -- loads scene settings from a chunk * * SimpleSceneClass::Compute_Point_Visibility -- returns visibility of a point * * SimpleSceneClass::Remove_All_Render_Objects -- Removes all render objects from the scene * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -67,28 +65,12 @@ #include "ww3d.h" #include "Renderer.h" #include "rinfo.h" -#include "WWLib/chunkio.h" #include "dx8renderer.h" #include "dx8wrapper.h" #include "sortingrenderer.h" #include "coltest.h" -/* -** Chunk ID's used by SceneClass -*/ -enum -{ - SCENECLASS_CHUNK_VARIABLES = 0x00042300, - - SCENECLASS_VARIABLE_AMBIENTLIGHT = 0x00, - SCENECLASS_VARIABLE_POLYRENDERMODE, - SCENECLASS_VARIABLE_FOGCOLOR, - SCENECLASS_VARIABLE_FOGENABLED, - SCENECLASS_VARIABLE_FOGSTART, - SCENECLASS_VARIABLE_FOGEND, -}; - /* ** SimpleSceneIterator ** This iterator is used by the SimpleSceneClass to allow @@ -249,64 +231,6 @@ void SceneClass::Render(RenderInfoClass & rinfo) Post_Render_Processing(rinfo); } -/*********************************************************************************************** - * SceneClass::Save -- saves scene settings into a chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void SceneClass::Save(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(SCENECLASS_CHUNK_VARIABLES); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_AMBIENTLIGHT,AmbientLight); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_POLYRENDERMODE,PolyRenderMode); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGCOLOR,FogColor); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGENABLED,FogEnabled); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGSTART,FogStart); - WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGEND,FogEnd); - csave.End_Chunk(); -} - - -/*********************************************************************************************** - * SceneClass::Load -- loads scene settings from a chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void SceneClass::Load(ChunkLoadClass & cload) -{ - cload.Open_Chunk(); - if (cload.Cur_Chunk_ID() == SCENECLASS_CHUNK_VARIABLES) { - - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_AMBIENTLIGHT,AmbientLight); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_POLYRENDERMODE,PolyRenderMode); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGCOLOR,FogColor); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGENABLED,FogEnabled); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGSTART,FogStart); - READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGEND,FogEnd); - } - cload.Close_Micro_Chunk(); - } - - } else { - WWDEBUG_SAY(("Unhandled Chunk: 0x%X in file: %s line: %d",cload.Cur_Chunk_ID(),__FILE__,__LINE__)); - } - cload.Close_Chunk(); -} - /*********************************************************************************************** * SimpleSceneClass -- Constructor * diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.h index a358f9d0a23..7caef834f23 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.h @@ -44,8 +44,6 @@ class RenderObjClass; class RenderInfoClass; class CameraClass; -class ChunkLoadClass; -class ChunkSaveClass; /* ** SceneIterator @@ -169,13 +167,6 @@ class SceneClass : public RefCountClass virtual float Compute_Point_Visibility( RenderInfoClass & rinfo, const Vector3 & point) { return 1.0f; } - - /////////////////////////////////////////////////////////////////////////////////// - // Save-Load, records the fog, depth cue, etc settings into a chunk - /////////////////////////////////////////////////////////////////////////////////// - virtual void Save(ChunkSaveClass & csave); - virtual void Load(ChunkLoadClass & cload); - protected: virtual void Render(RenderInfoClass & rinfo); //Made virtual so we can override -MW diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h index f074318ef80..2740e501968 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h @@ -2189,8 +2189,8 @@ struct W3dNullObjectStruct // // Note: This structure is followed directly by a chunk (W3D_CHUNK_SOUNDROBJ_DEFINITION) -// that contains an embedded AudibleSoundDefinitionClass's storage. See audibledound.h -// for details. +// that contains the settings of the sound. See SoundRenderObjDefClass::Write_Definition +// in soundrobj.cpp for details. // struct W3dSoundRObjHeaderStruct { diff --git a/Tests/Google/CMakeLists.txt b/Tests/Google/CMakeLists.txt index fb48f05daac..d2cce7241b6 100644 --- a/Tests/Google/CMakeLists.txt +++ b/Tests/Google/CMakeLists.txt @@ -6,6 +6,7 @@ if(RTS_BUILD_ZEROHOUR) target_link_libraries(z_googletest PRIVATE corei_googletest z_gameenginedevice + z_wwaudio zi_always ) add_test(NAME z_googletest COMMAND z_googletest) @@ -16,6 +17,7 @@ if(RTS_BUILD_GENERALS) target_link_libraries(g_googletest PRIVATE corei_googletest g_gameenginedevice + g_wwaudio gi_always ) add_test(NAME g_googletest COMMAND g_googletest) diff --git a/Tests/Google/Core/CMakeLists.txt b/Tests/Google/Core/CMakeLists.txt index 03efb5a3ac9..8681be68f0f 100644 --- a/Tests/Google/Core/CMakeLists.txt +++ b/Tests/Google/Core/CMakeLists.txt @@ -5,6 +5,7 @@ set(COREI_GOOGLETEST_SRC GameEngine/Common/INITest.cpp GameEngineDevice/StdDevice/Common/StdLocalFileSystemTest.cpp Libraries/Compression/CompressionManagerTest.cpp + Libraries/WWVegas/WW3D2/soundrobj_test.cpp Libraries/WWVegas/WWMath/WWMathCalls.h Libraries/WWVegas/WWMath/WWMathDumps.h Libraries/WWVegas/WWMath/WWMathKeys.h diff --git a/Tests/Google/Core/Libraries/WWVegas/WW3D2/soundrobj_test.cpp b/Tests/Google/Core/Libraries/WWVegas/WW3D2/soundrobj_test.cpp new file mode 100644 index 00000000000..93ae4c308cc --- /dev/null +++ b/Tests/Google/Core/Libraries/WWVegas/WW3D2/soundrobj_test.cpp @@ -0,0 +1,199 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2026 TheSuperHackers +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#include +#include + +#include "WW3D2/soundrobj.h" +#include "WWLib/RAMFILE.h" +#include "WWLib/chunkio.h" + +// W3DView saves and loads sound render objects as W3D_CHUNK_SOUNDROBJ. These arrays hold the bytes that ChunkSaveClass +// writes: a chunk header is the uint32 ID and the uint32 size, whose top bit marks a chunk that contains chunks, and a +// micro chunk header is the uint8 ID and the uint8 size. +namespace +{ +// clang-format off + +// Every setting differs from its default. +const unsigned char FullChunk[] = +{ + 0x00, 0x0A, 0x00, 0x00, 0xED, 0x00, 0x00, 0x80, // W3D_CHUNK_SOUNDROBJ, 237 bytes, contains chunks + 0x01, 0x0A, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, // W3D_CHUNK_SOUNDROBJ_HEADER, 56 bytes + // W3dSoundRObjHeaderStruct: version 0x00010003, name "ProbeSound", flags 0 + 0x03, 0x00, 0x01, 0x00, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x0A, 0x00, 0x00, 0xA5, 0x00, 0x00, 0x80, // W3D_CHUNK_SOUNDROBJ_DEFINITION, 165 bytes, contains chunks + 0x00, 0x01, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, // variables, 117 bytes + 0x03, 0x04, 0x00, 0x00, 0x80, 0x3E, // priority 0.25 + 0x04, 0x04, 0x00, 0x00, 0x40, 0x3F, // volume 0.75 + 0x05, 0x04, 0x00, 0x00, 0x00, 0x3E, // pan 0.125 + 0x06, 0x04, 0x03, 0x00, 0x00, 0x00, // loop count 3 + 0x07, 0x04, 0x00, 0x00, 0x5E, 0x42, // drop-off radius 55.5 + 0x08, 0x04, 0x00, 0x00, 0x44, 0x41, // max-volume radius 12.25 + 0x09, 0x04, 0x00, 0x00, 0x00, 0x00, // type 0 (music) + 0x0A, 0x01, 0x00, // is 3D false + 0x0B, 0x0A, 0x70, 0x72, 0x6F, 0x62, 0x65, 0x2E, 0x77, 0x61, 0x76, 0x00, // filename "probe.wav" + 0x0C, 0x0B, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x00, // display text "Probe text" + 0x12, 0x04, 0x00, 0x00, 0xC0, 0x3E, // start offset 0.375 + 0x13, 0x04, 0x00, 0x00, 0xC0, 0x3F, // pitch factor 1.5 + 0x0D, 0x04, 0x06, 0x00, 0x00, 0x00, // logical type mask 6 + 0x0E, 0x04, 0x00, 0x00, 0x60, 0x40, // logical notify delay 3.5 + 0x0F, 0x01, 0x01, // create logical sound true + 0x10, 0x04, 0x00, 0x00, 0x8C, 0x42, // logical drop-off radius 70 + 0x11, 0x0C, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x80, 0x3E, 0x00, 0x00, 0x80, 0x3F, // sphere color (0.5, 0.25, 1) + 0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, // base class, 32 bytes, contains chunks + 0x00, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, // variables, 24 bytes + 0x01, 0x04, 0x78, 0x56, 0x34, 0x12, // ID 0x12345678 + 0x03, 0x10, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6E, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, // name "ProbeDefinition" +}; + +// FullChunk with a variable ID that the definition does not read. +const unsigned char ChunkWithUnknownVariable[] = +{ + 0x00, 0x0A, 0x00, 0x00, 0xF3, 0x00, 0x00, 0x80, // W3D_CHUNK_SOUNDROBJ, 243 bytes, contains chunks + 0x01, 0x0A, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, // W3D_CHUNK_SOUNDROBJ_HEADER, 56 bytes + 0x03, 0x00, 0x01, 0x00, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x0A, 0x00, 0x00, 0xAB, 0x00, 0x00, 0x80, // W3D_CHUNK_SOUNDROBJ_DEFINITION, 171 bytes, contains chunks + 0x00, 0x01, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x00, // variables, 123 bytes + 0x03, 0x04, 0x00, 0x00, 0x80, 0x3E, + 0x04, 0x04, 0x00, 0x00, 0x40, 0x3F, + 0x05, 0x04, 0x00, 0x00, 0x00, 0x3E, + 0x06, 0x04, 0x03, 0x00, 0x00, 0x00, + 0x07, 0x04, 0x00, 0x00, 0x5E, 0x42, + 0x01, 0x04, 0xEF, 0xBE, 0xAD, 0xDE, // unknown variable 0x01 + 0x08, 0x04, 0x00, 0x00, 0x44, 0x41, + 0x09, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x0A, 0x01, 0x00, + 0x0B, 0x0A, 0x70, 0x72, 0x6F, 0x62, 0x65, 0x2E, 0x77, 0x61, 0x76, 0x00, + 0x0C, 0x0B, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x00, + 0x12, 0x04, 0x00, 0x00, 0xC0, 0x3E, + 0x13, 0x04, 0x00, 0x00, 0xC0, 0x3F, + 0x0D, 0x04, 0x06, 0x00, 0x00, 0x00, + 0x0E, 0x04, 0x00, 0x00, 0x60, 0x40, + 0x0F, 0x01, 0x01, + 0x10, 0x04, 0x00, 0x00, 0x8C, 0x42, + 0x11, 0x0C, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x80, 0x3E, 0x00, 0x00, 0x80, 0x3F, + 0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, + 0x00, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x01, 0x04, 0x78, 0x56, 0x34, 0x12, + 0x03, 0x10, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6E, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, +}; + +// A default definition with the name "ProbeSound". +const unsigned char DefaultChunk[] = +{ + 0x00, 0x0A, 0x00, 0x00, 0xCB, 0x00, 0x00, 0x80, // W3D_CHUNK_SOUNDROBJ, 203 bytes, contains chunks + 0x01, 0x0A, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, // W3D_CHUNK_SOUNDROBJ_HEADER, 56 bytes + // W3dSoundRObjHeaderStruct: version 0x00010003, name "ProbeSound", flags 1 (stop when hidden) + 0x03, 0x00, 0x01, 0x00, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x0A, 0x00, 0x00, 0x83, 0x00, 0x00, 0x80, // W3D_CHUNK_SOUNDROBJ_DEFINITION, 131 bytes, contains chunks + 0x00, 0x01, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, // variables, 98 bytes + 0x03, 0x04, 0x00, 0x00, 0x00, 0x3F, // priority 0.5 + 0x04, 0x04, 0x00, 0x00, 0x80, 0x3F, // volume 1 + 0x05, 0x04, 0x00, 0x00, 0x00, 0x3F, // pan 0.5 + 0x06, 0x04, 0x01, 0x00, 0x00, 0x00, // loop count 1 + 0x07, 0x04, 0x00, 0x00, 0x20, 0x42, // drop-off radius 40 + 0x08, 0x04, 0x00, 0x00, 0xA0, 0x41, // max-volume radius 20 + 0x09, 0x04, 0x01, 0x00, 0x00, 0x00, // type 1 (sound effect) + 0x0A, 0x01, 0x01, // is 3D true + 0x0B, 0x01, 0x00, // filename "" + 0x0C, 0x01, 0x00, // display text "" + 0x12, 0x04, 0x00, 0x00, 0x00, 0x00, // start offset 0 + 0x13, 0x04, 0x00, 0x00, 0x80, 0x3F, // pitch factor 1 + 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, // logical type mask 0 + 0x0E, 0x04, 0x00, 0x00, 0x00, 0x40, // logical notify delay 2 + 0x0F, 0x01, 0x00, // create logical sound false + 0x10, 0x04, 0x00, 0x00, 0x80, 0xBF, // logical drop-off radius -1 + 0x11, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x3F, 0x00, 0x00, 0x40, 0x3F, // sphere color (0, 0.75, 0.75) + 0x00, 0x02, 0x00, 0x00, 0x11, 0x00, 0x00, 0x80, // base class, 17 bytes, contains chunks + 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, // variables, 9 bytes + 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, // ID 0 + 0x03, 0x01, 0x00, // name "" +}; +// clang-format on + +template +std::vector toBytes(const unsigned char (&data)[Size]) +{ + return std::vector(data, data + Size); +} + +std::vector saveDefinition(SoundRenderObjDefClass &definition) +{ + std::vector buffer(1024); + RAMFileClass file(buffer.data(), static_cast(buffer.size())); + file.Open(FileClass::WRITE); + ChunkSaveClass csave(&file); + EXPECT_EQ(definition.Save_W3D(csave), WW3D_ERROR_OK); + buffer.resize(file.Size()); + file.Close(); + return buffer; +} + +// Loads the chunk with the loader that W3DView registers at the asset manager and saves the loaded definition again. +std::vector loadAndSave(std::vector input) +{ + RAMFileClass file(input.data(), static_cast(input.size())); + file.Open(FileClass::READ); + ChunkLoadClass cload(&file); + + std::vector output; + if (cload.Open_Chunk()) + { + EXPECT_EQ(cload.Cur_Chunk_ID(), static_cast(W3D_CHUNK_SOUNDROBJ)); + PrototypeClass *prototype = _SoundRenderObjLoader.Load_W3D(cload); + cload.Close_Chunk(); + EXPECT_NE(prototype, nullptr); + if (prototype != nullptr) + { + output = saveDefinition(*static_cast(prototype)->Peek_Definition()); + prototype->DeleteSelf(); + } + } + file.Close(); + return output; +} + +} // namespace + +TEST(SoundRenderObjDefClass, SavesLoadedChunkUnchanged) +{ + EXPECT_EQ(loadAndSave(toBytes(FullChunk)), toBytes(FullChunk)); +} + +TEST(SoundRenderObjDefClass, SkipsUnknownVariables) +{ + EXPECT_EQ(loadAndSave(toBytes(ChunkWithUnknownVariable)), toBytes(FullChunk)); +} + +TEST(SoundRenderObjDefClass, SavesDefaultSettings) +{ + SoundRenderObjDefClass *definition = NEW_REF(SoundRenderObjDefClass, ()); + definition->Set_Name("ProbeSound"); + EXPECT_EQ(saveDefinition(*definition), toBytes(DefaultChunk)); + REF_PTR_RELEASE(definition); +}