SRL Archive - Bugs

GroundItems still lags script


Narcle

2010-11-04 01:30:24

Using my current Echo Fighter (its in members scripts) when I use GroundItems after some time it still lags the script. Mouse speed is about halved, even when you stop and start the script back up its still slow. The only way to stop it is to restart Simba completely. I'm pretty positive there are no leaks in my PickUp function, I don't use global variables for it etc.

I'll get some recorded game play when I get a chance to show everyone.

Naike

2010-11-04 09:16:39

That's because we don't free all the memory..

As if we do, SMART will end up crashing.. I got so annoyed last time, I stopped trying!

One of the SmartFreeObject tries to free something that it shouldn't at RANDOM times.

function GetItemNodeList(ID: Integer; Info: TCacheInfo): integer;
var
Node, NextNode, D2NextNode, NodeID, i, index: integer;
F: Boolean;
begin
F := true;
Result := 0;
try
Index := ID and (Info.NLength - 1);
Node := SmartGetFieldArrayObject(Info.Nodes, '', Index);

for i := Index downto Index-10 do
begin
if not F then
begin
Node := SmartGetFieldObject(D2NextNode, hook_node_next);
// SmartFreeObject(D2NextNode);
end else
F := false;
NodeID := SmartGetFieldLongL(Node, hook_node_GetID);

if(NodeID = ID)then
begin
Result := SmartGetFieldObject(Node, hook_nodelistcache_GetNodeList);
Break;
end;

NextNode := SmartGetFieldObject(Node, hook_node_Previous);
// SmartFreeObject(Node);
D2NextNode := SmartGetFieldObject(NextNode, hook_node_Previous);
// SmartFreeObject(NextNode);
end;
finally
SmartFreeObject(Node);
SmartFreeObject(NextNode);
SmartFreeObject(D2NextNode);
end;
end;

Wizzup?

2010-11-04 11:10:11

You're probably freeing the wrong objects then. Only freeing faulty objects results in those errors. You could ask Ben to implement a feature to find out if the memory you want to free is allocated by SMART.

Cstrike

2010-11-04 12:33:49

Just for my 2 cents, if Ben could also look up why searching blank interfaces crashes that'd be awesome.

Naike

2010-11-04 16:19:58

Error located.
Think I got something to fix that, but I'll need to talk to ben before I release anything!

Error is that the Node jumps extremely high at random times!


NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203999104
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203999088
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203999088
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203999084
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203999080
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998076
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998068
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998064
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998060
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998056
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998052
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998048
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998044
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203998028
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998028
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998024
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998020
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998016
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998012
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998008
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998004
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203998000
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997996
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997992
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997988
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203997972
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997972
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997968
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997964
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997960
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997956
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203997952
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569476
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569472
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569468
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569464
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569460
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203569444
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569444
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569440
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569436
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569432
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569428
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569424
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569420
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569416
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569412
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569408
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569404
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203569380
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569380
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569376
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569372
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569368
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569364
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569360
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569356
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203569352
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566588
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566584
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566580
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203566564
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566564
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566560
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566556
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566552
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566548
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566544
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566540
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566536
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566532
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566528
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566524
FRREEEENODE
Node := SmartGetFieldArrayObject(Info.Nodes)
203566500
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566500
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566496
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=203566492
FRREEEENODE
NodeID := SmartGetFieldLongL(Node
NextNode := SmartGetFieldObject(Node
Node=867565608
FATAL ERROR in native method: Bad global or local ref passed to JNI

D:\Simba>

Method

2010-11-04 22:45:05

Here's what I wrote tonight. It was working for me when I tested it, but I haven't done much more than grabbing the items on a particular tile. I've tried to document the code where possible to help you guys follow the logic.

Also, the item id/stack hooks are reversed.

function GetGroundItems(tile: TTile): TGroundItemArray;
var
cache, hash, plane, nodes, size, index, tail, cur, next,
uid, list, id, stack: Integer;
begin
// grab the cache and calculate the tile's hash
cache := SmartGetFieldObject(0, hook_static_GroundItemCache);
plane := SmartGetFieldInt(0, hook_static_LoadedPlane);
hash := tile.x or (tile.y shl 14) or (plane shl 28);

// grab the nodes array and get the index where our item list
// should be, if it exists
nodes := SmartGetFieldObject(cache, hook_nodecache_GetNodes);
size := SmartGetFieldArraySize(nodes, '', 1);
index := hash and (size - 1);
SmartFreeObject(cache);

// get the dummy tail node of the current list and its successor
// for use in the next loop
tail := SmartGetFieldArrayObject(nodes, '', index);
cur := SmartGetFieldObject(tail, hook_node_Next);
SmartFreeObject(nodes);

// loop until we come back to the dummy tail node
// (the list is circular)
while (not (SmartIsEqual(tail, cur))) do
begin
uid := SmartGetFieldLongL(cur, hook_node_GetID);
if (uid = hash) then
begin
// if we have matching uids, grab the list and break
list := SmartGetFieldObject(cur, hook_nodelistcache_GetNodeList);
break;
end;

// otherwise, update our node
next := SmartGetFieldObject(cur, hook_node_Next);
SmartFreeObject(cur);
cur := next;
end;

// free objects we're finished with
SmartFreeObject(cur);
SmartFreeObject(tail);

// if we didn't find our list, there are no ground items on
// this tile
if (list = 0) then
Exit;

// grab pointers for the new list
tail := SmartGetFieldObject(list, hook_nodelist_Head);
cur := SmartGetFieldObject(tail, hook_node_Next);

while (not (SmartIsEqual(tail, cur))) do
begin
// create a new ground item
SetArrayLength(Result, GetArrayLength(Result) + 1);
id := SmartGetFieldInt(cur, hook_item_GetID);
stack := SmartGetFieldInt(cur, hook_item_GetStack);
Result[High(Result)] := NewGroundItem(id, stack, tile);

// update our pointers
next := SmartGetFieldObject(cur, hook_node_Next);
SmartFreeObject(cur);
cur := next;
end;

// free remaining objects
SmartFreeObject(cur);
SmartFreeObject(tail);
SmartFreeObject(list);
end;

mormonman

2010-11-04 23:34:46

So each tile has a specific hash and uid?

Method

2010-11-05 00:49:29

From: mormonman
So each tile has a specific hash and uid?


Yes, each tile has a unique hash. That value is also stored in the field that is a long inside of the Node class (called ID in the Hooks file).

mormonman

2010-11-05 01:49:37

From: Method
Yes, each tile has a unique hash. That value is also stored in the field that is a long inside of the Node class (called ID in the Hooks file).


So why did drags do his the other way? Did he just not understand grounditems enough?

Method

2010-11-05 09:45:25

From: mormonman
So why did drags do his the other way? Did he just not understand grounditems enough?


It was the same in his function, but he named it "ID". However, I do suspect that a lack of knowledge about the client was the cause of the problems we saw with the ground items. Hopefully the function I posted will work without the slowdowns.

Cstrike

2010-11-05 13:50:50

reflection\./Core/GroundItems.simba(61:95): Unknown identifier 'SmartIsEqual' at line 60

nielskool

2010-11-05 14:07:27

same here

Naike

2010-11-05 14:11:32

Read the updater log.

New version of smart, replace it it with the new one in the "place inside plugin folder".

nielskool

2010-11-05 14:48:29

extension of simba should do it. i don't have a map "place inside plugin folder".
if i update reflection manual, it works just fine.

Cstrike

2010-11-05 15:20:17

From: nielskool
extension of simba should do it. i don't have a map "place inside plugin folder".
if i update reflection manual, it works just fine.


Did you use the Reflection SVN or the SRL SVN or some other method? I'm trying to get my reflection working again so I can whore out randoms but I'm currently still getting the error even after ref. updating and checking the SVN.