Changeset 29 for trunk


Ignore:
Timestamp:
Jan 8, 2017, 10:20:03 PM (8 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:
3 added
3 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

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

    r23 r29  
    1 {$INCLUDE switches.inc}
     1{$INCLUDE Switches.inc}
    22unit AI;
    33
  • trunk/AI/AIProject.lpr

    r23 r29  
    1 {$INCLUDE switches.inc}
     1{$INCLUDE Switches.inc}
    22library AIProject;
    33
  • trunk/AI/CustomAI.pas

    r23 r29  
    1 {$INCLUDE switches.inc}
     1{$INCLUDE Switches.inc}
    22unit CustomAI;
    33
  • trunk/AI/Pile.pas

    r23 r29  
    22  main parts contributed by Rassim Eminli }
    33
    4 {$INCLUDE switches.inc}
     4{$INCLUDE Switches.inc}
    55unit Pile;
    66
  • trunk/AI/ToolAI.pas

    r23 r29  
    1 {$INCLUDE switches.inc}
     1{$INCLUDE Switches.inc}
    22unit ToolAI;
    33
  • 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);
  • trunk/Integrated.lpi

    r27 r29  
    430430        <StackChecks Value="True"/>
    431431      </Checks>
    432       <VerifyObjMethodCallValidity Value="True"/>
    433432    </CodeGeneration>
    434433    <Linking>
  • trunk/LocalPlayer/CityScreen.pas

    r28 r29  
    216216  Back.Height := ClientHeight;
    217217  Template := TBitmap.Create;
    218   LoadGraphicFile(Template, HomeDir + 'Graphics\City', gfNoGamma);
     218  LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'City', gfNoGamma);
    219219  Template.PixelFormat := pf8bit;
    220220  CityMapTemplate := TBitmap.Create;
    221   LoadGraphicFile(CityMapTemplate, HomeDir + 'Graphics\BigCityMap', gfNoGamma);
     221  LoadGraphicFile(CityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'BigCityMap', gfNoGamma);
    222222  CityMapTemplate.PixelFormat := pf8bit;
    223223  SmallCityMapTemplate := TBitmap.Create;
    224   LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics\SmallCityMap',
     224  LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'SmallCityMap',
    225225    gfNoGamma);
    226226  SmallCityMapTemplate.PixelFormat := pf24bit;
  • trunk/LocalPlayer/Draft.pas

    r21 r29  
    66uses
    77  Protocol, ClientTools, Term, ScreenTools, PVSB, BaseWin,
    8   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
    9   ButtonA, ButtonB, Area;
     8
     9  LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
     10  ButtonA,
     11  ButtonB, ButtonBase, Area;
    1012
    1113type
     
    8991  Back.Height := ClientHeight;
    9092  Template := TBitmap.Create;
    91   LoadGraphicFile(Template, HomeDir + 'Graphics\MiliRes', gfNoGamma);
     93  LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'MiliRes', gfNoGamma);
    9294  Template.PixelFormat := pf8bit;
    9395end;
  • trunk/LocalPlayer/Help.pas

    r28 r29  
    66uses
    77  Protocol, ScreenTools, BaseWin, StringTables,
     8
    89  LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    9   ExtCtrls, ButtonB, PVSB, Types;
     10  ExtCtrls, ButtonB, PVSB, ButtonBase, Types;
    1011
    1112const
     
    4041
    4142  THyperText = class(TStringList)
    42   public
    4343    procedure AddLine(s: String = ''; Format: integer = 0; Picpix: integer = 0;
    4444      LinkCategory: integer = 0; LinkIndex: integer = 0);
     
    11691169    List := TStringList.Create;
    11701170    plus := TStringList.Create;
    1171     if FindFirst(HomeDir + 'Graphics\*.credits.txt', $27, sr) = 0 then
     1171    if FindFirst(HomeDir + 'Graphics' + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then
    11721172      repeat
    1173         plus.LoadFromFile(HomeDir + 'Graphics\' + sr.Name);
     1173        plus.LoadFromFile(HomeDir + 'Graphics' + DirectorySeparator + sr.Name);
    11741174        List.AddStrings(plus);
    11751175      until FindNext(sr) <> 0;
     
    12031203  begin
    12041204    List := TStringList.Create;
    1205     List.LoadFromFile(HomeDir + 'Sounds\sound.credits.txt');
     1205    List.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.credits.txt');
    12061206    for i := 0 to List.Count - 1 do
    12071207    begin
     
    19171917        case Link and $FF of
    19181918          1:
    1919              OpenDocument(pchar(HomeDir + 'AI Template\AI development manual.html'));{ *Převedeno z ShellExecute* }
     1919             OpenDocument(pchar(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html'));{ *Převedeno z ShellExecute* }
    19201920          2:
    19211921            OpenURL('http://c-evo.org');{ *Převedeno z ShellExecute* }
  • trunk/LocalPlayer/NatStat.pas

    r21 r29  
    66uses
    77  Protocol, ClientTools, Term, ScreenTools, BaseWin,
    8   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    9   ButtonB, ButtonC, Menus, EOTButton;
     8
     9  LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     10  ButtonBase, ButtonB, ButtonC, Menus, EOTButton;
    1011
    1112type
  • trunk/LocalPlayer/Term.pas

    r28 r29  
    1010  Protocol, Tribes, PVSB, ClientTools, ScreenTools, BaseWin, Messg, ButtonBase,
    1111
    12   LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, Menus,
     12  LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, Menus,
    1313  ExtCtrls, dateutils, Platform,
    14   ButtonB, ButtonC, EOTButton, Area;
     14  ButtonA, ButtonB, ButtonC, EOTButton, Area;
    1515
    1616const
     
    34173417      doinit := false;
    34183418      OpenKey('SOFTWARE\cevo\RegVer9', false);
    3419       try
    3420         if ValueExists('TileWidth') then xxt := ReadInteger('TileWidth') div 2;
    3421         if ValueExists('TileHeight') then yyt := ReadInteger('TileHeight') div 2;
    3422         if ValueExists('OptionChecked') then OptionChecked := ReadInteger('OptionChecked');
    3423         if ValueExists('MapOptionChecked') then MapOptionChecked := ReadInteger('MapOptionChecked');
    3424         if ValueExists('CityMapMask') then CityRepMask := Cardinal(ReadInteger('CityReport'));
    3425       except
    3426         doinit := true;
    3427       end;
     3419      if ValueExists('TileWidth') then xxt := ReadInteger('TileWidth') div 2
     3420        else xxt := 48;
     3421      if ValueExists('TileHeight') then yyt := ReadInteger('TileHeight') div 2
     3422        else yyt := 24;
     3423      if ValueExists('OptionChecked') then OptionChecked := ReadInteger('OptionChecked')
     3424        else OptionChecked := DefaultOptionChecked;
     3425      if ValueExists('MapOptionChecked') then MapOptionChecked := ReadInteger('MapOptionChecked')
     3426        else MapOptionChecked := 1 shl moCityNames;
     3427      if ValueExists('CityMapMask') then CityRepMask := Cardinal(ReadInteger('CityReport'))
     3428        else CityRepMask := Cardinal(not chPopIncrease and not chNoGrowthWarning and
     3429        not chCaptured);
    34283430      CloseKey;
    34293431      if OptionChecked and (7 shl 16) = 0 then
     
    34313433      // old regver with no scrolling
    34323434    end;
    3433     Reg.free;
    3434     if doinit then
    3435     begin
    3436       xxt := 48;
    3437       yyt := 24;
    3438       OptionChecked := DefaultOptionChecked;
    3439       MapOptionChecked := 1 shl moCityNames;
    3440       CityRepMask := Cardinal(not chPopIncrease and not chNoGrowthWarning and
    3441         not chCaptured);
    3442     end;
    3443 
    3444     if FullScreen then
    3445     begin
     3435    Reg.Free;
     3436
     3437    if FullScreen then begin
    34463438      p.Style := $87000000;
    34473439      BorderStyle := bsNone;
     
    34543446      SoundMode := smOnAlt
    34553447    else
    3456       SoundMode := smOn
     3448      SoundMode := smOn;
    34573449  end;
    34583450
     
    49784970    GotoOnly: boolean;
    49794971  begin
    4980     Dist := 0;
    49814972    if ClientMode >= scContact then
    49824973      exit;
  • trunk/LocalPlayer/UnitStat.pas

    r21 r29  
    66uses
    77  Protocol, ClientTools, Term, ScreenTools, BaseWin,
    8   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    9   ButtonB, ButtonC;
     8
     9  LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,
     10  ButtonB,
     11  ButtonBase, ButtonC;
    1012
    1113type
     
    8183  Back.Height := hMax;
    8284  Template := TBitmap.Create;
    83   LoadGraphicFile(Template, HomeDir + 'Graphics\Unit', gfNoGamma);
     85  LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'Unit', gfNoGamma);
    8486  Template.PixelFormat := pf8bit;
    8587end;
  • trunk/ScreenTools.pas

    r28 r29  
    99  {$ENDIF}
    1010  StringTables,
    11   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls,
     11  LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls,
    1212  Forms, Menus;
    1313
     
    192192
    193193uses
    194   Directories, Sound, Registry;
     194  Directories, Sound, ButtonBase, ButtonA, ButtonB,
     195
     196  Registry;
    195197
    196198var
     
    384386procedure ApplyGamma(Start, Stop: pbyte);
    385387begin
    386   while Start < Stop do
     388  while integer(Start) < integer(Stop) do
    387389  begin
    388390    Start^ := GammaLUT[Start^];
     
    442444    FirstLine := bmp.ScanLine[0];
    443445    LastLine := bmp.ScanLine[bmp.Height - 1];
    444     if FirstLine < LastLine then
     446    if integer(FirstLine) < integer(LastLine) then
    445447      ApplyGamma(pointer(FirstLine), @LastLine[bmp.Width])
    446448    else
     
    502504    FirstLine := bmp.ScanLine[0];
    503505    LastLine := bmp.ScanLine[bmp.Height - 1];
    504     if FirstLine < LastLine then
     506    if integer(FirstLine) < integer(LastLine) then
    505507      ApplyGamma(pointer(FirstLine), @LastLine[bmp.Width])
    506508    else
     
    620622// X channel = background amp (old Dst content), 128=original brightness
    621623type
    622   TPixel = array [0..2] of Byte;
    623   PPixel = ^TPixel;
     624  TPixel = array [0 .. 2] of Byte;
    624625var
    625626  i, Brightness, test: integer;
    626627  PixelSrc: ^Byte;
    627   PixelDst: PPixel;
     628  PixelDst: ^TPixel;
    628629begin
    629630  {TODO assert(Src.PixelFormat = pf8bit);}
     
    652653  while yDst < h do
    653654  begin
    654     PixelDst := dst.ScanLine[yDst] + 3 * xDst;
    655     PixelSrc := Src.ScanLine[ySrc] + xSrc;
     655    PixelDst := pointer(integer(dst.ScanLine[yDst]) + 3 * xDst);
     656    PixelSrc := pointer(integer(Src.ScanLine[ySrc]) + xSrc);
    656657    for i := 0 to w - 1 do
    657658    begin
     
    672673      else
    673674        PixelDst[0] := test; // Blue
    674       PixelDst := Pointer(PixelDst) + 3;
    675       PixelSrc := Pointer(PixelSrc) + 1;
     675      PixelDst := pointer(integer(PixelDst) + 3);
     676      PixelSrc := pointer(integer(PixelSrc) + 1);
    676677    end;
    677678    inc(yDst);
     
    763764  while y < h do
    764765  begin
    765     Pixel := bmp.ScanLine[y] + 3 * x;
     766    Pixel := pointer(integer(bmp.ScanLine[y]) + 3 * x);
    766767    for i := 0 to w - 1 do
    767768    begin
     
    776777      Pixel[1] := Green;
    777778      Pixel[2] := Red;
    778       Pixel := Pointer(Pixel) + 3;
     779      Pixel := pointer(integer(Pixel) + 3);
    779780    end;
    780781    inc(y);
  • trunk/Start.pas

    r28 r29  
    199199    for I := 0 to nPlOffered - 1 do
    200200    begin
    201       if i = 0 then
    202         s := ':StdIntf'
    203       else
    204         s := 'StdAI';
     201      if i = 0 then s := ':StdIntf'
     202        else s := 'StdAI';
    205203      WriteString('Control' + IntToStr(i), s);
    206204      WriteInteger('Diff' + IntToStr(i), 2);
Note: See TracChangeset for help on using the changeset viewer.