SRL Archive - OSR Help

Design


Nataurs

2012-03-02 03:34:26

Was just wondering from a design and standrads point of view is it ok to Free a bitmap in a loop like in the example, so it saves me having to free every bitmap on its own line.


for i := 0 to GetArrayLength(Rune) do
begin
if FindBitmapToleranceIn(Rune[i].BMP, x, y, MSX1, MSY1, MSX2, MSY2, 15) then
begin
Mouse(x, y, 7, 7, true);
Wait(RandomRange(150, 250));
ClickMouse2(true)
if IsUpTextMultiCustom([Rune[1].Uptext + Rune[3].Uptext]) then
ClickMouse2(true);
FreeBitmap(Rune[i].BMP);
Break;
end;
end;

Sex

2012-03-02 03:41:07

Yes that is okay and preferred.

Nataurs

2012-03-02 03:41:29

Well, just figured if u free one bitmap and break the loop, then every other bitmap wont be freed.

Sex

2012-03-02 04:21:45

Ah, you are correct. Yeah, this would introduce some leaks.
Do something like this (declare b as a boolean):

for i := 0 to GetArrayLength(Rune) do
begin
b := FindBitmapToleranceIn(Rune[i].BMP, x, y, MSX1, MSY1, MSX2, MSY2, 15);
FreeBitmap(Rune[i].BMP);
if b then
begin
Mouse(x, y, 7, 7, true);
Wait(RandomRange(150, 250));
ClickMouse2(true)
if IsUpTextMultiCustom([Rune[1].Uptext + Rune[3].Uptext]) then
ClickMouse2(true);
Break;
end;
end;

Daniel

2012-03-07 05:25:51

Load all of your bitmaps at the beginning, and free them all at the very end of your script (if you don't, Simba will). Much less hassle this way, and preferable :)