Skip to content

Commit

Permalink
remove superfluous () from lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
DubbleClick committed May 9, 2024
1 parent 6a41fff commit 952cf9a
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 28 deletions.
3 changes: 1 addition & 2 deletions Dependencies/easywsclient/easywsclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ easywsclient::WebSocket::pointer from_url(const std::string& url, bool useMask,
}

if (is_ssl) {
int res = 0;
auto err_out = [res,ptConnCtx]() {
auto err_out = [ptConnCtx] {
ERR_print_errors_cb(print_error_callback, 0);
char err_str[255];
wolfSSL_ERR_error_string(SSL_get_error(ptConnCtx->sslHandle, 0),err_str);
Expand Down
17 changes: 8 additions & 9 deletions GWToolboxdll/Modules/SalvageInfoModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ namespace {
// Detected weapon type page. We need to go to the weapon with same name page and fetch materials from there
const auto expected_token = std::format("{} (weapon)", info->en_name.string());
std::unordered_set<std::string> sub_urls;
std::string::const_iterator sub_search_start(response.cbegin());
auto sub_search_start(response.cbegin());
while (std::regex_search(sub_search_start, response.cend(), m, sub_links_regex)) {
const auto entry = m[1].str();
// Search for entries that match [WeaponName] (weapon) token
Expand All @@ -252,7 +252,7 @@ namespace {
}

// Iterate over all skills in this list.
const auto infobox_row_regex = std::regex(
static const std::regex infobox_row_regex(
"(?:<tr>|<tr[^>]+>)[\\s\\S]*?(?:<th>|<th[^>]+>)([\\s\\S]*?)</th>[\\s\\S]*?(?:<td>|<td[^>]+>)([\\s\\S]*?)</td>[\\s\\S]*?</tr>"
);
auto words_begin = std::sregex_iterator(infobox_content.begin(), infobox_content.end(), infobox_row_regex);
Expand All @@ -272,13 +272,12 @@ namespace {
}
info->loading = false;
// Now we've got the wiki info parsed, trigger an item update ui message; this will refresh the item tooltip
GW::GameThread::Enqueue([info]() {
GW::GameThread::Enqueue([info] {
const auto item = GW::Items::GetHoveredItem();
if (item && wcscmp(item->name_enc, info->en_name.encoded().c_str()) == 0) {
GW::UI::SendUIMessage(GW::UI::UIMessage::kItemUpdated, item);
}
});
(response);
});
}

// Run on worker thread, so we can Sleep!
Expand All @@ -288,7 +287,7 @@ namespace {
// @Cleanup: this should never hang, but should we handle it?
Sleep(16);
}
const auto url = GuiUtils::WikiUrl(info->en_name.string().c_str());
const auto url = GuiUtils::WikiUrl(info->en_name.string());
Resources::Download(url, OnWikiContentDownloaded, info, std::chrono::days(30));
}

Expand All @@ -300,15 +299,15 @@ namespace {
if (found == salvage_info_by_single_item_name.end() ||
found->second->failed) {
if (found != salvage_info_by_single_item_name.end()) {
delete (found->second);
delete found->second;
}
// Need to fetch info for this item.
auto salvage_info = new SalvageInfo();
salvage_info->en_name.language(GW::Constants::Language::English);
salvage_info->en_name.reset(single_item_name);
salvage_info_by_single_item_name[single_item_name] = salvage_info;
salvage_info->loading = true;
Resources::EnqueueWorkerTask([salvage_info]() {
Resources::EnqueueWorkerTask([salvage_info] {
FetchSalvageInfoFromGuildWarsWiki(salvage_info);
});

Expand Down Expand Up @@ -389,7 +388,7 @@ void SalvageInfoModule::Initialize()
ASSERT(GW::HookBase::CreateHook((void**)&GetItemDescription_Func, OnGetItemDescription, (void**)&GetItemDescription_Ret) == 0);
GW::HookBase::EnableHooks(GetItemDescription_Func);
}
GW::GameThread::Enqueue([]() {
GW::GameThread::Enqueue([] {
materials = {
new CraftingMaterial(GW::Constants::ItemID::Bone, GW::EncStrings::Bone),
new CraftingMaterial(GW::Constants::ItemID::IronIngot, GW::EncStrings::IronIngot),
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Utils/GuiUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ namespace GuiUtils {
{
if (!decoded && !decoding && !encoded_ws.empty()) {
decoding = true;
GW::GameThread::Enqueue([&]() {
GW::GameThread::Enqueue([&] {
GW::UI::AsyncDecodeStr(encoded_ws.c_str(), OnStringDecoded, this, language_id);
});

Expand Down
6 changes: 3 additions & 3 deletions GWToolboxdll/Widgets/BondsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace {
}

// capture by value!
GW::GameThread::Enqueue([slot, targetId]() -> void {
GW::GameThread::Enqueue([slot, targetId] {
GW::SkillbarMgr::UseSkill(slot, targetId);
});
}
Expand Down Expand Up @@ -235,7 +235,7 @@ bool BondsWidget::UseBuff(GW::AgentID targetId, GW::Constants::SkillID skill_id)
}

// capture by value!
GW::GameThread::Enqueue([slot, targetId]() -> void {
GW::GameThread::Enqueue([slot, targetId] {
GW::SkillbarMgr::UseSkill(slot, targetId);
});
return true;
Expand All @@ -251,7 +251,7 @@ bool BondsWidget::DropBuffs(GW::AgentID targetId, GW::Constants::SkillID skill_i
if (!(targetId == (GW::AgentID)0 || buff.target_agent_id == targetId))
continue;
const auto buff_id = buff.buff_id;
GW::GameThread::Enqueue([buff_id]() -> void {
GW::GameThread::Enqueue([buff_id] {
GW::Effects::DropBuff(buff_id);
});
}
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Widgets/SkillMonitorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void SkillMonitorWidget::Draw(IDirect3DDevice9*)
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImColor(background).Value);

const float uiscale_multiply = GuiUtils::GetGWScaleMultiplier();
const auto calculate_window_position = [uiscale_multiply]() -> auto {
const auto calculate_window_position = [uiscale_multiply] {
// NB: Use case to define GW::Vec4f ?
GW::Vec2f x = party_window_position->xAxis();
GW::Vec2f y = party_window_position->yAxis();
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Windows/Hotkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ void HotkeyDropUseBuff::Execute()
if (islot >= 0) {
uint32_t slot = static_cast<uint32_t>(islot);
if (GW::SkillbarMgr::GetPlayerSkillbar()->skills[slot].recharge == 0) {
GW::GameThread::Enqueue([slot]() -> void {
GW::GameThread::Enqueue([slot] {
GW::SkillbarMgr::UseSkill(slot);
});
}
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Windows/ObjectiveTimerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ void ObjectiveTimerWindow::AddDoAObjectiveSet(const GW::Vec2f spawn)
{
constexpr int n_areas = 4;

const auto starting_area = [&]() -> int {
const auto starting_area = [&] {
constexpr GW::Vec2f mallyx_spawn(-3931, -6214);
constexpr GW::Vec2f area_spawns[] = {
{-10514, 15231}, // foundry
Expand Down
4 changes: 2 additions & 2 deletions GWToolboxdll/Windows/ObserverExportWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ nlohmann::json ObserverExportWindow::ToJSON_V_0_1()
json["parties"].push_back(nlohmann::json::value_t::null);
continue;
}
json["parties"].push_back([&]() -> nlohmann::json {
json["parties"].push_back([&] {
// parties -> party
nlohmann::json json_party;
json_party["party_id"] = party->party_id;
Expand All @@ -58,7 +58,7 @@ nlohmann::json ObserverExportWindow::ToJSON_V_0_1()
json_party["members"].push_back(nlohmann::json::value_t::null);
continue;
}
json_party["members"].push_back([&]() -> nlohmann::json {
json_party["members"].push_back([&] {
// parties -> party -> agents -> agent
nlohmann::json json_agent;
json_agent["display_name"] = agent->DisplayName();
Expand Down
2 changes: 1 addition & 1 deletion GWToolboxdll/Windows/PacketLoggerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ void PacketLoggerWindow::Draw(IDirect3DDevice9*)
void PacketLoggerWindow::Initialize()
{
ToolboxWindow::Initialize();
GW::GameThread::Enqueue([]() {
GW::GameThread::Enqueue([] {
InitStoC();
});
if (logger_enabled) {
Expand Down
6 changes: 3 additions & 3 deletions GWToolboxdll/Windows/PathfindingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace {
return;
delete astar;
astar = nullptr;
Resources::EnqueueWorkerTask([from_cpy = from, to_cpy = to ]() {
Resources::EnqueueWorkerTask([from_cpy = from, to_cpy = to] {
auto tmpAstar = new Pathing::AStar(GetMilepathForCurrentMap());
const auto res = tmpAstar->search(from_cpy, to_cpy);
if (res != Pathing::Error::OK) {
Expand Down Expand Up @@ -254,7 +254,7 @@ bool PathfindingWindow::CalculatePath(const GW::GamePos& from, const GW::GamePos

pending_worker_task = true;

Resources::EnqueueWorkerTask([from_cpy, to_cpy, callback, args ]() {
Resources::EnqueueWorkerTask([from_cpy, to_cpy, callback, args ] {
Pathing::MilePath* milepath = nullptr;
Pathing::AStar* tmpAstar = nullptr;
Pathing::Error res = Pathing::Error::OK;
Expand Down Expand Up @@ -285,7 +285,7 @@ bool PathfindingWindow::CalculatePath(const GW::GamePos& from, const GW::GamePos
delete tmpAstar;
delete from_cpy;
delete to_cpy;
Resources::EnqueueMainTask([waypoints, callback, args]() {
Resources::EnqueueMainTask([waypoints, callback, args] {
callback(*waypoints,args);
delete waypoints;

Expand Down
8 changes: 4 additions & 4 deletions GWToolboxdll/Windows/Pathing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace {
std::mutex mutex;
auto res_pt = &res;
// Enqueue
GW::GameThread::Enqueue([&block_pt, res_pt, &mutex]() {
const std::lock_guard<std::mutex> lock(mutex);
GW::GameThread::Enqueue([&block_pt, res_pt, &mutex] {
const std::lock_guard lock(mutex);
GW::MapContext* mapContext = GW::GetMapContext();
if (!mapContext) {
*res_pt = Pathing::Error::InvalidMapContext;
Expand All @@ -37,7 +37,7 @@ namespace {
});
// Wait
do {
const std::lock_guard<std::mutex> lock(mutex);
const std::lock_guard lock(mutex);
if (res != Pathing::Error::Unknown)
break;
} while (true);
Expand Down Expand Up @@ -214,7 +214,7 @@ namespace Pathing {
LoadMapSpecificData();
GenerateAABBs();
GenerateAABBGraph(); //not threaded because it relies on gw client Query altitude.
worker_thread = new std::thread([&]() {
worker_thread = new std::thread([&] {
GeneratePoints();
GenerateVisibilityGraph();
GenerateTeleportGraph();
Expand Down

0 comments on commit 952cf9a

Please sign in to comment.