Function renames
This commit is contained in:
@@ -783,7 +783,7 @@ void RegisterBossDefeatTimestamps() {
|
|||||||
case ACTOR_BOSS_GANON2:
|
case ACTOR_BOSS_GANON2:
|
||||||
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_DEFEAT_GANON] = GAMEPLAYSTAT_TOTAL_TIME;
|
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_DEFEAT_GANON] = GAMEPLAYSTAT_TOTAL_TIME;
|
||||||
gSaveContext.ship.stats.gameComplete = true;
|
gSaveContext.ship.stats.gameComplete = true;
|
||||||
ArchipelagoClient::getInstance().send_game_won();
|
ArchipelagoClient::GetInstance().SendGameWon();
|
||||||
break;
|
break;
|
||||||
case ACTOR_BOSS_GANONDROF:
|
case ACTOR_BOSS_GANONDROF:
|
||||||
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_DEFEAT_PHANTOM_GANON] = GAMEPLAYSTAT_TOTAL_TIME;
|
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_DEFEAT_PHANTOM_GANON] = GAMEPLAYSTAT_TOTAL_TIME;
|
||||||
|
|||||||
@@ -441,9 +441,9 @@ void Context::ParseArchipelago() {
|
|||||||
mSeedGenerated = false;
|
mSeedGenerated = false;
|
||||||
mSpoilerLoaded = false;
|
mSpoilerLoaded = false;
|
||||||
|
|
||||||
ArchipelagoClient& ap_client = ArchipelagoClient::getInstance();
|
ArchipelagoClient& ap_client = ArchipelagoClient::GetInstance();
|
||||||
Rando::Settings::GetInstance()->ParseArchipelago(ap_client.get_slot_data());
|
Rando::Settings::GetInstance()->ParseArchipelago(ap_client.GetSlotData());
|
||||||
ParseArchipelagoItemsLocations(ap_client.get_scouted_items());
|
ParseArchipelagoItemsLocations(ap_client.GetScoutedItems());
|
||||||
|
|
||||||
// lets see if counting AP_loaded as spoiler loaded does the trick
|
// lets see if counting AP_loaded as spoiler loaded does the trick
|
||||||
mSpoilerLoaded = true;
|
mSpoilerLoaded = true;
|
||||||
@@ -484,7 +484,7 @@ void Context::ParseItemLocationsJson(nlohmann::json spoilerFileJson) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Context::ParseArchipelagoItemsLocations(const std::vector<ArchipelagoClient::ApItem>& scouted_items) {
|
void Context::ParseArchipelagoItemsLocations(const std::vector<ArchipelagoClient::ApItem>& scouted_items) {
|
||||||
const std::string SlotName = ArchipelagoClient::getInstance().get_slot_name();
|
const std::string SlotName = ArchipelagoClient::GetInstance().GetSlotName();
|
||||||
|
|
||||||
// init the item table with regular items first
|
// init the item table with regular items first
|
||||||
for(int rc = 1; rc <= RC_MAX; rc++) {
|
for(int rc = 1; rc <= RC_MAX; rc++) {
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) {
|
|||||||
// todo maybe move to seperate function
|
// todo maybe move to seperate function
|
||||||
// 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.check_location(randomizerQueuedCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2445,7 +2445,7 @@ void RandomizerRegisterHooks() {
|
|||||||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
|
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
|
||||||
shuffleFreestandingOnVanillaBehaviorHook);
|
shuffleFreestandingOnVanillaBehaviorHook);
|
||||||
|
|
||||||
ArchipelagoClient::getInstance().removeItemRecievedCallback(ArchipelagoOnRecieveItem);
|
ArchipelagoClient::GetInstance().RemoveItemRecievedCallback(ArchipelagoOnRecieveItem);
|
||||||
|
|
||||||
onFlagSetHook = 0;
|
onFlagSetHook = 0;
|
||||||
onSceneFlagSetHook = 0;
|
onSceneFlagSetHook = 0;
|
||||||
@@ -2562,6 +2562,6 @@ void RandomizerRegisterHooks() {
|
|||||||
ShuffleFairies_RegisterHooks();
|
ShuffleFairies_RegisterHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoClient::getInstance().addItemRecievedCallback(ArchipelagoOnRecieveItem);
|
ArchipelagoClient::GetInstance().AddItemRecievedCallback(ArchipelagoOnRecieveItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5885,7 +5885,7 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
|
|||||||
(OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) + 1)) {
|
(OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) + 1)) {
|
||||||
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED] = GAMEPLAYSTAT_TOTAL_TIME;
|
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED] = GAMEPLAYSTAT_TOTAL_TIME;
|
||||||
gSaveContext.ship.stats.gameComplete = 1;
|
gSaveContext.ship.stats.gameComplete = 1;
|
||||||
ArchipelagoClient::getInstance().send_game_won();
|
ArchipelagoClient::GetInstance().SendGameWon();
|
||||||
Flags_SetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY);
|
Flags_SetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY);
|
||||||
Play_PerformSave(play);
|
Play_PerformSave(play);
|
||||||
Notification::Emit({
|
Notification::Emit({
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ void HandleDragAndDrop(std::vector<SplitObject>& objectList, int targetIndex, co
|
|||||||
void TimeSplitCompleteSplits() {
|
void TimeSplitCompleteSplits() {
|
||||||
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_DEFEAT_GANON] = GAMEPLAYSTAT_TOTAL_TIME;
|
gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_DEFEAT_GANON] = GAMEPLAYSTAT_TOTAL_TIME;
|
||||||
gSaveContext.ship.stats.gameComplete = true;
|
gSaveContext.ship.stats.gameComplete = true;
|
||||||
ArchipelagoClient::getInstance().send_game_won();
|
ArchipelagoClient::GetInstance().SendGameWon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeSplitsSkipSplit(uint32_t index) {
|
void TimeSplitsSkipSplit(uint32_t index) {
|
||||||
|
|||||||
@@ -19,50 +19,50 @@ ArchipelagoClient::ArchipelagoClient() {
|
|||||||
game_won = false;
|
game_won = false;
|
||||||
|
|
||||||
namespace apc = AP_Client_consts;
|
namespace apc = AP_Client_consts;
|
||||||
CVarSetInteger("archipelago_connected", 0);
|
CVarSetInteger("ArchipelagoConnected", 0);
|
||||||
strncpy(server_address, CVarGetString(apc::SETTING_ADDRESS, apc::DEFAULT_SERVER_NAME), apc::MAX_ADDRESS_LENGTH);
|
strncpy(serverAddress, CVarGetString(apc::SETTING_ADDRESS, apc::DEFAULT_SERVER_NAME), apc::MAX_ADDRESS_LENGTH);
|
||||||
strncpy(slot_name, CVarGetString(apc::SETTING_NAME, ""), apc::MAX_PLAYER_NAME_LENGHT);
|
strncpy(slotName, CVarGetString(apc::SETTING_NAME, ""), apc::MAX_PLAYER_NAME_LENGHT);
|
||||||
|
|
||||||
// call poll every frame
|
// call poll every frame
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([](){ArchipelagoClient::getInstance().poll();});
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([](){ArchipelagoClient::GetInstance().Poll();});
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoClient& ArchipelagoClient::getInstance() {
|
ArchipelagoClient& ArchipelagoClient::GetInstance() {
|
||||||
static ArchipelagoClient Client;
|
static ArchipelagoClient Client;
|
||||||
return Client;
|
return Client;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArchipelagoClient::start_client() {
|
bool ArchipelagoClient::StartClient() {
|
||||||
if(apclient != NULL) {
|
if(apClient != NULL) {
|
||||||
apclient.reset();
|
apClient.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
apclient = std::unique_ptr<APClient>(new APClient(uuid, AP_Client_consts::AP_GAME_NAME, server_address));
|
apClient = std::unique_ptr<APClient>(new APClient(uuid, AP_Client_consts::AP_GAME_NAME, serverAddress));
|
||||||
|
|
||||||
apclient->set_room_info_handler([&]() {
|
apClient->set_room_info_handler([&]() {
|
||||||
std::list<std::string> tags;
|
std::list<std::string> tags;
|
||||||
// tags.push_back("DeathLink"); // todo, implement deathlink
|
// tags.push_back("DeathLink"); // todo, implement deathlink
|
||||||
apclient->ConnectSlot(slot_name, password, 0b001, tags);
|
apClient->ConnectSlot(slotName, password, 0b001, tags);
|
||||||
});
|
});
|
||||||
|
|
||||||
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) {
|
||||||
on_item_recieved(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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
apclient->set_location_info_handler([&](const std::list<APClient::NetworkItem>& items) {
|
apClient->set_location_info_handler([&](const std::list<APClient::NetworkItem>& items) {
|
||||||
scouted_items.clear();
|
scoutedItems.clear();
|
||||||
|
|
||||||
for(const APClient::NetworkItem& item: items) {
|
for(const APClient::NetworkItem& item: items) {
|
||||||
ApItem apItem;
|
ApItem apItem;
|
||||||
const std::string game = apclient->get_player_game(item.player);
|
const std::string game = apClient->get_player_game(item.player);
|
||||||
apItem.itemName = apclient->get_item_name(item.item, game);
|
apItem.itemName = apClient->get_item_name(item.item, game);
|
||||||
apItem.locationName = apclient->get_location_name(item.location, game);
|
apItem.locationName = apClient->get_location_name(item.location, game);
|
||||||
apItem.playerName = apclient->get_player_alias(item.player);
|
apItem.playerName = apClient->get_player_alias(item.player);
|
||||||
apItem.flags = item.flags;
|
apItem.flags = item.flags;
|
||||||
apItem.index = item.index;
|
apItem.index = item.index;
|
||||||
scouted_items.push_back(apItem);
|
scoutedItems.push_back(apItem);
|
||||||
|
|
||||||
const std::string itemName = apItem.itemName;
|
const std::string itemName = apItem.itemName;
|
||||||
const std::string playerName = apItem.playerName;
|
const std::string playerName = apItem.playerName;
|
||||||
@@ -72,17 +72,17 @@ bool ArchipelagoClient::start_client() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}); // 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
|
||||||
});
|
});
|
||||||
|
|
||||||
save_data();
|
SaveData();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::start_location_scouts() {
|
void ArchipelagoClient::StartLocationScouts() {
|
||||||
std::set<int64_t> missing_loc_set = apclient->get_missing_locations();
|
std::set<int64_t> missing_loc_set = apClient->get_missing_locations();
|
||||||
std::set<int64_t> found_loc_set = apclient->get_checked_locations();
|
std::set<int64_t> found_loc_set = apClient->get_checked_locations();
|
||||||
std::list<int64_t> location_list;
|
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);
|
location_list.emplace_back(loc_id);
|
||||||
@@ -90,16 +90,16 @@ void ArchipelagoClient::start_location_scouts() {
|
|||||||
for(const int64_t loc_id : found_loc_set) {
|
for(const int64_t loc_id : found_loc_set) {
|
||||||
location_list.emplace_back(loc_id);
|
location_list.emplace_back(loc_id);
|
||||||
}
|
}
|
||||||
apclient->LocationScouts(location_list);
|
apClient->LocationScouts(location_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::save_data() {
|
void ArchipelagoClient::SaveData() {
|
||||||
CVarSetString(AP_Client_consts::SETTING_ADDRESS, server_address);
|
CVarSetString(AP_Client_consts::SETTING_ADDRESS, serverAddress);
|
||||||
CVarSetString(AP_Client_consts::SETTING_NAME, slot_name);
|
CVarSetString(AP_Client_consts::SETTING_NAME, slotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArchipelagoClient::isConnected() {
|
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::check_location(RandomizerCheck SoH_check_id) {
|
||||||
@@ -108,26 +108,26 @@ void ArchipelagoClient::check_location(RandomizerCheck SoH_check_id) {
|
|||||||
if(ap_name.empty()) {
|
if(ap_name.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int64_t ap_item_id = apclient->get_location_id(std::string(ap_name));
|
int64_t ap_item_id = apClient->get_location_id(std::string(ap_name));
|
||||||
std::string logMessage = "[LOG] Checked: " + ap_name + "(" + std::to_string(ap_item_id) + "), sending to AP server";
|
std::string logMessage = "[LOG] Checked: " + ap_name + "(" + std::to_string(ap_item_id) + "), sending to AP server";
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
|
|
||||||
// currently not sending, because i only get so many real chances
|
// currently not sending, because i only get so many real chances
|
||||||
if(!isConnected()) {
|
if(!IsConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
apclient->LocationChecks({ap_item_id});
|
apClient->LocationChecks({ap_item_id});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::addItemRecievedCallback(std::function<void(const std::string&)> callback) {
|
void ArchipelagoClient::AddItemRecievedCallback(std::function<void(const std::string&)> callback) {
|
||||||
ItemRecievedCallback = callback;
|
ItemRecievedCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::removeItemRecievedCallback(std::function<void(const std::string&)> old_callback) {
|
void ArchipelagoClient::RemoveItemRecievedCallback(std::function<void(const std::string&)> old_callback) {
|
||||||
ItemRecievedCallback = nullptr;
|
ItemRecievedCallback = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::on_connected() {
|
void ArchipelagoClient::OnConnected() {
|
||||||
// todo implement me
|
// todo implement me
|
||||||
ArchipelagoConsole_SendMessage("[LOG] AP Connected!");
|
ArchipelagoConsole_SendMessage("[LOG] AP Connected!");
|
||||||
}
|
}
|
||||||
@@ -135,10 +135,10 @@ void ArchipelagoClient::on_connected() {
|
|||||||
// // todo implement me
|
// // todo implement me
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void ArchipelagoClient::on_item_recieved(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);
|
||||||
ArchipelagoClient& ap_client = ArchipelagoClient::getInstance();
|
ArchipelagoClient& ap_client = ArchipelagoClient::GetInstance();
|
||||||
if(ap_client.ItemRecievedCallback) {
|
if(ap_client.ItemRecievedCallback) {
|
||||||
std::string logMessage = "[LOG] Item recieved: " + item_name + ". Notify: " + std::to_string(notify_player);
|
std::string logMessage = "[LOG] Item recieved: " + item_name + ". Notify: " + std::to_string(notify_player);
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
@@ -146,53 +146,53 @@ void ArchipelagoClient::on_item_recieved(int64_t recieved_item_id, bool notify_p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::send_game_won() {
|
void ArchipelagoClient::SendGameWon() {
|
||||||
if(!game_won) {
|
if(!game_won) {
|
||||||
apclient->StatusUpdate(APClient::ClientStatus::GOAL);
|
apClient->StatusUpdate(APClient::ClientStatus::GOAL);
|
||||||
game_won = true;
|
game_won = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoClient::poll() {
|
void ArchipelagoClient::Poll() {
|
||||||
if(apclient == nullptr) {
|
if(apClient == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
apclient->poll();
|
apClient->poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& ArchipelagoClient::get_slot_name() const {
|
const std::string& ArchipelagoClient::GetSlotName() const {
|
||||||
if(apclient == NULL) {
|
if(apClient == NULL) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return apclient->get_slot();
|
return apClient->get_slot();
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ArchipelagoClient::get_server_address_buff() {
|
char* ArchipelagoClient::GetServerAddressBuffer() {
|
||||||
return server_address;
|
return serverAddress;
|
||||||
}
|
}
|
||||||
char* ArchipelagoClient::get_slot_name_buff() {
|
char* ArchipelagoClient::GetSlotNameBuffer() {
|
||||||
return slot_name;
|
return slotName;
|
||||||
}
|
}
|
||||||
char* ArchipelagoClient::get_password_buff() {
|
char* ArchipelagoClient::GetPasswordBuffer() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, int>& ArchipelagoClient::get_slot_data() {
|
const std::map<std::string, int>& ArchipelagoClient::GetSlotData() {
|
||||||
return slot_data;
|
return slotData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ArchipelagoClient::ApItem>& ArchipelagoClient::get_scouted_items() {
|
const std::vector<ArchipelagoClient::ApItem>& ArchipelagoClient::GetScoutedItems() {
|
||||||
return scouted_items;
|
return scoutedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ArchipelagoClient::get_connection_status() {
|
const char* ArchipelagoClient::GetConnectionStatus() {
|
||||||
if (!apclient) {
|
if (!apClient) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
APClient::State clientStatus = apclient->get_state();
|
APClient::State clientStatus = apClient->get_state();
|
||||||
|
|
||||||
switch (clientStatus) {
|
switch (clientStatus) {
|
||||||
case APClient::State::DISCONNECTED: {
|
case APClient::State::DISCONNECTED: {
|
||||||
|
|||||||
@@ -28,39 +28,38 @@ class ArchipelagoClient{
|
|||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ArchipelagoClient& getInstance();
|
static ArchipelagoClient& GetInstance();
|
||||||
|
|
||||||
bool start_client();
|
bool StartClient();
|
||||||
bool stop_client();
|
bool StopClient();
|
||||||
|
|
||||||
void start_location_scouts();
|
void StartLocationScouts();
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
const std::string& get_slot_name() const;
|
const std::string& GetSlotName() const;
|
||||||
|
|
||||||
char* get_server_address_buff();
|
char* GetServerAddressBuffer();
|
||||||
char* get_slot_name_buff();
|
char* GetSlotNameBuffer();
|
||||||
char* get_password_buff();
|
char* GetPasswordBuffer();
|
||||||
const char* get_connection_status();
|
const char* GetConnectionStatus();
|
||||||
const std::map<std::string, int>& get_slot_data();
|
const std::map<std::string, int>& GetSlotData();
|
||||||
const std::vector<ApItem>& get_scouted_items();
|
const std::vector<ApItem>& GetScoutedItems();
|
||||||
|
|
||||||
bool isConnected();
|
bool IsConnected();
|
||||||
void check_location(RandomizerCheck SoH_check_id);
|
void check_location(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);
|
||||||
void removeItemRecievedCallback(std::function<void(const std::string&)> old_callback);
|
void RemoveItemRecievedCallback(std::function<void(const std::string&)> old_callback);
|
||||||
|
|
||||||
|
|
||||||
// todo move me back down when done testing
|
// todo move me back down when done testing
|
||||||
void on_item_recieved(int64_t recieved_item_id, bool notify_player);
|
void OnItemReceived(int64_t recieved_item_id, bool notify_player);
|
||||||
|
|
||||||
void send_game_won();
|
void SendGameWon();
|
||||||
|
|
||||||
void poll();
|
void Poll();
|
||||||
|
|
||||||
std::unique_ptr<APClient> apclient;
|
std::unique_ptr<APClient> apClient;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ArchipelagoClient();
|
ArchipelagoClient();
|
||||||
@@ -73,23 +72,23 @@ 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;
|
||||||
|
|
||||||
char server_address[AP_Client_consts::MAX_ADDRESS_LENGTH];
|
char serverAddress[AP_Client_consts::MAX_ADDRESS_LENGTH];
|
||||||
char slot_name[AP_Client_consts::MAX_PLAYER_NAME_LENGHT];
|
char slotName[AP_Client_consts::MAX_PLAYER_NAME_LENGHT];
|
||||||
char password[AP_Client_consts::MAX_PLAYER_NAME_LENGHT];
|
char password[AP_Client_consts::MAX_PLAYER_NAME_LENGHT];
|
||||||
|
|
||||||
bool game_won;
|
bool game_won;
|
||||||
|
|
||||||
std::map<std::string, int> slot_data;
|
std::map<std::string, int> slotData;
|
||||||
std::set<int64_t> locations;
|
std::set<int64_t> locations;
|
||||||
std::vector<ApItem> scouted_items;
|
std::vector<ApItem> scoutedItems;
|
||||||
|
|
||||||
void save_data();
|
void SaveData();
|
||||||
|
|
||||||
// callback functions
|
// callback functions
|
||||||
void on_connected();
|
void OnConnected();
|
||||||
|
|
||||||
void on_location_checked(int64_t location_id);
|
void OnLocationChecked(int64_t location_id);
|
||||||
void on_deathlink_recieved() { }; // TODO: implement me
|
void OnDeathLinkReceived() { }; // TODO: implement me
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
std::function<void(const std::string&)> ItemRecievedCallback;
|
std::function<void(const std::string&)> ItemRecievedCallback;
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ void ArchipelagoConsole_SendMessage(const char* fmt, ...) IM_FMTARGS(2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ArchipelagoConsoleWindow::DrawElement() {
|
void ArchipelagoConsoleWindow::DrawElement() {
|
||||||
// Reserve enough left-over height for 1 separator + 1 input text
|
|
||||||
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
|
||||||
|
|
||||||
if (ImGui::Button("Add line to log")) {
|
if (ImGui::Button("Add line to log")) {
|
||||||
|
ArchipelagoConsole_SendMessage("[LOG] Hello World");
|
||||||
|
ArchipelagoConsole_SendMessage("[ERROR] Hello World");
|
||||||
ArchipelagoConsole_SendMessage("Hello World");
|
ArchipelagoConsole_SendMessage("Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,18 +35,21 @@ void ArchipelagoConsoleWindow::DrawElement() {
|
|||||||
// Normally you would store more information in your item than just a string.
|
// Normally you would store more information in your item than just a string.
|
||||||
// (e.g. make Items[] an array of structure, store color/type etc.)
|
// (e.g. make Items[] an array of structure, store color/type etc.)
|
||||||
ImVec4 color;
|
ImVec4 color;
|
||||||
bool has_color = false;
|
bool hasColor = false;
|
||||||
if (strstr(item, "[error]")) {
|
if (strstr(item, "[ERROR]")) {
|
||||||
color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
|
color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
|
||||||
has_color = true;
|
hasColor = true;
|
||||||
|
} else if (strstr(item, "[LOG]")) {
|
||||||
|
color = ImVec4(0.7f, 0.7f, 1.0f, 1.0f);
|
||||||
|
hasColor = true;
|
||||||
} else if (strncmp(item, "# ", 2) == 0) {
|
} else if (strncmp(item, "# ", 2) == 0) {
|
||||||
color = ImVec4(1.0f, 0.8f, 0.6f, 1.0f);
|
color = ImVec4(1.0f, 0.8f, 0.6f, 1.0f);
|
||||||
has_color = true;
|
hasColor = true;
|
||||||
}
|
}
|
||||||
if (has_color)
|
if (hasColor)
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, color);
|
ImGui::PushStyleColor(ImGuiCol_Text, color);
|
||||||
ImGui::TextUnformatted(item);
|
ImGui::TextUnformatted(item);
|
||||||
if (has_color)
|
if (hasColor)
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,32 +6,32 @@
|
|||||||
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
|
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
|
||||||
|
|
||||||
void ArchipelagoSettingsWindow::DrawElement() {
|
void ArchipelagoSettingsWindow::DrawElement() {
|
||||||
ArchipelagoClient& AP_client = ArchipelagoClient::getInstance();
|
ArchipelagoClient& AP_client = ArchipelagoClient::GetInstance();
|
||||||
ImGui::SeparatorText("Connection info");
|
ImGui::SeparatorText("Connection info");
|
||||||
ImGui::InputText("Server Address", AP_client.get_server_address_buff(), AP_Client_consts::MAX_ADDRESS_LENGTH);
|
ImGui::InputText("Server Address", AP_client.GetServerAddressBuffer(), AP_Client_consts::MAX_ADDRESS_LENGTH);
|
||||||
ImGui::InputText("Slot Name", AP_client.get_slot_name_buff(), AP_Client_consts::MAX_PLAYER_NAME_LENGHT);
|
ImGui::InputText("Slot Name", AP_client.GetSlotNameBuffer(), AP_Client_consts::MAX_PLAYER_NAME_LENGHT);
|
||||||
ImGui::InputText("Password (leave blank for no password)", AP_client.get_password_buff(),
|
ImGui::InputText("Password (leave blank for no password)", AP_client.GetPasswordBuffer(),
|
||||||
AP_Client_consts::MAX_PASSWORD_LENGTH, ImGuiInputTextFlags_Password);
|
AP_Client_consts::MAX_PASSWORD_LENGTH, ImGuiInputTextFlags_Password);
|
||||||
|
|
||||||
if (ImGui::Button("Connect")) {
|
if (ImGui::Button("Connect")) {
|
||||||
bool success = AP_client.start_client();
|
bool success = AP_client.StartClient();
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...");
|
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text(ArchipelagoClient::getInstance().get_connection_status());
|
ImGui::Text(ArchipelagoClient::GetInstance().GetConnectionStatus());
|
||||||
|
|
||||||
if (ImGui::Button("scout")) {
|
if (ImGui::Button("Scout")) {
|
||||||
AP_client.start_location_scouts();
|
AP_client.StartLocationScouts();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("link up")) {
|
if (ImGui::Button("Link up")) {
|
||||||
CVarSetInteger("archipelago_connected", 1);
|
CVarSetInteger("ArchipelagoConnected", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
UIWidgets::PaddedSeparator();
|
UIWidgets::PaddedSeparator();
|
||||||
|
|
||||||
if(ImGui::Button("give blue ruppie")) {
|
if(ImGui::Button("Give Blue Rupee")) {
|
||||||
ArchipelagoClient::getInstance().on_item_recieved(66077, true);
|
ArchipelagoClient::GetInstance().OnItemReceived(66077, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2594,7 +2594,7 @@ void SoH_ProcessDroppedFiles(std::string filePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void parse_archipelago() {
|
extern "C" void ParseArchipelago() {
|
||||||
OTRGlobals::Instance->gRandoContext->ParseArchipelago();
|
OTRGlobals::Instance->gRandoContext->ParseArchipelago();
|
||||||
}
|
}
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ void CheckTracker_OnMessageClose();
|
|||||||
|
|
||||||
GetItemID RetrieveGetItemIDFromItemID(ItemID itemID);
|
GetItemID RetrieveGetItemIDFromItemID(ItemID itemID);
|
||||||
RandomizerGet RetrieveRandomizerGetFromItemID(ItemID itemID);
|
RandomizerGet RetrieveRandomizerGetFromItemID(ItemID itemID);
|
||||||
void parse_archipelago();
|
void ParseArchipelago();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1030,7 +1030,7 @@ void DrawSeedHashSprites(FileChooseContext* this) {
|
|||||||
u8 generating;
|
u8 generating;
|
||||||
int retries = 0;
|
int retries = 0;
|
||||||
bool fileSelectSpoilerFileLoaded = false;
|
bool fileSelectSpoilerFileLoaded = false;
|
||||||
bool fileSelectarchipelagoloaded = false;
|
bool fileSelectArchipelagoLoaded = false;
|
||||||
|
|
||||||
void FileChoose_UpdateRandomizer() {
|
void FileChoose_UpdateRandomizer() {
|
||||||
if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) != 0 && generating == 0) {
|
if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) != 0 && generating == 0) {
|
||||||
@@ -1075,10 +1075,9 @@ void FileChoose_UpdateRandomizer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CVarGetInteger("archipelago_connected", 0) != 0
|
if (CVarGetInteger("ArchipelagoConnected", 0) && !fileSelectArchipelagoLoaded) {
|
||||||
&& !fileSelectarchipelagoloaded) {
|
ParseArchipelago();
|
||||||
parse_archipelago();
|
fileSelectArchipelagoLoaded = true;
|
||||||
fileSelectarchipelagoloaded = true;
|
|
||||||
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3939,7 +3938,7 @@ void FileChoose_Init(GameState* thisx) {
|
|||||||
this->questType[1] = MIN_QUEST;
|
this->questType[1] = MIN_QUEST;
|
||||||
this->questType[2] = MIN_QUEST;
|
this->questType[2] = MIN_QUEST;
|
||||||
fileSelectSpoilerFileLoaded = false;
|
fileSelectSpoilerFileLoaded = false;
|
||||||
fileSelectarchipelagoloaded = false;
|
fileSelectArchipelagoLoaded = false;
|
||||||
CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0);
|
CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0);
|
||||||
|
|
||||||
SREG(30) = 1;
|
SREG(30) = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user