diff --git a/CHANGELOG.md b/CHANGELOG.md index c9049134..47d496f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 4.0.32 +- Properly expose data for CreateUserDefinedSolarFormation() so objects spawned this way can be tracked by other plugins. + ## 4.0.31 - Fixed a case in Advanced Startup Solars where randomly placed solars could occupy the same position diff --git a/plugins/solar_control/SolarControl.cpp b/plugins/solar_control/SolarControl.cpp index 5def8306..357beb26 100644 --- a/plugins/solar_control/SolarControl.cpp +++ b/plugins/solar_control/SolarControl.cpp @@ -359,18 +359,36 @@ namespace Plugins::SolarControl /** @ingroup SolarControl * @brief Creates a premade group of solars defined in the solar json file */ - void CreateUserDefinedSolarFormation(const std::wstring& formation, const Vector& position, uint system) + std::vector CreateUserDefinedSolarFormation(const std::wstring& formation, const Vector& position, uint system) { - for (auto component : global->config->solarArchFormations[formation].components) + std::vector formationSpaceIds; + + auto group = global->config->solarArchFormations.find(formation); + + if (group == global->config->solarArchFormations.end()) + { + Console::ConErr(std::format("Unable to find {} while attempting to spawn user defined formation", wstos(formation))); + return {}; + } + + for (auto& component : group->second.components) { - CreateUserDefinedSolar(stows(component.solarArchName), + if (component.relativePosition.size() != 3 || component.rotation.size() != 3) + { + Console::ConErr(std::format("Invalid rotation or coordinate values provided for '{}', failed to create", component.solarArchName)); + return {}; + } + + auto solar = CreateUserDefinedSolar(stows(component.solarArchName), Vector { {position.x + component.relativePosition[0]}, {position.y + component.relativePosition[1]}, {position.z + component.relativePosition[2]}}, EulerMatrix(Vector {component.rotation[0], component.rotation[1], component.rotation[2]}), system, false, false); + formationSpaceIds.emplace_back(solar); } + return formationSpaceIds; } /** @ingroup SolarControl diff --git a/plugins/solar_control/SolarControl.h b/plugins/solar_control/SolarControl.h index 62a7674d..f5a154f1 100644 --- a/plugins/solar_control/SolarControl.h +++ b/plugins/solar_control/SolarControl.h @@ -64,7 +64,7 @@ namespace Plugins::SolarControl explicit SolarCommunicator(const std::string& plug); uint PluginCall(CreateSolar, const std::wstring& name, Vector position, const Matrix& rotation, SystemId system, bool varyPosition, bool mission); - void PluginCall(CreateSolarFormation, const std::wstring& formation, const Vector& position, uint system); + std::vector PluginCall(CreateSolarFormation, const std::wstring& formation, const Vector& position, uint system); }; //! Global data for this plugin