Changeset 185


Ignore:
Timestamp:
May 4, 2020, 11:00:56 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GameServer.pas

    r169 r185  
    116116function PreviewMap(lm: integer): pointer;
    117117
     118
    118119implementation
    119120
    120121uses
    121   Directories, CityProcessing, UnitProcessing, CmdList,
    122 
    123   LCLIntf, LCLType, LMessages, Classes, SysUtils;
     122  Directories, CityProcessing, UnitProcessing, CmdList, LCLIntf, LCLType,
     123  LMessages, Classes, SysUtils;
    124124
    125125var
     
    304304  end;
    305305  CreateMap(true);
    306   result := @RealMap;
     306  Result := @RealMap;
    307307end;
    308308
  • trunk/Start.pas

    r183 r185  
    9898    AutoDiff: Integer;
    9999    MultiControl: Integer;
    100     MiniWidth: Integer;
    101     MiniHeight: Integer;
     100    MiniSize: TPoint;
    102101    Page: TStartPage;
    103102    ShowTab: TStartTab;
     
    114113    ListIndex: array [TStartTab] of Integer;
    115114    MapFileName: string;
    116     FormerGames, Maps: TStringList;
     115    FormerGames: TStringList;
     116    Maps: TStringList;
    117117    LogoBuffer, Mini: TBitmap; { game world sample preview }
    118118    MiniColors: array [0 .. 11, 0 .. 1] of TColor;
     
    142142  StartDlg: TStartDlg;
    143143
     144
    144145implementation
    145146
     
    154155  // predefined world size
    155156  // attention: lx*ly+1 must be prime!
    156   { nWorldSize=8;
     157  { MaxWorldSize=8;
    157158    lxpre: array[0..nWorldSize-1] of integer =(30,40,50,60,70,90,110,130);
    158159    lypre: array[0..nWorldSize-1] of integer =(46,52,60,70,84,94,110,130);
    159160    DefaultWorldTiles=4200; }
    160   nWorldSize = 6;
    161   lxpre: array [0 .. nWorldSize - 1] of integer = (30, 40, 50, 60, 75, 100);
    162   lypre: array [0 .. nWorldSize - 1] of integer = (46, 52, 60, 70, 82, 96);
     161  MaxWorldSize = 6;
     162  WorldSizes: array [0 .. MaxWorldSize - 1] of TPoint = ((X: 30; Y:46),
     163    (X: 40; Y:52), (X: 50; Y:60), (X: 60; Y:70), (X: 75; Y:82), (X: 100; Y:96));
    163164  DefaultWorldTiles = 4150;
    164165  DefaultWorldSize = 3;
     
    775776      MainTexture.clBevelShade);
    776777    RisedTextOut(Canvas, 344, y0Mini - 77, Phrases.Lookup('STARTCONTROLS', 5));
    777     s := IntToStr((lxpre[WorldSize] * lypre[WorldSize] * 20 +
     778    s := IntToStr((WorldSizes[WorldSize].X * WorldSizes[WorldSize].Y * 20 +
    778779      DefaultWorldTiles div 2) div DefaultWorldTiles * 5) + '%';
    779780    RisedTextOut(Canvas, 514 - BiColorTextWidth(Canvas, s), y0Mini - 77, s);
     
    826827  if not(Page in [pgMain, pgNoLoad]) then
    827828  begin
    828     xMini := x0Mini - MiniWidth;
    829     yMini := y0Mini - MiniHeight div 2;
    830     Frame(Canvas, xMini, yMini, xMini + 3 + MiniWidth * 2,
    831       yMini + 3 + MiniHeight, MainTexture.clBevelLight,
     829    xMini := x0Mini - MiniSize.X;
     830    yMini := y0Mini - MiniSize.Y div 2;
     831    Frame(Canvas, xMini, yMini, xMini + 3 + MiniSize.X * 2,
     832      yMini + 3 + MiniSize.Y, MainTexture.clBevelLight,
    832833      MainTexture.clBevelShade);
    833     Frame(Canvas, xMini + 1, yMini + 1, xMini + 2 + MiniWidth * 2,
    834       yMini + 2 + MiniHeight, MainTexture.clBevelShade,
     834    Frame(Canvas, xMini + 1, yMini + 1, xMini + 2 + MiniSize.X * 2,
     835      yMini + 2 + MiniSize.Y, MainTexture.clBevelShade,
    835836      MainTexture.clBevelLight);
    836837  end;
     
    838839  if MiniMode = mmPicture then
    839840  begin
    840     BitBlt(Canvas.Handle, xMini + 2, yMini + 2, MiniWidth * 2, MiniHeight,
     841    BitBlt(Canvas.Handle, xMini + 2, yMini + 2, MiniSize.X * 2, MiniSize.Y,
    841842      Mini.Canvas.Handle, 0, 0, SRCCOPY);
    842843    if Page = pgStartRandom then
     
    10011002
    10021003        StartNewGame(GetSavedDir + DirectorySeparator, FileName + CevoExt, MapFileName,
    1003           lxpre[WorldSize], lypre[WorldSize], StartLandMass, MaxTurn);
     1004          WorldSizes[WorldSize].X, WorldSizes[WorldSize].Y, StartLandMass, MaxTurn);
    10041005        UnlistBackupFile(FileName);
    10051006      end;
     
    10201021        end;
    10211022        MapFileName := Format(Phrases.Lookup('MAP'), [MapCount]) + CevoMapExt;
    1022         EditMap(MapFileName, lxpre[WorldSize], lypre[WorldSize], StartLandMass);
     1023        EditMap(MapFileName, WorldSizes[WorldSize].X, WorldSizes[WorldSize].Y, StartLandMass);
    10231024      end
    10241025  end
     
    10321033begin
    10331034  Map := PreviewMap(StartLandMass);
    1034   MiniWidth := lxpre[WorldSize];
    1035   MiniHeight := lypre[WorldSize];
     1035  MiniSize := WorldSizes[WorldSize];
    10361036
    10371037  Mini.PixelFormat := pf24bit;
    1038   Mini.SetSize(MiniWidth * 2, MiniHeight);
     1038  Mini.SetSize(MiniSize.X * 2, MiniSize.Y);
    10391039  Mini.BeginUpdate;
    10401040  MiniPixel.Init(Mini);
    1041   for y := 0 to MiniHeight - 1 do begin
    1042     for x := 0 to MiniWidth - 1 do begin
     1041  for y := 0 to MiniSize.Y - 1 do begin
     1042    for x := 0 to MiniSize.X - 1 do begin
    10431043      for i := 0 to 1 do begin
    1044         xm := (x * 2 + i + y and 1) mod (MiniWidth * 2);
     1044        xm := (x * 2 + i + y and 1) mod (MiniSize.X * 2);
    10451045        MiniPixel.SetX(xm);
    10461046        cm := MiniColors
    1047           [Map[x * lxmax div MiniWidth + lxmax *
    1048           ((y * (lymax - 1) + MiniHeight div 2) div (MiniHeight - 1))] and
     1047          [Map[x * lxmax div MiniSize.X + lxmax *
     1048          ((y * (lymax - 1) + MiniSize.Y div 2) div (MiniSize.Y - 1))] and
    10491049          fTerrain, i];
    10501050        MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3;
     
    10661066  EnemyColor := GrExt[HGrSystem].Data.Canvas.Pixels[96, 67];
    10671067  Mini.PixelFormat := pf24bit;
    1068   Mini.SetSize(MiniWidth * 2, MiniHeight);
     1068  Mini.SetSize(MiniSize.X * 2, MiniSize.Y);
    10691069  if MiniMode = mmPicture then
    10701070  begin
     
    10721072    MiniPixel.Init(Mini);
    10731073    PrevMiniPixel.Init(Mini, 0, -1);
    1074     for y := 0 to MiniHeight - 1 do begin
    1075       for x := 0 to MiniWidth - 1 do begin
     1074    for y := 0 to MiniSize.Y - 1 do begin
     1075      for x := 0 to MiniSize.X - 1 do begin
    10761076        for i := 0 to 1 do begin
    1077           xm := (x * 2 + i + y and 1) mod (MiniWidth * 2);
     1077          xm := (x * 2 + i + y and 1) mod (MiniSize.X * 2);
    10781078          MiniPixel.SetX(xm);
    1079           Tile := SaveMap[x + MiniWidth * y];
     1079          Tile := SaveMap[x + MiniSize.X * y];
    10801080          if Tile and fTerrain = fUNKNOWN then
    10811081            cm := $000000
     
    11291129    pgNoLoad:
    11301130      begin
    1131         MiniWidth := lxpre[DefaultWorldSize];
    1132         MiniHeight := lypre[DefaultWorldSize];
     1131        MiniSize := WorldSizes[DefaultWorldSize];
    11331132        MiniMode := mmNone;
    11341133      end;
     
    11431142          if Dummy >= $000E01 then
    11441143            BlockRead(LogFile, Dummy, 1); { item stored since 0.14.1 }
    1145           BlockRead(LogFile, MiniWidth, 1);
    1146           BlockRead(LogFile, MiniHeight, 1);
     1144          BlockRead(LogFile, MiniSize.X, 1);
     1145          BlockRead(LogFile, MiniSize.Y, 1);
    11471146          BlockRead(LogFile, FileLandMass, 1);
    11481147          if FileLandMass = 0 then
    1149             for y := 0 to MiniHeight - 1 do
    1150               BlockRead(LogFile, MapRow, MiniWidth);
     1148            for y := 0 to MiniSize.Y - 1 do
     1149              BlockRead(LogFile, MapRow, MiniSize.X);
    11511150          BlockRead(LogFile, Dummy, 1);
    11521151          BlockRead(LogFile, Dummy, 1);
     
    11581157            MiniMode := mmPicture;
    11591158          if MiniMode = mmPicture then
    1160             BlockRead(LogFile, SaveMap[4], (MiniWidth * MiniHeight - 1) div 4);
     1159            BlockRead(LogFile, SaveMap[4], (MiniSize.X * MiniSize.Y - 1) div 4);
    11611160          CloseFile(LogFile);
    11621161        except
    11631162          CloseFile(LogFile);
    11641163          LastTurn := 0;
    1165           MiniWidth := lxpre[DefaultWorldSize];
    1166           MiniHeight := lypre[DefaultWorldSize];
     1164          MiniSize := WorldSizes[DefaultWorldSize];
    11671165          MiniMode := mmNone;
    11681166        end;
     
    11951193          if Mini.height > MaxHeightMapLogo then
    11961194            Mini.height := MaxHeightMapLogo;
    1197           MiniWidth := Mini.width div 2;
    1198           MiniHeight := Mini.height;
     1195          MiniSize.X := Mini.width div 2;
     1196          MiniSize.Y := Mini.height;
    11991197        end
    12001198        else
    12011199        begin
    12021200          MiniMode := mmNone;
    1203           MiniWidth := MaxWidthMapLogo;
    1204           MiniHeight := MaxHeightMapLogo;
     1201          MiniSize.X := MaxWidthMapLogo;
     1202          MiniSize.Y := MaxHeightMapLogo;
    12051203        end;
    12061204
     
    17071705procedure TStartDlg.Up1BtnClick(Sender: TObject);
    17081706begin
    1709   if WorldSize < nWorldSize - 1 then
     1707  if WorldSize < MaxWorldSize - 1 then
    17101708  begin
    17111709    Inc(WorldSize);
Note: See TracChangeset for help on using the changeset viewer.