Log debug mode & location scouting progress
This commit is contained in:
@@ -178,6 +178,20 @@ typedef struct ShipQuestSaveContextData {
|
|||||||
ShipQuestSpecificSaveContextData data;
|
ShipQuestSpecificSaveContextData data;
|
||||||
} ShipQuestSaveContextData;
|
} ShipQuestSaveContextData;
|
||||||
|
|
||||||
|
typedef struct ArchipelagoLocationData {
|
||||||
|
char itemName[100];
|
||||||
|
char locationName[100];
|
||||||
|
char playerName[17];
|
||||||
|
u8 flags;
|
||||||
|
} ArchipelagoLocationData;
|
||||||
|
|
||||||
|
typedef struct ArchipelagoData {
|
||||||
|
char roomHash[100];
|
||||||
|
char slotName[17];
|
||||||
|
u32 lastReceivedItemIndex;
|
||||||
|
ArchipelagoLocationData locations[RC_MAX];
|
||||||
|
} ArchipelagoData;
|
||||||
|
|
||||||
typedef struct ShipSaveContextData {
|
typedef struct ShipSaveContextData {
|
||||||
u16 pendingSale;
|
u16 pendingSale;
|
||||||
u16 pendingSaleMod;
|
u16 pendingSaleMod;
|
||||||
@@ -185,6 +199,7 @@ typedef struct ShipSaveContextData {
|
|||||||
SohStats stats;
|
SohStats stats;
|
||||||
FaroresWindData backupFW;
|
FaroresWindData backupFW;
|
||||||
ShipQuestSaveContextData quest;
|
ShipQuestSaveContextData quest;
|
||||||
|
ArchipelagoData apData;
|
||||||
u8 maskMemory;
|
u8 maskMemory;
|
||||||
u8 filenameLanguage;
|
u8 filenameLanguage;
|
||||||
//TODO: Move non-rando specific flags to a new sohInf and move the remaining randomizerInf to ShipRandomizerSaveContextData
|
//TODO: Move non-rando specific flags to a new sohInf and move the remaining randomizerInf to ShipRandomizerSaveContextData
|
||||||
@@ -314,12 +329,14 @@ typedef enum {
|
|||||||
/* 01 */ QUEST_MASTER,
|
/* 01 */ QUEST_MASTER,
|
||||||
/* 02 */ QUEST_RANDOMIZER,
|
/* 02 */ QUEST_RANDOMIZER,
|
||||||
/* 03 */ QUEST_BOSSRUSH,
|
/* 03 */ QUEST_BOSSRUSH,
|
||||||
|
/* 03 */ QUEST_ARCHIPELAGO,
|
||||||
} Quest;
|
} Quest;
|
||||||
|
|
||||||
#define IS_VANILLA (gSaveContext.ship.quest.id == QUEST_NORMAL)
|
#define IS_VANILLA (gSaveContext.ship.quest.id == QUEST_NORMAL)
|
||||||
#define IS_MASTER_QUEST (gSaveContext.ship.quest.id == QUEST_MASTER)
|
#define IS_MASTER_QUEST (gSaveContext.ship.quest.id == QUEST_MASTER)
|
||||||
#define IS_RANDO (gSaveContext.ship.quest.id == QUEST_RANDOMIZER)
|
#define IS_RANDO (gSaveContext.ship.quest.id == QUEST_RANDOMIZER)
|
||||||
#define IS_BOSS_RUSH (gSaveContext.ship.quest.id == QUEST_BOSSRUSH)
|
#define IS_BOSS_RUSH (gSaveContext.ship.quest.id == QUEST_BOSSRUSH)
|
||||||
|
#define IS_ARCHIPELAGO (gSaveContext.ship.quest.id == QUEST_ARCHIPELAGO)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* 0x00 */ BTN_ENABLED,
|
/* 0x00 */ BTN_ENABLED,
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) {
|
|||||||
// let arhipelago know we got this check
|
// let arhipelago know we got this check
|
||||||
if(randomizerQueuedCheck != RC_ARCHIPELAGO_RECIEVED_ITEM) {
|
if(randomizerQueuedCheck != RC_ARCHIPELAGO_RECIEVED_ITEM) {
|
||||||
ArchipelagoClient& ap_client = ArchipelagoClient::GetInstance();
|
ArchipelagoClient& ap_client = ArchipelagoClient::GetInstance();
|
||||||
ap_client.check_location(randomizerQueuedCheck);
|
ap_client.CheckLocation(randomizerQueuedCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
loc->SetCheckStatus(RCSHOW_COLLECTED);
|
loc->SetCheckStatus(RCSHOW_COLLECTED);
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ ArchipelagoClient::ArchipelagoClient() {
|
|||||||
std::string uuid = ap_get_uuid("uuid");
|
std::string uuid = ap_get_uuid("uuid");
|
||||||
|
|
||||||
ItemRecievedCallback = nullptr;
|
ItemRecievedCallback = nullptr;
|
||||||
game_won = false;
|
gameWon = false;
|
||||||
|
|
||||||
namespace apc = AP_Client_consts;
|
namespace apc = AP_Client_consts;
|
||||||
CVarSetInteger("ArchipelagoConnected", 0);
|
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("Connected"), 0);
|
||||||
|
|
||||||
// call poll every frame
|
// call poll every frame
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([](){ArchipelagoClient::GetInstance().Poll();});
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([](){ArchipelagoClient::GetInstance().Poll();});
|
||||||
@@ -46,6 +46,11 @@ bool ArchipelagoClient::StartClient() {
|
|||||||
0b001, tags);
|
0b001, tags);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
apClient->set_slot_connected_handler([&](const nlohmann::json) {
|
||||||
|
ArchipelagoConsole_SendMessage("[LOG] Connected.", false);
|
||||||
|
ArchipelagoClient::StartLocationScouts();
|
||||||
|
});
|
||||||
|
|
||||||
apClient->set_items_received_handler([&](const std::list<APClient::NetworkItem>& items) {
|
apClient->set_items_received_handler([&](const std::list<APClient::NetworkItem>& items) {
|
||||||
for(const APClient::NetworkItem& item : items) {
|
for(const APClient::NetworkItem& item : items) {
|
||||||
OnItemReceived(item.item, false); // todo get rid of notify, since it doesn't work for us right now anyway
|
OnItemReceived(item.item, false); // todo get rid of notify, since it doesn't work for us right now anyway
|
||||||
@@ -72,7 +77,9 @@ bool ArchipelagoClient::StartClient() {
|
|||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArchipelagoConsole_SendMessage("[LOG] Scouting finished.");
|
||||||
}); // 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
|
||||||
|
|
||||||
apClient->set_location_checked_handler([&](const std::list<int64_t> locations) {
|
apClient->set_location_checked_handler([&](const std::list<int64_t> locations) {
|
||||||
// todo implement me
|
// todo implement me
|
||||||
});
|
});
|
||||||
@@ -97,7 +104,7 @@ bool ArchipelagoClient::IsConnected() {
|
|||||||
return apClient->get_state() == APClient::State::SLOT_CONNECTED;
|
return apClient->get_state() == APClient::State::SLOT_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::check_location(RandomizerCheck SoH_check_id) {
|
void ArchipelagoClient::CheckLocation(RandomizerCheck SoH_check_id) {
|
||||||
//std::string_view ap_name = Rando::StaticData::SohCheckToAP[SoH_check_id];
|
//std::string_view ap_name = Rando::StaticData::SohCheckToAP[SoH_check_id];
|
||||||
std::string ap_name = Rando::StaticData::GetLocation(SoH_check_id)->GetName();
|
std::string ap_name = Rando::StaticData::GetLocation(SoH_check_id)->GetName();
|
||||||
if(ap_name.empty()) {
|
if(ap_name.empty()) {
|
||||||
@@ -122,14 +129,6 @@ void ArchipelagoClient::RemoveItemRecievedCallback(std::function<void(const std:
|
|||||||
ItemRecievedCallback = nullptr;
|
ItemRecievedCallback = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::OnConnected() {
|
|
||||||
// todo implement me
|
|
||||||
ArchipelagoConsole_SendMessage("[LOG] AP Connected!");
|
|
||||||
}
|
|
||||||
//void ArchipelagoClient::on_couldntConnect(AP_ConnectionStatus connection_status) {
|
|
||||||
// // todo implement me
|
|
||||||
//}
|
|
||||||
|
|
||||||
void ArchipelagoClient::OnItemReceived(int64_t recieved_item_id, bool notify_player) {
|
void ArchipelagoClient::OnItemReceived(int64_t recieved_item_id, bool notify_player) {
|
||||||
// call each callback
|
// call each callback
|
||||||
const std::string item_name = apClient->get_item_name(recieved_item_id, AP_Client_consts::AP_GAME_NAME);
|
const std::string item_name = apClient->get_item_name(recieved_item_id, AP_Client_consts::AP_GAME_NAME);
|
||||||
@@ -142,9 +141,9 @@ void ArchipelagoClient::OnItemReceived(int64_t recieved_item_id, bool notify_pla
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::SendGameWon() {
|
void ArchipelagoClient::SendGameWon() {
|
||||||
if(!game_won) {
|
if(!gameWon) {
|
||||||
apClient->StatusUpdate(APClient::ClientStatus::GOAL);
|
apClient->StatusUpdate(APClient::ClientStatus::GOAL);
|
||||||
game_won = true;
|
gameWon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class ArchipelagoClient{
|
|||||||
const std::vector<ApItem>& GetScoutedItems();
|
const std::vector<ApItem>& GetScoutedItems();
|
||||||
|
|
||||||
bool IsConnected();
|
bool IsConnected();
|
||||||
void check_location(RandomizerCheck SoH_check_id);
|
void CheckLocation(RandomizerCheck SoH_check_id);
|
||||||
|
|
||||||
// callback slots
|
// callback slots
|
||||||
void AddItemRecievedCallback(std::function<void(const std::string&)> callback);
|
void AddItemRecievedCallback(std::function<void(const std::string&)> callback);
|
||||||
@@ -65,19 +65,17 @@ class ArchipelagoClient{
|
|||||||
static std::shared_ptr<ArchipelagoClient> instance; // is this even used?
|
static std::shared_ptr<ArchipelagoClient> instance; // is this even used?
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
|
|
||||||
bool game_won;
|
bool gameWon;
|
||||||
|
|
||||||
std::map<std::string, int> slotData;
|
std::map<std::string, int> slotData;
|
||||||
std::set<int64_t> locations;
|
std::set<int64_t> locations;
|
||||||
std::vector<ApItem> scoutedItems;
|
std::vector<ApItem> scoutedItems;
|
||||||
|
|
||||||
// callback functions
|
// Callback Functions
|
||||||
void OnConnected();
|
|
||||||
|
|
||||||
void OnLocationChecked(int64_t location_id);
|
void OnLocationChecked(int64_t location_id);
|
||||||
void OnDeathLinkReceived() { }; // TODO: implement me
|
void OnDeathLinkReceived() { }; // TODO: implement me
|
||||||
|
|
||||||
// callbacks
|
// Callbacks
|
||||||
std::function<void(const std::string&)> ItemRecievedCallback;
|
std::function<void(const std::string&)> ItemRecievedCallback;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ bool autoScroll = true;
|
|||||||
|
|
||||||
using namespace UIWidgets;
|
using namespace UIWidgets;
|
||||||
|
|
||||||
void ArchipelagoConsole_SendMessage(const char* fmt, ...) {
|
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage, ...) {
|
||||||
|
if (!debugMessage || CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"), 0)) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
@@ -18,6 +19,7 @@ void ArchipelagoConsole_SendMessage(const char* fmt, ...) {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
Items.push_back(strdup(buf));
|
Items.push_back(strdup(buf));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ArchipelagoConsoleWindow::DrawElement() {
|
void ArchipelagoConsoleWindow::DrawElement() {
|
||||||
ImGui::SeparatorText("Archipelago Log");
|
ImGui::SeparatorText("Archipelago Log");
|
||||||
@@ -60,11 +62,4 @@ void ArchipelagoConsoleWindow::DrawElement() {
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::PopStyleVar(2);
|
ImGui::PopStyleVar(2);
|
||||||
|
|
||||||
if (UIWidgets::Button("Add dummy lines to log",
|
|
||||||
UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Hello World");
|
|
||||||
ArchipelagoConsole_SendMessage("[ERROR] Hello World");
|
|
||||||
ArchipelagoConsole_SendMessage("Hello World");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
|
|||||||
void UpdateElement() override {};
|
void UpdateElement() override {};
|
||||||
};
|
};
|
||||||
|
|
||||||
void ArchipelagoConsole_SendMessage(const char* fmt, ...);
|
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage = true, ...);
|
||||||
|
|
||||||
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H
|
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H
|
||||||
@@ -38,13 +38,19 @@ 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...");
|
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Temporary developer helpers
|
||||||
|
UIWidgets::Separator();
|
||||||
|
if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"), 0)) {
|
||||||
ImGui::SeparatorText("Developer Tools");
|
ImGui::SeparatorText("Developer Tools");
|
||||||
if (UIWidgets::Button("Scout", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
if (UIWidgets::Button("Scout", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
||||||
AP_client.StartLocationScouts();
|
AP_client.StartLocationScouts();
|
||||||
@@ -54,8 +60,9 @@ void ArchipelagoSettingsWindow::DrawElement() {
|
|||||||
CVarSetInteger("ArchipelagoConnected", 1);
|
CVarSetInteger("ArchipelagoConnected", 1);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (UIWidgets::Button("Give Blue Rupee", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
if (UIWidgets::Button("Give Blue Rupee",
|
||||||
|
UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
||||||
ArchipelagoClient::GetInstance().OnItemReceived(66077, true);
|
ArchipelagoClient::GetInstance().OnItemReceived(66077, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1075,7 +1075,7 @@ void FileChoose_UpdateRandomizer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CVarGetInteger("ArchipelagoConnected", 0) && !fileSelectArchipelagoLoaded) {
|
if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("Connected"), 0) && !fileSelectArchipelagoLoaded) {
|
||||||
ParseArchipelago();
|
ParseArchipelago();
|
||||||
fileSelectArchipelagoLoaded = true;
|
fileSelectArchipelagoLoaded = true;
|
||||||
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
||||||
|
|||||||
Reference in New Issue
Block a user