diff --git a/src/xrGame/GameTaskDefs.h b/src/xrGame/GameTaskDefs.h index 9ff914ded..57980b8ca 100644 --- a/src/xrGame/GameTaskDefs.h +++ b/src/xrGame/GameTaskDefs.h @@ -49,4 +49,22 @@ struct CGameTaskRegistry : public CALifeAbstractRegistry CALifeAbstractRegistry::load(stream); load_data (g_active_task_id, stream); }; + virtual void save(CSaveObjectSave* Object) const + { + Object->BeginChunk("CGameTaskRegistry"); + { + CALifeAbstractRegistry::save(Object); + Object->GetCurrentChunk()->w_stringZ(g_active_task_id); + } + Object->EndChunk(); + }; + virtual void load(CSaveObjectLoad* Object) + { + Object->BeginChunk("CGameTaskRegistry"); + { + CALifeAbstractRegistry::load(Object); + Object->GetCurrentChunk()->r_stringZ(g_active_task_id); + } + Object->EndChunk(); + }; }; diff --git a/src/xrGame/InfoPortion.cpp b/src/xrGame/InfoPortion.cpp index d4aaa4c22..aa64b222a 100644 --- a/src/xrGame/InfoPortion.cpp +++ b/src/xrGame/InfoPortion.cpp @@ -26,6 +26,26 @@ void INFO_DATA::save (IWriter& stream) save_data(receive_time, stream); } +void INFO_DATA::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("INFO_DATA"); + { + Object->GetCurrentChunk()->r_stringZ(info_id); + Object->GetCurrentChunk()->r_u64(receive_time); + } + Object->EndChunk(); +} + +void INFO_DATA::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("INFO_DATA"); + { + Object->GetCurrentChunk()->w_stringZ(info_id); + Object->GetCurrentChunk()->w_u64(receive_time); + } + Object->EndChunk(); +} + SInfoPortionData::SInfoPortionData () { diff --git a/src/xrGame/alife_abstract_registry.h b/src/xrGame/alife_abstract_registry.h index 3f47cc01f..d21ef6ece 100644 --- a/src/xrGame/alife_abstract_registry.h +++ b/src/xrGame/alife_abstract_registry.h @@ -10,6 +10,7 @@ #include "object_interfaces.h" #include "object_broker.h" +#include "Save/SaveObject.h" template class CALifeAbstractRegistry : public IPureSerializeObject { @@ -28,10 +29,12 @@ class CALifeAbstractRegistry : public IPureSerializeObject { virtual ~CALifeAbstractRegistry (); virtual void save (IWriter &memory_stream); virtual void load (IReader &file_stream); + virtual void save(CSaveObjectSave* Object) const; + virtual void load(CSaveObjectLoad* Object); IC const OBJECT_REGISTRY &objects () const; IC void add (const _index_type &index, _data_type &data, bool no_assert = false); IC void remove (const _index_type &index, bool no_assert = false); IC _data_type *object (const _index_type &index, bool no_assert = false); }; -#include "alife_abstract_registry_inline.h" \ No newline at end of file +#include "alife_abstract_registry_inline.h" diff --git a/src/xrGame/alife_abstract_registry_inline.h b/src/xrGame/alife_abstract_registry_inline.h index 086bba6d8..a76c53019 100644 --- a/src/xrGame/alife_abstract_registry_inline.h +++ b/src/xrGame/alife_abstract_registry_inline.h @@ -7,6 +7,163 @@ //////////////////////////////////////////////////////////////////////////// #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) { + VERIFY2(false, "Not implemented for such template arguments!"); + } + + template + 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> @@ -34,6 +191,41 @@ void CSALifeAbstractRegistry ::load (IReader &file_stream) load_data (m_objects,file_stream); } +TEMPLATE_SPECIALIZATION +void CSALifeAbstractRegistry::save(CSaveObjectSave* Object) const +{ + Object->GetCurrentChunk()->WriteArray(m_objects.size()); + { + for (const auto& elem : m_objects) { + Object->BeginChunk("CSALifeAbstractRegistry::elem"); + { + SaveSystemDefined::Save<_index_type, _data_type>(Object, elem.first, elem.second); + } + Object->EndChunk(); + } + } + Object->GetCurrentChunk()->EndArray(); +} + +TEMPLATE_SPECIALIZATION +void CSALifeAbstractRegistry::load(CSaveObjectLoad* Object) +{ + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + { + for (u64 i = 0; i < ArraySize; ++i) { + std::pair< _index_type, _data_type>&& temp = std::pair< _index_type, _data_type>(); + Object->BeginChunk("CSALifeAbstractRegistry::elem"); + { + SaveSystemDefined::Load<_index_type, _data_type>(Object, temp.first, temp.second); + } + Object->EndChunk(); + m_objects.emplace(temp); + } + } + Object->GetCurrentChunk()->EndArray(); +} + TEMPLATE_SPECIALIZATION IC const typename CSALifeAbstractRegistry::OBJECT_REGISTRY &CSALifeAbstractRegistry::objects () const { diff --git a/src/xrGame/alife_registry_container.cpp b/src/xrGame/alife_registry_container.cpp index d605fd122..455ed39ae 100644 --- a/src/xrGame/alife_registry_container.cpp +++ b/src/xrGame/alife_registry_container.cpp @@ -104,3 +104,28 @@ void CALifeRegistryContainer::save(IWriter &memory_stream) >::process (this,memory_stream); memory_stream.close_chunk (); } + +void CALifeRegistryContainer::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CALifeRegistryContainer"); + { + CInfoPortionRegistry::load(Object); + CRelationRegistry::load(Object); + CEncyclopediaRegistry::load(Object); + CGameNewsRegistry::load(Object); + CSpecificCharacterRegistry::load(Object); + CMapLocationRegistry::load(Object); + CGameTaskRegistry::load(Object); + CActorStatisticRegistry::load(Object); + } + Object->EndChunk(); +} + +void CALifeRegistryContainer::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CALifeRegistryContainer"); + { + + } + Object->EndChunk(); +} diff --git a/src/xrGame/alife_registry_container.h b/src/xrGame/alife_registry_container.h index 7d22972ff..d684e1697 100644 --- a/src/xrGame/alife_registry_container.h +++ b/src/xrGame/alife_registry_container.h @@ -11,6 +11,7 @@ #include "alife_registry_container_space.h" #include "alife_registry_container_composition.h" #include "alife_abstract_registry.h" +#include "Save/SaveObject.h" template struct CLinearRegistryType : public _base, public _type {}; @@ -26,6 +27,8 @@ class CALifeRegistryContainer : public Loki::GenLinearHierarchyBeginChunk("ARTICLE_DATA"); + { + Object->GetCurrentChunk()->r_u64(receive_time); + Object->GetCurrentChunk()->r_stringZ(article_id); + Object->GetCurrentChunk()->r_bool(readed); + { + u8 type; + Object->GetCurrentChunk()->r_u8(type); + article_type = (EArticleType)type; + } + } + Object->EndChunk(); +} + +void ARTICLE_DATA::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("ARTICLE_DATA"); + { + Object->GetCurrentChunk()->w_u64(receive_time); + Object->GetCurrentChunk()->w_stringZ(article_id); + Object->GetCurrentChunk()->w_bool(readed); + Object->GetCurrentChunk()->w_u8((u8)article_type); + } + Object->EndChunk(); +} + CEncyclopediaArticle::CEncyclopediaArticle() { } diff --git a/src/xrGame/encyclopedia_article_defs.h b/src/xrGame/encyclopedia_article_defs.h index 70f038011..677219ac0 100644 --- a/src/xrGame/encyclopedia_article_defs.h +++ b/src/xrGame/encyclopedia_article_defs.h @@ -24,6 +24,8 @@ struct ARTICLE_DATA : public IPureSerializeObject virtual void load (IReader& stream); virtual void save (IWriter&); + virtual void load(CSaveObjectLoad* Object); + virtual void save(CSaveObjectSave* Object) const; ALife::_TIME_ID receive_time; shared_str article_id; diff --git a/src/xrGame/game_news.cpp b/src/xrGame/game_news.cpp index aeb53e07a..7436f64a4 100644 --- a/src/xrGame/game_news.cpp +++ b/src/xrGame/game_news.cpp @@ -34,6 +34,36 @@ void GAME_NEWS_DATA::save (IWriter& stream) // save_data(tex_rect, stream); } +void GAME_NEWS_DATA::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("GAME_NEWS_DATA"); + { + { + u8 type; + Object->GetCurrentChunk()->r_u8(type); + m_type = (eNewsType)type; + } + Object->GetCurrentChunk()->r_stringZ(news_caption); + Object->GetCurrentChunk()->r_stringZ(news_text); + Object->GetCurrentChunk()->r_u64(receive_time); + Object->GetCurrentChunk()->r_stringZ(texture_name); + } + Object->EndChunk(); +} + +void GAME_NEWS_DATA::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("GAME_NEWS_DATA"); + { + Object->GetCurrentChunk()->w_u8(m_type); + Object->GetCurrentChunk()->w_stringZ(news_caption); + Object->GetCurrentChunk()->w_stringZ(news_text); + Object->GetCurrentChunk()->w_u64(receive_time); + Object->GetCurrentChunk()->w_stringZ(texture_name); + } + Object->EndChunk(); +} + void GAME_NEWS_DATA::load (IReader& stream) { load_data(m_type, stream); diff --git a/src/xrGame/game_news.h b/src/xrGame/game_news.h index 99d2c4b3a..356bf8530 100644 --- a/src/xrGame/game_news.h +++ b/src/xrGame/game_news.h @@ -17,6 +17,8 @@ struct GAME_NEWS_DATA : public IPureSerializeObject virtual void load (IReader&); virtual void save (IWriter&); + virtual void load(CSaveObjectLoad* Object); + virtual void save(CSaveObjectSave* Object) const; shared_str news_caption; diff --git a/src/xrGame/map_location.cpp b/src/xrGame/map_location.cpp index 1de305799..eac850447 100644 --- a/src/xrGame/map_location.cpp +++ b/src/xrGame/map_location.cpp @@ -665,6 +665,47 @@ void CMapLocation::load(IReader &stream) } } +void CMapLocation::save(CSaveObjectSave* Object) +{ + Object->BeginChunk("CMapLocation"); + { + Object->GetCurrentChunk()->w_stringZ(m_hint); + Object->GetCurrentChunk()->w_u32(m_flags.flags); + Object->GetCurrentChunk()->w_stringZ(m_owner_task_id); + if (IsUserDefined()) + { + Object->GetCurrentChunk()->w_stringZ(m_cached.m_LevelName); + Object->GetCurrentChunk()->w_float(m_cached.m_Position.x); + Object->GetCurrentChunk()->w_float(m_cached.m_Position.y); + Object->GetCurrentChunk()->w_u16(m_cached.m_graphID); + } + } + Object->EndChunk(); +} + +void CMapLocation::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CMapLocation"); + { + xr_string str; + Object->GetCurrentChunk()->r_stringZ(str); + SetHint(str.c_str()); + Object->GetCurrentChunk()->r_u32(m_flags.flags); + Object->GetCurrentChunk()->r_stringZ(str); + m_owner_task_id = str.c_str(); + if (IsUserDefined()) + { + Object->GetCurrentChunk()->r_stringZ(m_cached.m_LevelName); + Object->GetCurrentChunk()->r_float(m_cached.m_Position.x); + Object->GetCurrentChunk()->r_float(m_cached.m_Position.y); + Object->GetCurrentChunk()->r_u16(m_cached.m_graphID); + m_position_on_map = m_cached.m_Position; + m_position_global.set(m_position_on_map.x, 0.f, m_position_on_map.y); + } + } + Object->EndChunk(); +} + void CMapLocation::SetHint(const shared_str& hint) { if ( hint == "disable_hint" ) diff --git a/src/xrGame/map_location.h b/src/xrGame/map_location.h index 656e7b196..a2769603a 100644 --- a/src/xrGame/map_location.h +++ b/src/xrGame/map_location.h @@ -115,6 +115,8 @@ protected : virtual void save (IWriter &stream); virtual void load (IReader &stream); + virtual void save(CSaveObjectSave* Object); + virtual void load(CSaveObjectLoad* Object); shared_str m_owner_task_id; diff --git a/src/xrGame/map_location_defs.h b/src/xrGame/map_location_defs.h index 5253944c0..e0e76c00d 100644 --- a/src/xrGame/map_location_defs.h +++ b/src/xrGame/map_location_defs.h @@ -20,6 +20,8 @@ struct SLocationKey : public IPureSerializeObject,public IPureD virtual void save (IWriter &stream); virtual void load (IReader &stream); + virtual void save(CSaveObjectSave* Object); + virtual void load(CSaveObjectLoad* Object); virtual void destroy (); }; diff --git a/src/xrGame/map_manager.cpp b/src/xrGame/map_manager.cpp index 79a1db6b4..653b80872 100644 --- a/src/xrGame/map_manager.cpp +++ b/src/xrGame/map_manager.cpp @@ -64,11 +64,47 @@ void SLocationKey::load(IReader &stream) location = new CMapLocation(*spot_type, object_id); } - location = new CMapLocation(*spot_type, object_id); + //TODO: Make commit to IX-Ray to fix this + //location = new CMapLocation(*spot_type, object_id); location->load (stream); } +void SLocationKey::save(CSaveObjectSave* Object) +{ + Object->BeginChunk("SLocationKey"); + { + Object->GetCurrentChunk()->w_u16(object_id); + Object->GetCurrentChunk()->w_stringZ(spot_type); + Object->GetCurrentChunk()->w_bool(location->IsUserDefined()); + Object->GetCurrentChunk()->w_u8(0); + location->save(Object); + } + Object->EndChunk(); +} + +void SLocationKey::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("SLocationKey"); + { + Object->GetCurrentChunk()->r_u16(object_id); + Object->GetCurrentChunk()->r_stringZ(spot_type); + bool bUserDefined; + Object->GetCurrentChunk()->w_bool(bUserDefined); + if (bUserDefined) + { + Level().Server->PerformIDgen(object_id); + location = new CMapLocation(*spot_type, object_id, true); + } + else + { + location = new CMapLocation(*spot_type, object_id); + } + location->load(Object); + } + Object->EndChunk(); +} + void SLocationKey::destroy() { if (location && location->IsUserDefined()) diff --git a/src/xrGame/relation_registry.cpp b/src/xrGame/relation_registry.cpp index 24748d60c..7d2f6a70a 100644 --- a/src/xrGame/relation_registry.cpp +++ b/src/xrGame/relation_registry.cpp @@ -47,6 +47,93 @@ void RELATION_DATA::save (IWriter& stream) save_data(communities, stream); } +void RELATION_DATA::load(CSaveObjectLoad* Object) +{ + Object->BeginChunk("RELATION_DATA"); + { + Object->BeginChunk("RELATION_DATA::personal"); + { + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + for (u64 i = 0; i < ArraySize; ++i) { + Object->BeginChunk("RELATION_DATA::personal::elem"); + { + std::pair&& temp = std::pair(); + Object->GetCurrentChunk()->r_u16(temp.first); + s32 Goodwill; + Object->GetCurrentChunk()->r_s32(Goodwill); + temp.second.SetGoodwill(Goodwill); + personal.emplace(temp); + } + Object->EndChunk(); + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("RELATION_DATA::communities"); + { + u64 ArraySize; + Object->GetCurrentChunk()->ReadArray(ArraySize); + for (u64 i = 0; i < ArraySize; ++i) { + Object->BeginChunk("RELATION_DATA::communities::elem"); + { + std::pair&& temp = std::pair(); + s32 CommunityIndex; + Object->GetCurrentChunk()->r_s32(CommunityIndex); + temp.first = CommunityIndex; + s32 Goodwill; + Object->GetCurrentChunk()->r_s32(Goodwill); + temp.second.SetGoodwill(Goodwill); + communities.emplace(temp); + } + Object->EndChunk(); + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + } + Object->EndChunk(); +} + +void RELATION_DATA::save(CSaveObjectSave* Object) const +{ + Object->BeginChunk("RELATION_DATA"); + { + Object->BeginChunk("RELATION_DATA::personal"); + { + Object->GetCurrentChunk()->WriteArray(personal.size()); + for (const auto& elem : personal) { + Object->BeginChunk("RELATION_DATA::personal::elem"); + { + Object->GetCurrentChunk()->w_u16(elem.first); + s32 Goodwill = elem.second.Goodwill(); + Object->GetCurrentChunk()->w_s32(Goodwill); + } + Object->EndChunk(); + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + Object->BeginChunk("RELATION_DATA::communities"); + { + Object->GetCurrentChunk()->WriteArray(communities.size()); + for (const auto& elem : communities) { + Object->BeginChunk("RELATION_DATA::communities::elem"); + { + s32 CommunityIndex = elem.first; + Object->GetCurrentChunk()->w_s32(CommunityIndex); + s32 Goodwill = elem.second.Goodwill(); + Object->GetCurrentChunk()->w_s32(Goodwill); + } + Object->EndChunk(); + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + } + Object->EndChunk(); +} + ////////////////////////////////////////////////////////////////////////// RELATION_REGISTRY::RELATION_MAP_SPOTS::RELATION_MAP_SPOTS() diff --git a/src/xrGame/relation_registry_defs.h b/src/xrGame/relation_registry_defs.h index 2fe9f4a3b..709b0e5d6 100644 --- a/src/xrGame/relation_registry_defs.h +++ b/src/xrGame/relation_registry_defs.h @@ -34,6 +34,8 @@ struct RELATION_DATA : public IPureSerializeObject virtual void load (IReader&); virtual void save (IWriter&); + virtual void load(CSaveObjectLoad* Object); + virtual void save(CSaveObjectSave* Object) const; //личные отношения PERSONAL_RELATION_MAP personal; diff --git a/src/xrServerEntities/InfoPortionDefs.h b/src/xrServerEntities/InfoPortionDefs.h index 576f1b7ad..f39828f56 100644 --- a/src/xrServerEntities/InfoPortionDefs.h +++ b/src/xrServerEntities/InfoPortionDefs.h @@ -2,6 +2,7 @@ #include "alife_space.h" #include "object_interfaces.h" +#include "Save/SaveObject.h" //using INFO_DATA = shared_str; @@ -12,6 +13,8 @@ struct INFO_DATA : public IPureSerializeObject void load(IReader& stream) override; void save(IWriter&) override; + void load(CSaveObjectLoad* Object); + void save(CSaveObjectSave* Object) const; shared_str info_id; // diff --git a/src/xrServerEntities/xrServer_Object_Base.cpp b/src/xrServerEntities/xrServer_Object_Base.cpp index c24ffd836..2c4657120 100644 --- a/src/xrServerEntities/xrServer_Object_Base.cpp +++ b/src/xrServerEntities/xrServer_Object_Base.cpp @@ -479,6 +479,66 @@ void CSE_Abstract::load_update (NET_Packet &tNetPacket) } /**/ +bool CSE_Abstract::Spawn_Read(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_Abstract"); + { + // generic + Object->GetCurrentChunk()->r_stringZ(s_name); + Object->GetCurrentChunk()->r_stringZ(s_name_replace); + u8 temp_gt; + Object->GetCurrentChunk()->r_u8(temp_gt); + Object->GetCurrentChunk()->r_u8(s_RP); + Object->GetCurrentChunk()->r_vec3(o_Position); + Object->GetCurrentChunk()->r_vec3(o_Angle); + Object->GetCurrentChunk()->r_u16(RespawnTime); + Object->GetCurrentChunk()->r_u16(ID); + Object->GetCurrentChunk()->r_u16(ID_Parent); + Object->GetCurrentChunk()->r_u16(ID_Phantom); + Object->GetCurrentChunk()->r_u16(s_flags.flags); + Object->GetCurrentChunk()->r_u16(m_wVersion); + { + u16 gt; + Object->GetCurrentChunk()->r_u16(gt); + m_gameType.m_GameType.assign(gt); + } + Object->GetCurrentChunk()->r_u16(m_script_version); + + Object->BeginChunk("CSE_Abstract::ClientObject"); + { + bool HasClientObject; + Object->GetCurrentChunk()->r_bool(HasClientObject); + if (HasClientObject) { +#ifndef XRGAME_EXPORTS +#else + // TODO: Implement spawn of client object here + /*auto Obj = smart_cast(Level().Objects.net_Find(ID)); + if (Obj) { + Obj->Load(Object); + }*/ +#endif + } + } + Object->EndChunk(); + + Object->GetCurrentChunk()->w_u16(m_tSpawnID); + +#ifdef XRSE_FACTORY_EXPORTS + { + // HACK: because all save functions of new system tend to be const and assign function cannot be const + auto MutableThis = (CSE_Abstract*)this; + MutableThis->assign(); + } +#endif + + STATE_ReadSave(Object); + R_ASSERT3((m_tClassID == CLSID_SPECTATOR), + "object isn't successfully saved, get your backup :(", name_replace()); + } + Object->EndChunk(); + return true; +} + void CSE_Abstract::Spawn_Write(CSaveObjectSave* Object, bool bLocal) const { Object->BeginChunk("CSE_Abstract"); @@ -494,28 +554,16 @@ void CSE_Abstract::Spawn_Write(CSaveObjectSave* Object, bool bLocal) const Object->GetCurrentChunk()->w_u16(ID); Object->GetCurrentChunk()->w_u16(ID_Parent); Object->GetCurrentChunk()->w_u16(ID_Phantom); - if (bLocal) { Object->GetCurrentChunk()->w_u16(u16(s_flags.flags | M_SPAWN_OBJECT_LOCAL)); } else { Object->GetCurrentChunk()->w_u16(u16(s_flags.flags & ~(M_SPAWN_OBJECT_LOCAL | M_SPAWN_OBJECT_ASPLAYER))); } - Object->GetCurrentChunk()->w_u16(SPAWN_VERSION); - Object->GetCurrentChunk()->w_u16(m_gameType.m_GameType.get()); - Object->GetCurrentChunk()->w_u16(script_server_object_version()); - - //client object custom data serialization SAVE - //u16 client_data_size = (u16)client_data.size(); //не может быть больше 256 байт - //tNetPacket.w_u16(client_data_size); - // Msg ("SERVER:saving:save:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : ""); - //if (client_data_size > 0) { - // tNetPacket.w(&*client_data.begin(), client_data_size); - //} Object->BeginChunk("CSE_Abstract::ClientObject"); { #ifndef XRGAME_EXPORTS @@ -531,12 +579,6 @@ void CSE_Abstract::Spawn_Write(CSaveObjectSave* Object, bool bLocal) const Object->EndChunk(); Object->GetCurrentChunk()->w_u16(m_tSpawnID); - // tNetPacket.w_float (m_spawn_probability); - // tNetPacket.w_u32 (m_spawn_flags.get()); - // tNetPacket.w_stringZ (m_spawn_control); - // tNetPacket.w_u32 (m_max_spawn_count); - // tNetPacket.w_u64 (m_min_spawn_interval); - // tNetPacket.w_u64 (m_max_spawn_interval); #ifdef XRSE_FACTORY_EXPORTS { @@ -546,16 +588,9 @@ void CSE_Abstract::Spawn_Write(CSaveObjectSave* Object, bool bLocal) const } #endif - // write specific data - //u32 position = tNetPacket.w_tell(); - //tNetPacket.w_u16(0); STATE_WriteSave(Object); - //u16 size = u16(tNetPacket.w_tell() - position); - //#ifdef XRSE_FACTORY_EXPORTS R_ASSERT3((m_tClassID == CLSID_SPECTATOR), "object isn't successfully saved, get your backup :(", name_replace()); - //#endif - //tNetPacket.w_seek(position, &size, sizeof(u16)); } Object->EndChunk(); } diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp index f7ae1b75f..ba125b2ac 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp @@ -529,6 +529,73 @@ void CSE_ALifeTraderAbstract::UPDATE_Read (NET_Packet &tNetPacket) { }; +void CSE_ALifeTraderAbstract::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeTraderAbstract::STATE"); + { + Object->GetCurrentChunk()->r_u32(m_dwMoney); + Object->GetCurrentChunk()->r_stringZ(m_SpecificCharacter); + { + u32 Value; + Object->GetCurrentChunk()->r_u32(Value); + m_trader_flags.assign(Value); + } + // tNetPacket.w_s32 (m_iCharacterProfile); + Object->GetCurrentChunk()->r_stringZ(m_sCharacterProfile); + Object->GetCurrentChunk()->r_s32(m_community_index); + Object->GetCurrentChunk()->r_s32(m_rank); + Object->GetCurrentChunk()->r_s32(m_reputation); + Object->GetCurrentChunk()->r_stringZ(m_character_name); + Object->GetCurrentChunk()->r_bool(m_deadbody_can_take); + Object->GetCurrentChunk()->r_bool(m_deadbody_closed); + } + Object->EndChunk(); +} + +void CSE_ALifeTraderAbstract::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeTraderAbstract::STATE"); + { + Object->GetCurrentChunk()->w_u32(m_dwMoney); +#ifdef XRGAME_EXPORTS + Object->GetCurrentChunk()->w_stringZ(m_SpecificCharacter); +#else + shared_str s; + Object->GetCurrentChunk()->w_stringZ(s); +#endif + Object->GetCurrentChunk()->w_u32(m_trader_flags.get()); + // tNetPacket.w_s32 (m_iCharacterProfile); + Object->GetCurrentChunk()->w_stringZ(m_sCharacterProfile); +#ifdef XRGAME_EXPORTS + Object->GetCurrentChunk()->w_s32(m_community_index); + Object->GetCurrentChunk()->w_s32(m_rank); + Object->GetCurrentChunk()->w_s32(m_reputation); +#else + Object->GetCurrentChunk()->w_s32(NO_COMMUNITY_INDEX); + Object->GetCurrentChunk()->w_s32(NO_RANK); + Object->GetCurrentChunk()->w_s32(NO_REPUTATION); +#endif + Object->GetCurrentChunk()->w_stringZ(m_character_name); + Object->GetCurrentChunk()->w_bool(m_deadbody_can_take); + Object->GetCurrentChunk()->w_bool(m_deadbody_closed); + } + Object->EndChunk(); +} + +void CSE_ALifeTraderAbstract::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeTraderAbstract::UPDATE"); + {} + Object->EndChunk(); +} + +void CSE_ALifeTraderAbstract::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeTraderAbstract::UPDATE"); + {} + Object->EndChunk(); +} + //////////////////////////////////////////////////////////////////////////// // CSE_ALifeTrader @@ -619,6 +686,46 @@ void CSE_ALifeTrader::UPDATE_Read (NET_Packet &tNetPacket) inherited2::UPDATE_Read (tNetPacket); }; +void CSE_ALifeTrader::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeTrader::STATE"); + { + inherited1::STATE_ReadSave(Object); + inherited2::STATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeTrader::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeTrader::STATE"); + { + inherited1::STATE_WriteSave(Object); + inherited2::STATE_WriteSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeTrader::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeTrader::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + inherited2::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeTrader::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeTrader::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + inherited2::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + bool CSE_ALifeTrader::interactive () const { return (false); @@ -702,6 +809,53 @@ void CSE_ALifeCustomZone::UPDATE_Write (NET_Packet &tNetPacket) inherited::UPDATE_Write (tNetPacket); } +void CSE_ALifeCustomZone::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCustomZone::STATE"); + { + inherited::STATE_ReadSave(Object); + float tmp; + Object->GetCurrentChunk()->r_float(tmp /*m_maxPower*/); + Object->GetCurrentChunk()->r_u32(m_owner_id); + Object->GetCurrentChunk()->r_u32(m_enabled_time); + Object->GetCurrentChunk()->r_u32(m_disabled_time); + Object->GetCurrentChunk()->r_u32(m_start_time_shift); + } + Object->EndChunk(); +} + +void CSE_ALifeCustomZone::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCustomZone::STATE"); + { + inherited::STATE_WriteSave(Object); + Object->GetCurrentChunk()->w_float(0.0/*m_maxPower*/); + Object->GetCurrentChunk()->w_u32(m_owner_id); + Object->GetCurrentChunk()->w_u32(m_enabled_time); + Object->GetCurrentChunk()->w_u32(m_disabled_time); + Object->GetCurrentChunk()->w_u32(m_start_time_shift); + } + Object->EndChunk(); +} + +void CSE_ALifeCustomZone::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCustomZone::UPDATE"); + { + inherited::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCustomZone::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCustomZone::UPDATE"); + { + inherited::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeCustomZone::FillProps (LPCSTR pref, PropItemVec& items) { @@ -821,6 +975,48 @@ void CSE_ALifeAnomalousZone::UPDATE_Write (NET_Packet &tNetPacket) inherited::UPDATE_Write (tNetPacket); } +void CSE_ALifeAnomalousZone::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeAnomalousZone::STATE"); + { + inherited::STATE_ReadSave(Object); + Object->GetCurrentChunk()->r_float(m_offline_interactive_radius); + Object->GetCurrentChunk()->r_u16(m_artefact_spawn_count); + Object->GetCurrentChunk()->r_u32(m_artefact_position_offset); + } + Object->EndChunk(); +} + +void CSE_ALifeAnomalousZone::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeAnomalousZone::STATE"); + { + inherited::STATE_WriteSave(Object); + Object->GetCurrentChunk()->w_float(m_offline_interactive_radius); + Object->GetCurrentChunk()->w_u16(m_artefact_spawn_count); + Object->GetCurrentChunk()->w_u32(m_artefact_position_offset); + } + Object->EndChunk(); +} + +void CSE_ALifeAnomalousZone::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeAnomalousZone::UPDATE"); + { + inherited::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeAnomalousZone::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeAnomalousZone::UPDATE"); + { + inherited::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeAnomalousZone::FillProps (LPCSTR pref, PropItemVec& items) { @@ -872,6 +1068,45 @@ void CSE_ALifeTorridZone::UPDATE_Write (NET_Packet &tNetPacket) inherited1::UPDATE_Write (tNetPacket); } +void CSE_ALifeTorridZone::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeTorridZone::STATE"); + { + inherited1::STATE_ReadSave(Object); + CSE_Motion::motion_read(Object); + set_editor_flag(flMotionChange); + } + Object->EndChunk(); +} + +void CSE_ALifeTorridZone::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeTorridZone::STATE"); + { + inherited1::STATE_WriteSave(Object); + CSE_Motion::motion_write(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeTorridZone::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeTorridZone::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeTorridZone::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeTorridZone::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeTorridZone::FillProps(LPCSTR pref, PropItemVec& values) { @@ -927,6 +1162,48 @@ void CSE_ALifeZoneVisual::UPDATE_Write (NET_Packet &tNetPacket) inherited1::UPDATE_Write (tNetPacket); } +void CSE_ALifeZoneVisual::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeZoneVisual::STATE"); + { + inherited1::STATE_ReadSave(Object); + visual_read(Object); + Object->GetCurrentChunk()->r_stringZ(startup_animation); + Object->GetCurrentChunk()->r_stringZ(attack_animation); + } + Object->EndChunk(); +} + +void CSE_ALifeZoneVisual::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeZoneVisual::STATE"); + { + inherited1::STATE_WriteSave(Object); + visual_write(Object); + Object->GetCurrentChunk()->w_stringZ(startup_animation); + Object->GetCurrentChunk()->w_stringZ(attack_animation); + } + Object->EndChunk(); +} + +void CSE_ALifeZoneVisual::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeZoneVisual::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeZoneVisual::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeZoneVisual::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeZoneVisual::FillProps(LPCSTR pref, PropItemVec& values) { @@ -1082,6 +1359,112 @@ void CSE_ALifeCreatureAbstract::UPDATE_Read (NET_Packet &tNetPacket) tNetPacket.r_u8 (s_group); }; +void CSE_ALifeCreatureAbstract::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreatureAbstract::STATE"); + { + inherited::STATE_ReadSave(Object); + Object->GetCurrentChunk()->r_u8(s_team); + Object->GetCurrentChunk()->r_u8(s_squad); + Object->GetCurrentChunk()->r_u8(s_group); + Object->GetCurrentChunk()->r_float(fHealth); + o_model = o_torso.yaw; + Object->GetCurrentChunk()->WriteArray(m_dynamic_out_restrictions.size()); + { + for (auto elem : m_dynamic_out_restrictions) { + Object->GetCurrentChunk()->w_u16(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + Object->GetCurrentChunk()->WriteArray(m_dynamic_in_restrictions.size()); + { + for (auto elem : m_dynamic_in_restrictions) { + Object->GetCurrentChunk()->w_u16(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + { + u16 Value; + Object->GetCurrentChunk()->r_u16(Value); + set_killer_id(Value); + } + o_torso.pitch = o_Angle.x; + o_torso.yaw = o_Angle.y; + Object->GetCurrentChunk()->r_u64(m_game_death_time); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureAbstract::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreatureAbstract::STATE"); + { + inherited::STATE_WriteSave(Object); + Object->GetCurrentChunk()->w_u8(s_team); + Object->GetCurrentChunk()->w_u8(s_squad); + Object->GetCurrentChunk()->w_u8(s_group); + Object->GetCurrentChunk()->w_float(fHealth); + Object->GetCurrentChunk()->WriteArray(m_dynamic_out_restrictions.size()); + { + for (auto elem : m_dynamic_out_restrictions) { + Object->GetCurrentChunk()->w_u16(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + Object->GetCurrentChunk()->WriteArray(m_dynamic_in_restrictions.size()); + { + for (auto elem : m_dynamic_in_restrictions) { + Object->GetCurrentChunk()->w_u16(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + Object->GetCurrentChunk()->w_u16(get_killer_id()); + R_ASSERT(!(get_health() > 0.0f && get_killer_id() != u16(-1))); + Object->GetCurrentChunk()->w_u64(m_game_death_time); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureAbstract::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreatureAbstract::UPDATE"); + { + inherited::UPDATE_ReadSave(Object); + Object->GetCurrentChunk()->r_float(fHealth); + Object->GetCurrentChunk()->r_u32(timestamp); + Object->GetCurrentChunk()->r_u8(flags); + Object->GetCurrentChunk()->r_vec3(o_Position); + Object->GetCurrentChunk()->r_float(o_model); + Object->GetCurrentChunk()->r_float(o_torso.yaw); + Object->GetCurrentChunk()->r_float(o_torso.pitch); + Object->GetCurrentChunk()->r_float(o_torso.roll); + Object->GetCurrentChunk()->r_u8(s_team); + Object->GetCurrentChunk()->r_u8(s_squad); + Object->GetCurrentChunk()->r_u8(s_group); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureAbstract::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreatureAbstract::UPDATE"); + { + inherited::UPDATE_WriteSave(Object); + Object->GetCurrentChunk()->w_float(fHealth); + Object->GetCurrentChunk()->w_u32(timestamp); + Object->GetCurrentChunk()->w_u8(flags); + Object->GetCurrentChunk()->w_vec3(o_Position); + Object->GetCurrentChunk()->w_float(o_model); + Object->GetCurrentChunk()->w_float(o_torso.yaw); + Object->GetCurrentChunk()->w_float(o_torso.pitch); + Object->GetCurrentChunk()->w_float(o_torso.roll); + Object->GetCurrentChunk()->w_u8(s_team); + Object->GetCurrentChunk()->w_u8(s_squad); + Object->GetCurrentChunk()->w_u8(s_group); + } + Object->EndChunk(); +} + u8 CSE_ALifeCreatureAbstract::g_team () { return s_team; @@ -1309,6 +1692,58 @@ void CSE_ALifeMonsterAbstract::UPDATE_Read (NET_Packet &tNetPacket) }; +void CSE_ALifeMonsterAbstract::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeMonsterAbstract::STATE"); + { + inherited1::STATE_ReadSave(Object); + Object->GetCurrentChunk()->r_stringZ(m_out_space_restrictors); + Object->GetCurrentChunk()->r_stringZ(m_in_space_restrictors); + Object->GetCurrentChunk()->r_u16(m_smart_terrain_id); + Object->GetCurrentChunk()->r_bool(m_task_reached); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterAbstract::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeMonsterAbstract::STATE"); + { + inherited1::STATE_WriteSave(Object); + Object->GetCurrentChunk()->w_stringZ(m_out_space_restrictors); + Object->GetCurrentChunk()->w_stringZ(m_in_space_restrictors); + Object->GetCurrentChunk()->w_u16(m_smart_terrain_id); + Object->GetCurrentChunk()->w_bool(m_task_reached); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterAbstract::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeMonsterAbstract::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + Object->GetCurrentChunk()->r_u16(m_tNextGraphID); + Object->GetCurrentChunk()->r_u16(m_tPrevGraphID); + Object->GetCurrentChunk()->r_float(m_fDistanceFromPoint); + Object->GetCurrentChunk()->r_float(m_fDistanceToPoint); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterAbstract::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeMonsterAbstract::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + Object->GetCurrentChunk()->w_u16(m_tNextGraphID); + Object->GetCurrentChunk()->w_u16(m_tPrevGraphID); + Object->GetCurrentChunk()->w_float(m_fDistanceFromPoint); + Object->GetCurrentChunk()->w_float(m_fDistanceToPoint); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeMonsterAbstract::FillProps (LPCSTR pref, PropItemVec& items) { @@ -1524,6 +1959,136 @@ void CSE_ALifeCreatureActor::UPDATE_Write (NET_Packet &tNetPacket) }; } +void CSE_ALifeCreatureActor::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreatureActor::STATE"); + { + inherited1::STATE_ReadSave(Object); + inherited2::STATE_ReadSave(Object); + inherited3::STATE_ReadSave(Object); + Object->GetCurrentChunk()->r_u16(m_holderID); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureActor::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreatureActor::STATE"); + { + inherited1::STATE_WriteSave(Object); + inherited2::STATE_WriteSave(Object); + inherited3::STATE_WriteSave(Object); + Object->GetCurrentChunk()->w_u16(m_holderID); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureActor::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + inherited2::UPDATE_ReadSave(Object); + inherited3::UPDATE_ReadSave(Object); + Object->GetCurrentChunk()->r_u16(mstate); + Object->GetCurrentChunk()->r_vec3(accel); + Object->GetCurrentChunk()->r_vec3(velocity); + Object->GetCurrentChunk()->r_float(fRadiation); + Object->GetCurrentChunk()->r_u8(weapon); + //////////////////////////////////////////////////// + Object->GetCurrentChunk()->r_u16(m_u16NumItems); + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE::m_u16NumItems"); + if (m_u16NumItems) { + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE::m_u16NumItems::eq1"); + if (m_u16NumItems == 1) + { + Object->GetCurrentChunk()->r_bool(m_AliveState.enabled); + Object->GetCurrentChunk()->r_vec3(m_AliveState.angular_vel); + Object->GetCurrentChunk()->r_vec3(m_AliveState.linear_vel); + Object->GetCurrentChunk()->r_vec3(m_AliveState.force); + Object->GetCurrentChunk()->r_vec3(m_AliveState.torque); + Object->GetCurrentChunk()->r_vec3(m_AliveState.position); + Object->GetCurrentChunk()->r_float(m_AliveState.quaternion.x); + Object->GetCurrentChunk()->r_float(m_AliveState.quaternion.y); + Object->GetCurrentChunk()->r_float(m_AliveState.quaternion.z); + Object->GetCurrentChunk()->r_float(m_AliveState.quaternion.w); + }; + Object->EndChunk(); + ////////////// Export dead body //////////////////// + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE::m_u16NumItems::dead_body"); + if (m_u16NumItems > 1) { + Object->GetCurrentChunk()->r_u8(m_BoneDataSize); + u64 BodyDataSize; + Object->GetCurrentChunk()->ReadArray(BodyDataSize); + { + VERIFY(BodyDataSize == 24 + m_BoneDataSize * m_u16NumItems && BodyDataSize <= 1024); + for (u64 i = 0; i < BodyDataSize; ++i) { + s8 Value; + Object->GetCurrentChunk()->r_s8(Value); + m_DeadBodyData[i] = Value; + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + } + Object->EndChunk(); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureActor::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + inherited2::UPDATE_WriteSave(Object); + inherited3::UPDATE_WriteSave(Object); + Object->GetCurrentChunk()->w_u16(mstate); + Object->GetCurrentChunk()->w_vec3(accel); + Object->GetCurrentChunk()->w_vec3(velocity); + Object->GetCurrentChunk()->w_float(fRadiation); + Object->GetCurrentChunk()->w_u8(weapon); + //////////////////////////////////////////////////// + Object->GetCurrentChunk()->w_u16(m_u16NumItems); + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE::m_u16NumItems"); + if (m_u16NumItems) { + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE::m_u16NumItems::eq1"); + if (m_u16NumItems == 1) + { + Object->GetCurrentChunk()->w_bool(m_AliveState.enabled); + Object->GetCurrentChunk()->w_vec3(m_AliveState.angular_vel); + Object->GetCurrentChunk()->w_vec3(m_AliveState.linear_vel); + Object->GetCurrentChunk()->w_vec3(m_AliveState.force); + Object->GetCurrentChunk()->w_vec3(m_AliveState.torque); + Object->GetCurrentChunk()->w_vec3(m_AliveState.position); + Object->GetCurrentChunk()->w_float(m_AliveState.quaternion.x); + Object->GetCurrentChunk()->w_float(m_AliveState.quaternion.y); + Object->GetCurrentChunk()->w_float(m_AliveState.quaternion.z); + Object->GetCurrentChunk()->w_float(m_AliveState.quaternion.w); + }; + Object->EndChunk(); + ////////////// Export dead body //////////////////// + Object->BeginChunk("CSE_ALifeCreatureActor::UPDATE::m_u16NumItems::dead_body"); + if (m_u16NumItems > 1) { + Object->GetCurrentChunk()->w_u8(m_BoneDataSize); + u32 BodyDataSize = 24 + m_BoneDataSize * m_u16NumItems; + VERIFY(BodyDataSize <= 1024); + Object->GetCurrentChunk()->WriteArray(BodyDataSize); + { + for (auto elem : m_DeadBodyData) { + Object->GetCurrentChunk()->w_s8(elem); + } + } + Object->GetCurrentChunk()->EndArray(); + } + Object->EndChunk(); + } + Object->EndChunk(); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeCreatureActor::FillProps (LPCSTR pref, PropItemVec& items) { @@ -1579,6 +2144,42 @@ void CSE_ALifeCreatureCrow::UPDATE_Write (NET_Packet &tNetPacket) inherited::UPDATE_Write (tNetPacket); } +void CSE_ALifeCreatureCrow::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreatureCrow::STATE"); + { + inherited::STATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureCrow::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreatureCrow::STATE"); + { + inherited::STATE_WriteSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureCrow::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreatureCrow::UPDATE"); + { + inherited::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCreatureCrow::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreatureCrow::UPDATE"); + { + inherited::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeCreatureCrow::FillProps (LPCSTR pref, PropItemVec& values) { @@ -1627,6 +2228,42 @@ void CSE_ALifeCreaturePhantom::UPDATE_Write (NET_Packet &tNetPacket) inherited::UPDATE_Write (tNetPacket); } +void CSE_ALifeCreaturePhantom::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreaturePhantom::STATE"); + { + inherited::STATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCreaturePhantom::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreaturePhantom::STATE"); + { + inherited::STATE_WriteSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCreaturePhantom::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeCreaturePhantom::UPDATE"); + { + inherited::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeCreaturePhantom::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeCreaturePhantom::UPDATE"); + { + inherited::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeCreaturePhantom::FillProps (LPCSTR pref, PropItemVec& values) { @@ -1747,6 +2384,90 @@ void CSE_ALifeMonsterRat::UPDATE_Write (NET_Packet &tNetPacket) inherited2::UPDATE_Write (tNetPacket); } +void CSE_ALifeMonsterRat::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeMonsterRat::STATE"); + { + inherited1::STATE_ReadSave(Object); + inherited2::STATE_ReadSave(Object); + Object->GetCurrentChunk()->r_float(fEyeFov); + Object->GetCurrentChunk()->r_float(fEyeRange); + Object->GetCurrentChunk()->r_float(fMinSpeed); + Object->GetCurrentChunk()->r_float(fMaxSpeed); + Object->GetCurrentChunk()->r_float(fAttackSpeed); + Object->GetCurrentChunk()->r_float(fMaxPursuitRadius); + Object->GetCurrentChunk()->r_float(fMaxHomeRadius); + // morale + Object->GetCurrentChunk()->r_float(fMoraleSuccessAttackQuant); + Object->GetCurrentChunk()->r_float(fMoraleDeathQuant); + Object->GetCurrentChunk()->r_float(fMoraleFearQuant); + Object->GetCurrentChunk()->r_float(fMoraleRestoreQuant); + Object->GetCurrentChunk()->r_u16(u16MoraleRestoreTimeInterval); + Object->GetCurrentChunk()->r_float(fMoraleMinValue); + Object->GetCurrentChunk()->r_float(fMoraleMaxValue); + Object->GetCurrentChunk()->r_float(fMoraleNormalValue); + // attack + Object->GetCurrentChunk()->r_float(fHitPower); + Object->GetCurrentChunk()->r_u16(u16HitInterval); + Object->GetCurrentChunk()->r_float(fAttackDistance); + Object->GetCurrentChunk()->r_float(fAttackAngle); + Object->GetCurrentChunk()->r_float(fAttackSuccessProbability); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterRat::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeMonsterRat::STATE"); + { + inherited1::STATE_WriteSave(Object); + inherited2::STATE_WriteSave(Object); + Object->GetCurrentChunk()->w_float(fEyeFov); + Object->GetCurrentChunk()->w_float(fEyeRange); + Object->GetCurrentChunk()->w_float(fMinSpeed); + Object->GetCurrentChunk()->w_float(fMaxSpeed); + Object->GetCurrentChunk()->w_float(fAttackSpeed); + Object->GetCurrentChunk()->w_float(fMaxPursuitRadius); + Object->GetCurrentChunk()->w_float(fMaxHomeRadius); + // morale + Object->GetCurrentChunk()->w_float(fMoraleSuccessAttackQuant); + Object->GetCurrentChunk()->w_float(fMoraleDeathQuant); + Object->GetCurrentChunk()->w_float(fMoraleFearQuant); + Object->GetCurrentChunk()->w_float(fMoraleRestoreQuant); + Object->GetCurrentChunk()->w_u16(u16MoraleRestoreTimeInterval); + Object->GetCurrentChunk()->w_float(fMoraleMinValue); + Object->GetCurrentChunk()->w_float(fMoraleMaxValue); + Object->GetCurrentChunk()->w_float(fMoraleNormalValue); + // attack + Object->GetCurrentChunk()->w_float(fHitPower); + Object->GetCurrentChunk()->w_u16(u16HitInterval); + Object->GetCurrentChunk()->w_float(fAttackDistance); + Object->GetCurrentChunk()->w_float(fAttackAngle); + Object->GetCurrentChunk()->w_float(fAttackSuccessProbability); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterRat::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeMonsterRat::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + inherited2::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterRat::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeMonsterRat::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + inherited2::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + CSE_Abstract *CSE_ALifeMonsterRat::init () { inherited1::init (); @@ -1878,6 +2599,68 @@ void CSE_ALifeMonsterZombie::UPDATE_Write (NET_Packet &tNetPacket) inherited::UPDATE_Write (tNetPacket); } +void CSE_ALifeMonsterZombie::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeMonsterZombie::STATE"); + { + inherited::STATE_ReadSave(Object); + // personal characteristics + Object->GetCurrentChunk()->r_float(fEyeFov); + Object->GetCurrentChunk()->r_float(fEyeRange); + Object->GetCurrentChunk()->r_float(fMinSpeed); + Object->GetCurrentChunk()->r_float(fMaxSpeed); + Object->GetCurrentChunk()->r_float(fAttackSpeed); + Object->GetCurrentChunk()->r_float(fMaxPursuitRadius); + Object->GetCurrentChunk()->r_float(fMaxHomeRadius); + // attack + Object->GetCurrentChunk()->r_float(fHitPower); + Object->GetCurrentChunk()->r_u16(u16HitInterval); + Object->GetCurrentChunk()->r_float(fAttackDistance); + Object->GetCurrentChunk()->r_float(fAttackAngle); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterZombie::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeMonsterZombie::STATE"); + { + inherited::STATE_WriteSave(Object); + // personal characteristics + Object->GetCurrentChunk()->w_float(fEyeFov); + Object->GetCurrentChunk()->w_float(fEyeRange); + Object->GetCurrentChunk()->w_float(fMinSpeed); + Object->GetCurrentChunk()->w_float(fMaxSpeed); + Object->GetCurrentChunk()->w_float(fAttackSpeed); + Object->GetCurrentChunk()->w_float(fMaxPursuitRadius); + Object->GetCurrentChunk()->w_float(fMaxHomeRadius); + // attack + Object->GetCurrentChunk()->w_float(fHitPower); + Object->GetCurrentChunk()->w_u16(u16HitInterval); + Object->GetCurrentChunk()->w_float(fAttackDistance); + Object->GetCurrentChunk()->w_float(fAttackAngle); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterZombie::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_ALifeMonsterZombie::UPDATE"); + { + inherited::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_ALifeMonsterZombie::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_ALifeMonsterZombie::UPDATE"); + { + inherited::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_ALifeMonsterZombie::FillProps (LPCSTR pref, PropItemVec& items) { diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp index 4d20123d8..c25dc7505 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp @@ -170,6 +170,57 @@ void CSE_SmartCover::UPDATE_Write(NET_Packet &tNetPacket) { inherited1::UPDATE_Write (tNetPacket); } + +void CSE_SmartCover::STATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_SmartCover::STATE"); + { + inherited1::STATE_ReadSave(Object); + cform_read(Object); + Object->GetCurrentChunk()->r_stringZ(m_description); + Object->GetCurrentChunk()->r_float(m_hold_position_time); + Object->GetCurrentChunk()->r_float(m_enter_min_enemy_distance); + Object->GetCurrentChunk()->r_float(m_exit_min_enemy_distance); + Object->GetCurrentChunk()->r_bool(m_is_combat_cover); + Object->GetCurrentChunk()->r_bool(m_can_fire); + } + Object->EndChunk(); +} + +void CSE_SmartCover::STATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_SmartCover::STATE"); + { + inherited1::STATE_WriteSave(Object); + cform_write(Object); + Object->GetCurrentChunk()->w_stringZ(m_description); + Object->GetCurrentChunk()->w_float(m_hold_position_time); + Object->GetCurrentChunk()->w_float(m_enter_min_enemy_distance); + Object->GetCurrentChunk()->w_float(m_exit_min_enemy_distance); + Object->GetCurrentChunk()->w_bool(m_is_combat_cover); + Object->GetCurrentChunk()->w_bool(m_can_fire); + } + Object->EndChunk(); +} + +void CSE_SmartCover::UPDATE_ReadSave(CSaveObjectLoad* Object) +{ + Object->BeginChunk("CSE_SmartCover::UPDATE"); + { + inherited1::UPDATE_ReadSave(Object); + } + Object->EndChunk(); +} + +void CSE_SmartCover::UPDATE_WriteSave(CSaveObjectSave* Object) const +{ + Object->BeginChunk("CSE_SmartCover::UPDATE"); + { + inherited1::UPDATE_WriteSave(Object); + } + Object->EndChunk(); +} + #ifndef XRGAME_EXPORTS void CSE_SmartCover::FillProps (LPCSTR pref, PropItemVec& items) { @@ -182,8 +233,8 @@ void CSE_SmartCover::FillProps (LPCSTR pref, PropItemVec& items) PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"exit min enemy distance"), &m_exit_min_enemy_distance, 0.f, 100.f); if (is_combat_cover(m_description)) { - PHelper().CreateBOOL (items, PrepareKey(pref, *s_name, "is combat cover"), &m_is_combat_cover); - PHelper().CreateBOOL (items, PrepareKey(pref, *s_name, "can fire"), &m_can_fire); + PHelper().CreateBool (items, PrepareKey(pref, *s_name, "is combat cover"), &m_is_combat_cover); + PHelper().CreateBool (items, PrepareKey(pref, *s_name, "can fire"), &m_can_fire); } # endif // #ifdef XRSE_FACTORY_EXPORTS } diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h index 0f394e70a..ed0b90d91 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h @@ -33,8 +33,8 @@ SERVER_ENTITY_DECLARE_BEGIN2(CSE_SmartCover,CSE_ALifeDynamicObject,CSE_Shape) float m_hold_position_time; float m_enter_min_enemy_distance; float m_exit_min_enemy_distance; - BOOL m_is_combat_cover; - BOOL m_can_fire; + bool m_is_combat_cover; + bool m_can_fire; bool m_need_to_reparse_loopholes; #ifndef AI_COMPILER luabind::object m_available_loopholes;