diff --git a/CMakeLists.txt b/CMakeLists.txt index d1e7a9d1e..6fb6cc54c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2633,11 +2633,11 @@ if(CLIENT AND DMGBUILD) COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ddnet-libs/sdl/${LIB_DIR}/SDL2.framework ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/SDL2.framework ${DMG_DISCORD_COPY_COMMAND} COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/freetype/${LIB_DIR}/libfreetype.6.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavcodec.58.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavformat.58.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavutil.56.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libswresample.3.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libswscale.5.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavcodec.59.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavformat.59.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavutil.57.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libswresample.4.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libswscale.6.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/libsteam_api.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/ COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/darwin_strip_rpath.py ${CMAKE_OTOOL} ${CMAKE_INSTALL_NAME_TOOL} ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/MacOS/${TARGET_CLIENT} COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath @loader_path/../Frameworks ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/MacOS/${TARGET_CLIENT} diff --git a/cmake/FindFFMPEG.cmake b/cmake/FindFFMPEG.cmake index aef2b17b4..ba5440d1f 100644 --- a/cmake/FindFFMPEG.cmake +++ b/cmake/FindFFMPEG.cmake @@ -12,35 +12,35 @@ endif() set_extra_dirs_lib(FFMPEG ffmpeg) find_library(AVCODEC_LIBRARY - NAMES avcodec.58 avcodec libavcodec + NAMES avcodec.59 avcodec libavcodec HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_AVCODEC_LIBRARY_DIRS} PATHS ${PATHS_AVCODEC_LIBDIR} ${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH} ) find_library(AVFORMAT_LIBRARY - NAMES avformat.58 avformat libavformat + NAMES avformat.59 avformat libavformat HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_AVFORMAT_LIBRARY_DIRS} PATHS ${PATHS_AVFORMAT_LIBDIR} ${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH} ) find_library(AVUTIL_LIBRARY - NAMES avutil.56 avutil libavutil + NAMES avutil.57 avutil libavutil HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_AVUTIL_LIBRARY_DIRS} PATHS ${PATHS_AVUTIL_LIBDIR} ${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH} ) find_library(SWSCALE_LIBRARY - NAMES swscale.5 swscale libswscale + NAMES swscale.6 swscale libswscale HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_SWSCALE_LIBRARY_DIRS} PATHS ${PATHS_SWSCALE_LIBDIR} ${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH} ) find_library(SWRESAMPLE_LIBRARY - NAMES swresample.3 swresample libswresample + NAMES swresample.4 swresample libswresample HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_SWRESAMPLE_LIBRARY_DIRS} PATHS ${PATHS_SWRESAMPLE_LIBDIR} ${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH} @@ -150,19 +150,19 @@ set(FFMPEG_COPY_FILES) if(FFMPEG_BUNDLED) if(TARGET_OS STREQUAL "windows") set(FFMPEG_COPY_FILES - "${EXTRA_FFMPEG_LIBDIR}/avcodec-58.dll" - "${EXTRA_FFMPEG_LIBDIR}/avformat-58.dll" - "${EXTRA_FFMPEG_LIBDIR}/avutil-56.dll" - "${EXTRA_FFMPEG_LIBDIR}/swresample-3.dll" - "${EXTRA_FFMPEG_LIBDIR}/swscale-5.dll" + "${EXTRA_FFMPEG_LIBDIR}/avcodec-59.dll" + "${EXTRA_FFMPEG_LIBDIR}/avformat-59.dll" + "${EXTRA_FFMPEG_LIBDIR}/avutil-57.dll" + "${EXTRA_FFMPEG_LIBDIR}/swresample-4.dll" + "${EXTRA_FFMPEG_LIBDIR}/swscale-6.dll" ) elseif(TARGET_OS STREQUAL "mac") set(FFMPEG_COPY_FILES - "${EXTRA_FFMPEG_LIBDIR}/libavcodec.58.dylib" - "${EXTRA_FFMPEG_LIBDIR}/libavformat.58.dylib" - "${EXTRA_FFMPEG_LIBDIR}/libavutil.56.dylib" - "${EXTRA_FFMPEG_LIBDIR}/libswresample.3.dylib" - "${EXTRA_FFMPEG_LIBDIR}/libswscale.5.dylib" + "${EXTRA_FFMPEG_LIBDIR}/libavcodec.59.dylib" + "${EXTRA_FFMPEG_LIBDIR}/libavformat.59.dylib" + "${EXTRA_FFMPEG_LIBDIR}/libavutil.57.dylib" + "${EXTRA_FFMPEG_LIBDIR}/libswresample.4.dylib" + "${EXTRA_FFMPEG_LIBDIR}/libswscale.6.dylib" ) endif() endif() diff --git a/cmake/FindWebsockets.cmake b/cmake/FindWebsockets.cmake index d8d0a84dd..b5bdd4367 100644 --- a/cmake/FindWebsockets.cmake +++ b/cmake/FindWebsockets.cmake @@ -33,7 +33,7 @@ if(WEBSOCKETS_FOUND) if(TARGET_OS STREQUAL "windows") set(WEBSOCKETS_COPY_FILES "${EXTRA_WEBSOCKETS_LIBDIR}/libwebsockets.dll") elseif(TARGET_OS STREQUAL "mac") - set(WEBSOCKETS_COPY_FILES "${EXTRA_WEBSOCKETS_LIBDIR}/libwebsockets.18.dylib") + set(WEBSOCKETS_COPY_FILES "${EXTRA_WEBSOCKETS_LIBDIR}/libwebsockets.19.dylib") endif() endif() endif() diff --git a/data/languages/simplified_chinese.txt b/data/languages/simplified_chinese.txt index 6135c913d..29d232cf4 100644 --- a/data/languages/simplified_chinese.txt +++ b/data/languages/simplified_chinese.txt @@ -15,6 +15,7 @@ # 2021-06-01 TsFreddie # 2021-11-19 cheeser0613 # 2021-12-21 cheeser0613 +# 2022-02-07 cheeser0613 ##### /authors ##### ##### translated strings ##### @@ -1360,4 +1361,4 @@ Chat command (e.g. showall 1) == 聊天指令 (例如: showall 1) Windowed fullscreen -== +== 窗口化全屏 diff --git a/data/languages/traditional_chinese.txt b/data/languages/traditional_chinese.txt index 7e97c4585..e130e8ecf 100644 --- a/data/languages/traditional_chinese.txt +++ b/data/languages/traditional_chinese.txt @@ -8,6 +8,7 @@ # 2021-06-01 TsFreddie # 2021-11-19 cheeser0613 # 2021-12-21 cheeser0613 +# 2022-02-07 cheeser0613 ##### /authors ##### ##### translated strings ##### @@ -1353,4 +1354,4 @@ Chat command (e.g. showall 1) == 聊天指令 (例如: showall 1) Windowed fullscreen -== +== 視窗化全螢幕 diff --git a/ddnet-libs b/ddnet-libs index b917d9a30..239dc15f4 160000 --- a/ddnet-libs +++ b/ddnet-libs @@ -1 +1 @@ -Subproject commit b917d9a3010f67f6cb77eed68512c05156b1cd65 +Subproject commit 239dc15f4fdc98dd709d1fa313c389ae04ad72aa diff --git a/src/engine/client/serverbrowser_http.cpp b/src/engine/client/serverbrowser_http.cpp index 9d7a21587..ca5d316f9 100644 --- a/src/engine/client/serverbrowser_http.cpp +++ b/src/engine/client/serverbrowser_http.cpp @@ -23,7 +23,7 @@ public: MAX_URLS = 16, }; CChooseMaster(IEngine *pEngine, VALIDATOR pfnValidator, const char **ppUrls, int NumUrls, int PreviousBestIndex); - virtual ~CChooseMaster() {} + virtual ~CChooseMaster(); bool GetBestUrl(const char **pBestUrl) const; void Reset(); @@ -44,13 +44,17 @@ private: }; class CJob : public IJob { + LOCK m_Lock; std::shared_ptr m_pData; + std::unique_ptr m_pHead PT_GUARDED_BY(m_Lock); + std::unique_ptr m_pGet PT_GUARDED_BY(m_Lock); virtual void Run(); public: CJob(std::shared_ptr pData) : - m_pData(std::move(pData)) {} - virtual ~CJob() {} + m_pData(std::move(pData)) { m_Lock = lock_create(); } + virtual ~CJob() { lock_destroy(m_Lock); } + void Abort(); }; IEngine *m_pEngine; @@ -76,6 +80,14 @@ CChooseMaster::CChooseMaster(IEngine *pEngine, VALIDATOR pfnValidator, const cha } } +CChooseMaster::~CChooseMaster() +{ + if(m_pJob) + { + m_pJob->Abort(); + } +} + int CChooseMaster::GetBestIndex() const { int BestIndex = m_pData->m_BestIndex.load(); @@ -113,6 +125,21 @@ void CChooseMaster::Refresh() m_pEngine->AddJob(m_pJob = std::make_shared(m_pData)); } +void CChooseMaster::CJob::Abort() +{ + lock_wait(m_Lock); + if(m_pHead != nullptr) + { + m_pHead->Abort(); + } + + if(m_pGet != nullptr) + { + m_pGet->Abort(); + } + lock_unlock(m_Lock); +} + void CChooseMaster::CJob::Run() { // Check masters in a random order. @@ -139,21 +166,37 @@ void CChooseMaster::CJob::Run() { aTimeMs[i] = -1; const char *pUrl = m_pData->m_aaUrls[aRandomized[i]]; - CHead Head(pUrl, Timeout, HTTPLOG::FAILURE); - IEngine::RunJobBlocking(&Head); - if(Head.State() != HTTP_DONE) + CHead *pHead = new CHead(pUrl, Timeout, HTTPLOG::FAILURE); + lock_wait(m_Lock); + m_pHead = std::unique_ptr(pHead); + lock_unlock(m_Lock); + IEngine::RunJobBlocking(pHead); + if(pHead->State() == HTTP_ABORTED) + { + dbg_msg("serverbrowse_http", "master chooser aborted"); + return; + } + if(pHead->State() != HTTP_DONE) { continue; } int64_t StartTime = time_get_microseconds(); - CGet Get(pUrl, Timeout, HTTPLOG::FAILURE); - IEngine::RunJobBlocking(&Get); + CGet *pGet = new CGet(pUrl, Timeout, HTTPLOG::FAILURE); + lock_wait(m_Lock); + m_pGet = std::unique_ptr(pGet); + lock_unlock(m_Lock); + IEngine::RunJobBlocking(pGet); int Time = (time_get_microseconds() - StartTime) / 1000; - if(Get.State() != HTTP_DONE) + if(pHead->State() == HTTP_ABORTED) + { + dbg_msg("serverbrowse_http", "master chooser aborted"); + return; + } + if(pGet->State() != HTTP_DONE) { continue; } - json_value *pJson = Get.ResultJson(); + json_value *pJson = pGet->ResultJson(); if(!pJson) { continue; @@ -195,7 +238,7 @@ class CServerBrowserHttp : public IServerBrowserHttp { public: CServerBrowserHttp(IEngine *pEngine, IConsole *pConsole, const char **ppUrls, int NumUrls, int PreviousBestIndex); - virtual ~CServerBrowserHttp() {} + virtual ~CServerBrowserHttp(); void Update(); bool IsRefreshing() { return m_State != STATE_DONE; } void Refresh(); @@ -261,6 +304,15 @@ CServerBrowserHttp::CServerBrowserHttp(IEngine *pEngine, IConsole *pConsole, con { m_pChooseMaster->Refresh(); } + +CServerBrowserHttp::~CServerBrowserHttp() +{ + if(m_pGetServers != nullptr) + { + m_pGetServers->Abort(); + } +} + void CServerBrowserHttp::Update() { if(m_State == STATE_WANTREFRESH)