Remove archi debug mode

This commit is contained in:
aMannus
2025-07-01 22:01:41 +02:00
parent d1070397c1
commit 53a1aa3d3f
6 changed files with 20 additions and 96 deletions

View File

@@ -349,26 +349,22 @@ void Context::SetSpoilerLoaded(const bool spoilerLoaded) {
void Context::AddReceivedArchipelagoItem(const RandomizerGet item) { void Context::AddReceivedArchipelagoItem(const RandomizerGet item) {
mAPreceiveQueue.emplace(item); mAPreceiveQueue.emplace(item);
std::string logMessage = "[LOG] Item Pushed: " + std::to_string(item);
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
} }
GetItemEntry Context::GetArchipelagoGIEntry() { GetItemEntry Context::GetArchipelagoGIEntry() {
ArchipelagoConsole_SendMessage("[LOG] Trying to get Item Entry", true);
if (mAPreceiveQueue.empty()) { if (mAPreceiveQueue.empty()) {
// something must have gone wrong here, just give a rupee // Something must have gone wrong here, just give a rupee
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_HEART); return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_HEART);
} }
// get the first item from the archipelago queue // Get the first item from the archipelago queue
RandomizerGet item_id = mAPreceiveQueue.front(); RandomizerGet itemId = mAPreceiveQueue.front();
assert(item_id != RG_NONE); assert(itemId != RG_NONE);
Item& item = StaticData::RetrieveItem(item_id); Item& item = StaticData::RetrieveItem(itemId);
SPDLOG_TRACE("Found item! {}, {}", item.GetName().GetEnglish(), (int)item_id); GetItemEntry itemEntry = item.GetGIEntry_Copy();
GetItemEntry item_entry = item.GetGIEntry_Copy();
mAPreceiveQueue.pop(); mAPreceiveQueue.pop();
return item_entry; // todo: add custom text maybe? return itemEntry;
} }
GetItemEntry Context::GetFinalGIEntry(const RandomizerCheck rc, const bool checkObtainability, GetItemEntry Context::GetFinalGIEntry(const RandomizerCheck rc, const bool checkObtainability,

View File

@@ -220,8 +220,6 @@ static RandomizerCheck randomizerQueuedCheck = RC_UNKNOWN_CHECK;
static GetItemEntry randomizerQueuedItemEntry = GET_ITEM_NONE; static GetItemEntry randomizerQueuedItemEntry = GET_ITEM_NONE;
void ArchipelagoOnReceiveItem(const int32_t item) { void ArchipelagoOnReceiveItem(const int32_t item) {
std::string logMessage = "[LOG] Receive item handler called: " + item;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
randomizerQueuedChecks.push(RC_ARCHIPELAGO_RECEIVED_ITEM); randomizerQueuedChecks.push(RC_ARCHIPELAGO_RECEIVED_ITEM);
Rando::Context::GetInstance()->AddReceivedArchipelagoItem(static_cast<RandomizerGet>(item)); Rando::Context::GetInstance()->AddReceivedArchipelagoItem(static_cast<RandomizerGet>(item));
} }
@@ -325,9 +323,6 @@ void RandomizerOnExternalCheckHandler(uint32_t randomizerCheck) {
Flags_SetInfTable(flagID); Flags_SetInfTable(flagID);
break; break;
case SPOILER_CHK_GOLD_SKULLTULA: case SPOILER_CHK_GOLD_SKULLTULA:
logMessage = "[LOG] Externaly checked golden skultulla: " + std::to_string(loc->GetActorParams()) + ", " +
std::to_string(flagID);
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
SET_GS_FLAGS((flagID & 0x1F00) >> 8, flagID & 0xFF); SET_GS_FLAGS((flagID & 0x1F00) >> 8, flagID & 0xFF);
break; break;
case SPOILER_CHK_GRAVEDIGGER: // This enum is used nowhere in code, so i'll leave it as nothing for now case SPOILER_CHK_GRAVEDIGGER: // This enum is used nowhere in code, so i'll leave it as nothing for now

View File

@@ -48,13 +48,13 @@ bool ArchipelagoClient::StartClient() {
new APClient(uuid, AP_Client_consts::AP_GAME_NAME, new APClient(uuid, AP_Client_consts::AP_GAME_NAME,
CVarGetString(CVAR_REMOTE_ARCHIPELAGO("ServerAddress"), "localhost:38281"), "cacert.pem")); CVarGetString(CVAR_REMOTE_ARCHIPELAGO("ServerAddress"), "localhost:38281"), "cacert.pem"));
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 1); // connecting CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 1); // Connecting
apClient->set_socket_error_handler([&](const std::string& msg) { apClient->set_socket_error_handler([&](const std::string& msg) {
retries++; retries++;
if(retries > AP_Client_consts::MAX_RETRIES) { if(retries > AP_Client_consts::MAX_RETRIES) {
ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server"); ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server");
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 2); // connection error CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 2); // Connection error
disconnecting = true; disconnecting = true;
return; return;
} }
@@ -122,16 +122,8 @@ bool ArchipelagoClient::StartClient() {
apItem.flags = item.flags; apItem.flags = item.flags;
apItem.index = item.index; apItem.index = item.index;
scoutedItems.push_back(apItem); scoutedItems.push_back(apItem);
const std::string itemName = apItem.itemName;
const std::string playerName = apItem.playerName;
const std::string locationName = apItem.locationName;
std::string logMessage =
"[LOG] Location scouted: " + itemName + " for " + playerName + " in location " + locationName;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
} }
ArchipelagoConsole_SendMessage("[LOG] Scouting finished.", true);
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 4); // locations scouted CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 4); // locations scouted
}); // todo maybe move these functions to a lambda, since they don't have to be static anymore }); // todo maybe move these functions to a lambda, since they don't have to be static anymore
@@ -242,8 +234,6 @@ void ArchipelagoClient::GameLoaded() {
return; return;
} }
ArchipelagoConsole_SendMessage("[LOG] Synching Items and Locations.", true);
SynchItems(); SynchItems();
SynchSentLocations(); SynchSentLocations();
SynchReceivedLocations(); SynchReceivedLocations();
@@ -264,7 +254,6 @@ void ArchipelagoClient::StartLocationScouts() {
void ArchipelagoClient::SynchItems() { void ArchipelagoClient::SynchItems() {
// Send a Synch request to get any items we may have missed // Send a Synch request to get any items we may have missed
ArchipelagoConsole_SendMessage("[LOG] Sending synch request", true);
apClient->Sync(); apClient->Sync();
} }
@@ -278,9 +267,6 @@ void ArchipelagoClient::SynchSentLocations() {
checkedLocations.emplace_back(apLocation); checkedLocations.emplace_back(apLocation);
} }
} }
std::string locationLog =
"[LOG] Synching " + std::to_string(checkedLocations.size()) + " checks already found in game";
ArchipelagoConsole_SendMessage(locationLog.c_str(), true);
apClient->LocationChecks(checkedLocations); apClient->LocationChecks(checkedLocations);
} }
@@ -297,7 +283,7 @@ void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
const uint32_t RC = static_cast<uint32_t>(Rando::StaticData::locationNameToEnum[checkName]); const uint32_t RC = static_cast<uint32_t>(Rando::StaticData::locationNameToEnum[checkName]);
if (RC == RC_UNKNOWN_CHECK) { if (RC == RC_UNKNOWN_CHECK) {
ArchipelagoConsole_SendMessage("[ERROR] Attempting to queue RC_UNKOWN_CHECK, skipping", false); ArchipelagoConsole_SendMessage("[ERROR] Attempting to queue an unknown location (RC_UNKOWN_CHECK), skipping.");
return; return;
} }
@@ -306,9 +292,6 @@ void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
return; return;
} }
std::string locationLog = "[LOG] Externaly checking: " + checkName;
ArchipelagoConsole_SendMessage(locationLog.c_str(), true);
GameInteractor_ExecuteOnRandomizerExternalCheck(RC); GameInteractor_ExecuteOnRandomizerExternalCheck(RC);
} }
@@ -322,7 +305,7 @@ bool ArchipelagoClient::IsConnected() {
void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) { void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) {
if (sohCheckId == RC_UNKNOWN_CHECK) { if (sohCheckId == RC_UNKNOWN_CHECK) {
ArchipelagoConsole_SendMessage("[ERROR] trying to send RC_UNKNOWN_CHECK, skipping", false); ArchipelagoConsole_SendMessage("[ERROR] Trying to queue an unknown location (RC_UNKOWN_CHECK), skipping");
return; return;
} }
@@ -336,36 +319,27 @@ void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) {
} }
int64_t apItemId = apClient->get_location_id(std::string(apName)); int64_t apItemId = apClient->get_location_id(std::string(apName));
std::string logMessage = "[LOG] Checked: " + apName + "(" + std::to_string(apItemId) + "), sending to AP server";
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
apClient->LocationChecks({ apItemId }); apClient->LocationChecks({ apItemId });
} }
void ArchipelagoClient::OnItemReceived(const ApItem apItem) { void ArchipelagoClient::OnItemReceived(const ApItem apItem) {
if (!GameInteractor::IsSaveLoaded(true)) {
// Don't queue up any items when we aren't in game // Don't queue up any items when we aren't in game
// Any Items missed this way will get synched when we load the save // Any Items missed this way will get synched when we load the save
if (!GameInteractor::IsSaveLoaded(true)) {
return; return;
} }
std::string logMessage = "[LOG] Received " + apItem.itemName;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
if (apItem.index < gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex) {
// Skip queueing any items we already have // Skip queueing any items we already have
std::string logMessage = "[LOG] Skipping giving " + apItem.itemName + ". We received this previously."; if (apItem.index < gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex) {
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
return; return;
} }
// add item to the queue // Add item to the queue
receiveQueue.push(apItem); receiveQueue.push(apItem);
} }
void ArchipelagoClient::QueueItem(const ApItem item) { void ArchipelagoClient::QueueItem(const ApItem item) {
std::string logMessage = "[LOG] Giving " + item.itemName;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
const RandomizerGet RG = Rando::StaticData::itemNameToEnum[item.itemName]; const RandomizerGet RG = Rando::StaticData::itemNameToEnum[item.itemName];
if (RG == RG_NONE) { if (RG == RG_NONE) {
return; return;
@@ -386,13 +360,12 @@ void ArchipelagoClient::SendMessageToConsole(const std::string message) {
// local commands not implemented yet // local commands not implemented yet
if (message.starts_with("/")) { if (message.starts_with("/")) {
ArchipelagoConsole_SendMessage( ArchipelagoConsole_SendMessage(
"Ship of Harkinian does not have any local commands yet.\nUse \"!help\" to see server commands instead", "Ship of Harkinian does not have any local commands.\nUse \"!help\" to see server commands instead.");
false);
return; return;
} }
if (apClient == nullptr) { if (apClient == nullptr) {
ArchipelagoConsole_SendMessage("[ERROR] Could not send message. Please Connect to your slot.", false); ArchipelagoConsole_SendMessage("[ERROR] Could not send message. Please Connect to your slot.");
return; return;
} }

View File

@@ -9,10 +9,7 @@ bool autoScroll = true;
using namespace UIWidgets; using namespace UIWidgets;
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage, ...) { void ArchipelagoConsole_SendMessage(const char* fmt, ...) {
if (debugMessage && !CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"), 0)) {
return;
}
char buf[1024]; char buf[1024];
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);

View File

@@ -18,7 +18,7 @@ class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
void UpdateElement() override{}; void UpdateElement() override{};
}; };
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage = false, ...); void ArchipelagoConsole_SendMessage(const char* fmt, ...);
void ArchipelagoConsole_PrintJson(const std::vector<ArchipelagoClient::ColoredTextNode> nodes); void ArchipelagoConsole_PrintJson(const std::vector<ArchipelagoClient::ColoredTextNode> nodes);
ImVec4 getColorVal(const std::string& color); ImVec4 getColorVal(const std::string& color);

View File

@@ -40,48 +40,11 @@ void ArchipelagoSettingsWindow::DrawElement() {
if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) { if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
bool success = AP_client.StartClient(); bool success = AP_client.StartClient();
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...", true);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text(ArchipelagoClient::GetInstance().GetConnectionStatus()); ImGui::Text(ArchipelagoClient::GetInstance().GetConnectionStatus());
UIWidgets::CVarCheckbox(
"Debug Enabled", CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"),
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Tooltip("Enable Archipelago debug tools and extra logging."));
// Temporary developer helpers
UIWidgets::Separator();
if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"), 0)) {
ImGui::SeparatorText("Developer Tools");
if (UIWidgets::Button("Scout", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
AP_client.StartLocationScouts();
}
ImGui::SameLine();
if (UIWidgets::Button("Link up", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("Connected"), 1);
}
ImGui::SameLine();
if (UIWidgets::Button("Give Blue Rupee",
UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
ArchipelagoClient::ApItem apItem;
apItem.itemName = "Blue Rupee";
apItem.locationName = "Nowhere";
apItem.playerName = "Nobody";
apItem.flags = 0b001;
apItem.index = 999999;
ArchipelagoClient::GetInstance().OnItemReceived(apItem);
}
ImGui::SameLine();
if (UIWidgets::Button("Send Game Won", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
ArchipelagoClient::GetInstance().SendGameWon();
}
if (UIWidgets::Button("Get Mido br chest",
UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
ArchipelagoClient::GetInstance().QueueExternalCheck(16711707);
}
}
static bool sArchipelagoTexturesLoaded = false; static bool sArchipelagoTexturesLoaded = false;
if (!sArchipelagoTexturesLoaded) { if (!sArchipelagoTexturesLoaded) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage(