clang-format

This commit is contained in:
aMannus
2025-06-30 11:40:20 +02:00
parent ae17e572a0
commit abe682e0f2
11 changed files with 227 additions and 210 deletions

View File

@@ -355,7 +355,7 @@ void Context::AddReceivedArchipelagoItem(const RandomizerGet item) {
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
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_HEART);
}
@@ -368,7 +368,7 @@ GetItemEntry Context::GetArchipelagoGIEntry() {
SPDLOG_TRACE("Found item! {}, {}", item.GetName().GetEnglish(), (int)item_id);
GetItemEntry item_entry = item.GetGIEntry_Copy();
mAPreceiveQueue.pop();
return item_entry; // todo: add custom text maybe?
return item_entry; // todo: add custom text maybe?
}
GetItemEntry Context::GetFinalGIEntry(const RandomizerCheck rc, const bool checkObtainability,
@@ -705,19 +705,19 @@ void Context::ParseArchipelagoOptions(const std::map<std::string, int>& slot_dat
void Context::ParseArchipelagoItemsLocations(const std::vector<ArchipelagoClient::ApItem>& scouted_items) {
const std::string SlotName = ArchipelagoClient::GetInstance().GetSlotName();
// Zero out the location table first
for(int rc = 1; rc < RC_MAX; rc++) {
for (int rc = 1; rc < RC_MAX; rc++) {
itemLocationTable[rc].SetPlacedItem(RG_NONE);
}
for(const ArchipelagoClient::ApItem& ap_item: scouted_items) {
//const RandomizerCheck rc = StaticData::APcheckToSoh.find(ap_item.locationName)->second;
for (const ArchipelagoClient::ApItem& ap_item : scouted_items) {
// const RandomizerCheck rc = StaticData::APcheckToSoh.find(ap_item.locationName)->second;
const RandomizerCheck rc = StaticData::locationNameToEnum[ap_item.locationName];
itemLocationTable[rc].SetCustomPrice(10);
if(SlotName == ap_item.playerName) {
if (SlotName == ap_item.playerName) {
// our item
SPDLOG_TRACE("Populated item {} at location {}", ap_item.itemName, ap_item.locationName);
const RandomizerGet item = StaticData::itemNameToEnum[ap_item.itemName];
@@ -727,10 +727,10 @@ void Context::ParseArchipelagoItemsLocations(const std::vector<ArchipelagoClient
// If progressive or trap bit flag is set, make item progressive.
if (ap_item.flags & (1 << 0) || ap_item.flags & (1 << 2)) {
itemLocationTable[rc].SetPlacedItem(RG_ARCHIPELAGO_ITEM_PROGRESSIVE);
// If useful bit flag is on, make item useful.
// If useful bit flag is on, make item useful.
} else if (ap_item.flags & (1 << 1)) {
itemLocationTable[rc].SetPlacedItem(RG_ARCHIPELAGO_ITEM_USEFUL);
// None of these flags being present means it's junk.
// None of these flags being present means it's junk.
} else {
itemLocationTable[rc].SetPlacedItem(RG_ARCHIPELAGO_ITEM_JUNK);
}

View File

@@ -290,15 +290,15 @@ void RandomizerOnExternalCheckHandler(uint32_t randomizerCheck) {
SceneID scene = loc->GetScene();
bool inSameArea = false;
if(gPlayState != nullptr) {
if (gPlayState != nullptr) {
inSameArea = scene == gPlayState->sceneNum;
}
std::string logMessage = "";
switch(loc->GetCollectionCheck().type) {
switch (loc->GetCollectionCheck().type) {
case SPOILER_CHK_CHEST:
if(inSameArea) {
if (inSameArea) {
Flags_SetTreasure(gPlayState, flagID);
} else {
gSaveContext.sceneFlags[scene].chest |= 1 << flagID;
@@ -306,7 +306,7 @@ void RandomizerOnExternalCheckHandler(uint32_t randomizerCheck) {
}
break;
case SPOILER_CHK_COLLECTABLE:
if(inSameArea) {
if (inSameArea) {
Flags_SetCollectible(gPlayState, flagID);
} else {
gSaveContext.sceneFlags[scene].collect |= 1 << flagID;
@@ -325,11 +325,12 @@ 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);
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
case SPOILER_CHK_GRAVEDIGGER: // This enum is used nowhere in code, so i'll leave it as nothing for now
case SPOILER_CHK_NONE:
// do Nothing
break;
@@ -393,7 +394,7 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() {
(getItemEntry.getItemCategory == ITEM_CATEGORY_JUNK ||
getItemEntry.getItemCategory == ITEM_CATEGORY_SKULLTULA_TOKEN ||
getItemEntry.getItemCategory == ITEM_CATEGORY_LESSER))))) {
Item_DropCollectible(gPlayState, &spawnPos, static_cast<int16_t>(ITEM00_SOH_GIVE_ITEM_ENTRY | 0x8000));
isGiSkipped = 1;
@@ -1097,8 +1098,8 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l
});
} else if (item00->itemEntry.modIndex == MOD_RANDOMIZER) {
if (!(item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_PROGRESSIVE ||
item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_USEFUL ||
item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_JUNK)) {
item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_USEFUL ||
item00->itemEntry.getItemId == RG_ARCHIPELAGO_ITEM_JUNK)) {
Notification::Emit({
.message = "You found ",
.suffix = Rando::StaticData::RetrieveItem((RandomizerGet)item00->itemEntry.getItemId)
@@ -2523,7 +2524,7 @@ void RandomizerRegisterHooks() {
RandomizerOnKaleidoscopeUpdateHandler);
onCuccoOrChickenHatchHook = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnCuccoOrChickenHatch>(
RandomizerOnCuccoOrChickenHatch);
COND_HOOK(GameInteractor::OnArchipelagoItemReceived, IS_ARCHIPELAGO, ArchipelagoOnReceiveItem);
COND_HOOK(GameInteractor::OnRandomizerExternalCheck, IS_ARCHIPELAGO, RandomizerOnExternalCheckHandler)

View File

@@ -133,7 +133,7 @@ bool ItemLocation::HasObtained() const {
}
void ItemLocation::SetCheckStatus(RandomizerCheckStatus status_) {
if(rc == RC_ARCHIPELAGO_RECEIVED_ITEM) // never count the AP receive trigger as 'collected'
if (rc == RC_ARCHIPELAGO_RECEIVED_ITEM) // never count the AP receive trigger as 'collected'
return;
status = status_;
}

View File

@@ -3482,7 +3482,7 @@ ShopItemIdentity Randomizer::IdentifyShopItem(s32 sceneNum, u8 slotIndex) {
if (randoCheck != RC_UNKNOWN_CHECK) {
RandomizerGet randoGet = Rando::Context::GetInstance()->GetItemLocation(randoCheck)->GetPlacedRandomizerGet();
if (randoGet != RG_NONE) {
shopItemIdentity.randomizerInf = rcToRandomizerInf[randoCheck];
shopItemIdentity.randomizerCheck = randoCheck;
@@ -5350,10 +5350,11 @@ CustomMessage Randomizer::GetGoronMessage(u16 index) {
void CreateArchipelagoItemMessage() {
CustomMessageManager* customMessageManager = CustomMessageManager::Instance;
customMessageManager->AddCustomMessageTable(Randomizer::archipelagoItemsTableID);
customMessageManager->CreateMessage(
customMessageManager->CreateMessage(
Randomizer::archipelagoItemsTableID, 0,
CustomMessage("You found [[apcolor]][[apitem]]%w for %r[[applayer]]%w!", "You found \x05\x06[[apitem]]\x05\x00 for \x05\x05[[applayer]]\x05\x00!",
"You found \x05\x06[[apitem]]\x05\x00 for \x05\x05[[applayer]]\x05\x00!"));
CustomMessage("You found [[apcolor]][[apitem]]%w for %r[[applayer]]%w!",
"You found \x05\x06[[apitem]]\x05\x00 for \x05\x05[[applayer]]\x05\x00!",
"You found \x05\x06[[apitem]]\x05\x00 for \x05\x05[[applayer]]\x05\x00!"));
}
CustomMessage Randomizer::GetArchipelagoItemMessage(int16_t randomizerGet, uint32_t randomizerCheck) {
@@ -5370,7 +5371,8 @@ CustomMessage Randomizer::GetArchipelagoItemMessage(int16_t randomizerGet, uint3
}
messageEntry.Replace("[[apcolor]]", itemColor);
messageEntry.Replace("[[apitem]]", std::string(gSaveContext.ship.quest.data.archipelago.locations[randomizerCheck].itemName));
messageEntry.Replace("[[apitem]]",
std::string(gSaveContext.ship.quest.data.archipelago.locations[randomizerCheck].itemName));
messageEntry.Replace("[[applayer]]",
std::string(gSaveContext.ship.quest.data.archipelago.locations[randomizerCheck].playerName));
messageEntry.AutoFormat();

View File

@@ -38,7 +38,7 @@ ArchipelagoClient& ArchipelagoClient::GetInstance() {
}
bool ArchipelagoClient::StartClient() {
if(apClient != NULL) {
if (apClient != NULL) {
apClient.reset();
}
@@ -51,20 +51,19 @@ bool ArchipelagoClient::StartClient() {
std::list<std::string> tags;
// tags.push_back("DeathLink"); // todo, implement deathlink
apClient->ConnectSlot(CVarGetString(CVAR_REMOTE_ARCHIPELAGO("SlotName"), ""),
CVarGetString(CVAR_REMOTE_ARCHIPELAGO("Password"), ""),
0b001, tags);
CVarGetString(CVAR_REMOTE_ARCHIPELAGO("Password"), ""), 0b001, tags);
});
apClient->set_slot_connected_handler([&](const nlohmann::json data) {
ArchipelagoConsole_SendMessage("[LOG] Connected.", true);
ArchipelagoClient::StartLocationScouts();
slotData = data;
// if we are already in game when we connect
// if we are already in game when we connect
// we won't have to request an itemSynch
if(GameInteractor::IsSaveLoaded(true)) {
if(!isRightSaveLoaded()) {
if (GameInteractor::IsSaveLoaded(true)) {
if (!isRightSaveLoaded()) {
disconnecting = true;
ArchipelagoConsole_SendMessage("[ERROR] Connected to incorrect slot, disconnecting...");
return;
@@ -76,11 +75,11 @@ bool ArchipelagoClient::StartClient() {
});
apClient->set_items_received_handler([&](const std::list<APClient::NetworkItem>& items) {
if(disconnecting) {
if (disconnecting) {
return;
}
for(const APClient::NetworkItem& item : items) {
for (const APClient::NetworkItem& item : items) {
ApItem apItem;
const std::string game = apClient->get_player_game(item.player);
apItem.itemName = apClient->get_item_name(item.item, AP_Client_consts::AP_GAME_NAME);
@@ -93,13 +92,13 @@ bool ArchipelagoClient::StartClient() {
});
apClient->set_location_info_handler([&](const std::list<APClient::NetworkItem>& items) {
if(disconnecting) {
if (disconnecting) {
return;
}
scoutedItems.clear();
for(const APClient::NetworkItem& item: items) {
for (const APClient::NetworkItem& item : items) {
ApItem apItem;
const std::string game = apClient->get_player_game(item.player);
apItem.itemName = apClient->get_item_name(item.item, game);
@@ -112,61 +111,75 @@ bool ArchipelagoClient::StartClient() {
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;
std::string logMessage =
"[LOG] Location scouted: " + itemName + " for " + playerName + " in location " + locationName;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
}
ArchipelagoConsole_SendMessage("[LOG] Scouting finished.", true);
}); // 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) {
if(disconnecting) {
if (disconnecting) {
return;
}
for(const int64_t apLoc : locations) {
for (const int64_t apLoc : locations) {
QueueExternalCheck(apLoc);
}
});
apClient->set_print_json_handler([&](const APClient::PrintJSONArgs& arg) {
if(disconnecting) {
if (disconnecting) {
return;
}
std::vector<ColoredTextNode> coloredNodes;
for(const APClient::TextNode& node : arg.data) {
for (const APClient::TextNode& node : arg.data) {
APClient* client = apClient.get();
std::string color;
std::string text;
if(node.type == "player_id") {
if (node.type == "player_id") {
int id = std::stoi(node.text);
if (color.empty() && id == client->get_player_number()) color = "magenta";
else if(color.empty()) color = "yellow";
if (color.empty() && id == client->get_player_number())
color = "magenta";
else if (color.empty())
color = "yellow";
text = client->get_player_alias(id);
} else if (node.type == "item_id") {
int64_t id = std::stoll(node.text);
if(color.empty()) {
if (node.flags & APClient::ItemFlags::FLAG_ADVANCEMENT) color = "plum";
else if (node.flags & APClient::ItemFlags::FLAG_NEVER_EXCLUDE) color = "slateblue";
else if (node.flags & APClient::ItemFlags::FLAG_TRAP) color = "salmon";
else color = "cyan";
if (color.empty()) {
if (node.flags & APClient::ItemFlags::FLAG_ADVANCEMENT)
color = "plum";
else if (node.flags & APClient::ItemFlags::FLAG_NEVER_EXCLUDE)
color = "slateblue";
else if (node.flags & APClient::ItemFlags::FLAG_TRAP)
color = "salmon";
else
color = "cyan";
}
text = client->get_item_name(id, client->get_player_game(node.player));
} else if (node.type == "location_id") {
int64_t id = std::stoll(node.text);
if (color.empty()) color = "blue";
if (color.empty())
color = "blue";
text = client->get_location_name(id, client->get_player_game(node.player));
} else if (node.type == "hint_status") {
text = node.text;
if (node.hintStatus == APClient::HINT_FOUND) color = "green";
else if (node.hintStatus == APClient::HINT_UNSPECIFIED) color = "grey";
else if (node.hintStatus == APClient::HINT_NO_PRIORITY) color = "slateblue";
else if (node.hintStatus == APClient::HINT_AVOID) color = "salmon";
else if (node.hintStatus == APClient::HINT_PRIORITY) color = "plum";
else color = "red"; // unknown status -> red
if (node.hintStatus == APClient::HINT_FOUND)
color = "green";
else if (node.hintStatus == APClient::HINT_UNSPECIFIED)
color = "grey";
else if (node.hintStatus == APClient::HINT_NO_PRIORITY)
color = "slateblue";
else if (node.hintStatus == APClient::HINT_AVOID)
color = "salmon";
else if (node.hintStatus == APClient::HINT_PRIORITY)
color = "plum";
else
color = "red"; // unknown status -> red
} else if (node.type == "ERROR") {
color = "ERROR";
text = node.text;
@@ -191,18 +204,18 @@ bool ArchipelagoClient::StartClient() {
}
void ArchipelagoClient::GameLoaded() {
if(apClient == nullptr) {
if (apClient == nullptr) {
return;
}
// if its not an AP save, disconnect
if(!IS_ARCHIPELAGO) {
if (!IS_ARCHIPELAGO) {
ArchipelagoConsole_SendMessage("[ERROR] Loaded save is not not an archipelago save, disconnecting...");
disconnecting = true;
return;
}
if(!isRightSaveLoaded()) {
if (!isRightSaveLoaded()) {
ArchipelagoConsole_SendMessage("[ERROR] Loaded save is not associated with connected slot, disconnecting...");
disconnecting = true;
return;
@@ -219,10 +232,10 @@ void ArchipelagoClient::StartLocationScouts() {
std::set<int64_t> missing_loc_set = apClient->get_missing_locations();
std::set<int64_t> found_loc_set = apClient->get_checked_locations();
std::list<int64_t> location_list;
for(const int64_t loc_id : missing_loc_set) {
for (const int64_t loc_id : missing_loc_set) {
location_list.emplace_back(loc_id);
}
for(const int64_t loc_id : found_loc_set) {
for (const int64_t loc_id : found_loc_set) {
location_list.emplace_back(loc_id);
}
apClient->LocationScouts(location_list);
@@ -237,14 +250,15 @@ void ArchipelagoClient::SynchItems() {
void ArchipelagoClient::SynchSentLocations() {
// send already checked locations
std::list<int64_t> checkedLocations;
for(const auto& loc : Rando::StaticData::GetLocationTable()) {
for (const auto& loc : Rando::StaticData::GetLocationTable()) {
const RandomizerCheck rc = loc.GetRandomizerCheck();
if(Rando::Context::GetInstance()->GetItemLocation(rc)->HasObtained()) {
if (Rando::Context::GetInstance()->GetItemLocation(rc)->HasObtained()) {
const int64_t apLocation = apClient->get_location_id(loc.GetName());
checkedLocations.emplace_back(apLocation);
}
}
std::string locationLog = "[LOG] Synching " + std::to_string(checkedLocations.size())+ " checks already found in game";
std::string locationLog =
"[LOG] Synching " + std::to_string(checkedLocations.size()) + " checks already found in game";
ArchipelagoConsole_SendMessage(locationLog.c_str(), true);
apClient->LocationChecks(checkedLocations);
@@ -252,7 +266,7 @@ void ArchipelagoClient::SynchSentLocations() {
void ArchipelagoClient::SynchReceivedLocations() {
// Open checks that have been found previously but went unsaved
for(const int64_t apLoc : apClient->get_checked_locations()) {
for (const int64_t apLoc : apClient->get_checked_locations()) {
QueueExternalCheck(apLoc);
}
}
@@ -261,13 +275,13 @@ void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
const std::string checkName = apClient->get_location_name(apLocation, AP_Client_consts::AP_GAME_NAME);
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);
return;
}
// Don't queue checks we already have
if(Rando::Context::GetInstance()->GetItemLocation(RC)->HasObtained()) {
if (Rando::Context::GetInstance()->GetItemLocation(RC)->HasObtained()) {
return;
}
@@ -278,7 +292,7 @@ void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
}
bool ArchipelagoClient::IsConnected() {
if(apClient == nullptr) {
if (apClient == nullptr) {
return false;
}
@@ -286,12 +300,12 @@ bool ArchipelagoClient::IsConnected() {
}
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);
return;
}
if(!IsConnected()) {
if (!IsConnected()) {
return;
}
@@ -308,7 +322,7 @@ void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) {
}
void ArchipelagoClient::OnItemReceived(const ApItem apItem) {
if(!GameInteractor::IsSaveLoaded(true)) {
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;
@@ -317,7 +331,7 @@ void ArchipelagoClient::OnItemReceived(const ApItem apItem) {
std::string logMessage = "[LOG] Received " + apItem.itemName;
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
if(apItem.index < gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex) {
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);
@@ -332,7 +346,7 @@ 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) {
if (RG == RG_NONE) {
return;
}
@@ -341,7 +355,7 @@ void ArchipelagoClient::QueueItem(const ApItem item) {
}
void ArchipelagoClient::SendGameWon() {
if(!gameWon) {
if (!gameWon) {
apClient->StatusUpdate(APClient::ClientStatus::GOAL);
gameWon = true;
}
@@ -349,12 +363,14 @@ void ArchipelagoClient::SendGameWon() {
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);
if (message.starts_with("/")) {
ArchipelagoConsole_SendMessage(
"Ship of Harkinian does not have any local commands yet.\nUse \"!help\" to see server commands instead",
false);
return;
}
if(apClient == nullptr) {
if (apClient == nullptr) {
ArchipelagoConsole_SendMessage("[ERROR] Could not send message. Please Connect to your slot.", false);
return;
}
@@ -363,24 +379,24 @@ void ArchipelagoClient::SendMessageToConsole(const std::string message) {
}
void ArchipelagoClient::Poll() {
if(apClient == nullptr) {
if (apClient == nullptr) {
return;
}
if(disconnecting) {
if (disconnecting) {
apClient->reset();
apClient = nullptr;
return;
}
// queue another item to be received
if(!itemQueued && receiveQueue.size() > 0) {
if (!itemQueued && receiveQueue.size() > 0) {
const ApItem item = receiveQueue.front();
receiveQueue.pop();
QueueItem(item);
}
apClient->poll();
}
@@ -391,7 +407,7 @@ bool ArchipelagoClient::isRightSaveLoaded() const {
}
const std::string ArchipelagoClient::GetSlotName() const {
if(apClient == NULL) {
if (apClient == NULL) {
return "";
}
@@ -413,7 +429,7 @@ const char* ArchipelagoClient::GetConnectionStatus() {
APClient::State clientStatus = apClient->get_state();
switch (clientStatus) {
switch (clientStatus) {
case APClient::State::DISCONNECTED: {
return "Disconnected!";
}
@@ -472,8 +488,7 @@ void LoadArchipelagoData() {
ARRAY_COUNT(gSaveContext.ship.quest.data.archipelago.slotName));
SaveManager::Instance->LoadArray(
"locations", ARRAY_COUNT(gSaveContext.ship.quest.data.archipelago.locations),
[](size_t i) {
"locations", ARRAY_COUNT(gSaveContext.ship.quest.data.archipelago.locations), [](size_t i) {
SaveManager::Instance->LoadStruct("", [&i]() {
SaveManager::Instance->LoadCharArray(
"itemName", gSaveContext.ship.quest.data.archipelago.locations[i].itemName,
@@ -529,42 +544,43 @@ void RegisterArchipelago() {
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("Connected"), 0);
COND_HOOK(GameInteractor::OnGameFrameUpdate, true, [](){ArchipelagoClient::GetInstance().Poll();});
COND_HOOK(GameInteractor::PostLoadGame, true, [](int32_t file_id){ArchipelagoClient::GetInstance().GameLoaded();});
COND_HOOK(GameInteractor::OnRandomizerItemGivenHooks, IS_ARCHIPELAGO,
[](uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped) {
if (rc == RC_ARCHIPELAGO_RECEIVED_ITEM) {
gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex++;
ArchipelagoClient::GetInstance().itemQueued = false;
} else {
ArchipelagoClient::GetInstance().CheckLocation((RandomizerCheck)rc);
COND_HOOK(GameInteractor::OnGameFrameUpdate, true, []() { ArchipelagoClient::GetInstance().Poll(); });
COND_HOOK(GameInteractor::PostLoadGame, true,
[](int32_t file_id) { ArchipelagoClient::GetInstance().GameLoaded(); });
COND_HOOK(
GameInteractor::OnRandomizerItemGivenHooks, IS_ARCHIPELAGO,
[](uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped) {
if (rc == RC_ARCHIPELAGO_RECEIVED_ITEM) {
gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex++;
ArchipelagoClient::GetInstance().itemQueued = false;
} else {
ArchipelagoClient::GetInstance().CheckLocation((RandomizerCheck)rc);
if (isGiSkipped && gi.modIndex == MOD_RANDOMIZER &&
(gi.getItemId == RG_ARCHIPELAGO_ITEM_PROGRESSIVE || gi.getItemId == RG_ARCHIPELAGO_ITEM_USEFUL ||
gi.getItemId == RG_ARCHIPELAGO_ITEM_JUNK)) {
if (isGiSkipped && gi.modIndex == MOD_RANDOMIZER &&
(gi.getItemId == RG_ARCHIPELAGO_ITEM_PROGRESSIVE || gi.getItemId == RG_ARCHIPELAGO_ITEM_USEFUL ||
gi.getItemId == RG_ARCHIPELAGO_ITEM_JUNK)) {
const char* itemIcon = "";
switch (gi.getItemId) {
case RG_ARCHIPELAGO_ITEM_PROGRESSIVE:
itemIcon = "Archipelago Progressive Icon";
break;
case RG_ARCHIPELAGO_ITEM_USEFUL:
itemIcon = "Archipelago Useful Icon";
break;
case RG_ARCHIPELAGO_ITEM_JUNK:
itemIcon = "Archipelago Junk Icon";
break;
const char* itemIcon = "";
switch (gi.getItemId) {
case RG_ARCHIPELAGO_ITEM_PROGRESSIVE:
itemIcon = "Archipelago Progressive Icon";
break;
case RG_ARCHIPELAGO_ITEM_USEFUL:
itemIcon = "Archipelago Useful Icon";
break;
case RG_ARCHIPELAGO_ITEM_JUNK:
itemIcon = "Archipelago Junk Icon";
break;
}
Notification::Emit(
{ .itemIcon = itemIcon,
.prefix = std::string(gSaveContext.ship.quest.data.archipelago.locations[rc].itemName),
.message = " for ",
.suffix = std::string(gSaveContext.ship.quest.data.archipelago.locations[rc].playerName) });
}
Notification::Emit({
.itemIcon = itemIcon,
.prefix = std::string(gSaveContext.ship.quest.data.archipelago.locations[rc].itemName),
.message = " for ",
.suffix = std::string(gSaveContext.ship.quest.data.archipelago.locations[rc].playerName)
});
}
}
});
});
}
static RegisterShipInitFunc initFunc(RegisterArchipelago, { "IS_ARCHIPELAGO" });

View File

@@ -10,81 +10,81 @@
class APClient;
namespace AP_Client_consts {
static constexpr int MAX_ADDRESS_LENGTH = 64;
static constexpr int MAX_PLAYER_NAME_LENGHT = 17;
static constexpr int MAX_PASSWORD_LENGTH = 32;
static constexpr int MAX_ADDRESS_LENGTH = 64;
static constexpr int MAX_PLAYER_NAME_LENGHT = 17;
static constexpr int MAX_PASSWORD_LENGTH = 32;
static constexpr char const* AP_GAME_NAME = "Ship of Harkinian";
}
static constexpr char const* AP_GAME_NAME = "Ship of Harkinian";
} // namespace AP_Client_consts
class ArchipelagoClient{
public:
struct ApItem {
std::string itemName;
std::string locationName;
std::string playerName;
unsigned int flags;
uint64_t index;
};
class ArchipelagoClient {
public:
struct ApItem {
std::string itemName;
std::string locationName;
std::string playerName;
unsigned int flags;
uint64_t index;
};
struct ColoredTextNode {
std::string text;
std::string color;
};
struct ColoredTextNode {
std::string text;
std::string color;
};
static ArchipelagoClient& GetInstance();
static ArchipelagoClient& GetInstance();
bool StartClient();
bool StopClient();
bool StartClient();
bool StopClient();
void GameLoaded();
void StartLocationScouts();
void SynchItems();
void SynchSentLocations();
void SynchReceivedLocations();
void GameLoaded();
void StartLocationScouts();
void SynchItems();
void SynchSentLocations();
void SynchReceivedLocations();
// getters
const std::string GetSlotName() const;
// getters
const std::string GetSlotName() const;
const char* GetConnectionStatus();
const nlohmann::json GetSlotData();
const std::vector<ApItem>& GetScoutedItems();
const char* GetConnectionStatus();
const nlohmann::json GetSlotData();
const std::vector<ApItem>& GetScoutedItems();
bool IsConnected();
void CheckLocation(RandomizerCheck SoH_check_id);
bool IsConnected();
void CheckLocation(RandomizerCheck SoH_check_id);
void OnItemReceived(const ApItem apItem);
void QueueItem(const ApItem item);
void QueueExternalCheck(int64_t apLocation);
void OnItemReceived(const ApItem apItem);
void QueueItem(const ApItem item);
void QueueExternalCheck(int64_t apLocation);
void SendGameWon();
void SendMessageToConsole(const std::string message);
void Poll();
void SendGameWon();
void SendMessageToConsole(const std::string message);
void Poll();
std::unique_ptr<APClient> apClient;
bool itemQueued;
bool disconnecting;
std::unique_ptr<APClient> apClient;
bool itemQueued;
bool disconnecting;
protected:
ArchipelagoClient();
protected:
ArchipelagoClient();
private:
ArchipelagoClient(ArchipelagoClient &) = delete;
void operator=(const ArchipelagoClient &) = delete;
private:
ArchipelagoClient(ArchipelagoClient&) = delete;
void operator=(const ArchipelagoClient&) = delete;
bool isRightSaveLoaded() const;
bool isRightSaveLoaded() const;
std::string uuid;
std::string uuid;
static std::shared_ptr<ArchipelagoClient> instance;
static bool initialized;
static std::shared_ptr<ArchipelagoClient> instance;
static bool initialized;
bool gameWon;
bool gameWon;
nlohmann::json slotData;
std::set<int64_t> locations;
std::vector<ApItem> scoutedItems;
std::queue<ApItem> receiveQueue;
nlohmann::json slotData;
std::set<int64_t> locations;
std::vector<ApItem> scoutedItems;
std::queue<ApItem> receiveQueue;
};
void LoadArchipelagoData();

View File

@@ -47,8 +47,8 @@ void ArchipelagoConsoleWindow::DrawElement() {
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 400), ImGuiChildFlags_AlwaysUseWindowPadding,
ImGuiWindowFlags_HorizontalScrollbar)) {
for(const std::vector<ArchipelagoClient::ColoredTextNode>& line : Items) {
for(const ArchipelagoClient::ColoredTextNode& node : line) {
for (const std::vector<ArchipelagoClient::ColoredTextNode>& line : Items) {
for (const ArchipelagoClient::ColoredTextNode& node : line) {
ImGui::PushStyleColor(ImGuiCol_Text, getColorVal(node.color));
ImGui::TextUnformatted(node.text.c_str());
ImGui::SameLine();
@@ -69,56 +69,55 @@ void ArchipelagoConsoleWindow::DrawElement() {
static char textEntryBuf[1024];
static bool keepFocus = false;
if(keepFocus) {
if (keepFocus) {
ImGui::SetKeyboardFocusHere();
keepFocus = false;
}
if(ImGui::InputText("##AP_MessageField", textEntryBuf, 1023, ImGuiInputTextFlags_EnterReturnsTrue)) {
if (ImGui::InputText("##AP_MessageField", textEntryBuf, 1023, ImGuiInputTextFlags_EnterReturnsTrue)) {
ArchipelagoClient::GetInstance().SendMessageToConsole(std::string(textEntryBuf));
textEntryBuf[0] = '\0';
keepFocus = true;
}
//keepFocus = ImGui::IsItemActive();
// keepFocus = ImGui::IsItemActive();
ImGui::SameLine();
if(ImGui::Button("Send")) {
if (ImGui::Button("Send")) {
ArchipelagoClient::GetInstance().SendMessageToConsole(std::string(textEntryBuf));
textEntryBuf[0] = '\0';
keepFocus = true;
}
ImGui::PopStyleColor();
ImGui::PopStyleVar(4);
};
ImVec4 getColorVal(const std::string& color) { // TODO change color strings to an enum
ImVec4 getColorVal(const std::string& color) { // TODO change color strings to an enum
if (color == "ERROR") {
return ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
} else if(color =="LOG") {
} else if (color == "LOG") {
return ImVec4(0.7f, 0.7f, 1.0f, 1.0f);
} else if(color == "black") {
} else if (color == "black") {
return ImVec4(0.000f, 0.000f, 0.000f, 1.00f);
} else if(color == "red") {
} else if (color == "red") {
return ImVec4(0.933f, 0.000f, 0.000f, 1.00f);
} else if(color == "green") {
} else if (color == "green") {
return ImVec4(0.000f, 1.000f, 0.498f, 1.00f);
} else if(color == "yellow") {
} else if (color == "yellow") {
return ImVec4(0.980f, 0.980f, 0.824f, 1.00f);
} else if(color == "blue") {
} else if (color == "blue") {
return ImVec4(0.392f, 0.584f, 0.929f, 1.00f);
} else if(color == "cyan") {
} else if (color == "cyan") {
return ImVec4(0.000f, 0.933f, 0.933f, 1.00f);
} else if(color == "magenta") {
} else if (color == "magenta") {
return ImVec4(0.933f, 0.000f, 0.933f, 1.00f);
} else if(color == "slateblue") {
} else if (color == "slateblue") {
return ImVec4(0.427f, 0.545f, 0.910f, 1.00f);
} else if(color == "plum") {
} else if (color == "plum") {
return ImVec4(0.686f, 0.600f, 0.937f, 1.00f);
} else if(color == "salmon") {
} else if (color == "salmon") {
return ImVec4(0.980f, 0.502f, 0.447f, 1.00f);
} else if(color == "white") {
} else if (color == "white") {
return ImVec4(0.93f, 0.93f, 0.93f, 1.00f);
} else if(color == "orange") {
} else if (color == "orange") {
return ImVec4(1.000, 0.467f, 0.000f, 1.000f);
}
return ImVec4(0.93f, 0.93f, 0.93f, 1.00f);

View File

@@ -10,12 +10,12 @@
class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
~ArchipelagoConsoleWindow() {};
~ArchipelagoConsoleWindow(){};
protected:
void InitElement() override {};
void InitElement() override{};
void DrawElement() override;
void UpdateElement() override {};
void UpdateElement() override{};
};
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage = false, ...);

View File

@@ -72,11 +72,11 @@ void ArchipelagoSettingsWindow::DrawElement() {
ArchipelagoClient::GetInstance().OnItemReceived(apItem);
}
ImGui::SameLine();
if (UIWidgets::Button("Send Game Won",
UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
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)))) {
if (UIWidgets::Button("Get Mido br chest",
UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
ArchipelagoClient::GetInstance().QueueExternalCheck(16711707);
}
}
@@ -96,7 +96,6 @@ void ArchipelagoSettingsWindow::DrawElement() {
void ArchipelagoSettingsWindow::InitElement() {
SaveManager::Instance->AddLoadFunction("archipelagoData", 1, LoadArchipelagoData);
SaveManager::Instance->AddSaveFunction("archipelagoData", 1, SaveArchipelagoData, true,
SECTION_PARENT_NONE);
SaveManager::Instance->AddSaveFunction("archipelagoData", 1, SaveArchipelagoData, true, SECTION_PARENT_NONE);
SaveManager::Instance->AddInitFunction(InitArchipelagoData);
}

View File

@@ -7,12 +7,12 @@
class ArchipelagoSettingsWindow final : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
~ArchipelagoSettingsWindow() {};
~ArchipelagoSettingsWindow(){};
protected:
void InitElement() override;
void DrawElement() override;
void UpdateElement() override {};
void UpdateElement() override{};
};
#endif // ARCHIPELAGO_SETTINGS_WINDOW_H

View File

@@ -201,7 +201,7 @@ void SetupGuiElements() {
"Archipelago Settings", ImVec2(600, 450));
gui->AddGuiWindow(mArchipelagoSettingsWindow);
mArchipelagoConsoleWindow = std::make_shared<ArchipelagoConsoleWindow>(CVAR_WINDOW("ArchipelagoConsoleWindow"),
"Archipelago Console", ImVec2(600, 550));
"Archipelago Console", ImVec2(600, 550));
gui->AddGuiWindow(mArchipelagoConsoleWindow);
mModalWindow = std::make_shared<SohModalWindow>(CVAR_WINDOW("ModalWindow"), "Modal Window");
gui->AddGuiWindow(mModalWindow);