SRL Archive - OSR Help

What am I doing wrong here? [Freeing Bitmaps]


Pew

2012-12-29 07:06:20

Heya and thanks for the help in advance.

Got a basic script working but whenever I terminate it I am left with a massive list of bitmaps that haven't been freed. The list gets longer the longer I leave it running (so the more loops) and obviously this is not a good thing.

Too save opening another thread if anyone could suggest a better dropping method I could look into it would be much appreciated as this one seems rather slow.

program new;
{$define srl5}
{$loadlib sps}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
full:boolean;

Procedure StartFishing;
begin
Mouse(290, 150, 13, 13, True);
Wait(1000)

End;

Procedure DropInventory;
var
trout, salmon, dropsalmon, droptrout, x, y, x2, y2:Integer;
Begin;
repeat
salmon := BitmapFromString(22, 8, 'meJxjYMAOGBkYgkMzEpIrzWzirJ0' +
'y7D0K3QNqvENbA6J6QuKnRCTPiUqdl16yZeGyQ7i0A5GJZbSlY6qd' +
'e56LT7lHYL1PeEdw7KTQhOlAvXGZS4Ha86oPMeLQDrHXybMUbi9EL' +
'9Dq6PQFiXlrsqv2lracA6pUUDDA1I5sr39EV2B0P9xeoN604k051f' +
'vh2pFNgLgcaDVQL9y/cHvjs5enFmzMLN+ZX3sYl3aIvZ7BTUC9QI1' +
'AXbEZi4D2AvUCrQb6Gmh1SdOZirZLWLVDvAwMK6Cbw5NmAvUm5KxK' +
'yl8HdHNG6fasit0FdUeB2qs6sWt39asCOhuuF2Ij0MFAjUB7gc4ur' +
'D+OSzsQAADvfpLV');

trout := BitmapFromString(30, 26, 'meJytle1OGkEUhuVOvITejH9sot' +
'bEWj9qbay1dv2sWivWWqxVY0UjGlQsLQQiFQMEi5ISIBQJEKIkGE1' +
'6GX3ak2w24o8dwmZ+TDYzz77nPe/MNjTU7bHUD3UHOzW1UHc4wPEJ' +
'69zcJyaNjQ/qiB0de6djayDfWykvtZG3+DD/frU2weza2/dZql4OD' +
'0+KD4sf12sgs2XDvi9kfS/zoaFxfJiZWUTw0pLd8v+lUhNZbLNtOB' +
'zfhawTenpeDAxouAHc6fSuf3Gi3HxCWMbG5eWt3V2PADs6eoWJFWi' +
'enbUB9PvD8mnzfRQzcXJ1baet7UlnZ1/fs1f4II2zWj9TTjT66ygQ' +
'0ZkmscgD0tz8qL29u/fpy8HBUfF24cMahaysOL66A+l0TilyUlpT0' +
'8OW1sddXf39z19r2vTkm3nRSQm01XV4dBw8VcWiE0vRKRnATzIAE5' +
'00C1fxNh5Pq2KxFJ3/Wq9N636i077pgnng8gd+RM/OU0r9ku7D5Ai' +
'gEz9hYik6t7fdpNrjCQZPYqpYY0TJEiIBohMmqaNZZCAWSyYSGSUs' +
'cSJg0iPOlJjJEaBN7m/HPl8oFDo7/ZlQxUqcyC21CxOFXu8JbcJSy' +
'g+Hz8Emk1klrIgkRZSMPEqOROIAEckpwFJ0EtrsRVE1CQQJJ4mZMO' +
'GgUJho1ofqDcx6qR2R0Kg3k8nTJrLKvJpsHivlIxKFqdTF72yhULh' +
'EtsyNZIGbJ9MdFGIjnHy+VCqVy+VrZOdyJf3CZKjKZiVShVMsXl1e' +
'VSqVm9vbP3zCeHfp17Kqz/eOakgNP1CjNuNQgtx5/gKCIdSE');

