mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
More fixes in binary data transmission
This commit is contained in:
@@ -234,7 +234,7 @@ private:
|
||||
const bool explosion;
|
||||
};
|
||||
|
||||
/* Follow command */
|
||||
/* SetTask command */
|
||||
class SetTask : public Command
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -162,43 +162,43 @@ public:
|
||||
virtual void setActivePath(list<Coords> newValue);
|
||||
|
||||
/********** Getters **********/
|
||||
virtual const string& getCategory() { return category; };
|
||||
virtual const bool& getAlive() { return alive; }
|
||||
virtual const bool& getHuman() { return human; }
|
||||
virtual const bool& getControlled() { return controlled; }
|
||||
virtual const unsigned char& getCoalition() { return coalition; }
|
||||
virtual const unsigned char& getCountry() { return country; }
|
||||
virtual const string& getName() { return name; }
|
||||
virtual const string& getUnitName() { return unitName; }
|
||||
virtual const string& getGroupName() { return groupName; }
|
||||
virtual const unsigned char& getState() { return state; }
|
||||
virtual const string& getTask() { return task; }
|
||||
virtual const bool& getHasTask() { return hasTask; }
|
||||
virtual const Coords& getPosition() { return position; }
|
||||
virtual const double& getSpeed() { return speed; }
|
||||
virtual const double& getHeading() { return heading; }
|
||||
virtual const bool& getIsTanker() { return isTanker; }
|
||||
virtual const bool& getIsAWACS() { return isAWACS; }
|
||||
virtual const bool& getOnOff() { return onOff; };
|
||||
virtual const bool& getFollowRoads() { return followRoads; };
|
||||
virtual const unsigned short& getFuel() { return fuel; }
|
||||
virtual const double& getDesiredSpeed() { return desiredSpeed; };
|
||||
virtual const bool& getDesiredSpeedType() { return desiredSpeedType; };
|
||||
virtual const double& getDesiredAltitude() { return desiredAltitude; };
|
||||
virtual const bool& getDesiredAltitudeType() { return desiredAltitudeType; };
|
||||
virtual const unsigned int& getLeaderID() { return leaderID; }
|
||||
virtual const Offset& getFormationoffset() { return formationOffset; }
|
||||
virtual const unsigned int& getTargetID() { return targetID; }
|
||||
virtual const Coords& getTargetPosition() { return targetPosition; }
|
||||
virtual const unsigned char& getROE() { return ROE; }
|
||||
virtual const unsigned char& getReactionToThreat() { return reactionToThreat; }
|
||||
virtual const unsigned char& getEmissionsCountermeasures() { return emissionsCountermeasures; };
|
||||
virtual const DataTypes::TACAN& getTACAN() { return TACAN; }
|
||||
virtual const DataTypes::Radio& getRadio() { return radio; }
|
||||
virtual const DataTypes::GeneralSettings& getGeneralSettings() { return generalSettings; }
|
||||
virtual const vector<DataTypes::Ammo>& getAmmo() { return ammo; }
|
||||
virtual const vector<DataTypes::Contact>& getTargets() { return contacts; }
|
||||
virtual const list<Coords>& getActivePath() { return activePath; }
|
||||
virtual string getCategory() { return category; };
|
||||
virtual bool getAlive() { return alive; }
|
||||
virtual bool getHuman() { return human; }
|
||||
virtual bool getControlled() { return controlled; }
|
||||
virtual unsigned char getCoalition() { return coalition; }
|
||||
virtual unsigned char getCountry() { return country; }
|
||||
virtual string getName() { return name; }
|
||||
virtual string getUnitName() { return unitName; }
|
||||
virtual string getGroupName() { return groupName; }
|
||||
virtual unsigned char getState() { return state; }
|
||||
virtual string getTask() { return task; }
|
||||
virtual bool getHasTask() { return hasTask; }
|
||||
virtual Coords getPosition() { return position; }
|
||||
virtual double getSpeed() { return speed; }
|
||||
virtual double getHeading() { return heading; }
|
||||
virtual bool getIsTanker() { return isTanker; }
|
||||
virtual bool getIsAWACS() { return isAWACS; }
|
||||
virtual bool getOnOff() { return onOff; };
|
||||
virtual bool getFollowRoads() { return followRoads; };
|
||||
virtual unsigned short getFuel() { return fuel; }
|
||||
virtual double getDesiredSpeed() { return desiredSpeed; };
|
||||
virtual bool getDesiredSpeedType() { return desiredSpeedType; };
|
||||
virtual double getDesiredAltitude() { return desiredAltitude; };
|
||||
virtual bool getDesiredAltitudeType() { return desiredAltitudeType; };
|
||||
virtual unsigned int getLeaderID() { return leaderID; }
|
||||
virtual Offset getFormationoffset() { return formationOffset; }
|
||||
virtual unsigned int getTargetID() { return targetID; }
|
||||
virtual Coords getTargetPosition() { return targetPosition; }
|
||||
virtual unsigned char getROE() { return ROE; }
|
||||
virtual unsigned char getReactionToThreat() { return reactionToThreat; }
|
||||
virtual unsigned char getEmissionsCountermeasures() { return emissionsCountermeasures; };
|
||||
virtual DataTypes::TACAN getTACAN() { return TACAN; }
|
||||
virtual DataTypes::Radio getRadio() { return radio; }
|
||||
virtual DataTypes::GeneralSettings getGeneralSettings() { return generalSettings; }
|
||||
virtual vector<DataTypes::Ammo> getAmmo() { return ammo; }
|
||||
virtual vector<DataTypes::Contact> getTargets() { return contacts; }
|
||||
virtual list<Coords> getActivePath() { return activePath; }
|
||||
|
||||
protected:
|
||||
unsigned int ID;
|
||||
@@ -220,7 +220,7 @@ protected:
|
||||
double heading = NULL;
|
||||
bool isTanker = false;
|
||||
bool isAWACS = false;
|
||||
bool onOff = false;
|
||||
bool onOff = true;
|
||||
bool followRoads = false;
|
||||
unsigned short fuel = 0;
|
||||
double desiredSpeed = 0;
|
||||
@@ -265,7 +265,7 @@ protected:
|
||||
if (newValue != value)
|
||||
{
|
||||
triggerUpdate(datumIndex);
|
||||
*(&value) = newValue;
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,9 @@ protected:
|
||||
const unsigned short size = datumValue.size();
|
||||
ss.write((const char*)&datumIndex, sizeof(unsigned char));
|
||||
ss.write((const char*)&size, sizeof(unsigned short));
|
||||
ss.write((const char*)&datumValue, size * sizeof(T));
|
||||
|
||||
for (auto& el : datumValue)
|
||||
ss.write((const char*)&el, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -113,6 +113,8 @@ void AirUnit::setState(unsigned char newState)
|
||||
|
||||
log(unitName + " setting state from " + to_string(state) + " to " + to_string(newState));
|
||||
state = newState;
|
||||
|
||||
triggerUpdate(DataIndex::state);
|
||||
}
|
||||
|
||||
void AirUnit::AIloop()
|
||||
|
||||
@@ -65,6 +65,8 @@ void GroundUnit::setState(unsigned char newState)
|
||||
|
||||
log(unitName + " setting state from " + to_string(state) + " to " + to_string(newState));
|
||||
state = newState;
|
||||
|
||||
triggerUpdate(DataIndex::state);
|
||||
}
|
||||
|
||||
void GroundUnit::AIloop()
|
||||
|
||||
@@ -57,6 +57,7 @@ void Scheduler::handleRequest(string key, json::value value)
|
||||
Command* command = nullptr;
|
||||
|
||||
log("Received request with ID: " + key);
|
||||
log(value.serialize());
|
||||
if (key.compare("setPath") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
@@ -146,10 +147,10 @@ void Scheduler::handleRequest(string key, json::value value)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
unitsManager->acquireControl(ID);
|
||||
unsigned int leaderID = value[L"targetID"].as_integer();
|
||||
unsigned int offsetX = value[L"offsetX"].as_integer();
|
||||
unsigned int offsetY = value[L"offsetY"].as_integer();
|
||||
unsigned int offsetZ = value[L"offsetZ"].as_integer();
|
||||
unsigned int leaderID = value[L"targetID"].as_double();
|
||||
double offsetX = value[L"offsetX"].as_double();
|
||||
double offsetY = value[L"offsetY"].as_double();
|
||||
double offsetZ = value[L"offsetZ"].as_double();
|
||||
|
||||
Unit* unit = unitsManager->getGroupLeader(ID);
|
||||
Unit* leader = unitsManager->getUnit(leaderID);
|
||||
|
||||
@@ -128,7 +128,6 @@ void Unit::updateMissionData(json::value json)
|
||||
if (json.has_object_field(L"ammo")) {
|
||||
vector<DataTypes::Ammo> ammo;
|
||||
for (auto const& el : json[L"ammo"].as_object()) {
|
||||
log(el.second.serialize());
|
||||
DataTypes::Ammo ammoItem;
|
||||
auto ammoJson = el.second;
|
||||
ammoItem.quantity = ammoJson[L"count"].as_number().to_uint32();
|
||||
@@ -156,12 +155,12 @@ void Unit::updateMissionData(json::value json)
|
||||
contactItem.ID = contactJson[L"object"][L"id_"].as_number().to_uint32();
|
||||
|
||||
string detectionMethod = to_string(contactJson[L"detectionMethod"]);
|
||||
if (detectionMethod.compare("VISUAL")) contactItem.detectionMethod = 1;
|
||||
else if (detectionMethod.compare("OPTIC")) contactItem.detectionMethod = 2;
|
||||
else if (detectionMethod.compare("RADAR")) contactItem.detectionMethod = 4;
|
||||
else if (detectionMethod.compare("IRST")) contactItem.detectionMethod = 8;
|
||||
else if (detectionMethod.compare("RWR")) contactItem.detectionMethod = 16;
|
||||
else if (detectionMethod.compare("DLINK")) contactItem.detectionMethod = 32;
|
||||
if (detectionMethod.compare("VISUAL") == 0) contactItem.detectionMethod = 1;
|
||||
else if (detectionMethod.compare("OPTIC") == 0) contactItem.detectionMethod = 2;
|
||||
else if (detectionMethod.compare("RADAR") == 0) contactItem.detectionMethod = 4;
|
||||
else if (detectionMethod.compare("IRST") == 0) contactItem.detectionMethod = 8;
|
||||
else if (detectionMethod.compare("RWR") == 0) contactItem.detectionMethod = 16;
|
||||
else if (detectionMethod.compare("DLINK") == 0) contactItem.detectionMethod = 32;
|
||||
contacts.push_back(contactItem);
|
||||
}
|
||||
setContacts(contacts);
|
||||
@@ -248,7 +247,7 @@ void Unit::setContacts(vector<DataTypes::Contact> newValue)
|
||||
{
|
||||
if (contacts.size() == newValue.size()) {
|
||||
bool equal = true;
|
||||
for (int i = 0; i < ammo.size(); i++) {
|
||||
for (int i = 0; i < contacts.size(); i++) {
|
||||
if (contacts.at(i) != newValue.at(i))
|
||||
{
|
||||
equal = false;
|
||||
|
||||
Reference in New Issue
Block a user