Changeset 41


Ignore:
Timestamp:
Apr 18, 2019, 4:39:53 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Use fgl generics if possible.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UDebugForm.lfm

    r39 r41  
    11object DebugForm: TDebugForm
    2   Left = 243
     2  Left = 453
    33  Height = 300
    4   Top = 32
    5   Width = 400
     4  Top = 543
     5  Width = 613
    66  Caption = 'Debug'
    77  DesignTimePPI = 120
  • trunk/Forms/UDebugForm.pas

    r30 r41  
    11unit UDebugForm;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
  • trunk/Forms/UGameResultForm.pas

    r30 r41  
    11unit UGameResultForm;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
  • trunk/Forms/UMainForm.pas

    r38 r41  
    11unit UMainForm;
    22
    3 {$mode Delphi}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
  • trunk/Forms/UMapForm.pas

    r24 r41  
    11unit UMapForm;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
  • trunk/Forms/UNewGameForm.pas

    r38 r41  
    11unit UNewGameForm;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
  • trunk/Languages/Tunneler.cs.po

    r39 r41  
    1212"X-Generator: Poedit 2.2\n"
    1313
    14 #: tdebugform.debugform.caption
     14#: tdebugform.caption
     15#, fuzzy
     16msgctxt "tdebugform.caption"
    1517msgid "Debug"
    1618msgstr "Ladění"
    17 
    18 #: tdebugform.listview1.columns[0].caption
    19 msgctxt "TDEBUGFORM.LISTVIEW1.COLUMNS[0].CAPTION"
    20 msgid "Player"
    21 msgstr "Hráč"
    22 
    23 #: tdebugform.listview1.columns[1].caption
    24 msgid "Frame size"
    25 msgstr "Velikost rámce"
    26 
    27 #: tdebugform.listview1.columns[2].caption
    28 msgid "Bullets"
    29 msgstr "Kulky"
    30 
    31 #: tform1.caption
    32 msgid "Form1"
    33 msgstr "Form1"
    3419
    3520#: tgameresultform.caption
    3621msgid "Game result"
    3722msgstr "VÃœsledek hry"
    38 
    39 #: tgameresultsform.gameresultsform.caption
    40 msgid "Final results"
    41 msgstr "Končené vÃœsledky"
    4223
    4324#: tmainform.aabout.caption
     
    152133msgstr "%0:s z %1:s"
    153134
    154 #: uthreading.scurrentthreadnotfound
    155 msgid "Current thread ID %d not found in virtual thread list."
    156 msgstr "Aktuální vlákno ID %s nenalezeno v seznamu virtuálních vláken."
  • trunk/UCore.pas

    r36 r41  
    11unit UCore;
    22
    3 {$mode Delphi}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
     
    88  Dialogs, Classes, SysUtils, Graphics, SpecializedMatrix, SpecializedList,
    99  IntfGraphics, FPImage, LCLType, SpecializedBitmap, GraphType, Math, URectangle,
    10   Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, UAudioSystemMPlayer,
    11   XMLConf, DOM;
     10  Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, XMLConf, DOM, fgl;
    1211
    1312const
     
    7170  { TTanks }
    7271
    73   TTanks = class(TListObject)
     72  TTanks = class(TFPGObjectList<TTank>)
    7473    procedure Assign(Source: TTanks);
    7574  end;
     
    148147  { TPlayers }
    149148
    150   TPlayers = class(TListObject)
     149  TPlayers = class(TFPGObjectList<TPlayer>)
    151150    Engine: TEngine;
     151    function AddNew: TPlayer;
    152152    procedure Assign(Players: TPlayers);
    153153    procedure LoadConfig(Config: TXMLConfig; Path: string);
     
    163163    Diggable: Boolean;
    164164    Blocking: Boolean;
     165  end;
     166
     167  { TMatters }
     168
     169  TMatters = class(TFPGObjectList<TMatter>)
     170    function AddNew: TMatter;
    165171  end;
    166172
     
    175181    Engine: TEngine;
    176182    Surface: TMatrixByte;
    177     Matter: TListObject; // TListObject<TMatter>
     183    Matters: TMatters;
    178184    procedure Generate;
    179185    constructor Create;
     
    229235    Keyboard: TKeyboard;
    230236    World: TWorld;
    231     PlayerPool: TPlayers; // TListObject<TPlayer>
    232     Players: TPlayers; // TListObject<TPlayer>
     237    PlayerPool: TPlayers;
     238    Players: TPlayers;
    233239    DigMasks: TListObject; // TListObject<TMatrixByte>
    234240    Lock: TCriticalSection;
     
    283289end;
    284290
     291{ TMatters }
     292
     293function TMatters.AddNew: TMatter;
     294begin
     295  Result := TMatter.Create;
     296  Add(Result);
     297end;
     298
    285299{ TTanks }
    286300
     
    298312
    299313{ TPlayers }
     314
     315function TPlayers.AddNew: TPlayer;
     316begin
     317  Result := TPlayer.Create;
     318  Add(Result);
     319end;
    300320
    301321procedure TPlayers.Assign(Players: TPlayers);
     
    407427begin
    408428  // Space
    409   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     429  with Matters.AddNew do begin
    410430    Kind := mkSpace;
    411431    Color := clBlack;
     
    413433  end;
    414434  // Dirt1
    415   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     435  with Matters.AddNew do begin
    416436    Kind := mkDirt;
    417437    Color := $0756b0;
     
    420440  end;
    421441  // Dirt2
    422   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     442  with Matters.AddNew do begin
    423443    Kind := mkDirt;
    424444    Color := $2170c3;
     
    427447  end;
    428448  // Rock
    429   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     449  with Matters.AddNew do begin
    430450    Kind := mkRock;
    431451    Color := TColor($9a9a9a);
     
    434454  end;
    435455  // Bullet1
    436   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     456  with Matters.AddNew do begin
    437457    Kind := mkBullet;
    438458    Color := clRed;
     
    440460  end;
    441461  // Bullet2
    442   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     462  with Matters.AddNew do begin
    443463    Kind := mkBullet;
    444464    Color := clRed;
     
    446466  end;
    447467  // Border
    448   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     468  with Matters.AddNew do begin
    449469    Kind := mkBorder;
    450470    Color := clNavy;
     
    453473
    454474  // Player 1 cannon
    455   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     475  with Matters.AddNew do begin
    456476    Kind := mkTankBody;
    457477    Color := clYellow;
     
    460480  end;
    461481  // Player 1 home
    462   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     482  with Matters.AddNew do begin
    463483    Kind := mkHome;
    464484    Color := TColor($00ff00);
     
    467487  end;
    468488  // Player 1 body1
    469   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     489  with Matters.AddNew do begin
    470490    Kind := mkTankBody;
    471491    Color := TColor($00ff00);
     
    474494  end;
    475495  // Player 1 body2
    476   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     496  with Matters.AddNew do begin
    477497    Kind := mkTankBody;
    478498    Color := TColor($00a000);
     
    482502
    483503  // Player 2 cannon
    484   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     504  with Matters.AddNew do begin
    485505    Kind := mkTankBody;
    486506    Color := clYellow;
     
    489509  end;
    490510  // Player 2 home
    491   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     511  with Matters.AddNew do begin
    492512    Kind := mkHome;
    493513    Color :=  TColor($ff2c2c);
     
    496516  end;
    497517  // Player 2 body1
    498   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     518  with Matters.AddNew do begin
    499519    Kind := mkTankBody;
    500520    Color := TColor($ff2c2c);
     
    503523  end;
    504524  // Player 2 body2
    505   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     525  with Matters.AddNew do begin
    506526    Kind := mkTankBody;
    507527    Color := TColor($b60000);
     
    511531
    512532  // Player 3 cannon
    513   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     533  with Matters.AddNew do begin
    514534    Kind := mkTankBody;
    515535    Color := clYellow;
     
    518538  end;
    519539  // Player 3 home
    520   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     540  with Matters.AddNew do begin
    521541    Kind := mkHome;
    522542    Color :=  TColor($0000ff);
     
    525545  end;
    526546  // Player 3 body1
    527   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     547  with Matters.AddNew do begin
    528548    Kind := mkTankBody;
    529549    Color := TColor($0000ff);
     
    532552  end;
    533553  // Player 3 body2
    534   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     554  with Matters.AddNew do begin
    535555    Kind := mkTankBody;
    536556    Color := TColor($0000a0);
     
    540560
    541561  // Player 4 cannon
    542   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     562  with Matters.AddNew do begin
    543563    Kind := mkTankBody;
    544564    Color := clYellow;
     
    547567  end;
    548568  // Player 4 home
    549   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     569  with Matters.AddNew do begin
    550570    Kind := mkHome;
    551571    Color :=  TColor($ff2cff);
     
    554574  end;
    555575  // Player 4 body1
    556   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     576  with Matters.AddNew do begin
    557577    Kind := mkTankBody;
    558578    Color := TColor($ff2cff);
     
    561581  end;
    562582  // Player 4 body2
    563   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     583  with Matters.AddNew do begin
    564584    Kind := mkTankBody;
    565585    Color := TColor($b600b6);
     
    569589
    570590  // Player 5 cannon
    571   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     591  with Matters.AddNew do begin
    572592    Kind := mkTankBody;
    573593    Color := clYellow;
     
    576596  end;
    577597  // Player 5 home
    578   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     598  with Matters.AddNew do begin
    579599    Kind := mkHome;
    580600    Color := TColor($ffff2c);
     
    583603  end;
    584604  // Player 5 body1
    585   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     605  with Matters.AddNew do begin
    586606    Kind := mkTankBody;
    587607    Color := TColor($ffff2c);
     
    590610  end;
    591611  // Player 5 body2
    592   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     612  with Matters.AddNew do begin
    593613    Kind := mkTankBody;
    594614    Color := TColor($b6b600);
     
    598618
    599619  // Player 6 cannon
    600   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     620  with Matters.AddNew do begin
    601621    Kind := mkTankBody;
    602622    Color := clYellow;
     
    605625  end;
    606626  // Player 6 home
    607   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     627  with Matters.AddNew do begin
    608628    Kind := mkHome;
    609629    Color :=  TColor($2cffff);
     
    612632  end;
    613633  // Player 6 body1
    614   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     634  with Matters.AddNew do begin
    615635    Kind := mkTankBody;
    616636    Color := TColor($2cffff);
     
    619639  end;
    620640  // Player 6 body2
    621   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     641  with Matters.AddNew do begin
    622642    Kind := mkTankBody;
    623643    Color := TColor($00b6b6);
     
    627647
    628648  // Player 7 cannon
    629   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     649  with Matters.AddNew do begin
    630650    Kind := mkTankBody;
    631651    Color := clYellow;
     
    634654  end;
    635655  // Player 7 home
    636   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     656  with Matters.AddNew do begin
    637657    Kind := mkHome;
    638658    Color :=  TColor($008cff);
     
    641661  end;
    642662  // Player 7 body1
    643   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     663  with Matters.AddNew do begin
    644664    Kind := mkTankBody;
    645665    Color := TColor($008cff);
     
    648668  end;
    649669  // Player 7 body2
    650   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     670  with Matters.AddNew do begin
    651671    Kind := mkTankBody;
    652672    Color := TColor($002da0);
     
    656676
    657677  // Player 8 cannon
    658   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     678  with Matters.AddNew do begin
    659679    Kind := mkTankBody;
    660680    Color := clYellow;
     
    663683  end;
    664684  // Player 8 home
    665   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     685  with Matters.AddNew do begin
    666686    Kind := mkHome;
    667687    Color :=  TColor($d0d0d0);
     
    670690  end;
    671691  // Player 8 body1
    672   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     692  with Matters.AddNew do begin
    673693    Kind := mkTankBody;
    674694    Color := TColor($d0d0d0);
     
    677697  end;
    678698  // Player 8 body2
    679   with TMatter(Matter.AddNew(TMatter.Create)) do begin
     699  with Matters.AddNew do begin
    680700    Kind := mkTankBody;
    681701    Color := TColor($707070);
     
    743763  NewSize: TMatrixByteIndex;
    744764begin
    745   Matter := TListObject.Create;
     765  Matters := TMatters.Create;
    746766  InitMatter;
    747767  Surface := TMatrixByte.Create;
     
    754774begin
    755775  FreeAndNil(Surface);
    756   FreeAndNil(Matter);
     776  FreeAndNil(Matters);
    757777  inherited Destroy;
    758778end;
     
    775795      PixelPtr := PixelRowPtr;
    776796      for X := 0 to Bitmap.Width - 1 do begin
    777         P := TMatter(Matter[Surface.ItemsXY[Trunc(X / Bitmap.Width * Surface.Count.X),
     797        P := TMatter(Matters[Surface.ItemsXY[Trunc(X / Bitmap.Width * Surface.Count.X),
    778798            Trunc(Y / Bitmap.Height * Surface.Count.Y)]]).Color;
    779799        PixelPtr^ := SwapBRComponent(P);
     
    970990          with TPlayer(Engine.Players[P]) do
    971991          if (Self.Id <> P) and
    972             (TMatter(Engine.World.Matter[ItemsXY[Pos.X, Pos.Y]]).Kind = mkTankBody) and
    973             (TMatter(Engine.World.Matter[ItemsXY[Pos.X, Pos.Y]]).Player = P) then
     992            (TMatter(Engine.World.Matters[ItemsXY[Pos.X, Pos.Y]]).Kind = mkTankBody) and
     993            (TMatter(Engine.World.Matters[ItemsXY[Pos.X, Pos.Y]]).Player = P) then
    974994            Shield := Shield - 1 / ShieldSteps;
    975995          if StopByDirt then Explosion(LastPos, BulletExplosionRange);
     
    10071027    Fill(CreateIndex(ScreenFrame.Left, ScreenFrame.Top),
    10081028      CreateIndex(ScreenFrame.Right, ScreenFrame.Bottom),
    1009       TMatter(Engine.World.Matter[Integer(miRock)]).Color);
     1029      TMatter(Engine.World.Matters[Integer(miRock)]).Color);
    10101030
    10111031    with Engine.World do
     
    10151035        YY := Y - ScreenFrame.Top - ((ScreenFrame.Bottom - ScreenFrame.Top) div 2) + Position.Y;
    10161036        if (YY >= 0) and (YY < Surface.Count.Y) and (XX >= 0) and (XX < Surface.Count.X) then
    1017           ItemsXY[X, Y] := TMatter(Engine.World.Matter[Surface.ItemsXY[XX, YY]]).Color;
     1037          ItemsXY[X, Y] := TMatter(Engine.World.Matters[Surface.ItemsXY[XX, YY]]).Color;
    10181038      end;
    10191039
     
    10671087    YY := Y + NewPosition.Y - Image.Count.Y div 2;
    10681088    if Image.ItemsXY[X, Y] > 0 then begin
    1069       if TMatter(Matter[Surface.ItemsXY[XX, YY]]).Blocking then
     1089      if TMatter(Matters[Surface.ItemsXY[XX, YY]]).Blocking then
    10701090        Result.Blocking := True;
    1071       if TMatter(Matter[Surface.ItemsXY[XX, YY]]).Diggable then
     1091      if TMatter(Matters[Surface.ItemsXY[XX, YY]]).Diggable then
    10721092        Result.Diggable := True;
    10731093    end;
     
    12781298begin
    12791299  with Config do begin
    1280     Self.Name := GetValue(DOMString(Path + '/Name'), '');
     1300    Self.Name := string(GetValue(DOMString(Path + '/Name'), ''));
    12811301    Color := GetValue(DOMString(Path + '/Color'), 0);
    12821302    Enabled := GetValue(DOMString(Path + '/Enabled'), False);
     
    12931313begin
    12941314  with Config do begin
    1295     SetValue(DOMString(Path + '/Name'), Self.Name);
     1315    SetValue(DOMString(Path + '/Name'), DOMString(Self.Name));
    12961316    SetValue(DOMString(Path + '/Color'), Color);
    12971317    SetValue(DOMString(Path + '/Enabled'), Enabled);
     
    13811401    BytePerRow := RawImage.Description.BytesPerLine;
    13821402    if ClearBackground then begin
    1383       BgColor := TMatter(World.Matter[Integer(miBorder)]).Color;
     1403      BgColor := TMatter(World.Matters[Integer(miBorder)]).Color;
    13841404      BgColor := SwapBRComponent(BgColor);
    13851405      FillDWord(RawImage.Data^, Bitmap.Height * BytePerRow div 4, BgColor);
     
    15401560begin
    15411561  PlayerPool.Clear;
    1542   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1562  with PlayerPool.AddNew do begin
    15431563    Keys.Left := 65;
    15441564    Keys.Down := 83;
     
    15481568    Enabled := True;
    15491569  end;
    1550   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1570  with PlayerPool.AddNew do begin
    15511571    Keys.Left := 37;
    15521572    Keys.Down := 40;
     
    15561576    Enabled := True;
    15571577  end;
    1558   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1578  with PlayerPool.AddNew do begin
    15591579    Keys.Left := 76;
    15601580    Keys.Down := 147;
     
    15631583    Keys.Shoot := 191;
    15641584  end;
    1565   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1585  with PlayerPool.AddNew do begin
    15661586    Keys.Left := 100;
    15671587    Keys.Down := 98;
     
    15701590    Keys.Shoot := 105;
    15711591  end;
    1572   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1592  with PlayerPool.AddNew do begin
    15731593    Keys.Left := 0;
    15741594    Keys.Down := 0;
     
    15771597    Keys.Shoot := 0;
    15781598  end;
    1579   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1599  with PlayerPool.AddNew do begin
    15801600    Keys.Left := 0;
    15811601    Keys.Down := 0;
     
    15841604    Keys.Shoot := 0;
    15851605  end;
    1586   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1606  with PlayerPool.AddNew do begin
    15871607    Keys.Left := 0;
    15881608    Keys.Down := 0;
     
    15911611    Keys.Shoot := 0;
    15921612  end;
    1593   with TPlayer(PlayerPool.AddNew(TPlayer.Create)) do begin
     1613  with PlayerPool.AddNew do begin
    15941614    Keys.Left := 0;
    15951615    Keys.Down := 0;
     
    17551775
    17561776procedure TEngine.NewGame;
    1757 var
    1758   I: Integer;
    17591777begin
    17601778  Active := False;
  • trunk/tunneler.lpr

    r39 r41  
    11program tunneler;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55uses
Note: See TracChangeset for help on using the changeset viewer.