Results 1 to 7 of 7

Thread: What causes "access violation" errors? (Likely bug in isMouseOverText)

  1. #1
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Post What causes "access violation" errors? (Likely bug in isMouseOverText)

    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.

    Code:
    -- 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():
    Code:
    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);

  2. #2
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Could you please post the script line where you call isMouseOverText please.

    Forum account issues? Please send me a PM

  3. #3
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    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

    libnpc.simba
    lumbyDung.simba

  4. #4
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    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

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

    Code:
    -- 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]

    Forum account issues? Please send me a PM

  5. #5
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    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.

  6. #6
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    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.

    Forum account issues? Please send me a PM

  7. #7
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Justin View Post
    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

    Code:
    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.

    lumbyDung.simba
    libnpc.simba

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •