Added ability to delete original cloned units

Mostly useful to group units together
This commit is contained in:
Pax1601
2023-09-07 13:02:14 +02:00
parent e2f80c5788
commit 09bf361d44
6 changed files with 128 additions and 77 deletions

View File

@@ -250,8 +250,9 @@ private:
class Clone : public Command
{
public:
Clone(vector<CloneOptions> cloneOptions) :
cloneOptions(cloneOptions)
Clone(vector<CloneOptions> cloneOptions, bool deleteOriginal) :
cloneOptions(cloneOptions),
deleteOriginal(deleteOriginal)
{
priority = CommandPriority::LOW;
};
@@ -260,6 +261,7 @@ public:
private:
const vector<CloneOptions> cloneOptions;
const bool deleteOriginal;
};
/* Delete unit command */

View File

@@ -152,7 +152,8 @@ string Clone::getString()
std::ostringstream commandSS;
commandSS.precision(10);
commandSS << "Olympus.clone, "
<< "{" << unitsSS.str() << "}";
<< "{" << unitsSS.str() << "}" << ", "
<< (deleteOriginal ? "true" : "false");
return commandSS.str();
}

View File

@@ -380,6 +380,7 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
else if (key.compare("cloneUnits") == 0)
{
vector<CloneOptions> cloneOptions;
bool deleteOriginal = value[L"deleteOriginal"].as_bool();
for (auto unit : value[L"units"].as_array()) {
unsigned int ID = unit[L"ID"].as_integer();
@@ -390,7 +391,7 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
cloneOptions.push_back({ ID, location });
}
command = dynamic_cast<Command*>(new Clone(cloneOptions));
command = dynamic_cast<Command*>(new Clone(cloneOptions, deleteOriginal));
}
else if (key.compare("setROE") == 0)
{