Log in

View Full Version : DrawATPA Error / SmartGraphics Error



Dill
10-12-2012, 06:48 PM
Error: Exception: The Points you passed to DrawATPA exceed the bitmap's bounds at line 96



Line 91{*
Line 92 Authors: Sir R. Magician, Brandon.
Line 93
Line 94 Draws a TPA with a specified Colour onto Smart's Canvas.
Line 95 Clears the Canvas first if Clear is set to true.
Line 96*}


I'm running m34t's planker script, which he no longer updates so been going through trying to resolve some of the errors it gives out. Whenever it goes to bank to withdraw items from the bank it will make it to the point where you right click on the item to choose how many to withdraw then it gives the above error.

I searched on the forums here for others who had similar errors but the coding wasn't the same as in those incidents.

Any help or suggestions are welcome.

litoris
10-12-2012, 06:54 PM
Can you post the function that contains line 96?

Dill
10-12-2012, 06:59 PM
I'd be happy to but I dunno which it is, I'm fairly new at attempting to resolve issues on this script, any guidance as to whereas the function would be located?

I'm a bit noob, sorry.

Kasi
10-12-2012, 07:07 PM
the Points are out of range of the SMART canvas.

say a bitmap is 20 by 20 (Width 20, height 20)
if you wanna draw at point(20, 21) you'd get that error.

beat's me how you got that error tho, i cant even find the DrawATPA function.

litoris
10-12-2012, 07:08 PM
I'd be happy to but I dunno which it is, I'm fairly new at attempting to resolve issues on this script, any guidance as to whereas the function would be located?

I'm a bit noob, sorry.

Find line 96. There should be lines above it and below it. Somewhere above it, there should be something like
procedure {procedure name}(?? : integer, ???: Array of Tpoint);//something like this
var//followed by this
i: integer; //some stuff like this below
A: TpointArray;
begin//there definitely is a begin here
{lines of code, including line 96 with the ATPA stuff}
end;//the function ends here
^That is pretty much what a function/procedure looks like. Find it and post it.(note: it may say function instead of procedure, comparing it to the above example)

Dill
10-12-2012, 07:10 PM
procedure SMART_DrawDotsEx(Clear: boolean; Pixels: TPointArray; Color: TColor);
{$IFDEF SMART}
var
P: TPointArray;
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug;

if Clear then SMART_ClearCanvas;
P := CopyTPA(Pixels);
OffsetTPA(P, Point(SRL_NAVBAR_INGAME_X, SRL_NAVBAR_INGAME_Y));
SMART_Canvas.DrawTPA(P, Color);
{$ELSE}
begin
{$ENDIF}
end;

Those are the lines under 96, the lines above 96 were as posted above.

J J
10-12-2012, 07:13 PM
I believe someone had this error in my GOP script aswell. I think it has something to do with the offset from the navigiation bar. It might push the TPA coordinates out of the SMART client bounds.

litoris
10-12-2012, 07:13 PM
What about line 96 on that script?(the planker)
The stuff you posted are from the include, and work fine on other scripts.

Dill
10-12-2012, 07:16 PM
function DownloadToFile(const URL, Filename: string): boolean;
var
FileI: LongInt;
FileC, FileH: string;
begin
Result := False;

FileI := InitializeHTTPClient(False,False);
try
FileC := GetHTTPPage(FileI, URL);
FileH := GetRawHeaders(FileI);

if ((FileC = '') or (FileH = '')) then
begin
WriteLn('Error downloading "' + URL + '".');
Exit;
end;

FileH := Copy(GetRawHeaders(FileI), 10, Pos(#13, FileH) - 10);

if (FileH <> '200 OK') then
begin
WriteLn('Couldn''t download "' + URL + '", Error Code: ' + FileH + '.');
Exit;
end;


finally
FreeHTTPClient(FileI);
end;

try
if not FileExists(Filename) then
FileI := CreateFile(Filename)
else
FileI := OpenFile(Filename, False);

CloseFile(FileI);

FileI := RewriteFile(Filename, False);
Result := WriteFileString(FileI, FileC);
finally
CloseFile(FileI);
end;
end;

That's the one above line 96 on the script

tls
10-12-2012, 07:19 PM
I believe someone had this error in my GOP script aswell. I think it has something to do with the offset from the navigiation bar. It might push the TPA coordinates out of the SMART client bounds.

Don't offset your points before plugging them into the drawing functions. They are offset by default at the start of the functions.

Kasi
10-12-2012, 07:21 PM
Wouldn't it just be better to add range checks to smart's draw functions?

Edit: Like..


procedure SMART_DrawDotsEx(Clear: boolean; Pixels: TPointArray; Color: TColor);
{$IFDEF SMART}
var
P: TPointArray;
T : TBox;
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug;

if Clear then SMART_ClearCanvas;
P := CopyTPA(Pixels);
T := GetTPABounds(P);

if ((T.X2 - T.X1) > Smart_Canvas.Width) or ((T.Y2 - T.Y1) > Smart_Canvas.Height) then
exit; // this

OffsetTPA(P, Point(SRL_NAVBAR_INGAME_X, SRL_NAVBAR_INGAME_Y));
SMART_Canvas.DrawTPA(P, Color);
{$ELSE}
begin
{$ENDIF}
end;


Dunno if it works.

Olly
10-12-2012, 07:29 PM
Ever since we changed from paintsmart to smartgraphics there is no clipping which means if a point that is suppost to be draw is off the smart canvas it will just error out :(

although this does work

try
smart_drawcircle(false,point(1,1),20,false,clred);
except end;

^ just wont draw it and script will continue.

Dill
10-12-2012, 07:35 PM
Hmm thanks for the help

tls
10-12-2012, 08:36 PM
Wouldn't it just be better to add range checks to smart's draw functions?

Edit: Like..


procedure SMART_DrawDotsEx(Clear: boolean; Pixels: TPointArray; Color: TColor);
{$IFDEF SMART}
var
P: TPointArray;
T : TBox;
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug;

if Clear then SMART_ClearCanvas;
P := CopyTPA(Pixels);
T := GetTPABounds(P);

if ((T.X2 - T.X1) > Smart_Canvas.Width) or ((T.Y2 - T.Y1) > Smart_Canvas.Height) then
exit; // this

OffsetTPA(P, Point(SRL_NAVBAR_INGAME_X, SRL_NAVBAR_INGAME_Y));
SMART_Canvas.DrawTPA(P, Color);
{$ELSE}
begin
{$ENDIF}
end;


Dunno if it works.

No that is the responsibility of the scripter.

Brandon
10-12-2012, 08:44 PM
Ever since we changed from paintsmart to smartgraphics there is no clipping which means if a point that is suppost to be draw is off the smart canvas it will just error out :(

although this does work

try
smart_drawcircle(false,point(1,1),20,false,clred);
except end;

^ just wont draw it and script will continue.


It was never clipped before either. It was just simply not drawn. Thus that TryCatch does the same thing as the old clipping. Also that navbar did indeed cause quite an uproar in SRL.