diff --git a/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp b/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp index e06b431e2c..fec28962e6 100644 --- a/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp +++ b/SerialPrograms/Source/Controllers/ControllerDescriptor.cpp @@ -21,14 +21,17 @@ namespace PokemonAutomation{ // // Here we store a map of all controller types in the program. // -std::map> ALL_CONTROLLER_INTERFACES; +static std::map>& all_controller_interfaces(){ + static std::map> instance; + return instance; +} void InterfaceType::register_factory( ControllerInterface controller_interface, std::unique_ptr factory ){ - auto ret = ALL_CONTROLLER_INTERFACES.emplace(controller_interface, std::move(factory)); + auto ret = all_controller_interfaces().emplace(controller_interface, std::move(factory)); if (!ret.second){ throw InternalProgramError( nullptr, PA_CURRENT_FUNCTION, @@ -76,7 +79,7 @@ void ControllerOption::load_json(const JsonValue& json){ break; } - for (const auto& item : ALL_CONTROLLER_INTERFACES){ + for (const auto& item : all_controller_interfaces()){ const JsonValue* params = obj->get_value(CONTROLLER_INTERFACE_STRINGS.get_string(item.first)); if (params == nullptr){ continue;