From 2ab87f2d2241fb98fffc1a07be4edd84026bbe9c Mon Sep 17 00:00:00 2001 From: SkyHasACat Date: Mon, 4 Aug 2025 08:35:13 -0700 Subject: [PATCH] Use namespace for servicesoffered --- apps/openmw/mwlua/types/actor.hpp | 2 +- apps/openmw/mwlua/types/npc.cpp | 2 +- apps/openmw/mwlua/types/servicesoffered.hpp | 26 ++++++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwlua/types/actor.hpp b/apps/openmw/mwlua/types/actor.hpp index f55089c5a4..bd098d99d5 100644 --- a/apps/openmw/mwlua/types/actor.hpp +++ b/apps/openmw/mwlua/types/actor.hpp @@ -34,7 +34,7 @@ namespace MWLua services = MWBase::Environment::get().getESMStore()->get().find(rec.mClass)->mData.mServices; } - for (const auto& [flag, name] : ServiceNames) + for (const auto& [flag, name] : MWLua::ServiceNames) { providedServices[name] = (services & flag) != 0; } diff --git a/apps/openmw/mwlua/types/npc.cpp b/apps/openmw/mwlua/types/npc.cpp index 49acfb111b..489b01e140 100644 --- a/apps/openmw/mwlua/types/npc.cpp +++ b/apps/openmw/mwlua/types/npc.cpp @@ -115,7 +115,7 @@ namespace const sol::table services = rec["servicesOffered"]; int flags = 0; - for (const auto& [mask, key] : ServiceNames) + for (const auto& [mask, key] : MWLua::ServiceNames) { sol::object value = services[key]; if (value != sol::nil && value.as()) diff --git a/apps/openmw/mwlua/types/servicesoffered.hpp b/apps/openmw/mwlua/types/servicesoffered.hpp index bfc4f96fc9..4a87975a7d 100644 --- a/apps/openmw/mwlua/types/servicesoffered.hpp +++ b/apps/openmw/mwlua/types/servicesoffered.hpp @@ -1,12 +1,22 @@ +#ifndef MWLUA_SERVICESOFFERED_HPP +#define MWLUA_SERVICESOFFERED_HPP + #include #include #include -inline constexpr std::array, 19> ServiceNames - = { { { ESM::NPC::Spells, "Spells" }, { ESM::NPC::Spellmaking, "Spellmaking" }, - { ESM::NPC::Enchanting, "Enchanting" }, { ESM::NPC::Training, "Training" }, { ESM::NPC::Repair, "Repair" }, - { ESM::NPC::AllItems, "Barter" }, { ESM::NPC::Weapon, "Weapon" }, { ESM::NPC::Armor, "Armor" }, - { ESM::NPC::Clothing, "Clothing" }, { ESM::NPC::Books, "Books" }, { ESM::NPC::Ingredients, "Ingredients" }, - { ESM::NPC::Picks, "Picks" }, { ESM::NPC::Probes, "Probes" }, { ESM::NPC::Lights, "Lights" }, - { ESM::NPC::Apparatus, "Apparatus" }, { ESM::NPC::RepairItem, "RepairItem" }, { ESM::NPC::Misc, "Misc" }, - { ESM::NPC::Potions, "Potions" }, { ESM::NPC::MagicItems, "MagicItems" } } }; +namespace MWLua +{ + + inline constexpr std::array, 19> ServiceNames + = { { { ESM::NPC::Spells, "Spells" }, { ESM::NPC::Spellmaking, "Spellmaking" }, + { ESM::NPC::Enchanting, "Enchanting" }, { ESM::NPC::Training, "Training" }, { ESM::NPC::Repair, "Repair" }, + { ESM::NPC::AllItems, "Barter" }, { ESM::NPC::Weapon, "Weapon" }, { ESM::NPC::Armor, "Armor" }, + { ESM::NPC::Clothing, "Clothing" }, { ESM::NPC::Books, "Books" }, { ESM::NPC::Ingredients, "Ingredients" }, + { ESM::NPC::Picks, "Picks" }, { ESM::NPC::Probes, "Probes" }, { ESM::NPC::Lights, "Lights" }, + { ESM::NPC::Apparatus, "Apparatus" }, { ESM::NPC::RepairItem, "RepairItem" }, { ESM::NPC::Misc, "Misc" }, + { ESM::NPC::Potions, "Potions" }, { ESM::NPC::MagicItems, "MagicItems" } } }; +} + + +#endif \ No newline at end of file