dropsalmon := BitmapFromString(108, 15, 'meJztlEsOgDAIRDmaR/TGdacEC' +
'oxB/EQmLpDUKbxWxjhEZVrWwZ+6jZAyLrfd6ZVi5MU/iLGaIVVibI' +
'Z5/ZMhG5NDLNaorbwuXncxnZP+q/W5/gSxtQZ1aLvnQ4YCFB6H9ZB' +
'9P0GGSD6Mp+frx2I9TqOCIRkny+t0WDnOvm2SoYjvZKhphMftwLe2' +
'OBt/juGpmLf2fob+9BPJ6UqdRxokdeV4fhpr24p/WTggjWTkoGuBa' +
'oZ5NcO8mmErrw0OOxCU');

droptrout := BitmapFromString(96, 15, 'meJztllEOgCAMQzmaR/TG+KcL3b' +
'qRsGhwjR84oR0vhNj7o5am4+zyyQtarptMKiKJZSGiDNqDp8SSh6j' +
'4xEP34COupXEyYrTqGIo7Uu8l/krWEjfiSRxcPkGSOHYhuE0G+ahB' +
'UxEkOr7TDD7DJ2zSOnWcj1X5OB9Mjxxy8lewH5+psUT6Lh9+26iTX' +
'YdIkw2OiqyrY9XZMseIqboVOiWCpdSKj6fiw1V8/qwLk9O7hA==');

If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15);
Mouse(x2, y2, 3, 3, True);
FreeBitmap(trout);
FreeBitmap(droptrout);
wait(1000 + Random(100));
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 546, 184, 753, 453, 15)) then
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(dropsalmon, x2, y2, 546, 184, 753, 453, 15);
Mouse(x2, y2, 3, 3, True);
FreeBitmap(salmon);
FreeBitmap(dropsalmon);
wait(1000 + Random(100));
end else
begin
Startfishing;
Full := False
end;
end;
until(Full = False)
end;



Procedure CheckFull;
var
trout, salmon, x, y:Integer;
Begin
repeat
salmon := BitmapFromString(22, 8, 'meJxjYMAOGBkYgkMzEpIrzWzirJ0' +
'y7D0K3QNqvENbA6J6QuKnRCTPiUqdl16yZeGyQ7i0A5GJZbSlY6qd' +
'e56LT7lHYL1PeEdw7KTQhOlAvXGZS4Ha86oPMeLQDrHXybMUbi9EL' +
'9Dq6PQFiXlrsqv2lracA6pUUDDA1I5sr39EV2B0P9xeoN604k051f' +
'vh2pFNgLgcaDVQL9y/cHvjs5enFmzMLN+ZX3sYl3aIvZ7BTUC9QI1' +
'AXbEZi4D2AvUCrQb6Gmh1SdOZirZLWLVDvAwMK6Cbw5NmAvUm5KxK' +
'yl8HdHNG6fasit0FdUeB2qs6sWt39asCOhuuF2Ij0MFAjUB7gc4ur' +
'D+OSzsQAADvfpLV');

trout := BitmapFromString(30, 26, 'meJytle1OGkEUhuVOvITejH9sot' +
'bEWj9qbay1dv2sWivWWqxVY0UjGlQsLQQiFQMEi5ISIBQJEKIkGE1' +
'6GX3ak2w24o8dwmZ+TDYzz77nPe/MNjTU7bHUD3UHOzW1UHc4wPEJ' +
'69zcJyaNjQ/qiB0de6djayDfWykvtZG3+DD/frU2weza2/dZql4OD' +
'0+KD4sf12sgs2XDvi9kfS/zoaFxfJiZWUTw0pLd8v+lUhNZbLNtOB' +
'zfhawTenpeDAxouAHc6fSuf3Gi3HxCWMbG5eWt3V2PADs6eoWJFWi' +
'enbUB9PvD8mnzfRQzcXJ1baet7UlnZ1/fs1f4II2zWj9TTjT66ygQ' +
'0ZkmscgD0tz8qL29u/fpy8HBUfF24cMahaysOL66A+l0TilyUlpT0' +
'8OW1sddXf39z19r2vTkm3nRSQm01XV4dBw8VcWiE0vRKRnATzIAE5' +
'00C1fxNh5Pq2KxFJ3/Wq9N636i077pgnng8gd+RM/OU0r9ku7D5Ai' +
'gEz9hYik6t7fdpNrjCQZPYqpYY0TJEiIBohMmqaNZZCAWSyYSGSUs' +
'cSJg0iPOlJjJEaBN7m/HPl8oFDo7/ZlQxUqcyC21CxOFXu8JbcJSy' +
'g+Hz8Emk1klrIgkRZSMPEqOROIAEckpwFJ0EtrsRVE1CQQJJ4mZMO' +
'GgUJho1ofqDcx6qR2R0Kg3k8nTJrLKvJpsHivlIxKFqdTF72yhULh' +
'EtsyNZIGbJ9MdFGIjnHy+VCqVy+VrZOdyJf3CZKjKZiVShVMsXl1e' +
'VSqVm9vbP3zCeHfp17Kqz/eOakgNP1CjNuNQgtx5/gKCIdSE');
wait(10000 + Random(1000));
If (FindBitmapToleranceIn(trout, x, y, 690, 405, 737, 444, 15)) then
begin
FreeBitmap(trout);
Full := True
DropInventory;
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 690, 405, 737, 444, 15)) then
begin
FreeBitmap(salmon);
Full := True
DropInventory;
end;
end;
until(Full = True)
end;



