Added code to update ammo and contacts

This commit is contained in:
Pax1601
2023-07-01 12:31:30 +02:00
parent 211cf48681
commit 807cdfeb5b
2 changed files with 112 additions and 82 deletions

View File

@@ -157,48 +157,48 @@ public:
virtual void setTACAN(DataTypes::TACAN newValue, bool force = false);
virtual void setRadio(DataTypes::Radio newValue, bool force = false);
virtual void setGeneralSettings(DataTypes::GeneralSettings newValue, bool force = false);
virtual void setAmmo(vector<DataTypes::Ammo> newValue) { updateValue(ammo, newValue, DataIndex::ammo); }
virtual void setContacts(vector<DataTypes::Contact> newValue) { updateValue(contacts, newValue, DataIndex::contacts); }
virtual void setAmmo(vector<DataTypes::Ammo> newValue);
virtual void setContacts(vector<DataTypes::Contact> newValue);
virtual void setActivePath(list<Coords> newValue);
/********** Getters **********/
virtual string getCategory() { return category; };
virtual bool getAlive() { return alive; }
virtual bool getHuman() { return human; }
virtual bool getControlled() { return controlled; }
virtual unsigned int 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 double 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; }
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; }
protected:
unsigned int ID;
@@ -251,6 +251,13 @@ protected:
/********** Private methods **********/
virtual void AIloop() = 0;
void appendString(stringstream& ss, const unsigned char& datumIndex, const string& datumValue) {
const unsigned short size = datumValue.size();
ss.write((const char*)&datumIndex, sizeof(unsigned char));
ss.write((const char*)&size, sizeof(unsigned short));
ss << datumValue;
}
/********** Template methods **********/
template <typename T>
void updateValue(T& value, T& newValue, unsigned char datumIndex)
@@ -268,13 +275,6 @@ protected:
ss.write((const char*)&datumValue, sizeof(T));
}
void appendString(stringstream& ss, const unsigned char& datumIndex, string& datumValue) {
const unsigned short size = datumValue.size();
ss.write((const char*)&datumIndex, sizeof(unsigned char));
ss.write((const char*)&size, sizeof(unsigned short));
ss << datumValue;
}
template <typename T>
void appendVector(stringstream& ss, const unsigned char& datumIndex, vector<T>& datumValue) {
const unsigned short size = datumValue.size();