Skip to content

Commit

Permalink
Merge branch 'hotfix/versionCheck' into release/1.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
svengcz committed Apr 21, 2023
2 parents 271b520 + 8c1c9cd commit b57fddb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace {
const char *PLUGIN_NAME{ "vACDM" };
const char *PLUGIN_VERSION{ "@CMAKE_PROJECT_VERSION@" };
const char *PLUGIN_AUTHOR{ "-" };
const char *PLUGIN_LICENSE{ "-" };
const char* WEBAPI_VERSION{ "10" };
const char *PLUGIN_LICENSE{ "GPLv3" };

static constexpr std::uint8_t PLUGIN_VERSION_MAJOR = @CMAKE_PROJECT_VERSION_MAJOR@;
static constexpr std::uint8_t PLUGIN_VERSION_MINOR = @CMAKE_PROJECT_VERSION_MINOR@;
static constexpr std::uint8_t PLUGIN_VERSION_PATCH = @CMAKE_PROJECT_VERSION_PATCH@;
}
7 changes: 2 additions & 5 deletions com/Server.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#include "Server.h"
#include "Version.h"
#include "logging/Logger.h"

using namespace vacdm;
using namespace vacdm::com;

static constexpr std::uint8_t ApiMajorVersion = 0;
static constexpr std::uint8_t ApiMinorVersion = 0;
static constexpr std::uint8_t ApiPatchVersion = 1;

static std::string __receivedDeleteData;
static std::string __receivedGetData;
static std::string __receivedPatchData;
Expand Down Expand Up @@ -152,7 +149,7 @@ bool Server::checkWepApi() {

logging::Logger::instance().log("Server", logging::Logger::Level::System, "Received API-version-message: " + __receivedGetData);
if (reader->parse(__receivedGetData.c_str(), __receivedGetData.c_str() + __receivedGetData.length(), &root, &errors)) {
if (ApiMajorVersion != root.get("major", Json::Value(-1)).asInt()) {
if (PLUGIN_VERSION_MAJOR != root.get("major", Json::Value(-1)).asInt()) {
this->m_errorCode = "Backend-version is incompatible. Please update the plugin.";
this->m_validWebApi = false;
}
Expand Down
8 changes: 6 additions & 2 deletions vACDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,22 @@ bool vACDM::OnCompileCommand(const char* sCommandLine) {
return false;

if (std::string::npos != message.find("MASTER")) {
bool userConnected = this->GetConnectionType() != EuroScopePlugIn::CONNECTION_TYPE_NO;
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) {
if (!userConnected) {
userIsNotEligibleMessage = "You are not logged in to the VATSIM network";
}
else 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";
userIsNotEligibleMessage = "You are logged in on a Sweatbox Server and Server does not allow Sweatbox connections " + std::to_string(this->GetConnectionType());
}
else {
this->DisplayUserMessage("vACDM", PLUGIN_NAME, "Executing vACDM as the MASTER", true, true, true, true, false);
Expand Down

0 comments on commit b57fddb

Please sign in to comment.