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 --- .gitignore | 1 + CMakeLists.txt | 7 ++++++- ap_state.cpp | 40 ++++++++++++++++++++++++---------------- ap_state.h | 2 -- game_data.cpp | 7 +++++-- game_data.h | 1 + 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index d008edb..a7cadc7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ builds/ assets/LL1.yaml .DS_Store +.vs diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d9a111..fea5d7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,11 @@ project (lingo_ap_tracker) set(CMAKE_BUILD_TYPE Debug) +if (MSVC) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +set(CMAKE_WIN32_EXECUTABLE true) +endif(MSVC) + find_package(wxWidgets CONFIG REQUIRED) find_package(OpenSSL REQUIRED) find_package(yaml-cpp REQUIRED) @@ -36,6 +41,6 @@ add_executable(lingo_ap_tracker eye_indicator.cpp tracker_state.cpp ) -set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) +set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 20) set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) target_link_libraries(lingo_ap_tracker PRIVATE OpenSSL::SSL OpenSSL::Crypto wx::core wx::base yaml-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; } diff --git a/ap_state.h b/ap_state.h index d815f93..5ed7574 100644 --- a/ap_state.h +++ b/ap_state.h @@ -1,7 +1,6 @@ #ifndef AP_STATE_H_664A4180 #define AP_STATE_H_664A4180 -#include #include #include #include @@ -40,7 +39,6 @@ class APState { TrackerFrame* tracker_frame_; - std::unique_ptr apclient_; bool client_active_ = false; std::mutex client_mutex_; diff --git a/game_data.cpp b/game_data.cpp index b1504de..80ffd97 100644 --- a/game_data.cpp +++ b/game_data.cpp @@ -308,7 +308,10 @@ int GameData::AddOrGetDoor(std::string room, std::string door) { if (!door_by_id_.count(full_name)) { door_by_id_[full_name] = doors_.size(); - doors_.push_back({.name = door, .room = AddOrGetRoom(room)}); + doors_.push_back({ + .room = AddOrGetRoom(room), + .name = door + }); } return door_by_id_[full_name]; @@ -321,7 +324,7 @@ int GameData::AddOrGetPanel(std::string room, std::string panel) { int panel_id = panels_.size(); panel_by_id_[full_name] = panel_id; panels_.push_back( - {.id = panel_id, .name = panel, .room = AddOrGetRoom(room)}); + {.id = panel_id, .room = AddOrGetRoom(room), .name = panel}); } return panel_by_id_[full_name]; diff --git a/game_data.h b/game_data.h index 3c50b68..6ee277b 100644 --- a/game_data.h +++ b/game_data.h @@ -2,6 +2,7 @@ #define GAME_DATA_H_9C42AC51 #include +#include #include #include -- cgit 1.4.1