begin
SetupSRL;
StartFishing;
CheckFull;
end.

Laimonas171

2012-12-29 07:09:43

Alot of things you can make easier for your self. give me few minutes.

EDIT:

bitmaps should be small, to reduce memory useage example

Bitmaps

//make it small as possible, though they should be not to small to mix with other bitmaps. which may fail script.
Silver := BitmapFromString(7, 2, 'meJwTa1wshopkl1/m9YpFEwEiAGnl' +
'Eb4=');

Drop method.

instead of

If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then //search item
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15); //search bitmap drop text.
Mouse(x2, y2, 3, 3, True);
FreeBitmap(trout);
FreeBitmap(droptrout);
wait(1000 + Random(100));
end

you can do easier.

   
{* make note it's better to use these, then your own coords (unless you know you need too.)
MSX1, MSY1, MSX2, MSY2 <-- main screen coordinates
MIX1, MIY1, MIX2, MIY2 < -- inventory coords.
MCX1, MCY1, MCX2, MCY2 < -- Chat
MMX1, MMY1, MMX2, MMY2 << Minimap
*}

If(FindBitmapToleranceIn(trout, x, y, MSX1, MSY1, MSX2, MSY2, 15)) then
begin
mouse(x, y, 5, 5, false);
wait(200+random(150));
WaitOption('Drop', 500);
end;

not sure about your "FULL" checking. though
here is boolean InvFull. which returns true if inventory is full and false if here is at least one free space.

etc.


repeat
Fishing;
until(InvFull = true)
//it will fish until inventory will be full then you can write down drop.
Dropall; //<drops everything from inventory
//but you probably would be more interested to DropAllExcept(dontdrop: TintegerArrat); < basically you can say what slot leave alone. like dont drop 1 etc.

Pew

2012-12-29 07:50:39

Last time I tried using the preset commands they didn't work as this is a private server and the stuff I tried to use last time was all for modern rs and wouldn't work. I'll go give these a try but and post an update.

Laimonas171

2012-12-29 07:55:00

From: Pew
Last time I tried using the preset commands they didn't work as this is a private server and the stuff I tried to use last time was all for modern rs and wouldn't work. I'll go give these a try but and post an update.


All things i wrote down works well though i use in my own scripts

Pew

2012-12-29 07:56:03

Awesome! And with smallest bitmap possible you mean recreate them from scratch?

-edit* and I still don't think it's freeing the bitmaps correctly.

Laimonas171

2012-12-29 07:59:24

From: Pew
Awesome! And with smallest bitmap possible you mean recreate them from scratch?


Yeah kinda, not necessary though.. but it's better to use. let me give you example.

instead of
(26x19)

you can use this one

(6x6)

of course you may need testing, but it will run script smoother.

edit: and make sure no other items has quite the same bitmap colors at inv. at the moment. etc if you take ore dark (not main color) …
example.
gold ore has yellow as main color but if you make bitmap from grey/brown < whatever… most of ores has the same color so your bitmap fail (or be universal) depending on what you want to do though


edit:
From: Pew
Awesome! And with smallest bitmap possible you mean recreate them from scratch?

-edit* and I still don't think it's freeing the bitmaps correctly.


