Skip to content

Commit

Permalink
Fixed bug preventing district travel, see comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon committed Aug 21, 2024
1 parent 7d400f3 commit 7f94114
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion GuildWarsPartySearch.Bot/Dependencies/Headquarter
29 changes: 24 additions & 5 deletions GuildWarsPartySearch.Bot/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,21 +624,23 @@ static uint32_t get_original_map_id(uint32_t map_id) {
static bool in_correct_outpost() {
if (!GetIsIngame())
return false;
if (!map_id)
return false;

uint32_t check_map_id = get_original_map_id(map_id);
uint32_t check_map_id = get_original_map_id(GetMapId());

return ((!wanted_map_id || check_map_id == wanted_map_id) &&
(wanted_district == District::DISTRICT_CURRENT || district == wanted_district) &&
(!bot_configuration.district_number || district_number == bot_configuration.district_number));
(wanted_district == District::DISTRICT_CURRENT || GetDistrict() == wanted_district) &&
(!bot_configuration.district_number || GetDistrictNumber() == bot_configuration.district_number));
}

static void ensure_correct_outpost() {
if (!wanted_map_id)
exit_with_status("No wanted_map_id in ensure_correct_outpost", 1);
if (in_correct_outpost())
return;
if (!IsMapUnlocked(wanted_map_id)) {
LogError("map %d not unlocked", wanted_map_id);
exit_with_status("Map not unlocked",1);
}
LogInfo("Zoning into outpost");
int res = 0;
size_t retries = 4;
Expand Down Expand Up @@ -812,6 +814,23 @@ static int main_bot(void* param)

msec_t last_calculated_map_check = 0;

// Theres a HQ bug where it knows our map, but not district until you travel.
// Fix this by deliberately travelling somewhere else.
uint32_t tmp_map_id = 0;
uint32_t current_map_id = GetMapId();
for (size_t i = 0; i < 877; i++) {
if (current_map_id == i)
continue;
if (!is_valid_outpost(i))
continue;
if (!IsMapUnlocked(i))
continue;
tmp_map_id = i;
break;
}
assert(tmp_map_id);
assert(travel_wait(tmp_map_id, District::DISTRICT_CURRENT, 0) == 0);

while (running) {
wait_until_ingame();
if (!*account_uuid)
Expand Down

0 comments on commit 7f94114

Please sign in to comment.