Changeset 590 for trunk/MiniMap.pas
- Timestamp:
- Jul 24, 2024, 10:25:56 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MiniMap.pas
r545 r590 5 5 6 6 uses 7 Classes, SysUtils, Protocol, ClientTools, 7 Classes, SysUtils, Protocol, ClientTools, Map, 8 8 {$IFDEF DPI}Dpi.Graphics, Dpi.Common{$ELSE}Graphics{$ENDIF}; 9 9 … … 111 111 procedure TMiniMap.LoadFromMapFile(FileName: string; var nMapLandTiles, nMapStartPositions: Integer); 112 112 var 113 x, y, lxFile, lyFile: integer; 114 MapFile: file; 115 s: string[255]; 113 x, y: integer; 116 114 MapRow: array [0 .. lxmax - 1] of Cardinal; 117 115 ImageFileName: string; 116 Map: TMap; 117 Tile: Cardinal; 118 118 begin 119 119 ImageFileName := Copy(FileName, 1, Length(FileName) - Length(CevoMapExt)) + CevoMapPictureExt; … … 125 125 if Bitmap.Height > MaxHeightMapLogo then 126 126 Bitmap.Height := MaxHeightMapLogo; 127 Size.X := Bitmap.Width div 2; 128 Size.Y := Bitmap.Height; 127 Size := Point(Bitmap.Width div 2, Bitmap.Height); 129 128 end else begin 130 129 Mode := mmNone; 131 Size.X := MaxWidthMapLogo; 132 Size.Y := MaxHeightMapLogo; 133 end; 134 135 AssignFile(MapFile, FileName); 130 Size := Point(MaxWidthMapLogo, MaxHeightMapLogo); 131 end; 132 133 Map := TMap.Create; 136 134 try 137 Reset(MapFile, 4); 138 BlockRead(MapFile, s[1], 2); { file id } 139 BlockRead(MapFile, x, 1); { format id } 140 BlockRead(MapFile, x, 1); // MaxTurn 141 BlockRead(MapFile, lxFile, 1); 142 BlockRead(MapFile, lyFile, 1); 135 Map.LoadFromFile(FileName); 143 136 nMapLandTiles := 0; 144 137 nMapStartPositions := 0; 145 for y := 0 to lyFile - 1 do begin 146 BlockRead(MapFile, MapRow, lxFile); 147 for x := 0 to lxFile - 1 do 148 begin 149 if (MapRow[x] and fTerrain) in [fGrass, fPrairie, fTundra, fSwamp, 138 for y := 0 to Map.Size.Y - 1 do begin 139 for X := 0 to Map.Size.X - 1 do begin 140 Tile := Map.Tiles[Y * Map.Size.X + X]; 141 if (Tile and fTerrain) in [fGrass, fPrairie, fTundra, fSwamp, 150 142 fForest, fHills] then 151 143 Inc(nMapLandTiles); 152 if MapRow[x]and (fPrefStartPos or fStartPos) <> 0 then144 if Tile and (fPrefStartPos or fStartPos) <> 0 then 153 145 Inc(nMapStartPositions); 154 end 146 end; 155 147 end; 156 148 if nMapStartPositions > nPl then 157 149 nMapStartPositions := nPl; 158 CloseFile(MapFile); 159 except 160 CloseFile(MapFile); 150 finally 151 FreeAndNil(Map); 161 152 end; 162 153 end;
Note:
See TracChangeset
for help on using the changeset viewer.