diff --git a/Dependencies/GWCA/bin/gwca.dll b/Dependencies/GWCA/bin/gwca.dll index 30f187f70..906a69bda 100644 Binary files a/Dependencies/GWCA/bin/gwca.dll and b/Dependencies/GWCA/bin/gwca.dll differ diff --git a/Dependencies/GWCA/include/GWCA/GWCAVersion.h b/Dependencies/GWCA/include/GWCA/GWCAVersion.h index 7fbda792b..a5371e1f9 100644 --- a/Dependencies/GWCA/include/GWCA/GWCAVersion.h +++ b/Dependencies/GWCA/include/GWCA/GWCAVersion.h @@ -2,9 +2,9 @@ #define GWCA_VERSION_MAJOR 1 #define GWCA_VERSION_MINOR 0 -#define GWCA_VERSION_PATCH 3 +#define GWCA_VERSION_PATCH 4 #define GWCA_VERSION_BUILD 0 -#define GWCA_VERSION "1.0.3.0" +#define GWCA_VERSION "1.0.4.0" namespace GWCA { constexpr int VersionMajor = GWCA_VERSION_MAJOR; diff --git a/Dependencies/GWCA/include/GWCA/Managers/AgentMgr.h b/Dependencies/GWCA/include/GWCA/Managers/AgentMgr.h index 1ddc768e9..e50c43894 100644 --- a/Dependencies/GWCA/include/GWCA/Managers/AgentMgr.h +++ b/Dependencies/GWCA/include/GWCA/Managers/AgentMgr.h @@ -115,7 +115,5 @@ namespace GW { // Might be bugged, avoid to use. GWCA_API wchar_t* GetAgentEncName(const Agent* agent); GWCA_API wchar_t* GetAgentEncName(uint32_t agent_id); - - GWCA_API bool AsyncGetAgentName(const Agent *agent, std::wstring& name); }; } diff --git a/Dependencies/GWCA/include/GWCA/Managers/ItemMgr.h b/Dependencies/GWCA/include/GWCA/Managers/ItemMgr.h index b553b65cf..786e70b67 100644 --- a/Dependencies/GWCA/include/GWCA/Managers/ItemMgr.h +++ b/Dependencies/GWCA/include/GWCA/Managers/ItemMgr.h @@ -149,8 +149,6 @@ namespace GW { // Returns the slot of the materials in the storage page. (-1 if not found) GWCA_API Constants::MaterialSlot GetMaterialSlot(const Item *item); - GWCA_API void AsyncGetItemName(const Item *item, std::wstring& name); - GWCA_API EquipmentStatus GetEquipmentVisibility(EquipmentType type); GWCA_API bool SetEquipmentVisibility(EquipmentType type, EquipmentStatus state); diff --git a/Dependencies/GWCA/include/GWCA/Managers/UIMgr.h b/Dependencies/GWCA/include/GWCA/Managers/UIMgr.h index 6fdb4da59..15a5fd95d 100644 --- a/Dependencies/GWCA/include/GWCA/Managers/UIMgr.h +++ b/Dependencies/GWCA/include/GWCA/Managers/UIMgr.h @@ -1078,10 +1078,8 @@ namespace GW { GWCA_API bool GetIsShiftScreenShot(); GWCA_API bool GetIsWorldMapShowing(); - GWCA_API void AsyncDecodeStr(const wchar_t *enc_str, char *buffer, size_t size); GWCA_API void AsyncDecodeStr(const wchar_t *enc_str, wchar_t *buffer, size_t size); GWCA_API void AsyncDecodeStr(const wchar_t* enc_str, DecodeStr_Callback callback, void* callback_param = 0, GW::Constants::Language language_id = (GW::Constants::Language)0xff); - GWCA_API void AsyncDecodeStr(const wchar_t *enc_str, std::wstring *out, GW::Constants::Language language_id = (GW::Constants::Language)0xff); GWCA_API bool IsValidEncStr(const wchar_t* enc_str); diff --git a/Dependencies/GWCA/lib/gwca.lib b/Dependencies/GWCA/lib/gwca.lib index 23eb64b68..66f5f500b 100644 Binary files a/Dependencies/GWCA/lib/gwca.lib and b/Dependencies/GWCA/lib/gwca.lib differ diff --git a/GWToolboxdll/Modules/ObserverModule.cpp b/GWToolboxdll/Modules/ObserverModule.cpp index 337799d51..9918b6aeb 100644 --- a/GWToolboxdll/Modules/ObserverModule.cpp +++ b/GWToolboxdll/Modules/ObserverModule.cpp @@ -23,7 +23,7 @@ #include #include - +#include namespace { GW::HookEntry ChatCmd_HookEntry; @@ -2024,7 +2024,7 @@ ObserverModule::ObservableAgent::ObservableAgent(ObserverModule& parent, const G , is_npc(agent_living.IsNPC()) { // async initialise the agents name now because we probably want it later - GW::Agents::AsyncGetAgentName(&agent_living, _raw_name_w); + GW::UI::AsyncDecodeStr(GW::Agents::GetAgentEncName(&agent_living), &_raw_name_w); if (primary != GW::Constants::Profession::None) { std::string prof = GetProfessionAcronym(primary); diff --git a/GWToolboxdll/Utils/ToolboxUtils.cpp b/GWToolboxdll/Utils/ToolboxUtils.cpp index 5d7d7b0c3..d37a2cc44 100644 --- a/GWToolboxdll/Utils/ToolboxUtils.cpp +++ b/GWToolboxdll/Utils/ToolboxUtils.cpp @@ -175,6 +175,19 @@ namespace GW { return !out.empty(); } } + namespace UI { + void AsyncDecodeStr(const wchar_t* enc_str, std::wstring* out, GW::Constants::Language language_id) { + out->clear(); + AsyncDecodeStr(enc_str, [](void* param, const wchar_t* s) { + *(std::wstring*)param = s; + }, &out, language_id); + } + } + namespace Agents { + void AsyncGetAgentName(const Agent* agent, std::wstring& out) { + UI::AsyncDecodeStr(GetAgentEncName(agent), &out); + } + } } namespace ToolboxUtils { diff --git a/GWToolboxdll/Utils/ToolboxUtils.h b/GWToolboxdll/Utils/ToolboxUtils.h index 6521f9209..b4f2166fd 100644 --- a/GWToolboxdll/Utils/ToolboxUtils.h +++ b/GWToolboxdll/Utils/ToolboxUtils.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include class StoCCallback { GW::HookEntry* hook_entry = nullptr; @@ -125,6 +126,12 @@ namespace GW { namespace MemoryMgr { bool GetPersonalDir(std::wstring& out); } + namespace UI { + void AsyncDecodeStr(const wchar_t* enc_str, std::wstring* out, GW::Constants::Language language_id = (GW::Constants::Language)0xff); + } + namespace Agents { + void AsyncGetAgentName(const Agent* agent, std::wstring& out); + } } namespace ToolboxUtils { diff --git a/GWToolboxdll/Widgets/HealthWidget.cpp b/GWToolboxdll/Widgets/HealthWidget.cpp index c81fd1157..603ba6ed4 100644 --- a/GWToolboxdll/Widgets/HealthWidget.cpp +++ b/GWToolboxdll/Widgets/HealthWidget.cpp @@ -18,6 +18,7 @@ #include #include #include +#include constexpr auto HEALTH_THRESHOLD_INIFILENAME = L"HealthThreshold.ini"; diff --git a/GWToolboxdll/Widgets/Minimap/CustomRenderer.cpp b/GWToolboxdll/Widgets/Minimap/CustomRenderer.cpp index 31e4624ca..426f4be11 100644 --- a/GWToolboxdll/Widgets/Minimap/CustomRenderer.cpp +++ b/GWToolboxdll/Widgets/Minimap/CustomRenderer.cpp @@ -235,28 +235,7 @@ void CustomRenderer::Invalidate() void CustomRenderer::SetTooltipMapID(const GW::Constants::MapID& map_id) { - if (map_id_tooltip.map_id != map_id) { - map_id_tooltip.map_id = map_id; - if (map_id == GW::Constants::MapID::None) { - snprintf(map_id_tooltip.tooltip_str, sizeof(map_id_tooltip.tooltip_str), "Map ID (Any)"); - } - else { - snprintf(map_id_tooltip.tooltip_str, sizeof(map_id_tooltip.tooltip_str), "Map ID"); - const GW::AreaInfo* map_info = map_id < GW::Constants::MapID::Count ? GW::Map::GetMapInfo(map_id) : nullptr; - if (map_info && map_info->name_id) { - wchar_t map_id_buf[8]; - map_id_tooltip.map_name_ws.clear(); - if (GW::UI::UInt32ToEncStr(map_info->name_id, map_id_buf, 8)) { - GW::UI::AsyncDecodeStr(map_id_buf, &map_id_tooltip.map_name_ws); - } - } - } - } - if (!map_id_tooltip.map_name_ws.empty()) { - snprintf(map_id_tooltip.tooltip_str, sizeof(map_id_tooltip.tooltip_str), "Map ID (%s)", TextUtils::WStringToString(map_id_tooltip.map_name_ws).c_str()); - map_id_tooltip.map_name_ws.clear(); - } - ImGui::SetTooltip(map_id_tooltip.tooltip_str); + ImGui::SetTooltip(std::format("Map ID ({})",Resources::GetMapName(map_id)->string()).c_str()); } bool CustomRenderer::RemoveCustomLine(CustomLine* line) diff --git a/GWToolboxdll/Windows/ObjectiveTimerWindow.cpp b/GWToolboxdll/Windows/ObjectiveTimerWindow.cpp index 50bdcb322..b73328d18 100644 --- a/GWToolboxdll/Windows/ObjectiveTimerWindow.cpp +++ b/GWToolboxdll/Windows/ObjectiveTimerWindow.cpp @@ -151,17 +151,6 @@ namespace { } } - void AsyncGetMapName(char* buffer, const size_t n, const GW::Constants::MapID mapID = GW::Map::GetMapID()) - { - static wchar_t enc_str[16]; - const GW::AreaInfo* info = GW::Map::GetMapInfo(mapID); - if (!GW::UI::UInt32ToEncStr(info->name_id, enc_str, n)) { - buffer[0] = 0; - return; - } - GW::UI::AsyncDecodeStr(enc_str, buffer, n); - } - void ComputeNColumns() { n_columns = 0 + (show_start_column ? 1 : 0) + (show_end_column ? 1 : 0) + (show_time_column ? 1 : 0); @@ -552,7 +541,8 @@ void ObjectiveTimerWindow::AddObjectiveSet(ObjectiveSet* os) void ObjectiveTimerWindow::AddDungeonObjectiveSet(const std::vector& levels) { const auto os = new ObjectiveSet; - AsyncGetMapName(os->name, sizeof(os->name)); + ASSERT(!levels.empty()); + os->name = Resources::GetMapName(levels[0])->string(); for (size_t i = 0; i < levels.size(); i++) { char name[256]; snprintf(name, sizeof(name), "Level %d", i); @@ -592,7 +582,8 @@ void ObjectiveTimerWindow::AddDoAObjectiveSet(const GW::Vec2f spawn) } const auto os = new ObjectiveSet; - AsyncGetMapName(os->name, sizeof(os->name)); + + os->name = Resources::GetMapName(GW::Constants::MapID::Domain_of_Anguish)->string(); const std::vector> add_doa_obj = { [&] { @@ -713,7 +704,7 @@ void ObjectiveTimerWindow::AddUrgozObjectiveSet() // Objective for Urgoz = 357 const auto os = new ObjectiveSet; - AsyncGetMapName(os->name, sizeof(os->name)); + os->name = Resources::GetMapName(GW::Constants::MapID::Urgozs_Warren)->string(); os->AddObjective(new Objective("Zone 1 | Weakness"))->SetStarted(); os->AddObjectiveAfterAll(new Objective("Zone 2 | Life Drain"))->AddStartEvent(EventType::DoorOpen, 45420); os->AddObjectiveAfterAll(new Objective("Zone 3 | Levers"))->AddStartEvent(EventType::DoorOpen, 11692); @@ -737,7 +728,7 @@ void ObjectiveTimerWindow::AddUrgozObjectiveSet() void ObjectiveTimerWindow::AddDeepObjectiveSet() { const auto os = new ObjectiveSet; - AsyncGetMapName(os->name, sizeof(os->name)); + os->name = Resources::GetMapName(GW::Constants::MapID::The_Deep)->string(); os->AddObjective(new Objective("Room 1 | Soothing")) ->SetStarted() ->AddEndEvent(EventType::DoorOpen, Deep_room_1_first) @@ -789,7 +780,7 @@ void ObjectiveTimerWindow::AddDeepObjectiveSet() void ObjectiveTimerWindow::AddFoWObjectiveSet() { const auto os = new ObjectiveSet; - AsyncGetMapName(os->name, sizeof(os->name)); + os->name = Resources::GetMapName(GW::Constants::MapID::The_Fissure_of_Woe)->string(); os->AddQuestObjective("ToC", 309); os->AddQuestObjective("Wailing Lord", 310); @@ -808,7 +799,7 @@ void ObjectiveTimerWindow::AddFoWObjectiveSet() void ObjectiveTimerWindow::AddUWObjectiveSet() { const auto os = new ObjectiveSet; - AsyncGetMapName(os->name, sizeof(os->name)); + os->name = Resources::GetMapName(GW::Constants::MapID::The_Underworld)->string(); os->AddQuestObjective("Chamber", 146); os->AddQuestObjective("Restore", 147); os->AddQuestObjective("Escort", 148); @@ -828,23 +819,21 @@ void ObjectiveTimerWindow::AddUWObjectiveSet() void ObjectiveTimerWindow::AddToPKObjectiveSet() { const auto os = new ObjectiveSet; - - // we could read out the name of the maps... - os->AddObjective(new Objective("The Underworld")) + os->name = Resources::GetMapName(GW::Constants::MapID::Tomb_of_the_Primeval_Kings)->string(); + os->AddObjective(new Objective(Resources::GetMapName(GW::Constants::MapID::The_Underworld_PvP)->string().c_str())) ->SetStarted() ->AddStartEvent(EventType::InstanceLoadInfo, std::to_underlying(GW::Constants::MapID::The_Underworld_PvP)) ->AddEndEvent(EventType::CountdownStart, std::to_underlying(GW::Constants::MapID::The_Underworld_PvP)); - os->AddObjective(new Objective("Scarred Earth")) + os->AddObjective(new Objective(Resources::GetMapName(GW::Constants::MapID::Scarred_Earth)->string().c_str())) ->AddStartEvent(EventType::InstanceLoadInfo, std::to_underlying(GW::Constants::MapID::Scarred_Earth)) ->AddEndEvent(EventType::CountdownStart, std::to_underlying(GW::Constants::MapID::Scarred_Earth)); - os->AddObjective(new Objective("The Courtyard")) + os->AddObjective(new Objective(Resources::GetMapName(GW::Constants::MapID::The_Courtyard)->string().c_str())) ->AddStartEvent(EventType::InstanceLoadInfo, std::to_underlying(GW::Constants::MapID::The_Courtyard)) ->AddEndEvent(EventType::CountdownStart, std::to_underlying(GW::Constants::MapID::The_Courtyard)); - os->AddObjective(new Objective("The Hall of Heroes")) + os->AddObjective(new Objective(Resources::GetMapName(GW::Constants::MapID::The_Hall_of_Heroes)->string().c_str())) ->AddStartEvent(EventType::InstanceLoadInfo, std::to_underlying(GW::Constants::MapID::The_Hall_of_Heroes)) ->AddEndEvent(EventType::CountdownStart, std::to_underlying(GW::Constants::MapID::The_Hall_of_Heroes)); - AsyncGetMapName(os->name, sizeof(os->name), GW::Constants::MapID::Tomb_of_the_Primeval_Kings); AddObjectiveSet(os); } @@ -893,7 +882,7 @@ void ObjectiveTimerWindow::Draw(IDirect3DDevice9*) ImGui::SetNextWindowCenter(ImGuiCond_FirstUseEver); ImGui::SetNextWindowSize(ImVec2(300, 0), ImGuiCond_FirstUseEver); char buf[256]; - sprintf(buf, "%s - %s###ObjectiveTimerCurrentRun", current_objective_set->name, current_objective_set->GetDurationStr()); + sprintf(buf, "%s - %s###ObjectiveTimerCurrentRun", current_objective_set->name.c_str(), current_objective_set->GetDurationStr()); if (ImGui::Begin(buf, &show_current_run_window, GetWinFlags())) { ImGui::PushID(static_cast(current_objective_set->ui_id)); @@ -1461,8 +1450,7 @@ ObjectiveTimerWindow::ObjectiveSet* ObjectiveTimerWindow::ObjectiveSet::FromJson const auto os = new ObjectiveSet; os->active = false; os->system_time = json.at("utc_start").get(); - const auto name = json.at("name").get(); - snprintf(os->name, sizeof(os->name), "%s", name.c_str()); + os->name = json.at("name").get(); os->run_start_time_point = json.at("instance_start").get(); if (json.contains("duration")) { os->duration = json.at("duration").get(); @@ -1575,10 +1563,10 @@ bool ObjectiveTimerWindow::ObjectiveSet::Draw() } } if (show_start_date_time) { - sprintf(buf, "%s - %s - %s%s###header%u", GetStartTimeStr(), name, GetDurationStr(), failed ? " [Failed]" : "", ui_id); + sprintf(buf, "%s - %s - %s%s###header%u", GetStartTimeStr(), name.c_str(), GetDurationStr(), failed ? " [Failed]" : "", ui_id); } else { - sprintf(buf, "%s - %s%s###header%u", name, GetDurationStr(), failed ? " [Failed]" : "", ui_id); + sprintf(buf, "%s - %s%s###header%u", name.c_str(), GetDurationStr(), failed ? " [Failed]" : "", ui_id); } bool is_open = true; diff --git a/GWToolboxdll/Windows/ObjectiveTimerWindow.h b/GWToolboxdll/Windows/ObjectiveTimerWindow.h index 6a4580c46..d719b27f5 100644 --- a/GWToolboxdll/Windows/ObjectiveTimerWindow.h +++ b/GWToolboxdll/Windows/ObjectiveTimerWindow.h @@ -163,7 +163,7 @@ class ObjectiveTimerWindow : public ToolboxWindow { bool failed = false; bool from_disk = false; bool need_to_collapse = false; - char name[256] = {0}; + std::string name; std::vector objectives{}; diff --git a/GWToolboxdll/Windows/PacketLoggerWindow.cpp b/GWToolboxdll/Windows/PacketLoggerWindow.cpp index 709521303..1e6ccd933 100644 --- a/GWToolboxdll/Windows/PacketLoggerWindow.cpp +++ b/GWToolboxdll/Windows/PacketLoggerWindow.cpp @@ -23,7 +23,7 @@ #include #include - +#include namespace { wchar_t* GetMessageCore() { diff --git a/GWToolboxdll/Windows/StringDecoderWindow.cpp b/GWToolboxdll/Windows/StringDecoderWindow.cpp index e51dd3b9c..d506a08c9 100644 --- a/GWToolboxdll/Windows/StringDecoderWindow.cpp +++ b/GWToolboxdll/Windows/StringDecoderWindow.cpp @@ -11,7 +11,7 @@ #include #include - +#include namespace { void printchar(const wchar_t c) {