Loadouts changes and spawn menu update

This commit is contained in:
Pax1601
2023-08-24 16:16:59 +02:00
parent b1e4dd62b0
commit eb80c39b98
298 changed files with 67845 additions and 6766 deletions

View File

@@ -3,6 +3,7 @@
#include "luatools.h"
#include "utils.h"
#include "logger.h"
#include "datatypes.h"
namespace CommandPriority {
enum CommandPriorities { LOW, MEDIUM, HIGH, IMMEDIATE };
@@ -154,11 +155,9 @@ private:
class SpawnGroundUnits : public Command
{
public:
SpawnGroundUnits(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> liveryIDs, bool immediate) :
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, bool immediate) :
coalition(coalition),
unitTypes(unitTypes),
locations(locations),
liveryIDs(liveryIDs),
spawnOptions(spawnOptions),
immediate(immediate)
{
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
@@ -168,9 +167,7 @@ public:
private:
const string coalition;
const vector<string> unitTypes;
const vector<Coords> locations;
const vector<string> liveryIDs;
const vector<SpawnOptions> spawnOptions;
const bool immediate;
};
@@ -178,11 +175,9 @@ private:
class SpawnNavyUnits : public Command
{
public:
SpawnNavyUnits(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> liveryIDs, bool immediate) :
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, bool immediate) :
coalition(coalition),
unitTypes(unitTypes),
locations(locations),
liveryIDs(liveryIDs),
spawnOptions(spawnOptions),
immediate(immediate)
{
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
@@ -192,9 +187,7 @@ public:
private:
const string coalition;
const vector<string> unitTypes;
const vector<Coords> locations;
const vector<string> liveryIDs;
const vector<SpawnOptions> spawnOptions;
const bool immediate;
};
@@ -202,12 +195,9 @@ private:
class SpawnAircrafts : public Command
{
public:
SpawnAircrafts(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> loadouts, vector<string> liveryIDs, string airbaseName, bool immediate) :
SpawnAircrafts(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, bool immediate) :
coalition(coalition),
unitTypes(unitTypes),
locations(locations),
loadouts(loadouts),
liveryIDs(liveryIDs),
spawnOptions(spawnOptions),
airbaseName(airbaseName),
immediate(immediate)
{
@@ -218,10 +208,7 @@ public:
private:
const string coalition;
const vector<string> unitTypes;
const vector<Coords> locations;
const vector<string> loadouts;
const vector<string> liveryIDs;
const vector<SpawnOptions> spawnOptions;
const string airbaseName;
const bool immediate;
};
@@ -231,12 +218,9 @@ private:
class SpawnHelicopters : public Command
{
public:
SpawnHelicopters(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> loadouts, vector<string> liveryIDs, string airbaseName, bool immediate) :
SpawnHelicopters(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, bool immediate) :
coalition(coalition),
unitTypes(unitTypes),
locations(locations),
loadouts(loadouts),
liveryIDs(liveryIDs),
spawnOptions(spawnOptions),
airbaseName(airbaseName),
immediate(immediate)
{
@@ -247,10 +231,7 @@ public:
private:
const string coalition;
const vector<string> unitTypes;
const vector<Coords> locations;
const vector<string> loadouts;
const vector<string> liveryIDs;
const vector<SpawnOptions> spawnOptions;
const string airbaseName;
const bool immediate;
};

View File

@@ -1,6 +1,6 @@
#pragma once
#include "framework.h"
#include "utils.h"
namespace DataIndex {
enum DataIndexes {
@@ -114,3 +114,10 @@ bool operator==(const DataTypes::Radio& lhs, const DataTypes::Radio& rhs);
bool operator==(const DataTypes::GeneralSettings& lhs, const DataTypes::GeneralSettings& rhs);
bool operator==(const DataTypes::Ammo& lhs, const DataTypes::Ammo& rhs);
bool operator==(const DataTypes::Contact& lhs, const DataTypes::Contact& rhs);
struct SpawnOptions {
string unitType;
Coords location;
string loadout;
string liveryID;
};

View File

@@ -40,16 +40,14 @@ string Smoke::getString()
/* Spawn ground units command */
string SpawnGroundUnits::getString()
{
if (unitTypes.size() != locations.size()) return "";
std::ostringstream unitsSS;
unitsSS.precision(10);
for (int i = 0; i < unitTypes.size(); i++) {
for (int i = 0; i < spawnOptions.size(); i++) {
unitsSS << "[" << i + 1 << "] = {"
<< "unitType = " << "\"" << unitTypes[i] << "\"" << ", "
<< "lat = " << locations[i].lat << ", "
<< "lng = " << locations[i].lng << ", "
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
<< "lat = " << spawnOptions[i].location.lat << ", "
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
}
std::ostringstream commandSS;
@@ -65,16 +63,14 @@ string SpawnGroundUnits::getString()
/* Spawn ground units command */
string SpawnNavyUnits::getString()
{
if (unitTypes.size() != locations.size()) return "";
std::ostringstream unitsSS;
unitsSS.precision(10);
for (int i = 0; i < unitTypes.size(); i++) {
for (int i = 0; i < spawnOptions.size(); i++) {
unitsSS << "[" << i + 1 << "] = {"
<< "unitType = " << "\"" << unitTypes[i] << "\"" << ", "
<< "lat = " << locations[i].lat << ", "
<< "lng = " << locations[i].lng << ", "
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
<< "lat = " << spawnOptions[i].location.lat << ", "
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
}
std::ostringstream commandSS;
@@ -89,18 +85,16 @@ string SpawnNavyUnits::getString()
/* Spawn aircrafts command */
string SpawnAircrafts::getString()
{
if (unitTypes.size() != locations.size() || unitTypes.size() != loadouts.size()) return "";
std::ostringstream unitsSS;
unitsSS.precision(10);
for (int i = 0; i < unitTypes.size(); i++) {
for (int i = 0; i < spawnOptions.size(); i++) {
unitsSS << "[" << i + 1 << "] = {"
<< "unitType = " << "\"" << unitTypes[i] << "\"" << ", "
<< "lat = " << locations[i].lat << ", "
<< "lng = " << locations[i].lng << ", "
<< "alt = " << locations[i].alt << ", "
<< "loadout = \"" << loadouts[i] << "\"" << ", "
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
<< "lat = " << spawnOptions[i].location.lat << ", "
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "alt = " << spawnOptions[i].location.alt << ", "
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
}
std::ostringstream commandSS;
@@ -117,18 +111,16 @@ string SpawnAircrafts::getString()
/* Spawn helicopters command */
string SpawnHelicopters::getString()
{
if (unitTypes.size() != locations.size() || unitTypes.size() != loadouts.size()) return "";
std::ostringstream unitsSS;
unitsSS.precision(10);
for (int i = 0; i < unitTypes.size(); i++) {
for (int i = 0; i < spawnOptions.size(); i++) {
unitsSS << "[" << i + 1 << "] = {"
<< "unitType = " << "\"" << unitTypes[i] << "\"" << ", "
<< "lat = " << locations[i].lat << ", "
<< "lng = " << locations[i].lng << ", "
<< "alt = " << locations[i].alt << ", "
<< "loadout = \"" << loadouts[i] << "\"" << ", "
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
<< "lat = " << spawnOptions[i].location.lat << ", "
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "alt = " << spawnOptions[i].location.alt << ", "
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
}
std::ostringstream commandSS;
@@ -141,7 +133,6 @@ string SpawnHelicopters::getString()
return commandSS.str();
}
/* Clone unit command */
string Clone::getString()
{

View File

@@ -183,10 +183,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
if (!checkSpawnPoints(spawnPoints, coalition)) return;
vector<string> unitTypes;
vector<Coords> locations;
vector<string> loadouts;
vector<string> liveryIDs;
vector<SpawnOptions> spawnOptions;
for (auto unit : value[L"units"].as_array()) {
string unitType = to_string(unit[L"unitType"]);
double lat = unit[L"location"][L"lat"].as_double();
@@ -196,14 +193,11 @@ void Scheduler::handleRequest(string key, json::value value, string username)
string loadout = to_string(unit[L"loadout"]);
string liveryID = to_string(unit[L"liveryID"]);
unitTypes.push_back(unitType);
locations.push_back(location);
loadouts.push_back(loadout);
liveryIDs.push_back(liveryID);
spawnOptions.push_back({unitType, location, loadout, liveryID});
log(username + " spawned a " + coalition + " " + unitType, true);
}
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, unitTypes, locations, loadouts, liveryIDs, airbaseName, immediate));
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, spawnOptions, airbaseName, immediate));
}
else if (key.compare("spawnHelicopters") == 0)
{
@@ -214,10 +208,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
if (!checkSpawnPoints(spawnPoints, coalition)) return;
vector<string> unitTypes;
vector<Coords> locations;
vector<string> loadouts;
vector<string> liveryIDs;
vector<SpawnOptions> spawnOptions;
for (auto unit : value[L"units"].as_array()) {
string unitType = to_string(unit[L"unitType"]);
double lat = unit[L"location"][L"lat"].as_double();
@@ -227,14 +218,11 @@ void Scheduler::handleRequest(string key, json::value value, string username)
string loadout = to_string(unit[L"loadout"]);
string liveryID = to_string(unit[L"liveryID"]);
unitTypes.push_back(unitType);
locations.push_back(location);
loadouts.push_back(loadout);
liveryIDs.push_back(liveryID);
spawnOptions.push_back({ unitType, location, loadout, liveryID });
log(username + " spawned a " + coalition + " " + unitType, true);
}
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, unitTypes, locations, loadouts, liveryIDs, airbaseName, immediate));
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, spawnOptions, airbaseName, immediate));
}
else if (key.compare("spawnGroundUnits") == 0)
{
@@ -244,9 +232,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
if (!checkSpawnPoints(spawnPoints, coalition)) return;
vector<string> unitTypes;
vector<Coords> locations;
vector<string> liveryIDs;
vector<SpawnOptions> spawnOptions;
for (auto unit : value[L"units"].as_array()) {
string unitType = to_string(unit[L"unitType"]);
double lat = unit[L"location"][L"lat"].as_double();
@@ -254,13 +240,11 @@ void Scheduler::handleRequest(string key, json::value value, string username)
Coords location; location.lat = lat; location.lng = lng;
string liveryID = to_string(unit[L"liveryID"]);
unitTypes.push_back(unitType);
locations.push_back(location);
liveryIDs.push_back(liveryID);
spawnOptions.push_back({ unitType, location, "", liveryID});
log(username + " spawned a " + coalition + " " + unitType, true);
}
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, unitTypes, locations, liveryIDs, immediate));
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, immediate));
}
else if (key.compare("spawnNavyUnits") == 0)
{
@@ -270,9 +254,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
if (!checkSpawnPoints(spawnPoints, coalition)) return;
vector<string> unitTypes;
vector<Coords> locations;
vector<string> liveryIDs;
vector<SpawnOptions> spawnOptions;
for (auto unit : value[L"units"].as_array()) {
string unitType = to_string(unit[L"unitType"]);
double lat = unit[L"location"][L"lat"].as_double();
@@ -280,13 +262,11 @@ void Scheduler::handleRequest(string key, json::value value, string username)
Coords location; location.lat = lat; location.lng = lng;
string liveryID = to_string(unit[L"liveryID"]);
unitTypes.push_back(unitType);
locations.push_back(location);
liveryIDs.push_back(liveryID);
spawnOptions.push_back({ unitType, location, "", liveryID });
log(username + " spawned a " + coalition + " " + unitType, true);
}
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, unitTypes, locations, liveryIDs, immediate));
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, immediate));
}
else if (key.compare("attackUnit") == 0)
{