From 47e59ea969c775bea316b1a910c845a7c8482091 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 3 May 2023 01:29:41 -0400 Subject: Changes to get it to compile on Windows --- ap_state.cpp | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'ap_state.cpp') diff --git a/ap_state.cpp b/ap_state.cpp index 910feb7..2c8ba0a 100644 --- a/ap_state.cpp +++ b/ap_state.cpp @@ -1,8 +1,12 @@ #include "ap_state.h" -#include +#define HAS_STD_FILESYSTEM +#define _WEBSOCKETPP_CPP11_STRICT_ +#pragma comment(lib, "crypt32") +#include #include +#include #include #include #include @@ -17,13 +21,15 @@ constexpr int AP_REVISION = 0; constexpr int ITEM_HANDLING = 7; // <- all +static APClient* apclient = nullptr; + APState::APState() { std::thread([this]() { for (;;) { { std::lock_guard client_guard(client_mutex_); - if (apclient_) { - apclient_->poll(); + if (apclient) { + apclient->poll(); } } @@ -39,11 +45,13 @@ void APState::Connect(std::string server, std::string player, { std::lock_guard client_guard(client_mutex_); - if (apclient_) { - apclient_->reset(); + if (apclient) { + apclient->reset(); + delete apclient; + apclient = nullptr; } - apclient_ = std::make_unique(ap_get_uuid(""), "Lingo", server); + apclient = new APClient(ap_get_uuid(""), "Lingo", server); } inventory_.clear(); @@ -52,15 +60,15 @@ void APState::Connect(std::string server, std::string player, bool connected = false; bool has_connection_result = false; - apclient_->set_room_info_handler([&]() { + apclient->set_room_info_handler([&]() { tracker_frame_->SetStatusMessage( "Connected to Archipelago server. Authenticating..."); - apclient_->ConnectSlot(player, password, ITEM_HANDLING, {"Tracker"}, + apclient->ConnectSlot(player, password, ITEM_HANDLING, {"Tracker"}, {AP_MAJOR, AP_MINOR, AP_REVISION}); }); - apclient_->set_location_checked_handler( + apclient->set_location_checked_handler( [&](const std::list& locations) { for (const int64_t location_id : locations) { checked_locations_.insert(location_id); @@ -70,15 +78,15 @@ void APState::Connect(std::string server, std::string player, RefreshTracker(); }); - apclient_->set_slot_disconnected_handler([&]() { + apclient->set_slot_disconnected_handler([&]() { tracker_frame_->SetStatusMessage("Disconnected from Archipelago."); }); - apclient_->set_socket_disconnected_handler([&]() { + apclient->set_socket_disconnected_handler([&]() { tracker_frame_->SetStatusMessage("Disconnected from Archipelago."); }); - apclient_->set_items_received_handler( + apclient->set_items_received_handler( [&](const std::list& items) { for (const APClient::NetworkItem& item : items) { // TODO: Progressive items. @@ -90,7 +98,7 @@ void APState::Connect(std::string server, std::string player, RefreshTracker(); }); - apclient_->set_slot_connected_handler([&](const nlohmann::json& slot_data) { + apclient->set_slot_connected_handler([&](const nlohmann::json& slot_data) { tracker_frame_->SetStatusMessage("Connected to Archipelago!"); door_shuffle_mode_ = slot_data["shuffle_doors"].get(); @@ -100,7 +108,7 @@ void APState::Connect(std::string server, std::string player, has_connection_result = true; }); - apclient_->set_slot_refused_handler( + apclient->set_slot_refused_handler( [&](const std::list& errors) { connected = false; has_connection_result = true; @@ -163,7 +171,7 @@ void APState::Connect(std::string server, std::string player, section_id++) { const Location& location = map_area.locations.at(section_id); - int64_t ap_id = apclient_->get_location_id(location.ap_location_name); + int64_t ap_id = apclient->get_location_id(location.ap_location_name); if (ap_id == APClient::INVALID_NAME_ID) { std::cout << "Could not find AP location ID for " << location.ap_location_name << std::endl; @@ -232,7 +240,7 @@ void APState::RefreshTracker() { } int64_t APState::GetItemId(const std::string& item_name) { - int64_t ap_id = apclient_->get_item_id(item_name); + int64_t ap_id = apclient->get_item_id(item_name); if (ap_id == APClient::INVALID_NAME_ID) { std::cout << "Could not find AP item ID for " << item_name << std::endl; } -- cgit 1.4.1