Skip to content

Commit

Permalink
Fixed issues with minimap focussing on the wrong agent when observing
Browse files Browse the repository at this point in the history
  • Loading branch information
3vcloud committed Jun 20, 2024
1 parent e76ac13 commit 8847192
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Dependencies/GWCA
1 change: 1 addition & 0 deletions GWToolboxdll/Modules/ChatCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ namespace {
void CHAT_CMD_FUNC(CmdPlayEffect)
{
const auto player = GW::Agents::GetPlayer();
if (!player) return;
auto packet = new GW::Packet::StoC::PlayEffect();
memset(packet, 0, sizeof(*packet));
packet->header = GW::Packet::StoC::PlayEffect::STATIC_HEADER;
Expand Down
17 changes: 2 additions & 15 deletions GWToolboxdll/Modules/ItemFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,11 @@ namespace {
return;
}

const auto* player = GW::Agents::GetCharacter();
if (player == nullptr) {
return;
}

if (player->max_energy == 0 || player->login_number == 0) {
// we're spectating, not sure what our own player is
if (WantToHide(*item, false) && WantToHide(*item, true)) {
// only block items that we want to block for player and party
status->blocked = true;
suppressed_packets.push_back(*packet);
}
return;
}
const auto my_agent_id = GW::Agents::GetPlayerId();

const auto owner_id = GetItemOwner(item->item_id);
const auto can_pick_up = owner_id == 0 // not reserved
|| owner_id == player->agent_id; // reserved for user
|| owner_id == my_agent_id; // reserved for user

if (WantToHide(*item, can_pick_up)) {
status->blocked = true;
Expand Down
130 changes: 64 additions & 66 deletions GWToolboxdll/Modules/ToolboxSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,74 +381,72 @@ void ToolboxSettings::Draw(IDirect3DDevice9*)

void ToolboxSettings::Update(float)
{
// save location data
if (save_location_data && TIMER_DIFF(location_timer) > 1000) {
location_timer = TIMER_INIT();
if (GW::Map::GetInstanceType() == GW::Constants::InstanceType::Explorable
&& GW::Agents::GetPlayer() != nullptr) {
GW::Constants::MapID current = GW::Map::GetMapID();
if (location_current_map != current) {
location_current_map = current;

std::wstring map_string;
switch (current) {
case GW::Constants::MapID::Domain_of_Anguish:
map_string = L"DoA";
break;
case GW::Constants::MapID::Urgozs_Warren:
map_string = L"Urgoz";
break;
case GW::Constants::MapID::The_Deep:
map_string = L"Deep";
break;
case GW::Constants::MapID::The_Underworld:
map_string = L"UW";
break;
case GW::Constants::MapID::The_Fissure_of_Woe:
map_string = L"FoW";
break;
default:
map_string = std::wstring(L"Map-") + std::to_wstring(static_cast<long>(current));
}

std::wstring prof_string;
if (const auto me = GW::Agents::GetCharacter()) {
prof_string += L" - ";
prof_string += GetWProfessionAcronym(
static_cast<GW::Constants::Profession>(me->primary));
prof_string += L"-";
prof_string += GetWProfessionAcronym(
static_cast<GW::Constants::Profession>(me->secondary));
}

SYSTEMTIME localtime;
GetLocalTime(&localtime);
const std::wstring filename = std::to_wstring(localtime.wYear)
+ L"-" + std::to_wstring(localtime.wMonth)
+ L"-" + std::to_wstring(localtime.wDay)
+ L" - " + std::to_wstring(localtime.wHour)
+ L"-" + std::to_wstring(localtime.wMinute)
+ L"-" + std::to_wstring(localtime.wSecond)
+ L" - " + map_string + prof_string + L".log";

if (location_file && location_file.is_open()) {
location_file.close();
}
const std::wstring path = Resources::GetPath(L"location logs", filename);
location_file.open(path);
}

const GW::Agent* me = GW::Agents::GetCharacter();
if (location_file.is_open() && me != nullptr) {
location_file << "Time=" << GW::Map::GetInstanceTime();
location_file << " X=" << me->pos.x;
location_file << " Y=" << me->pos.y;
location_file << "\n";
}
if (!(save_location_data && TIMER_DIFF(location_timer) > 1000))
return;
location_timer = TIMER_INIT();
if (GW::Map::GetInstanceType() != GW::Constants::InstanceType::Explorable) {
location_current_map = GW::Constants::MapID::None;
location_file.close();
return;
}
GW::Constants::MapID current = GW::Map::GetMapID();
const auto me = GW::Agents::GetCharacter();
if (location_current_map != current) {
location_current_map = current;

std::wstring map_string;
switch (current) {
case GW::Constants::MapID::Domain_of_Anguish:
map_string = L"DoA";
break;
case GW::Constants::MapID::Urgozs_Warren:
map_string = L"Urgoz";
break;
case GW::Constants::MapID::The_Deep:
map_string = L"Deep";
break;
case GW::Constants::MapID::The_Underworld:
map_string = L"UW";
break;
case GW::Constants::MapID::The_Fissure_of_Woe:
map_string = L"FoW";
break;
default:
map_string = std::wstring(L"Map-") + std::to_wstring(static_cast<long>(current));
}

std::wstring prof_string;
if (me) {
prof_string += L" - ";
prof_string += GetWProfessionAcronym(
static_cast<GW::Constants::Profession>(me->primary));
prof_string += L"-";
prof_string += GetWProfessionAcronym(
static_cast<GW::Constants::Profession>(me->secondary));
}
else {
location_current_map = GW::Constants::MapID::None;

SYSTEMTIME localtime;
GetLocalTime(&localtime);
const std::wstring filename = std::to_wstring(localtime.wYear)
+ L"-" + std::to_wstring(localtime.wMonth)
+ L"-" + std::to_wstring(localtime.wDay)
+ L" - " + std::to_wstring(localtime.wHour)
+ L"-" + std::to_wstring(localtime.wMinute)
+ L"-" + std::to_wstring(localtime.wSecond)
+ L" - " + map_string + prof_string + L".log";

if (location_file && location_file.is_open()) {
location_file.close();
}
const std::wstring path = Resources::GetPath(L"location logs", filename);
location_file.open(path);
}


if (location_file.is_open() && me != nullptr) {
location_file << "Time=" << GW::Map::GetInstanceTime();
location_file << " X=" << me->pos.x;
location_file << " Y=" << me->pos.y;
location_file << "\n";
}
}
2 changes: 1 addition & 1 deletion GWToolboxdll/Widgets/Minimap/Minimap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ bool Minimap::IsActive() const
&& GW::Map::GetIsMapLoaded()
&& !GW::UI::GetIsWorldMapShowing()
&& GW::Map::GetInstanceType() != GW::Constants::InstanceType::Loading
&& (GW::Agents::GetPlayerId() != 0 || GW::Agents::GetObservingId() != 0);
&& GW::Agents::GetObservingId() != 0;
}

void Minimap::RenderSetupProjection(IDirect3DDevice9* device)
Expand Down

0 comments on commit 8847192

Please sign in to comment.