From 52a3c9932fc22dc5e13dff4c990816a7c4e98578 Mon Sep 17 00:00:00 2001 From: Miran Date: Mon, 2 Dec 2024 03:26:17 +0100 Subject: [PATCH] Fixed performance of example script. --- examples/Limits_Info.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/Limits_Info.txt b/examples/Limits_Info.txt index c05f50c9..18480e57 100644 --- a/examples/Limits_Info.txt +++ b/examples/Limits_Info.txt @@ -5,6 +5,12 @@ script_name {name} "lim_info" +// In case if limits adjuster is used pools can have really big sizes. +// Going throught all elements can really create performance hit +// Proper solution would be to put some wait in pools processing loops and store results in variables, +// then during every frame draw info stored in variables +const Pool_Size_Cap = 1111 // walk around, just do not parse all contents of bigger pools + int active = false while true @@ -135,12 +141,22 @@ function GET_POOL_INFO(address :int) : int, int int size = read_memory_with_offset {address} pool {offset} 0x8 {size} 4 // CPool::m_nSize + // for performance reasons do not iterate through all elements of realy big pools + int processSize + if + size < Pool_Size_Cap + then + processSize = size + else + processSize = Pool_Size_Cap + end + // count empty slots int byteMap = read_memory_with_offset {address} pool {offset} 0x4 {size} 4 // CPool::m_byteMap int count = 0 int i = 0 - while i < size + while i < processSize int flags = read_memory_with_offset {address} byteMap {offset} i {size} 1 // tPoolObjectFlags if not is_local_var_bit_set_const {number} flags {n} 7 // tPoolObjectFlags::bEmpty