i didn't free'ed


edit2:


If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then //search item 
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15); //search bitmap drop text.
Mouse(x2, y2, 3, 3, True);
FreeBitmap(trout);
FreeBitmap(droptrout);
wait(1000 + Random(100));
end

your code, since you free then inside you "If (FindBitmapToleranceIn…." that means if script not finds bitmap he leave it unfreed there for you should free them after you searh for them example:
If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then //search item 
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15); //search bitmap drop text.
Mouse(x2, y2, 3, 3, True);

wait(1000 + Random(100));
end;//here ends your "if find" so if he do not finds he going to continue running and there for you can free them after. it will work fine at this case
FreeBitmap(trout);
FreeBitmap(droptrout);

Pew

2012-12-29 08:09:51

Sadly the preset drop commands etc do not work. Unlike on some of the other servers this is the client/graphics from 06 so it looks like I'm going to have to code everything from scratch.

Pew

2012-12-29 09:05:02

Using my original script with updated bitmaps I still cannot get freeing bitmaps correct..
Is there no way of simply saying free all used bitmaps at the end of each loop?

-edit Updated code and debug.
It's all those unfreed bitmaps at the end that have me stumped because as far as I can see it frees all that it uses?



My code:
program new;
{$define srl5}
{$loadlib sps}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
full:boolean;

Procedure StartFishing;
begin
Mouse(290, 150, 13, 13, True);
Wait(1000)

End;

Procedure DropInventory;
var
trout, salmon, dropsalmon, droptrout, x, y, x2, y2:Integer;
Begin;
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');

dropsalmon := BitmapFromString(108, 15, 'meJztlEsOgDAIRDmaR/TGdacEC' +
'oxB/EQmLpDUKbxWxjhEZVrWwZ+6jZAyLrfd6ZVi5MU/iLGaIVVibI' +
'Z5/ZMhG5NDLNaorbwuXncxnZP+q/W5/gSxtQZ1aLvnQ4YCFB6H9ZB' +
'9P0GGSD6Mp+frx2I9TqOCIRkny+t0WDnOvm2SoYjvZKhphMftwLe2' +
'OBt/juGpmLf2fob+9BPJ6UqdRxokdeV4fhpr24p/WTggjWTkoGuBa' +
'oZ5NcO8mmErrw0OOxCU');

droptrout := BitmapFromString(96, 15, 'meJztllEOgCAMQzmaR/TG+KcL3b' +
'qRsGhwjR84oR0vhNj7o5am4+zyyQtarptMKiKJZSGiDNqDp8SSh6j' +
'4xEP34COupXEyYrTqGIo7Uu8l/krWEjfiSRxcPkGSOHYhuE0G+ahB' +
'UxEkOr7TDD7DJ2zSOnWcj1X5OB9Mjxxy8lewH5+psUT6Lh9+26iTX' +
'YdIkw2OiqyrY9XZMseIqboVOiWCpdSKj6fiw1V8/qwLk9O7hA==');

If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15);
Mouse(x2, y2, 3, 3, True);
wait(1000 + Random(100));
FreeBitmap(trout);
FreeBitmap(droptrout);
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 546, 184, 753, 453, 15)) then
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(dropsalmon, x2, y2, 546, 184, 753, 453, 15);
Mouse(x2, y2, 3, 3, True);
wait(1000 + Random(100));
FreeBitmap(salmon);
FreeBitmap(dropsalmon);
end else
begin
Startfishing;
Full := False
end;
end;
until(Full = False)
end;



Procedure CheckFull;
var
trout, salmon, x, y:Integer;
Begin
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');

wait(10000 + Random(1000));
If (FindBitmapToleranceIn(trout, x, y, 690, 405, 737, 444, 15)) then
begin
FreeBitmap(trout);
Full := True
DropInventory;
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 690, 405, 737, 444, 15)) then
begin
FreeBitmap(salmon)
Full := True
DropInventory;
end;
end;
until(Full = True)
end;

Debug:
SRL Compiled in 0 msec
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap, 5, 7, 11, 15, 19, 23, 27, 31, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]

Laimonas171

2012-12-29 09:22:35

From: Pew
Using my original script with updated bitmaps I still cannot get freeing bitmaps correct..
Is there no way of simply saying free all used bitmaps at the end of each loop?

