anchor.diff: -unit KM_Utils;
  -{$I KaM_Remake.inc}
  -interface
  -uses
  -  Classes, DateUtils, Math, SysUtils, KM_Defaults, KM_Points, KM_CommonTypes
  -  {$IFDEF MSWindows}
  -  ,Windows
  -  ,MMSystem //Required for TimeGet which is defined locally because this unit must NOT know about KromUtils as it is not Linux compatible (and this unit is used in Linux dedicated servers)
  -  {$ENDIF}
  -  {$IFDEF Unix}
  -  ,unix, baseunix, UnixUtil
  -  {$ENDIF}
  -  ;
  -
  -  function KMGetCursorDirection(X,Y: integer): TKMDirection;
  -
  -  function GetPositionInGroup2(OriginX, OriginY: Word; aDir: TKMDirection; aIndex, aUnitPerRow: Word; MapX, MapY: Word; out aTargetCanBeReached: Boolean): TKMPoint;
  -  function GetPositionFromIndex(aOrigin: TKMPoint; aIndex: Byte): TKMPoint;
  -
  -  function FixDelim(const aString: UnicodeString): UnicodeString;
  -
  -  procedure ConvertRGB2HSB(aR, aG, aB: Integer; out oH, oS, oB: Single);
  -  procedure ConvertHSB2RGB(aHue, aSat, aBri: Single; out R, G, B: Byte);
  -  function MultiplyBrightnessByFactor(aColor: Cardinal; aBrightnessFactor: Single; aMinBrightness: Single = 0; aMaxBrightness: Single = 1): Cardinal;
  -  function ReduceBrightness(aColor: Cardinal; aBrightness: Byte): Cardinal;
  -  function GetPingColor(aPing: Word): Cardinal;
  -  function GetFPSColor(aFPS: Word): Cardinal;
  -  function FlagColorToTextColor(aColor: Cardinal): Cardinal;
  -  function TimeToString(aTime: TDateTime): UnicodeString;
  -  function WrapColor(aText: UnicodeString; aColor: Cardinal): UnicodeString;
  -  function WrapColorA(aText: AnsiString; aColor: Cardinal): AnsiString;
  -  function StripColor(aText: UnicodeString): UnicodeString;
  -  function FindMPColor(aColor: Cardinal): Integer;
  -
  -  procedure ParseDelimited(const Value, Delimiter: UnicodeString; SL: TStringList);
  -
  -  procedure SetKaMSeed(aSeed: Integer);
  -  function GetKaMSeed: Integer;
  -  function KaMRandom:extended; overload;
  -  function KaMRandom(aMax:integer):integer; overload;
  -  function KaMRandomS(Range_Both_Directions:integer):integer; overload;
  -  function KaMRandomS(Range_Both_Directions:single):single; overload;
  -
  -  function TimeGet: Cardinal;
  -  function GetTimeSince(aTime: Cardinal): Cardinal;
  -  function UTCNow: TDateTime;
  -  function UTCToLocal(Input: TDateTime): TDateTime;
  -
  -  function MapSizeIndex(X, Y: Word): Byte;
  -  function MapSizeText(X,Y: Word): UnicodeString;
  -
  -  //Taken from KromUtils to reduce dependancies (required so the dedicated server compiles on Linux without using Controls)
  -  procedure KMSwapInt(var A,B:byte); overload;
  -  procedure KMSwapInt(var A,B:shortint); overload;
  -  procedure KMSwapInt(var A,B:smallint); overload;
  -  procedure KMSwapInt(var A,B:word); overload;
  -  procedure KMSwapInt(var A,B:integer); overload;
  -  procedure KMSwapInt(var A,B:cardinal); overload;
  -
  -  function GetNoColorMarkupText(aText: UnicodeString): UnicodeString;
  -
  -  function DeleteDoubleSpaces(aString: string): string;
  -
  -  function GetMultiplicator(aShift: TShiftState): Word;
  -
  -  //String functions
  +unit KM_Utils;
  +{$I KaM_Remake.inc}
  +interface
  +uses
  +  Classes, DateUtils, Math, SysUtils, KM_Defaults, KM_Points, KM_CommonTypes
  +  {$IFDEF MSWindows}
  +  ,Windows
  +  ,MMSystem //Required for TimeGet which is defined locally because this unit must NOT know about KromUtils as it is not Linux compatible (and this unit is used in Linux dedicated servers)
  +  {$ENDIF}
  +  {$IFDEF Unix}
  +  ,unix, baseunix, UnixUtil
  +  {$ENDIF}
  +  ;
  +
  +  function KMGetCursorDirection(X,Y: integer): TKMDirection;
  +
  +  function GetPositionInGroup2(OriginX, OriginY: Word; aDir: TKMDirection; aIndex, aUnitPerRow: Word; MapX, MapY: Word; out aTargetCanBeReached: Boolean): TKMPoint;
  +  function GetPositionFromIndex(aOrigin: TKMPoint; aIndex: Byte): TKMPoint;
  +
  +  function FixDelim(const aString: UnicodeString): UnicodeString;
  +
  +  procedure ConvertRGB2HSB(aR, aG, aB: Integer; out oH, oS, oB: Single);
  +  procedure ConvertHSB2RGB(aHue, aSat, aBri: Single; out R, G, B: Byte);
  +  function MultiplyBrightnessByFactor(aColor: Cardinal; aBrightnessFactor: Single; aMinBrightness: Single = 0; aMaxBrightness: Single = 1): Cardinal;
  +  function ReduceBrightness(aColor: Cardinal; aBrightness: Byte): Cardinal;
  +  function GetPingColor(aPing: Word): Cardinal;
  +  function GetFPSColor(aFPS: Word): Cardinal;
  +  function FlagColorToTextColor(aColor: Cardinal): Cardinal;
  +  function TimeToString(aTime: TDateTime): UnicodeString;
  +  function WrapColor(aText: UnicodeString; aColor: Cardinal): UnicodeString;
  +  function WrapColorA(aText: AnsiString; aColor: Cardinal): AnsiString;
  +  function StripColor(aText: UnicodeString): UnicodeString;
  +  function FindMPColor(aColor: Cardinal): Integer;
  +
  +  procedure ParseDelimited(const Value, Delimiter: UnicodeString; SL: TStringList);
  +
  +  procedure SetKaMSeed(aSeed: Integer);
  +  function GetKaMSeed: Integer;
  +  function KaMRandom:extended; overload;
  +  function KaMRandom(aMax:integer):integer; overload;
  +  function KaMRandomS(Range_Both_Directions:integer):integer; overload;
  +  function KaMRandomS(Range_Both_Directions:single):single; overload;
  +
  +  function TimeGet: Cardinal;
  +  function GetTimeSince(aTime: Cardinal): Cardinal;
  +  function UTCNow: TDateTime;
  +  function UTCToLocal(Input: TDateTime): TDateTime;
  +
  +  function MapSizeIndex(X, Y: Word): Byte;
  +  function MapSizeText(X,Y: Word): UnicodeString;
  +
  +  //Taken from KromUtils to reduce dependancies (required so the dedicated server compiles on Linux without using Controls)
  +  procedure KMSwapInt(var A,B:byte); overload;
  +  procedure KMSwapInt(var A,B:shortint); overload;
  +  procedure KMSwapInt(var A,B:smallint); overload;
  +  procedure KMSwapInt(var A,B:word); overload;
  +  procedure KMSwapInt(var A,B:integer); overload;
  +  procedure KMSwapInt(var A,B:cardinal); overload;
  +
  +  function GetNoColorMarkupText(aText: UnicodeString): UnicodeString;
  +
  +  function DeleteDoubleSpaces(aString: string): string;
  +
  +  function GetMultiplicator(aShift: TShiftState): Word;
  +
  +  //String functions
     function StrIndexOf(aStr, aSubStr: String): Integer;
     function StrLastIndexOf(aStr, aSubStr: String): Integer;
     function StrSubstring(aStr: String; aFrom, aLength: Integer): String; overload;
  
positive.code:       Result := Result + aString[I];
    end;
  end;
  
  
  function GetMultiplicator(aShift: TShiftState): Word;
  begin
    Result := Byte(aShift = [ssLeft]) + Byte(aShift = [ssRight]) * 10 + Byte(aShift = [ssShift, ssLeft]) * 100 + Byte(aShift = [ssShift, ssRight]) * 1000;
  end;
  
  
  {
  String functions
  These function are replacements for String functions introduced after XE2 (XE5 probably)
  Names are the same as in new Delphi versions, but with 'Str' prefix
  }
  function StrIndexOf(aStr, aSubStr: String): Integer;
  begin
    Result := AnsiPos(aSubStr, aStr) - 1;
  end;
  
  
  
negative.code: 
  function StrSplitToStrArray(aStr, aDelimiters: String): TStringArray;
  var StrArray: TStringDynArray;
      I: Integer;
  begin
    StrArray := SplitString(aStr, aDelimiters);
    SetLength(Result, Length(StrArray));
    for I := Low(StrArray) to High(StrArray) do
      Result[I] := StrArray[I];
  