From 4002d6a0835f55f470981b17cc2e62aa1ae05976 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Wed, 27 Jul 2022 17:37:20 -0500 Subject: [PATCH] [Hotfix] Shared Memory Protection Fixes --- common/shareddb.cpp | 16 +++++++++++----- common/shareddb.h | 4 ++++ zone/main.cpp | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 3f2c95dab..35cedb324 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -932,8 +932,6 @@ bool SharedDatabase::LoadItems(const std::string &prefix) { return false; } - m_shared_items_count = GetItemsCount(); - return true; } @@ -1784,8 +1782,6 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const LogError("Error Loading Spells: {}", ex.what()); return false; } - - m_shared_spells_count = GetSpellsCount(); return true; } @@ -2403,4 +2399,14 @@ uint32 SharedDatabase::GetItemsCount() } return 0; -} \ No newline at end of file +} + +void SharedDatabase::SetSharedItemsCount(uint32 shared_items_count) +{ + SharedDatabase::m_shared_items_count = shared_items_count; +} + +void SharedDatabase::SetSharedSpellsCount(uint32 shared_spells_count) +{ + SharedDatabase::m_shared_spells_count = shared_spells_count; +} diff --git a/common/shareddb.h b/common/shareddb.h index 1124a0ab4..f8b0ce6b7 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -217,6 +217,10 @@ protected: std::unique_ptr base_data_mmf; std::unique_ptr spells_mmf; +public: + void SetSharedItemsCount(uint32 shared_items_count); + void SetSharedSpellsCount(uint32 shared_spells_count); +protected: uint32 m_shared_items_count = 0; uint32 m_shared_spells_count = 0; }; diff --git a/zone/main.cpp b/zone/main.cpp index 3273db791..627f9e9b4 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -333,6 +333,10 @@ int main(int argc, char** argv) { return 1; } + // load these here for now until spells and items can be truly repointed to "content_db" + database.SetSharedItemsCount(content_db.GetItemsCount()); + database.SetSharedSpellsCount(content_db.GetSpellsCount()); + LogInfo("Loading base data"); if (!database.LoadBaseData(hotfix_name)) { LogError("Loading base data failed!");