Changeset 29 for trunk/GameServer.pas


Ignore:
Timestamp:
Jan 8, 2017, 10:20:03 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: Use DirectorySeparator in directory path for platform independence.
  • Fixed: Some warining about incorrect pointer arithmetic.
  • Added: Support for multi-platform AI library name and location.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1111lib
        1212heaptrclog.trc
         13c-evo
  • trunk/GameServer.pas

    r24 r29  
    183183  T: TextFile;
    184184  s: string;
    185 
     185  Key: string;
     186  Value: string;
    186187begin
    187188  Notify := NotifyFunction;
     
    204205  nBrain := bixFirstAI;
    205206  bixBeginner := bixFirstAI;
    206   if FindFirst(HomeDir + '*.ai.txt', $21, f) = 0 then
     207  if FindFirst(HomeDir + 'AI' + DirectorySeparator + '*.ai.txt', $21, f) = 0 then
    207208    repeat
    208209      with Brain[nBrain] do
    209210      begin
    210211        FileName := Copy(f.Name, 1, Length(f.Name) - 7);
    211         DLLName := HomeDir + FileName;
     212        DLLName := HomeDir + 'AI' + DirectorySeparator + FileName;
    212213        Name := Copy(f.Name, 1, Length(f.Name) - 7);
    213214        Credits := '';
     
    216217        Initialized := false;
    217218        ServerVersion := 0;
    218         AssignFile(T, HomeDir + f.Name);
     219        AssignFile(T, HomeDir + 'AI' + DirectorySeparator + f.Name);
    219220        Reset(T);
    220221        while not EOF(T) do
     
    222223          ReadLn(T, s);
    223224          s := trim(s);
    224           if Copy(s, 1, 5) = '#NAME' then
    225             Name := Copy(s, 7, 255)
    226           else if Copy(s, 1, 10) = '#.NET' then
     225          if Pos(' ', S) > 0 then begin
     226            Key := Copy(S, 1, Pos(' ', S) - 1);
     227            Value := Trim(Copy(S, Pos(' ', S) + 1, Length(S)));
     228          end else begin
     229            Key := S;
     230            Value := '';
     231          end;
     232          if Key = '#NAME' then
     233            Name := Value
     234          else if Key = '#.NET' then
    227235            Flags := Flags or fDotNet
    228           else if Copy(s, 1, 9) = '#BEGINNER' then
     236          else if Key = '#BEGINNER' then
    229237            bixBeginner := nBrain
    230           else if Copy(s, 1, 5) = '#PATH' then
    231             DLLName := HomeDir + trim(Copy(s, 7, 255))
    232           else if Copy(s, 1, 12) = '#GAMEVERSION' then
    233             for i := 13 to Length(s) do
    234               case s[i] of
     238          else if Key = '#PATH' then
     239            DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     240          {$IFDEF WINDOWS}{$IFDEF CPU32}
     241          else if Key = '#PATH_WIN32' then
     242            DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     243          {$ENDIF}{$ENDIF}
     244          {$IFDEF WINDOWS}{$IFDEF CPU64}
     245          else if Key = '#PATH_WIN64' then
     246            DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     247          {$ENDIF}{$ENDIF}
     248          {$IFDEF LINUX}{$IFDEF CPU32}
     249          else if Key = '#PATH_LINUX32' then
     250            DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     251          {$ENDIF}{$ENDIF}
     252          {$IFDEF LINUX}{$IFDEF CPU64}
     253          else if Key = '#PATH_LINUX64' then
     254            DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     255          {$ENDIF}{$ENDIF}
     256          else if Key = '#GAMEVERSION' then
     257            for i := 1 to Length(Value) do
     258              case Value[i] of
    235259                '0' .. '9':
    236260                  ServerVersion := ServerVersion and $FFFF00 + ServerVersion and
    237                     $FF * 10 + ord(s[i]) - 48;
     261                    $FF * 10 + ord(Value[i]) - 48;
    238262                '.':
    239263                  ServerVersion := ServerVersion shl 8;
    240264              end
    241           else if Copy(s, 1, 8) = '#CREDITS' then
    242             Credits := Copy(s, 10, 255)
     265          else if Key = '#CREDITS' then
     266            Credits := Value
    243267        end;
    244268        CloseFile(T);
Note: See TracChangeset for help on using the changeset viewer.