From c1ad23ed22cd107a1cda366e84d7e01581676aac Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 26 Apr 2018 00:15:36 +0200 Subject: [PATCH] Revisited aggressive object freeing --- SilentPatchSA/GeneralSA.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SilentPatchSA/GeneralSA.cpp b/SilentPatchSA/GeneralSA.cpp index d53d4e1..3392c86 100644 --- a/SilentPatchSA/GeneralSA.cpp +++ b/SilentPatchSA/GeneralSA.cpp @@ -5,6 +5,8 @@ #include "ModelInfoSA.h" #include "PoolsSA.h" +#include + // Wrappers static void* EntityRender = AddressByVersion(0x534310, 0x5347B0, 0x545B30); WRAPPER void CEntity::Render() { VARJMP(EntityRender); } @@ -105,9 +107,9 @@ extern void (*WorldRemove)(CEntity*); void CObject::TryToFreeUpTempObjects_SilentPatch( int numObjects ) { const auto [ numProcessed, numFreed ] = TryOrFreeUpTempObjects( numObjects, false ); - if ( numProcessed >= numObjects && numObjects > numFreed ) + if ( numFreed < numObjects ) { - TryOrFreeUpTempObjects( numObjects - numFreed, true ); + TryOrFreeUpTempObjects( std::min(numProcessed, numObjects - numFreed), true ); } }