PDA

View Full Version : What causes "access violation" errors? (Likely bug in isMouseOverText)



bonsai
10-06-2013, 01:02 AM
I have most of a script working to level combat.

It crashes occasionally with the exception shown below. I was hesitant to post it on the official buglist since I can't figure out what would cause it.

I tried researching access violation messages but didn't really find anything. What causes access violations?

My code is calling mainscreen.findObject() to locate and click on the target. I modified mainscreen to fix the 'x' 'y' munging issue I reported on the bug page. Now the script runs, sometimes for a while, but this access violation issue is popping up.


-- TRSMainscreen.findObject()
---- Colors found: 42
---- Possible objects found: 1
---- isMouseOverText()
------ Current mouse-over text: "Attack Warped cockroach"
------ Found "ockroach" in mouse-over string: "Attack Warped cockroach"
---- isMouseOverText(): True
---- Successfully mouse'd object
-- TRSMainscreen.findObject(): True
mainscreen.getBounds() = {X1 = 0, Y1 = 0, X2 = 734, Y2 = 407}
-- TRSMainscreen.findObject()
---- Colors found: 25
---- Possible objects found: 0
-- TRSMainscreen.findObject(): False
-- FAILED to find monster, sleeping
-- TRSMainscreen.findObject()
---- Colors found: 113
---- Possible objects found: 1
---- isMouseOverText()
Exception in Script: Runtime error: "Access violation" at line 544, column 62 in file "C:\Simba\Includes\srl-6\lib\core\text.simba"

Calling this version of findObject():

result := mainscreen.findObject(x,
y,
monsterColor(mname),
monsterTol(mname),
colorSetting(2, monsterHue(mname), monsterSat(mname)),
mainscreen.getCenterPoint(),
monsterWidth(mname) ,
monsterHeight(mname),
monsterPointMatch(mname),
[monsterUptext(mname)],
MOUSE_LEFT);

Justin
10-06-2013, 01:07 AM
Could you please post the script line where you call isMouseOverText please.

bonsai
10-06-2013, 01:41 AM
It's called by findObject not directly.

Here's the code being used. Place character in first room of lumby dungeon with the cockroaches.

Please be gentle with criticism, it's my first simba script :)

22280
22279

Justin
10-06-2013, 02:02 AM
It's called by findObject not directly.

Here's the code being used. Place character in first room of lumby dungeon with the cockroaches.

Please be gentle with criticism, it's my first simba script :)

22280
22279

Humm, I'm getting Out of bounds error, I'll pass this on to the developers.


-- TRSMainscreen.findObject(): True
Exception in Script: Runtime error: "You passed a wrong xe to a finder function: 1218. The client has a width of 960, thus the xe is out of bounds." at line 797, column 20 in file "C:\Simba\Includes\srl-6\lib\utilities\wrappers.simba"
The following DTMs were not freed: [0]

bonsai
10-06-2013, 08:14 AM
I think Olly already fixed that, I filed a bug.

To fix yourself until released, you need to edit mainscreen.simba and find the functions that use x and y as var parameters (I think it was only the findObject functions). Change x and y to another name like ix, iy

Those names are the same as the boundary x,y inherited from interfaces and it was altering the main record not the local variable.

Justin
10-06-2013, 08:23 AM
I think Olly already fixed that, I filed a bug.

To fix yourself until released, you need to edit mainscreen.simba and find the functions that use x and y as var parameters (I think it was only the findObject functions). Change x and y to another name like ix, iy

Those names are the same as the boundary x,y inherited from interfaces and it was altering the main record not the local variable.

I downloaded the latest include from GitHub before I tested the script.

bonsai
10-06-2013, 01:02 PM
I downloaded the latest include from GitHub before I tested the script.

He got the main function but the bug is still in the overloaded one. I'll post an update in the bug section.


mainscreen.simba line 316


function TRSMainscreen.findObject(var x, y: integer; col, tol: integer; colSettings: TColorSettings; sortFrom: TPoint; objWidth, objHeight, minCount: integer; mouseOverText: TStringArray; mouseAction: integer = MOUSE_NONE): boolean; overload;
begin
result := self.findObject(x, y, [col], [tol], colSettings, sortFrom, objWidth, objHeight, minCount, mouseOverText, self.getBounds(), mouseAction);
end;

x and y in this code need to be changed to another name (ix and iy were used in the prior function fix).

I'm still getting the violation exception but I did figure out it was more likely to happen if I was calling findObject while I was still in the previous fight. Still working on the fight detection logic/DTM. I also noticed it was more likely to happen if someone else was in the room killing things.

I put in some more delays and it tends to run more than one or two kills.

I'll try to spend some time looking at the details of findObject -> isMouseOverText() to see if I can find the culprit.

22281
22282