Results 1 to 3 of 3

Thread: What causes Exception TLPThread.Destroy: Access violation ?

  1. #1
    Join Date
    Mar 2006
    Posts
    141
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default What causes Exception TLPThread.Destroy: Access violation ?

    Hello, after running this script:
    Code:
    program new;
    {$i alb\Alb_include.simba}
    
    begin
    setup;
    charspeed;
    ExecuteRun('kingspool');
    end.
    I get this output. Everything seems to run normally until it is done running.
    Code:
    Include file loaded.
    Finding Speed
    Exiting inventory
    Your speed is 4.5 m/s.
    6
    654 & 194.9
    499 & 264
    608 & 350.7
    391 & 318
    462 & 26.2
    271 & 97
    589 & 152.9
    ending run
    Successfully executed.
    Exception TLPThread.Destroy: Access violation
    Here is the include file that the above script uses. After narrowing it down I think the error is stemming from the ExecuteRun function.
    Code:
    begin
      clearDebug();
      writeln('Include file loaded.');
    end;
    
    var
      client_x, client_y: Integer;
      speed_f: extended;
      magRead, degRead: TExtendedArray;
    
    const
      manualmode := 1;
      ppm := 350;
      x_offset = 0;
      y_offset = 40;
      angle = 45;
      ppmy := sin (angle * (3.1416 / 180)) * ppm;
    
    function TrimLetters(s: string): string;
    var
      LetterArray: TStringArray;
      i: Integer;
    begin
      LetterArray := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '*', '!', '/', '^'];
      result := s;
      for i := 0 to Length(LetterArray) - 1 do
        result := Replace(result, LetterArray[i], '', [rfReplaceAll, rfIgnoreCase]);
    end;
    {$s+}
    
    type
      TDebug = (DEBUG, HEADER, SUB, FOOTER, LOG, HINT, WARNING, ERROR, FATAL);
      {$s-}
    
    procedure openInv;
    begin
      KeyDown(73);
      wait(RandomRange(50, 100));
      KeyUp(73);
    end;
    
    procedure print(txt: string; debugType: TDebug = TDebug.DEBUG);
    begin
    end;
    {$i SRL-6\lib\core\tesseract.simba}
    
    function GetText(box: TBox): string;
    var
      TesFilter: TTesseractFilter;
    begin
      TesFilter := TTesseractFilter([4, 4, [False, 20, TM_MinMax]]);
      Result := Tesseract_GetText(box.x1, box.y1, box.x2, box.y2, TesFilter);
    end;
    
    function charSpeed: Extended;
    var
      bitx, bity: Integer;
      ocr: string;
      speed_input: string;
      x := BitmapFromString (11, 11, 'meJyLiFyemX6ypOiRk+tieaVqdr' + 'ZQFhZXVjZvZmZbDg5HDja7uOSj1vYLRcTiGNnsGVht2dm9pQTCJPh' + 'CJQVCJflDpQRCmRm9GVicgVIQxMTiysHmBjSEmdUVSLKxuTGxubKI' + '+PM6VvG61vA6V/A6l/E6l/P7NvDYFTJy2jGwWjGxOjHzeitM3Kex9' + '7nymgcQpLLukcLMc8wC7gzM1owsLgxMLkzMQVJ5M4zvfbJ4/tPi5m' + 'e9Sx9VNz3l0EhiYLFjYPFgYPRiYAhh5nGX71hn+fpX+I//Vp//aex' + '9KdO1n4HFhok1gIEpkIEhgoHZmYXPR3PDBfv3f6K//9e/8EFlwxMe' + 'qxJGVqBUKANDDAMjkAzhUs/VOXTP89Nfz9e/VLc8k27Zz8gaxcAUy' + '8AYycAYy8AAJMOEA3uNH333+frP6PJH5XWPGFiiGBjTgOIMjOEMTC' + 'DExBEl17TR+uUvv2//DG59AQCapGwT');
      inv2 := BitmapFromString (10, 10, 'meJyLO3w77sjt2AO34g7eij14O/' + 'bQrfhjd0Do6J3YgzdjD9wEysYdAkrdApJxh28nHL8bD0TH7sQduRW' + 'z/wZQJP7w7eg9V6J2X449cBsoFbPvctiWE8FrT8aC1YdvOuHat8S5' + 'Z5PvottBK486dS02yZtglLMEKBV36LZz1yy1gFS95KVWtXdtauar+' + 'uXJOTWrh+8G2gu0UVzfVCO81rjgtNvUawrO4Sp+bXpppw3S10TvvR' + 'Gz/yansKhB2lSLquuBKy6IG1hrRMwwyrvpOulAzL4b0ftusPMLGuf' + 'Os6q76btgt4SRg27ScvOKe2EbL8UcuBm1FySrHdNjnH/OtGC2rF2W' + 'fuo2y+o7bpPWA40F6tWOSFHxyVYPW6IetlIv9YBl9UnXCSdUfCIBa' + 'wiaSw==');
    begin
      if (manualmode = 1) then
      begin
        writeln('Finding Speed');
        openInv;
        wait(100);
        movemouse(1366, 299);
        wait(100);
        clickmouse(1366, 299, 1);
        ocr := TrimLetters(GetText(IntToBox(1208, 667, 1294, 689)));
        try
          speed_f := StrToFloat(ocr);
          writeln('Automatically found speed: ' + ToStr(speed_f));
        except
          InputQuery('User Input', 'What is your movement speed? (in m/s)', speed_input);
          speed_f := StrToFloat(speed_input);
        finally
          begin
            writeln('Exiting inventory');
            writeln('Your speed is ' + ToStr(speed_f) + ' m/s.');
            wait(100);
            movemouse(1373, 127);
            wait(100);
            clickmouse(1373, 127, 1);
            wait(100);
            movemouse(1884, 84);
            wait(100);
            clickmouse(1884, 84, 1);
            wait(100);
          end;
        end;
      end
      else
      begin
        OpenInv;
        wait(100);
        FindBitmap(inv2, bitx, bity);
        wait(100);
        movemouse(bitx, bity);
        wait(100);
        clickmouse(bitx, bity, 1);
        wait(100);
        ocr := TrimLetters(GetText(IntToBox(1208, 667, 1294, 689)));
        try
          speed_f := StrToFloat(ocr);
          writeln('Automatically found speed: ' + ToStr(speed_f) + ' m/s');
        except
          MessageBox('Automode failed, please use manual mode. Script will end.', 'Warning', 8);
          writeln('Scripted automatically ended, please use manual mode.');
          writeln('Open Alb_include and change manual_mode to 1.');
          terminatescript;
        finally
          begin
            repeat
              FindBitmap(x, bitx, bity);
              wait(100);
              movemouse(bitx, bity);
              wait(100);
              clickmouse(bitx, bity, 1);
              wait(100);
            until (not (FindBitmap(x, bitx, bity)));
          end;
          Result := speed_f;
        end;
      end;
      freeBitmap(inv2);
      freeBitmap(x);
    end;
    
    procedure setup;
    var
      w, h: integer;
      speed_input: string;
    begin
      GetClientDimensions(w, h);
      client_x := w;
      client_y := h;
      ActivateClient;
    end;
    
    function WriteToFile(Text, FileName: string): Boolean;
    var
      thePath: string;
      theFile: Integer;
      bothFiles: string;
    begin
      thePath := AppPath + 'Scripts\alb\runFiles\';
      bothFiles := thePath + ToStr(theFile);
      try
        theFile := AppendFile(thePath + toStr(FileName));
      except
        WriteLn('Error: Could not open run file.');
      finally
        clearDebug();
        WriteLn('Saving Data...');
      end;
      if (WriteFileString(theFile, Text)) then
        Result := True;
      CloseFile(theFile);
    end;
    
    procedure RunDist(magr, direction: Extended);
    var
      sTime, modTime, speed, distance: Extended;
      c, d, f: Integer;
    begin
      distance := magr / ppm;
      c := round(((client_x - 8) / 2) - x_offset);
      d := round(((client_y - 29) / 2) - y_offset);
      modTime := (magr) * (10000 * ppm * speed_f);
      writeln('Running at ' + ToStr(direction) + ' degrees , Mag: ' + ToStr(magr) + ', for ' + ToStr(round(modTime)) + ' seconds.');
      if (direction <= 90) then
      begin
        direction := direction * (3.1416 / 180);
        c := c + round(magr * cos(direction));
        d := d - round(magr * sin(direction));
      end
      else if (direction <= 180) then
      begin
        direction := direction * (3.1416 / 180);
        c := c + round(magr * cos(direction));
        d := d - round(magr * sin(direction));
      end
      else if (direction <= 270) then
      begin
        direction := direction * (3.1416 / 180);
        c := c + round(magr * cos(direction));
        d := d - round(magr * sin(direction));
      end
      else if (direction <= 360) then
      begin
        direction := direction * (3.1416 / 180);
        c := c + round(magr * cos(direction));
        d := d - round(magr * sin(direction));
      end;
      movemouse(c, d);
      wait(10);
      clickmouse(c, d, 0);
      wait(floor((modTime) * 1000));
      GetMousePos(c, d);
    end;
    
    function readRun(Filename: string): Integer;
    var
      FileNum, h, h2, i: integer;
      s: string;
      tempArray: TStringArray
    begin
      FileNum := OpenFile(Filename, true);
      ReadFileString(FileNum, s, FileSize(FileNum));
      CloseFile(FileNum);
      tempArray := Explode(chr(10), s);
      h := high(tempArray);
      h2 := floor(h / 2);
      SetLength(magRead, h2);
      SetLength(degRead, h2);
      for i := 0 to h do
      begin
        if (i mod 2 = 0) then
        begin
          magRead[i div 2] := StrToFloat(tempArray[i]);
        end
        else
          degRead[i div 2] := StrToFloat(tempArray[i]);
      end
      Result := h2;
    end;
    
    procedure ExecuteRun(runFilename: string);
    var
      theRunPath: string;
      a, i: Integer;
      bothRunFiles: string;
    begin
      theRunPath := AppPath + 'Scripts\alb\runFiles\';
      bothRunFiles := theRunPath + runFilename + '.txt';
      a := ReadRun(bothRunFiles);
      readRun(bothRunFiles);
      writeln(a);
      for i := 0 to a do
      begin
        writeln(ToStr(magRead[i]) + ' & ' + ToStr(degRead[i]));
      end;
      writeln('ending run');
    end;
    
    function playerHealth: Integer;
    var
      a, b, lx, ly, rx, ry, ilx, x: integer;
      colorArray: TIntegerArray;
    begin
      colorArray := [1285716, 1285973, 1286742, 1354074];
      lx := 915;
      ly := 350;
      rx := 1027;
      ry := ly + 20;
      ilx := lx;
      cleardebug();
      Writeln('Starting color test');
      freeze;
      repeat
        begin
          if (findcolortolerance(a, b, 1285716, lx, ly, rx, ry, 15)) then
            Inc(lx);
          Inc(rx);
        end
      until (not (findcolortolerance(a, b, 1285716, lx, ly, rx, ry, 15)));
      x := floor((round(((lx - ilx) / 90), 2) * 100));
      Result := x;
      unfreeze;
    end;

  2. #2
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    I used to get this error a lot when I was improperly managing array lengths and values. Try to make sure all your arrays are correctly handled? Other than that, I do not know.

    Quote Originally Posted by Olly View Post
    I would guess your messing around with pointers/arrays and have done something Lape doesn''t like.
    https://villavu.com/forum/showthread...576&highlight=

  3. #3
    Join Date
    Jun 2014
    Location
    Oklahoma
    Posts
    336
    Mentioned
    22 Post(s)
    Quoted
    231 Post(s)

    Default

    I got this error when having a function that did not return anything.

    I've noticed it only started happening when the function was pretty big. I think CharSpeed is your culprit.

    There is probably some technical way to describe this.. But try throwing a result := 0.0; at the top of CharSpeed() and see what happens

    E: I just read your stuff a bit better, and realized what I said has nothing to do with the problem... My bad

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
  •