SRL Archive - RS3 Help

Weird infinite loop, can't find the cause of it


rj

2014-02-05 21:30:21

Someone I am getting a infinite loop with this function..

procedure _loot_array.pickUp(orig, dots:TPointArray);
var
_dots:TPointArray;
_possible_loot:T2DPointArray;
options:array of TOptions;
i, k, _count:integer;
opt_strs:TStringArray;
_ls:TPoint;
t:integer;
begin
writeln('@_loot_array.pickUp(orig, dots:TPointArray)');
_dots := combinetpa(orig, dots);
cleardoubletpa(_dots);
filterpointspie(_dots, 0, 360, 0, _loot_distance * 4, 627, 138);
_possible_loot := clusterTPA(_dots, 1);
debugatpa(_possible_loot, 'bmp');
writeln('# for 0 to ' , high(_possible_loot));
for i := 0 to high(_possible_loot) do
begin
t := getSystemTime;
_ls := ss_MMtoMsPoint(middletpa(_possible_loot[i]));
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
options := _ss.getOptions();
setLength(opt_strs, length(options));
for i := 0 to high(options) do
opt_strs[i] := options[i].Str;
for k := 0 to high(self) do
if isText(opt_strs, self[i].options) then
_count := _count + 1;
writeln('Calculations took ' , (getsystemtime - t) , ' ms (length=',length(_possible_loot),')');
end;
writeln('Loot count ' , _count);
writeln('# for 0 to ' , _count);
for i := 0 to _count do
begin
if (i > 0) then
mouse(258, 230, 0, 0, mouse_right);
if not _ss.waitOptionMulti(self[i].options, 1200) then
moveMouse(0, 0);
end;
writeln('@end@');
end;


It gets the debug

@_loot_array.pickUp(orig, dots:TPointArray)
# for 0 to 4
Calculations took 468 ms (length=5)
Calculations took 483 ms (length=5)
Calculations took 437 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 422 ms (length=5)
Calculations took 421 ms (length=5)
Calculations took 359 ms (length=5)
Calculations took 390 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 421 ms (length=5)
Calculations took 375 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 437 ms (length=5)
Calculations took 374 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 437 ms (length=5)
Calculations took 390 ms (length=5)
Calculations took 437 ms (length=5)
Calculations took 375 ms (length=5)
Calculations took 437 ms (length=5)
Calculations took 375 ms (length=5)
Calculations took 406 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 422 ms (length=5)
Calculations took 328 ms (length=5)
Calculations took 483 ms (length=5)
Calculations took 422 ms (length=5)
Calculations took 390 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 375 ms (length=5)
Calculations took 421 ms (length=5)
Calculations took 405 ms (length=5)
Calculations took 374 ms (length=5)
Calculations took 499 ms (length=5)
Calculations took 375 ms (length=5)


And it spams that until I stop the script.


when this happens, it's always right clicked on a option… when I move the mouse away it right clicks again in a different spot

Brandon

2014-02-05 22:32:42

Using "I" in the nested for-loop resets it to 0 every loop. Use another variable in the inner for-loop.

If you still do not see it:


for i := 0 to high(_possible_loot) do //I = 0 to..
begin
t := getSystemTime;
_ls := ss_MMtoMsPoint(middletpa(_possible_loot[i]));
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
options := _ss.getOptions();
setLength(opt_strs, length(options));

for i := 0 to high(options) do //I = 0 to..

Anyway, hope that helps.

rj

2014-02-06 15:20:30

From: Brandon
Using "I" in the nested for-loop resets it to 0 every loop. Use another variable in the inner for-loop.

If you still do not see it:


for i := 0 to high(_possible_loot) do //I = 0 to..
begin
t := getSystemTime;
_ls := ss_MMtoMsPoint(middletpa(_possible_loot[i]));
mouse(_ls.x, _ls.y, 0, 0, mouse_right);
options := _ss.getOptions();
setLength(opt_strs, length(options));

for i := 0 to high(options) do //I = 0 to..

Anyway, hope that helps.


:duh: that's probably it