Skip to content

Commit

Permalink
Removed other std::wstring passing to gwca
Browse files Browse the repository at this point in the history
  • Loading branch information
3vcloud committed Jan 6, 2025
1 parent 28ad5d8 commit 2e080a5
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 64 deletions.
Binary file modified Dependencies/GWCA/bin/gwca.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Dependencies/GWCA/include/GWCA/GWCAVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions Dependencies/GWCA/include/GWCA/Managers/AgentMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
2 changes: 0 additions & 2 deletions Dependencies/GWCA/include/GWCA/Managers/ItemMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions Dependencies/GWCA/include/GWCA/Managers/UIMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Binary file modified Dependencies/GWCA/lib/gwca.lib
Binary file not shown.
4 changes: 2 additions & 2 deletions GWToolboxdll/Modules/ObserverModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <Logger.h>
#include <Utils/TextUtils.h>

#include <Utils/ToolboxUtils.h>
namespace {

GW::HookEntry ChatCmd_HookEntry;
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions GWToolboxdll/Utils/ToolboxUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions GWToolboxdll/Utils/ToolboxUtils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <GWCA/Managers/UIMgr.h>
#include <GWCA/Managers/StoCMgr.h>
#include <GWCA/Managers/AgentMgr.h>

class StoCCallback {
GW::HookEntry* hook_entry = nullptr;
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions GWToolboxdll/Widgets/HealthWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <Widgets/HealthWidget.h>
#include <Utils/FontLoader.h>
#include <Utils/TextUtils.h>
#include <Utils/ToolboxUtils.h>

constexpr auto HEALTH_THRESHOLD_INIFILENAME = L"HealthThreshold.ini";

Expand Down
23 changes: 1 addition & 22 deletions GWToolboxdll/Widgets/Minimap/CustomRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
46 changes: 17 additions & 29 deletions GWToolboxdll/Windows/ObjectiveTimerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -552,7 +541,8 @@ void ObjectiveTimerWindow::AddObjectiveSet(ObjectiveSet* os)
void ObjectiveTimerWindow::AddDungeonObjectiveSet(const std::vector<GW::Constants::MapID>& 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);
Expand Down Expand Up @@ -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<std::function<void()>> add_doa_obj = {
[&] {
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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<int>(current_objective_set->ui_id));
Expand Down Expand Up @@ -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<DWORD>();
const auto name = json.at("name").get<std::string>();
snprintf(os->name, sizeof(os->name), "%s", name.c_str());
os->name = json.at("name").get<std::string>();
os->run_start_time_point = json.at("instance_start").get<DWORD>();
if (json.contains("duration")) {
os->duration = json.at("duration").get<DWORD>();
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Windows/ObjectiveTimerWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Objective*> objectives{};

Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Windows/PacketLoggerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <GWToolbox.h>
#include <Utils/TextUtils.h>

#include <Utils/ToolboxUtils.h>
namespace {
wchar_t* GetMessageCore()
{
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Windows/StringDecoderWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <Windows/StringDecoderWindow.h>
#include <Utils/TextUtils.h>

#include <Utils/ToolboxUtils.h>
namespace {
void printchar(const wchar_t c)
{
Expand Down

0 comments on commit 2e080a5

Please sign in to comment.