Revisited aggressive object freeing

This commit is contained in:
Silent 2018-04-26 00:15:36 +02:00
parent ed397348d1
commit c1ad23ed22
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1

View file

@ -5,6 +5,8 @@
#include "ModelInfoSA.h"
#include "PoolsSA.h"
#include <algorithm>
// Wrappers
static void* EntityRender = AddressByVersion<void*>(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 );
}
}