Skip to content

Commit 4a24cdf

Browse files
committed
Utilize ESE parser to load radio callsigns
WIP
1 parent 55a4231 commit 4a24cdf

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

DiscordEuroscope/ConfigManager.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "stdafx.h"
1919
#include "ConfigManager.h"
2020
#include "MessageFormatter.h"
21+
#include "ESEHandler.h"
2122
#include <string>
2223
#include <sstream>
2324
#include <fstream>
@@ -132,6 +133,24 @@ namespace DiscordEuroScope_Configuration
132133

133134
void ConfigManager::LoadRadioCallsigns()
134135
{
136+
if (json_document.HasMember("load_from_ese")) {
137+
if (json_document["load_from_ese"].IsBool() && json_document["load_from_ese"].GetBool() && json_document["path_to_ese"].IsString())
138+
{
139+
std::string relative_to_full_path;
140+
std::string relative_path = json_document["path_to_ese"].GetString();
141+
if (relative_path[1] == ':')
142+
relative_to_full_path = relative_path;
143+
else
144+
relative_to_full_path = this->file_path.substr(0, this->file_path.find_last_of('\\') + 1) + relative_path;
145+
if (ESEHandler::LocateESEFile(relative_to_full_path))
146+
{
147+
int p = ESEHandler::ParsePositions();
148+
ESEHandler::GetRadioCallsigns(data.RadioCallsigns);
149+
return;
150+
}
151+
}
152+
}
153+
135154
assert(json_document["radio_callsigns"].IsObject());
136155
data.RadioCallsigns.clear();
137156
for (auto& it : json_document["radio_callsigns"].GetObject())

0 commit comments

Comments
 (0)