diff --git a/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj b/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj
index 69e7893f9..57daa3ca5 100644
--- a/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj
+++ b/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj
@@ -59,6 +59,7 @@
+
@@ -253,6 +254,7 @@
+
diff --git a/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj.filters b/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj.filters
index 4289e51d2..c106e1145 100644
--- a/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj.filters
+++ b/msvc/UKControllerPlugin/UKControllerPlugin.vcxproj.filters
@@ -714,6 +714,9 @@
src\squawk
+
+ src\controller
+
@@ -1207,5 +1210,8 @@
src\squawk
+
+ src\controller
+
-
+
\ No newline at end of file
diff --git a/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj b/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj
index 818fb5f66..7c4875deb 100644
--- a/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj
+++ b/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj
@@ -62,6 +62,7 @@
+
diff --git a/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj.filters b/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj.filters
index 27c503bf7..eaa9046f7 100644
--- a/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj.filters
+++ b/msvc/UKControllerPluginTest/UKControllerPluginTest.vcxproj.filters
@@ -533,6 +533,9 @@
test\squawk
+
+ test\controller
+
@@ -636,4 +639,4 @@
mock
-
+
\ No newline at end of file
diff --git a/src/airfield/AirfieldOwnershipManager.cpp b/src/airfield/AirfieldOwnershipManager.cpp
index 986db2844..4b91ee990 100644
--- a/src/airfield/AirfieldOwnershipManager.cpp
+++ b/src/airfield/AirfieldOwnershipManager.cpp
@@ -118,7 +118,7 @@ namespace UKControllerPlugin {
}
// Only log when positions have changed hands
- bool needsLog = this->ownershipMap.count(icao) > 0 &&
+ bool needsLog = this->ownershipMap.count(icao) == 0 ||
this->ownershipMap.at(icao)->GetCallsign() !=
this->activeCallsigns.GetLeadCallsignForPosition(*it).GetCallsign();
diff --git a/src/controller/ControllerPositionCollection.cpp b/src/controller/ControllerPositionCollection.cpp
index 12fb3a472..50eb19d83 100644
--- a/src/controller/ControllerPositionCollection.cpp
+++ b/src/controller/ControllerPositionCollection.cpp
@@ -1,6 +1,7 @@
#include "pch/stdafx.h"
#include "controller/ControllerPositionCollection.h"
#include "controller/ControllerPosition.h"
+#include "controller/TranslateFrequencyAbbreviation.h"
using UKControllerPlugin::Controller::ControllerPosition;
@@ -35,6 +36,9 @@ namespace UKControllerPlugin {
std::string facility,
double frequency
) const {
+
+ facility = TranslateFrequencyAbbreviation(facility);
+
// If there's no chance of finding anything, save us the iteration.
if (!this->IsPossibleAreaPosition(facility) && !this->IsPossibleAirfieldPosition(facility)) {
throw std::out_of_range("Position not found.");
@@ -70,7 +74,8 @@ namespace UKControllerPlugin {
*/
bool ControllerPositionCollection::IsPossibleAirfieldPosition(std::string facility) const
{
- return facility.size() == 4 && facility.substr(0, 2) == "EG";
+ return facility == "ESSEX" || facility == "THAMES" || facility == "SOLENT" ||
+ facility.size() == 4 && facility.substr(0, 2) == "EG";
}
/*
diff --git a/src/controller/TranslateFrequencyAbbreviation.cpp b/src/controller/TranslateFrequencyAbbreviation.cpp
new file mode 100644
index 000000000..9518974d9
--- /dev/null
+++ b/src/controller/TranslateFrequencyAbbreviation.cpp
@@ -0,0 +1,23 @@
+#include "pch/stdafx.h"
+#include "controller/TranslateFrequencyAbbreviation.h"
+
+namespace UKControllerPlugin {
+ namespace Controller {
+
+ std::map translations = {
+ {"ESX", "ESSEX"},
+ {"SOL", "SOLENT"},
+ {"THA", "THAMES"},
+ {"TMS", "THAMES"}
+ };
+
+ /*
+ Given a recognised abbreviation for a facility, translate
+ it to the full facility for use in matching controller positions.
+ */
+ std::string TranslateFrequencyAbbreviation(std::string facility)
+ {
+ return translations.count(facility) ? translations.at(facility) : facility;
+ }
+ } // namespace Controller
+} // namespace UKControllerPlugin
diff --git a/src/controller/TranslateFrequencyAbbreviation.h b/src/controller/TranslateFrequencyAbbreviation.h
new file mode 100644
index 000000000..c6eef1f49
--- /dev/null
+++ b/src/controller/TranslateFrequencyAbbreviation.h
@@ -0,0 +1,8 @@
+#pragma once
+
+namespace UKControllerPlugin {
+ namespace Controller {
+
+ std::string TranslateFrequencyAbbreviation(std::string facility);
+ } // namespace Controller
+} // namespace UKControllerPlugin
diff --git a/src/plugin/UKPlugin.cpp b/src/plugin/UKPlugin.cpp
index 57ba1278e..fb28ef64d 100644
--- a/src/plugin/UKPlugin.cpp
+++ b/src/plugin/UKPlugin.cpp
@@ -118,6 +118,13 @@ namespace UKControllerPlugin {
void UKPlugin::DoInitialControllerLoad(void)
{
LogInfo("Initial controller load started");
+
+ EuroScopePlugIn::CController me = this->ControllerMyself();
+ if (me.IsValid()) {
+ this->OnControllerPositionUpdate(me);
+ LogInfo("Loaded myself, on " + std::string(me.GetCallsign()));
+ }
+
EuroScopePlugIn::CController current = this->ControllerSelectFirst();
// If there's nobody online, stop.
diff --git a/src/update/PluginVersion.cpp b/src/update/PluginVersion.cpp
index 76be3d231..db1fb1a9d 100644
--- a/src/update/PluginVersion.cpp
+++ b/src/update/PluginVersion.cpp
@@ -3,7 +3,7 @@
namespace UKControllerPlugin {
namespace Plugin {
- const char * const PluginVersion::version = "1.1.1";
+ const char * const PluginVersion::version = "1.1.2";
const char * const PluginVersion::title = "UK Controller Plugin";
const char * const PluginVersion::author = "VATSIM UK";
const char * const PluginVersion::copyright = "VATSIM United Kingdom Division";
diff --git a/src/update/PluginVersion.h b/src/update/PluginVersion.h
index 4e0c815a1..e0bc41c0e 100644
--- a/src/update/PluginVersion.h
+++ b/src/update/PluginVersion.h
@@ -2,6 +2,12 @@
namespace UKControllerPlugin {
namespace Plugin {
+
+ /*
+ Contains the version details of the plugin
+ that get passed to ES and are also used in update
+ checks.
+ */
typedef struct PluginVersion {
static const char * const version;
static const char * const title;
diff --git a/test/test/controller/ControllerPositionCollectionTest.cpp b/test/test/controller/ControllerPositionCollectionTest.cpp
index 5a1a40a5e..4c301579b 100644
--- a/test/test/controller/ControllerPositionCollectionTest.cpp
+++ b/test/test/controller/ControllerPositionCollectionTest.cpp
@@ -111,5 +111,53 @@ namespace UKControllerPluginTest {
collection.AddPosition(std::move(controller));
EXPECT_EQ(*controllerRaw, collection.FetchPositionByFacilityAndFrequency("EGFF", 125.8514));
}
+
+ TEST(ControllerPositionCollection, FetchPositionByFacilityAndFrequencyWillWorkForEssex)
+ {
+ ControllerPositionCollection collection;
+ std::unique_ptr controller(
+ new ControllerPosition("ESSEX_APP", 120.620, "APP", std::vector {"EGSS, EGGW, EGSC"})
+ );
+
+ ControllerPosition * controllerRaw = controller.get();
+ collection.AddPosition(std::move(controller));
+ EXPECT_EQ(*controllerRaw, collection.FetchPositionByFacilityAndFrequency("ESSEX", 120.620));
+ }
+
+ TEST(ControllerPositionCollection, FetchPositionByFacilityAndFrequencyWillWorkForThames)
+ {
+ ControllerPositionCollection collection;
+ std::unique_ptr controller(
+ new ControllerPosition("THAMES", 132.700, "APP", std::vector {"EGLC, EGKB"})
+ );
+
+ ControllerPosition * controllerRaw = controller.get();
+ collection.AddPosition(std::move(controller));
+ EXPECT_EQ(*controllerRaw, collection.FetchPositionByFacilityAndFrequency("THAMES", 132.700));
+ }
+
+ TEST(ControllerPositionCollection, FetchPositionByFacilityAndFrequencyWillWorkForSolent)
+ {
+ ControllerPositionCollection collection;
+ std::unique_ptr controller(
+ new ControllerPosition("SOLENT", 120.220, "APP", std::vector {"EGLC, EGKB"})
+ );
+
+ ControllerPosition * controllerRaw = controller.get();
+ collection.AddPosition(std::move(controller));
+ EXPECT_EQ(*controllerRaw, collection.FetchPositionByFacilityAndFrequency("SOLENT", 120.220));
+ }
+
+ TEST(ControllerPositionCollection, FetchPositionByFacilityAndFrequencyWillWorkForAbbreviations)
+ {
+ ControllerPositionCollection collection;
+ std::unique_ptr controller(
+ new ControllerPosition("ESSEX_APP", 120.620, "APP", std::vector {"EGSS, EGGW, EGSC"})
+ );
+
+ ControllerPosition * controllerRaw = controller.get();
+ collection.AddPosition(std::move(controller));
+ EXPECT_EQ(*controllerRaw, collection.FetchPositionByFacilityAndFrequency("ESX", 120.620));
+ }
} // namespace Controller
} // namespace UKControllerPluginTest
diff --git a/test/test/controller/TranslateFrequencyAbbreviationTest.cpp b/test/test/controller/TranslateFrequencyAbbreviationTest.cpp
new file mode 100644
index 000000000..ecbc26f49
--- /dev/null
+++ b/test/test/controller/TranslateFrequencyAbbreviationTest.cpp
@@ -0,0 +1,34 @@
+#include "pch/pch.h"
+#include "controller/TranslateFrequencyAbbreviation.h"
+
+using UKControllerPlugin::Controller::TranslateFrequencyAbbreviation;
+
+namespace UKControllerPluginTest {
+ namespace Controller {
+
+ TEST(TranslateFrequencyAbbreviation, ItTranslatesEssexAbbreviation)
+ {
+ EXPECT_EQ("ESSEX", TranslateFrequencyAbbreviation("ESX"));
+ }
+
+ TEST(TranslateFrequencyAbbreviation, ItTranslatesSolentAbbreviation)
+ {
+ EXPECT_EQ("SOLENT", TranslateFrequencyAbbreviation("SOL"));
+ }
+
+ TEST(TranslateFrequencyAbbreviation, ItTranslatesThamesAbbreviation)
+ {
+ EXPECT_EQ("THAMES", TranslateFrequencyAbbreviation("THA"));
+ }
+
+ TEST(TranslateFrequencyAbbreviation, ItTranslatesThamesAbbreviation2)
+ {
+ EXPECT_EQ("THAMES", TranslateFrequencyAbbreviation("TMS"));
+ }
+
+ TEST(TranslateFrequencyAbbreviation, ItReturnsFacilityIfNoTranslation)
+ {
+ EXPECT_EQ("EGKK", TranslateFrequencyAbbreviation("EGKK"));
+ }
+ } // namespace Controller
+} // namespace UKControllerPluginTest