diff --git a/src/client/attachableobject.cpp b/src/client/attachableobject.cpp index a1034d0f80..8d796f87cf 100644 --- a/src/client/attachableobject.cpp +++ b/src/client/attachableobject.cpp @@ -118,7 +118,7 @@ void AttachableObject::clearTemporaryAttachedEffects() { if (!hasAttachedEffects()) return; m_data->attachedEffects.erase(std::remove_if(m_data->attachedEffects.begin(), m_data->attachedEffects.end(), - [&](const AttachedEffectPtr& obj) { + [this](const AttachedEffectPtr& obj) { if (!obj->isPermanent()) { onDetachEffect(obj); return true; @@ -131,7 +131,7 @@ void AttachableObject::clearPermanentAttachedEffects() { if (!hasAttachedEffects()) return; m_data->attachedEffects.erase(std::remove_if(m_data->attachedEffects.begin(), m_data->attachedEffects.end(), - [&](const AttachedEffectPtr& obj) { + [this](const AttachedEffectPtr& obj) { if (obj->isPermanent()) { onDetachEffect(obj); return true; diff --git a/src/client/game.cpp b/src/client/game.cpp index 924d18e42a..877112439e 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1748,4 +1748,4 @@ void Game::openContainerQuickLoot(uint8_t action, uint8_t category, const Positi m_denyBotCall = false; m_protocolGame->openContainerQuickLoot(action, category, pos, itemId, stackpos, useMainAsFallback); m_denyBotCall = true; -} +} \ No newline at end of file diff --git a/src/client/map.cpp b/src/client/map.cpp index 3572c5ca6c..50d9c1c972 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -47,7 +47,7 @@ Map g_map; void Map::init() { - g_window.addKeyListener([&](const InputEvent& inputEvent) { + g_window.addKeyListener([this](const InputEvent& inputEvent) { notificateKeyRelease(inputEvent); }); diff --git a/src/framework/core/graphicalapplication.cpp b/src/framework/core/graphicalapplication.cpp index 9683ea4ba3..ddad41577e 100644 --- a/src/framework/core/graphicalapplication.cpp +++ b/src/framework/core/graphicalapplication.cpp @@ -67,7 +67,7 @@ void GraphicalApplication::init(std::vector& args, ApplicationConte else g_dispatcher.addEvent([&, PH1]() { inputEvent(PH1); }); }); - g_window.setOnClose([this] { g_dispatcher.addEvent([&]() { close(); }); }); + g_window.setOnClose([this] { g_dispatcher.addEvent([this]() { close(); }); }); g_mouse.init(); @@ -139,16 +139,18 @@ void GraphicalApplication::run() g_lua.callGlobalField("g_app", "onRun"); - const auto& FPS = [&] { + const auto& FPS = [this] { m_mapProcessFrameCounter.setTargetFps(g_window.vsyncEnabled() || getMaxFps() || getTargetFps() ? 500u : 0u); return m_graphicFrameCounter.getFps(); }; // THREAD - POOL & MAP - const auto& mapThread = g_asyncDispatcher.submit_task([&] { + const auto& mapThread = g_asyncDispatcher.submit_task([this] { const auto uiPool = g_drawPool.get(DrawPoolType::FOREGROUND); const auto fgMapPool = g_drawPool.get(DrawPoolType::FOREGROUND_MAP); + BS::multi_future tasks; + g_eventThreadId = EventDispatcher::getThreadId(); while (!m_stopping) { poll(); @@ -167,23 +169,22 @@ void GraphicalApplication::run() m_drawEvents->preLoad(); - BS::multi_future threads; - threads.reserve(3); + tasks.clear(); if (m_drawEvents->canDraw(DrawPoolType::LIGHT)) { - threads.emplace_back(g_asyncDispatcher.submit_task([&] { + tasks.emplace_back(g_asyncDispatcher.submit_task([this] { m_drawEvents->draw(DrawPoolType::LIGHT); })); } if (uiPool->canRepaint()) { - threads.emplace_back(g_asyncDispatcher.submit_task([&] { + tasks.emplace_back(g_asyncDispatcher.submit_task([this] { g_ui.render(DrawPoolType::FOREGROUND); })); } if (fgMapPool->canRepaint()) { - threads.emplace_back(g_asyncDispatcher.submit_task([&] { + tasks.emplace_back(g_asyncDispatcher.submit_task([this] { m_drawEvents->draw(DrawPoolType::CREATURE_INFORMATION); m_drawEvents->draw(DrawPoolType::FOREGROUND_MAP); })); @@ -191,7 +192,7 @@ void GraphicalApplication::run() m_drawEvents->draw(DrawPoolType::MAP); - threads.wait(); + tasks.wait(); m_mapProcessFrameCounter.update(); } diff --git a/src/framework/graphics/animatedtexture.cpp b/src/framework/graphics/animatedtexture.cpp index 49ec83b012..3b763b21e9 100644 --- a/src/framework/graphics/animatedtexture.cpp +++ b/src/framework/graphics/animatedtexture.cpp @@ -49,7 +49,7 @@ void AnimatedTexture::buildHardwareMipmaps() if (getProp(Prop::hasMipMaps)) return; setProp(Prop::hasMipMaps, true); - g_mainDispatcher.addEvent([&] { + g_mainDispatcher.addEvent([this] { for (const auto& frame : m_frames) frame->buildHardwareMipmaps(); }); @@ -58,7 +58,7 @@ void AnimatedTexture::buildHardwareMipmaps() void AnimatedTexture::setSmooth(bool smooth) { setProp(Prop::smooth, smooth); - g_mainDispatcher.addEvent([&] { + g_mainDispatcher.addEvent([this, smooth] { for (const auto& frame : m_frames) frame->setSmooth(smooth); }); @@ -67,7 +67,7 @@ void AnimatedTexture::setSmooth(bool smooth) void AnimatedTexture::setRepeat(bool repeat) { setProp(Prop::repeat, repeat); - g_mainDispatcher.addEvent([&] { + g_mainDispatcher.addEvent([this, repeat] { for (const auto& frame : m_frames) frame->setRepeat(repeat); }); diff --git a/src/framework/net/httplogin.cpp b/src/framework/net/httplogin.cpp index 9efa5df090..148484af97 100644 --- a/src/framework/net/httplogin.cpp +++ b/src/framework/net/httplogin.cpp @@ -68,7 +68,7 @@ void LoginHttp::startHttpLogin(const std::string& host, const std::string& path, httplib::SSLClient cli(host, port); cli.set_logger( - [&](const auto& req, const auto& res) { LoginHttp::Logger(req, res); }); + [this](const auto& req, const auto& res) { LoginHttp::Logger(req, res); }); json body = json{ {"email", email}, {"password", password}, {"stayloggedin", true}, {"type", "login"} }; httplib::Headers headers = { {"User-Agent", "Mozilla/5.0"} }; @@ -137,7 +137,7 @@ httplib::Result LoginHttp::loginHttpsJson(const std::string& host, httplib::SSLClient client(host, port); client.set_logger( - [&](const auto& req, const auto& res) { LoginHttp::Logger(req, res); }); + [this](const auto& req, const auto& res) { LoginHttp::Logger(req, res); }); json body = { {"email", email}, {"password", password}, {"stayloggedin", true}, {"type", "login"} }; httplib::Headers headers = { {"User-Agent", "Mozilla/5.0"} }; @@ -169,7 +169,7 @@ httplib::Result LoginHttp::loginHttpJson(const std::string& host, const std::string& password) { httplib::Client client(host, port); client.set_logger( - [&](const auto& req, const auto& res) { LoginHttp::Logger(req, res); }); + [this](const auto& req, const auto& res) { LoginHttp::Logger(req, res); }); httplib::Headers headers = { {"User-Agent", "Mozilla/5.0"} }; json body = { {"email", email}, {"password", password}, {"stayloggedin", true}, {"type", "login"} }; diff --git a/src/framework/net/protocolhttp.cpp b/src/framework/net/protocolhttp.cpp index 94dabedd54..f028cfe330 100644 --- a/src/framework/net/protocolhttp.cpp +++ b/src/framework/net/protocolhttp.cpp @@ -67,7 +67,7 @@ int Http::get(const std::string& url, int timeout) result->operationId = operationId; m_operations[operationId] = result; const auto& session = std::make_shared(m_ios, url, m_userAgent, m_enable_time_out_on_read_write, m_custom_header, timeout, - false, true, result, [&](HttpResult_ptr result) { + false, true, result, [this, operationId](HttpResult_ptr result) { bool finished = result->finished; g_dispatcher.addEvent([result, finished] { if (!finished) { @@ -104,7 +104,7 @@ int Http::post(const std::string& url, const std::string& data, int timeout, boo result->postData = data; m_operations[operationId] = result; const auto& session = std::make_shared(m_ios, url, m_userAgent, m_enable_time_out_on_read_write, m_custom_header, timeout, - isJson, checkContentLength, result, [&](HttpResult_ptr result) { + isJson, checkContentLength, result, [this, operationId](HttpResult_ptr result) { bool finished = result->finished; g_dispatcher.addEvent([result, finished] { if (!finished) { @@ -437,7 +437,7 @@ void HttpSession::on_request_sent(const std::error_code& ec, size_t /*bytes_tran void HttpSession::on_read(const std::error_code& ec, size_t bytes_transferred) { - auto on_done_read = [&]() { + auto on_done_read = [this]() { m_timer.cancel(); const auto& data = m_response.data(); m_result->response.append(asio::buffers_begin(data), asio::buffers_end(data)); @@ -559,19 +559,6 @@ void WebsocketSession::start() }); } - - - - - - - - - - - - - void WebsocketSession::on_resolve(const std::error_code& ec, asio::ip::tcp::resolver::iterator iterator) { if (ec) { @@ -989,4 +976,4 @@ void WebsocketSession::close() } } } -} +} \ No newline at end of file diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index e111e01489..7f006cd379 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -474,7 +474,7 @@ void WIN32Window::resize(const Size& size) void WIN32Window::show() { - g_mainDispatcher.addEvent([&] { + g_mainDispatcher.addEvent([this] { m_hidden = false; if (m_maximized) ShowWindow(m_window, SW_MAXIMIZE);