My code:
program new;
{$define srl5}
{$loadlib sps}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
full:boolean;

Procedure StartFishing;
begin
Mouse(290, 150, 13, 13, True);
Wait(1000)

End;

Procedure DropInventory;
var
trout, salmon, dropsalmon, droptrout, x, y, x2, y2:Integer;
Begin;
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');

dropsalmon := BitmapFromString(108, 15, 'meJztlEsOgDAIRDmaR/TGdacEC' +
'oxB/EQmLpDUKbxWxjhEZVrWwZ+6jZAyLrfd6ZVi5MU/iLGaIVVibI' +
'Z5/ZMhG5NDLNaorbwuXncxnZP+q/W5/gSxtQZ1aLvnQ4YCFB6H9ZB' +
'9P0GGSD6Mp+frx2I9TqOCIRkny+t0WDnOvm2SoYjvZKhphMftwLe2' +
'OBt/juGpmLf2fob+9BPJ6UqdRxokdeV4fhpr24p/WTggjWTkoGuBa' +
'oZ5NcO8mmErrw0OOxCU');

droptrout := BitmapFromString(96, 15, 'meJztllEOgCAMQzmaR/TG+KcL3b' +
'qRsGhwjR84oR0vhNj7o5am4+zyyQtarptMKiKJZSGiDNqDp8SSh6j' +
'4xEP34COupXEyYrTqGIo7Uu8l/krWEjfiSRxcPkGSOHYhuE0G+ahB' +
'UxEkOr7TDD7DJ2zSOnWcj1X5OB9Mjxxy8lewH5+psUT6Lh9+26iTX' +
'YdIkw2OiqyrY9XZMseIqboVOiWCpdSKj6fiw1V8/qwLk9O7hA==');

If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15);
Mouse(x2, y2, 3, 3, True);
wait(1000 + Random(100));
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 546, 184, 753, 453, 15)) then
begin
Mouse(x, y, 3, 3, False);
wait(10)
FindBitmapToleranceIn(dropsalmon, x2, y2, 546, 184, 753, 453, 15);
Mouse(x2, y2, 3, 3, True);
wait(1000 + Random(100));
end else
begin
Startfishing;
Full := False
end;
FreeBitmap(trout);
FreeBitmap(droptrout);
FreeBitmap(salmon);
FreeBitmap(dropsalmon);
end;
until(Full = False)
end;



Procedure CheckFull;
var
trout, salmon, x, y:Integer;
Begin
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');

wait(10000 + Random(1000));
If (FindBitmapToleranceIn(trout, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True
DropInventory;
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True
DropInventory;
end;
FreeBitmap(trout);
FreeBitmap(salmon);
end;
until(Full = True)
end;



begin
ClearDebug;
SetupSRL;
StartFishing;
CheckFull;
end.

Debug:
SRL Compiled in 0 msec
Error: Exception: The bitmap[6] does not exist at line 101
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap, 5]


ignore that output :?

Pew

2012-12-29 09:27:55

From: Laimonas171
ignore that output :?



With that output it would not run.
Error: Exception: The bitmap[6] does not exist at line 101


When I updated the code to what it is now ^^It leaves me with all those unfreed bitmaps after just 1 loop and it starts to slow down considerably as time goes on.



edit - Something is going wrong somewhere in my loop as this is what I get after letting it do 2/3 loads. That doesn't look good hahaah.
SRL Compiled in 0 msec
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204]

Pew

2012-12-29 14:28:05

I am going crazy here. If anyone could help me I cannot even explain how much of a help you would be. I've tried rewriting it so many ways but I'm still getting god damn bitmaps not freed!

program new;
{$define srl5}
{$loadlib sps}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
full:boolean;
trout, salmon, dropsalmon, droptrout:Integer;

Procedure RiverTroll;
var
x, y:Integer;
begin
If FindcolorTolerance(x, y, 7966560, 0, 0, 511, 334, 5) then
Mouse(584, 61, 5, 5, true);
wait(15000 + random (1000));
Mouse(636, 474, 10, 10, true);
Wait(100);
Mouse(639, 346, 3, 40, true);
wait(10);
WriteLn('River Troll Detected! -logging out');
end;

