Results 1 to 13 of 13

Thread: Unknown access violation error...

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Unknown access violation error...

    This function always gives me a access voilation once in a while and I don't know why

    Simba Code:
    function TRSInventory.DTMExists(const DTM, slot:integer):boolean;
    var
      x, y:integer;
    begin
      result := findDTM(DTM, x, y, self.slots[slot].X1, self.slots[slot].y1, self.slots[slot].x2, self.slots[slot].y2);
    end;


    slots is a TBoxArray


    what could cause this to throw a access violation

  2. #2
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    This happens when you access memory which isn't yours to access. Probably either the box it searches is invalid or the slot is invalid when it bugs out.
    Edit: or the DTM doesnt exist.
    Last edited by Kasi; 11-29-2016 at 01:59 AM.

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    This happens when you access memory which isn't yours to access. Probably either the box it searches is invalid or the slot is invalid when it bugs out.
    how could it possibly be invalid, the tboxarray is declared at the beginning of the script and does not change throughout it

    also I'm getting an out of memory error... somehow for a part of the script that does not load DTMs/bitmaps..

    Simba Code:
    for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);

    wth are these errors

  4. #4
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    You think DTMs/Bitmaps are the only thing that take up memory? I edited my other post btw.

  5. #5
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Unless lape has been updated since I last used it, there's no out of range checking, so this error could also be a out of range.

    Code:
    for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
    if len(textATPAS) < len(Colors) it will be out of range
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Kyle View Post
    Unless lape has been updated since I last used it, there's no out of range checking, so this error could also be a out of range.

    Code:
    for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
    if len(textATPAS) < len(Colors) it will be out of range

    Nope :/

    Simba Code:
    setLength(textATPAS, length(colors));
      for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);

    Line before makes sure of that.

    the error has been narrowed down to the OP post.. I output the slots length,current slot, and the dtm it errored on but nothing useful

    Code:
    [ERROR] function TRSInventory.DTMExists(const DTM, slot:integer):boolean;
    Slots length:28
    Current slot:{X1 = 567, Y1 = 259, X2 = 605, Y2 = 294}
    DTM:2


    Would be nice if simba has a printexception procedure because there is nothing I can tell that is wrong from using writeln here.

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by rj View Post
    This function always gives me a access voilation once in a while and I don't know why

    Simba Code:
    function TRSInventory.DTMExists(const DTM, slot:integer):boolean;
    var
      x, y:integer;
    begin
      result := findDTM(DTM, x, y, self.slots[slot].X1, self.slots[slot].y1, self.slots[slot].x2, self.slots[slot].y2);
    end;


    slots is a TBoxArray


    what could cause this to throw a access violation


    TRSInventory is an instance type and references self. If self is not available, nil.slots or danglingPtr.slots would raise. If slot > 28, it could raise too. Could always try changing `const` to `const ref` and see if that helps.
    Last edited by Brandon; 11-29-2016 at 03:31 AM.
    I am Ggzz..
    Hackintosher

  8. #8
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    TRSInventory is an instance type and references self. If self is not available, nil.slots or danglingPtr.slots would raise. If slot > 28, it could raise too. Could always try changing `const` to `const ref` and see if that helps.
    if self wasn't available it wouldn't have been able to print out that debug though right?

    Removed the type and still get the error (everything is inventoryCount, inventoryFull, InventorysearchDTM etc etc)

  9. #9
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Provide full source, or atleast partial source and we can help you figure out your common mistakes
    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Simba Code:
    {$I srl-6/srl.simba}


    const
      TASK = 'mix'; //clean or mix
      USERNAME = '';
      CLIENTNAME = 'Runique';
      CLIENTWIDTH = 765;
      CLIENTHEIGHT = 525;
      dirtyHerbDTM = 'mQwAAAHicY2ZgYMgE4hQgTgbiXiDuBOI+IHa3kGQIcZZjcPDlZEAGjEgYCADVNgS+';
      cleanHerbDTM = 'mbQAAAHicY2VgYHBnYmBwAmIvIPaBskUYGRj4oRjEFgNiz3BuBkUNVqAORgYHX04Gn2huBmyAEQsGAwAnYAQZ';
      ingr_1DTM = 'mbQAAAHicY2VgYHBnYmBwAmIvIPaBskUYGRj4oRjEFgNiz3BuBkUNVqAORgYHX04Gn2huBmyAEQsGAwAnYAQZ';
      ingr_2DTM = 'mQwAAAHicY2ZgYOgH4slA3A3E04B4IhT3T97BkJo9lWHn7tMMyIARCQMBAG3ECOo=';
      finished_productDTM = 'mWAAAAHicY2FgYHBlYmDwBGJnIPYBYklGBgZxIBYFYgkgXtpszVAaq8WwuNEaqBoogAYY0TAIAAAj2AVO';
      dialogColor = 128;
      dialogCount = 473;
      dialogTolerance = 0.05;


    {


    }


    type

      fnct_actionOptions = (ClickRight, ClickLeft, ClickMiddle, Move, Nothing);

      TOptions = record
        Str: string;
        Bounds, BigBox: TBox;
      end;


    var
      slots:TBoxArray;
      bounds:Tbox;
      rsClient:TSysProc;
      dirtyHerb, cleanHerb, ingr_1, ingr_2, finished_product:integer;

    procedure clickMouse2(button:integer);
    begin
      holdMouse(0, 0, button);
      wait(50);
      releaseMouse(0, 0, button);
      wait(10);
    end;

    function boxCenter(bx: TBox): TPoint; begin if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then begin if(bx.X1 > bx.X2) then Swap(bx.X1, bx.X2); if (bx.Y1 > bx.Y2) then Swap(bx.Y1, bx.Y2); end; Result := Point(Round(bx.X1 + ((bx.X2 - bx.X1) div 2)), Round(bx.Y1 + ((bx.Y2 - bx.Y1) div 2))); end;

    function explodeBox(bx: TBox; rows, columns: integer): TBoxArray; var r, c, w, h, ew, eh, ow, oh, i, x, y: integer; begin if ((rows > 0) and (columns > 0) and(bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then begin w := ((bx.X2 - bx.X1) + 1); h := ((bx.Y2 - bx.Y1) + 1); if (rows < 1) then rows := 1 else if (rows > h) then rows := h; if (columns < 1) then columns := 1 else if (columns > w) then columns := w; w := (w div columns); h := (h div rows); ew := (((bx.X2 - bx.X1) + 1) - (w * columns)); eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows)); SetLength(result, (rows * columns)); y :=bx.Y1;for r := 0 to (rows - 1) do begin x := bx.X1; if ((eh > 0) and (r < eh)) then oh := 1 else oh := 0; for c := 0 to (columns - 1) do begin if ((ew > 0) and (c < ew)) then ow := 1 else ow := 0; i := ((r * columns) + c); result[i].X1 := x; result[i].X2 := (x + (w - 1) + ow); result[i].Y1 := y; result[i].Y2 := (y + (h - 1) + oh); x := (Result[i].X2 + 1); end;y := (result[i].Y2 + 1); end; end else SetLength(result, 0); end;

    function isText(Text, theText: TStringArray): Boolean;
    var
      i, k: Integer;
    begin
      for i := 0 to High(Text) do
        for k := 0 to high(theText) do
          if (Pos(Text[i], TheText[k]) > 0) then
            exit(true);
    end;

    function getOptions(): Array of TOptions;
    var
       B, BB: TBox;
       TPA, restpa, blacktpa, newtpa, merged: TPointArray;
       ATPA, tempatpa, blackatpa, newatpa: T2DPointArray;
       I, L, target, bmp, w, h: Integer;
       BoxColors: TIntegerArray;
    begin
      target := GetImageTarget;
      GetClientDimensions(B.X2, B.Y2);
      B := IntToBox(0, 0, B.X2-1, B.Y2-1);
      BoxColors := [4674653];
      SetLength(ATPA, Length(BoxColors));
      FindColors(tpa, 4674653, b);
      If Length(tpa) < 100 Then
        exit;
      atpa := clusterTpa(tpa, 3);
      for i := 0 to High(ATPA) do
      begin
        B := GetTPABounds(ATPA[i]);
        if ((B.x2-B.x1) > 95) and ((B.y2-B.y1) > 18) then
          Break
        else
          B := IntToBox(0, 0, 0, 0);
      end;
      If (B.x2 = 0) then
        exit;
      findcolors(blacktpa, 0, b);
      if (length(blacktpa) < 1) then
        exit;
      blackatpa := clustertpa(blacktpa, 1);
      for i := 0 to high(blackatpa) do
      begin
        b := gettpaBounds(blackatpa[i]);
         if ((B.x2-B.x1) > 95) and ((B.y2-B.y1) > 16) then
           break
        else
          b := inttobox(0, 0, 0, 0);
      end;
      findcolors(newtpa, 4674653, b);
      if (length(newtpa) < 0) then
        exit;
      newatpa := clustertpa(newtpa, 1);
      b := gettpaBounds(newatpa[0]);
      findcolors(blacktpa, 0, b);
      merged := mergeAtpa([blacktpa, newtpa]);
      ReturnPointsNotInTPAWrap(merged, b, resTPA);
      bmp := CreateBitmap(b.X2-B.X1+2, b.Y2-b.Y1+2);
      OffsetTPA(restpa, Point(-B.X1, -B.Y1));
      FastDrawClear(bmp, 0);
      DrawTPABitmap(bmp, restpa, clRed);//Text
      GetbitmapSize(bmp, w, h);
      settargetbitmap(bmp);
      SetLength(newatpa, H div 16);
      for i := 0 to High(newatpa) do
        FindColorsTolerance(newatpa[i], 255, 0, 2+i*15,  W-1, 15+i*15, 0);
      L := High(newatpa);
      SortATPAFromFirstPointY(newatpa, Point(w div 2,0));
      SetArrayLength(Result, Length(newatpa));
      Result[0].BigBox := b;
      for i := 0 to high(newatpa) do
      begin
        TPA := newatpa[i];
        tempatpa := SplitTPAEx(TPA, 1, 10);
        SortATPAFromFirstPointX(tempatpa, Point(0, 0));
        Result[i].Str := GetTextATPA(tempatpa, 4, 'UpChars07'); //Writeln(Result[i].Str);
        BB := GetTPABounds(newatpa[i]);
        Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
        setlength(tempatpa,0);
        setlength(TPA,0);
      end;
      SetImageTarget(target);
      FreeBitmap(bmp);
    end;

    function ArrInStr(arrS: TStringArray; str: string): Boolean;
    var
      I, L, H: Integer;
    begin
      Result := True;
      L := Low(arrS);    H := High(arrS);
      for I := L to H do
        if Pos(arrS[I], Str) > 0 then
          Exit;
      Result := False;
    end;

    function chooseOptionMulti(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
    var
       B: TBox;
       i, H, x, R: Integer;
       T: TPoint;
       Options: array of TOptions;
    begin
      Result := False;
      Options := getOptions();
      if (Length(Options) < 1) then
        Exit;
      H := High(Options);
      for i := 0 To H do
      begin
        if ArrInStr(Texts, Options[i].Str) then
        begin
          Result := True;
          B := Options[i].Bounds;
          GetMousePos(T.x, T.y);

          R:= Min(((B.X2 - B.X1) shr 1), 5);
          case Action of
            ClickLeft:
              if PointInBox(T, B) then
                ClickMouse2(mouse_left)
              else
                Mouse(intToBox(B.x1 + R, B.Y1, B.x2 - R, B.Y1 + 5).getMiddle(), mouse_Left);

            Move:
              if not PointInBox(T, B) then
                Mouse(intToBox(B.x1 + R, B.Y1, B.x2 - R, B.Y1 + 5).getMiddle(), mouse_move);

            Nothing:
              begin
              end;

            else
              writeLn('ChooseOptionMultiEx ', ' ClickRight not a valid click for RS menus!');
          end;
          Exit;
        end;
      end;
      B := Options[0].BigBox;
      if Action <> Nothing then
      begin
        x := Max(B.X1 - 52, 0);
        if x = 0 then
          x := B.X2+10;
        MoveMouse(0, 0);
        Wait(200 + Random(100));
      end;
    end;

    function chooseOptionMulti(Txt: TStringArray): Boolean; overload;
    begin
      Result := chooseOptionMulti(Txt, 'All', ClickLeft);
    end;

    function chooseOption2(Txt, TextType: string): Boolean;
    begin
      Result := chooseOptionMulti([Txt], TextType, ClickLeft);
    end;

    function chooseOption2(Txt: String): Boolean; overload;
    begin
      Result := chooseOptionMulti([Txt], 'All', ClickLeft);
    end;

    function waitOptionMulti(S: TStringArray; TextType: string; Action: fnct_ActionOptions; Time: Integer): Boolean;
    var
      T: Integer;
    begin
      Result := False;
      T := GetSystemTime + Time;
      while (GetSystemTime < T) do
      begin
        if (chooseOptionMulti(S, TextType, Action)) then
          exit(true);
        Wait(20 + Random(10));
      end;
    end;

    function waitOptionMulti(S: TStringArray; Time: Integer): Boolean; overload;
    begin
      Result := waitOptionMulti(S, 'all', ClickLeft, Time);
    end;

    function waitOption(S: string; Time: Integer): Boolean; overload;
    begin
      Result := waitOptionMulti([s], 'all', ClickLeft, Time);
    end;

    procedure initInv();
    begin
      slots := explodeBox(bounds, 7, 4);
    end;

    function getSlot(slot:integer):Tbox;
    begin
      result := slots[slot];
    end;

    function slotFull(s:Integer):Boolean;
    var
      xee, yee:integer;
    begin
      result := FindColor(xee, yee, 65536, slots[s]);
    end;

    function Inventorycount:Integer;
    var
      i:Integer;
    begin
      for i := 0 to high(slots) do
        if slotFull(i) then
          result := result + 1;
    end;

    function Inventoryfull:Boolean;
    begin
      result := false;
      exit(inventorycount = 28);
    end;

    procedure interactItem(constref slot, Button:Integer);
    begin
      if (slotFull(slot)) then
        mouse(boxCenter(slots[slot]).x, boxCenter(slots[slot]).y, 0, 0, BUTTON);
    end;

    function InventoryDTMExists2(const DTM, slot:integer):boolean;
    var
      x, y:integer;
    begin
      try
      result := findDTM(DTM, x, y, slots[slot].X1, slots[slot].y1, slots[slot].x2, slots[slot].y2);
      except
        writeln('[ERROR] function InventoryDTMExists(const DTM, slot:integer):boolean;');
        writeln('Slots length:', length(slots));
       // writeln('Current slot:', self.slots[slot]);
        writeln('DTM:',DTM);
        terminateScript();
        //printexception;
      end;
    end;

    function InventorycountDTM(const DTMSearch:Integer):Integer;
    var
      i:Integer;
    begin
      for i := 0 to high(slots) do
        if (InventoryDTMExists2(dtmSearch, i)) then
          result := result + 1;
    end;

    function InventorycountDTM(const DTMSearch:TIntegerArray):integer; overload;
    var
      i:integer;
    begin
      for i := 0 to high(DTMSearch) do
        result := result + InventorycountDTM(DTMsearch[i]);
    end;

    function InventorysearchDTM(const DTMSearch:Integer;click, cont:Boolean;button:Integer):Boolean;
    var
      i:Integer;
    begin
      for i := 0 to high(slots) do
      begin
        if InventoryDTMExists2(dtmSearch, i) then
        begin
          result := true;
          if click then
            interactItem(i, button);
          if not cont then
            exit;
        end;
      end;
    end;

    function InventorysearchDTM(const DTMSearch:Integer;cont:Boolean;button:Integer):Boolean; overload;
    var
      I:Integer;
    begin
      result := false;
      for i := 0 to high(slots) do
      begin
      if InventoryDTMExists2(dtmSearch, i) then
        begin
          result := true;
          interactItem(i, button);
          if not cont then
            exit;
        end;
      end;
    end;

    function InventorysearchDTM(const DTMSearch:Integer;button:Integer):Boolean; overload;
    var
      I, x, y:Integer;
    begin
      result := false;
      for i := 0 to high(slots) do
      begin
        if InventoryDTMExists2(dtmSearch, i) then
        begin
          interactItem(i, button);
          exit(true);
        end;
      end;
    end;

    function InventorysearchDTM(const DTMSearch:TIntegerarray;button:Integer):boolean; overload;
    var
      i:integer;
    begin
      for i := 0 to high(DTMSearch) do
        if InventorysearchDTM(DTMSearch[i], true, false, 1) then
          exit(true);
    end;

    function string.contains(s: string): Boolean;
    begin
      if ((self <> '') and (s <> '')) then
        result := (pos(s, self) > 0)
      else
        result := False;
    end;

    function activateRsClient(firstTime:boolean):boolean;
    var
      processes: TSysProcArr;
      i: integer;
    begin
      result := false;
      processes := GetProcesses();
      if (firstTime) then
        writeln('Scanning for ' , CLIENTNAME , 'Client..');
      for i := 0 to high(processes) do
        if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
        begin
          if (firstTime) then
          begin
            writeln('Found client');
            writeln('Target set to: ' , toStr(processes[i]));
          end;
          rsClient := processes[i];
          setTarget(processes[i]);
          ActivateClient();
          exit(true);
        end;
    end;

    function getClientName():string;
    begin
      activateRsClient(false);
      result := rsClient.title;
    end;

    function isLoggedIn():boolean; override;
    begin
      if (USERNAME = '') then
      begin
        writeln('Please enter a username at the top of the script');
        terminateScript();
      end else
        result := getClientName().contains(USERNAME);
    end;

    function loginPlayer():boolean;
    begin
      writeln('logging in player');
    end;

    function dialogOpen():boolean;
    var
      textColorCount:integer;
    begin
      textColorCount := countColorTolerance(dialogColor, intToBox(152, 404, 376, 425), 0, colorSetting(1, 0.00, 0.00));
      result := inRange(textColorCount, textColorCount * (1.00 - dialogTolerance), textColorCount * (1.00 + dialogTolerance));
    end;

    function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
    var
      textTPA:TPointArray;
      textATPA, textATPAS:T2DPointArray;
      i:integer;
      textStr:string;
    begin
      setLength(textATPAS, length(colors));
      for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
      textTPA := mergeATPA(textATPAS);
      textATPA := SplitTPAEx(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textATPA, 3, font);
    end;

    function bankOpen():boolean;
    var
      getStr:string;
    begin
      getStr := getSimpleText([2070783], 180, 65, 312, 84, 'UpChars07');
      result := getStr.contains('Runique') or getStr.contains('Bank of');
    end;

    procedure bankAll();
    begin
      if bankOpen() then
        mouse(Point(356, 348), 1);
    end;

    procedure closeBank();
    begin
      if bankOpen() then
        mouse(Point(491, 75), 1);
    end;

    function findBank():boolean;
    var
      brownTPA, silverTPA:TPointArray;
      brownATPA, silverATPA:T2DPointArray;
      P:TPoint;
      i:integer;
    begin
      if findColorstolerancE(brownTPA, 6057341, intToBox(4, 47, 520, 384), 16, colorSetting(2, 0.05, 0.70)) then
      begin
        brownATPA := clusterTPA(brownTPA, 10);
        filterTPAsbetween(brownATPA, 0, 500);
        for i := 0 to high(brownATPA) do
          if findColorsTolerance(silverTPA, 11250613, brownATPA[i].getBounds(), 14, colorSetting(2, 0.15, 0.11)) then
          begin
            silverATPA := clusterTPA(silverTPA, 10);
            for i := 0 to high(silverATPA) do
            begin
              p := silverATPA[i].getBounds().getMiddle();
              mouse(p, 0);
              if waitOption('Use', 1000) then
                if waitFunc(@bankOpen, 40, 1500) then
                  exit(true)
              else
              begin
                mouse(Point(0, 0), 0);
                wait(100);
              end;
            end;
            //debugATPABounds2(silverATPA);
          end;
      end;
    end;

    procedure cleanHerbs;
    var
      T:TTimeMarker;
    begin
      T.start();
      repeat
        inventorysearchDTM(dirtyHerb, true, mouse_left);
        wait(random(100));
        if (not isLoggedIn()) then
          exit;
      Until (T.getTotalTime() > 60000) or (inventorycountDTM(dirtyHerb) = 0);
    end;

    procedure mixPotions;
    var
      T:TTimeMarker;
    begin
      closeBank();
      T.start();
      if inventorysearchDTM(ingr_1, false, mouse_left) then
        if inventorysearchDTM(ingr_2, false, mouse_left) then
          if waitFunc(@dialogOpen, 40, 2500) then
          begin
            mouse(Point(267, 456), mouse_right);
            if waitOption('ake All', 600) then
            repeat
              wait(50);
              if (not isLoggedIn()) then
                exit;
            Until ((inventorycountDTM(ingr_1) = 0) or (inventorycountDTM(ingr_2) = 0) or (inventorycountDTM(finished_product) = 14) or (T.getTotalTime() > 200000));
          end;
    end;

    function findBankDTM(searchFor:integer):boolean;
    var
      fx, fy:integer;
    begin
      if (not bankOpen()) then
        exit(false)
      else begin
        if findDTM(searchFor, fx, fy, 34, 123, 470, 160) then
        begin
          moveMouse(fx + random(3), fy + random(3));
          wait(200);
          clickMouse2(mouse_right);
          wait(200);
          exit(true);
        end;
      end;
    end;

    procedure teleport(toWhere:string);
    begin
    end;

    procedure withDraw();
    var
      mx, my:integer;
    begin
      if (inventorycount() > 0) then
        bankAll();
      wait(150);
      if (TASK = 'clean') then
      begin
        if findBankDTM(dirtyHerb) then
        begin
          waitOption('draw All', 850);
          wait(200);
        end;
      end else if (TASK = 'mix') then
      begin
        if findBankDTM(ingr_1) then
          if (not waitOption('draw 14', 850)) then
          begin
            wait(350);
            if findBankDTM(ingr_1) then
            begin
              if (not waitOption('draw X', 850)) then
                exit
              else
                wait(1000);
                typeSend('14');
                wait(500);
            end;
          end;
        if findBankDTM(ingr_2) then
      begin
        waitOption('draw 14', 750);
        wait(500);
      end;
      end;

    end;

    procedure loadDTMs;
    begin
      dirtyHerb := DTMFromString(dirtyHerbDTM);
      cleanHerb := DTMFromString(cleanHerbDTM);
      ingr_1 := DTMFromString(ingr_1DTM);
      ingr_2 := DTMFromString(ingr_2DTM);
      finished_product := DTMFromString(finished_productDTM);
    end;

    procedure free;
    begin
      freeDTM(dirtyHerb);
      freeDTM(cleanHerb);
      freeDTM(ingr_1);
      freeDTM(ingr_2);
      freeDTM(finished_product);
    end;

    begin
      loadDTMs;
      addOnTerminate('free');
      activateRsClient(true);
      bounds := IntTobox(567, 259, 722, 506);
      initInv();
      repeat
        wait(100);
        if (not isLoggedIn) then
          if (not loginPlayer()) then
          begin
            writeln('Did not login player waiting . . . ');
            wait(4000);
          end;
        closeBank();
        case TASK of
          'clean':
          begin
            if (inventorycountDTM(dirtyHerb) = 28) then
              cleanHerbs
            else begin
              if findBank() then
                withDraw()
              else
                telePort('');
            end;
          end;
          'mix':
          begin
            if (inventorycountDTM(ingr_1) + inventorycountDTM(ingr_2) <> 28) then
            begin
              if findBank() then
                withDraw()
              else
                telePort('');
            end else
              mixPotions;
          end;
        end;
      Until (isKeydown(113));
    end.
    @Joopi; @Brandon;

  11. #11
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    There is a memory leak somewhere... when I add longer waits to the loops it takes longer for it to error out



    Source of the memory leak:

    Simba Code:
    function activateRsClient(firstTime:boolean):boolean;
    var
      processes: TSysProcArr;
      i: integer;
    begin
      result := false;
      processes := GetProcesses();
      if (firstTime) then
        writeln('Scanning for ' , CLIENTNAME , 'Client..');
      for i := 0 to high(processes) do
        if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
        begin
          if (firstTime) then
          begin
            writeln('Found client');
            writeln('Target set to: ' , toStr(processes[i]));
          end;
          rsClient := processes[i];
          setTarget(processes[i]);
          ActivateClient();
          exit(true);
        end;
    end;

    function getClientName():string;
    begin
      activateRsClient(false);
      result := rsClient.title;
    end;

    function isLoggedIn():boolean; override;
    begin
      if (USERNAME = '') then
      begin
        writeln('Please enter a username at the top of the script');
        terminateScript();
      end else
        result := getClientName().contains(USERNAME);
    end;


    Changed to:

    Simba Code:
    function activateRsClient(firstTime:boolean):boolean;
    var
      processes: TSysProcArr;
      i: integer;
    begin
      result := false;
      processes := GetProcesses();
      if (firstTime) then
        writeln('Scanning for ' , CLIENTNAME , 'Client..');
      for i := 0 to high(processes) do
        if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
        begin
          if (firstTime) then
          begin
            writeln('Found client');
            writeln('Target set to: ' , toStr(processes[i]));
          end;
          rsClient := processes[i];
          setTarget(processes[i]);
          ActivateClient();
          exit(true);
        end;
    end;

    function isLoggedIn():boolean; override;
    begin
      if (USERNAME = '') then
      begin
        writeln('Please enter a username at the top of the script');
        terminateScript();
      end else
        result := rsClient.title.contains(USERNAME);
    end;

  12. #12
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by rj View Post
    There is a memory leak somewhere... when I add longer waits to the loops it takes longer for it to error out
    Maybe I'm blind but those two snippets seem to be the exact same with getClientName missing..

    As for the leak. Maybe you have to do:

    Simba Code:
    FreeTarget(SetTarget(processes[i]));
    I am Ggzz..
    Hackintosher

  13. #13
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Maybe I'm blind but those two snippets seem to be the exact same with getClientName missing..

    As for the leak. Maybe you have to do:

    Simba Code:
    FreeTarget(SetTarget(processes[i]));
    getClientName reset the target everytime

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
  •