diff --git a/core/2d/CCGrid.cpp b/core/2d/CCGrid.cpp index 66ba4365ea..9603f3f9a8 100644 --- a/core/2d/CCGrid.cpp +++ b/core/2d/CCGrid.cpp @@ -208,7 +208,7 @@ void GridBase::beforeDraw() renderer->addCommand(groupCommand); renderer->pushGroup(groupCommand->getRenderQueueID()); - auto beforeDrawCommandFunc = [=, this]() -> void { + auto beforeDrawCommandFunc = [director, renderer, this]() -> void { _directorProjection = director->getProjection(); set2DProjection(); Vec2 size = director->getWinSizeInPixels(); @@ -238,7 +238,7 @@ void GridBase::afterDraw(ax::Node* /*target*/) // renderer->setViewPort(vp.x, vp.y, vp.w, vp.h); // renderer->setRenderTarget(_oldRenderTarget); //}; - renderer->addCallbackCommand([=, this]() -> void { + renderer->addCallbackCommand([director, renderer, this]() -> void { director->setProjection(_directorProjection); const auto& vp = Camera::getDefaultViewport(); renderer->setViewPort(vp.x, vp.y, vp.w, vp.h); @@ -263,12 +263,12 @@ void GridBase::afterDraw(ax::Node* /*target*/) // TODO: Director::getInstance()->setProjection(Director::getInstance()->getProjection()); // TODO: Director::getInstance()->applyOrientation(); //_beforeBlitCommand.func = [=]() -> void { beforeBlit(); }; - renderer->addCallbackCommand([=, this]() -> void { beforeBlit(); }); + renderer->addCallbackCommand([this]() -> void { beforeBlit(); }); blit(); //_afterBlitCommand.func = [=]() -> void { afterBlit(); }; - renderer->addCallbackCommand([=, this]() -> void { afterBlit(); }); + renderer->addCallbackCommand([this]() -> void { afterBlit(); }); } // implementation of Grid3D diff --git a/core/2d/CCRenderTexture.cpp b/core/2d/CCRenderTexture.cpp index 8f62f960b2..0f0a957e8f 100644 --- a/core/2d/CCRenderTexture.cpp +++ b/core/2d/CCRenderTexture.cpp @@ -654,7 +654,7 @@ void RenderTexture::clearColorAttachment() auto renderer = _director->getRenderer(); auto beforeClearAttachmentCommand = renderer->nextCallbackCommand(); beforeClearAttachmentCommand->init(0); - beforeClearAttachmentCommand->func = [=, this]() -> void { + beforeClearAttachmentCommand->func = [this, renderer]() -> void { _oldRenderTarget = renderer->getRenderTarget(); renderer->setRenderTarget(_renderTarget); }; @@ -666,7 +666,7 @@ void RenderTexture::clearColorAttachment() // auto renderer = _director->getRenderer(); auto afterClearAttachmentCommand = renderer->nextCallbackCommand(); afterClearAttachmentCommand->init(0); - afterClearAttachmentCommand->func = [=, this]() -> void { renderer->setRenderTarget(_oldRenderTarget); }; + afterClearAttachmentCommand->func = [this, renderer]() -> void { renderer->setRenderTarget(_oldRenderTarget); }; renderer->addCommand(afterClearAttachmentCommand); } diff --git a/core/3d/CCObjLoader.cpp b/core/3d/CCObjLoader.cpp index 833ec446c5..d0b4ea4337 100644 --- a/core/3d/CCObjLoader.cpp +++ b/core/3d/CCObjLoader.cpp @@ -859,7 +859,7 @@ std::string LoadObj(std::vector& shapes, char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE]; token += 7; #ifdef _MSC_VER - sscanf_s(token, "%s", namebuf, _countof(namebuf)); + sscanf_s(token, "%s", namebuf, (unsigned int)_countof(namebuf)); #else sscanf(token, "%s", namebuf); #endif diff --git a/core/base/CCConsole.cpp b/core/base/CCConsole.cpp index 9557c36bbc..686bed8ce8 100644 --- a/core/base/CCConsole.cpp +++ b/core/base/CCConsole.cpp @@ -517,14 +517,14 @@ bool Console::listenOnTCP(int port) hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) WSADATA wsaData; n = WSAStartup(MAKEWORD(2, 2), &wsaData); #endif if ((n = getaddrinfo(nullptr, serv, &hints, &res)) != 0) { -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) fprintf(stderr, "net_listen error for %s: %s", serv, gai_strerrorA(n)); #else fprintf(stderr, "net_listen error for %s: %s", serv, gai_strerror(n)); @@ -561,7 +561,7 @@ bool Console::listenOnTCP(int port) break; /* success */ /* bind error, close and try next one */ -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) closesocket(listenfd); #else close(listenfd); @@ -784,7 +784,7 @@ void Console::loop() // receive a SIGPIPE, which will cause linux system shutdown the sending process. // Add this ioctl code to check if the socket has been closed by peer. -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) u_long n = 0; ioctlsocket(fd, FIONREAD, &n); #else @@ -841,14 +841,14 @@ void Console::loop() // clean up: ignore stdin, stdout and stderr for (const auto& fd : _fds) { -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) closesocket(fd); #else close(fd); #endif } -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) closesocket(_listenfd); WSACleanup(); #else @@ -1244,7 +1244,7 @@ void Console::commandExit(socket_native_type fd, std::string_view /*args*/) { FD_CLR(fd, &_read_set); _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) closesocket(fd); #else close(fd); @@ -1421,7 +1421,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie _touchId = rand(); Scheduler* sched = Director::getInstance()->getScheduler(); - sched->runOnAxmolThread([=, this]() { + sched->runOnAxmolThread([x1, y1, this]() { float tempx = x1, tempy = y1; Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &_touchId, &tempx, &tempy); }); @@ -1450,7 +1450,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie { _y_ -= dy / dx; } - sched->runOnAxmolThread([=, this]() { + sched->runOnAxmolThread([_x_, _y_, this]() { float tempx = _x_, tempy = _y_; Director::getInstance()->getOpenGLView()->handleTouchesMove(1, &_touchId, &tempx, &tempy); }); @@ -1477,7 +1477,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie { _y_ -= 1; } - sched->runOnAxmolThread([=, this]() { + sched->runOnAxmolThread([_x_, _y_, this]() { float tempx = _x_, tempy = _y_; Director::getInstance()->getOpenGLView()->handleTouchesMove(1, &_touchId, &tempx, &tempy); }); @@ -1485,7 +1485,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie } } - sched->runOnAxmolThread([=, this]() { + sched->runOnAxmolThread([x2, y2, this]() { float tempx = x2, tempy = y2; Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &_touchId, &tempx, &tempy); }); diff --git a/core/base/CCController.h b/core/base/CCController.h index b6f75853af..d060a35544 100644 --- a/core/base/CCController.h +++ b/core/base/CCController.h @@ -27,7 +27,7 @@ #define __cocos2d_libs__CCController__ #if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID || AX_TARGET_PLATFORM == AX_PLATFORM_IOS || \ AX_TARGET_PLATFORM == AX_PLATFORM_MAC || AX_TARGET_PLATFORM == AX_PLATFORM_LINUX || \ - AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) + defined(_WIN32)) # include "platform/CCPlatformMacros.h" # include diff --git a/core/network/HttpClient.cpp b/core/network/HttpClient.cpp index e7877dfbfb..0f385c7109 100644 --- a/core/network/HttpClient.cpp +++ b/core/network/HttpClient.cpp @@ -126,14 +126,14 @@ HttpClient::HttpClient() _service->set_option(yasio::YOPT_S_FORWARD_EVENT, 1); _service->set_option(yasio::YOPT_S_DNS_QUERIES_TIMEOUT, 3); _service->set_option(yasio::YOPT_S_DNS_QUERIES_TRIES, 1); - _service->start([=, this](yasio::event_ptr&& e) { handleNetworkEvent(e.get()); }); + _service->start([this](yasio::event_ptr&& e) { handleNetworkEvent(e.get()); }); for (int i = 0; i < HttpClient::MAX_CHANNELS; ++i) { _availChannelQueue.unsafe_emplace_back(i); } - _scheduler->schedule([=, this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#"); + _scheduler->schedule([this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#"); _isInited = true; } @@ -159,7 +159,7 @@ void HttpClient::setDispatchOnWorkThread(bool bVal) _scheduler->unscheduleAllForTarget(this); _dispatchOnWorkThread = bVal; if (!bVal) - _scheduler->schedule([=, this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#"); + _scheduler->schedule([this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#"); } void HttpClient::handleNetworkStatusChanged() diff --git a/core/platform/CCFileUtils.cpp b/core/platform/CCFileUtils.cpp index 5008f28a88..d4240871ab 100644 --- a/core/platform/CCFileUtils.cpp +++ b/core/platform/CCFileUtils.cpp @@ -1114,7 +1114,7 @@ void FileUtils::listFilesRecursively(std::string_view dirPath, std::vector -#if AX_TARGET_PLATFORM == AX_PLATFORM_WIN32 +#if defined(_WIN32) # include # include # include diff --git a/core/platform/CCSAXParser.cpp b/core/platform/CCSAXParser.cpp index 479fb1188a..3ce82f22e1 100644 --- a/core/platform/CCSAXParser.cpp +++ b/core/platform/CCSAXParser.cpp @@ -43,14 +43,14 @@ public: { _curEleAttrs.reserve(64); - _sax3Handler.xml_start_element_cb = [=, this](char* name, size_t size) { + _sax3Handler.xml_start_element_cb = [this](char* name, size_t size) { _curEleName = xsxml::string_view(name, size); }; - _sax3Handler.xml_attr_cb = [=, this](const char* name, size_t, const char* value, size_t) { + _sax3Handler.xml_attr_cb = [this](const char* name, size_t, const char* value, size_t) { _curEleAttrs.emplace_back(name); _curEleAttrs.emplace_back(value); }; - _sax3Handler.xml_end_attr_cb = [=, this]() { + _sax3Handler.xml_end_attr_cb = [this]() { if (!_curEleAttrs.empty()) { _curEleAttrs.emplace_back(nullptr); @@ -66,10 +66,10 @@ public: (const AX_XML_CHAR**)attrs); } }; - _sax3Handler.xml_end_element_cb = [=, this](const char* name, size_t len) { + _sax3Handler.xml_end_element_cb = [this](const char* name, size_t len) { SAXParser::endElement(_ccsaxParserImp, (const AX_XML_CHAR*)name); }; - _sax3Handler.xml_text_cb = [=, this](const char* s, size_t len) { + _sax3Handler.xml_text_cb = [this](const char* s, size_t len) { SAXParser::textHandler(_ccsaxParserImp, (const AX_XML_CHAR*)s, len); }; }; diff --git a/core/renderer/CCMaterial.cpp b/core/renderer/CCMaterial.cpp index 40559bebd4..3577928d94 100644 --- a/core/renderer/CCMaterial.cpp +++ b/core/renderer/CCMaterial.cpp @@ -40,7 +40,7 @@ #include -#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) +#if defined(_WIN32) # define strcasecmp _stricmp #endif diff --git a/core/renderer/CCRenderer.cpp b/core/renderer/CCRenderer.cpp index 056c7386c5..622b4a6723 100644 --- a/core/renderer/CCRenderer.cpp +++ b/core/renderer/CCRenderer.cpp @@ -864,7 +864,7 @@ void Renderer::clear(ClearFlag flags, const Color4F& color, float depth, unsigne CallbackCommand* command = nextCallbackCommand(); command->init(globalOrder); - command->func = [=, this]() -> void { + command->func = [this, flags, color, depth, stencil]() -> void { backend::RenderPassDescriptor descriptor; diff --git a/core/renderer/backend/opengl/TextureGL.cpp b/core/renderer/backend/opengl/TextureGL.cpp index 7455bbfa31..6812a6e8a9 100644 --- a/core/renderer/backend/opengl/TextureGL.cpp +++ b/core/renderer/backend/opengl/TextureGL.cpp @@ -77,7 +77,7 @@ void TextureInfoGL::applySampler(const SamplerDescriptor& descriptor, bool isPow } // apply sampler for all internal textures - foreach ([=, this](GLuint texID, int index) { + foreach ([this, target](GLuint texID, int index) { glBindTexture(target, textures[index]); setCurrentTexParameters(target); diff --git a/core/ui/UIPageView.cpp b/core/ui/UIPageView.cpp index 93483e1740..fae9239841 100644 --- a/core/ui/UIPageView.cpp +++ b/core/ui/UIPageView.cpp @@ -295,7 +295,7 @@ void PageView::pageTurningEvent() void PageView::addEventListener(const ccPageViewCallback& callback) { _eventCallback = callback; - ccScrollViewCallback scrollViewCallback = [=, this](Ref* /*ref*/, ScrollView::EventType type) -> void { + ccScrollViewCallback scrollViewCallback = [this](Ref* /*ref*/, ScrollView::EventType type) -> void { if (type == ScrollView::EventType::AUTOSCROLL_ENDED && _previousPageIndex != _currentPageIndex) { pageTurningEvent(); diff --git a/core/ui/UIPageViewIndicator.cpp b/core/ui/UIPageViewIndicator.cpp index 27205720ab..af3c1e68af 100644 --- a/core/ui/UIPageViewIndicator.cpp +++ b/core/ui/UIPageViewIndicator.cpp @@ -248,7 +248,7 @@ void PageViewIndicator::increaseNumberOfPages() indexNode = Sprite::createWithSpriteFrameName(_indexNodesTextureFile); break; default: - break; + return; } } diff --git a/core/ui/UITextFieldEx.cpp b/core/ui/UITextFieldEx.cpp index 8cebfd68b2..ddbb12d78b 100644 --- a/core/ui/UITextFieldEx.cpp +++ b/core/ui/UITextFieldEx.cpp @@ -19,7 +19,7 @@ NS_AX_BEGIN -#ifdef _WIN32 +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP # define nxbeep(t) MessageBeep(t) #else # define nxbeep(t) @@ -380,7 +380,7 @@ void TextFieldEx::enableIME(Node* control) if (control == nullptr) control = this; - touchListener->onTouchBegan = [=, this](Touch* touch, Event*) { + touchListener->onTouchBegan = [control,this](Touch* touch, Event*) { bool focus = (engine_inj_checkVisibility(this) && this->editable && this->enabled && engine_inj_containsTouchPoint(control, touch)); diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index ce17c3a51a..827ec29486 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -317,7 +317,7 @@ void AssetsManager::downloadAndUncompress() // Uncompress zip file. if (!uncompress()) { - Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this] { + Director::getInstance()->getScheduler()->runOnAxmolThread([&, this] { UserDefault::getInstance()->setStringForKey(this->keyOfDownloadedVersion().c_str(), ""); UserDefault::getInstance()->flush(); if (this->_delegate) @@ -326,7 +326,7 @@ void AssetsManager::downloadAndUncompress() break; } - Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this] { + Director::getInstance()->getScheduler()->runOnAxmolThread([&, this] { // Record new version code. UserDefault::getInstance()->setStringForKey(this->keyOfVersion().c_str(), this->_version);