Results 1 to 5 of 5

Thread: FindFlag2

  1. #1
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default FindFlag2

    I believe there is an issue in FindFlag2. It changes the target temporarily - does some work and then frees the temporary target _before_ restoring the old target. This is not allowed as Simba will temporarily be without a target.

    I'm not sure why this wasn't a problem before, but it caused exceptions on Linux with Lape.

    Below a changed version where the temporary target is stored in 't', the old target is restored and then 't' is freed.

    Please try this before committing as I've only tested it a bit. Although I'm pretty sure it's a safe change.

    Simba Code:
    function FindFlag2(var X, Y: Integer): Boolean;
    var
      KMTarget, ITarget, I, Hi, Map, W, H, t: Integer;
      TPA: TPointArray;
    begin
      Result := False;
      Map := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
      CopyClientToBitmap(Map, MMX1, MMY1, MMX2, MMY2);
      KMTarget := GetKeyMouseTarget;
      ITarget := GetImageTarget;
      SetTargetBitmap(Map);
      GetBitmapSize(Map, W, H);
      FindColors(TPA, 65536, 0, 0, W - 1, H -1);
      FilterPointsDist(TPA, 0, 75.5, W div 2, H div 2);
      Hi := Length(TPA);
      for I := 0 to Hi - 1 do
        if ((FastGetPixel(Map, TPA[I].X - 1, TPA[I].Y - 1) - FastGetPixel(Map, TPA[I].X, TPA[I].Y - 1)) = 6381921) then
        begin
          Result := True;
          X := TPA[I].X + MMX1;
          Y := TPA[I].Y + MMY1;
          Break;
        end;

      t := GetImageTarget;
      SetKeyMouseTarget(KMTarget);
      SetImageTarget(ITarget);
      FreeTarget(t);
      FreeBitmap(Map);
    end;

    PS: It could also just use Freeze, couldn't it?

    E: Also, GetColor() operates on the bitmap as well. So you could use that instead of FastGetPixel.
    Last edited by Wizzup?; 02-12-2012 at 01:49 PM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

  3. #3
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    @Wizzup
    Previous one I had it use freeze. Its about ~ twice as fast that way. But I tested this HELLA amounts the speed doesn't matter anymore for Flag other then when you want to call FlagPresent.

    Idk, either way works - I prefer Freeze but general consensus was saying it gave problems... (only because it was committed wrong couple times, maybe even tampered with when it shouldn't of been)
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  4. #4
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    i think this is the first time i have heard of freeze being used, i know this is a little off topic but what are some good application for freeze?



  5. #5
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Quote Originally Posted by Bonfield View Post
    i think this is the first time i have heard of freeze being used, i know this is a little off topic but what are some good application for freeze?
    For example Flag is moving quite rapidly and FindFlag2 compares the nearby pixels so it would sometimes fail if the flag has moved during the process.
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

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
  •