Added more functions to edit Coalition Areas

This commit is contained in:
Pax1601
2023-06-18 19:55:01 +02:00
parent ad3b1cb167
commit f9f02c3eb0
18 changed files with 3660 additions and 159 deletions

View File

@@ -145,37 +145,40 @@ private:
class SpawnGroundUnit : public Command
{
public:
SpawnGroundUnit(wstring coalition, wstring unitType, Coords location) :
SpawnGroundUnit(wstring coalition, wstring unitType, Coords location, bool immediate) :
coalition(coalition),
unitType(unitType),
location(location)
location(location),
immediate(immediate)
{
priority = CommandPriority::LOW;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 100; }
virtual int getLoad() { return 100 * !immediate; }
private:
const wstring coalition;
const wstring unitType;
const Coords location;
const bool immediate;
};
/* Spawn air unit command */
class SpawnAircraft : public Command
{
public:
SpawnAircraft(wstring coalition, wstring unitType, Coords location, wstring payloadName, wstring airbaseName) :
SpawnAircraft(wstring coalition, wstring unitType, Coords location, wstring payloadName, wstring airbaseName, bool immediate) :
coalition(coalition),
unitType(unitType),
location(location),
payloadName(payloadName),
airbaseName(airbaseName)
airbaseName(airbaseName),
immediate(immediate)
{
priority = CommandPriority::LOW;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 100; }
virtual int getLoad() { return 100 * !immediate; }
private:
const wstring coalition;
@@ -183,6 +186,7 @@ private:
const Coords location;
const wstring payloadName;
const wstring airbaseName;
const bool immediate;
};
/* Clone unit command */
@@ -232,7 +236,7 @@ public:
priority = CommandPriority::MEDIUM;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 10; }
virtual int getLoad() { return 2; }
private:
const wstring groupName;
@@ -249,7 +253,7 @@ public:
priority = CommandPriority::HIGH;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 10; }
virtual int getLoad() { return 2; }
private:
const wstring groupName;
@@ -266,7 +270,7 @@ public:
priority = CommandPriority::HIGH;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 10; }
virtual int getLoad() { return 2; }
private:
const wstring groupName;
@@ -297,7 +301,7 @@ public:
priority = CommandPriority::HIGH;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 10; }
virtual int getLoad() { return 2; }
private:
const wstring groupName;
@@ -318,7 +322,7 @@ public:
priority = CommandPriority::HIGH;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 10; }
virtual int getLoad() { return 2; }
private:
const wstring groupName;

View File

@@ -92,16 +92,18 @@ void Scheduler::handleRequest(wstring key, json::value value)
}
else if (key.compare(L"spawnGround") == 0)
{
bool immediate = value[L"immediate"].as_bool();
wstring coalition = value[L"coalition"].as_string();
wstring type = value[L"type"].as_string();
double lat = value[L"location"][L"lat"].as_double();
double lng = value[L"location"][L"lng"].as_double();
log(L"Spawning " + coalition + L" ground unit of type " + type + L" at (" + to_wstring(lat) + L", " + to_wstring(lng) + L")");
Coords loc; loc.lat = lat; loc.lng = lng;
command = dynamic_cast<Command*>(new SpawnGroundUnit(coalition, type, loc));
command = dynamic_cast<Command*>(new SpawnGroundUnit(coalition, type, loc, immediate));
}
else if (key.compare(L"spawnAir") == 0)
{
bool immediate = value[L"immediate"].as_bool();
wstring coalition = value[L"coalition"].as_string();
wstring type = value[L"type"].as_string();
double lat = value[L"location"][L"lat"].as_double();
@@ -111,7 +113,7 @@ void Scheduler::handleRequest(wstring key, json::value value)
wstring payloadName = value[L"payloadName"].as_string();
wstring airbaseName = value[L"airbaseName"].as_string();
log(L"Spawning " + coalition + L" air unit of type " + type + L" with payload " + payloadName + L" at (" + to_wstring(lat) + L", " + to_wstring(lng) + L" " + airbaseName + L")");
command = dynamic_cast<Command*>(new SpawnAircraft(coalition, type, loc, payloadName, airbaseName));
command = dynamic_cast<Command*>(new SpawnAircraft(coalition, type, loc, payloadName, airbaseName, immediate));
}
else if (key.compare(L"attackUnit") == 0)
{