SRL Archive - OSR Help

TPA Debug script


serajin

2012-05-12 15:46:58

Hey guys,

I found a tutorial by Cazax about TPAs and he has a debug script in there. However when I run it it runs an error..

The script is as follows
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I: Integer;
xs, ys, xe, ye: Integer;

Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points[i].X);
ys := Min(ys, Points[i].Y);

xe := Max(xe, Points[i].X);
ye := Max(ye, Points[i].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

and I am calling it like this:
DebugTPA(C, '');

and I get an error
[Error] (245:5): Unknown identifier 'SafeDrawBitmap' at line 244

Any help is appreciated! I'm trying to make sure my TPAs are working, and from the looks of this, the script will mark where the tpas were found on an image. Correct me if I am wrong! Thanks!

Brandon

2012-05-12 15:51:46


{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}

var
SomeTPAToDebug: TPointArray;
begin
SetupSRL;
DebugTPA(SomeTPAToDebug, '');
end.

serajin

2012-05-12 16:00:56

Thank you. That compiled! But do I need to be using Smart for that?

I am currently not, and it just kinda brings up a tiny window that all I can do is close, and is like, 8x8 pixels.

Brandon

2012-05-12 16:24:18

From: serajin
Thank you. That compiled! But do I need to be using Smart for that?

I am currently not, and it just kinda brings up a tiny window that all I can do is close, and is like, 8x8 pixels.



For Debugging you do not need smart.. If you want to debug on smart then you do:


{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/PaintSmart.Simba}

Smart_DrawDots(TPAToDraw);
Now the previous code I gave you does exactly what it says. It opens a debug window with you TPA Drawn to it. If your didn't select your client, you TPA will have no points to draw so the window will be the size of the Close button.

serajin

2012-05-12 16:36:18

Hmm..well while I waited on your reply.. I got smart to load(which I was having trouble with). But I do have my client selected, and I get a really small window. It's not quite the size of the close button, but it has 1 black dot on a white screen. And If I move it, the whole box turns black. and I can click the close button at any time.

Any ideas why it may not be grabbing a snapshot of the client? Should I run as admin?

Edit: This is the window that pops up (http://imgur.com/bmL0Z)

Edit 2: The TPA is getting points. I have them listed out before it trys to debug them. And I have made my character successfully navigate points as well…so I know there is data there.

Brandon

2012-05-12 16:38:21

From: serajin
Hmm..well while I waited on your reply.. I got smart to load(which I was having trouble with). But I do have my client selected, and I get a really small window. It's not quite the size of the close button, but it has 1 black dot on a white screen. And If I move it, the whole box turns black. and I can click the close button at any time.

Any ideas why it may not be grabbing a snapshot of the client? Should I run as admin?


Check the size of your TPA. The TPA your passing it probably has no points. Make sure it has some. Try WriteLn(TPA);

And see if it prints points.. Try if (Length(TPA) < 10) then writeln('TPASmall');

Stuff like that.

serajin

2012-05-12 16:41:19

yea..okay I'm dumb! I was looking at a TPA I DID have that was full of points. And The new one I created to test had no points..

Sorry for all the confusion!

Shatterhand

2012-05-12 17:05:26

Check out my debug function. :)
http://villavu.com/forum/showthread.php?p=991760#post991760