Skip to content

Commit 14b40f2

Browse files
authored
Merge pull request #589 from VATSIM-UK/blank-intention-codes
Fixes #560 - Use empty string as default intention code
2 parents 784cffa + 099d77e commit 14b40f2

2 files changed

Lines changed: 23 additions & 18 deletions

File tree

src/plugin/intention/IntentionCodeCollectionFactory.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ namespace UKControllerPlugin::IntentionCode {
122122
if (!codes.is_array()) {
123123
LogWarning("Intention codes dependency is invalid");
124124
// Add the fallback - full airfield ICAO
125-
collection->Add(std::make_shared<IntentionCodeModel>(
126-
-1,
127-
std::make_unique<FullAirfieldIdentifier>(),
128-
std::make_unique<AllOf>(std::list<std::shared_ptr<Condition>>({})),
129-
std::unique_ptr<IntentionCodeMetadata>(new IntentionCodeMetadata)));
125+
collection->Add(
126+
std::make_shared<IntentionCodeModel>(
127+
-1,
128+
std::make_unique<FullAirfieldIdentifier>(),
129+
std::make_unique<AllOf>(std::list<std::shared_ptr<Condition>>({})),
130+
std::unique_ptr<IntentionCodeMetadata>(new IntentionCodeMetadata)));
130131
return collection;
131132
}
132133

@@ -137,21 +138,24 @@ namespace UKControllerPlugin::IntentionCode {
137138
}
138139

139140
auto metadata = std::unique_ptr<IntentionCodeMetadata>(new IntentionCodeMetadata);
140-
collection->Add(std::make_shared<IntentionCodeModel>(
141-
code.at("id").get<int>(),
142-
MakeCode(code.at("code")),
143-
std::make_unique<AllOf>(MakeConditions(code.at("conditions"), generator, activeControllers, *metadata))
141+
collection->Add(
142+
std::make_shared<IntentionCodeModel>(
143+
code.at("id").get<int>(),
144+
MakeCode(code.at("code")),
145+
std::make_unique<AllOf>(
146+
MakeConditions(code.at("conditions"), generator, activeControllers, *metadata))
144147

145-
,
146-
std::move(metadata)));
148+
,
149+
std::move(metadata)));
147150
}
148151

149-
// Add full airfield icao fallback
150-
collection->Add(std::make_shared<IntentionCodeModel>(
151-
-1,
152-
std::make_unique<FullAirfieldIdentifier>(),
153-
std::make_unique<AllOf>(std::list<std::shared_ptr<Condition>>({})),
154-
std::unique_ptr<IntentionCodeMetadata>(new IntentionCodeMetadata)));
152+
// Add blank as fallback
153+
collection->Add(
154+
std::make_shared<IntentionCodeModel>(
155+
-1,
156+
std::make_unique<SingleCode>(""),
157+
std::make_unique<AllOf>(std::list<std::shared_ptr<Condition>>({})),
158+
std::unique_ptr<IntentionCodeMetadata>(new IntentionCodeMetadata)));
155159

156160
LogInfo("Loaded " + std::to_string(collection->Count()) + " intention codes");
157161
return collection;

test/plugin/intention/IntentionCodeCollectionFactoryTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ namespace UKControllerPluginTest::IntentionCode {
433433
EXPECT_EQ(-1, intention->Id());
434434

435435
try {
436-
static_cast<void>(dynamic_cast<const FullAirfieldIdentifier&>(intention->Generator()));
436+
static_cast<void>(dynamic_cast<const SingleCode&>(intention->Generator()));
437+
EXPECT_EQ("", dynamic_cast<const SingleCode&>(intention->Generator()).Code());
437438
} catch (std::bad_cast&) {
438439
FAIL();
439440
}

0 commit comments

Comments
 (0)