-
+
4
diff --git a/client/views/unitcontrolpanel.ejs b/client/views/unitcontrolpanel.ejs
index 40629d4d..276b569c 100644
--- a/client/views/unitcontrolpanel.ejs
+++ b/client/views/unitcontrolpanel.ejs
@@ -62,127 +62,3 @@
Delete unit
-
-
-
-
-
-
-
-
-
-
-
-
-
- Operate as AAR tanker
-
-
-
-
-
-
- Operate as AWACS
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/core/src/airunit.cpp b/src/core/src/airunit.cpp
index cf3c9079..5d580b65 100644
--- a/src/core/src/airunit.cpp
+++ b/src/core/src/airunit.cpp
@@ -52,10 +52,12 @@ void AirUnit::setState(int newState)
case State::IDLE: {
clearActivePath();
resetActiveDestination();
+ addMeasure(L"currentState", json::value(L"Idle"));
break;
}
case State::REACH_DESTINATION: {
resetActiveDestination();
+ addMeasure(L"currentState", json::value(L"Reach destination"));
break;
}
case State::ATTACK: {
@@ -65,21 +67,25 @@ void AirUnit::setState(int newState)
clearActivePath();
pushActivePathFront(targetPosition);
resetActiveDestination();
+ addMeasure(L"currentState", json::value(L"Attack"));
}
break;
}
case State::FOLLOW: {
clearActivePath();
resetActiveDestination();
+ addMeasure(L"currentState", json::value(L"Follow"));
break;
}
case State::LAND: {
resetActiveDestination();
+ addMeasure(L"currentState", json::value(L"Land"));
break;
}
case State::REFUEL: {
clearActivePath();
resetActiveDestination();
+ addMeasure(L"currentState", json::value(L"Refuel"));
break;
}
default:
@@ -184,7 +190,7 @@ void AirUnit::AIloop()
{
std::wostringstream taskSS;
if (isTanker) {
- taskSS << "{ [1] = { id = 'Orbit', pattern = 'Race-Track' }, [2] = { id = 'Tanker' } }";
+ taskSS << "{ [1] = { id = 'Tanker' }, [2] = { id = 'Orbit', pattern = 'Race-Track' } }";
}
else {
taskSS << "{ id = 'Orbit', pattern = 'Circle' }";
@@ -260,21 +266,12 @@ void AirUnit::AIloop()
wstring enrouteTask = enrouteTaskSS.str();
currentTask = L"Attacking " + getTargetName();
- if (activeDestination == NULL || !hasTask)
+ if (!hasTask)
{
setActiveDestination();
goToDestination(enrouteTask);
}
- else {
- if (isDestinationReached()) {
- if (updateActivePath(false) && setActiveDestination())
- goToDestination(enrouteTask);
- else {
- setState(State::IDLE);
- break;
- }
- }
- }
+
break;
}
case State::FOLLOW: {
@@ -327,5 +324,4 @@ void AirUnit::AIloop()
break;
}
addMeasure(L"currentTask", json::value(currentTask));
- addMeasure(L"currentState", json::value(state));
}
diff --git a/src/core/src/unit.cpp b/src/core/src/unit.cpp
index ee64b6c3..bf848269 100644
--- a/src/core/src/unit.cpp
+++ b/src/core/src/unit.cpp
@@ -19,6 +19,7 @@ Unit::Unit(json::value json, int ID) :
ID(ID)
{
log("Creating unit with ID: " + to_string(ID));
+ addMeasure(L"currentState", json::value(L"Idle"));
}
Unit::~Unit()
@@ -134,7 +135,7 @@ json::value Unit::getData(long long time)
/********** Task data **********/
json[L"taskData"] = json::value::object();
- for (auto key : { L"currentTask", L"targetSpeed", L"targetAltitude", L"activePath", L"isTanker", L"isAWACS", L"TACANChannel", L"TACANXY", L"TACANCallsign", L"radioFrequency", L"radioCallsign", L"radioCallsignNumber"})
+ for (auto key : { L"currentState", L"currentTask", L"targetSpeed", L"targetAltitude", L"activePath", L"isTanker", L"isAWACS", L"TACANChannel", L"TACANXY", L"TACANCallsign", L"radioFrequency", L"radioCallsign", L"radioCallsignNumber"})
{
if (measures.find(key) != measures.end() && measures[key]->getTime() > time)
json[L"taskData"][key] = measures[key]->getValue();