| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856 |
- /*
- ** Command & Conquer Renegade(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/Tools/LevelEdit/EditorSaveLoad.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 3/05/02 3:30p $*
- * *
- * $Revision:: 37 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "stdafx.h"
- #include "leveleditdoc.h"
- #include "editorsaveload.h"
- #include "persist.h"
- #include "persistfactory.h"
- #include "preset.h"
- #include "utils.h"
- #include "definition.h"
- #include "editorchunkids.h"
- #include "physstaticsavesystem.h"
- #include "chunkio.h"
- #include "cameramgr.h"
- #include "filemgr.h"
- #include "matrix3d.h"
- #include "rawfile.h"
- #include "nodemgr.h"
- #include "sceneeditor.h"
- #include "node.h"
- #include "lightambientform.h"
- #include "soundscene.h"
- #include "backgroundmgr.h"
- #include "conversationmgr.h"
- #include "weathermgr.h"
- #include "combat.h"
- #include "mapmgr.h"
- #include "pathfind.h"
- #include "lightsolvesavesystem.h"
- #include "heightfieldmgr.h"
- ///////////////////////////////////////////////////////////////////////
- // Global singleton instance
- ///////////////////////////////////////////////////////////////////////
- EditorSaveLoadClass _TheEditorSaveLoadSubsystem;
- PathfindImportExportSaveLoadClass _ThePathfindImporterExporter;
- ///////////////////////////////////////////////////////////////////////
- // Static member initialization
- ///////////////////////////////////////////////////////////////////////
- bool EditorSaveLoadClass::m_LoadedValidVis = true;
- ///////////////////////////////////////////////////////////////////////
- // Constants
- ///////////////////////////////////////////////////////////////////////
- enum
- {
- CHUNKID_MICRO_CHUNKS = 0x10140738,
- CHUNKID_OBSOLETE,
- CHUNKID_PATHFIND_DATA
- };
- enum
- {
- VARID_INCLUDE_FILE = 0x01,
- VARID_CAMERA_TM,
- VARID_OBSOLETE_0,
- VARID_BACK_MUSIC,
- VARID_AMBIENT_LIGHT,
- VARID_OBSOLETE_1,
- VARID_OBSOLETE_2,
- VARID_FAR_CLIP_PLANE_DOUBLE,
- VARID_FOG_COLOR,
- VARID_FOG_PLANES,
- VARID_FOG_ENABLED,
- VARID_FAR_CLIP_PLANE,
- VARID_RESTART_SCRIPT_NAME,
- VARID_RESPAWN_SCRIPT_NAME,
- };
- enum
- {
- CHUNKID_LVL_DATA = 304021447,
- CHUNKID_LIGHT_SOLVE,
- };
- ///////////////////////////////////////////////////////////////////////
- //
- // Chunk_ID
- //
- ///////////////////////////////////////////////////////////////////////
- uint32
- EditorSaveLoadClass::Chunk_ID (void) const
- {
- return CHUNKID_EDITOR_SAVELOAD;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Contains_Data
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- EditorSaveLoadClass::Contains_Data (void) const
- {
- return true;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Save
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- EditorSaveLoadClass::Save (ChunkSaveClass &csave)
- {
- bool retval = true;
- int index;
- csave.Begin_Chunk (CHUNKID_MICRO_CHUNKS);
- //
- // Write the camera transform to the chunk
- //
- Matrix3D camera_tm = ::Get_Camera_Mgr ()->Get_Camera ()->Get_Transform ();
- WRITE_MICRO_CHUNK (csave, VARID_CAMERA_TM, camera_tm);
- //
- // Write the miscellaneous level settings to the chunk
- //
- Vector3 ambient_light = ::Get_Scene_Editor ()->Get_Ambient_Light ();
- WRITE_MICRO_CHUNK (csave, VARID_AMBIENT_LIGHT, ambient_light);
- //
- // Save the fog settings
- //
- bool fog_enabled = false;
- struct
- {
- float z_near;
- float z_far;
- } fog_planes = { 50.0F, 100.0F };
- Vector3 fog_color (0, 0, 0);
- ::Get_Scene_Editor ()->Get_Fog_Range (&fog_planes.z_near, &fog_planes.z_far);
- fog_color = ::Get_Scene_Editor ()->Get_Fog_Color ();
- fog_enabled = ::Get_Scene_Editor ()->Get_Fog_Enable ();
- WRITE_MICRO_CHUNK (csave, VARID_FOG_ENABLED, fog_enabled);
- WRITE_MICRO_CHUNK (csave, VARID_FOG_COLOR, fog_color);
- WRITE_MICRO_CHUNK (csave, VARID_FOG_PLANES, fog_planes);
- //
- // Save the restart and respawn script names
- //
- StringClass restart_script_name = CombatManager::Get_Start_Script ();
- StringClass respawn_script_name = CombatManager::Get_Respawn_Script ();
- WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_RESTART_SCRIPT_NAME, restart_script_name);
- WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_RESPAWN_SCRIPT_NAME, respawn_script_name);
- //
- // Save the far clip plane...
- //
- float znear = 0;
- float zfar = 0;
- ::Get_Camera_Mgr ()->Get_Camera ()->Get_Clip_Planes (znear, zfar);
- WRITE_MICRO_CHUNK (csave, VARID_FAR_CLIP_PLANE, zfar);
- //
- // Write the background music filename out to the chunk
- //
- CString filename = ::Get_Scene_Editor ()->Get_Background_Music_Filename ();
- CString path = ::Get_File_Mgr ()->Make_Relative_Path (filename);
- WRITE_MICRO_CHUNK_STRING (csave, VARID_BACK_MUSIC, (LPCTSTR)path);
- //
- // Write the list of include files for the level to the chunk.
- //
- STRING_LIST &include_list = ::Get_File_Mgr ()->Get_Include_File_List ();
- for (index = 0; index < include_list.Count (); index ++) {
- StringClass filename = (LPCTSTR)include_list[index];
- WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_INCLUDE_FILE, filename);
- }
- csave.End_Chunk ();
- return retval;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Load
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- EditorSaveLoadClass::Load (ChunkLoadClass &cload)
- {
- bool retval = true;
- while (cload.Open_Chunk ()) {
- switch (cload.Cur_Chunk_ID ()) {
-
- //
- // Load all the presets from this chunk
- //
- case CHUNKID_MICRO_CHUNKS:
- retval &= Load_Micro_Chunks (cload);
- break;
- }
- cload.Close_Chunk ();
- }
- SaveLoadSystemClass::Register_Post_Load_Callback (this);
- return retval;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Load_Micro_Chunks
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- EditorSaveLoadClass::Load_Micro_Chunks (ChunkLoadClass &cload)
- {
- bool retval = true;
- Vector3 fog_color (0, 0, 0);
- bool fog_enabled = false;
- StringClass restart_script_name;
- StringClass respawn_script_name;
- while (cload.Open_Micro_Chunk ()) {
- switch (cload.Cur_Micro_Chunk_ID ()) {
-
- //
- // Read the camera's transformation matrix from the chunk
- // and pass it onto the camera.
- //
- case VARID_CAMERA_TM:
- {
- Matrix3D camera_tm;
- cload.Read(&camera_tm,sizeof (camera_tm));
- ::Get_Camera_Mgr ()->Get_Camera ()->Set_Transform (camera_tm);
- }
- break;
- //
- // Read the include file from the chunk and add it to the list
- // of level include files.
- //
- case VARID_INCLUDE_FILE:
- {
- StringClass filename;
- cload.Read(filename.Get_Buffer(cload.Cur_Micro_Chunk_Length()),cload.Cur_Micro_Chunk_Length());
- ::Get_File_Mgr ()->Get_Include_File_List ().Add ((LPCTSTR)filename);
- }
- break;
- case VARID_FAR_CLIP_PLANE_DOUBLE:
- {
- float znear = 0;
- float zfar = 0;
- ::Get_Camera_Mgr ()->Get_Camera ()->Get_Clip_Planes (znear, zfar);
- double double_zfar = 0;
- cload.Read (&double_zfar, sizeof (double_zfar));
- zfar = double_zfar;
- ::Get_Camera_Mgr ()->Get_Camera ()->Set_Clip_Planes (znear, zfar);
- }
- break;
- case VARID_FAR_CLIP_PLANE:
- {
- float znear = 0;
- float zfar = 0;
- ::Get_Camera_Mgr ()->Get_Camera ()->Get_Clip_Planes (znear, zfar);
- cload.Read (&zfar, sizeof (zfar));
- ::Get_Camera_Mgr ()->Get_Camera ()->Set_Clip_Planes (znear, zfar);
- }
- break;
- case VARID_AMBIENT_LIGHT:
- {
- Vector3 ambient_light;
- cload.Read (&ambient_light, sizeof (ambient_light));
- ::Get_Scene_Editor ()->Set_Ambient_Light (ambient_light);
- ::Get_Scene_Editor ()->Update_Lighting ();
-
- LightAmbientFormClass *light_form = Get_Ambient_Light_Form ();
- light_form->Update_Settings ();
- }
- break;
- READ_MICRO_CHUNK (cload, VARID_FOG_ENABLED, fog_enabled);
- READ_MICRO_CHUNK (cload, VARID_FOG_COLOR, fog_color);
- READ_MICRO_CHUNK_WWSTRING (cload, VARID_RESTART_SCRIPT_NAME, restart_script_name);
- READ_MICRO_CHUNK_WWSTRING (cload, VARID_RESPAWN_SCRIPT_NAME, respawn_script_name);
-
- case VARID_FOG_PLANES:
- {
- struct
- {
- float z_near;
- float z_far;
- } fog_planes = { 50.0F, 100.0F };
- cload.Read (&fog_planes, sizeof (fog_planes));
- ::Get_Scene_Editor ()->Set_Fog_Range (fog_planes.z_near, fog_planes.z_far);
- }
- break;
- case VARID_BACK_MUSIC:
- {
- StringClass filename;
- cload.Read(filename.Get_Buffer(cload.Cur_Micro_Chunk_Length()),cload.Cur_Micro_Chunk_Length());
- ::Get_Scene_Editor ()->Set_Background_Music (filename);
- }
- break;
- }
- cload.Close_Micro_Chunk ();
- }
- //
- // Apply the script settings
- //
- CombatManager::Set_Start_Script (restart_script_name);
- CombatManager::Set_Respawn_Script (respawn_script_name);
- //
- // Apply the fog settings
- //
- ::Get_Scene_Editor ()->Set_Fog_Color (fog_color);
- ::Get_Scene_Editor ()->Set_Fog_Enable (fog_enabled);
- return retval;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Save_Level
- //
- ///////////////////////////////////////////////////////////////////////
- void
- EditorSaveLoadClass::Save_Level (LPCTSTR filename)
- {
- //
- // Create the file
- //
- HANDLE hfile = ::CreateFile (filename,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- 0L,
- NULL);
- ASSERT (hfile != INVALID_HANDLE_VALUE);
- if (hfile != INVALID_HANDLE_VALUE) {
- RawFileClass file_obj;
- file_obj.Attach (hfile);
- ChunkSaveClass chunk_save (&file_obj);
- //
- // (gth) March 4, 2002 - modifying this function to embed two "save files" into this
- // file. The first chunk will contain an entire save for the normal level data. The second
- // chunk will contain the lighting save
- //
- chunk_save.Begin_Chunk(CHUNKID_LVL_DATA);
- Save_Level_Data(chunk_save);
- chunk_save.End_Chunk();
- chunk_save.Begin_Chunk(CHUNKID_LIGHT_SOLVE);
- Save_Light_Solve(chunk_save);
- chunk_save.End_Chunk();
- //
- // Remember that we are now up-to-date
- //
- Set_Modified (false);
- }
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Save_Level_Data - saves the level data for an LVL file
- //
- ///////////////////////////////////////////////////////////////////////
- void
- EditorSaveLoadClass::Save_Level_Data(ChunkSaveClass & chunk_save)
- {
- //
- // Repartition the static culling systems
- // (gth) can't re-partition the object culling systems or
- // we'll lose hierarchical vis
- //
- ::Get_Scene_Editor ()->Re_Partition_Static_Lights ();
- ::Get_Scene_Editor ()->Re_Partition_Audio_System ();
- //
- // Basically just save the list of nodes and some other
- // miscellaneous information (camera, sky, etc).
- //
- SaveLoadSystemClass::Save (chunk_save, _PhysStaticDataSaveSystem);
- SaveLoadSystemClass::Save (chunk_save, _TheNodeMgr);
- SaveLoadSystemClass::Save (chunk_save, _TheEditorSaveLoadSubsystem);
- SaveLoadSystemClass::Save (chunk_save, _TheBackgroundMgr);
- SaveLoadSystemClass::Save (chunk_save, _TheWeatherMgr);
- SaveLoadSystemClass::Save (chunk_save, _TheMapMgrSaveLoadSubsystem);
- SaveLoadSystemClass::Save (chunk_save, _TheHeightfieldMgrSaveLoadSubsystem);
-
- //
- // Save the level-specific conversations
- //
- _ConversationMgrSaveLoad.Set_Category_To_Save (ConversationMgrClass::CATEGORY_LEVEL);
- SaveLoadSystemClass::Save (chunk_save, _ConversationMgrSaveLoad);
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Save_Light_Solve - saves the light-solve data for an LVL file
- //
- ///////////////////////////////////////////////////////////////////////
- void EditorSaveLoadClass::Save_Light_Solve(ChunkSaveClass & chunk_save)
- {
- SaveLoadSystemClass::Save( chunk_save, _TheLightSolveSaveSystem);
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Load_Level
- //
- ///////////////////////////////////////////////////////////////////////
- void
- EditorSaveLoadClass::Load_Level (LPCTSTR filename)
- {
- //
- // Create the file
- //
- HANDLE hfile = ::CreateFile (filename,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- 0L,
- NULL);
- ASSERT (hfile != INVALID_HANDLE_VALUE);
- if (hfile != INVALID_HANDLE_VALUE) {
- RawFileClass file_obj;
- file_obj.Attach (hfile);
- ChunkLoadClass chunk_load (&file_obj);
- SoundSceneClass *sound_scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene ();
- if (sound_scene != NULL) {
- sound_scene->Set_Batch_Mode (true);
- }
- //
- // Get the save-load subsystem to load
- //
- m_LoadedValidVis = true;
- NodeMgrClass::Free_Nodes ();
- //
- // (gth) March 4, 2002 - LVL files are now two independent save-load operations,
- // one for the normal level data and one for the light solve data. Here, we
- // detect whether we are loading a file that was created before this change.
- //
- uint32 id,size;
- if (chunk_load.Peek_Next_Chunk(&id,&size) && (id == CHUNKID_LVL_DATA)) {
-
- // Current file format, multiple saves embedded into this file
- while (chunk_load.Open_Chunk()) {
- switch (chunk_load.Cur_Chunk_ID()) {
- case CHUNKID_LVL_DATA:
- case CHUNKID_LIGHT_SOLVE:
- SaveLoadSystemClass::Load (chunk_load);
- break;
- default:
- break;
- }
-
- chunk_load.Close_Chunk();
- }
- } else {
- // Legacy file format support
- SaveLoadSystemClass::Load (chunk_load);
- }
- //
- // Repartition the static culling systems
- // (gth) can't re-partition the object culling systems or
- // we'll lose hierarchical vis
- //
- ::Get_Scene_Editor ()->Re_Partition_Static_Lights ();
- ::Get_Scene_Editor ()->Re_Partition_Audio_System ();
- //
- // Now create any embedded nodes (nodes that are embedded inside
- // the preset of any nodes that are currently in the level).
- //
- NodeMgrClass::Create_All_Embedded_Nodes ();
-
- //
- // Validate VIS information if necessary
- //
- if (m_LoadedValidVis) {
- ::Get_Scene_Editor ()->Validate_Vis ();
- ::Get_Scene_Editor ()->Update_Culling_System_Bounding_Boxes ();
- } else {
- ::MessageBox (NULL, "Static geometry has changed since the last time this level was loaded. All previously generated VIS data has been discarded.", "Vis Discarded", MB_ICONEXCLAMATION | MB_OK);
- ::Get_Scene_Editor ()->Discard_Vis ();
- }
- if (sound_scene != NULL) {
- sound_scene->Set_Batch_Mode (false);
- }
- //
- // Remember that we are now up-to-date
- //
- Set_Modified (false);
- }
-
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Export_Dynamic_Objects
- //
- ///////////////////////////////////////////////////////////////////////
- void
- EditorSaveLoadClass::Export_Dynamic_Objects (LPCTSTR filename)
- {
- //
- // Create the file
- //
- HANDLE hfile = ::CreateFile (filename,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- 0L,
- NULL);
- ASSERT (hfile != INVALID_HANDLE_VALUE);
- if (hfile != INVALID_HANDLE_VALUE) {
- RawFileClass file_obj;
- file_obj.Attach (hfile);
- ChunkSaveClass chunk_save (&file_obj);
- //
- // Remove the static objects from the level, save the nodes,
- // then put the static objects back
- //
- NODE_LIST static_obj_list;
- NodeMgrClass::Remove_Static_Objects (static_obj_list);
- SaveLoadSystemClass::Save (chunk_save, _TheNodeMgr);
- NodeMgrClass::Put_Objects_Back (static_obj_list);
- }
-
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Import_Dynamic_Objects
- //
- ///////////////////////////////////////////////////////////////////////
- void
- EditorSaveLoadClass::Import_Dynamic_Objects (LPCTSTR filename)
- {
- //
- // Create the file
- //
- HANDLE hfile = ::CreateFile (filename,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- 0L,
- NULL);
- ASSERT (hfile != INVALID_HANDLE_VALUE);
- if (hfile != INVALID_HANDLE_VALUE) {
- RawFileClass file_obj;
- file_obj.Attach (hfile);
- ChunkLoadClass chunk_load (&file_obj);
- //
- // Find the largest used ID
- //
- uint32 start_id = (NodeMgrClass::Get_Max_Used_ID () + 1);
- //
- // Remove the dynamic objects from the level and load the new objects.
- //
- NODE_LIST dynamic_obj_list;
- NodeMgrClass::Remove_Dynamic_Objects (dynamic_obj_list);
- SaveLoadSystemClass::Load (chunk_load);
- ::Output_Message ("Resetting existing static node IDs.\r\n");
-
- //
- // Re-assign IDs to the existing static nodes
- //
- for ( NodeClass *node = NodeMgrClass::Get_First ();
- node != NULL;
- node = NodeMgrClass::Get_Next (node))
- {
- if (node->Is_Static ()) {
- node->Set_ID (start_id++);
- }
- }
- //
- // Check all the dynamic objects for ID collision
- //
- CString id_collision_msg = "The following dynamic object IDs collided on import:\n\n";
- bool show_msg = false;
- DynamicVectorClass<NodeClass *> bad_node_list;
- for (int index = 0; index < dynamic_obj_list.Count (); index ++) {
- NodeClass *node = dynamic_obj_list[index];
- if (NodeMgrClass::Find_Node (node->Get_ID ()) != NULL) {
- CString entry;
- entry.Format ("Object %d\n", node->Get_ID ());
- id_collision_msg += entry;
- bad_node_list.Add (node);
- show_msg = true;
- }
- }
- //
- // Put the original objects back
- //
- NodeMgrClass::Put_Objects_Back (dynamic_obj_list);
- NodeMgrClass::Reset_New_ID ();
- //
- // Let the user know we had ID collision (if necessary)
- //
- if (show_msg) {
- ::MessageBox (NULL, id_collision_msg, "ID Collision", MB_ICONERROR | MB_OK);
-
- //
- // Ask the user if we should fix the collisions or not
- //
- if (::MessageBox (NULL, "Would you like to repair the newly imported objects with ambiguous IDs?", "ID Collision", MB_ICONQUESTION | MB_YESNO) == IDYES) {
-
- //
- // Repair all collisions
- //
- for (int index = 0; index < bad_node_list.Count (); index ++) {
- NodeClass *node = bad_node_list[index];
- if (node != NULL) {
- node->Set_ID (NodeMgrClass::Get_Node_ID (node->Get_Type ()));
- }
- }
- }
- }
- }
-
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // On_Post_Load
- //
- ///////////////////////////////////////////////////////////////////////
- void
- EditorSaveLoadClass::On_Post_Load (void)
- {
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Export_Pathfind
- //
- ///////////////////////////////////////////////////////////////////////
- void
- PathfindImportExportSaveLoadClass::Export_Pathfind (LPCTSTR filename)
- {
- //
- // Create the file
- //
- HANDLE hfile = ::CreateFile (filename,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- 0L,
- NULL);
- ASSERT (hfile != INVALID_HANDLE_VALUE);
- if (hfile != INVALID_HANDLE_VALUE) {
- RawFileClass file_obj;
- file_obj.Attach (hfile);
- ChunkSaveClass chunk_save (&file_obj);
- //
- //
- // Basically just save the list of nodes and some other
- // miscellaneous information (camera, sky, etc).
- //
- SaveLoadSystemClass::Save (chunk_save, _ThePathfindImporterExporter);
- }
-
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Import_Pathfind
- //
- ///////////////////////////////////////////////////////////////////////
- void
- PathfindImportExportSaveLoadClass::Import_Pathfind (LPCTSTR filename)
- {
- //
- // Create the file
- //
- HANDLE hfile = ::CreateFile (filename,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- 0L,
- NULL);
- ASSERT (hfile != INVALID_HANDLE_VALUE);
- if (hfile != INVALID_HANDLE_VALUE) {
- RawFileClass file_obj;
- file_obj.Attach (hfile);
- ChunkLoadClass chunk_load (&file_obj);
- //
- // Get the save-load subsystem to load
- //
- SaveLoadSystemClass::Load (chunk_load);
- }
-
- return ;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Save
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- PathfindImportExportSaveLoadClass::Save (ChunkSaveClass &csave)
- {
- //
- // Save the pathfind data
- //
- csave.Begin_Chunk (CHUNKID_PATHFIND_DATA);
- PathfindClass::Get_Instance()->Save (csave);
- csave.End_Chunk ();
- return true;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Load
- //
- ///////////////////////////////////////////////////////////////////////
- bool
- PathfindImportExportSaveLoadClass::Load (ChunkLoadClass &cload)
- {
- while (cload.Open_Chunk ()) {
- switch (cload.Cur_Chunk_ID ()) {
-
- //
- // Import the pathfind data...
- //
- case CHUNKID_PATHFIND_DATA:
- PathfindClass::Get_Instance()->Load (cload);
- break;
- }
- cload.Close_Chunk ();
- }
- return true;
- }
|