mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Performance optimizations for large unit counts
This commit is contained in:
@@ -12,6 +12,7 @@ class AirUnit : public Unit
|
||||
public:
|
||||
AirUnit(json::value json, unsigned int ID);
|
||||
|
||||
virtual void setDefaults(bool force = false);
|
||||
virtual void setState(unsigned char newState);
|
||||
|
||||
virtual void changeSpeed(string change) = 0;
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
|
||||
private:
|
||||
const string color;
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return immediate? 1: 100; }
|
||||
virtual unsigned int getLoad() { return immediate? 1: 30; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return immediate ? 1 : 100; }
|
||||
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return immediate ? 1 : 100; }
|
||||
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return immediate ? 1 : 100; }
|
||||
virtual unsigned int getLoad() { return immediate ? 1 : 30; }
|
||||
|
||||
private:
|
||||
const string coalition;
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 100; }
|
||||
virtual unsigned int getLoad() { return 30; }
|
||||
|
||||
private:
|
||||
const unsigned int ID;
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
immediate = immediate;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return immediate? 1: 20; }
|
||||
virtual unsigned int getLoad() { return immediate? 1: 5; }
|
||||
|
||||
private:
|
||||
const unsigned int ID;
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
virtual unsigned int getLoad() { return 1; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
virtual unsigned int getLoad() { return 1; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
virtual unsigned int getLoad() { return 1; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
@@ -362,7 +362,7 @@ public:
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
virtual unsigned int getLoad() { return 1; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
@@ -383,7 +383,7 @@ public:
|
||||
priority = CommandPriority::HIGH;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 2; }
|
||||
virtual unsigned int getLoad() { return 1; }
|
||||
|
||||
private:
|
||||
const string groupName;
|
||||
@@ -401,7 +401,7 @@ public:
|
||||
priority = CommandPriority::MEDIUM;
|
||||
};
|
||||
virtual string getString(lua_State* L);
|
||||
virtual unsigned int getLoad() { return 10; }
|
||||
virtual unsigned int getLoad() { return 4; }
|
||||
|
||||
private:
|
||||
const Coords location;
|
||||
|
||||
@@ -9,10 +9,11 @@ public:
|
||||
GroundUnit(json::value json, unsigned int ID);
|
||||
|
||||
virtual void setState(unsigned char newState);
|
||||
virtual void setDefaults(bool force = false);
|
||||
|
||||
virtual void changeSpeed(string change);
|
||||
virtual void setOnOff(bool newOnOff);
|
||||
virtual void setFollowRoads(bool newFollowRoads);
|
||||
virtual void setOnOff(bool newOnOff, bool force = false);
|
||||
virtual void setFollowRoads(bool newFollowRoads, bool force = false);
|
||||
|
||||
protected:
|
||||
virtual void AIloop();
|
||||
|
||||
@@ -10,12 +10,16 @@ public:
|
||||
~Scheduler();
|
||||
|
||||
void appendCommand(Command* command);
|
||||
int getCurrentLoad();
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(string key, json::value value);
|
||||
|
||||
int getLoad();
|
||||
void setFrameRate(double newFrameRate) { frameRate = newFrameRate; }
|
||||
int getFrameRate() { return frameRate; };
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
unsigned int load;
|
||||
double frameRate;
|
||||
};
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace DataIndex {
|
||||
ammo,
|
||||
contacts,
|
||||
activePath,
|
||||
isLeader,
|
||||
lastIndex,
|
||||
endOfData = 255
|
||||
};
|
||||
@@ -86,14 +87,12 @@ public:
|
||||
|
||||
/********** Methods **********/
|
||||
void initialize(json::value json);
|
||||
void setDefaults(bool force = false);
|
||||
virtual void setDefaults(bool force = false);
|
||||
|
||||
void runAILoop();
|
||||
|
||||
void updateExportData(json::value json, double dt = 0);
|
||||
void updateMissionData(json::value json);
|
||||
void update(json::value json, double dt);
|
||||
|
||||
unsigned int getDataPacket(char*& data);
|
||||
unsigned int getID() { return ID; }
|
||||
void getData(stringstream& ss, unsigned long long time);
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
@@ -144,8 +143,8 @@ public:
|
||||
virtual void setHeading(double newValue) { updateValue(heading, newValue, DataIndex::heading); }
|
||||
virtual void setIsTanker(bool newValue);
|
||||
virtual void setIsAWACS(bool newValue);
|
||||
virtual void setOnOff(bool newValue) { updateValue(onOff, newValue, DataIndex::onOff); };
|
||||
virtual void setFollowRoads(bool newValue) { updateValue(followRoads, newValue, DataIndex::followRoads); };
|
||||
virtual void setOnOff(bool newValue, bool force = false) { updateValue(onOff, newValue, DataIndex::onOff); };
|
||||
virtual void setFollowRoads(bool newValue, bool force = false) { updateValue(followRoads, newValue, DataIndex::followRoads); };
|
||||
virtual void setFuel(unsigned short newValue) { updateValue(fuel, newValue, DataIndex::fuel); }
|
||||
virtual void setDesiredSpeed(double newValue);
|
||||
virtual void setDesiredSpeedType(string newValue);
|
||||
@@ -164,6 +163,7 @@ public:
|
||||
virtual void setAmmo(vector<DataTypes::Ammo> newValue);
|
||||
virtual void setContacts(vector<DataTypes::Contact> newValue);
|
||||
virtual void setActivePath(list<Coords> newValue);
|
||||
virtual void setIsLeader(bool newValue) { updateValue(isLeader, newValue, DataIndex::isLeader); }
|
||||
|
||||
/********** Getters **********/
|
||||
virtual string getCategory() { return category; };
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
virtual double getDesiredAltitude() { return desiredAltitude; };
|
||||
virtual bool getDesiredAltitudeType() { return desiredAltitudeType; };
|
||||
virtual unsigned int getLeaderID() { return leaderID; }
|
||||
virtual Offset getFormationoffset() { return formationOffset; }
|
||||
virtual Offset getFormationOffset() { return formationOffset; }
|
||||
virtual unsigned int getTargetID() { return targetID; }
|
||||
virtual Coords getTargetPosition() { return targetPosition; }
|
||||
virtual unsigned char getROE() { return ROE; }
|
||||
@@ -203,6 +203,7 @@ public:
|
||||
virtual vector<DataTypes::Ammo> getAmmo() { return ammo; }
|
||||
virtual vector<DataTypes::Contact> getTargets() { return contacts; }
|
||||
virtual list<Coords> getActivePath() { return activePath; }
|
||||
virtual bool getIsLeader() { return isLeader; }
|
||||
|
||||
protected:
|
||||
unsigned int ID;
|
||||
@@ -244,13 +245,14 @@ protected:
|
||||
vector<DataTypes::Ammo> ammo;
|
||||
vector<DataTypes::Contact> contacts;
|
||||
list<Coords> activePath;
|
||||
bool isLeader = false;
|
||||
Coords activeDestination = Coords(NULL);
|
||||
|
||||
/********** Other **********/
|
||||
unsigned int taskCheckCounter = 0;
|
||||
Coords activeDestination = Coords(NULL);
|
||||
double initialFuel = 0;
|
||||
Coords oldPosition = Coords(0);
|
||||
map<unsigned char, unsigned long long> updateTimeMap;
|
||||
unsigned long long lastLoopTime = 0;
|
||||
|
||||
/********** Private methods **********/
|
||||
virtual void AIloop() = 0;
|
||||
|
||||
@@ -13,14 +13,13 @@ public:
|
||||
map<unsigned int, Unit*>& getUnits() { return units; };
|
||||
Unit* getUnit(unsigned int ID);
|
||||
bool isUnitInGroup(Unit* unit);
|
||||
bool isUnitGroupLeader(Unit* unit);
|
||||
bool isUnitGroupLeader(Unit* unit, Unit*& leader);
|
||||
Unit* getGroupLeader(unsigned int ID);
|
||||
Unit* getGroupLeader(Unit* unit);
|
||||
vector<Unit*> getGroupMembers(string groupName);
|
||||
void updateExportData(lua_State* L, double dt = 0);
|
||||
void updateMissionData(json::value missionData);
|
||||
void update(json::value& missionData, double dt);
|
||||
void runAILoop();
|
||||
string getUnitData(stringstream &ss, unsigned long long time);
|
||||
void getUnitData(stringstream &ss, unsigned long long time);
|
||||
void deleteUnit(unsigned int ID, bool explosion, bool immediate);
|
||||
void acquireControl(unsigned int ID);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user