From 0c7cb22f3da56fde00f981f9fefb971c541bc8f1 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 15 May 2024 13:19:34 -0400 Subject: Logging changes --- src/ap_state.cpp | 56 +++++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'src/ap_state.cpp') diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 68a6902..4a15db0 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -21,7 +21,6 @@ #include #include "game_data.h" -#include "logger.h" #include "tracker_frame.h" #include "tracker_state.h" @@ -75,7 +74,7 @@ struct APState { void Connect(std::string server, std::string player, std::string password) { if (!initialized) { - wxLogMessage("Initializing APState..."); + wxLogVerbose("Initializing APState..."); std::thread([this]() { for (;;) { @@ -108,11 +107,10 @@ struct APState { initialized = true; } - tracker_frame->SetStatusMessage("Connecting to Archipelago server...."); - wxLogMessage("Connecting to Archipelago server (%s)...", server); + wxLogStatus("Connecting to Archipelago server (%s)...", server); { - wxLogMessage("Destroying old AP client..."); + wxLogVerbose("Destroying old AP client..."); std::lock_guard client_guard(client_mutex); @@ -156,12 +154,11 @@ struct APState { apclient->set_room_info_handler([this, player, password]() { inventory.clear(); - wxLogMessage("Connected to Archipelago server. Authenticating as %s %s", - player, - (password.empty() ? " without password" - : " with password " + password)); - tracker_frame->SetStatusMessage( + wxLogStatus( "Connected to Archipelago server. Authenticating..."); + wxLogVerbose("Authenticating as %s %s", player, + (password.empty() ? "without password" + : "with password " + password)); apclient->ConnectSlot(player, password, ITEM_HANDLING, {"Tracker"}, {AP_MAJOR, AP_MINOR, AP_REVISION}); @@ -171,23 +168,19 @@ struct APState { [this](const std::list& locations) { for (const int64_t location_id : locations) { checked_locations.insert(location_id); - wxLogMessage("Location: %lld", location_id); + wxLogVerbose("Location: %lld", location_id); } RefreshTracker(false); }); apclient->set_slot_disconnected_handler([this]() { - tracker_frame->SetStatusMessage( - "Disconnected from Archipelago. Attempting to reconnect..."); - wxLogMessage( + wxLogStatus( "Slot disconnected from Archipelago. Attempting to reconnect..."); }); apclient->set_socket_disconnected_handler([this]() { - tracker_frame->SetStatusMessage( - "Disconnected from Archipelago. Attempting to reconnect..."); - wxLogMessage( + wxLogStatus( "Socket disconnected from Archipelago. Attempting to reconnect..."); }); @@ -195,7 +188,7 @@ struct APState { [this](const std::list& items) { for (const APClient::NetworkItem& item : items) { inventory[item.item]++; - wxLogMessage("Item: %lld", item.item); + wxLogVerbose("Item: %lld", item.item); } RefreshTracker(false); @@ -219,8 +212,7 @@ struct APState { apclient->set_slot_connected_handler([this]( const nlohmann::json& slot_data) { - tracker_frame->SetStatusMessage("Connected to Archipelago!"); - wxLogMessage("Connected to Archipelago!"); + wxLogStatus("Connected to Archipelago!"); data_storage_prefix = "Lingo_" + std::to_string(apclient->get_player_number()) + "_"; @@ -341,9 +333,7 @@ struct APState { DestroyClient(); - tracker_frame->SetStatusMessage("Disconnected from Archipelago."); - - wxLogMessage("Timeout while connecting to Archipelago server."); + wxLogStatus("Timeout while connecting to Archipelago server."); wxMessageBox("Timeout while connecting to Archipelago server.", "Connection failed", wxOK | wxICON_ERROR); } @@ -363,11 +353,11 @@ struct APState { void HandleDataStorage(const std::string& key, const nlohmann::json& value) { if (value.is_boolean()) { data_storage[key] = value.get(); - wxLogMessage("Data storage %s retrieved as %s", key, + wxLogVerbose("Data storage %s retrieved as %s", key, (value.get() ? "true" : "false")); } else if (value.is_number()) { data_storage[key] = value.get(); - wxLogMessage("Data storage %s retrieved as %d", key, value.get()); + wxLogVerbose("Data storage %s retrieved as %d", key, value.get()); } else if (value.is_object()) { if (key.ends_with("PlayerPos")) { auto map_value = value.get>(); @@ -376,7 +366,7 @@ struct APState { data_storage[key] = value.get>(); } - wxLogMessage("Data storage %s retrieved as dictionary", key); + wxLogVerbose("Data storage %s retrieved as dictionary", key); } else if (value.is_null()) { if (key.ends_with("PlayerPos")) { player_pos = std::nullopt; @@ -384,15 +374,19 @@ struct APState { data_storage.erase(key); } - wxLogMessage("Data storage %s retrieved as null", key); + wxLogVerbose("Data storage %s retrieved as null", key); } else if (value.is_array()) { + auto list_value = value.get>(); + if (key.ends_with("Paintings")) { - data_storage[key] = value.get>(); + data_storage[key] = + std::set(list_value.begin(), list_value.end()); } else { - data_storage[key] = value.get>(); + data_storage[key] = list_value; } - wxLogMessage("Data storage %s retrieved as list", key); + wxLogVerbose("Data storage %s retrieved as list: [%s]", key, + hatkirby::implode(list_value, ", ")); } } @@ -425,7 +419,7 @@ struct APState { } void RefreshTracker(bool reset) { - wxLogMessage("Refreshing display..."); + wxLogVerbose("Refreshing display..."); RecalculateReachability(); -- cgit 1.4.1