Skip to content

Commit

Permalink
Utilize ESE parser to load radio callsigns
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
Kirollos committed Apr 11, 2024
1 parent 55a4231 commit 4a24cdf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions DiscordEuroscope/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "stdafx.h"
#include "ConfigManager.h"
#include "MessageFormatter.h"
#include "ESEHandler.h"
#include <string>
#include <sstream>
#include <fstream>
Expand Down Expand Up @@ -132,6 +133,24 @@ namespace DiscordEuroScope_Configuration

void ConfigManager::LoadRadioCallsigns()
{
if (json_document.HasMember("load_from_ese")) {
if (json_document["load_from_ese"].IsBool() && json_document["load_from_ese"].GetBool() && json_document["path_to_ese"].IsString())
{
std::string relative_to_full_path;
std::string relative_path = json_document["path_to_ese"].GetString();
if (relative_path[1] == ':')
relative_to_full_path = relative_path;
else
relative_to_full_path = this->file_path.substr(0, this->file_path.find_last_of('\\') + 1) + relative_path;
if (ESEHandler::LocateESEFile(relative_to_full_path))
{
int p = ESEHandler::ParsePositions();
ESEHandler::GetRadioCallsigns(data.RadioCallsigns);
return;
}
}
}

assert(json_document["radio_callsigns"].IsObject());
data.RadioCallsigns.clear();
for (auto& it : json_document["radio_callsigns"].GetObject())
Expand Down

0 comments on commit 4a24cdf

Please sign in to comment.