SRL Archive - Jr. Member General Help and Discussion

acess violation help on tpointarray function


ogustuce

2019-07-31 23:11:58

hey guys, for a couple days now i've been working on a little project of mine. Its similar to the action bar function but to work with the sidebars (additionnal bars on screen)

so far i've made one that works fine but it relies on bitmaps to locate the bars(but it only locate them when they're in a certain position). So i started writing one that relies on other things to find the bars so ican find them no matter their positions.

So far what i made locates the bars, and reads the number in the yellow circle to identify them. However i cant manage to turn that function into a TpointArray for later use in the script. The script compiles fine but i get an access violation that i cant find the solution to.

here's the function


function FindSidebars:Tpointarray;
var
i,k,h,x,y,f:integer;
p:tpoint;
Circle,circle2:Tpointarray;
box,box2,box3:Tbox;
circles:t2dpointarray;
begin


findcolorsspiraltolerance(x,y,circle,1343945,Getclientbounds,25);
circles:=SplitTPAex(circle,8,8);
h:=high(circles);

for i:=h downto 0 do
begin
box:=circles[i].getbounds;
filterpointspie(circles[i],0,360,6,8,middlebox(box).x,middlebox(box).y);

box:=circles[i].getBounds;

etl_drawbox(Box2,clred,false);

box:=circles[i].getBounds;

f:= strToIntdef(getTextAtEx(intToBox(box.x1, box.y1, box.x2,box.y2), 0, 0, 0, 3111603, 0, 'UpChars'), -1);

if f>0 then
begin
result[i]:=middlebox(circles[i].getBounds);
end

end

end

klamor

2019-07-31 23:40:04

would help if you could provide a print out of the error message

ogustuce

2019-07-31 23:49:29

there you go


Error: Access violation at line 37
Execution failed.
The following bitmaps were not freed: [Minimap Mask]


its tied to the result part.

what it does is look for a color on the whole screen (the yellow-ish circle around your bar number)
makes tpa from that
split that tpa into ATPA
and apply filters to keep only the circles with the numbers in it.
get the bound of the circle
make a tbox from that
and lastly the part that don't work is to turn the middle points of those boxes into a TpointArray

Citrus

2019-08-01 06:53:56

You need to check if the arrays are empty before trying to access them. There's a reason that FindColors() returns a boolean.

ogustuce

2019-08-01 13:48:50

Well thye shouldnt be? I tried replacing the result by

P:=middlebox(circles[i].getbounds);
Writeln(inttostr(p.x)+'/'+inttostr(p.y));
P as a tpoint

And it prints 4 tpoints

Olly

2019-08-01 15:26:46

You need to set the length of the result.

ogustuce

2019-08-01 19:04:08

At school rn, ill try it when i get home, ty