Map by service name

macos_ci_fix
Zackhasacat 1 year ago
parent 44303ed8ca
commit 9c4ffa8256

@ -17,9 +17,9 @@ namespace MWLua
template <class T> template <class T>
void addActorServicesBindings(sol::usertype<T>& record, const Context& context) void addActorServicesBindings(sol::usertype<T>& record, const Context& context)
{ {
record["servicesOffered"] = sol::readonly_property([](const T& rec) -> std::vector<std::string> { record["servicesOffered"] = sol::readonly_property([](const T& rec) -> std::map<std::string, bool> {
std::vector<std::string> providedServices; std::map<std::string, bool> providedServices;
std::map<int, std::string> serviceNames = { { ESM::NPC::Spells, "Spells" }, const static std::map<int, std::string> serviceNames = { { ESM::NPC::Spells, "Spells" },
{ ESM::NPC::Spellmaking, "Spellmaking" }, { ESM::NPC::Enchanting, "Enchanting" }, { ESM::NPC::Spellmaking, "Spellmaking" }, { ESM::NPC::Enchanting, "Enchanting" },
{ ESM::NPC::Training, "Training" }, { ESM::NPC::Repair, "Repair" }, { ESM::NPC::AllItems, "Barter" }, { 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::Weapon, "Weapon" }, { ESM::NPC::Armor, "Armor" }, { ESM::NPC::Clothing, "Clothing" },
@ -41,12 +41,9 @@ namespace MWLua
} }
for (const auto& [flag, name] : serviceNames) for (const auto& [flag, name] : serviceNames)
{ {
if (services & flag) providedServices[name] = (services & flag) != 0;
providedServices.push_back(name);
} }
providedServices["Travel"] = !rec.getTransport().empty();
if (!rec.getTransport().empty())
providedServices.push_back("Travel");
return providedServices; return providedServices;
}); });
} }

Loading…
Cancel
Save