diff options
Diffstat (limited to 'src/ap_state.cpp')
-rw-r--r-- | src/ap_state.cpp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index b057beb..e5ff74d 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -75,7 +75,7 @@ struct APState { | |||
75 | 75 | ||
76 | void Connect(std::string server, std::string player, std::string password) { | 76 | void Connect(std::string server, std::string player, std::string password) { |
77 | if (!initialized) { | 77 | if (!initialized) { |
78 | TrackerLog("Initializing APState..."); | 78 | wxLogMessage("Initializing APState..."); |
79 | 79 | ||
80 | std::thread([this]() { | 80 | std::thread([this]() { |
81 | for (;;) { | 81 | for (;;) { |
@@ -108,10 +108,10 @@ struct APState { | |||
108 | } | 108 | } |
109 | 109 | ||
110 | tracker_frame->SetStatusMessage("Connecting to Archipelago server...."); | 110 | tracker_frame->SetStatusMessage("Connecting to Archipelago server...."); |
111 | TrackerLog("Connecting to Archipelago server (" + server + ")..."); | 111 | wxLogMessage("Connecting to Archipelago server (%s)...", server); |
112 | 112 | ||
113 | { | 113 | { |
114 | TrackerLog("Destroying old AP client..."); | 114 | wxLogMessage("Destroying old AP client..."); |
115 | 115 | ||
116 | std::lock_guard client_guard(client_mutex); | 116 | std::lock_guard client_guard(client_mutex); |
117 | 117 | ||
@@ -155,10 +155,10 @@ struct APState { | |||
155 | apclient->set_room_info_handler([this, player, password]() { | 155 | apclient->set_room_info_handler([this, player, password]() { |
156 | inventory.clear(); | 156 | inventory.clear(); |
157 | 157 | ||
158 | TrackerLog("Connected to Archipelago server. Authenticating as " + | 158 | wxLogMessage("Connected to Archipelago server. Authenticating as %s %s", |
159 | player + | 159 | player, |
160 | (password.empty() ? " without password" | 160 | (password.empty() ? " without password" |
161 | : " with password " + password)); | 161 | : " with password " + password)); |
162 | tracker_frame->SetStatusMessage( | 162 | tracker_frame->SetStatusMessage( |
163 | "Connected to Archipelago server. Authenticating..."); | 163 | "Connected to Archipelago server. Authenticating..."); |
164 | 164 | ||
@@ -170,7 +170,7 @@ struct APState { | |||
170 | [this](const std::list<int64_t>& locations) { | 170 | [this](const std::list<int64_t>& locations) { |
171 | for (const int64_t location_id : locations) { | 171 | for (const int64_t location_id : locations) { |
172 | checked_locations.insert(location_id); | 172 | checked_locations.insert(location_id); |
173 | TrackerLog("Location: " + std::to_string(location_id)); | 173 | wxLogMessage("Location: %lld", location_id); |
174 | } | 174 | } |
175 | 175 | ||
176 | RefreshTracker(false); | 176 | RefreshTracker(false); |
@@ -179,14 +179,14 @@ struct APState { | |||
179 | apclient->set_slot_disconnected_handler([this]() { | 179 | apclient->set_slot_disconnected_handler([this]() { |
180 | tracker_frame->SetStatusMessage( | 180 | tracker_frame->SetStatusMessage( |
181 | "Disconnected from Archipelago. Attempting to reconnect..."); | 181 | "Disconnected from Archipelago. Attempting to reconnect..."); |
182 | TrackerLog( | 182 | wxLogMessage( |
183 | "Slot disconnected from Archipelago. Attempting to reconnect..."); | 183 | "Slot disconnected from Archipelago. Attempting to reconnect..."); |
184 | }); | 184 | }); |
185 | 185 | ||
186 | apclient->set_socket_disconnected_handler([this]() { | 186 | apclient->set_socket_disconnected_handler([this]() { |
187 | tracker_frame->SetStatusMessage( | 187 | tracker_frame->SetStatusMessage( |
188 | "Disconnected from Archipelago. Attempting to reconnect..."); | 188 | "Disconnected from Archipelago. Attempting to reconnect..."); |
189 | TrackerLog( | 189 | wxLogMessage( |
190 | "Socket disconnected from Archipelago. Attempting to reconnect..."); | 190 | "Socket disconnected from Archipelago. Attempting to reconnect..."); |
191 | }); | 191 | }); |
192 | 192 | ||
@@ -194,7 +194,7 @@ struct APState { | |||
194 | [this](const std::list<APClient::NetworkItem>& items) { | 194 | [this](const std::list<APClient::NetworkItem>& items) { |
195 | for (const APClient::NetworkItem& item : items) { | 195 | for (const APClient::NetworkItem& item : items) { |
196 | inventory[item.item]++; | 196 | inventory[item.item]++; |
197 | TrackerLog("Item: " + std::to_string(item.item)); | 197 | wxLogMessage("Item: %lld", item.item); |
198 | } | 198 | } |
199 | 199 | ||
200 | RefreshTracker(false); | 200 | RefreshTracker(false); |
@@ -219,7 +219,7 @@ struct APState { | |||
219 | apclient->set_slot_connected_handler([this]( | 219 | apclient->set_slot_connected_handler([this]( |
220 | const nlohmann::json& slot_data) { | 220 | const nlohmann::json& slot_data) { |
221 | tracker_frame->SetStatusMessage("Connected to Archipelago!"); | 221 | tracker_frame->SetStatusMessage("Connected to Archipelago!"); |
222 | TrackerLog("Connected to Archipelago!"); | 222 | wxLogMessage("Connected to Archipelago!"); |
223 | 223 | ||
224 | data_storage_prefix = | 224 | data_storage_prefix = |
225 | "Lingo_" + std::to_string(apclient->get_player_number()) + "_"; | 225 | "Lingo_" + std::to_string(apclient->get_player_number()) + "_"; |
@@ -323,7 +323,7 @@ struct APState { | |||
323 | } | 323 | } |
324 | 324 | ||
325 | std::string full_message = hatkirby::implode(error_messages, " "); | 325 | std::string full_message = hatkirby::implode(error_messages, " "); |
326 | TrackerLog(full_message); | 326 | wxLogError(wxString(full_message)); |
327 | 327 | ||
328 | wxMessageBox(full_message, "Connection failed", wxOK | wxICON_ERROR); | 328 | wxMessageBox(full_message, "Connection failed", wxOK | wxICON_ERROR); |
329 | }); | 329 | }); |
@@ -342,7 +342,7 @@ struct APState { | |||
342 | 342 | ||
343 | tracker_frame->SetStatusMessage("Disconnected from Archipelago."); | 343 | tracker_frame->SetStatusMessage("Disconnected from Archipelago."); |
344 | 344 | ||
345 | TrackerLog("Timeout while connecting to Archipelago server."); | 345 | wxLogMessage("Timeout while connecting to Archipelago server."); |
346 | wxMessageBox("Timeout while connecting to Archipelago server.", | 346 | wxMessageBox("Timeout while connecting to Archipelago server.", |
347 | "Connection failed", wxOK | wxICON_ERROR); | 347 | "Connection failed", wxOK | wxICON_ERROR); |
348 | } | 348 | } |
@@ -362,12 +362,11 @@ struct APState { | |||
362 | void HandleDataStorage(const std::string& key, const nlohmann::json& value) { | 362 | void HandleDataStorage(const std::string& key, const nlohmann::json& value) { |
363 | if (value.is_boolean()) { | 363 | if (value.is_boolean()) { |
364 | data_storage[key] = value.get<bool>(); | 364 | data_storage[key] = value.get<bool>(); |
365 | TrackerLog("Data storage " + key + " retrieved as " + | 365 | wxLogMessage("Data storage %s retrieved as %s", key, |
366 | (value.get<bool>() ? "true" : "false")); | 366 | (value.get<bool>() ? "true" : "false")); |
367 | } else if (value.is_number()) { | 367 | } else if (value.is_number()) { |
368 | data_storage[key] = value.get<int>(); | 368 | data_storage[key] = value.get<int>(); |
369 | TrackerLog("Data storage " + key + " retrieved as " + | 369 | wxLogMessage("Data storage %s retrieved as %d", key, value.get<int>()); |
370 | std::to_string(value.get<int>())); | ||
371 | } else if (value.is_object()) { | 370 | } else if (value.is_object()) { |
372 | if (key.ends_with("PlayerPos")) { | 371 | if (key.ends_with("PlayerPos")) { |
373 | auto map_value = value.get<std::map<std::string, int>>(); | 372 | auto map_value = value.get<std::map<std::string, int>>(); |
@@ -376,7 +375,7 @@ struct APState { | |||
376 | data_storage[key] = value.get<std::map<std::string, int>>(); | 375 | data_storage[key] = value.get<std::map<std::string, int>>(); |
377 | } | 376 | } |
378 | 377 | ||
379 | TrackerLog("Data storage " + key + " retrieved as dictionary"); | 378 | wxLogMessage("Data storage %s retrieved as dictionary", key); |
380 | } else if (value.is_null()) { | 379 | } else if (value.is_null()) { |
381 | if (key.ends_with("PlayerPos")) { | 380 | if (key.ends_with("PlayerPos")) { |
382 | player_pos = std::nullopt; | 381 | player_pos = std::nullopt; |
@@ -384,7 +383,7 @@ struct APState { | |||
384 | data_storage.erase(key); | 383 | data_storage.erase(key); |
385 | } | 384 | } |
386 | 385 | ||
387 | TrackerLog("Data storage " + key + " retrieved as null"); | 386 | wxLogMessage("Data storage %s retrieved as null", key); |
388 | } | 387 | } |
389 | } | 388 | } |
390 | 389 | ||
@@ -408,7 +407,7 @@ struct APState { | |||
408 | } | 407 | } |
409 | 408 | ||
410 | void RefreshTracker(bool reset) { | 409 | void RefreshTracker(bool reset) { |
411 | TrackerLog("Refreshing display..."); | 410 | wxLogMessage("Refreshing display..."); |
412 | 411 | ||
413 | RecalculateReachability(); | 412 | RecalculateReachability(); |
414 | 413 | ||
@@ -422,7 +421,7 @@ struct APState { | |||
422 | int64_t GetItemId(const std::string& item_name) { | 421 | int64_t GetItemId(const std::string& item_name) { |
423 | int64_t ap_id = apclient->get_item_id(item_name); | 422 | int64_t ap_id = apclient->get_item_id(item_name); |
424 | if (ap_id == APClient::INVALID_NAME_ID) { | 423 | if (ap_id == APClient::INVALID_NAME_ID) { |
425 | TrackerLog("Could not find AP item ID for " + item_name); | 424 | wxLogError("Could not find AP item ID for %s", item_name); |
426 | } | 425 | } |
427 | 426 | ||
428 | return ap_id; | 427 | return ap_id; |