mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Transition to json to binary data transfers
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
class Aircraft : public AirUnit
|
||||
{
|
||||
public:
|
||||
Aircraft(json::value json, int ID);
|
||||
Aircraft(json::value json, unsigned int ID);
|
||||
|
||||
virtual wstring getCategory() { return L"Aircraft"; };
|
||||
virtual string getCategory() { return "Aircraft"; };
|
||||
|
||||
virtual void changeSpeed(wstring change);
|
||||
virtual void changeAltitude(wstring change);
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void changeAltitude(string change);
|
||||
};
|
||||
@@ -5,18 +5,18 @@
|
||||
#include "luatools.h"
|
||||
#include "Unit.h"
|
||||
|
||||
#define AIR_DEST_DIST_THR 2000
|
||||
#define AIR_DEST_DIST_THR 2000 // Meters
|
||||
|
||||
class AirUnit : public Unit
|
||||
{
|
||||
public:
|
||||
AirUnit(json::value json, int ID);
|
||||
AirUnit(json::value json, unsigned int ID);
|
||||
|
||||
virtual void setState(int newState);
|
||||
virtual void setState(unsigned char newState);
|
||||
|
||||
virtual wstring getCategory() = 0;
|
||||
virtual void changeSpeed(wstring change) = 0;
|
||||
virtual void changeAltitude(wstring change) = 0;
|
||||
virtual string getCategory() = 0;
|
||||
virtual void changeSpeed(string change) = 0;
|
||||
virtual void changeAltitude(string change) = 0;
|
||||
|
||||
protected:
|
||||
virtual void AIloop();
|
||||
|
||||
@@ -54,6 +54,15 @@ namespace ReactionToThreat {
|
||||
};
|
||||
}
|
||||
|
||||
namespace EmissionCountermeasure {
|
||||
enum ReactionsToThreat {
|
||||
SILENT = 0,
|
||||
ATTACK = 1,
|
||||
DEFEND = 2,
|
||||
FREE = 3
|
||||
};
|
||||
}
|
||||
|
||||
namespace RadarUse {
|
||||
enum RadarUses {
|
||||
NEVER = 0,
|
||||
@@ -85,19 +94,19 @@ namespace ECMUse {
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
int getPriority() { return priority; }
|
||||
virtual wstring getString(lua_State* L) = 0;
|
||||
virtual int getLoad() = 0;
|
||||
unsigned int getPriority() { return priority; }
|
||||
virtual string getString(lua_State* L) = 0;
|
||||
virtual unsigned int getLoad() = 0;
|
||||
|
||||
protected:
|
||||
int priority = CommandPriority::LOW;
|
||||
unsigned int priority = CommandPriority::LOW;
|
||||
};
|
||||
|
||||
/* Simple low priority move command (from user click) */
|
||||
class Move : public Command
|
||||
{
|
||||
public:
|
||||
Move(wstring groupName, Coords destination, double speed, wstring speedType, double altitude, wstring altitudeType, wstring taskOptions, wstring category):
|
||||
Move(string groupName, Coords destination, double speed, string speedType, double altitude, string altitudeType, string taskOptions, string category):
|
||||
groupName(groupName),
|
||||
destination(destination),
|
||||
speed(speed),
|
||||
@@ -109,35 +118,35 @@ public:
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 5; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const wstring groupName;
|
||||
const string groupName;
|
||||
const Coords destination;
|
||||
const double speed;
|
||||
const wstring speedType;
|
||||
const string speedType;
|
||||
const double altitude;
|
||||
const wstring altitudeType;
|
||||
const wstring taskOptions;
|
||||
const wstring category;
|
||||
const string altitudeType;
|
||||
const string taskOptions;
|
||||
const string category;
|
||||
};
|
||||
|
||||
/* Smoke command */
|
||||
class Smoke : public Command
|
||||
{
|
||||
public:
|
||||
Smoke(wstring color, Coords location) :
|
||||
Smoke(string color, Coords location) :
|
||||
color(color),
|
||||
location(location)
|
||||
{
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 5; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const wstring color;
|
||||
const string color;
|
||||
const Coords location;
|
||||
};
|
||||
|
||||
@@ -145,7 +154,7 @@ private:
|
||||
class SpawnGroundUnit : public Command
|
||||
{
|
||||
public:
|
||||
SpawnGroundUnit(wstring coalition, wstring unitType, Coords location, bool immediate) :
|
||||
SpawnGroundUnit(string coalition, string unitType, Coords location, bool immediate) :
|
||||
coalition(coalition),
|
||||
unitType(unitType),
|
||||
location(location),
|
||||
@@ -153,12 +162,12 @@ public:
|
||||
{
|
||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 100 * !immediate; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 100 * !immediate; }
|
||||
|
||||
private:
|
||||
const wstring coalition;
|
||||
const wstring unitType;
|
||||
const string coalition;
|
||||
const string unitType;
|
||||
const Coords location;
|
||||
const bool immediate;
|
||||
};
|
||||
@@ -167,7 +176,7 @@ private:
|
||||
class SpawnAircraft : public Command
|
||||
{
|
||||
public:
|
||||
SpawnAircraft(wstring coalition, wstring unitType, Coords location, wstring payloadName, wstring airbaseName, bool immediate) :
|
||||
SpawnAircraft(string coalition, string unitType, Coords location, string payloadName, string airbaseName, bool immediate) :
|
||||
coalition(coalition),
|
||||
unitType(unitType),
|
||||
location(location),
|
||||
@@ -177,15 +186,15 @@ public:
|
||||
{
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 100 * !immediate; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 100 * !immediate; }
|
||||
|
||||
private:
|
||||
const wstring coalition;
|
||||
const wstring unitType;
|
||||
const string coalition;
|
||||
const string unitType;
|
||||
const Coords location;
|
||||
const wstring payloadName;
|
||||
const wstring airbaseName;
|
||||
const string payloadName;
|
||||
const string airbaseName;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
@@ -193,17 +202,17 @@ private:
|
||||
class Clone : public Command
|
||||
{
|
||||
public:
|
||||
Clone(int ID, Coords location) :
|
||||
Clone(unsigned int ID, Coords location) :
|
||||
ID(ID),
|
||||
location(location)
|
||||
{
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 100; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 100; }
|
||||
|
||||
private:
|
||||
const int ID;
|
||||
const unsigned int ID;
|
||||
const Coords location;
|
||||
};
|
||||
|
||||
@@ -211,17 +220,17 @@ private:
|
||||
class Delete : public Command
|
||||
{
|
||||
public:
|
||||
Delete(int ID, bool explosion) :
|
||||
Delete(unsigned int ID, bool explosion) :
|
||||
ID(ID),
|
||||
explosion(explosion)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 20; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 20; }
|
||||
|
||||
private:
|
||||
const int ID;
|
||||
const unsigned int ID;
|
||||
const bool explosion;
|
||||
};
|
||||
|
||||
@@ -229,59 +238,59 @@ private:
|
||||
class SetTask : public Command
|
||||
{
|
||||
public:
|
||||
SetTask(wstring groupName, wstring task) :
|
||||
SetTask(string groupName, string task) :
|
||||
groupName(groupName),
|
||||
task(task)
|
||||
{
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 2; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const wstring groupName;
|
||||
const wstring task;
|
||||
const string groupName;
|
||||
const string task;
|
||||
};
|
||||
|
||||
/* Reset task command */
|
||||
class ResetTask : public Command
|
||||
{
|
||||
public:
|
||||
ResetTask(wstring groupName) :
|
||||
ResetTask(string groupName) :
|
||||
groupName(groupName)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 2; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const wstring groupName;
|
||||
const string groupName;
|
||||
};
|
||||
|
||||
/* Set command */
|
||||
class SetCommand : public Command
|
||||
{
|
||||
public:
|
||||
SetCommand(wstring groupName, wstring command) :
|
||||
SetCommand(string groupName, string command) :
|
||||
groupName(groupName),
|
||||
command(command)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 2; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const wstring groupName;
|
||||
const wstring command;
|
||||
const string groupName;
|
||||
const string command;
|
||||
};
|
||||
|
||||
/* Set option command */
|
||||
class SetOption : public Command
|
||||
{
|
||||
public:
|
||||
SetOption(wstring groupName, int optionID, int optionValue) :
|
||||
SetOption(string groupName, unsigned int optionID, unsigned int optionValue) :
|
||||
groupName(groupName),
|
||||
optionID(optionID),
|
||||
optionValue(optionValue),
|
||||
@@ -291,7 +300,7 @@ public:
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
|
||||
SetOption(wstring groupName, int optionID, bool optionBool) :
|
||||
SetOption(string groupName, unsigned int optionID, bool optionBool) :
|
||||
groupName(groupName),
|
||||
optionID(optionID),
|
||||
optionValue(0),
|
||||
@@ -300,13 +309,13 @@ public:
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 2; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const wstring groupName;
|
||||
const int optionID;
|
||||
const int optionValue;
|
||||
const string groupName;
|
||||
const unsigned int optionID;
|
||||
const unsigned int optionValue;
|
||||
const bool optionBool;
|
||||
const bool isBoolean;
|
||||
};
|
||||
@@ -315,17 +324,17 @@ private:
|
||||
class SetOnOff : public Command
|
||||
{
|
||||
public:
|
||||
SetOnOff(wstring groupName, bool onOff) :
|
||||
SetOnOff(string groupName, bool onOff) :
|
||||
groupName(groupName),
|
||||
onOff(onOff)
|
||||
{
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 2; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const wstring groupName;
|
||||
const string groupName;
|
||||
const bool onOff;
|
||||
};
|
||||
|
||||
@@ -333,16 +342,16 @@ private:
|
||||
class Explosion : public Command
|
||||
{
|
||||
public:
|
||||
Explosion(int intensity, Coords location) :
|
||||
Explosion(unsigned int intensity, Coords location) :
|
||||
location(location),
|
||||
intensity(intensity)
|
||||
{
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual wstring getString(lua_State* L);
|
||||
virtual int getLoad() { return 10; }
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 10; }
|
||||
|
||||
private:
|
||||
const Coords location;
|
||||
const int intensity;
|
||||
const unsigned int intensity;
|
||||
};
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
class GroundUnit : public Unit
|
||||
{
|
||||
public:
|
||||
GroundUnit(json::value json, int ID);
|
||||
virtual wstring getCategory() { return L"GroundUnit"; };
|
||||
GroundUnit(json::value json, unsigned int ID);
|
||||
virtual string getCategory() { return "GroundUnit"; };
|
||||
|
||||
virtual void setState(int newState);
|
||||
virtual void setState(unsigned char newState);
|
||||
|
||||
virtual void changeSpeed(wstring change);
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void setOnOff(bool newOnOff);
|
||||
virtual void setFollowRoads(bool newFollowRoads);
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
class Helicopter : public AirUnit
|
||||
{
|
||||
public:
|
||||
Helicopter(json::value json, int ID);
|
||||
Helicopter(json::value json, unsigned int ID);
|
||||
|
||||
virtual wstring getCategory() { return L"Helicopter"; };
|
||||
virtual string getCategory() { return "Helicopter"; };
|
||||
|
||||
virtual void changeSpeed(wstring change);
|
||||
virtual void changeAltitude(wstring change);
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void changeAltitude(string change);
|
||||
};
|
||||
@@ -4,10 +4,10 @@
|
||||
class NavyUnit : public Unit
|
||||
{
|
||||
public:
|
||||
NavyUnit(json::value json, int ID);
|
||||
NavyUnit(json::value json, unsigned int ID);
|
||||
virtual void AIloop();
|
||||
|
||||
virtual wstring getCategory() { return L"NavyUnit"; };
|
||||
virtual void changeSpeed(wstring change);
|
||||
virtual string getCategory() { return "NavyUnit"; };
|
||||
virtual void changeSpeed(string change);
|
||||
|
||||
};
|
||||
@@ -11,10 +11,10 @@ public:
|
||||
|
||||
void appendCommand(Command* command);
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(wstring key, json::value value);
|
||||
void handleRequest(string key, json::value value);
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
int load;
|
||||
unsigned int load;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ public:
|
||||
|
||||
void start(lua_State* L);
|
||||
void stop(lua_State* L);
|
||||
json::value& getUpdateJson() { return updateJson; }
|
||||
json::value& getRefreshJson() { return refreshJson; }
|
||||
|
||||
private:
|
||||
std::thread* serverThread;
|
||||
@@ -29,9 +27,7 @@ private:
|
||||
void task();
|
||||
|
||||
atomic<bool> runListener;
|
||||
json::value updateJson;
|
||||
json::value refreshJson;
|
||||
|
||||
wstring password = L"";
|
||||
string password = "";
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "luatools.h"
|
||||
#include "measure.h"
|
||||
#include "logger.h"
|
||||
#include "commands.h"
|
||||
|
||||
#define TASK_CHECK_INIT_VALUE 10
|
||||
|
||||
@@ -32,16 +33,16 @@ namespace Options {
|
||||
struct TACAN
|
||||
{
|
||||
bool isOn = false;
|
||||
int channel = 40;
|
||||
wstring XY = L"X";
|
||||
wstring callsign = L"TKR";
|
||||
unsigned char channel = 40;
|
||||
char XY = 'X';
|
||||
char callsign[4];
|
||||
};
|
||||
|
||||
struct Radio
|
||||
{
|
||||
int frequency = 124000000; // MHz
|
||||
int callsign = 1;
|
||||
int callsignNumber = 1;
|
||||
unsigned int frequency = 124000000; // MHz
|
||||
unsigned char callsign = 1;
|
||||
unsigned char callsignNumber = 1;
|
||||
};
|
||||
|
||||
struct GeneralSettings
|
||||
@@ -54,116 +55,145 @@ namespace Options {
|
||||
};
|
||||
}
|
||||
|
||||
namespace DataTypes {
|
||||
struct Ammo {
|
||||
unsigned short quantity = 0;
|
||||
string name;
|
||||
unsigned char guidance = 0;
|
||||
unsigned char category = 0;
|
||||
unsigned char missileCategory = 0;
|
||||
};
|
||||
|
||||
struct Contact {
|
||||
unsigned int ID = 0;
|
||||
unsigned char detectionMethod = 0;
|
||||
};
|
||||
|
||||
struct DataPacket {
|
||||
unsigned int ID;
|
||||
unsigned int bitmask;
|
||||
Coords position;
|
||||
double speed;
|
||||
double heading;
|
||||
unsigned short fuel;
|
||||
double desiredSpeed;
|
||||
double desiredAltitude;
|
||||
unsigned int targetID;
|
||||
Coords targetPosition;
|
||||
unsigned char state;
|
||||
unsigned char ROE;
|
||||
unsigned char reactionToThreat;
|
||||
unsigned char emissionsCountermeasures;
|
||||
Options::TACAN TACAN;
|
||||
Options::Radio Radio;
|
||||
};
|
||||
}
|
||||
|
||||
class Unit
|
||||
{
|
||||
public:
|
||||
Unit(json::value json, int ID);
|
||||
Unit(json::value json, unsigned int ID);
|
||||
~Unit();
|
||||
|
||||
/********** Public methods **********/
|
||||
void initialize(json::value json);
|
||||
void setDefaults(bool force = false);
|
||||
int getID() { return ID; }
|
||||
unsigned int getID() { return ID; }
|
||||
void runAILoop();
|
||||
void updateExportData(json::value json, double dt = 0);
|
||||
void updateMissionData(json::value json);
|
||||
json::value getData(long long time, bool getAll = false);
|
||||
virtual wstring getCategory() { return L"No category"; };
|
||||
DataTypes::DataPacket getDataPacket();
|
||||
string getData(bool refresh);
|
||||
virtual string getCategory() { return "No category"; };
|
||||
|
||||
/********** Base data **********/
|
||||
void setControlled(bool newControlled) { controlled = newControlled; addMeasure(L"controlled", json::value(newControlled)); }
|
||||
void setName(wstring newName) { name = newName; addMeasure(L"name", json::value(newName));}
|
||||
void setUnitName(wstring newUnitName) { unitName = newUnitName; addMeasure(L"unitName", json::value(newUnitName));}
|
||||
void setGroupName(wstring newGroupName) { groupName = newGroupName; addMeasure(L"groupName", json::value(newGroupName));}
|
||||
void setAlive(bool newAlive) { alive = newAlive; addMeasure(L"alive", json::value(newAlive));}
|
||||
void setType(json::value newType) { type = newType; addMeasure(L"type", newType);}
|
||||
void setCountry(int newCountry) { country = newCountry; addMeasure(L"country", json::value(newCountry));}
|
||||
void setControlled(bool newControlled) { controlled = newControlled; }
|
||||
void setName(string newName) { name = newName; }
|
||||
void setUnitName(string newUnitName) { unitName = newUnitName; }
|
||||
void setGroupName(string newGroupName) { groupName = newGroupName; }
|
||||
void setAlive(bool newAlive) { alive = newAlive; }
|
||||
void setCountry(unsigned int newCountry) { country = newCountry; }
|
||||
void setHuman(bool newHuman) { human = newHuman; }
|
||||
|
||||
bool getControlled() { return controlled; }
|
||||
wstring getName() { return name; }
|
||||
wstring getUnitName() { return unitName; }
|
||||
wstring getGroupName() { return groupName; }
|
||||
string getName() { return name; }
|
||||
string getUnitName() { return unitName; }
|
||||
string getGroupName() { return groupName; }
|
||||
bool getAlive() { return alive; }
|
||||
json::value getType() { return type; }
|
||||
int getCountry() { return country; }
|
||||
unsigned int getCountry() { return country; }
|
||||
bool getHuman() { return human; }
|
||||
|
||||
/********** Flight data **********/
|
||||
void setLatitude(double newLatitude) {latitude = newLatitude; addMeasure(L"latitude", json::value(newLatitude));}
|
||||
void setLongitude(double newLongitude) {longitude = newLongitude; addMeasure(L"longitude", json::value(newLongitude));}
|
||||
void setAltitude(double newAltitude) {altitude = newAltitude; addMeasure(L"altitude", json::value(newAltitude));}
|
||||
void setHeading(double newHeading) {heading = newHeading; addMeasure(L"heading", json::value(newHeading));}
|
||||
void setSpeed(double newSpeed) {speed = newSpeed; addMeasure(L"speed", json::value(newSpeed));}
|
||||
void setPosition(Coords newPosition) { position = newPosition; }
|
||||
void setHeading(double newHeading) {heading = newHeading; }
|
||||
void setSpeed(double newSpeed) {speed = newSpeed; }
|
||||
|
||||
double getLatitude() { return latitude; }
|
||||
double getLongitude() { return longitude; }
|
||||
double getAltitude() { return altitude; }
|
||||
Coords getPosition() { return position; }
|
||||
double getHeading() { return heading; }
|
||||
double getSpeed() { return speed; }
|
||||
|
||||
/********** Mission data **********/
|
||||
void setFuel(double newFuel) { fuel = newFuel; addMeasure(L"fuel", json::value(newFuel));}
|
||||
void setAmmo(json::value newAmmo) { ammo = newAmmo; addMeasure(L"ammo", json::value(newAmmo));}
|
||||
void setContacts(json::value newContacts) {contacts = newContacts; addMeasure(L"contacts", json::value(newContacts));}
|
||||
void setFuel(short newFuel) { fuel = newFuel; }
|
||||
void setAmmo(vector<DataTypes::Ammo> newAmmo) { ammo = newAmmo; }
|
||||
void setContacts(vector<DataTypes::Contact> newContacts) {contacts = newContacts; }
|
||||
void setHasTask(bool newHasTask);
|
||||
void setCoalitionID(int newCoalitionID);
|
||||
void setFlags(json::value newFlags) { flags = newFlags; addMeasure(L"flags", json::value(newFlags));}
|
||||
void setCoalitionID(unsigned int newCoalitionID);
|
||||
|
||||
double getFuel() { return fuel; }
|
||||
json::value getAmmo() { return ammo; }
|
||||
json::value getTargets() { return contacts; }
|
||||
vector<DataTypes::Ammo> getAmmo() { return ammo; }
|
||||
vector<DataTypes::Contact> getTargets() { return contacts; }
|
||||
bool getHasTask() { return hasTask; }
|
||||
wstring getCoalition() { return coalition; }
|
||||
int getCoalitionID();
|
||||
json::value getFlags() { return flags; }
|
||||
string getCoalition() { return coalition; }
|
||||
unsigned int getCoalitionID();
|
||||
|
||||
/********** Formation data **********/
|
||||
void setLeaderID(int newLeaderID) { leaderID = newLeaderID; addMeasure(L"leaderID", json::value(newLeaderID)); }
|
||||
void setLeaderID(unsigned int newLeaderID) { leaderID = newLeaderID; }
|
||||
void setFormationOffset(Offset formationOffset);
|
||||
|
||||
int getLeaderID() { return leaderID; }
|
||||
unsigned int getLeaderID() { return leaderID; }
|
||||
Offset getFormationoffset() { return formationOffset; }
|
||||
|
||||
/********** Task data **********/
|
||||
void setCurrentTask(wstring newCurrentTask) { currentTask = newCurrentTask; addMeasure(L"currentTask", json::value(newCurrentTask)); }
|
||||
void setCurrentTask(string newCurrentTask) { currentTask = newCurrentTask; }
|
||||
void setDesiredSpeed(double newDesiredSpeed);
|
||||
void setDesiredAltitude(double newDesiredAltitude);
|
||||
void setDesiredSpeedType(wstring newDesiredSpeedType);
|
||||
void setDesiredAltitudeType(wstring newDesiredAltitudeType);
|
||||
void setActiveDestination(Coords newActiveDestination) { activeDestination = newActiveDestination; addMeasure(L"activeDestination", json::value("")); } // TODO fix
|
||||
void setDesiredSpeedType(string newDesiredSpeedType);
|
||||
void setDesiredAltitudeType(string newDesiredAltitudeType);
|
||||
void setActiveDestination(Coords newActiveDestination) { activeDestination = newActiveDestination; }
|
||||
void setActivePath(list<Coords> newActivePath);
|
||||
void setTargetID(int newTargetID) { targetID = newTargetID; addMeasure(L"targetID", json::value(newTargetID));}
|
||||
void setTargetLocation(Coords newTargetLocation);
|
||||
void setTargetID(unsigned int newTargetID) { targetID = newTargetID; }
|
||||
void setTargetPosition(Coords newTargetPosition);
|
||||
void setIsTanker(bool newIsTanker);
|
||||
void setIsAWACS(bool newIsAWACS);
|
||||
virtual void setOnOff(bool newOnOff) { onOff = newOnOff; addMeasure(L"onOff", json::value(newOnOff));};
|
||||
virtual void setFollowRoads(bool newFollowRoads) { followRoads = newFollowRoads; addMeasure(L"followRoads", json::value(newFollowRoads)); };
|
||||
virtual void setOnOff(bool newOnOff) { onOff = newOnOff; };
|
||||
virtual void setFollowRoads(bool newFollowRoads) { followRoads = newFollowRoads; };
|
||||
|
||||
wstring getCurrentTask() { return currentTask; }
|
||||
string getCurrentTask() { return currentTask; }
|
||||
virtual double getDesiredSpeed() { return desiredSpeed; };
|
||||
virtual double getDesiredAltitude() { return desiredAltitude; };
|
||||
virtual wstring getDesiredSpeedType() { return desiredSpeedType; };
|
||||
virtual wstring getDesiredAltitudeType() { return desiredAltitudeType; };
|
||||
virtual bool getDesiredSpeedType() { return desiredSpeedType; };
|
||||
virtual bool getDesiredAltitudeType() { return desiredAltitudeType; };
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
list<Coords> getActivePath() { return activePath; }
|
||||
int getTargetID() { return targetID; }
|
||||
Coords getTargetLocation() { return targetLocation; }
|
||||
unsigned int getTargetID() { return targetID; }
|
||||
Coords getTargetPosition() { return targetPosition; }
|
||||
bool getIsTanker() { return isTanker; }
|
||||
bool getIsAWACS() { return isAWACS; }
|
||||
bool getOnOff() { return onOff; };
|
||||
bool getFollowRoads() { return followRoads; };
|
||||
|
||||
/********** Options data **********/
|
||||
void setROE(wstring newROE, bool force = false);
|
||||
void setReactionToThreat(wstring newReactionToThreat, bool force = false);
|
||||
void setEmissionsCountermeasures(wstring newEmissionsCountermeasures, bool force = false);
|
||||
void setROE(unsigned char newROE, bool force = false);
|
||||
void setReactionToThreat(unsigned char newReactionToThreat, bool force = false);
|
||||
void setEmissionsCountermeasures(unsigned char newEmissionsCountermeasures, bool force = false);
|
||||
void setTACAN(Options::TACAN newTACAN, bool force = false);
|
||||
void setRadio(Options::Radio newradio, bool force = false);
|
||||
void setGeneralSettings(Options::GeneralSettings newGeneralSettings, bool force = false);
|
||||
void setEPLRS(bool newEPLRS, bool force = false);
|
||||
|
||||
wstring getROE() { return ROE; }
|
||||
wstring getReactionToThreat() { return reactionToThreat; }
|
||||
wstring getEmissionsCountermeasures() { return emissionsCountermeasures; };
|
||||
unsigned char getROE() { return ROE; }
|
||||
unsigned char getReactionToThreat() { return reactionToThreat; }
|
||||
unsigned char getEmissionsCountermeasures() { return emissionsCountermeasures; };
|
||||
Options::TACAN getTACAN() { return TACAN; }
|
||||
Options::Radio getRadio() { return radio; }
|
||||
Options::GeneralSettings getGeneralSettings() { return generalSettings; }
|
||||
@@ -171,10 +201,10 @@ public:
|
||||
|
||||
/********** Control functions **********/
|
||||
void landAt(Coords loc);
|
||||
virtual void changeSpeed(wstring change) {};
|
||||
virtual void changeAltitude(wstring change) {};
|
||||
virtual void changeSpeed(string change) {};
|
||||
virtual void changeAltitude(string change) {};
|
||||
void resetActiveDestination();
|
||||
virtual void setState(int newState) { state = newState; };
|
||||
virtual void setState(unsigned char newState) { state = newState; };
|
||||
void resetTask();
|
||||
void clearActivePath();
|
||||
void pushActivePathFront(Coords newActivePathFront);
|
||||
@@ -182,81 +212,77 @@ public:
|
||||
void popActivePathFront();
|
||||
|
||||
protected:
|
||||
int ID;
|
||||
unsigned int ID;
|
||||
|
||||
map<wstring, Measure*> measures;
|
||||
int taskCheckCounter = 0;
|
||||
map<string, Measure*> measures;
|
||||
unsigned int taskCheckCounter = 0;
|
||||
|
||||
/********** Base data **********/
|
||||
bool controlled = false;
|
||||
wstring name = L"undefined";
|
||||
wstring unitName = L"undefined";
|
||||
wstring groupName = L"undefined";
|
||||
string name = "undefined";
|
||||
string unitName = "undefined";
|
||||
string groupName = "undefined";
|
||||
bool alive = true;
|
||||
json::value type = json::value::null();
|
||||
int country = NULL;
|
||||
bool human = false;
|
||||
unsigned int country = NULL;
|
||||
|
||||
/********** Flight data **********/
|
||||
double latitude = NULL;
|
||||
double longitude = NULL;
|
||||
double altitude = NULL;
|
||||
Coords position = Coords(NULL);
|
||||
double speed = NULL;
|
||||
double heading = NULL;
|
||||
|
||||
/********** Mission data **********/
|
||||
double fuel = 0;
|
||||
unsigned short fuel = 0;
|
||||
double initialFuel = 0; // Used internally to detect refueling completed
|
||||
json::value ammo = json::value::null();
|
||||
json::value contacts = json::value::null();
|
||||
vector<DataTypes::Ammo> ammo;
|
||||
vector<DataTypes::Contact> contacts;
|
||||
bool hasTask = false;
|
||||
wstring coalition = L"";
|
||||
json::value flags = json::value::null();
|
||||
string coalition = "";
|
||||
|
||||
/********** Formation data **********/
|
||||
int leaderID = NULL;
|
||||
unsigned int leaderID = NULL;
|
||||
Offset formationOffset = Offset(NULL);
|
||||
|
||||
/********** Task data **********/
|
||||
wstring currentTask = L"";
|
||||
string currentTask = "";
|
||||
double desiredSpeed = 0;
|
||||
double desiredAltitude = 0;
|
||||
wstring desiredSpeedType = L"GS";
|
||||
wstring desiredAltitudeType = L"AGL";
|
||||
bool desiredSpeedType = 0;
|
||||
bool desiredAltitudeType = 0;
|
||||
list<Coords> activePath;
|
||||
Coords activeDestination = Coords(NULL);
|
||||
int targetID = NULL;
|
||||
Coords targetLocation = Coords(NULL);
|
||||
unsigned int targetID = NULL;
|
||||
Coords targetPosition = Coords(NULL);
|
||||
bool isTanker = false;
|
||||
bool isAWACS = false;
|
||||
bool onOff = true;
|
||||
bool followRoads = false;
|
||||
|
||||
/********** Options data **********/
|
||||
wstring ROE = L"Designated";
|
||||
wstring reactionToThreat = L"Evade";
|
||||
wstring emissionsCountermeasures = L"Defend";
|
||||
unsigned char ROE = ROE::OPEN_FIRE_WEAPON_FREE;
|
||||
unsigned char reactionToThreat = ReactionToThreat::EVADE_FIRE;
|
||||
unsigned char emissionsCountermeasures = EmissionCountermeasure::DEFEND;
|
||||
Options::TACAN TACAN;
|
||||
Options::Radio radio;
|
||||
Options::GeneralSettings generalSettings;
|
||||
bool EPLRS = false;
|
||||
|
||||
/********** State machine **********/
|
||||
int state = State::NONE;
|
||||
unsigned char state = State::NONE;
|
||||
|
||||
/********** Other **********/
|
||||
Coords oldPosition = Coords(0); // Used to approximate speed
|
||||
|
||||
/********** Functions **********/
|
||||
wstring getTargetName();
|
||||
wstring getLeaderName();
|
||||
string getTargetName();
|
||||
string getLeaderName();
|
||||
bool isTargetAlive();
|
||||
bool isLeaderAlive();
|
||||
virtual void AIloop() = 0;
|
||||
void addMeasure(wstring key, json::value value);
|
||||
bool isDestinationReached(double threshold);
|
||||
bool setActiveDestination();
|
||||
bool updateActivePath(bool looping);
|
||||
void goToDestination(wstring enrouteTask = L"nil");
|
||||
void goToDestination(string enrouteTask = "nil");
|
||||
bool checkTaskFailed();
|
||||
void resetTaskFailedCounter();
|
||||
};
|
||||
|
||||
@@ -10,23 +10,22 @@ public:
|
||||
UnitsManager(lua_State* L);
|
||||
~UnitsManager();
|
||||
|
||||
map<int, Unit*>& getUnits() { return units; };
|
||||
Unit* getUnit(int ID);
|
||||
map<unsigned int, Unit*>& getUnits() { return units; };
|
||||
Unit* getUnit(unsigned int ID);
|
||||
bool isUnitInGroup(Unit* unit);
|
||||
bool isUnitGroupLeader(Unit* unit);
|
||||
Unit* getGroupLeader(int ID);
|
||||
Unit* getGroupLeader(unsigned int ID);
|
||||
Unit* getGroupLeader(Unit* unit);
|
||||
vector<Unit*> getGroupMembers(wstring groupName);
|
||||
vector<Unit*> getGroupMembers(string groupName);
|
||||
void updateExportData(lua_State* L, double dt = 0);
|
||||
void updateMissionData(json::value missionData);
|
||||
void runAILoop();
|
||||
void getUnitData(json::value& answer, long long time);
|
||||
void appendUnitData(int ID, json::value& answer, long long time);
|
||||
void deleteUnit(int ID, bool explosion);
|
||||
void acquireControl(int ID);
|
||||
string getUnitData(bool refresh);
|
||||
void deleteUnit(unsigned int ID, bool explosion);
|
||||
void acquireControl(unsigned int ID);
|
||||
|
||||
private:
|
||||
map<int, Unit*> units;
|
||||
map<unsigned int, Unit*> units;
|
||||
json::value missionDB;
|
||||
|
||||
};
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
class Weapon : public Unit
|
||||
{
|
||||
public:
|
||||
Weapon(json::value json, int ID);
|
||||
Weapon(json::value json, unsigned int ID);
|
||||
|
||||
virtual wstring getCategory() = 0;
|
||||
virtual string getCategory() = 0;
|
||||
|
||||
protected:
|
||||
/* Weapons are not controllable and have no AIloop */
|
||||
@@ -16,15 +16,15 @@ protected:
|
||||
class Missile : public Weapon
|
||||
{
|
||||
public:
|
||||
Missile(json::value json, int ID);
|
||||
Missile(json::value json, unsigned int ID);
|
||||
|
||||
virtual wstring getCategory() { return L"Missile"; };
|
||||
virtual string getCategory() { return "Missile"; };
|
||||
};
|
||||
|
||||
class Bomb : public Weapon
|
||||
{
|
||||
public:
|
||||
Bomb(json::value json, int ID);
|
||||
Bomb(json::value json, unsigned int ID);
|
||||
|
||||
virtual wstring getCategory() { return L"Bomb"; };
|
||||
virtual string getCategory() { return "Bomb"; };
|
||||
};
|
||||
Reference in New Issue
Block a user