Changeset 124


Ignore:
Timestamp:
Apr 21, 2018, 11:40:27 AM (7 years ago)
Author:
chronos
Message:
  • Added: Other available AI libraries to AI subdirectory. The game detects new AI libraries by searching subdirectories in AI directory and its specification file .ai.txt. Note that precompiled 32-bit DLLs work only under 32-bit Windows.
Location:
trunk
Files:
49 added
6 deleted
7 edited
20 moved

Legend:

Unmodified
Added
Removed
  • trunk/AI

    • Property svn:ignore deleted
  • trunk/GameServer.pas

    r120 r124  
    185185  Key: string;
    186186  Value: string;
     187  BasePath: string;
     188  AIFileName: string;
    187189begin
    188190  Notify := NotifyFunction;
     
    205207  nBrain := bixFirstAI;
    206208  bixBeginner := bixFirstAI;
    207   if FindFirst(HomeDir + 'AI' + DirectorySeparator + '*.ai.txt', $21, f) = 0 then
    208     repeat
    209       with Brain[nBrain] do
    210       begin
    211         FileName := Copy(f.Name, 1, Length(f.Name) - 7);
    212         DLLName := HomeDir + 'AI' + DirectorySeparator + FileName;
    213         Name := Copy(f.Name, 1, Length(f.Name) - 7);
     209  if FindFirst(HomeDir + 'AI' + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
     210  repeat
     211    if (f.Name <> '.') and (f.Name <> '..') then begin
     212      with Brain[nBrain] do begin
     213        BasePath := HomeDir + 'AI' + DirectorySeparator + f.Name;
     214        FileName := f.Name;
     215        DLLName := BasePath + DirectorySeparator + FileName + '.dll';
     216        AIFileName := BasePath + DirectorySeparator + f.Name + '.ai.txt';
     217        Name := f.Name;
    214218        Credits := '';
    215219        Flags := fMultiple;
     
    217221        Initialized := false;
    218222        ServerVersion := 0;
    219         AssignFile(T, HomeDir + 'AI' + DirectorySeparator + f.Name);
     223        if not FileExists(AIFileName) then
     224          raise Exception.Create(Format('AI specification file %s not found', [AIFileName]));
     225        AssignFile(T, AIFileName);
    220226        Reset(T);
    221227        while not EOF(T) do
     
    237243            bixBeginner := nBrain
    238244          else if Key = '#PATH' then
    239             DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     245            DLLName := BasePath + DirectorySeparator + Value
    240246          {$IFDEF WINDOWS}{$IFDEF CPU32}
    241247          else if Key = '#PATH_WIN32' then
    242             DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     248            DLLName := BasePath + DirectorySeparator + Value
    243249          {$ENDIF}{$ENDIF}
    244250          {$IFDEF WINDOWS}{$IFDEF CPU64}
    245251          else if Key = '#PATH_WIN64' then
    246             DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     252            DLLName := BasePath + DirectorySeparator + Value
    247253          {$ENDIF}{$ENDIF}
    248254          {$IFDEF LINUX}{$IFDEF CPU32}
    249255          else if Key = '#PATH_LINUX32' then
    250             DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     256            DLLName := BasePath + DirectorySeparator + Value
    251257          {$ENDIF}{$ENDIF}
    252258          {$IFDEF LINUX}{$IFDEF CPU64}
    253259          else if Key = '#PATH_LINUX64' then
    254             DLLName := HomeDir + 'AI' + DirectorySeparator + Value
     260            DLLName := BasePath + DirectorySeparator + Value
    255261          {$ENDIF}{$ENDIF}
    256262          else if Key = '#GAMEVERSION' then
     
    272278        ((Brain[nBrain].Flags and fDotNet = 0) or (@DotNetClient <> nil)) then
    273279        inc(nBrain);
    274     until FindNext(f) <> 0;
     280    end;
     281  until FindNext(f) <> 0;
    275282  FindClose(F);
     283
     284  if nBrain = 0 then
     285    raise Exception.Create(Format('No AI libraries found in directory %s', [HomeDir + 'AI']));
    276286end;
    277287
  • trunk/Install/win/C-evo.iss

    r116 r124  
    7070Source: "{#MyAppSubDir}\Language.txt"; DestDir: "{app}"; Flags: ignoreversion
    7171Source: "{#MyAppSubDir}\Language2.txt"; DestDir: "{app}"; Flags: ignoreversion
    72 Source: "{#MyAppSubDir}\AI\lib\x86_64-win64-Release\StdAI.dll"; DestDir: "{app}\AI"; DestName: "StdAI-win64.dll"; Flags: ignoreversion; Check: Is64BitInstallMode
    73 Source: "{#MyAppSubDir}\AI\lib\i386-win32-Release\StdAI.dll"; DestDir: "{app}\AI"; DestName: "StdAI-win32.dll"; Flags: ignoreversion; Check: not Is64BitInstallMode
    74 Source: "{#MyAppSubDir}\AI\StdAI.png"; DestDir: "{app}\AI"; Flags: ignoreversion;
    75 Source: "{#MyAppSubDir}\AI\StdAI.ai.txt"; DestDir: "{app}\AI"; Flags: ignoreversion;
     72Source: "{#MyAppSubDir}\AI\StdAI\lib\x86_64-win64-Release\StdAI.dll"; DestDir: "{app}\AI\StdAI"; DestName: "StdAI-win64.dll"; Flags: ignoreversion; Check: Is64BitInstallMode
     73Source: "{#MyAppSubDir}\AI\StdAI\lib\i386-win32-Release\StdAI.dll"; DestDir: "{app}\AI\StdAI"; DestName: "StdAI-win32.dll"; Flags: ignoreversion; Check: not Is64BitInstallMode
     74Source: "{#MyAppSubDir}\AI\StdAI\StdAI.png"; DestDir: "{app}\AI\StdAI"; Flags: ignoreversion;
     75Source: "{#MyAppSubDir}\AI\StdAI\StdAI.ai.txt"; DestDir: "{app}\AI\StdAI"; Flags: ignoreversion;
    7676Source: "{#MyAppSubDir}\Maps\*.*"; DestDir: "{localappdata}\c-evo\Maps"; Flags: ignoreversion createallsubdirs recursesubdirs comparetimestamp
    7777Source: "{#MyAppSubDir}\Saved\*.*"; DestDir: "{localappdata}\c-evo\Saved"; Flags: ignoreversion createallsubdirs recursesubdirs comparetimestamp
  • trunk/Install/win/build.bat

    r116 r124  
    77rem Build AI
    88SET PROJECTNAME=AIProject
    9 SET MAIN_DLL=..\..\AI\StdAI.dll
    10 SET WIN32_DLL=..\..\AI\lib\i386-win32-Release\StdAI.dll
    11 SET WIN64_DLL=..\..\AI\lib\x86_64-win64-Release\StdAI.dll
     9SET MAIN_DLL=..\..\AI\StdAI\StdAI.dll
     10SET WIN32_DLL=..\..\AI\StdAI\lib\i386-win32-Release\StdAI.dll
     11SET WIN64_DLL=..\..\AI\StdAI\lib\x86_64-win64-Release\StdAI.dll
    1212IF EXIST %MAIN_DLL% del %MAIN_DLL%
    1313IF EXIST %WIN32_DLL% del %WIN32_DLL%
    1414IF EXIST %WIN64_DLL% del %WIN64_DLL%
    1515
    16 %LAZDIR%\lazbuild.exe --lazarusdir=%LAZDIR% --build-mode="Release" --cpu=i386 --operating-system=Win32 ..\..\AI\%PROJECTNAME%.lpi
     16%LAZDIR%\lazbuild.exe --lazarusdir=%LAZDIR% --build-mode="Release" --cpu=i386 --operating-system=Win32 ..\..\AI\StdAI\%PROJECTNAME%.lpi
    1717copy %MAIN_DLL% %WIN32_DLL%
    18 %LAZDIR%\lazbuild.exe --lazarusdir=%LAZDIR% --build-mode="Release" --cpu=x86_64 --operating-system=Win64 ..\..\AI\%PROJECTNAME%.lpi
     18%LAZDIR%\lazbuild.exe --lazarusdir=%LAZDIR% --build-mode="Release" --cpu=x86_64 --operating-system=Win64 ..\..\AI\StdAI\%PROJECTNAME%.lpi
    1919copy %MAIN_DLL% %WIN64_DLL%
    2020
  • trunk/Locale.lfm

    r65 r124  
    88  ClientHeight = 456
    99  ClientWidth = 483
     10  DesignTimePPI = 144
    1011  FormStyle = fsStayOnTop
    1112  OnCreate = FormCreate
     
    1314  OnPaint = FormPaint
    1415  OnShow = FormShow
    15   LCLVersion = '1.6.0.4'
     16  LCLVersion = '1.8.2.0'
    1617  object List: TListBox
    1718    Tag = 15360
     
    3435    TabOrder = 0
    3536    TabStop = False
    36     TopIndex = -1
    3737  end
    3838  object OKBtn: TButtonA
  • trunk/Start.lfm

    r117 r124  
    22  Left = 246
    33  Height = 326
    4   Top = 109
     4  Top = 120
    55  Width = 556
    66  BorderIcons = []
     
    2525  OnPaint = FormPaint
    2626  OnShow = FormShow
    27   LCLVersion = '1.8.0.6'
     27  LCLVersion = '1.8.2.0'
    2828  object StartBtn: TButtonA
    2929    Tag = 15104
  • trunk/Start.pas

    r118 r124  
    336336  for i := bixFirstAI to nBrain - 1 do begin
    337337    BrainPicture[i] := TBitmap.Create;
    338     if not LoadGraphicFile(BrainPicture[i], HomeDir + 'AI' + DirectorySeparator + Brain[i].FileName + '.png',
     338    if not LoadGraphicFile(BrainPicture[i], HomeDir + 'AI' + DirectorySeparator +
     339      Brain[i].FileName + DirectorySeparator + Brain[i].FileName + '.png',
    339340      gfNoError) then begin
    340341      BrainPicture[i].SetSize(64, 64);
Note: See TracChangeset for help on using the changeset viewer.