Skip to content

Commit

Permalink
Merge branch 'main' into feature/AORT,ASRT&colorizeFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoKle authored Apr 19, 2023
2 parents 623c18b + a40372a commit 07b0be1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
10 changes: 6 additions & 4 deletions com/Airport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,25 @@ void Airport::updateTobt(const std::string& callsign, const std::chrono::utc_clo

auto it = this->m_flights.find(callsign);
if (it != this->m_flights.end() && it->second[FlightServer].callsign == callsign) {
bool resetTsat = (tobt == types::defaultTime && true == manualTobt) || tobt >= it->second[FlightConsolidated].tsat;
Json::Value root;

root["callsign"] = callsign;
root["vacdm"] = Json::Value();
root["vacdm"]["tobt"] = Airport::timestampToIsoString(tobt);
root["vacdm"]["tsat"] = Airport::timestampToIsoString(types::defaultTime);
if (false == manualTobt) {
if (true == resetTsat)
root["vacdm"]["tsat"] = Airport::timestampToIsoString(types::defaultTime);
if (false == manualTobt)
root["vacdm"]["tobt_state"] = "CONFIRMED";
}
root["vacdm"]["ttot"] = root["vacdm"]["tsat"].asString();
root["vacdm"]["asat"] = root["vacdm"]["tsat"].asString();
root["vacdm"]["aobt"] = root["vacdm"]["tsat"].asString();
root["vacdm"]["atot"] = root["vacdm"]["tsat"].asString();

it->second[FlightEuroscope].lastUpdate = std::chrono::utc_clock::now();
it->second[FlightConsolidated].tobt = tobt;
it->second[FlightConsolidated].tsat = types::defaultTime;
if (true == resetTsat)
it->second[FlightConsolidated].tsat = types::defaultTime;
it->second[FlightConsolidated].ttot = types::defaultTime;
it->second[FlightConsolidated].exot = types::defaultTime;
it->second[FlightConsolidated].asat = types::defaultTime;
Expand Down
35 changes: 20 additions & 15 deletions vACDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,25 +651,30 @@ bool vACDM::OnCompileCommand(const char* sCommandLine) {
if (0 != message.find(".VACDM"))
return false;

// check if the controller is logged in as _OBS
bool isObs = false;
if (false == this->m_config.masterAsObserver && std::string_view(this->ControllerMyself().GetCallsign()).ends_with("_OBS") == true) {
this->DisplayUserMessage("vACDM", PLUGIN_NAME, "Server does not allow OBS as master", true, true, true, true, false);
isObs = true;
}

bool inSweatbox = false;
if (false == this->m_config.masterInSweatbox) {
this->DisplayUserMessage("vACDM", PLUGIN_NAME, "Server does not allow sweatbox-connections as master", true, true, true, true, false);
inSweatbox = this->GetConnectionType() != EuroScopePlugIn::CONNECTION_TYPE_DIRECT;
}

if (std::string::npos != message.find("MASTER")) {
this->DisplayUserMessage("vACDM", PLUGIN_NAME, "Executing vACDM as the MASTER", true, true, true, true, false);
if (isObs == false && inSweatbox == false) {
bool userIsInSweatbox = this->GetConnectionType() != EuroScopePlugIn::CONNECTION_TYPE_DIRECT;
bool userIsObs = std::string_view(this->ControllerMyself().GetCallsign()).ends_with("_OBS") == true;
bool serverAllowsObsAsMaster = this->m_config.masterAsObserver;
bool serverAllowsSweatboxAsMaster = this->m_config.masterInSweatbox;

std::string userIsNotEligibleMessage;

if (userIsObs && !serverAllowsObsAsMaster) {
userIsNotEligibleMessage = "You are logged in as Observer and Server does not allow Observers to be Master";
}
else if (userIsInSweatbox && !serverAllowsSweatboxAsMaster) {
userIsNotEligibleMessage = "You are logged in on a Sweatbox Server and Server does not allow Sweatbox connections";
}
else {
this->DisplayUserMessage("vACDM", PLUGIN_NAME, "Executing vACDM as the MASTER", true, true, true, true, false);
logging::Logger::instance().log("vACDM", logging::Logger::Level::Info, "Switched to MASTER");
com::Server::instance().setMaster(true);

return true;
}

this->DisplayUserMessage("vACDM", PLUGIN_NAME, "Cannot upgrade to Master", true, true, true, true, false);
this->DisplayUserMessage("vACDM", PLUGIN_NAME, userIsNotEligibleMessage.c_str(), true, true, true, true, false);
return true;
}
else if (std::string::npos != message.find("SLAVE")) {
Expand Down

0 comments on commit 07b0be1

Please sign in to comment.