Results 1 to 2 of 2

Thread: Flag bug snippet

  1. #1
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Thumbs up Flag bug snippet

    Quite frequently the old-school flag gets jammed at an unreachable location, causing functions like FFlag() and common loops like "while FlagPresent do wait(100)" to cause issues in scripts.

    This function can be used in place of both previously mentioned flag techniques. This function returns true and ends if FlagDistance doesn't change for "maxtime", with a wait of "poll" between measurements. But if the flag doesn't jam, it acts like FFlag and waits until FlagDistance is less than or equal to "FlagDist".

    Simba Code:
    function NebulaFlag(FlagDist, Maxtime, Poll: Integer): boolean;
    var
      tt, q, f: Integer;
      FlagArr: Array of Integer;
      flagGood: boolean;
    Label
      reset;
    begin
      tt:= maxtime;
      marktime(q);
      while (FlagDistance > FlagDist) do
      begin
        FindNormalRandoms;
        SetLength(FlagArr, Length(FlagArr)+1);
        FlagArr[High(FlagArr)] := Flagdistance;
        if (TimeFromMark(q) > tt) then
        begin
          for f:= High(FlagArr) downto (High(FlagArr) - round(maxtime/poll)) do
          begin
            if FlagArr[max(0, f)] <> FlagArr[max(0, f-1)] then
            begin
              flagGood := true;
              break;
            end;
          end;
          if flagGood then
            GoTo reset;
          writeln('flag jammed');
          result := true;
          Exit;
        end;
        reset:
        wait(poll);
      end;
    end;

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

    Default

    Thanks, this may be useful in the SRL include also as sometimes the flag gets stuck

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •