| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- /*
- ** Command & Conquer Generals(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 <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** 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 "always.h"
- #include "audiosaveload.h"
- #include "persist.h"
- #include "persistfactory.h"
- #include "definition.h"
- #include "soundchunkids.h"
- #include "chunkio.h"
- #include "SoundScene.h"
- #include "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 (void) const
- {
- return CHUNKID_STATIC_SAVELOAD;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Contains_Data
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- StaticAudioSaveLoadClass::Contains_Data (void) 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 != NULL) {
- 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 != NULL) {
- scene->Load_Static (cload);
- }
- }
- break;
- }
- cload.Close_Chunk ();
- }
- return retval;
- }
- //*******************************************************************//
- //*
- //* Start of DynamicAudioSaveLoadClass
- //*
- //*******************************************************************//
- ///////////////////////////////////////////////////////////////////////
- //
- // Chunk_ID
- //
- ///////////////////////////////////////////////////////////////////////
- uint32
- DynamicAudioSaveLoadClass::Chunk_ID (void) const
- {
- return CHUNKID_DYNAMIC_SAVELOAD;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Contains_Data
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- DynamicAudioSaveLoadClass::Contains_Data (void) 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 != NULL) {
-
- 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 != NULL) {
- scene->Load_Dynamic (cload);
- }
- }
- break;
- }
- cload.Close_Chunk ();
- }
- return retval;
- }
|