Procedure StartFishing;
begin
Mouse(290, 150, 13, 13, True);
Wait(1000)

End;

Procedure DropInventory;
var
trout, salmon, dropsalmon, droptrout, x, y, x2, y2:Integer;
Begin;
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');

dropsalmon := BitmapFromString(108, 15, 'meJztlEsOgDAIRDmaR/TGdacEC' +
'oxB/EQmLpDUKbxWxjhEZVrWwZ+6jZAyLrfd6ZVi5MU/iLGaIVVibI' +
'Z5/ZMhG5NDLNaorbwuXncxnZP+q/W5/gSxtQZ1aLvnQ4YCFB6H9ZB' +
'9P0GGSD6Mp+frx2I9TqOCIRkny+t0WDnOvm2SoYjvZKhphMftwLe2' +
'OBt/juGpmLf2fob+9BPJ6UqdRxokdeV4fhpr24p/WTggjWTkoGuBa' +
'oZ5NcO8mmErrw0OOxCU');

droptrout := BitmapFromString(96, 15, 'meJztllEOgCAMQzmaR/TG+KcL3b' +
'qRsGhwjR84oR0vhNj7o5am4+zyyQtarptMKiKJZSGiDNqDp8SSh6j' +
'4xEP34COupXEyYrTqGIo7Uu8l/krWEjfiSRxcPkGSOHYhuE0G+ahB' +
'UxEkOr7TDD7DJ2zSOnWcj1X5OB9Mjxxy8lewH5+psUT6Lh9+26iTX' +
'YdIkw2OiqyrY9XZMseIqboVOiWCpdSKj6fiw1V8/qwLk9O7hA==');

If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then
begin
wait(10);
Mouse(x, y, 3, 3, False);
wait(10);
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15);
wait(10);
Mouse(x2, y2, 50, 3, True);
wait(1000 + Random(100));
end else
begin
wait(10);
If (FindBitmapToleranceIn(salmon, x, y, 546, 184, 753, 453, 15)) then
begin
wait(10);
Mouse(x, y, 3, 3, False);
wait(10);
FindBitmapToleranceIn(dropsalmon, x2, y2, 546, 184, 753, 453, 15);
wait(10);
Mouse(x2, y2, 50, 3, True);
wait(1000 + Random(100));
end else
begin
Full := False
end;
FreeBitmap(salmon);
FreeBitmap(dropsalmon);
FreeBitmap(trout);
FreeBitmap(droptrout);
end;
until(Full = False)
end;



Procedure CheckFull;
var
trout, salmon, x, y:Integer;
Begin
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');


