Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Irateredkite/solar ipc interface fixes #425

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
24 changes: 21 additions & 3 deletions plugins/solar_control/SolarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint> CreateUserDefinedSolarFormation(const std::wstring& formation, const Vector& position, uint system)
{
for (auto component : global->config->solarArchFormations[formation].components)
std::vector<uint> 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
Expand Down
2 changes: 1 addition & 1 deletion plugins/solar_control/SolarControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint> PluginCall(CreateSolarFormation, const std::wstring& formation, const Vector& position, uint system);
};

//! Global data for this plugin
Expand Down
Loading