From e431474c676a253004a26d86fc9e1a6100d329d4 Mon Sep 17 00:00:00 2001 From: -ffs-PLASMA <33094646+ffsPLASMA@users.noreply.github.com> Date: Wed, 21 Aug 2024 21:14:34 +0200 Subject: [PATCH 1/8] Make frame graph scale accordingly to resolution (#3593) --- Client/core/CChat.cpp | 5 ++++ Client/core/CChat.h | 2 ++ Client/core/CGUI.cpp | 5 ++++ Client/core/CGUI.h | 1 + Client/core/CGraphStats.cpp | 48 +++++++++++++++++++++---------------- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/Client/core/CChat.cpp b/Client/core/CChat.cpp index 4a66d2907b..438ea577fe 100644 --- a/Client/core/CChat.cpp +++ b/Client/core/CChat.cpp @@ -1117,6 +1117,11 @@ void CChat::SetCharacterLimit(int charLimit) m_iCharacterLimit = charLimit; } +float CChat::GetChatBottomPosition() const noexcept +{ + return m_vecBackgroundSize.fY; +} + CChatLine::CChatLine() { m_bActive = false; diff --git a/Client/core/CChat.h b/Client/core/CChat.h index 5316086170..e967127075 100644 --- a/Client/core/CChat.h +++ b/Client/core/CChat.h @@ -207,6 +207,8 @@ class CChat constexpr int GetDefaultCharacterLimit() const { return m_iDefaultCharacterLimit; } constexpr int GetMaxCharacterLimit() const { return m_iMaxCharacterLimit; } + float GetChatBottomPosition() const noexcept; + private: void LoadCVars(); diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index a64955ac79..c4a2729d7a 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -449,6 +449,11 @@ CChat* CLocalGUI::GetChat() return m_pChat; } +float CLocalGUI::GetChatBottomPosition() const noexcept +{ + return m_pChat->GetChatBottomPosition(); +} + CDebugView* CLocalGUI::GetDebugView() { return m_pDebugView; diff --git a/Client/core/CGUI.h b/Client/core/CGUI.h index 39d7921bba..f667082844 100644 --- a/Client/core/CGUI.h +++ b/Client/core/CGUI.h @@ -68,6 +68,7 @@ class CLocalGUI : public CSingleton bool IsMainMenuVisible(); CChat* GetChat(); + float GetChatBottomPosition() const noexcept; void SetChatBoxVisible(bool bVisible, bool bInputBlocked = true); bool IsChatBoxVisible(); bool IsChatBoxInputBlocked(); diff --git a/Client/core/CGraphStats.cpp b/Client/core/CGraphStats.cpp index eb6284ff15..3a5a25cc2e 100644 --- a/Client/core/CGraphStats.cpp +++ b/Client/core/CGraphStats.cpp @@ -12,8 +12,6 @@ namespace { - #define GRAPHSTAT_HISTORY_SIZE 256 - struct SGraphStatLine { TIMEUS prevData; @@ -113,6 +111,11 @@ void CGraphStats::AddTimingPoint(const char* szName) if (!IsEnabled()) return; + CGraphicsInterface* pGraphics = g_pCore->GetGraphics(); + + std::uint32_t viewportWidth = pGraphics->GetViewportWidth(); + std::uint32_t sizeX = viewportWidth / 4; // one quarter of screen width + // Start of next frame? if (szName[0] == 0) { @@ -133,7 +136,7 @@ void CGraphStats::AddTimingPoint(const char* szName) for (int i = 0; i < Dups; i++) { pLine->iDataPos++; - if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1) + if (pLine->iDataPos > sizeX - 1) pLine->iDataPos = 0; pLine->dataHistory[pLine->iDataPos] = Data; } @@ -153,7 +156,7 @@ void CGraphStats::AddTimingPoint(const char* szName) // Add new line MapSet(m_LineList, szName, SGraphStatLine()); pLine = MapFind(m_LineList, szName); - pLine->dataHistory.resize(GRAPHSTAT_HISTORY_SIZE); + pLine->dataHistory.resize(sizeX); memset(&pLine->dataHistory[0], 0, pLine->dataHistory.size()); pLine->iDataPos = 0; pLine->prevData = 0; @@ -179,7 +182,7 @@ void CGraphStats::AddTimingPoint(const char* szName) // Inc position pLine->iDataPos++; - if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1) + if (pLine->iDataPos > sizeX - 1) pLine->iDataPos = 0; // Insert data point @@ -199,29 +202,34 @@ void CGraphStats::Draw() return; CGraphicsInterface* pGraphics = g_pCore->GetGraphics(); + CLocalGUI* pLocalGUI = g_pCore->GetLocalGUI(); + + std::uint32_t viewportWidth = pGraphics->GetViewportWidth(); // get width of current resolution + std::uint32_t viewportHeight = pGraphics->GetViewportHeight(); // get height of current resolution + std::uint32_t originX = 10; // offset the graph by 10 pixels from left side of screen + std::uint32_t originY = pLocalGUI->GetChatBottomPosition(); // get chat bottom screen position + std::uint32_t sizeX = viewportWidth / 4; // set the width of graph to 1/4 of current resolution + std::uint32_t sizeY = viewportHeight / 4; // set the height of graph to 1/4 of current resolution + std::uint32_t rangeY = 100; // 100ms + + originY = originY + sizeY + 30; // add graph height plus a little gap to the overall Y position - uint uiViewportHeight = pGraphics->GetViewportHeight(); - uint uiOriginX = 10; - uint uiOriginY = std::min(500, uiViewportHeight - 10); - uint uiSizeX = GRAPHSTAT_HISTORY_SIZE; - uint uiSizeY = 150; - uint uiRangeY = 100; // 100ms - float fLineScale = 1 / 1000.f / uiRangeY * uiSizeY; + float fLineScale = 1 / 1000.f / rangeY * sizeY; float fLineHeight = pGraphics->GetDXFontHeight(); // Backgroung box - pGraphics->DrawRectQueued(uiOriginX, uiOriginY - uiSizeY, uiSizeX, uiSizeY, SColorRGBA(0, 0, 0, 128), true); + pGraphics->DrawRectQueued(originX, originY - sizeY, sizeX, sizeY, SColorRGBA(0, 0, 0, 128), true); // Draw data lines - float fLabelX = uiOriginX + uiSizeX + 22; - float fLabelY = uiOriginY - m_LineList.size() * fLineHeight; + float fLabelX = originX + sizeX + 22; + float fLabelY = originY - m_LineList.size() * fLineHeight; for (const auto& dataLine : m_LineList) { const SGraphStatLine& line = dataLine.second; int iDataPos = line.iDataPos; int iDataPosPrev = iDataPos; - for (int i = uiSizeX - 1; i > 0; i--) + for (int i = sizeX - 1; i > 0; i--) { float fY0 = line.dataHistory[iDataPos] * fLineScale; float fY1 = line.dataHistory[iDataPosPrev] * fLineScale; @@ -229,14 +237,14 @@ void CGraphStats::Draw() iDataPosPrev = iDataPos; iDataPos--; if (iDataPos == -1) - iDataPos = GRAPHSTAT_HISTORY_SIZE - 1; + iDataPos = sizeX - 1; - pGraphics->DrawLineQueued(uiOriginX + i - 1, uiOriginY - fY0, uiOriginX + i, uiOriginY - fY1, 1, line.color, true); + pGraphics->DrawLineQueued(originX + i - 1, originY - fY0, originX + i, originY - fY1, 1, line.color, true); - if (i == uiSizeX - 1) + if (i == sizeX - 1) { // Line from graph to label - pGraphics->DrawLineQueued(uiOriginX + i - 1, uiOriginY - fY0, fLabelX - 2, fLabelY + fLineHeight / 2, 1, line.color, true); + pGraphics->DrawLineQueued(originX + i - 1, originY - fY0, fLabelX - 2, fLabelY + fLineHeight / 2, 1, line.color, true); } } From cd7dd1aa9c8ee0bc39b1aef42caa9cd5d469e54a Mon Sep 17 00:00:00 2001 From: MTABot Date: Thu, 22 Aug 2024 07:20:49 +0000 Subject: [PATCH 2/8] Visual Studio Update Build Tools 2022: 17.11.35219.272 This is an automated commit to keep track of toolchain changes on the build server. It applies to every MTA build after this commit until further notice. [skip ci] From a41e5aae8b312383931d06a4f304c97d7cda86d0 Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Fri, 23 Aug 2024 22:20:26 +0200 Subject: [PATCH 3/8] Switch to libncursesw6 --- Dockerfile | 2 +- Dockerfile.arm64 | 2 +- Dockerfile.armhf | 2 +- Dockerfile.i386 | 2 +- README.md | 4 ++-- Server/core/premake5.lua | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56439d28be..c0a721081b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ENV AS_BUILDAGENT=0 \ RUN apt-get update && \ apt-get install -y software-properties-common wget ca-certificates git build-essential \ gcc-10 g++-10 curl subversion ncftp \ - libncurses-dev libncursesw5 libmysqlclient-dev + libncurses-dev libncursesw6 libmysqlclient-dev # Set build directory VOLUME /build diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index f491aa5cf0..b2da73f581 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -21,7 +21,7 @@ RUN sed -i 's/deb http/deb \[arch=amd64,i386\] http/' /etc/apt/sources.list && \ apt-get update && \ apt-get install -y make git ncftp \ gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu \ - libncursesw5:arm64 libncursesw5-dev:arm64 libmysqlclient-dev:arm64 + libncurses-dev:arm64 libncursesw6:arm64 libmysqlclient-dev:arm64 # Set build directory VOLUME /build diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 0cdf11543c..3cc20df9c5 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -21,7 +21,7 @@ RUN sed -i 's/deb http/deb \[arch=amd64,i386\] http/' /etc/apt/sources.list && \ apt-get update && \ apt-get install -y make git ncftp \ gcc-10-arm-linux-gnueabihf g++-10-arm-linux-gnueabihf \ - libncursesw5:armhf libncursesw5-dev:armhf libmysqlclient-dev:armhf + libncurses-dev:armhf libncursesw6:armhf libmysqlclient-dev:armhf # Set build directory VOLUME /build diff --git a/Dockerfile.i386 b/Dockerfile.i386 index 787782bdbe..7706537c15 100644 --- a/Dockerfile.i386 +++ b/Dockerfile.i386 @@ -15,7 +15,7 @@ ENV AS_BUILDAGENT=0 \ RUN dpkg --add-architecture i386 && apt-get update && \ apt-get install -y software-properties-common wget ca-certificates git build-essential \ gcc-10-multilib g++-10-multilib curl subversion ncftp \ - libncurses-dev:i386 libncursesw5:i386 libmysqlclient-dev:i386 + libncurses-dev:i386 libncursesw6:i386 libmysqlclient-dev:i386 # Set build directory VOLUME /build diff --git a/README.md b/README.md index 27221cabf3..c10258f599 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ You can build the MTA:SA server on GNU/Linux distributions only for x86, x86_64, - git - make - GNU GCC compiler (version 10 or newer) -- libncursesw5 -- libncursesw5-dev +- libncursesw6 +- libncurses-dev - libmysqlclient-dev **Build instructions: Script** diff --git a/Server/core/premake5.lua b/Server/core/premake5.lua index 7e52214323..c7b5c552d9 100644 --- a/Server/core/premake5.lua +++ b/Server/core/premake5.lua @@ -44,7 +44,7 @@ project "Core" links { "breakpad", "rt" } buildoptions { "-pthread" } linkoptions { "-pthread" } - linkoptions { "-l:libncursesw.so.5" } + linkoptions { "-l:libncursesw.so.6" } filter "system:macosx" links { "ncurses", "breakpad", "CoreFoundation.framework" } From 09e8350a3130c0f8fdf0f51b9d8e0882b571d779 Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Fri, 23 Aug 2024 22:52:09 +0200 Subject: [PATCH 4/8] Remove Docker files for macOS --- .github/workflows/dockerimage.yaml | 6 ----- Dockerfile.osx-arm64 | 40 ------------------------------ Dockerfile.osx-x64 | 40 ------------------------------ utils/docker-entrypoint-osx.sh | 16 ------------ 4 files changed, 102 deletions(-) delete mode 100644 Dockerfile.osx-arm64 delete mode 100644 Dockerfile.osx-x64 delete mode 100644 utils/docker-entrypoint-osx.sh diff --git a/.github/workflows/dockerimage.yaml b/.github/workflows/dockerimage.yaml index 21fcd2da1f..fcc2b8e4c7 100644 --- a/.github/workflows/dockerimage.yaml +++ b/.github/workflows/dockerimage.yaml @@ -12,8 +12,6 @@ on: - 'Dockerfile.i386' - 'Dockerfile.armhf' - 'Dockerfile.arm64' - - 'Dockerfile.osx-x64' - - 'Dockerfile.osx-arm64' jobs: build: @@ -28,10 +26,6 @@ jobs: dockerfile: Dockerfile.armhf - tag: arm64 dockerfile: Dockerfile.arm64 - - tag: osx-x64 - dockerfile: Dockerfile.osx-x64 - - tag: osx-arm64 - dockerfile: Dockerfile.osx-arm64 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/Dockerfile.osx-arm64 b/Dockerfile.osx-arm64 deleted file mode 100644 index 4846c0cdf2..0000000000 --- a/Dockerfile.osx-arm64 +++ /dev/null @@ -1,40 +0,0 @@ -FROM jetbrains/teamcity-minimal-agent:latest - -# This is important for using apt-get -USER root - -# Install cross-build dependencies -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates subversion ncftp \ - git autoconf wget make patch cmake clang llvm-dev uuid-dev libssl-dev lzma-dev libxml2-dev python3 - -# Prepare cross-build environment -ENV MACOSX_DEPLOYMENT_TARGET=11.0 \ - PATH="${PATH}:/opt/osxcross/bin" \ - OSXCROSS_MP_INC=1 - -RUN mkdir -p /opt/osxcross && \ - git clone https://github.com/tpoechtrager/osxcross.git /opt/osxcross/setup_files && \ - cd /opt/osxcross/setup_files && \ - wget -P tarballs https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \ - UNATTENDED=1 TARGET_DIR=/opt/osxcross ./build.sh && \ - UNATTENDED=1 ../bin/osxcross-macports install --arm64 mysql8 libidn2 - -# Default build configuration -ENV AS_BUILDAGENT=0 \ - BUILD_ARCHITECTURE=arm64 \ - BUILD_CONFIG=release \ - AR=arm64-apple-darwin20.4-ar \ - CC=arm64-apple-darwin20.4-clang \ - CXX=arm64-apple-darwin20.4-clang++ - -# Set build directory -VOLUME /build -WORKDIR /build - -# Copy entrypoint script -COPY utils/docker-entrypoint-osx.sh /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh - -# Set entrypoint -ENTRYPOINT /docker-entrypoint.sh diff --git a/Dockerfile.osx-x64 b/Dockerfile.osx-x64 deleted file mode 100644 index a694b06027..0000000000 --- a/Dockerfile.osx-x64 +++ /dev/null @@ -1,40 +0,0 @@ -FROM jetbrains/teamcity-minimal-agent:latest - -# This is important for using apt-get -USER root - -# Install cross-build dependencies -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates subversion ncftp \ - git autoconf wget make patch cmake clang llvm-dev uuid-dev libssl-dev lzma-dev libxml2-dev python3 - -# Prepare cross-build environment -ENV MACOSX_DEPLOYMENT_TARGET=10.15 \ - PATH="${PATH}:/opt/osxcross/bin" \ - OSXCROSS_MP_INC=1 - -RUN mkdir -p /opt/osxcross && \ - git clone https://github.com/tpoechtrager/osxcross.git /opt/osxcross/setup_files && \ - cd /opt/osxcross/setup_files && \ - wget -P tarballs https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \ - UNATTENDED=1 TARGET_DIR=/opt/osxcross ./build.sh && \ - UNATTENDED=1 ../bin/osxcross-macports install mysql8 libidn2 - -# Default build configuration -ENV AS_BUILDAGENT=0 \ - BUILD_ARCHITECTURE=x64 \ - BUILD_CONFIG=release \ - AR=x86_64-apple-darwin20.4-ar \ - CC=x86_64-apple-darwin20.4-clang \ - CXX=x86_64-apple-darwin20.4-clang++ - -# Set build directory -VOLUME /build -WORKDIR /build - -# Copy entrypoint script -COPY utils/docker-entrypoint-osx.sh /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh - -# Set entrypoint -ENTRYPOINT /docker-entrypoint.sh diff --git a/utils/docker-entrypoint-osx.sh b/utils/docker-entrypoint-osx.sh deleted file mode 100644 index 6b40c2a7c2..0000000000 --- a/utils/docker-entrypoint-osx.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# If configurede as a build agent, start Teamcity agent -if [[ $AS_BUILDAGENT = "1" ]]; then - # https://github.com/JetBrains/teamcity-docker-minimal-agent/blob/master/Dockerfile#L17 - exec /run-services.sh -fi - -# Manually invoke build process -# So, first make a shallow clone of the repository if it not exists -umask 000 -if [ ! -f ./premake5.lua ]; then - git clone --depth=1 https://github.com/multitheftauto/mtasa-blue.git . -fi - -./linux-build.sh --os=macosx --arch=$BUILD_ARCHITECTURE --config=$BUILD_CONFIG From 1c6cab5a94c8c6ff5cf9b1fc0c9bc04808c922f8 Mon Sep 17 00:00:00 2001 From: justn <39979049+jvstns@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:49:35 -0400 Subject: [PATCH 5/8] Fixes getTimerDetails negative remaining duration (#3663) * Fixes negative numbers Fixes negative remaining duration in current timer, remaining should always be 0 * Return in single statement Co-authored-by: Nico <122193236+Nico8340@users.noreply.github.com> * 0 > 0LL --------- Co-authored-by: Nico <122193236+Nico8340@users.noreply.github.com> Co-authored-by: TEDERIs --- Shared/mods/deathmatch/logic/lua/CLuaTimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/mods/deathmatch/logic/lua/CLuaTimer.cpp b/Shared/mods/deathmatch/logic/lua/CLuaTimer.cpp index 00f919704f..f632a1a237 100644 --- a/Shared/mods/deathmatch/logic/lua/CLuaTimer.cpp +++ b/Shared/mods/deathmatch/logic/lua/CLuaTimer.cpp @@ -68,5 +68,5 @@ CTickCount CLuaTimer::GetTimeLeft() { CTickCount llCurrentTime = CTickCount::Now(); CTickCount llTimeLeft = m_llStartTime + m_llDelay - llCurrentTime; - return llTimeLeft; + return llTimeLeft.ToLongLong() < 0LL ? CTickCount(0LL) : llTimeLeft; } From 5508c7e4058ad9d29cacc9964f8e84df2c60d14f Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Sat, 24 Aug 2024 19:52:42 +0200 Subject: [PATCH 6/8] Fix google-breakpad in newer GCC versions (PR #3674) --- .../src/client/linux/handler/minidump_descriptor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/google-breakpad/src/client/linux/handler/minidump_descriptor.h b/vendor/google-breakpad/src/client/linux/handler/minidump_descriptor.h index 911beaef45..8c700861af 100644 --- a/vendor/google-breakpad/src/client/linux/handler/minidump_descriptor.h +++ b/vendor/google-breakpad/src/client/linux/handler/minidump_descriptor.h @@ -34,6 +34,7 @@ #include #include +#include #include "client/linux/handler/microdump_extra_info.h" #include "common/using_std_string.h" From 295844a8ca95af94450c9da6ff6cde547df29caa Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Mon, 26 Aug 2024 16:57:02 +0300 Subject: [PATCH 7/8] Fix engineRequestModel crash caused by CResourceModelStreamer (#3675) * Fix crash * Fix refs count * Use reference --------- Co-authored-by: TEDERIs --- Client/mods/deathmatch/logic/CResourceModelStreamer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CResourceModelStreamer.cpp b/Client/mods/deathmatch/logic/CResourceModelStreamer.cpp index 9c58219d8b..c6c2eb30d1 100644 --- a/Client/mods/deathmatch/logic/CResourceModelStreamer.cpp +++ b/Client/mods/deathmatch/logic/CResourceModelStreamer.cpp @@ -106,7 +106,11 @@ void CResourceModelStreamer::ReleaseAll() void CResourceModelStreamer::FullyReleaseModel(std::uint16_t modelId) { - std::uint16_t &refsCount = m_requestedModels[modelId]; + auto refs = m_requestedModels.find(modelId); + if (refs == m_requestedModels.end()) + return; + + std::uint16_t& refsCount = refs->second; if (refsCount > 0) { From 4e7afa2586c6992a75ac5312378c1096d87148ae Mon Sep 17 00:00:00 2001 From: TEDERIs Date: Tue, 27 Aug 2024 14:59:45 +0700 Subject: [PATCH 8/8] setElementModel memory leak fix (#3671) * Memory leak fix * Misprint fix * Clean up * Use CEntitySAInterface::DeleteRwObject --- Client/core/CCore.cpp | 5 ---- Client/core/CCore.h | 1 - Client/core/CModelCacheManager.cpp | 28 +-------------------- Client/core/CModelCacheManager.h | 1 - Client/game_sa/CPedSA.cpp | 16 ++++-------- Client/game_sa/CPedSA.h | 1 - Client/mods/deathmatch/logic/CClientPed.cpp | 17 +------------ Client/sdk/core/CCoreInterface.h | 1 - Client/sdk/game/CPed.h | 1 - 9 files changed, 7 insertions(+), 64 deletions(-) diff --git a/Client/core/CCore.cpp b/Client/core/CCore.cpp index 849eee0afc..364836e111 100644 --- a/Client/core/CCore.cpp +++ b/Client/core/CCore.cpp @@ -2181,11 +2181,6 @@ CModelCacheManager* CCore::GetModelCacheManager() return m_pModelCacheManager; } -void CCore::AddModelToPersistentCache(ushort usModelId) -{ - return GetModelCacheManager()->AddModelToPersistentCache(usModelId); -} - void CCore::StaticIdleHandler() { g_pCore->IdleHandler(); diff --git a/Client/core/CCore.h b/Client/core/CCore.h index 55460a6f4f..3439a484de 100644 --- a/Client/core/CCore.h +++ b/Client/core/CCore.h @@ -253,7 +253,6 @@ class CCore : public CCoreInterface, public CSingleton EDiagnosticDebugType GetDiagnosticDebug(); void SetDiagnosticDebug(EDiagnosticDebugType value); CModelCacheManager* GetModelCacheManager(); - void AddModelToPersistentCache(ushort usModelId); static void StaticIdleHandler(); void IdleHandler(); diff --git a/Client/core/CModelCacheManager.cpp b/Client/core/CModelCacheManager.cpp index 00c762fa80..40fa7c8ff4 100644 --- a/Client/core/CModelCacheManager.cpp +++ b/Client/core/CModelCacheManager.cpp @@ -47,7 +47,6 @@ class CModelCacheManagerImpl : public CModelCacheManager virtual void OnClientClose(); virtual void UpdatePedModelCaching(const std::map& newNeedCacheList); virtual void UpdateVehicleModelCaching(const std::map& newNeedCacheList); - virtual void AddModelToPersistentCache(ushort usModelId); virtual void SetCustomLimits(std::optional numVehicles, std::optional numPeds); // CModelCacheManagerImpl methods @@ -72,7 +71,6 @@ class CModelCacheManagerImpl : public CModelCacheManager bool m_IsUsingCustomVehicleCacheLimit{}; //< If `true` the value is set by the scripter, otherwise is calculated in `DoPulse()` std::map m_PedModelCacheInfoMap{}; std::map m_VehicleModelCacheInfoMap{}; - std::set m_PermoLoadedModels{}; }; /////////////////////////////////////////////////////////////// @@ -266,22 +264,6 @@ void CModelCacheManagerImpl::DoPulse() } } -/////////////////////////////////////////////////////////////// -// -// CModelCacheManagerImpl::AddModelToPersistentCache -// -// Keep this model around 4 evar now -// -/////////////////////////////////////////////////////////////// -void CModelCacheManagerImpl::AddModelToPersistentCache(ushort usModelId) -{ - if (!MapContains(m_PermoLoadedModels, usModelId)) - { - AddModelRefCount(usModelId); - MapInsert(m_PermoLoadedModels, usModelId); - } -} - /////////////////////////////////////////////////////////////// // // CModelCacheManagerImpl::UpdatePedModelCaching @@ -542,13 +524,5 @@ void CModelCacheManagerImpl::OnRestreamModel(ushort usModelId) OutputDebugLine(SString("[Cache] End caching model %d (OnRestreamModel)", usModelId)); } } - } - - // Also check the permo list - if (MapContains(m_PermoLoadedModels, usModelId)) - { - SubModelRefCount(usModelId); - MapRemove(m_PermoLoadedModels, usModelId); - OutputDebugLine(SString("[Cache] End permo-caching model %d (OnRestreamModel)", usModelId)); - } + } } diff --git a/Client/core/CModelCacheManager.h b/Client/core/CModelCacheManager.h index ee54cbedfe..7d7952d0b5 100644 --- a/Client/core/CModelCacheManager.h +++ b/Client/core/CModelCacheManager.h @@ -24,7 +24,6 @@ class CModelCacheManager virtual void OnClientClose() = 0; virtual void UpdatePedModelCaching(const std::map& newNeedCacheList) = 0; virtual void UpdateVehicleModelCaching(const std::map& newNeedCacheList) = 0; - virtual void AddModelToPersistentCache(ushort usModelId) = 0; virtual void SetCustomLimits(std::optional numVehicles, std::optional numPeds) = 0; }; diff --git a/Client/game_sa/CPedSA.cpp b/Client/game_sa/CPedSA.cpp index 009e618e8c..1ae9f942f8 100644 --- a/Client/game_sa/CPedSA.cpp +++ b/Client/game_sa/CPedSA.cpp @@ -98,8 +98,12 @@ void CPedSA::Init() void CPedSA::SetModelIndex(DWORD dwModelIndex) { - DWORD dwFunction = FUNC_SetModelIndex; + // Delete any existing RwObject first + GetPedInterface()->DeleteRwObject(); + + // Set new model DWORD dwThis = (DWORD)GetInterface(); + DWORD dwFunction = FUNC_SetModelIndex; _asm { mov ecx, dwThis @@ -116,16 +120,6 @@ void CPedSA::SetModelIndex(DWORD dwModelIndex) } } -// Hacky thing done for the local player when changing model -void CPedSA::RemoveGeometryRef() -{ - RpClump* pClump = (RpClump*)GetInterface()->m_pRwObject; - RpAtomic* pAtomic = (RpAtomic*)((pClump->atomics.root.next) - 0x8); - RpGeometry* pGeometry = pAtomic->geometry; - if (pGeometry->refs > 1) - pGeometry->refs--; -} - bool CPedSA::IsInWater() { CTask* pTask = m_pPedIntelligence->GetTaskManager()->GetTask(TASK_PRIORITY_EVENT_RESPONSE_NONTEMP); diff --git a/Client/game_sa/CPedSA.h b/Client/game_sa/CPedSA.h index daae468472..fee84fd651 100644 --- a/Client/game_sa/CPedSA.h +++ b/Client/game_sa/CPedSA.h @@ -295,7 +295,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA CPedSAInterface* GetPedInterface() { return (CPedSAInterface*)GetInterface(); } void Init(); void SetModelIndex(DWORD dwModelIndex); - void RemoveGeometryRef(); void AttachPedToEntity(DWORD dwEntityInterface, CVector* vector, unsigned short sDirection, float fRotationLimit, eWeaponType weaponType, bool bChangeCamera); void DetachPedFromEntity(); diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 81faab7efd..5716bea120 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -3927,22 +3927,7 @@ void CClientPed::_ChangeModel() // So make sure clothes geometry is built now... m_pClothes->AddAllToModel(); m_pPlayerPed->RebuildPlayer(); - - // ...and decrement the extra ref - #ifdef NO_CRASH_FIX_TEST2 - m_pPlayerPed->RemoveGeometryRef(); - #endif - } - else - { - // When the local player changes to another (non CJ) model, the geometry gets an extra ref from somewhere, causing a memory leak. - // So decrement the extra ref here - #ifdef NO_CRASH_FIX_TEST - m_pPlayerPed->RemoveGeometryRef(); - #endif - // As we will have problem removing the geometry later, we might as well keep the model cached until exit - g_pCore->AddModelToPersistentCache((ushort)m_ulModel); - } + } // Remove reference to the old model we used (Flag extra GTA reference to be removed as well) pLoadedModel->RemoveRef(true); diff --git a/Client/sdk/core/CCoreInterface.h b/Client/sdk/core/CCoreInterface.h index aea1ca9054..c591d546e5 100644 --- a/Client/sdk/core/CCoreInterface.h +++ b/Client/sdk/core/CCoreInterface.h @@ -160,7 +160,6 @@ class CCoreInterface virtual EDiagnosticDebugType GetDiagnosticDebug() = 0; virtual void SetDiagnosticDebug(EDiagnosticDebugType value) = 0; virtual CModelCacheManager* GetModelCacheManager() = 0; - virtual void AddModelToPersistentCache(ushort usModelId) = 0; virtual void UpdateDummyProgress(int iValue = -1, const char* szType = "") = 0; virtual void SetDummyProgressUpdateAlways(bool bAlways) = 0; diff --git a/Client/sdk/game/CPed.h b/Client/sdk/game/CPed.h index 29bbf60104..4e91cdb8b4 100644 --- a/Client/sdk/game/CPed.h +++ b/Client/sdk/game/CPed.h @@ -191,7 +191,6 @@ class CPed : public virtual CPhysical virtual void Respawn(CVector* position, bool bCameraCut) = 0; virtual void SetModelIndex(unsigned long ulModel) = 0; - virtual void RemoveGeometryRef() = 0; virtual float GetHealth() = 0; virtual void SetHealth(float fHealth) = 0;