If (FindBitmapToleranceIn(trout, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True
DropInventory;
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True
DropInventory;
end;
FreeBitmap(salmon);
FreeBitmap(trout);
wait(10000 + Random(1000));
end;
until(Full = True)
end;

Procedure Randoms;
begin
If(Full = False) then
repeat
Rivertroll;
Wait (5000 + random(7000));
until(Full = True)
end;



begin
ClearDebug;
SetupSRL;
StartFishing;
CheckFull;
Randoms;
end.

rj

2012-12-30 14:00:03

From: Pew
I am going crazy here. If anyone could help me I cannot even explain how much of a help you would be. I've tried rewriting it so many ways but I'm still getting god damn bitmaps not freed!

program new;
{$define srl5}
{$loadlib sps}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
full:boolean;
trout, salmon, dropsalmon, droptrout:Integer;

Procedure RiverTroll;
var
x, y:Integer;
begin
If FindcolorTolerance(x, y, 7966560, 0, 0, 511, 334, 5) then
Mouse(584, 61, 5, 5, true);
wait(15000 + random (1000));
Mouse(636, 474, 10, 10, true);
Wait(100);
Mouse(639, 346, 3, 40, true);
wait(10);
WriteLn('River Troll Detected! -logging out');
end;

Procedure StartFishing;
begin
Mouse(290, 150, 13, 13, True);
Wait(1000)

End;

Procedure DropInventory;
var
trout, salmon, dropsalmon, droptrout, x, y, x2, y2:Integer;
Begin;
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');

dropsalmon := BitmapFromString(108, 15, 'meJztlEsOgDAIRDmaR/TGdacEC' +
'oxB/EQmLpDUKbxWxjhEZVrWwZ+6jZAyLrfd6ZVi5MU/iLGaIVVibI' +
'Z5/ZMhG5NDLNaorbwuXncxnZP+q/W5/gSxtQZ1aLvnQ4YCFB6H9ZB' +
'9P0GGSD6Mp+frx2I9TqOCIRkny+t0WDnOvm2SoYjvZKhphMftwLe2' +
'OBt/juGpmLf2fob+9BPJ6UqdRxokdeV4fhpr24p/WTggjWTkoGuBa' +
'oZ5NcO8mmErrw0OOxCU');

droptrout := BitmapFromString(96, 15, 'meJztllEOgCAMQzmaR/TG+KcL3b' +
'qRsGhwjR84oR0vhNj7o5am4+zyyQtarptMKiKJZSGiDNqDp8SSh6j' +
'4xEP34COupXEyYrTqGIo7Uu8l/krWEjfiSRxcPkGSOHYhuE0G+ahB' +
'UxEkOr7TDD7DJ2zSOnWcj1X5OB9Mjxxy8lewH5+psUT6Lh9+26iTX' +
'YdIkw2OiqyrY9XZMseIqboVOiWCpdSKj6fiw1V8/qwLk9O7hA==');

If (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then
begin
wait(10);
Mouse(x, y, 3, 3, False);
wait(10);
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15);
wait(10);
Mouse(x2, y2, 50, 3, True);
wait(1000 + Random(100));
end else
begin
wait(10);
If (FindBitmapToleranceIn(salmon, x, y, 546, 184, 753, 453, 15)) then
begin
wait(10);
Mouse(x, y, 3, 3, False);
wait(10);
FindBitmapToleranceIn(dropsalmon, x2, y2, 546, 184, 753, 453, 15);
wait(10);
Mouse(x2, y2, 50, 3, True);
wait(1000 + Random(100));
end else
begin
Full := False
end;
FreeBitmap(salmon);
FreeBitmap(dropsalmon);
FreeBitmap(trout);
FreeBitmap(droptrout);
end;
until(Full = False)
end;



Procedure CheckFull;
var
trout, salmon, x, y:Integer;
Begin
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' +
'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' +
'yG50swmztopw96j0D2gBgATwBhd');

trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' +
'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' +
'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');


