Results 1 to 6 of 6

Thread: findobj: Warning! You passed a wrong ys to a finder function

  1. #1
    Join Date
    Mar 2012
    Posts
    182
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default findobj: Warning! You passed a wrong ys to a finder function

    For more extensive discussion of this minor issue: http://villavu.com/forum/showthread.php?p=1110192

    This is the error message: Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.

    MasterBB has deduced and even made a Youtube video of the issue here.

    Can someone please take a look at fix the flaw in the function design? Or at least for now disable the warning message that clogs up the message box?

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    If any srl dev says they will use my fix, I can fix it and improve the function. Git is not an option for me atm.
    Working on: Tithe Farmer

  3. #3
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Could anyone test this:
    Simba Code:
    function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
        Tol, Step, xs, ys, xe, ye: Integer): Boolean;
    var
      MidX, MidY, i, j, k, x, y, width, height, HalfWidth, HalfHeight: Integer;
      ColorFound: Boolean;
      SearchBoxes: Array of Array of TBox;
      p: TPointArray;
    begin
      Result := False;

      //check for all the colors
      for i := 0 to (GetArrayLength(Color)-1) do
        if (FindColorSpiralTolerance(cx, cy, Color[i], xs, ys, xe, ye, Tol)) then
        begin
          ColorFound := True;
          Break;
        end;

      if not(ColorFound) then
        Exit; //None of the colors could be found on screen

      //Start coordinates
      MidX := Round((xe - xs) / 2);
      MidY := Round((ye - ys) / 2);

      //width and height in boxes
      Width := Ceil(abs(xe - xs) / 2 / Step - 0.5) * 2 + 1;
      Height := Ceil(abs(ye - ys) / 2 / Step - 0.5) * 2 + 1;

      SetLength(SearchBoxes, Width);

      HalfWidth := Floor(Width / 2);
      HalfHeight := Floor(Height / 2)

      for x := -1 * HalfWidth to HalfWidth do
      begin
        SetLength(SearchBoxes[x + HalfWidth], Height);
        for y := -1 * HalfHeight to HalfHeight do
          SearchBoxes[x + HalfWidth][y + HalfHeight] := IntToBox(
             Max(xs, xs + Round(MidX + ((x - 0.5) * Step))),
             Max(ys, ys + Round(MidY + ((y - 0.5) * Step))),
             Min(xe, xs + Round(MidX + ((x + 0.5) * Step))),
             Min(ye, ys + Round(MidY + ((y + 0.5) * Step))));
      end;

      p := TPAFromBox(IntToBox(0, 0, Width-1, Height-1));
      SortTPAFrom(p, Point(floor(Width / 2), floor(Height / 2)));

      for k := 0 to High(Color) do
        for j := 0 to High(p) do
        begin
          if (FindColorTolerance(cx, cy, Color[k], SearchBoxes[p[j].x][p[j].y].x1,
            SearchBoxes[p[j].x][p[j].y].y1, SearchBoxes[p[j].x][p[j].y].x2,
            SearchBoxes[p[j].x][p[j].y].y2, Tol)) then
          begin
            MMouse(cx, cy, 3, 3);
            If (WaitUptextMulti(Text, 300)) then
            begin
              GetMousePos(cx, cy);
              Result := True;
              Exit;
            end;
          end;
        end;
    end;

    Just replace the function in object.simba
    Working on: Tithe Farmer

  4. #4
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,193
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    If you get a few good test on it I'll put it in my Git and push it. From there it'll be up to the Devs to grab it.

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

  5. #5
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Riwu thought me git. I am able to create a pull request myself now ^^. I got one waiting for you on srl btw.
    Working on: Tithe Farmer

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Working on: Tithe Farmer

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
  •