Changeset 192 for trunk/GameServer.pas


Ignore:
Timestamp:
May 7, 2020, 12:30:04 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
  • Modified: Simplified initialization of brain pictures.
  • Modified: Use GetAiDir function for AI subdirectory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GameServer.pas

    r185 r192  
    122122  Directories, CityProcessing, UnitProcessing, CmdList, LCLIntf, LCLType,
    123123  LMessages, Classes, SysUtils;
     124
     125resourcestring
     126  SNoAiFound = 'No AI libraries found in directory %s';
    124127
    125128var
     
    256259  BrainBeginner := nil;
    257260
    258   if FindFirst(HomeDir + 'AI' + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
     261  if FindFirst(GetAiDir + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
    259262  repeat
    260     BasePath := HomeDir + 'AI' + DirectorySeparator + f.Name;
     263    BasePath := GetAiDir + DirectorySeparator + f.Name;
    261264    if (f.Name <> '.') and (f.Name <> '..') and DirectoryExists(BasePath) then begin
    262265      NewBrain := Brains.AddNew;
     
    272275
    273276  if Brains.GetKindCount(btAI) = 0 then
    274     raise Exception.Create(Format('No AI libraries found in directory %s', [HomeDir + 'AI']));
     277    raise Exception.Create(Format(SNoAiFound, [GetAiDir]));
    275278end;
    276279
     
    45844587constructor TBrain.Create;
    45854588begin
    4586   Picture := nil;
     4589  Picture := TBitmap.Create;
     4590  Picture.SetSize(64, 64);
    45874591end;
    45884592
    45894593destructor TBrain.Destroy;
    45904594begin
    4591   if Assigned(Picture) then Picture.Free;
     4595  FreeAndNil(Picture);
    45924596  inherited Destroy;
    45934597end;
Note: See TracChangeset for help on using the changeset viewer.