Skip to content

Commit

Permalink
Fixed performance of example script.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Dec 2, 2024
1 parent 07ae82a commit 52a3c99
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion examples/Limits_Info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 52a3c99

Please sign in to comment.