Use local database pointer

This commit is contained in:
Chris Miles 2025-06-27 16:11:05 -05:00
parent 66cc83cb28
commit 7d223ce6f2
5 changed files with 12 additions and 10 deletions

View File

@ -320,7 +320,9 @@ bool WorldContentService::DoesZonePassContentFiltering(const ZoneRepository::Zon
return DoesPassContentFiltering(f); return DoesPassContentFiltering(f);
} }
void WorldContentService::LoadTargetedRulesets(Database* db)
void WorldContentService::LoadTargetedRulesets()
{ {
if (!m_zone_id) { if (!m_zone_id) {
LogError("Zone ID is not set. Cannot load targeted rulesets."); LogError("Zone ID is not set. Cannot load targeted rulesets.");
@ -331,8 +333,8 @@ void WorldContentService::LoadTargetedRulesets(Database* db)
constexpr int8 EXPANSION_ZERO_VALUE = -2; constexpr int8 EXPANSION_ZERO_VALUE = -2;
auto rules = RuleValuesRepository::GetWhere(*db, "TRUE ORDER BY ruleset_id, rule_name"); auto rules = RuleValuesRepository::GetWhere(*m_database, "TRUE ORDER BY ruleset_id, rule_name");
auto sets = RuleSetsRepository::GetWhere(*db, "TRUE ORDER BY ruleset_id"); auto sets = RuleSetsRepository::GetWhere(*m_database, "TRUE ORDER BY ruleset_id");
for (auto& e : sets) { for (auto& e : sets) {
bool has_filters = bool has_filters =
!e.zone_ids.empty() || !e.zone_ids.empty() ||

View File

@ -82,7 +82,7 @@ namespace Expansion {
"Empires of Kunark", "Empires of Kunark",
"Ring of Scale", "Ring of Scale",
"The Burning Lands", "The Burning Lands",
"Torment of Velious", "Torment of Velious"
}; };
} }
@ -194,7 +194,7 @@ public:
bool IsInPublicStaticInstance(uint32 instance_id); bool IsInPublicStaticInstance(uint32 instance_id);
// targeted rulesets // targeted rulesets
void LoadTargetedRulesets(Database* db); void LoadTargetedRulesets();
inline void SetZoneId(int zone_id) { m_zone_id = zone_id; } inline void SetZoneId(int zone_id) { m_zone_id = zone_id; }
inline void SetInstanceVersion(int instance_version) { m_instance_version = instance_version; } inline void SetInstanceVersion(int instance_version) { m_instance_version = instance_version; }

View File

@ -328,7 +328,7 @@ bool RuleManager::LoadRules(Database *db, const std::string &rule_set_name, bool
); );
if (m_post_load_callback) { if (m_post_load_callback) {
m_post_load_callback(db); m_post_load_callback();
} }
return true; return true;

View File

@ -157,7 +157,7 @@ public:
bool UpdateInjectedRules(Database* db, const std::string& rule_set_name, bool quiet_update = false); bool UpdateInjectedRules(Database* db, const std::string& rule_set_name, bool quiet_update = false);
bool UpdateOrphanedRules(Database* db, bool quiet_update = false); bool UpdateOrphanedRules(Database* db, bool quiet_update = false);
bool RestoreRuleNotes(Database* db); bool RestoreRuleNotes(Database* db);
void SetPostLoadCallback(std::function<void(Database*)> cb) { void SetPostLoadCallback(std::function<void()> cb) {
m_post_load_callback = std::move(cb); m_post_load_callback = std::move(cb);
} }
@ -174,7 +174,7 @@ private:
uint32 m_RuleBoolValues[BoolRuleCount]; uint32 m_RuleBoolValues[BoolRuleCount];
std::string m_RuleStringValues[StringRuleCount]; std::string m_RuleStringValues[StringRuleCount];
std::function<void(Database*)> m_post_load_callback; std::function<void()> m_post_load_callback;
typedef enum { typedef enum {
IntRule, IntRule,

View File

@ -414,8 +414,8 @@ int main(int argc, char **argv)
ZoneEventScheduler::Instance()->SetDatabase(&database)->LoadScheduledEvents(); ZoneEventScheduler::Instance()->SetDatabase(&database)->LoadScheduledEvents();
RuleManager::Instance()->SetPostLoadCallback( RuleManager::Instance()->SetPostLoadCallback(
[&](Database* db) { [&]() {
WorldContentService::Instance()->LoadTargetedRulesets(db); WorldContentService::Instance()->LoadTargetedRulesets();
} }
); );