Results 1 to 4 of 4

Thread: Remove a func

  1. #1
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default Remove a func

    I don't know why there are two functions that do the same thing (one built in simba, one in SRL), but I'd suggest one be removed.

    Ex.
    https://github.com/SRL/SRL-5/blob/ma...bol.simba#L896
    Simba Code:
    function IsPointInTPA(Point: TPoint; TPA: TPointArray): Boolean;
    var
      I: LongInt;
    begin
      for I := High(TPA) downto 0 do
        if (TPA[I].X = Point.X) then
          if (TPA[I].Y = Point.Y) then
          begin
            Result:= True;
            Exit;
          end;
    end;

    && ...

    https://github.com/MerlijnWajer/Simb.../tpa.pas#L2082
    Simba Code:
    function PointInTPA(const p: TPoint;const arP: TPointArray): Boolean;
    var
      i, l: Integer;
    begin
      l := High(arP);
      if l < 0 then
        Exit(false);
      Result := True;
      for i := 0 to l do
        if (arP[i].x = p.x) and (arP[i].y = p.y) then
          Exit;
      Result := False;
    end;

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

    Default

    Removing one could break scripts that use it

    Forum account issues? Please send me a PM

  3. #3
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by [J]ustin View Post
    Removing one could break scripts that use it
    Well it'd be easy to re-route one another to a wrapper; however I'm more curious why they both exist (as opposed to -I think- only have a built in one)?

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    From what i can see from the code IsPointInTPA() loops from the last TPA down to the first, while PointInTPA() does it the other way round.

    IsPointInTPA() is probably rarely used since you would want to search from first TPA in most cases, and since it is in the module it's probably slower than using WizzyPlugin: PointInTPA(InvertTPA()) to search from right.

    The best way would be to have an optional param reverse = False but Simba does not support it

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
  •