If (FindBitmapToleranceIn(trout, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True
DropInventory;
end else
begin
FreeBitmap(trout);
If (FindBitmapToleranceIn(salmon, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True
DropInventory;
end;
FreeBitmap(salmon);
FreeBitmap(trout);
wait(10000 + Random(1000));
end;
until(Full = True)
end;

Procedure Randoms;
begin
If(Full = False) then
repeat
Rivertroll;
Wait (5000 + random(7000));
until(Full = True)
end;



begin
ClearDebug;
SetupSRL;
StartFishing;
CheckFull;
Randoms;
end.


I think the problem is that it's not freeing them when you end the script, which is fine because it is still freeing them while it's running which means only an extra like.. 250 kb of ram being used.

Also lemee just format dat script for you:

program new;
{$define srl5}
{$loadlib sps}
{$i srl/srl.simba}
{$i sps/sps.simba}

var
full: boolean;
trout, salmon, dropsalmon, droptrout: Integer;

procedure RiverTroll;
var
x, y: Integer;
begin
if FindcolorTolerance(x, y, 7966560, 0, 0, 511, 334, 5) then
Mouse(584, 61, 5, 5, true);
wait(15000 + random(1000));
Mouse(636, 474, 10, 10, true);
Wait(100);
Mouse(639, 346, 3, 40, true);
wait(10);
WriteLn('River Troll Detected! -logging out');
end;

procedure StartFishing;
begin
Mouse(290, 150, 13, 13, True);
Wait(1000)
end;

procedure DropInventory;
var
trout, salmon, dropsalmon, droptrout, x, y, x2, y2: Integer;
begin
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' + 'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' + 'yG50swmztopw96j0D2gBgATwBhd');
trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' + 'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' + 'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');
dropsalmon := BitmapFromString(108, 15, 'meJztlEsOgDAIRDmaR/TGdacEC' + 'oxB/EQmLpDUKbxWxjhEZVrWwZ+6jZAyLrfd6ZVi5MU/iLGaIVVibI' + 'Z5/ZMhG5NDLNaorbwuXncxnZP+q/W5/gSxtQZ1aLvnQ4YCFB6H9ZB' + '9P0GGSD6Mp+frx2I9TqOCIRkny+t0WDnOvm2SoYjvZKhphMftwLe2' + 'OBt/juGpmLf2fob+9BPJ6UqdRxokdeV4fhpr24p/WTggjWTkoGuBa' + 'oZ5NcO8mmErrw0OOxCU');
droptrout := BitmapFromString(96, 15, 'meJztllEOgCAMQzmaR/TG+KcL3b' + 'qRsGhwjR84oR0vhNj7o5am4+zyyQtarptMKiKJZSGiDNqDp8SSh6j' + '4xEP34COupXEyYrTqGIo7Uu8l/krWEjfiSRxcPkGSOHYhuE0G+ahB' + 'UxEkOr7TDD7DJ2zSOnWcj1X5OB9Mjxxy8lewH5+psUT6Lh9+26iTX' + 'YdIkw2OiqyrY9XZMseIqboVOiWCpdSKj6fiw1V8/qwLk9O7hA==');
if (FindBitmapToleranceIn(trout, x, y, 546, 184, 753, 453, 15)) then
begin
wait(10);
Mouse(x, y, 3, 3, False);
wait(10);
FindBitmapToleranceIn(droptrout, x2, y2, 546, 184, 753, 453, 15);
wait(10);
Mouse(x2, y2, 50, 3, True);
wait(1000 + Random(100));
end
else
begin
wait(10);
if (FindBitmapToleranceIn(salmon, x, y, 546, 184, 753, 453, 15)) then
begin
wait(10);
Mouse(x, y, 3, 3, False);
wait(10);
FindBitmapToleranceIn(dropsalmon, x2, y2, 546, 184, 753, 453, 15);
wait(10);
Mouse(x2, y2, 50, 3, True);
wait(1000 + Random(100));
end
else
begin
Full := False
end;
FreeBitmap(salmon);
FreeBitmap(dropsalmon);
FreeBitmap(trout);
FreeBitmap(droptrout);
end;
until (Full = False)
end;

procedure CheckFull;
var
trout, salmon, x, y: Integer;
begin
repeat
salmon := BitmapFromString(6, 8, 'meJxjYMAJGDG4je2LGZG4VXUz0UQK' + 'Sntrm+Yywrjp2U0lFRPrmuczgrlAFJtQkpnbUlo12dIx1c49Lzg0I' + 'yG50swmztopw96j0D2gBgATwBhd');
trout := BitmapFromString(7, 8, 'meJxjYCAAGLGJLF+xmRFVZM7cFZiC' + 'EyfOWbRoPSOSSGtr/5Qp85cs2cAIMxlIVlY2dnZOnj5jcUJCRnp6H' + 'lAkO7ukuqYtKioxKSkrJ7estLQWAJdQHgk=');
if (FindBitmapToleranceIn(trout, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True DropInventory;
end
else
begin
FreeBitmap(trout);
if (FindBitmapToleranceIn(salmon, x, y, 690, 405, 737, 444, 15)) then
begin
Full := True DropInventory;
end;
FreeBitmap(salmon);
FreeBitmap(trout);
wait(10000 + Random(1000));
end;
until (Full = True)
end;

procedure Randoms;
begin
if (Full = False) then
repeat
Rivertroll;
Wait(5000 + random(7000));
until (Full = True)
end;

begin
ClearDebug;
SetupSRL;
StartFishing;
CheckFull;
Randoms;
end.

Wardancer

2012-12-30 15:06:24

I quickly looked at the code and you seem to be using these bitmaps for the whole script. There is no real need to call and free them over and over and over again. At the beginning of your script, OUTSIDE your main loop, you can call a procedure that will call all your bitmaps (make sure that the integer variables for those are global though) then simply call the integer when needed.

EDIT: If you REALLY want to call each time then I suggest you to call the bitmaps BEFORE you start your loop and free them once the loop is over. The standards aren't really good and I don't want to bother counting, but I believe that, at the moment, you only end up freeing your bitmaps if a condition is met.