From 66b0fdfbd7792c4ff52293efe859121f07e16a3d Mon Sep 17 00:00:00 2001 From: mnelenpridumivat Date: Tue, 10 Dec 2024 01:41:17 +0300 Subject: [PATCH] Add all registry classes to new save system --- src/xrGame/GameTask.cpp | 198 +++++++++++++++++++ src/xrGame/GameTask.h | 4 + src/xrGame/GameTaskDefs.h | 2 + src/xrGame/actor_statistic_defs.h | 4 + src/xrGame/actor_statistic_mgr.cpp | 69 ++++++- src/xrGame/alife_abstract_registry.cpp | 209 ++++++++++++++++++++ src/xrGame/alife_abstract_registry_inline.h | 156 +-------------- src/xrGame/alife_registry_container.cpp | 4 +- src/xrGame/alife_registry_container.h | 4 +- src/xrGame/map_location_defs.h | 2 +- src/xrGame/map_manager.cpp | 4 +- 11 files changed, 494 insertions(+), 162 deletions(-) create mode 100644 src/xrGame/alife_abstract_registry.cpp diff --git a/src/xrGame/GameTask.cpp b/src/xrGame/GameTask.cpp index 1e6cc23f40..290ac0d28f 100644 --- a/src/xrGame/GameTask.cpp +++ b/src/xrGame/GameTask.cpp @@ -256,6 +256,62 @@ void CGameTask::load_task(IReader &stream) CreateMapLocation (true); } +void CGameTask::save_task(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CGameTask"); + { + Object->GetCurrentChunk()->w_u8(m_task_state); + Object->GetCurrentChunk()->w_u8(m_task_type); + Object->GetCurrentChunk()->w_u64(m_ReceiveTime); + Object->GetCurrentChunk()->w_u64(m_FinishTime); + Object->GetCurrentChunk()->w_u64(m_TimeToComplete); + Object->GetCurrentChunk()->w_u64(m_timer_finish); + Object->GetCurrentChunk()->w_stringZ(m_Title); + Object->GetCurrentChunk()->w_stringZ(m_Description); + Object->GetCurrentChunk()->w_stringZ(m_Description); + m_pScriptHelper.save(Object); + Object->GetCurrentChunk()->w_stringZ(m_icon_texture_name); + Object->GetCurrentChunk()->w_stringZ(m_map_hint); + Object->GetCurrentChunk()->w_stringZ(m_map_location); + Object->GetCurrentChunk()->w_u16(m_map_object_id); + Object->GetCurrentChunk()->w_u32(m_priority); + } + Object->EndChunk(); +} + +void CGameTask::load_task(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CGameTask"); + { + { + u8 Value; + Object->GetCurrentChunk()->r_u8(Value); + m_task_state = (ETaskState)Value; + } + { + u8 Value; + Object->GetCurrentChunk()->r_u8(Value); + m_task_type = (ETaskType)Value; + } + Object->GetCurrentChunk()->r_u64(m_ReceiveTime); + Object->GetCurrentChunk()->r_u64(m_FinishTime); + Object->GetCurrentChunk()->r_u64(m_TimeToComplete); + Object->GetCurrentChunk()->r_u64(m_timer_finish); + Object->GetCurrentChunk()->r_stringZ(m_Title); + Object->GetCurrentChunk()->r_stringZ(m_Description); + Object->GetCurrentChunk()->r_stringZ(m_Description); + m_pScriptHelper.load(Object); + Object->GetCurrentChunk()->r_stringZ(m_icon_texture_name); + Object->GetCurrentChunk()->r_stringZ(m_map_hint); + Object->GetCurrentChunk()->r_stringZ(m_map_location); + Object->GetCurrentChunk()->r_u16(m_map_object_id); + Object->GetCurrentChunk()->r_u32(m_priority); + CommitScriptHelperContents(); + CreateMapLocation(true); + } + Object->EndChunk(); +} + void CGameTask::CommitScriptHelperContents() { m_pScriptHelper.init_functors (m_pScriptHelper.m_s_complete_lua_functions, m_complete_lua_functions); @@ -323,6 +379,126 @@ void SScriptTaskHelper::load(IReader &stream) load_data(m_s_lua_functions_on_fail, stream); } +void SScriptTaskHelper::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("SScriptTaskHelper"); + { + Object->BeginChunk("SScriptTaskHelper::complete_cond"); + { + Object->GetCurrentChunk()->WriteArray(m_s_complete_lua_functions.size()); + { + for (const auto& elem : m_s_complete_lua_functions) { + Object->GetCurrentChunk()->w_stringZ(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("SScriptTaskHelper::fail_cond"); + { + Object->GetCurrentChunk()->WriteArray(m_s_fail_lua_functions.size()); + { + for (const auto& elem : m_s_fail_lua_functions) { + Object->GetCurrentChunk()->w_stringZ(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("SScriptTaskHelper::on_complete"); + { + Object->GetCurrentChunk()->WriteArray(m_s_lua_functions_on_complete.size()); + { + for (const auto& elem : m_s_lua_functions_on_complete) { + Object->GetCurrentChunk()->w_stringZ(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("SScriptTaskHelper::on_fail"); + { + Object->GetCurrentChunk()->WriteArray(m_s_lua_functions_on_fail.size()); + { + for (const auto& elem : m_s_lua_functions_on_fail) { + Object->GetCurrentChunk()->w_stringZ(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + } + Object->EndChunk(); +} + +void SScriptTaskHelper::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("SScriptTaskHelper"); + { + Object->BeginChunk("SScriptTaskHelper::complete_cond"); + { + m_s_complete_lua_functions.clear(); + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + shared_str Value; + Object->GetCurrentChunk()->r_stringZ(Value); + m_s_complete_lua_functions.emplace_back(Value); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("SScriptTaskHelper::fail_cond"); + { + m_s_fail_lua_functions.clear(); + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + shared_str Value; + Object->GetCurrentChunk()->r_stringZ(Value); + m_s_fail_lua_functions.emplace_back(Value); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("SScriptTaskHelper::on_complete"); + { + m_s_lua_functions_on_complete.clear(); + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + shared_str Value; + Object->GetCurrentChunk()->r_stringZ(Value); + m_s_lua_functions_on_complete.emplace_back(Value); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("SScriptTaskHelper::on_fail"); + { + m_s_lua_functions_on_fail.clear(); + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + shared_str Value; + Object->GetCurrentChunk()->r_stringZ(Value); + m_s_lua_functions_on_fail.emplace_back(Value); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + } + Object->EndChunk(); +} + void SScriptTaskHelper::save(IWriter &stream) { save_data(m_s_complete_lua_functions, stream); @@ -346,6 +522,28 @@ void SGameTaskKey::load(IReader &stream) } +void SGameTaskKey::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("SGameTaskKey"); + { + Object->GetCurrentChunk()->w_stringZ(task_id); + game_task->save_task(Object); + } + Object->EndChunk(); +} + +void SGameTaskKey::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("SGameTaskKey"); + { + game_task = new CGameTask(); + Object->GetCurrentChunk()->r_stringZ(task_id); + game_task->m_ID = task_id; + game_task->load_task(Object); + } + Object->EndChunk(); +} + void SGameTaskKey::destroy() { delete_data(game_task); diff --git a/src/xrGame/GameTask.h b/src/xrGame/GameTask.h index ad36689018..cfc1e0bbc7 100644 --- a/src/xrGame/GameTask.h +++ b/src/xrGame/GameTask.h @@ -27,6 +27,8 @@ class SScriptTaskHelper: public IPureSerializeObject virtual void save (IWriter &stream); virtual void load (IReader &stream); + virtual void save(CSaveObjectSave* Object) const; + virtual void load(CSaveObjectLoad* Object); void init_functors (xr_vector& v_src, task_state_functors& v_dest); }; @@ -74,6 +76,8 @@ class CGameTask void save_task (IWriter &stream); void load_task (IReader &stream); + void save_task(CSaveObjectSave* Object) const; + void load_task(CSaveObjectLoad* Object); shared_str m_ID; diff --git a/src/xrGame/GameTaskDefs.h b/src/xrGame/GameTaskDefs.h index 57980b8ca8..cd8cfd013f 100644 --- a/src/xrGame/GameTaskDefs.h +++ b/src/xrGame/GameTaskDefs.h @@ -31,6 +31,8 @@ struct SGameTaskKey : public IPureSerializeObject,public IPureD virtual void save (IWriter &stream); virtual void load (IReader &stream); + virtual void save(CSaveObjectSave* Object) const; + virtual void load(CSaveObjectLoad* Object); virtual void destroy (); }; diff --git a/src/xrGame/actor_statistic_defs.h b/src/xrGame/actor_statistic_defs.h index 5a37186240..603442c0bc 100644 --- a/src/xrGame/actor_statistic_defs.h +++ b/src/xrGame/actor_statistic_defs.h @@ -13,6 +13,8 @@ struct SStatDetailBData: public IPureSerializeObject virtual void save (IWriter &stream); virtual void load (IReader &stream); + virtual void save(CSaveObjectSave* Object) const; + virtual void load(CSaveObjectLoad* Object); }; @@ -27,6 +29,8 @@ struct SStatSectionData: public IPureSerializeObject s32 GetTotalPoints () const; virtual void save (IWriter &stream); virtual void load (IReader &stream); + virtual void save(CSaveObjectSave* Object) const; + virtual void load(CSaveObjectLoad* Object); }; typedef xr_vector vStatSectionData; diff --git a/src/xrGame/actor_statistic_mgr.cpp b/src/xrGame/actor_statistic_mgr.cpp index c74ec76a4c..f1a0578576 100644 --- a/src/xrGame/actor_statistic_mgr.cpp +++ b/src/xrGame/actor_statistic_mgr.cpp @@ -32,6 +32,30 @@ void SStatDetailBData::load(IReader &stream) load_data (str_value, stream); } +void SStatDetailBData::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("SStatDetailBData"); + { + Object->GetCurrentChunk()->w_stringZ(key); + Object->GetCurrentChunk()->w_s32(int_count); + Object->GetCurrentChunk()->w_s32(int_points); + Object->GetCurrentChunk()->w_stringZ(str_value); + } + Object->EndChunk(); +} + +void SStatDetailBData::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("SStatDetailBData"); + { + Object->GetCurrentChunk()->r_stringZ(key); + Object->GetCurrentChunk()->r_s32(int_count); + Object->GetCurrentChunk()->r_s32(int_points); + Object->GetCurrentChunk()->r_stringZ(str_value); + } + Object->EndChunk(); +} + //////////////////////////////////////////////// void SStatSectionData::save(IWriter &stream) @@ -45,8 +69,8 @@ void SStatSectionData::load(IReader &stream) load_data (data, stream); if(ai().get_alife()->header().version()==0x0002) { - int tmp; - load_data (tmp, stream); + int tmp; + load_data (tmp, stream); switch(tmp) { case 100: @@ -73,9 +97,44 @@ void SStatSectionData::load(IReader &stream) } s32 tmp2; load_data (tmp2, stream);// old total_points - }else - load_data (key, stream); -}; + } + else { + load_data(key, stream); + } +} + +void SStatSectionData::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("SStatSectionData"); + { + Object->GetCurrentChunk()->WriteArray(data.size()); + for (const auto& elem : data) { + elem.save(Object); + } + Object->GetCurrentChunk()->EndArray(); + Object->GetCurrentChunk()->w_stringZ(key); + } + Object->EndChunk(); +} + +void SStatSectionData::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("SStatSectionData"); + { + data.clear(); + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + for (u64 i = 0; i < ArraySize; ++i) { + SStatDetailBData&& Value = SStatDetailBData(); + Value.load(Object); + data.emplace_back(Value); + } + Object->GetCurrentChunk()->EndArray(); + Object->GetCurrentChunk()->r_stringZ(key); + } + Object->EndChunk(); +} + SStatDetailBData& SStatSectionData::GetData (const shared_str& key_) { diff --git a/src/xrGame/alife_abstract_registry.cpp b/src/xrGame/alife_abstract_registry.cpp new file mode 100644 index 0000000000..2a6263ff7d --- /dev/null +++ b/src/xrGame/alife_abstract_registry.cpp @@ -0,0 +1,209 @@ +#include "StdAfx.h" +#include "alife_abstract_registry.h" + +#include "game_news.h" +#include "encyclopedia_article_defs.h" +#include "character_info_defs.h" +#include "relation_registry_defs.h" +#include "InfoPortionDefs.h" +#include "_stl_extensions.h" +#include "map_location_defs.h" +#include "map_location.h" +#include "GameTaskDefs.h" +#include "actor_statistic_defs.h" + +namespace SaveSystemDefined { + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const KNOWN_INFO_VECTOR& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Obj->GetCurrentChunk()->WriteArray(Value.size()); + { + for (const auto& elem : Value) { + elem.save(Obj); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, KNOWN_INFO_VECTOR& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.clear(); + u64 ArraySize; + Obj->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + INFO_DATA&& temp = INFO_DATA(); + temp.load(Obj); + Value.emplace_back(temp); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const RELATION_DATA& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Value.save(Obj); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, RELATION_DATA& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.load(Obj); + } + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const ARTICLE_VECTOR& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Obj->GetCurrentChunk()->WriteArray(Value.size()); + { + for (const auto& elem : Value) { + elem.save(Obj); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, ARTICLE_VECTOR& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.clear(); + u64 ArraySize; + Obj->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + ARTICLE_DATA&& temp = ARTICLE_DATA(); + temp.load(Obj); + Value.emplace_back(temp); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const GAME_NEWS_VECTOR& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Obj->GetCurrentChunk()->WriteArray(Value.size()); + { + for (const auto& elem : Value) { + elem.save(Obj); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, GAME_NEWS_VECTOR& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.clear(); + u64 ArraySize; + Obj->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + GAME_NEWS_DATA&& temp = GAME_NEWS_DATA(); + temp.load(Obj); + Value.emplace_back(temp); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Save(CSaveObjectSave* Obj, shared_str Key, const int& Value) { + Obj->GetCurrentChunk()->w_stringZ(Key); + Obj->GetCurrentChunk()->w_s32(Value); + } + + template<> + void Load(CSaveObjectLoad* Obj, shared_str& Key, int& Value) { + Obj->GetCurrentChunk()->r_stringZ(Key); + Obj->GetCurrentChunk()->r_s32(Value); + } + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const Locations& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Obj->GetCurrentChunk()->WriteArray(Value.size()); + { + for (const auto& elem : Value) { + elem.save(Obj); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, Locations& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.clear(); + u64 ArraySize; + Obj->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + SLocationKey&& temp = SLocationKey(); + temp.load(Obj); + Value.emplace_back(temp); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const vGameTasks& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Obj->GetCurrentChunk()->WriteArray(Value.size()); + { + for (const auto& elem : Value) { + elem.save(Obj); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, vGameTasks& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.clear(); + u64 ArraySize; + Obj->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + SGameTaskKey&& temp = SGameTaskKey(); + temp.load(Obj); + Value.emplace_back(temp); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Save(CSaveObjectSave* Obj, u16 Key, const vStatSectionData& Value) { + Obj->GetCurrentChunk()->w_u16(Key); + Obj->GetCurrentChunk()->WriteArray(Value.size()); + { + for (const auto& elem : Value) { + elem.save(Obj); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + + template<> + void Load(CSaveObjectLoad* Obj, u16& Key, vStatSectionData& Value) { + Obj->GetCurrentChunk()->r_u16(Key); + Value.clear(); + u64 ArraySize; + Obj->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + SStatSectionData&& temp = SStatSectionData(); + temp.load(Obj); + Value.emplace_back(temp); + } + } + Obj->GetCurrentChunk()->EndArray(); + } + +}; \ No newline at end of file diff --git a/src/xrGame/alife_abstract_registry_inline.h b/src/xrGame/alife_abstract_registry_inline.h index a76c530191..2099e115c1 100644 --- a/src/xrGame/alife_abstract_registry_inline.h +++ b/src/xrGame/alife_abstract_registry_inline.h @@ -7,163 +7,19 @@ //////////////////////////////////////////////////////////////////////////// #pragma once -#include "game_news.h" -#include "encyclopedia_article_defs.h" -#include "character_info_defs.h" -#include "relation_registry_defs.h" -#include "InfoPortionDefs.h" -#include "_stl_extensions.h" -#include "map_location_defs.h" namespace SaveSystemDefined { - + template - void Save(CSaveObjectSave* Obj, K Key, const V& Value) { + void Save(CSaveObjectSave* Obj, K Key, const V& Value); /* { VERIFY2(false, "Not implemented for such template arguments!"); - } + }*/ template - void Load(CSaveObjectLoad* Obj, K& Key, V& Value) { + void Load(CSaveObjectLoad* Obj, K& Key, V& Value); /*{ VERIFY2(false, "Not implemented for such template arguments!"); - } - - template<> - void Save(CSaveObjectSave* Obj, u16 Key, const KNOWN_INFO_VECTOR& Value) { - Obj->GetCurrentChunk()->w_u16(Key); - Obj->GetCurrentChunk()->WriteArray(Value.size()); - { - for (const auto& elem : Value) { - elem.save(Obj); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Load(CSaveObjectLoad* Obj, u16& Key, KNOWN_INFO_VECTOR& Value) { - Obj->GetCurrentChunk()->r_u16(Key); - Value.clear(); - u64 ArraySize; - Obj->GetCurrentChunk()->ReadArray(ArraySize); - { - for (u64 i = 0; i < ArraySize; ++i) { - INFO_DATA&& temp = INFO_DATA(); - temp.load(Obj); - Value.emplace_back(temp); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Save(CSaveObjectSave* Obj, u16 Key, const RELATION_DATA& Value) { - Obj->GetCurrentChunk()->w_u16(Key); - Value.save(Obj); - } - - template<> - void Load(CSaveObjectLoad* Obj, u16& Key, RELATION_DATA& Value) { - Obj->GetCurrentChunk()->r_u16(Key); - Value.load(Obj); - } - - template<> - void Save(CSaveObjectSave* Obj, u16 Key, const ARTICLE_VECTOR& Value) { - Obj->GetCurrentChunk()->w_u16(Key); - Obj->GetCurrentChunk()->WriteArray(Value.size()); - { - for (const auto& elem : Value) { - elem.save(Obj); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Load(CSaveObjectLoad* Obj, u16& Key, ARTICLE_VECTOR& Value) { - Obj->GetCurrentChunk()->r_u16(Key); - Value.clear(); - u64 ArraySize; - Obj->GetCurrentChunk()->ReadArray(ArraySize); - { - for (u64 i = 0; i < ArraySize; ++i) { - ARTICLE_DATA&& temp = ARTICLE_DATA(); - temp.load(Obj); - Value.emplace_back(temp); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Save(CSaveObjectSave* Obj, u16 Key, const GAME_NEWS_VECTOR& Value) { - Obj->GetCurrentChunk()->w_u16(Key); - Obj->GetCurrentChunk()->WriteArray(Value.size()); - { - for (const auto& elem : Value) { - elem.save(Obj); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Load(CSaveObjectLoad* Obj, u16& Key, GAME_NEWS_VECTOR& Value) { - Obj->GetCurrentChunk()->r_u16(Key); - Value.clear(); - u64 ArraySize; - Obj->GetCurrentChunk()->ReadArray(ArraySize); - { - for (u64 i = 0; i < ArraySize; ++i) { - GAME_NEWS_DATA&& temp = GAME_NEWS_DATA(); - temp.load(Obj); - Value.emplace_back(temp); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Save(CSaveObjectSave* Obj, shared_str Key, const int& Value) { - Obj->GetCurrentChunk()->w_stringZ(Key); - Obj->GetCurrentChunk()->w_s32(Value); - } - - template<> - void Load(CSaveObjectLoad* Obj, shared_str& Key, int& Value) { - Obj->GetCurrentChunk()->r_stringZ(Key); - Obj->GetCurrentChunk()->r_s32(Value); - } - - template<> - void Save(CSaveObjectSave* Obj, u16 Key, const Locations& Value) { - Obj->GetCurrentChunk()->w_u16(Key); - Obj->GetCurrentChunk()->WriteArray(Value.size()); - { - for (const auto& elem : Value) { - elem.save(Obj); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - - template<> - void Load(CSaveObjectLoad* Obj, u16& Key, Locations& Value) { - Obj->GetCurrentChunk()->r_u16(Key); - Value.clear(); - u64 ArraySize; - Obj->GetCurrentChunk()->ReadArray(ArraySize); - { - for (u64 i = 0; i < ArraySize; ++i) { - GAME_NEWS_DATA&& temp = GAME_NEWS_DATA(); - temp.load(Obj); - Value.emplace_back(temp); - } - } - Obj->GetCurrentChunk()->EndArray(); - } - -}; + }*/ +} #define TEMPLATE_SPECIALIZATION template #define CSALifeAbstractRegistry CALifeAbstractRegistry<_index_type,_data_type> diff --git a/src/xrGame/alife_registry_container.cpp b/src/xrGame/alife_registry_container.cpp index 455ed39ae4..0e5231323a 100644 --- a/src/xrGame/alife_registry_container.cpp +++ b/src/xrGame/alife_registry_container.cpp @@ -105,7 +105,7 @@ void CALifeRegistryContainer::save(IWriter &memory_stream) memory_stream.close_chunk (); } -void CALifeRegistryContainer::load(CSaveObjectLoad* Object) +void CALifeRegistryContainer::Load(CSaveObjectLoad* Object) { Object->BeginChunk("CALifeRegistryContainer"); { @@ -121,7 +121,7 @@ void CALifeRegistryContainer::load(CSaveObjectLoad* Object) Object->EndChunk(); } -void CALifeRegistryContainer::save(CSaveObjectSave* Object) const +void CALifeRegistryContainer::Save(CSaveObjectSave* Object) const { Object->BeginChunk("CALifeRegistryContainer"); { diff --git a/src/xrGame/alife_registry_container.h b/src/xrGame/alife_registry_container.h index d684e16972..f196bd71ef 100644 --- a/src/xrGame/alife_registry_container.h +++ b/src/xrGame/alife_registry_container.h @@ -27,8 +27,8 @@ class CALifeRegistryContainer : public Loki::GenLinearHierarchy,public IPureD virtual void save (IWriter &stream); virtual void load (IReader &stream); - virtual void save(CSaveObjectSave* Object); + virtual void save(CSaveObjectSave* Object) const; virtual void load(CSaveObjectLoad* Object); virtual void destroy (); }; diff --git a/src/xrGame/map_manager.cpp b/src/xrGame/map_manager.cpp index 653b80872c..486c7d03aa 100644 --- a/src/xrGame/map_manager.cpp +++ b/src/xrGame/map_manager.cpp @@ -70,7 +70,7 @@ void SLocationKey::load(IReader &stream) location->load (stream); } -void SLocationKey::save(CSaveObjectSave* Object) +void SLocationKey::save(CSaveObjectSave* Object) const { Object->BeginChunk("SLocationKey"); { @@ -90,7 +90,7 @@ void SLocationKey::load(CSaveObjectLoad* Object) Object->GetCurrentChunk()->r_u16(object_id); Object->GetCurrentChunk()->r_stringZ(spot_type); bool bUserDefined; - Object->GetCurrentChunk()->w_bool(bUserDefined); + Object->GetCurrentChunk()->r_bool(bUserDefined); if (bUserDefined) { Level().Server->PerformIDgen(object_id);