Replace archi SPD instances with built in console

This commit is contained in:
aMannus
2025-05-19 09:55:01 +02:00
parent 21c53aff93
commit 1bf399658c
8 changed files with 22 additions and 21 deletions

View File

@@ -348,13 +348,12 @@ void Context::SetSpoilerLoaded(const bool spoilerLoaded) {
void Context::AddRecievedArchipelagoItem(const std::string& ap_item_id) {
mAPrecieveQueue.emplace(ap_item_id);
SPDLOG_TRACE("Item Pushed {}", ap_item_id);
AddToArchipelagoConsole("Item Pushed");
std::string logMessage = "[LOG] Item Pushed: " + ap_item_id;
ArchipelagoConsole_SendMessage(logMessage.c_str());
}
GetItemEntry Context::GetArchipelagoGIEntry() {
SPDLOG_TRACE("Trying to get Item Entry");
AddToArchipelagoConsole("Trying to get Item Entry");
ArchipelagoConsole_SendMessage("[LOG] Trying to get Item Entry");
if(mAPrecieveQueue.empty()) {
// something must have gone wrong here, just give a rupee
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_HEART);

View File

@@ -17,6 +17,7 @@
#include "soh/SaveManager.h"
#include "soh/Enhancements/randomizer/ShuffleFairies.h"
#include "soh/Network/Archipelago/Archipelago.h"
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
extern "C" {
#include "macros.h"
@@ -223,7 +224,8 @@ static RandomizerCheck randomizerQueuedCheck = RC_UNKNOWN_CHECK;
static GetItemEntry randomizerQueuedItemEntry = GET_ITEM_NONE;
void ArchipelagoOnRecieveItem(const std::string& ap_item_name) {
SPDLOG_TRACE("Recieve item handler called! {}", ap_item_name);
std::string logMessage = "[LOG] Receive item handler called: " + ap_item_name;
ArchipelagoConsole_SendMessage(logMessage.c_str());
randomizerQueuedChecks.push(RC_ARCHIPELAGO_RECIEVED_ITEM);
Rando::Context::GetInstance()->AddRecievedArchipelagoItem(ap_item_name);
}
@@ -314,7 +316,6 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() {
GetItemID vanillaItem = (GetItemID)Rando::StaticData::RetrieveItem(vanillaRandomizerGet).GetItemID();
getItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)vanillaRandomizerGet);
}
SPDLOG_TRACE("RC found!");
if (loc->HasObtained()) {
SPDLOG_INFO("RC {} already obtained, skipping", static_cast<uint32_t>(rc));
@@ -373,8 +374,6 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) {
if (randomizerQueuedCheck == RC_UNKNOWN_CHECK)
return;
SPDLOG_TRACE("Dropped into recieve handler!");
auto loc = Rando::Context::GetInstance()->GetItemLocation(randomizerQueuedCheck);
if (randomizerQueuedItemEntry.modIndex == receivedItemEntry.modIndex &&
randomizerQueuedItemEntry.itemId == receivedItemEntry.itemId) {

View File

@@ -14,7 +14,6 @@
typedef enum {
MOD_NONE,
MOD_RANDOMIZER,
MOD_ARCHIPELAGO // no actually used yet i think
} ModIndex;
typedef enum {
TABLE_VANILLA = MOD_NONE,

View File

@@ -4,12 +4,12 @@
#include "soh/OTRGlobals.h"
#include <spdlog/spdlog.h>
#include <utility>
#include "consolevariablebridge.h"
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
namespace Rando {
std::shared_ptr<Settings> Settings::mInstance;
@@ -2968,7 +2968,8 @@ void Settings::ParseArchipelago(const std::map<std::string, int>& slot_data) {
const std::string& setting_name = std::string(StaticData::APsettingToHoSsetting[APname]);
const RandomizerSettingKey index = StaticData::optionNameToEnum[setting_name];
mContext->GetOption(index).Set(value);
SPDLOG_INFO("Parsed Setting {}: ({}, {})", APname, (int)index, value);
std::string logMessage = "[LOG] Parsed Setting " + APname + ": (" + std::to_string((int)index) + ", " + std::to_string(value) + ")";
ArchipelagoConsole_SendMessage(logMessage.c_str());
}
// maybe we have to set a couple of settings manually, if ap doesn't set them

View File

@@ -5,9 +5,9 @@
#include <fstream>
#include <filesystem>
#include <spdlog/spdlog.h>
#include <iostream>
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
#include "soh/Enhancements/randomizer/randomizerTypes.h"
#include "soh/Enhancements/randomizer/static_data.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
@@ -67,7 +67,8 @@ bool ArchipelagoClient::start_client() {
const std::string itemName = apItem.itemName;
const std::string playerName = apItem.playerName;
const std::string locationName = apItem.locationName;
SPDLOG_TRACE("Location scouted: {} for {} in location {}", itemName, playerName, locationName);
std::string logMessage = "[LOG] Location scouted: " + itemName + " for " + playerName + " in location " + locationName;
ArchipelagoConsole_SendMessage(logMessage.c_str());
}
}); // todo maybe move these functions to a lambda, since they don't have to be static anymore
@@ -108,7 +109,8 @@ void ArchipelagoClient::check_location(RandomizerCheck SoH_check_id) {
return;
}
int64_t ap_item_id = apclient->get_location_id(std::string(ap_name));
SPDLOG_TRACE("Checked: {}({}), sending to AP server", ap_name, ap_item_id);
std::string logMessage = "[LOG] Checked: " + ap_name + "(" + std::to_string(ap_item_id) + "), sending to AP server";
ArchipelagoConsole_SendMessage(logMessage.c_str());
// currently not sending, because i only get so many real chances
if(!isConnected()) {
@@ -127,7 +129,7 @@ void ArchipelagoClient::removeItemRecievedCallback(std::function<void(const std:
void ArchipelagoClient::on_connected() {
// todo implement me
SPDLOG_TRACE("AP Connected!!");
ArchipelagoConsole_SendMessage("[LOG] AP Connected!");
}
//void ArchipelagoClient::on_couldntConnect(AP_ConnectionStatus connection_status) {
// // todo implement me
@@ -138,7 +140,8 @@ void ArchipelagoClient::on_item_recieved(int64_t recieved_item_id, bool notify_p
const std::string item_name = apclient->get_item_name(recieved_item_id, AP_Client_consts::AP_GAME_NAME);
ArchipelagoClient& ap_client = ArchipelagoClient::getInstance();
if(ap_client.ItemRecievedCallback) {
SPDLOG_TRACE("item recieved: {}, notify: {}", item_name, notify_player);
std::string logMessage = "[LOG] Item recieved: " + item_name + ". Notify: " + std::to_string(notify_player);
ArchipelagoConsole_SendMessage(logMessage.c_str());
ap_client.ItemRecievedCallback.operator()(item_name); // somehow passing it through the itemname breaks it????
}
}

View File

@@ -7,7 +7,7 @@ ImVector<char*> Items;
bool autoScroll = true;
bool scrollToBottom = false;
void AddToArchipelagoConsole(const char* fmt, ...) IM_FMTARGS(2) {
void ArchipelagoConsole_SendMessage(const char* fmt, ...) IM_FMTARGS(2) {
char buf[1024];
va_list args;
va_start(args, fmt);
@@ -22,7 +22,7 @@ void ArchipelagoConsoleWindow::DrawElement() {
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
if (ImGui::Button("Add line to log")) {
AddToArchipelagoConsole("Hello world");
ArchipelagoConsole_SendMessage("Hello World");
}
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 400), false,

View File

@@ -15,6 +15,6 @@ class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
void UpdateElement() override {};
};
void AddToArchipelagoConsole(const char* fmt, ...);
void ArchipelagoConsole_SendMessage(const char* fmt, ...);
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H

View File

@@ -15,7 +15,7 @@ void ArchipelagoSettingsWindow::DrawElement() {
if (ImGui::Button("Connect")) {
bool success = AP_client.start_client();
AddToArchipelagoConsole("Trying to connect...");
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...");
}
ImGui::SameLine();