From da8f3caeee5b01c38db30ebb146b76dc41f9ca74 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 21 Apr 2024 14:36:15 -0400 Subject: Expand sphere 1 in door shuffle + no ECH --- src/ap_state.cpp | 17 ++++++++++++++--- src/game_data.cpp | 4 ++++ src/game_data.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ap_state.cpp b/src/ap_state.cpp index aeed914..9aceef6 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -473,16 +473,27 @@ int AP_GetMasteryRequirement() { return GetState().mastery_requirement; } int AP_GetLevel2Requirement() { return GetState().level_2_requirement; } bool AP_IsLocationVisible(int classification) { + int world_state = 0; + switch (GetState().location_checks) { case kNORMAL_LOCATIONS: - return classification & kLOCATION_NORMAL; + world_state = kLOCATION_NORMAL; + break; case kREDUCED_LOCATIONS: - return classification & kLOCATION_REDUCED; + world_state = kLOCATION_REDUCED; + break; case kPANELSANITY: - return classification & kLOCATION_INSANITY; + world_state = kLOCATION_INSANITY; + break; default: return false; } + + if (GetState().door_shuffle_mode && !GetState().early_color_hallways) { + world_state |= kLOCATION_SMALL_SPHERE_ONE; + } + + return (world_state & classification); } VictoryCondition AP_GetVictoryCondition() { diff --git a/src/game_data.cpp b/src/game_data.cpp index c98f532..dbc269a 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -534,6 +534,10 @@ struct GameData { } } + if (room_name == "Starting Room") { + classification |= kLOCATION_SMALL_SPHERE_ONE; + } + int area_id = AddOrGetArea(area_name); MapArea &map_area = map_areas_[area_id]; // room field should be the original room ID diff --git a/src/game_data.h b/src/game_data.h index cd09627..88f8a13 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -22,6 +22,7 @@ enum class LingoColor { constexpr int kLOCATION_NORMAL = 1; constexpr int kLOCATION_REDUCED = 2; constexpr int kLOCATION_INSANITY = 4; +constexpr int kLOCATION_SMALL_SPHERE_ONE = 8; enum class EntranceType { kNormal, -- cgit 1.4.1 From 3b3c3ca4ed98c8d1e884f6c9f8f63d7b7c76e37b Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 10 Jun 2024 18:11:06 -0400 Subject: Fixed subway map when eye_painting is mapped --- src/game_data.cpp | 10 ++++------ src/game_data.h | 2 +- src/subway_map.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/game_data.cpp b/src/game_data.cpp index 6f1a2e4..85f7f51 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -839,13 +839,11 @@ const SubwayItem &GD_GetSubwayItem(int id) { return GetState().subway_items_.at(id); } -int GD_GetSubwayItemForPainting(const std::string &painting_id) { -#ifndef NDEBUG - if (!GetState().subway_item_by_painting_.count(painting_id)) { - wxLogError("No subway item for painting %s", painting_id); +std::optional GD_GetSubwayItemForPainting(const std::string &painting_id) { + if (GetState().subway_item_by_painting_.count(painting_id)) { + return GetState().subway_item_by_painting_.at(painting_id); } -#endif - return GetState().subway_item_by_painting_.at(painting_id); + return std::nullopt; } int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { diff --git a/src/game_data.h b/src/game_data.h index e37c276..66f3e0e 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -164,7 +164,7 @@ const std::vector& GD_GetSunwarpDoors(); int GD_GetRoomForSunwarp(int index); const std::vector& GD_GetSubwayItems(); const SubwayItem& GD_GetSubwayItem(int id); -int GD_GetSubwayItemForPainting(const std::string& painting_id); +std::optional GD_GetSubwayItemForPainting(const std::string& painting_id); int GD_GetSubwayItemForSunwarp(const SubwaySunwarp& sunwarp); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 408c4f0..5c99567 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -147,9 +147,13 @@ void SubwayMap::UpdateIndicators() { checked_paintings_.insert(painting_id); if (AP_GetPaintingMapping().count(painting_id)) { - networks_.AddLink(GD_GetSubwayItemForPainting(painting_id), - GD_GetSubwayItemForPainting( - AP_GetPaintingMapping().at(painting_id))); + std::optional from_id = GD_GetSubwayItemForPainting(painting_id); + std::optional to_id = GD_GetSubwayItemForPainting( + AP_GetPaintingMapping().at(painting_id)); + + if (from_id && to_id) { + networks_.AddLink(*from_id, *to_id); + } } } } -- cgit 1.4.1 From 33bf1f9653ed608de5554940dc8a0c3f5dc7e4ea Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 10 Jun 2024 19:13:22 -0400 Subject: Go back to old logging system Brought in libfmt to handle string formatting and replace a bunch of ostringstream uses. --- CMakeLists.txt | 5 +++- src/ap_state.cpp | 79 +++++++++++++++++++++++++++--------------------------- src/game_data.cpp | 63 +++++++++++++++++++++---------------------- src/logger.cpp | 32 ++++++++++++++++++++++ src/logger.h | 8 ++++++ src/main.cpp | 12 --------- src/subway_map.cpp | 14 +++++----- src/version.h | 7 +++-- vcpkg.json | 3 ++- 9 files changed, 126 insertions(+), 97 deletions(-) create mode 100644 src/logger.cpp create mode 100644 src/logger.h (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index cd62c55..f9f1117 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ find_package(wxWidgets CONFIG REQUIRED) find_package(OpenSSL REQUIRED) find_package(yaml-cpp REQUIRED) find_package(websocketpp REQUIRED) +find_package(fmt REQUIRED) include_directories( vendor/hkutil @@ -22,6 +23,7 @@ include_directories( ${yaml-cpp_INCLUDE_DIRS} ${OpenSSL_INCLUDE_DIRS} vendor/whereami + ${fmt_INCLUDE_DIRS} vendor ) @@ -45,8 +47,9 @@ add_executable(lingo_ap_tracker "src/global.cpp" "src/subway_map.cpp" "src/network_set.cpp" + "src/logger.cpp" "vendor/whereami/whereami.c" ) 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 websocketpp::websocketpp wx::core wx::base wx::net yaml-cpp::yaml-cpp) +target_link_libraries(lingo_ap_tracker PRIVATE fmt::fmt OpenSSL::SSL OpenSSL::Crypto websocketpp::websocketpp wx::core wx::base wx::net yaml-cpp::yaml-cpp) diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 8ff0ccd..e4d892b 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -4,6 +4,7 @@ #define _WEBSOCKETPP_CPP11_STRICT_ #pragma comment(lib, "crypt32") +#include #include #include @@ -21,6 +22,7 @@ #include #include "game_data.h" +#include "logger.h" #include "tracker_frame.h" #include "tracker_state.h" @@ -75,7 +77,7 @@ struct APState { void Connect(std::string server, std::string player, std::string password) { if (!initialized) { - wxLogVerbose("Initializing APState..."); + TrackerLog("Initializing APState..."); std::thread([this]() { for (;;) { @@ -91,14 +93,14 @@ struct APState { }).detach(); for (int panel_id : GD_GetAchievementPanels()) { - tracked_data_storage_keys.push_back( - "Achievement|" + GD_GetPanel(panel_id).achievement_name); + tracked_data_storage_keys.push_back(fmt::format( + "Achievement|{}", GD_GetPanel(panel_id).achievement_name)); } for (const MapArea& map_area : GD_GetMapAreas()) { for (const Location& location : map_area.locations) { tracked_data_storage_keys.push_back( - "Hunt|" + std::to_string(location.ap_location_id)); + fmt::format("Hunt|{}", location.ap_location_id)); } } @@ -109,10 +111,10 @@ struct APState { } tracker_frame->SetStatusMessage("Connecting to Archipelago server...."); - wxLogStatus("Connecting to Archipelago server (%s)...", server); + TrackerLog(fmt::format("Connecting to Archipelago server ({})...", server)); { - wxLogVerbose("Destroying old AP client..."); + TrackerLog("Destroying old AP client..."); std::lock_guard client_guard(client_mutex); @@ -158,10 +160,10 @@ struct APState { apclient->set_room_info_handler([this, player, password]() { inventory.clear(); - wxLogStatus("Connected to Archipelago server. Authenticating as %s %s", - player, - (password.empty() ? "without password" - : "with password " + password)); + TrackerLog(fmt::format( + "Connected to Archipelago server. Authenticating as {} {}", player, + (password.empty() ? "without password" + : "with password " + password))); tracker_frame->SetStatusMessage( "Connected to Archipelago server. Authenticating..."); @@ -173,7 +175,7 @@ struct APState { [this](const std::list& locations) { for (const int64_t location_id : locations) { checked_locations.insert(location_id); - wxLogVerbose("Location: %lld", location_id); + TrackerLog(fmt::format("Location: {}", location_id)); } RefreshTracker(false); @@ -182,14 +184,14 @@ struct APState { apclient->set_slot_disconnected_handler([this]() { tracker_frame->SetStatusMessage( "Disconnected from Archipelago. Attempting to reconnect..."); - wxLogStatus( + TrackerLog( "Slot disconnected from Archipelago. Attempting to reconnect..."); }); apclient->set_socket_disconnected_handler([this]() { tracker_frame->SetStatusMessage( "Disconnected from Archipelago. Attempting to reconnect..."); - wxLogStatus( + TrackerLog( "Socket disconnected from Archipelago. Attempting to reconnect..."); }); @@ -197,7 +199,7 @@ struct APState { [this](const std::list& items) { for (const APClient::NetworkItem& item : items) { inventory[item.item]++; - wxLogVerbose("Item: %lld", item.item); + TrackerLog(fmt::format("Item: {}", item.item)); } RefreshTracker(false); @@ -222,10 +224,10 @@ struct APState { apclient->set_slot_connected_handler([this, &connection_mutex]( const nlohmann::json& slot_data) { tracker_frame->SetStatusMessage("Connected to Archipelago!"); - wxLogStatus("Connected to Archipelago!"); + TrackerLog("Connected to Archipelago!"); data_storage_prefix = - "Lingo_" + std::to_string(apclient->get_player_number()) + "_"; + fmt::format("Lingo_{}_", apclient->get_player_number()); door_shuffle_mode = slot_data["shuffle_doors"].get(); color_shuffle = slot_data["shuffle_colors"].get() == 1; painting_shuffle = slot_data["shuffle_paintings"].get() == 1; @@ -277,18 +279,18 @@ struct APState { corrected_keys.push_back(data_storage_prefix + key); } - { - std::ostringstream vdsks; - vdsks << "_read_client_status_" << apclient->get_team_number() << "_" - << apclient->get_player_number(); - victory_data_storage_key = vdsks.str(); - } + victory_data_storage_key = + fmt::format("_read_client_status_{}_{}", apclient->get_team_number(), + apclient->get_player_number()); corrected_keys.push_back(victory_data_storage_key); apclient->Get(corrected_keys); apclient->SetNotify(corrected_keys); + ResetReachabilityRequirements(); + RefreshTracker(true); + { std::lock_guard connection_lock(connection_mutex); if (!has_connection_result) { @@ -333,7 +335,7 @@ struct APState { } std::string full_message = hatkirby::implode(error_messages, " "); - wxLogError(wxString(full_message)); + TrackerLog(full_message); wxMessageBox(full_message, "Connection failed", wxOK | wxICON_ERROR); }); @@ -355,7 +357,7 @@ struct APState { DestroyClient(); tracker_frame->SetStatusMessage("Disconnected from Archipelago."); - wxLogStatus("Timeout while connecting to Archipelago server."); + TrackerLog("Timeout while connecting to Archipelago server."); wxMessageBox("Timeout while connecting to Archipelago server.", "Connection failed", wxOK | wxICON_ERROR); @@ -374,9 +376,6 @@ struct APState { } if (connected) { - ResetReachabilityRequirements(); - RefreshTracker(true); - } else { client_active = false; } } @@ -384,11 +383,12 @@ struct APState { void HandleDataStorage(const std::string& key, const nlohmann::json& value) { if (value.is_boolean()) { data_storage[key] = value.get(); - wxLogVerbose("Data storage %s retrieved as %s", key, - (value.get() ? "true" : "false")); + TrackerLog(fmt::format("Data storage {} retrieved as {}", key, + (value.get() ? "true" : "false"))); } else if (value.is_number()) { data_storage[key] = value.get(); - wxLogVerbose("Data storage %s retrieved as %d", key, value.get()); + TrackerLog(fmt::format("Data storage {} retrieved as {}", key, + value.get())); } else if (value.is_object()) { if (key.ends_with("PlayerPos")) { auto map_value = value.get>(); @@ -397,7 +397,7 @@ struct APState { data_storage[key] = value.get>(); } - wxLogVerbose("Data storage %s retrieved as dictionary", key); + TrackerLog(fmt::format("Data storage {} retrieved as dictionary", key)); } else if (value.is_null()) { if (key.ends_with("PlayerPos")) { player_pos = std::nullopt; @@ -405,7 +405,7 @@ struct APState { data_storage.erase(key); } - wxLogVerbose("Data storage %s retrieved as null", key); + TrackerLog(fmt::format("Data storage {} retrieved as null", key)); } else if (value.is_array()) { auto list_value = value.get>(); @@ -416,8 +416,8 @@ struct APState { data_storage[key] = list_value; } - wxLogVerbose("Data storage %s retrieved as list: [%s]", key, - hatkirby::implode(list_value, ", ")); + TrackerLog(fmt::format("Data storage {} retrieved as list: [{}]", key, + hatkirby::implode(list_value, ", "))); } } @@ -427,7 +427,7 @@ struct APState { bool HasCheckedHuntPanel(int location_id) { std::string key = - data_storage_prefix + "Hunt|" + std::to_string(location_id); + fmt::format("{}Hunt|{}", data_storage_prefix, location_id); return data_storage.count(key) && std::any_cast(data_storage.at(key)); } @@ -436,12 +436,13 @@ struct APState { } bool HasAchievement(const std::string& name) { - std::string key = data_storage_prefix + "Achievement|" + name; + std::string key = + fmt::format("{}Achievement|{}", data_storage_prefix, name); return data_storage.count(key) && std::any_cast(data_storage.at(key)); } const std::set& GetCheckedPaintings() { - std::string key = data_storage_prefix + "Paintings"; + std::string key = fmt::format("{}Paintings", data_storage_prefix); if (!data_storage.count(key)) { data_storage[key] = std::set(); } @@ -458,7 +459,7 @@ struct APState { } void RefreshTracker(bool reset) { - wxLogVerbose("Refreshing display..."); + TrackerLog("Refreshing display..."); RecalculateReachability(); @@ -472,7 +473,7 @@ struct APState { int64_t GetItemId(const std::string& item_name) { int64_t ap_id = apclient->get_item_id(item_name); if (ap_id == APClient::INVALID_NAME_ID) { - wxLogError("Could not find AP item ID for %s", item_name); + TrackerLog(fmt::format("Could not find AP item ID for {}", item_name)); } return ap_id; diff --git a/src/game_data.cpp b/src/game_data.cpp index 85f7f51..77e435a 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -1,11 +1,6 @@ #include "game_data.h" -#include - -#ifndef WX_PRECOMP -#include -#endif - +#include #include #include @@ -13,6 +8,7 @@ #include #include "global.h" +#include "logger.h" namespace { @@ -36,7 +32,7 @@ LingoColor GetColorForString(const std::string &str) { } else if (str == "purple") { return LingoColor::kPurple; } else { - wxLogError("Invalid color: %s", str); + TrackerLog(fmt::format("Invalid color: {}", str)); return LingoColor::kNone; } @@ -88,7 +84,7 @@ struct GameData { ap_id_by_color_[GetColorForString(input_name)] = ids_config["special_items"][color_name].as(); } else { - wxLogError("Missing AP item ID for color %s", color_name); + TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); } }; @@ -165,7 +161,8 @@ struct GameData { // This shouldn't happen. std::ostringstream formatted; formatted << entrance_it; - wxLogError("Error reading game data: %s", formatted.str()); + TrackerLog( + fmt::format("Error reading game data: {}", formatted.str())); break; } } @@ -290,8 +287,9 @@ struct GameData { [panels_[panel_id].name] .as(); } else { - wxLogError("Missing AP location ID for panel %s - %s", - rooms_[room_id].name, panels_[panel_id].name); + TrackerLog(fmt::format("Missing AP location ID for panel {} - {}", + rooms_[room_id].name, + panels_[panel_id].name)); } } } @@ -354,8 +352,9 @@ struct GameData { [doors_[door_id].name]["item"] .as(); } else { - wxLogError("Missing AP item ID for door %s - %s", - rooms_[room_id].name, doors_[door_id].name); + TrackerLog(fmt::format("Missing AP item ID for door {} - {}", + rooms_[room_id].name, + doors_[door_id].name)); } } @@ -369,8 +368,8 @@ struct GameData { ids_config["door_groups"][doors_[door_id].group_name] .as(); } else { - wxLogError("Missing AP item ID for door group %s", - doors_[door_id].group_name); + TrackerLog(fmt::format("Missing AP item ID for door group {}", + doors_[door_id].group_name)); } } @@ -380,11 +379,11 @@ struct GameData { } else if (!door_it.second["skip_location"] && !door_it.second["event"]) { if (has_external_panels) { - wxLogError( - "%s - %s has panels from other rooms but does not have an " + TrackerLog(fmt::format( + "{} - {} has panels from other rooms but does not have an " "explicit location name and is not marked skip_location or " "event", - rooms_[room_id].name, doors_[door_id].name); + rooms_[room_id].name, doors_[door_id].name)); } doors_[door_id].location_name = @@ -404,8 +403,9 @@ struct GameData { [doors_[door_id].name]["location"] .as(); } else { - wxLogError("Missing AP location ID for door %s - %s", - rooms_[room_id].name, doors_[door_id].name); + TrackerLog(fmt::format("Missing AP location ID for door {} - {}", + rooms_[room_id].name, + doors_[door_id].name)); } } @@ -473,8 +473,8 @@ struct GameData { progressive_item_id = ids_config["progression"][progressive_item_name].as(); } else { - wxLogError("Missing AP item ID for progressive item %s", - progressive_item_name); + TrackerLog(fmt::format("Missing AP item ID for progressive item {}", + progressive_item_name)); } int index = 1; @@ -553,14 +553,13 @@ struct GameData { int area_id = AddOrGetArea(area_name); MapArea &map_area = map_areas_[area_id]; // room field should be the original room ID - map_area.locations.push_back( - {.name = section_name, - .ap_location_name = location_name, - .ap_location_id = panel.ap_location_id, - .room = panel.room, - .panels = {panel.id}, - .classification = classification, - .hunt = panel.hunt}); + map_area.locations.push_back({.name = section_name, + .ap_location_name = location_name, + .ap_location_id = panel.ap_location_id, + .room = panel.room, + .panels = {panel.id}, + .classification = classification, + .hunt = panel.hunt}); locations_by_name[location_name] = {area_id, map_area.locations.size() - 1}; } @@ -638,7 +637,7 @@ struct GameData { // Report errors. for (const std::string &area : malconfigured_areas_) { - wxLogError("Area data not found for: %s", area); + TrackerLog(fmt::format("Area data not found for: {}", area)); } // Read in subway items. @@ -709,7 +708,7 @@ struct GameData { for (const auto &[tag, items] : subway_tags) { if (items.size() == 1) { - wxLogWarning("Singleton subway item tag: %s", tag); + TrackerLog(fmt::format("Singleton subway item tag: {}", tag)); } } } diff --git a/src/logger.cpp b/src/logger.cpp new file mode 100644 index 0000000..09fc331 --- /dev/null +++ b/src/logger.cpp @@ -0,0 +1,32 @@ +#include "logger.h" + +#include +#include +#include + +#include "global.h" + +namespace { + +class Logger { + public: + Logger() : logfile_(GetAbsolutePath("debug.log")) {} + + void LogLine(const std::string& text) { + std::lock_guard guard(file_mutex_); + logfile_ << "[" << std::chrono::system_clock::now() << "] " << text + << std::endl; + logfile_.flush(); + } + + private: + std::ofstream logfile_; + std::mutex file_mutex_; +}; + +} // namespace + +void TrackerLog(std::string text) { + static Logger* instance = new Logger(); + instance->LogLine(text); +} diff --git a/src/logger.h b/src/logger.h new file mode 100644 index 0000000..a27839f --- /dev/null +++ b/src/logger.h @@ -0,0 +1,8 @@ +#ifndef LOGGER_H_9BDD07EA +#define LOGGER_H_9BDD07EA + +#include + +void TrackerLog(std::string message); + +#endif /* end of include guard: LOGGER_H_9BDD07EA */ diff --git a/src/main.cpp b/src/main.cpp index b327b25..1d7cc9e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,25 +4,13 @@ #include #endif -#include - #include "global.h" #include "tracker_config.h" #include "tracker_frame.h" -static std::ofstream* logfile; - class TrackerApp : public wxApp { public: virtual bool OnInit() { - logfile = new std::ofstream(GetAbsolutePath("debug.log")); - wxLog::SetActiveTarget(new wxLogStream(logfile)); - wxLog::SetVerbose(true); - -#ifndef NDEBUG - wxLog::SetActiveTarget(new wxLogWindow(nullptr, "Debug Log")); -#endif - GetTrackerConfig().Load(); TrackerFrame *frame = new TrackerFrame(); diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 5c99567..c7b2c8a 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "ap_state.h" @@ -85,10 +86,8 @@ void SubwayMap::OnConnect() { if (!AP_IsSunwarpShuffle() && subway_item.sunwarp && subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { - std::ostringstream tag; - tag << "sunwarp" << subway_item.sunwarp->dots; - - tagged[tag.str()].push_back(subway_item.id); + std::string tag = fmt::format("subway{}", subway_item.sunwarp->dots); + tagged[tag].push_back(subway_item.id); } if (!AP_IsPilgrimageEnabled() && @@ -100,8 +99,7 @@ void SubwayMap::OnConnect() { if (AP_IsSunwarpShuffle()) { for (const auto &[index, mapping] : AP_GetSunwarpMapping()) { - std::ostringstream tag; - tag << "sunwarp" << mapping.dots; + std::string tag = fmt::format("sunwarp{}", mapping.dots); SubwaySunwarp fromWarp; if (index < 6) { @@ -121,8 +119,8 @@ void SubwayMap::OnConnect() { toWarp.type = SubwaySunwarpType::kExit; } - tagged[tag.str()].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); - tagged[tag.str()].push_back(GD_GetSubwayItemForSunwarp(toWarp)); + tagged[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); + tagged[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); } } diff --git a/src/version.h b/src/version.h index 7aab91b..060d557 100644 --- a/src/version.h +++ b/src/version.h @@ -1,9 +1,10 @@ #ifndef VERSION_H_C757E53C #define VERSION_H_C757E53C -#include #include +#include + struct Version { int major = 0; int minor = 0; @@ -24,9 +25,7 @@ struct Version { } std::string ToString() const { - std::ostringstream output; - output << "v" << major << "." << minor << "." << revision; - return output.str(); + return fmt::format("v{}.{}.{}", major, minor, revision); } bool operator<(const Version& rhs) const { diff --git a/vcpkg.json b/vcpkg.json index 925212a..e13d228 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,6 +3,7 @@ "websocketpp", "wxwidgets", "openssl", - "yaml-cpp" + "yaml-cpp", + "fmt" ] } -- cgit 1.4.1 From cce6451f13144d6035a16a52e315c5cebf4f6eb2 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 9 Jun 2024 23:50:35 -0400 Subject: Revert subway map crashing on hover before connect --- src/tracker_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index a4134f9..2f25257 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -650,5 +650,5 @@ bool IsPaintingReachable(int painting_id) { const std::map& GetDoorRequirements(int door_id) { std::lock_guard reachability_guard(GetState().reachability_mutex); - return GetState().door_reports.at(door_id); + return GetState().door_reports[door_id]; } -- cgit 1.4.1 From 902bad34643b10880704dbc41f3b1253bac2f542 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 10 Jun 2024 19:32:49 -0400 Subject: Update ECH painting location --- assets/subway.yaml | 3 +-- src/subway_map.cpp | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/assets/subway.yaml b/assets/subway.yaml index 266b722..8ef3aee 100644 --- a/assets/subway.yaml +++ b/assets/subway.yaml @@ -630,6 +630,7 @@ - blue_ch - yellow_ch - green_ch + - early_ch - pos: [1567, 1264] tags: - red_ch @@ -686,8 +687,6 @@ tags: - blueman_courtyard - blueman_starting -- pos: [60, 970] - special: early_color_hallways - pos: [402, 1012] room: Outside The Undeterred door: Green Painting diff --git a/src/subway_map.cpp b/src/subway_map.cpp index c7b2c8a..e3b844d 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -1,9 +1,9 @@ #include "subway_map.h" +#include #include #include -#include #include #include "ap_state.h" @@ -71,9 +71,8 @@ void SubwayMap::OnConnect() { std::map> tagged; for (const SubwayItem &subway_item : GD_GetSubwayItems()) { if (AP_HasEarlyColorHallways() && - (subway_item.special == "starting_room_paintings" || - subway_item.special == "early_color_hallways")) { - tagged["early_color_hallways"].push_back(subway_item.id); + subway_item.special == "starting_room_paintings") { + tagged["early_ch"].push_back(subway_item.id); } if (AP_IsPaintingShuffle() && !subway_item.paintings.empty()) { @@ -406,7 +405,7 @@ void SubwayMap::OnMouseMove(wxMouseEvent &event) { std::vector hovered = tree_->query( {static_cast(mouse_pos.x), static_cast(mouse_pos.y), 2, 2}); if (!hovered.empty()) { - actual_hover_= hovered[0]; + actual_hover_ = hovered[0]; } else { actual_hover_ = std::nullopt; } @@ -532,15 +531,9 @@ void SubwayMap::Redraw() { std::optional shade_color; if (AP_HasEarlyColorHallways() && - (subway_item.special == "starting_room_paintings" || - subway_item.special == "early_color_hallways")) { + subway_item.special == "starting_room_paintings") { draw_type = ItemDrawType::kOwl; - - if (subway_item.special == "starting_room_paintings") { - shade_color = wxColour(0, 255, 0, 128); - } else { - shade_color = wxColour(255, 0, 0, 128); - } + shade_color = wxColour(0, 255, 0, 128); } else if (subway_item.special == "sun_painting") { if (!AP_IsPilgrimageEnabled()) { if (IsDoorOpen(*subway_item.door)) { @@ -572,7 +565,8 @@ void SubwayMap::Redraw() { } } - if (has_unchecked_painting || has_mapped_painting || has_codomain_painting) { + if (has_unchecked_painting || has_mapped_painting || + has_codomain_painting) { draw_type = ItemDrawType::kOwl; if (has_checked_painting) { -- cgit 1.4.1 From 7fb9b44388b2a11e5ceaa281c2579bf8ffc045bf Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 10 Jun 2024 19:33:05 -0400 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index 060d557..7c3d3ad 100644 --- a/src/version.h +++ b/src/version.h @@ -36,6 +36,6 @@ struct Version { } }; -constexpr const Version kTrackerVersion = Version(0, 10, 2); +constexpr const Version kTrackerVersion = Version(0, 10, 3); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1 From c15162268a16b3ce9f8d8d08ebf5a6049f8f2a68 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 1 Jul 2024 19:08:01 -0400 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index 7c3d3ad..98df919 100644 --- a/src/version.h +++ b/src/version.h @@ -36,6 +36,6 @@ struct Version { } }; -constexpr const Version kTrackerVersion = Version(0, 10, 3); +constexpr const Version kTrackerVersion = Version(0, 10, 4); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1 From f99095ab41678f23e7fe0356ea06f94f05f7781f Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 12 Jul 2024 18:13:13 -0400 Subject: Increase connection history to 10 slots --- src/tracker_frame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 107ae49..80fd137 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp @@ -157,7 +157,7 @@ void TrackerFrame::OnConnect(wxCommandEvent &event) { } } - while (new_history.size() > 5) { + while (new_history.size() > 10) { new_history.pop_back(); } -- cgit 1.4.1 From 4e1325e9189d401a7398ab4133312309d7d6c2bc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 12 Jul 2024 18:13:31 -0400 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index 98df919..b688e27 100644 --- a/src/version.h +++ b/src/version.h @@ -36,6 +36,6 @@ struct Version { } }; -constexpr const Version kTrackerVersion = Version(0, 10, 4); +constexpr const Version kTrackerVersion = Version(0, 10, 5); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1 From ba352dbe181987e7749e9115a18a431d54fa1922 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 00:37:12 -0400 Subject: Fix issue with painting shuffle + no painting pilgrimage --- src/tracker_state.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 2f25257..fd5ff4b 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -218,6 +218,7 @@ class StateCalculator { GD_GetPaintingExit(GD_GetPaintingByName( AP_GetPaintingMapping().at(cur_painting.internal_id))); painting_exit.destination_room = target_painting.room; + painting_exit.type = EntranceType::kPainting; new_boundary.push_back(painting_exit); } -- cgit 1.4.1 From bbf47da879b816167c8f3bed716570effa4b52bb Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 00:37:58 -0400 Subject: Fix start of pilgrimage on sunwarp shuffle --- src/tracker_state.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index fd5ff4b..da8f426 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -288,7 +288,17 @@ class StateCalculator { } if (AP_IsPilgrimageEnabled()) { - if (room_obj.name == "Hub Room") { + int pilgrimage_start_id = GD_GetRoomByName("Hub Room"); + if (AP_IsSunwarpShuffle()) { + for (const auto& [start_index, mapping] : + AP_GetSunwarpMapping()) { + if (mapping.dots == 1) { + pilgrimage_start_id = GD_GetRoomForSunwarp(start_index); + } + } + } + + if (room_exit.destination_room == pilgrimage_start_id) { new_boundary.push_back( {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), .type = EntranceType::kPilgrimage}); -- cgit 1.4.1 From 52bc9fdf99d452c592e174acd9cb174ec00e19d7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 00:47:11 -0400 Subject: Added path tracking for debugging --- src/game_data.cpp | 3 ++- src/game_data.h | 1 + src/tracker_state.cpp | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game_data.cpp b/src/game_data.cpp index e75170e..4c0104f 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -109,6 +109,7 @@ struct GameData { auto process_single_entrance = [this, room_id, from_room_id](const YAML::Node &option) { Exit exit_obj; + exit_obj.source_room = from_room_id; exit_obj.destination_room = room_id; if (option["door"]) { @@ -143,7 +144,7 @@ struct GameData { switch (entrance_it.second.Type()) { case YAML::NodeType::Scalar: { // This is just "true". - rooms_[from_room_id].exits.push_back({.destination_room = room_id}); + rooms_[from_room_id].exits.push_back({.source_room = from_room_id, .destination_room = room_id}); break; } case YAML::NodeType::Map: { diff --git a/src/game_data.h b/src/game_data.h index b787e6f..23f7b3a 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -83,6 +83,7 @@ struct Door { }; struct Exit { + int source_room; int destination_room; std::optional door; EntranceType type = EntranceType::kNormal; diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index da8f426..ba615d1 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -1,5 +1,8 @@ #include "tracker_state.h" +#include +#include + #include #include #include @@ -9,6 +12,7 @@ #include "ap_state.h" #include "game_data.h" +#include "logger.h" namespace { @@ -217,6 +221,7 @@ class StateCalculator { PaintingExit target_painting = GD_GetPaintingExit(GD_GetPaintingByName( AP_GetPaintingMapping().at(cur_painting.internal_id))); + painting_exit.source_room = cur_painting.room; painting_exit.destination_room = target_painting.room; painting_exit.type = EntranceType::kPainting; @@ -245,6 +250,12 @@ class StateCalculator { reachable_rooms_.insert(room_exit.destination_room); reachable_changed = true; +#ifndef NDEBUG + std::list room_path = paths_[room_exit.source_room]; + room_path.push_back(room_exit.destination_room); + paths_[room_exit.destination_room] = room_path; +#endif + const Room& room_obj = GD_GetRoom(room_exit.destination_room); for (const Exit& out_edge : room_obj.exits) { if (out_edge.type == EntranceType::kPainting && @@ -283,7 +294,8 @@ class StateCalculator { if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { new_boundary.push_back( - {.destination_room = GD_GetRoomByName("Outside The Undeterred"), + {.source_room = room_exit.destination_room, + .destination_room = GD_GetRoomByName("Outside The Undeterred"), .type = EntranceType::kPainting}); } @@ -300,13 +312,15 @@ class StateCalculator { if (room_exit.destination_room == pilgrimage_start_id) { new_boundary.push_back( - {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), + {.source_room = room_exit.destination_room, + .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), .type = EntranceType::kPilgrimage}); } } else { if (room_obj.name == "Starting Room") { new_boundary.push_back( - {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), + {.source_room = room_exit.destination_room, + .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), .door = GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), .type = EntranceType::kPainting}); @@ -347,6 +361,19 @@ class StateCalculator { return door_report_; } + std::string GetPathToRoom(int room_id) const { + if (!paths_.count(room_id)) { + return ""; + } + + const std::list& path = paths_.at(room_id); + std::vector room_names; + for (int room_id : path) { + room_names.push_back(GD_GetRoom(room_id).name); + } + return hatkirby::implode(room_names, " -> "); + } + private: Decision IsNonGroupedDoorReachable(const Door& door_obj) { bool has_item = AP_HasItem(door_obj.ap_item_id); @@ -585,6 +612,8 @@ class StateCalculator { std::set solveable_panels_; std::set reachable_paintings_; std::map> door_report_; + + std::map> paths_; }; } // namespace -- cgit 1.4.1 From 2bf1b2abf0e90da14080573d7270cca62b2815f0 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 01:19:02 -0400 Subject: Display correct sunwarp doors when shuffled --- src/subway_map.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/subway_map.cpp b/src/subway_map.cpp index e3b844d..044e6fa 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -16,6 +16,29 @@ constexpr int OWL_ACTUAL_SIZE = 32; enum class ItemDrawType { kNone, kBox, kOwl }; +namespace { + +std::optional GetRealSubwayDoor(const SubwayItem subway_item) { + std::optional subway_door = subway_item.door; + if (AP_IsSunwarpShuffle() && subway_item.sunwarp && + subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { + int sunwarp_index = subway_item.sunwarp->dots - 1; + if (subway_item.sunwarp->type == SubwaySunwarpType::kExit) { + sunwarp_index += 6; + } + + for (const auto &[start_index, mapping] : AP_GetSunwarpMapping()) { + if (start_index == sunwarp_index || mapping.exit_index == sunwarp_index) { + subway_door = GD_GetSunwarpDoors().at(mapping.dots - 1); + } + } + + return subway_door; + } +} + +} // namespace + SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { SetBackgroundStyle(wxBG_STYLE_PAINT); @@ -267,9 +290,11 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { // Note that these requirements are duplicated on OnMouseClick so that it // knows when an item has a hover effect. const SubwayItem &subway_item = GD_GetSubwayItem(*hovered_item_); - if (subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) { + std::optional subway_door = GetRealSubwayDoor(subway_item); + + if (subway_door && !GetDoorRequirements(*subway_door).empty()) { const std::map &report = - GetDoorRequirements(*subway_item.door); + GetDoorRequirements(*subway_door); int acc_height = 10; int col_width = 0; @@ -450,7 +475,9 @@ void SubwayMap::OnMouseClick(wxMouseEvent &event) { if (actual_hover_) { const SubwayItem &subway_item = GD_GetSubwayItem(*actual_hover_); - if ((subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) || + std::optional subway_door = GetRealSubwayDoor(subway_item); + + if ((subway_door && !GetDoorRequirements(*subway_door).empty()) || networks_.IsItemInNetwork(*hovered_item_)) { if (actual_hover_ != hovered_item_) { hovered_item_ = actual_hover_; -- cgit 1.4.1 From 8995a57f74f2ba87575cc81d6f37fbcc6b452fcc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 01:22:39 -0400 Subject: Display connection string in status bar --- src/ap_state.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 876fdd8..ebc5fc9 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -221,9 +221,11 @@ struct APState { RefreshTracker(false); }); - apclient->set_slot_connected_handler([this, &connection_mutex]( + apclient->set_slot_connected_handler([this, player, server, + &connection_mutex]( const nlohmann::json& slot_data) { - tracker_frame->SetStatusMessage("Connected to Archipelago!"); + tracker_frame->SetStatusMessage( + fmt::format("Connected to Archipelago! ({}@{})", player, server)); TrackerLog("Connected to Archipelago!"); data_storage_prefix = -- cgit 1.4.1 From 9b193c3ffd036dbc2496645ef7ffc8938ddeeb8e Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 01:23:17 -0400 Subject: Bump version --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index b688e27..8f93e18 100644 --- a/src/version.h +++ b/src/version.h @@ -36,6 +36,6 @@ struct Version { } }; -constexpr const Version kTrackerVersion = Version(0, 10, 5); +constexpr const Version kTrackerVersion = Version(0, 10, 6); #endif /* end of include guard: VERSION_H_C757E53C */ \ No newline at end of file -- cgit 1.4.1