SRL Archive - OSR Help

Won't free my dtms


NexPB

2011-12-24 09:12:13

ERROR:
Error: Exception: The given DTM Index[2] doesn't exist at line 72
The following DTMs were not freed: [SRL - Lamp bitmap, 1, 3]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]


program GlowHerblore;
{$i srl/srl/misc/smart.scar}
{$i SRL\SRL.scar}

{
-=-=-=- INFORMATION THIS IS MADE BY NEXPB aka NEX -=-=-=-
- Fill in the required information.
- Only spec restores supported atm.
}

const
userName = ''; //Username here. (needed to login)
passWord = ''; //Pass here.
nickName = ''; //3-4 lowercase letters from your username.
bankPin = ''; //Bankpin here.
makeAmountPots = 1000;// Amount pots need to be made (Always put an amount)
makePot = 'Recover_special'; // your potion here write it same like rs please. (space is "_")
World = 69;//World you want to login.
LampXpIn = 'Farming';//Skill you want exp in from the genie.

var
firstItem, secondItem, potsMade: Integer;//Don't touch this.

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := userName;
Players[0].Pass := passWord;
Players[0].Nick := nickName;
Players[0].Active := True;
Players[0].Pin := bankPin;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];//Random event prices.
end;

procedure AntiRandoms;
begin
FindNormalRandoms;
LampSkill := (LampXpIn);
LevelUp;
end;

procedure StartUpClient;
begin
Smart_Server := World;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;

SetupSRL;
DeclarePlayers;
ActivateClient;
if not LoggedIn then
LoginPlayer;
end;

procedure GetDTMs(potion: String);
begin
Case (Lowercase(potion)) of
'recover_special':
begin
firstItem := DTMFromString('mrAAAAHic42BgYPBjYmAIBuIwIA4H4gAgdgViDyD2AuJTjAwMe4D4GBCfA+KLQHwGiI8A8U4gnuFYCTSFCQ/GDxgJYBgAABIICjI=');//super energy
secondItem := DTMFromString('mggAAAHicY2NgYKhgYmBoAOJyIC4A4iIgrgPiI4wMDKeB+BwQnwTifUC8F4gnLhEF6mLCgrEDRhwYAgBiYwjj');//Papaya
end;
end;
end;

procedure FreeDTMs;
begin
FreeDTM(firstItem);
FreeDTM(secondItem);
end;

procedure WithDrawFromBank(dtm: Integer; amount: String);
var
x, y: Integer;

begin
if not BankScreen then exit;
if (FindDTM(dtm, x, y, MSX1, MSY1, MSX2, MSY2)) then
begin
Mouse(x, y, 4, 4, false);
ChooseOption(amount);
end else
begin
Mouse(x, y, 4, 4, false);
ChooseOption('ithdraw-x');
wait(600 + random(200));
TypeSend(amount);
end;
FreeDTM(dtm);
FreeDTMs;
end;

procedure MakingPots;
var
x, y: Integer;

begin
writeln('Make pots.');
if not LoggedIn then Exit;
//while Animating(IntToBox(MSX1, MSY1, MSX2, MSY2), 2000, 1) do
//begin
//Wait(1000 + random(500));
//end;
if FindDTM(firstItem, x, y, MIX1, MIY1, MIX2, MIY2)then
begin
Mouse(x, y, 4, 4, false);
Wait(450 + random(150));
ChooseOption('Use');
if FindDTM(secondItem, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MMouse(x, y, 4, 4);
if WaitUptext('Use', 300 + random(100)) then
begin
MouseAction(true);
end;
MMouse(272, 571, 4, 4);
if WaitUptext('Make all', 300 + random(100)) then
MouseAction(true);
end;
end;
FreeDTMs;
end;

procedure TakeItems;
var
x, y: Integer;

begin
writeln('bank and take items');
if not LoggedIn then Exit;
if not BankScreen then
begin
if FindObjCustom(x, y, ['chest', 'ank'], [5793394, 13158865], 5) then
Mouse(x, y, 4, 4, false);
wait(500 + random(200));
ChooseOption('Use');
wait(500 + random(200));
end;
If PinScreen then
InPin(Players[CurrentPlayer].Pin);
if BankScreen then
begin
if (not InvFull and not FindDTM(firstItem, x, y, MIX1, MIY1, MIX2, MIY2) and not FindDTM(secondItem, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
potsMade := (potsMade + InvCount);
DepositAll;
wait(900 + random(200));
WithDrawFromBank(firstItem, '14');
wait(900 + random(200));
WithDrawFromBank(secondItem, '14');
end else
begin
CloseBank;
end;
end;
FreeDTMs;
end;

procedure Loop;
var
x, y: Integer;

begin
GetDTMs(makePot);
AntiRandoms;
if (FindDTM(firstItem, x, y, MIX1, MIY1, MIX2, MIY2) and FindDTM(secondItem, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
MakingPots;
end else
begin
TakeItems;
end;
end;

begin
StartUpClient;
Addonterminate('freeDTMs');
if LoggedIn then
repeat
Loop;
until (potsMade >= makeAmountPots) or not LoggedIn;
end.

BraK

2011-12-24 09:17:06

in your mainloop call Addonterminate('freeDTMs'); that should always free them.

Jhangir

2011-12-24 16:30:40

I also noticed you never have the option to use the bank pin.

NexPB

2011-12-25 11:53:03

Got a new error.

cause

2011-12-25 18:09:18

What's the error?

NexPB

2011-12-25 18:16:50

From: cause
What's the error?

Posted above in thread but here

Error: Exception: The given DTM Index[2] doesn't exist at line 72
The following DTMs were not freed: [SRL - Lamp bitmap, 1, 3]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

bud_wis_er_420

2011-12-25 22:00:00

ur problem is here

procedure FreeDTMs;
begin
FreeDTM(firstItem);
FreeDTM(secondItem);
end;

when you call this procedure at the current time the dtm 'firstItem' didn't exist. You have not made it yet. So find a better way to free you dtms

maybe free it in the procdure you use the dtm in. Free it right after you use it. Declare it right b4 you need it, as well.

NexPB

2011-12-26 07:15:14

From: bud_wis_er_420
ur problem is here

procedure FreeDTMs;
begin
FreeDTM(firstItem);
FreeDTM(secondItem);
end;

when you call this procedure at the current time the dtm 'firstItem' didn't exist. You have not made it yet. So find a better way to free you dtms

maybe free it in the procdure you use the dtm in. Free it right after you use it. Declare it right b4 you need it, as well.

I know but i can't find how to fix it.

NexPB

2011-12-26 20:06:32

Bump. Still need help someone.

Kyle Undefined

2011-12-26 21:43:19

Looks like your "FirstItem" DTM is either already freed or isn't set when you call your FreeDTM procedure.

NexPB

2011-12-27 10:14:15

From: Kyle Undefined
Looks like your "FirstItem" DTM is either already freed or isn't set when you call your FreeDTM procedure.


But there is nothing wrong with my method to get DTMs?

Brandon

2011-12-27 10:29:47

From: NexPB
But there is nothing wrong with my method to get DTMs?


Indeed there is. I'll point it out as it's not very obvious.

A: GetDTM's is called at the beginning of the "Procedure Loop"
B: FreeDTM's is called at the end of MakingPots.
C: FreeDTM's is called at the end of TakeItems.


If B gets executed, there is no DTM's to free at C. That's the problem because the way I see it, B ALWAYS gets called and will ALWAYS free the DTM's before C can even see them.

You can either remove the call to freedtm's at B.. Or you can just free and initialize the DTM's as you go along which might be a much better approach rather than spreading them across three procedures. Reasoning: If spread that wide, if the script terminates prematurely/in-between.. the DTM's will not be freed until something else is written over that block of memory.

NexPB

2011-12-27 11:18:34

From: ggzz
Indeed there is. I'll point it out as it's not very obvious.

A: GetDTM's is called at the beginning of the "Procedure Loop"
B: FreeDTM's is called at the end of MakingPots.
C: FreeDTM's is called at the end of TakeItems.


If B gets executed, there is no DTM's to free at C. That's the problem because the way I see it, B ALWAYS gets called and will ALWAYS free the DTM's before C can even see them.

You can either remove the call to freedtm's at B.. Or you can just free and initialize the DTM's as you go along which might be a much better approach rather than spreading them across three procedures. Reasoning: If spread that wide, if the script terminates prematurely/in-between.. the DTM's will not be freed until something else is written over that block of memory.


Thanks for the helpfull post I always thought that it would recall the GetDTMs because it was at a begin from the loop.
Going to fix it now.