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) {
mAPreceiveQueue.emplace(item);
std::string logMessage = "[LOG] Item Pushed: " + std::to_string(item);
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
}
GetItemEntry Context::GetArchipelagoGIEntry() {
ArchipelagoConsole_SendMessage("[LOG] Trying to get Item Entry", true);
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);
}
// get the first item from the archipelago queue
RandomizerGet item_id = mAPreceiveQueue.front();
assert(item_id != RG_NONE);
// Get the first item from the archipelago queue
RandomizerGet itemId = mAPreceiveQueue.front();
assert(itemId != RG_NONE);
Item& item = StaticData::RetrieveItem(item_id);
SPDLOG_TRACE("Found item! {}, {}", item.GetName().GetEnglish(), (int)item_id);
GetItemEntry item_entry = item.GetGIEntry_Copy();
Item& item = StaticData::RetrieveItem(itemId);
GetItemEntry itemEntry = item.GetGIEntry_Copy();
mAPreceiveQueue.pop();
return item_entry; // todo: add custom text maybe?
return itemEntry;
}
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;
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);
Rando::Context::GetInstance()->AddReceivedArchipelagoItem(static_cast<RandomizerGet>(item));
}
@@ -325,9 +323,6 @@ void RandomizerOnExternalCheckHandler(uint32_t randomizerCheck) {
Flags_SetInfTable(flagID);
break;
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);
break;
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,
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) {
retries++;
if(retries > AP_Client_consts::MAX_RETRIES) {
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;
return;
}
@@ -122,16 +122,8 @@ bool ArchipelagoClient::StartClient() {
apItem.flags = item.flags;
apItem.index = item.index;
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
}); // 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;
}
ArchipelagoConsole_SendMessage("[LOG] Synching Items and Locations.", true);
SynchItems();
SynchSentLocations();
SynchReceivedLocations();
@@ -264,7 +254,6 @@ void ArchipelagoClient::StartLocationScouts() {
void ArchipelagoClient::SynchItems() {
// Send a Synch request to get any items we may have missed
ArchipelagoConsole_SendMessage("[LOG] Sending synch request", true);
apClient->Sync();
}
@@ -278,9 +267,6 @@ void ArchipelagoClient::SynchSentLocations() {
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);
}
@@ -297,7 +283,7 @@ void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
const uint32_t RC = static_cast<uint32_t>(Rando::StaticData::locationNameToEnum[checkName]);
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;
}
@@ -306,9 +292,6 @@ void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
return;
}
std::string locationLog = "[LOG] Externaly checking: " + checkName;
ArchipelagoConsole_SendMessage(locationLog.c_str(), true);
GameInteractor_ExecuteOnRandomizerExternalCheck(RC);
}
@@ -322,7 +305,7 @@ bool ArchipelagoClient::IsConnected() {
void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) {
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;
}
@@ -336,36 +319,27 @@ void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) {
}
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 });
}
void ArchipelagoClient::OnItemReceived(const ApItem apItem) {
// 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
if (!GameInteractor::IsSaveLoaded(true)) {
// 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
return;
}
std::string logMessage = "[LOG] Received " + apItem.itemName;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
// Skip queueing any items we already have
if (apItem.index < gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex) {
// Skip queueing any items we already have
std::string logMessage = "[LOG] Skipping giving " + apItem.itemName + ". We received this previously.";
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
return;
}
// add item to the queue
// Add item to the queue
receiveQueue.push(apItem);
}
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];
if (RG == RG_NONE) {
return;
@@ -386,13 +360,12 @@ void ArchipelagoClient::SendMessageToConsole(const std::string message) {
// local commands not implemented yet
if (message.starts_with("/")) {
ArchipelagoConsole_SendMessage(
"Ship of Harkinian does not have any local commands yet.\nUse \"!help\" to see server commands instead",
false);
"Ship of Harkinian does not have any local commands.\nUse \"!help\" to see server commands instead.");
return;
}
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;
}

View File

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

View File

@@ -18,7 +18,7 @@ class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
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);
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)))) {
bool success = AP_client.StartClient();
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...", true);
}
ImGui::SameLine();
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;
if (!sArchipelagoTexturesLoaded) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage(