source: branches/highdpi/LocalPlayer/IsoEngine.pas@ 179

Last change on this file since 179 was 179, checked in by chronos, 2 years ago
  • Modified: Improved scaling support.
File size: 53.2 KB
Line 
1{$INCLUDE Switches.inc}
2unit IsoEngine;
3
4interface
5
6uses
7 Protocol, ClientTools, ScreenTools, Tribes, UDpiControls,
8{$IFNDEF SCR}Term, {$ENDIF}
9 LCLIntf, LCLType, SysUtils, Classes, Graphics;
10
11type
12 TInitEnemyModelEvent = function(emix: integer): boolean;
13
14 { TIsoMap }
15
16 TIsoMap = class
17 constructor Create;
18 procedure SetOutput(Output: TDpiBitmap);
19 procedure SetPaintBounds(Left, Top, Right, Bottom: integer);
20 procedure Paint(x, y, Loc, nx, ny, CityLoc, CityOwner: integer;
21 UseBlink: boolean = false; CityAllowClick: boolean = false);
22 procedure PaintUnit(x, y: integer; const UnitInfo: TUnitInfo;
23 Status: integer);
24 procedure PaintCity(x, y: integer; const CityInfo: TCityInfo;
25 accessory: boolean = true);
26 procedure BitBlt(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,
27 Rop: integer);
28
29 procedure AttackBegin(const ShowMove: TShowMove);
30 procedure AttackEffect(const ShowMove: TShowMove);
31 procedure AttackEnd;
32
33 private
34 procedure CityGrid(xm, ym: integer; CityAllowClick: Boolean);
35 function IsShoreTile(Loc: integer): boolean;
36 procedure MakeDark(Line: PPixelPointer; Length: Integer);
37 procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer);
38 protected
39 FOutput: TDpiBitmap;
40 FLeft, FTop, FRight, FBottom, RealTop, RealBottom, AttLoc, DefLoc,
41 DefHealth, FAdviceLoc: integer;
42 DataDC, MaskDC: HDC;
43 function Connection4(Loc, Mask, Value: integer): integer;
44 function Connection8(Loc, Mask: integer): integer;
45 function OceanConnection(Loc: integer): integer;
46 procedure PaintShore(x, y, Loc: integer);
47 procedure PaintTileExtraTerrain(x, y, Loc: integer);
48 procedure PaintTileObjects(x, y, Loc, CityLoc, CityOwner: integer;
49 UseBlink: boolean);
50 procedure PaintGrid(x, y, nx, ny: integer);
51 procedure FillRect(x, y, Width, Height, Color: integer);
52 procedure Textout(x, y, Color: integer; const s: string);
53 procedure Sprite(HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
54 procedure TSprite(xDst, yDst, grix: integer; PureBlack: boolean = false);
55
56 public
57 property AdviceLoc: integer read FAdviceLoc write FAdviceLoc;
58 end;
59
60const
61 // options switched by buttons
62 moPolitical = 0;
63 moCityNames = 1;
64 moGreatWall = 4;
65 moGrid = 5;
66 moBareTerrain = 6;
67
68 // other options
69 moEditMode = 16;
70 moLocCodes = 17;
71
72var
73 NoMap: TIsoMap;
74 Options: integer;
75 pDebugMap: integer; // -1 for off
76
77function IsJungle(y: integer): boolean;
78procedure Init(InitEnemyModelHandler: TInitEnemyModelEvent);
79function ApplyTileSize(xxtNew, yytNew: integer): boolean;
80procedure Done;
81procedure Reset;
82
83implementation
84
85const
86 ShoreDither = fGrass;
87 TerrainIconLines = 21;
88 TerrainIconCols = 9;
89
90 // sprites indexes
91 spDeadLands = 2 * TerrainIconCols + 6;
92 spBlink1 = 1 * TerrainIconCols + 8;
93 spBlink2 = 2 * TerrainIconCols + 8;
94 spPrefStartPos = 1 * TerrainIconCols;
95 spStartPos = 2 * TerrainIconCols;
96 spPlain = 2 * TerrainIconCols + 7;
97 spForest = 3 * TerrainIconCols;
98 spRoad = 9 * TerrainIconCols;
99 spRailRoad = 10 * TerrainIconCols;
100 spCanal = 11 * TerrainIconCols;
101 spIrrigation = 12 * TerrainIconCols;
102 spFarmLand = 12 * TerrainIconCols + 1;
103 spMine = 12 * TerrainIconCols + 2;
104 spFortFront = 12 * TerrainIconCols + 3;
105 spBase = 12 * TerrainIconCols + 4;
106 spSpacePort = 12 * TerrainIconCols + 5;
107 spPollution = 12 * TerrainIconCols + 6;
108 spFortBack = 12 * TerrainIconCols + 7;
109 spRiver = 13 * TerrainIconCols;
110 spJungle = 18 * TerrainIconCols;
111
112var
113 BordersOK: integer;
114 OnInitEnemyModel: TInitEnemyModelEvent;
115 LandPatch, OceanPatch, Borders: TDpiBitmap;
116 TSpriteSize: array [0 .. TerrainIconLines * 9 - 1] of TRect;
117 DebugMap: ^TTileList;
118 CitiesPictures: array [2 .. 3, 0 .. 3] of TCityPicture;
119 FoW, ShowLoc, ShowCityNames, ShowObjects, ShowBorder, ShowMyBorder,
120 ShowGrWall, ShowDebug: boolean;
121
122function IsJungle(y: integer): boolean;
123begin
124 result := (y > (G.ly - 2) div 4) and (G.ly - 1 - y > (G.ly - 2) div 4)
125end;
126
127procedure Init(InitEnemyModelHandler: TInitEnemyModelEvent);
128begin
129 OnInitEnemyModel := InitEnemyModelHandler;
130 if NoMap <> nil then
131 NoMap.Free;
132 NoMap := TIsoMap.Create;
133end;
134
135function ApplyTileSize(xxtNew, yytNew: integer): boolean;
136var
137 i, x, y, xSrc, ySrc, HGrTerrainNew, HGrCitiesNew, age, size: integer;
138 LandMore, OceanMore, DitherMask, Mask24: TDpiBitmap;
139 MaskLine: array [0 .. 32 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt
140 Border: boolean;
141begin
142 result := false;
143 HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png',
144 [xxtNew * 2, yytNew * 2]));
145 if HGrTerrainNew < 0 then
146 exit;
147 HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png',
148 [xxtNew * 2, yytNew * 2]));
149 if HGrCitiesNew < 0 then
150 exit;
151 xxt := xxtNew;
152 yyt := yytNew;
153 HGrTerrain := HGrTerrainNew;
154 HGrCities := HGrCitiesNew;
155 result := true;
156
157 // prepare age 2+3 cities
158 for age := 2 to 3 do
159 for size := 0 to 3 do
160 with CitiesPictures[age, size] do
161 FindPosition(HGrCities, size * (xxt * 2 + 1), (age - 2) * (yyt * 3 + 1),
162 xxt * 2 - 1, yyt * 3 - 1, $00FFFF, xShield, yShield);
163
164 { prepare dithered ground tiles }
165 if LandPatch <> nil then
166 LandPatch.Free;
167 LandPatch := TDpiBitmap.Create;
168 LandPatch.PixelFormat := pf24bit;
169 LandPatch.Canvas.Brush.Color := 0;
170 LandPatch.SetSize(xxt * 18, yyt * 9);
171 LandPatch.Canvas.FillRect(0, 0, LandPatch.Width, LandPatch.Height);
172 if OceanPatch <> nil then
173 OceanPatch.Free;
174 OceanPatch := TDpiBitmap.Create;
175 OceanPatch.PixelFormat := pf24bit;
176 OceanPatch.Canvas.Brush.Color := 0;
177 OceanPatch.SetSize(xxt * 8, yyt * 4);
178 OceanPatch.Canvas.FillRect(0, 0, OceanPatch.Width, OceanPatch.Height);
179 LandMore := TDpiBitmap.Create;
180 LandMore.PixelFormat := pf24bit;
181 LandMore.Canvas.Brush.Color := 0;
182 LandMore.SetSize(xxt * 18, yyt * 9);
183 LandMore.Canvas.FillRect(0, 0, LandMore.Width, LandMore.Height);
184 OceanMore := TDpiBitmap.Create;
185 OceanMore.PixelFormat := pf24bit;
186 OceanMore.Canvas.Brush.Color := 0;
187 OceanMore.SetSize(xxt * 8, yyt * 4);
188 OceanMore.Canvas.FillRect(0, 0, OceanMore.Width, OceanMore.Height);
189 DitherMask := TDpiBitmap.Create;
190 DitherMask.PixelFormat := pf24bit;
191 DitherMask.SetSize(xxt * 2, yyt * 2);
192 DitherMask.Canvas.FillRect(0, 0, DitherMask.Width, DitherMask.Height);
193 BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt * 2,
194 GrExt[HGrTerrain].Mask.Canvas.Handle, 1 + 7 * (xxt * 2 + 1),
195 1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
196
197 for x := -1 to 6 do
198 begin
199 if x = -1 then
200 begin
201 xSrc := ShoreDither * (xxt * 2 + 1) + 1;
202 ySrc := 1 + yyt
203 end
204 else if x = 6 then
205 begin
206 xSrc := 1 + (xxt * 2 + 1) * 2;
207 ySrc := 1 + yyt + (yyt * 3 + 1) * 2
208 end
209 else
210 begin
211 xSrc := (x + 2) * (xxt * 2 + 1) + 1;
212 ySrc := 1 + yyt
213 end;
214 for y := -1 to 6 do
215 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
216 xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc,
217 SRCCOPY);
218 for y := -2 to 6 do
219 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
220 yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt,
221 SRCPAINT);
222 for y := -2 to 6 do
223 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
224 xxt, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt,
225 SRCPAINT);
226 for y := -2 to 6 do
227 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
228 yyt, DitherMask.Canvas.Handle, xxt, yyt, SRCAND);
229 for y := -2 to 6 do
230 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
231 xxt, yyt, DitherMask.Canvas.Handle, 0, yyt, SRCAND);
232 end;
233
234 for y := -1 to 6 do
235 begin
236 if y = -1 then
237 begin
238 xSrc := ShoreDither * (xxt * 2 + 1) + 1;
239 ySrc := 1 + yyt
240 end
241 else if y = 6 then
242 begin
243 xSrc := 1 + 2 * (xxt * 2 + 1);
244 ySrc := 1 + yyt + 2 * (yyt * 3 + 1)
245 end
246 else
247 begin
248 xSrc := (y + 2) * (xxt * 2 + 1) + 1;
249 ySrc := 1 + yyt
250 end;
251 for x := -2 to 6 do
252 BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
253 xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc,
254 SRCCOPY);
255 BitBlt(LandMore.Canvas.Handle, xxt * 2, (y + 2) * yyt, xxt, yyt,
256 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt, SRCPAINT);
257 for x := 0 to 7 do
258 BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
259 xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt,
260 SRCPAINT);
261 for x := -2 to 6 do
262 BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
263 xxt * 2, yyt, DitherMask.Canvas.Handle, 0, 0, SRCAND);
264 end;
265
266 for x := 0 to 3 do
267 for y := 0 to 3 do
268 begin
269 if (x = 1) and (y = 1) then
270 xSrc := 1
271 else
272 xSrc := (x mod 2) * (xxt * 2 + 1) + 1;
273 ySrc := 1 + yyt;
274 if (x >= 1) = (y >= 2) then
275 BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
276 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc, SRCCOPY);
277 if (x >= 1) and ((y < 2) or (x >= 2)) then
278 begin
279 BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt, yyt,
280 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt,
281 SRCPAINT);
282 BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
283 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt, SRCPAINT);
284 end;
285 BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt, yyt,
286 DitherMask.Canvas.Handle, xxt, yyt, SRCAND);
287 BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
288 DitherMask.Canvas.Handle, 0, yyt, SRCAND);
289 end;
290
291 for y := 0 to 3 do
292 for x := 0 to 3 do
293 begin
294 if (x = 1) and (y = 1) then
295 xSrc := 1
296 else
297 xSrc := (y mod 2) * (xxt * 2 + 1) + 1;
298 ySrc := 1 + yyt;
299 if (x < 1) or (y >= 2) then
300 BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
301 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc, SRCCOPY);
302 if (x = 1) and (y < 2) or (x >= 2) and (y >= 1) then
303 begin
304 BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2), y * yyt, xxt, yyt,
305 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt,
306 SRCPAINT);
307 BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
308 GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt, SRCPAINT);
309 end;
310 BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
311 DitherMask.Canvas.Handle, 0, 0, SRCAND);
312 end;
313
314 BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt * 2,
315 DitherMask.Canvas.Handle, 0, 0, DSTINVERT); { invert dither mask }
316 BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt * 2,
317 GrExt[HGrTerrain].Mask.Canvas.Handle, 1, 1 + yyt, SRCPAINT);
318
319 for x := -1 to 6 do
320 for y := -2 to 6 do
321 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
322 xxt * 2, yyt, DitherMask.Canvas.Handle, 0, 0, SRCAND);
323
324 for y := -1 to 6 do
325 for x := -2 to 7 do
326 BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
327 xxt * 2, yyt, DitherMask.Canvas.Handle, 0, yyt, SRCAND);
328
329 BitBlt(LandPatch.Canvas.Handle, 0, 0, (xxt * 2) * 9, yyt * 9,
330 LandMore.Canvas.Handle, 0, 0, SRCPAINT);
331
332 for x := 0 to 3 do
333 for y := 0 to 3 do
334 BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
335 DitherMask.Canvas.Handle, 0, 0, SRCAND);
336
337 for y := 0 to 3 do
338 for x := 0 to 4 do
339 BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2) - xxt, y * yyt, xxt * 2,
340 yyt, DitherMask.Canvas.Handle, 0, yyt, SRCAND);
341
342 BitBlt(OceanPatch.Canvas.Handle, 0, 0, (xxt * 2) * 4, yyt * 4,
343 OceanMore.Canvas.Handle, 0, 0, SRCPAINT);
344
345 with DitherMask.Canvas do
346 begin
347 Brush.Color := $FFFFFF;
348 FillRect(Rect(0, 0, xxt * 2, yyt));
349 end;
350 BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt,
351 GrExt[HGrTerrain].Mask.Canvas.Handle, 1, 1 + yyt, SRCCOPY);
352
353 for x := 0 to 6 do
354 BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), yyt, xxt * 2, yyt,
355 DitherMask.Canvas.Handle, 0, 0, SRCAND);
356 BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt, DitherMask.Canvas.Handle,
357 0, 0, DSTINVERT);
358
359 for y := 0 to 6 do
360 BitBlt(LandPatch.Canvas.Handle, xxt * 2, (y + 2) * yyt, xxt * 2, yyt,
361 DitherMask.Canvas.Handle, 0, 0, SRCAND);
362
363 LandMore.Free;
364 OceanMore.Free;
365 DitherMask.Free;
366
367 // reduce size of terrain icons
368 Mask24 := TDpiBitmap.Create;
369 Mask24.Assign(GrExt[HGrTerrain].Mask);
370 Mask24.PixelFormat := pf24bit;
371 Mask24.BeginUpdate;
372 for ySrc := 0 to TerrainIconLines - 1 do
373 begin
374 for i := 0 to yyt * 3 - 1 do
375 MaskLine[i].Init(Mask24, 0, 1 + ySrc * (yyt * 3 + 1) + i);
376 for xSrc := 0 to 9 - 1 do
377 begin
378 i := ySrc * 9 + xSrc;
379 TSpriteSize[i].Left := 0;
380 repeat
381 Border := true;
382 for y := 0 to yyt * 3 - 1 do begin
383 MaskLine[y].SetX(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left);
384 if MaskLine[y].Pixel^.B = 0 then Border := false;
385 end;
386 if Border then Inc(TSpriteSize[i].Left);
387 until not Border or (TSpriteSize[i].Left = xxt * 2 - 1);
388 TSpriteSize[i].Top := 0;
389 repeat
390 Border := true;
391 for x := 0 to xxt * 2 - 1 do begin
392 MaskLine[TSpriteSize[i].Top].SetX(1 + xSrc * (xxt * 2 + 1) + x);
393 if MaskLine[TSpriteSize[i].Top].Pixel^.B = 0 then Border := false;
394 end;
395 if Border then inc(TSpriteSize[i].Top);
396 until not Border or (TSpriteSize[i].Top = yyt * 3 - 1);
397 TSpriteSize[i].Right := xxt * 2;
398 repeat
399 Border := true;
400 for y := 0 to yyt * 3 - 1 do begin
401 MaskLine[y].SetX(xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right);
402 if MaskLine[y].Pixel^.B = 0 then Border := false;
403 end;
404 if Border then Dec(TSpriteSize[i].Right);
405 until not Border or (TSpriteSize[i].Right = TSpriteSize[i].Left);
406 TSpriteSize[i].Bottom := yyt * 3;
407 repeat
408 Border := true;
409 for x := 0 to xxt * 2 - 1 do begin
410 MaskLine[TSpriteSize[i].Bottom - 1].SetX(1 + xSrc * (xxt * 2 + 1) + x);
411 if MaskLine[TSpriteSize[i].Bottom - 1].Pixel^.B = 0 then Border := false;
412 end;
413 if Border then Dec(TSpriteSize[i].Bottom);
414 until not Border or (TSpriteSize[i].Bottom = TSpriteSize[i].Top);
415 end
416 end;
417 Mask24.EndUpdate;
418 Mask24.Free;
419
420 if Borders <> nil then
421 Borders.Free;
422 Borders := TDpiBitmap.Create;
423 Borders.PixelFormat := pf24bit;
424 Borders.SetSize(xxt * 2,(yyt * 2) * nPl);
425 Borders.Canvas.FillRect(0, 0, Borders.Width, Borders.Height);
426 BordersOK := 0;
427end;
428
429procedure Done;
430begin
431 FreeAndNil(NoMap);
432 FreeAndNil(LandPatch);
433 FreeAndNil(OceanPatch);
434 FreeAndNil(Borders);
435end;
436
437procedure Reset;
438begin
439 BordersOK := 0;
440end;
441
442constructor TIsoMap.Create;
443begin
444 inherited;
445 FLeft := 0;
446 FTop := 0;
447 FRight := 0;
448 FBottom := 0;
449 AttLoc := -1;
450 DefLoc := -1;
451 FAdviceLoc := -1;
452end;
453
454procedure TIsoMap.SetOutput(Output: TDpiBitmap);
455begin
456 FOutput := Output;
457 FLeft := 0;
458 FTop := 0;
459 FRight := FOutput.Width;
460 FBottom := FOutput.Height;
461end;
462
463procedure TIsoMap.SetPaintBounds(Left, Top, Right, Bottom: integer);
464begin
465 FLeft := Left;
466 FTop := Top;
467 FRight := Right;
468 FBottom := Bottom;
469end;
470
471procedure TIsoMap.FillRect(x, y, Width, Height, Color: integer);
472begin
473 if x < FLeft then
474 begin
475 Width := Width - (FLeft - x);
476 x := FLeft
477 end;
478 if y < FTop then
479 begin
480 Height := Height - (FTop - y);
481 y := FTop
482 end;
483 if x + Width >= FRight then
484 Width := FRight - x;
485 if y + Height >= FBottom then
486 Height := FBottom - y;
487 if (Width <= 0) or (Height <= 0) then
488 exit;
489
490 FOutput.Canvas.Brush.Color := Color;
491 FOutput.Canvas.FillRect(Rect(x, y, x + Width, y + Height));
492 FOutput.Canvas.Brush.Style := bsClear;
493end;
494
495procedure TIsoMap.Textout(x, y, Color: integer; const s: string);
496begin
497 FOutput.Canvas.Font.Color := Color;
498 FOutput.Canvas.TextRect(Rect(FLeft, FTop, FRight, FBottom), x, y, s)
499end;
500
501procedure TIsoMap.BitBlt(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,
502 Rop: integer);
503begin
504 if x < FLeft then
505 begin
506 Width := Width - (FLeft - x);
507 xSrc := xSrc + (FLeft - x);
508 x := FLeft
509 end;
510 if y < FTop then
511 begin
512 Height := Height - (FTop - y);
513 ySrc := ySrc + (FTop - y);
514 y := FTop
515 end;
516 if x + Width >= FRight then
517 Width := FRight - x;
518 if y + Height >= FBottom then
519 Height := FBottom - y;
520 if (Width <= 0) or (Height <= 0) then
521 exit;
522
523 DpiBitBlt(FOutput.Canvas.Handle, x, y, Width, Height, Src.Canvas.Handle,
524 xSrc, ySrc, Rop);
525end;
526
527procedure TIsoMap.Sprite(HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
528begin
529 BitBlt(GrExt[HGr].Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND);
530 BitBlt(GrExt[HGr].Data, xDst, yDst, Width, Height, xGr, yGr, SRCPAINT);
531end;
532
533procedure TIsoMap.TSprite(xDst, yDst, grix: integer;
534 PureBlack: boolean = false);
535var
536 Width, Height, xSrc, ySrc: integer;
537begin
538 Width := TSpriteSize[grix].Right - TSpriteSize[grix].Left;
539 Height := TSpriteSize[grix].Bottom - TSpriteSize[grix].Top;
540 xSrc := 1 + grix mod 9 * (xxt * 2 + 1) + TSpriteSize[grix].Left;
541 ySrc := 1 + grix div 9 * (yyt * 3 + 1) + TSpriteSize[grix].Top;
542 xDst := xDst + TSpriteSize[grix].Left;
543 yDst := yDst - yyt + TSpriteSize[grix].Top;
544 if xDst < FLeft then
545 begin
546 Width := Width - (FLeft - xDst);
547 xSrc := xSrc + (FLeft - xDst);
548 xDst := FLeft
549 end;
550 if yDst < FTop then
551 begin
552 Height := Height - (FTop - yDst);
553 ySrc := ySrc + (FTop - yDst);
554 yDst := FTop
555 end;
556 if xDst + Width >= FRight then
557 Width := FRight - xDst;
558 if yDst + Height >= FBottom then
559 Height := FBottom - yDst;
560 if (Width <= 0) or (Height <= 0) then
561 exit;
562
563 DpiBitBlt(FOutput.Canvas.Handle, xDst, yDst, Width, Height, MaskDC, xSrc, ySrc, SRCAND);
564 if not PureBlack then
565 DpiBitBlt(FOutput.Canvas.Handle, xDst, yDst, Width, Height, DataDC, xSrc, ySrc,
566 SRCPAINT);
567end;
568
569procedure TIsoMap.PaintUnit(x, y: integer; const UnitInfo: TUnitInfo;
570 Status: integer);
571var
572 xsh, ysh, xGr, yGr, j, mixShow: integer;
573begin
574 with UnitInfo do
575 if (Owner = me) or (emix <> $FFFF) then
576 begin
577 if Job = jCity then
578 mixShow := -1 // building site
579 else
580 mixShow := mix;
581 if (Tribe[Owner].ModelPicture[mixShow].HGr = 0) and
582 (@OnInitEnemyModel <> nil) then
583 if not OnInitEnemyModel(emix) then
584 exit;
585 xsh := Tribe[Owner].ModelPicture[mixShow].xShield;
586 ysh := Tribe[Owner].ModelPicture[mixShow].yShield;
587{$IFNDEF SCR} if Status and usStay <> 0 then
588 j := 19
589 else if Status and usRecover <> 0 then
590 j := 16
591 else if Status and (usGoto or usEnhance) = usGoto or usEnhance then
592 j := 18
593 else if Status and usEnhance <> 0 then
594 j := 17
595 else if Status and usGoto <> 0 then
596 j := 20
597 else {$ENDIF} if Job = jCity then
598 j := jNone
599 else
600 j := Job;
601 if Flags and unMulti <> 0 then
602 Sprite(Tribe[Owner].symHGr, x + xsh - 1 + 4, y + ysh - 2, 14, 12,
603 33 + Tribe[Owner].sympix mod 10 * 65,
604 1 + Tribe[Owner].sympix div 10 * 49);
605 Sprite(Tribe[Owner].symHGr, x + xsh - 1, y + ysh - 2, 14, 12,
606 18 + Tribe[Owner].sympix mod 10 * 65,
607 1 + Tribe[Owner].sympix div 10 * 49);
608 FillRect(x + xsh, y + ysh + 5, 1 + Health * 11 div 100, 3,
609 ColorOfHealth(Health));
610 if j > 0 then
611 begin
612 xGr := 121 + j mod 7 * 9;
613 yGr := 1 + j div 7 * 9;
614 BitBlt(GrExt[HGrSystem].Mask, x + xsh + 3, y + ysh + 9, 8, 8, xGr,
615 yGr, SRCAND);
616 Sprite(HGrSystem, x + xsh + 2, y + ysh + 8, 8, 8, xGr, yGr);
617 end;
618 with Tribe[Owner].ModelPicture[mixShow] do
619 Sprite(HGr, x, y, 64, 48, pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
620 if Flags and unFortified <> 0 then
621 begin
622 { DataDC:=GrExt[HGrTerrain].Data.Canvas.Handle;
623 MaskDC:=GrExt[HGrTerrain].Mask.Canvas.Handle;
624 TSprite(x,y+16,12*9+7); }
625 Sprite(HGrStdUnits, x, y, xxu * 2, yyu * 2, 1 + 6 * (xxu * 2 + 1), 1);
626 end
627 end
628end; { PaintUnit }
629
630procedure TIsoMap.PaintCity(x, y: integer; const CityInfo: TCityInfo;
631 accessory: boolean);
632var
633 age, cHGr, cpix, xGr, xShield, yShield, LabelTextColor, LabelLength: integer;
634 cpic: TCityPicture;
635 s: string;
636begin
637 age := GetAge(CityInfo.Owner);
638 if CityInfo.size < 5 then
639 xGr := 0
640 else if CityInfo.size < 9 then
641 xGr := 1
642 else if CityInfo.size < 13 then
643 xGr := 2
644 else
645 xGr := 3;
646 Tribe[CityInfo.Owner].InitAge(age);
647 if age < 2 then
648 begin
649 cHGr := Tribe[CityInfo.Owner].cHGr;
650 cpix := Tribe[CityInfo.Owner].cpix;
651 if (ciWalled and CityInfo.Flags = 0) or
652 (GrExt[cHGr].Data.Canvas.Pixels[(xGr + 4) * 65, cpix * 49 + 48] = $00FFFF)
653 then
654 Sprite(cHGr, x - xxc, y - 2 * yyc, xxc * 2, yyc * 3,
655 xGr * (xxc * 2 + 1) + 1, 1 + cpix * (yyc * 3 + 1));
656 if ciWalled and CityInfo.Flags <> 0 then
657 Sprite(cHGr, x - xxc, y - 2 * yyc, xxc * 2, yyc * 3,
658 (xGr + 4) * (xxc * 2 + 1) + 1, 1 + cpix * (yyc * 3 + 1));
659 end
660 else
661 begin
662 if ciWalled and CityInfo.Flags <> 0 then
663 Sprite(HGrCities, x - xxt, y - 2 * yyt, 2 * xxt, 3 * yyt,
664 (xGr + 4) * (2 * xxt + 1) + 1, 1 + (age - 2) * (3 * yyt + 1))
665 else
666 Sprite(HGrCities, x - xxt, y - 2 * yyt, 2 * xxt, 3 * yyt,
667 xGr * (2 * xxt + 1) + 1, 1 + (age - 2) * (3 * yyt + 1));
668 end;
669
670 if not accessory then
671 exit;
672
673 { if ciCapital and CityInfo.Flags<>0 then
674 Sprite(Tribe[CityInfo.Owner].symHGr,x+cpic.xf,y-13+cpic.yf,13,14,
675 1+Tribe[CityInfo.Owner].sympix mod 10 *65,
676 1+Tribe[CityInfo.Owner].sympix div 10 *49); {capital -- paint flag }
677
678 if MyMap[CityInfo.Loc] and fObserved <> 0 then
679 begin
680 if age < 2 then
681 begin
682 cpic := Tribe[CityInfo.Owner].CityPicture[xGr];
683 xShield := x - xxc + cpic.xShield;
684 yShield := y - 2 * yyc + cpic.yShield;
685 end
686 else
687 begin
688 cpic := CitiesPictures[age, xGr];
689 xShield := x - xxt + cpic.xShield;
690 yShield := y - 2 * yyt + cpic.yShield;
691 end;
692 s := IntToStr(CityInfo.size);
693 LabelLength := FOutput.Canvas.TextWidth(s);
694 FillRect(xShield, yShield, LabelLength + 4, 16, $000000);
695 if MyMap[CityInfo.Loc] and (fUnit or fObserved) = fObserved then
696 // empty city
697 LabelTextColor := Tribe[CityInfo.Owner].Color
698 else
699 begin
700 FillRect(xShield + 1, yShield + 1, LabelLength + 2, 14,
701 Tribe[CityInfo.Owner].Color);
702 LabelTextColor := $000000;
703 end;
704 Textout(xShield + 2, yShield - 1, LabelTextColor, s);
705 end
706end; { PaintCity }
707
708function PoleTile(Loc: integer): integer;
709begin { virtual pole tile }
710 result := fUNKNOWN;
711 if Loc < -2 * G.lx then
712 else if Loc < -G.lx then
713 begin
714 if (MyMap[dLoc(Loc, 0, 2)] and fTerrain <> fUNKNOWN) and
715 (MyMap[dLoc(Loc, -2, 2)] and fTerrain <> fUNKNOWN) and
716 (MyMap[dLoc(Loc, 2, 2)] and fTerrain <> fUNKNOWN) then
717 result := fArctic;
718 if (MyMap[dLoc(Loc, 0, 2)] and fObserved <> 0) and
719 (MyMap[dLoc(Loc, -2, 2)] and fObserved <> 0) and
720 (MyMap[dLoc(Loc, 2, 2)] and fObserved <> 0) then
721 result := result or fObserved
722 end
723 else if Loc < 0 then
724 begin
725 if (MyMap[dLoc(Loc, -1, 1)] and fTerrain <> fUNKNOWN) and
726 (MyMap[dLoc(Loc, 1, 1)] and fTerrain <> fUNKNOWN) then
727 result := fArctic;
728 if (MyMap[dLoc(Loc, -1, 1)] and fObserved <> 0) and
729 (MyMap[dLoc(Loc, 1, 1)] and fObserved <> 0) then
730 result := result or fObserved
731 end
732 else if Loc < G.lx * (G.ly + 1) then
733 begin
734 if (MyMap[dLoc(Loc, -1, -1)] and fTerrain <> fUNKNOWN) and
735 (MyMap[dLoc(Loc, 1, -1)] and fTerrain <> fUNKNOWN) then
736 result := fArctic;
737 if (MyMap[dLoc(Loc, -1, -1)] and fObserved <> 0) and
738 (MyMap[dLoc(Loc, 1, -1)] and fObserved <> 0) then
739 result := result or fObserved
740 end
741 else if Loc < G.lx * (G.ly + 2) then
742 begin
743 if (MyMap[dLoc(Loc, 0, -2)] and fTerrain <> fUNKNOWN) and
744 (MyMap[dLoc(Loc, -2, -2)] and fTerrain <> fUNKNOWN) and
745 (MyMap[dLoc(Loc, 2, -2)] and fTerrain <> fUNKNOWN) then
746 result := fArctic;
747 if (MyMap[dLoc(Loc, 0, -2)] and fObserved <> 0) and
748 (MyMap[dLoc(Loc, -2, -2)] and fObserved <> 0) and
749 (MyMap[dLoc(Loc, 2, -2)] and fObserved <> 0) then
750 result := result or fObserved
751 end
752end;
753
754const
755 Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0);
756 Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2);
757
758function TIsoMap.Connection4(Loc, Mask, Value: integer): integer;
759begin
760 result := 0;
761 if dLoc(Loc, 1, -1) >= 0 then
762 begin
763 if MyMap[dLoc(Loc, 1, -1)] and Mask = Cardinal(Value) then
764 inc(result, 1);
765 if MyMap[dLoc(Loc, -1, -1)] and Mask = Cardinal(Value) then
766 inc(result, 8);
767 end;
768 if dLoc(Loc, 1, 1) < G.lx * G.ly then
769 begin
770 if MyMap[dLoc(Loc, 1, 1)] and Mask = Cardinal(Value) then
771 inc(result, 2);
772 if MyMap[dLoc(Loc, -1, 1)] and Mask = Cardinal(Value) then
773 inc(result, 4);
774 end
775end;
776
777function TIsoMap.Connection8(Loc, Mask: integer): integer;
778var
779 Dir, ConnLoc: integer;
780begin
781 result := 0;
782 for Dir := 0 to 7 do
783 begin
784 ConnLoc := dLoc(Loc, Dirx[Dir], Diry[Dir]);
785 if (ConnLoc >= 0) and (ConnLoc < G.lx * G.ly) and
786 (MyMap[ConnLoc] and Mask <> 0) then
787 inc(result, 1 shl Dir);
788 end
789end;
790
791function TIsoMap.OceanConnection(Loc: integer): integer;
792var
793 Dir, ConnLoc: integer;
794begin
795 result := 0;
796 for Dir := 0 to 7 do
797 begin
798 ConnLoc := dLoc(Loc, Dirx[Dir], Diry[Dir]);
799 if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or
800 ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
801 inc(result, 1 shl Dir);
802 end
803end;
804
805procedure TIsoMap.PaintShore(x, y, Loc: integer);
806var
807 Conn, Tile: integer;
808begin
809 if (y <= FTop - yyt * 2) or (y > FBottom) or (x <= FLeft - xxt * 2) or
810 (x > FRight) then
811 exit;
812 if (Loc < 0) or (Loc >= G.lx * G.ly) then
813 exit;
814 Tile := MyMap[Loc];
815 if Tile and fTerrain >= fGrass then
816 exit;
817 Conn := OceanConnection(Loc);
818 if Conn = 0 then
819 exit;
820
821 BitBlt(GrExt[HGrTerrain].Data, x + xxt div 2, y, xxt, yyt,
822 1 + (Conn shr 6 + Conn and 1 shl 2) * (xxt * 2 + 1),
823 1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
824 BitBlt(GrExt[HGrTerrain].Data, x + xxt, y + yyt div 2, xxt, yyt,
825 1 + (Conn and 7) * (xxt * 2 + 1) + xxt,
826 1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
827 BitBlt(GrExt[HGrTerrain].Data, x + xxt div 2, y + yyt, xxt, yyt,
828 1 + (Conn shr 2 and 7) * (xxt * 2 + 1) + xxt,
829 1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
830 BitBlt(GrExt[HGrTerrain].Data, x, y + yyt div 2, xxt, yyt,
831 1 + (Conn shr 4 and 7) * (xxt * 2 + 1),
832 1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
833 Conn := Connection4(Loc, fTerrain, fUNKNOWN); { dither to black }
834 if Conn and 1 <> 0 then
835 BitBlt(GrExt[HGrTerrain].Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
836 xxt, 1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
837 if Conn and 2 <> 0 then
838 BitBlt(GrExt[HGrTerrain].Mask, x + xxt, y + yyt, xxt, yyt,
839 1 + 7 * (xxt * 2 + 1) + xxt, 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
840 if Conn and 4 <> 0 then
841 BitBlt(GrExt[HGrTerrain].Mask, x, y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
842 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
843 if Conn and 8 <> 0 then
844 BitBlt(GrExt[HGrTerrain].Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
845 1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
846end;
847
848procedure TIsoMap.PaintTileExtraTerrain(x, y, Loc: integer);
849var
850 Dir, Conn, RRConn, yGr, Tile, yLoc: integer;
851begin
852 if (Loc < 0) or (Loc >= G.lx * G.ly) or (y <= -yyt * 2) or
853 (y > FOutput.Height) or (x <= -xxt * 2) or (x > FOutput.Width) then
854 exit;
855 Tile := MyMap[Loc];
856 if Tile and fTerrain = fForest then
857 begin
858 yLoc := Loc div G.lx;
859 if IsJungle(yLoc) then
860 yGr := spJungle
861 else
862 yGr := spForest;
863 Conn := Connection4(Loc, fTerrain, Tile and fTerrain);
864 if (yLoc = (G.ly - 2) div 4) or (G.ly - 1 - yLoc = (G.ly + 2) div 4) then
865 Conn := Conn and not 6 // no connection to south
866 else if (yLoc = (G.ly + 2) div 4) or (G.ly - 1 - yLoc = (G.ly - 2) div 4)
867 then
868 Conn := Conn and not 9; // no connection to north
869 TSprite(x, y, yGr + Conn mod 8 + (Conn div 8) * TerrainIconCols);
870 end
871 else if Tile and fTerrain in [fHills, fMountains, fForest] then
872 begin
873 yGr := 3 + 2 * (Tile and fTerrain - fForest);
874 Conn := Connection4(Loc, fTerrain, Tile and fTerrain);
875 TSprite(x, y, Conn mod 8 + (yGr + Conn div 8) * TerrainIconCols);
876 end
877 else if Tile and fDeadLands <> 0 then
878 TSprite(x, y, spDeadLands);
879
880 if ShowObjects then
881 begin
882 if Tile and fTerImp = tiFarm then
883 TSprite(x, y, spFarmLand)
884 else if Tile and fTerImp = tiIrrigation then
885 TSprite(x, y, spIrrigation);
886 end;
887 if Tile and fRiver <> 0 then
888 begin
889 Conn := Connection4(Loc, fRiver, fRiver) or
890 Connection4(Loc, fTerrain, fShore) or Connection4(Loc, fTerrain,
891 fUNKNOWN);
892 TSprite(x, y, spRiver + Conn mod 8 + (Conn div 8) * TerrainIconCols);
893 end;
894
895 if Tile and fTerrain < fGrass then
896 begin
897 Conn := Connection4(Loc, fRiver, fRiver);
898 for Dir := 0 to 3 do
899 if Conn and (1 shl Dir) <> 0 then { river mouths }
900 TSprite(x, y, 15 * TerrainIconCols + Dir);
901 if ShowObjects then
902 begin
903 Conn := Connection8(Loc, fCanal);
904 for Dir := 0 to 7 do
905 if Conn and (1 shl Dir) <> 0 then { canal mouths }
906 TSprite(x, y, 20 * TerrainIconCols + 1 + Dir);
907 end
908 end;
909
910 if ShowObjects then
911 begin
912 if (Tile and fCanal <> 0) or (Tile and fCity <> 0) then
913 begin // paint canal connections
914 Conn := Connection8(Loc, fCanal or fCity);
915 if Tile and fCanal <> 0 then
916 Conn := Conn or ($FF - OceanConnection(Loc));
917 if Conn = 0 then
918 begin
919 if Tile and fCanal <> 0 then
920 TSprite(x, y, spCanal)
921 end
922 else
923 for Dir := 0 to 7 do
924 if (1 shl Dir) and Conn <> 0 then
925 TSprite(x, y, spCanal + 1 + Dir);
926 end;
927 if Tile and (fRR or fCity) <> 0 then
928 RRConn := Connection8(Loc, fRR or fCity)
929 else
930 RRConn := 0;
931 if Tile and (fRoad or fRR or fCity) <> 0 then
932 begin // paint road connections
933 Conn := Connection8(Loc, fRoad or fRR or fCity) and not RRConn;
934 if (Conn = 0) and (Tile and (fRR or fCity) = 0) then
935 TSprite(x, y, spRoad)
936 else if Conn > 0 then
937 for Dir := 0 to 7 do
938 if (1 shl Dir) and Conn <> 0 then
939 TSprite(x, y, spRoad + 1 + Dir);
940 end;
941 // paint railroad connections
942 if (Tile and fRR <> 0) and (RRConn = 0) then
943 TSprite(x, y, spRailRoad)
944 else if RRConn > 0 then
945 for Dir := 0 to 7 do
946 if (1 shl Dir) and RRConn <> 0 then
947 TSprite(x, y, spRailRoad + 1 + Dir);
948 end;
949end;
950
951// (x,y) is top left pixel of (2*xxt,3*yyt) rectangle
952procedure TIsoMap.PaintTileObjects(x, y, Loc, CityLoc, CityOwner: integer;
953 UseBlink: boolean);
954var
955 p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: integer;
956 CityInfo: TCityInfo;
957 UnitInfo: TUnitInfo;
958 fog: boolean;
959 SpecialRow: Integer;
960 SpecialCol: Integer;
961
962 procedure NameCity;
963 var
964 cix, xs, w: integer;
965 BehindCityInfo: TCityInfo;
966 s: string;
967 IsCapital: boolean;
968 begin
969 BehindCityInfo.Loc := Loc - 2 * G.lx;
970 if ShowCityNames and (Options and (1 shl moEditMode) = 0) and
971 (BehindCityInfo.Loc >= 0) and (BehindCityInfo.Loc < G.lx * G.ly) and
972 (MyMap[BehindCityInfo.Loc] and fCity <> 0) then
973 begin
974 GetCityInfo(BehindCityInfo.Loc, cix, BehindCityInfo);
975 IsCapital := BehindCityInfo.Flags and ciCapital <> 0;
976 { if Showuix and (cix>=0) then s:=IntToStr(cix)
977 else } s := CityName(BehindCityInfo.ID);
978 w := FOutput.Canvas.TextWidth(s);
979 xs := x + xxt - (w + 1) div 2;
980 if IsCapital then
981 FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style + [fsUnderline];
982 Textout(xs + 1, y - 9, $000000, s);
983 Textout(xs, y - 10, $FFFFFF, s);
984 if IsCapital then
985 FOutput.Canvas.Font.Style := FOutput.Canvas.Font.Style - [fsUnderline];
986 end;
987 end;
988
989 procedure ShowSpacePort;
990 begin
991 if ShowObjects and (Options and (1 shl moEditMode) = 0) and
992 (Tile and fCity <> 0) and (CityInfo.Flags and ciSpacePort <> 0) then
993 TSprite(x + xxt, y - 6, spSpacePort);
994 end;
995
996 procedure PaintBorder;
997 var
998 dx, dy: integer;
999 PixelPtr: TPixelPointer;
1000 begin
1001 if ShowBorder and (Loc >= 0) and (Loc < G.lx * G.ly) and
1002 (Tile and fTerrain <> fUNKNOWN) then
1003 begin
1004 p1 := MyRO.Territory[Loc];
1005 if (p1 >= 0) and (ShowMyBorder or (p1 <> me)) then
1006 begin
1007 if BordersOK and (1 shl p1) = 0 then
1008 begin
1009 // Clearing before bitblt SRCCOPY shouldn't be neccesary but for some
1010 // reason without it code works different then under Delphi
1011 Borders.Canvas.FillRect(Bounds(0, p1 * (yyt * 2), xxt * 2, yyt * 2));
1012
1013 DpiBitBlt(Borders.Canvas.Handle, 0, p1 * (yyt * 2), xxt * 2,
1014 yyt * 2, GrExt[HGrTerrain].Data.Canvas.Handle,
1015 1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1), SRCCOPY);
1016 Borders.BeginUpdate;
1017 for dy := 0 to yyt * 2 - 1 do
1018 begin
1019 PixelPtr.Init(Borders, 0, p1 * (yyt * 2) + dy);
1020 for dx := 0 to xxt * 2 - 1 do begin
1021 if PixelPtr.Pixel^.B = 99 then begin
1022 PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF;
1023 PixelPtr.Pixel^.G := Tribe[p1].Color shr 8 and $FF;
1024 PixelPtr.Pixel^.R := Tribe[p1].Color and $FF;
1025 end;
1026 PixelPtr.NextPixel;
1027 end;
1028 end;
1029 Borders.EndUpdate;
1030 BordersOK := BordersOK or 1 shl p1;
1031 end;
1032 for dy := 0 to 1 do
1033 for dx := 0 to 1 do
1034 begin
1035 Loc1 := dLoc(Loc, dx * 2 - 1, dy * 2 - 1);
1036 begin
1037 if (Loc1 < 0) or (Loc1 >= G.lx * G.ly) then
1038 p2 := -1
1039 else if MyMap[Loc1] and fTerrain = fUNKNOWN then
1040 p2 := p1
1041 else
1042 p2 := MyRO.Territory[Loc1];
1043 if p2 <> p1 then
1044 begin
1045 BitBlt(GrExt[HGrTerrain].Mask, x + dx * xxt, y + dy * yyt, xxt,
1046 yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt,
1047 1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND);
1048 BitBlt(Borders, x + dx * xxt, y + dy * yyt, xxt, yyt, dx * xxt,
1049 p1 * (yyt * 2) + dy * yyt, SRCPAINT);
1050 end
1051 end;
1052 end
1053 end
1054 end;
1055 end;
1056
1057begin
1058 if (Loc < 0) or (Loc >= G.lx * G.ly) then
1059 Tile := PoleTile(Loc)
1060 else
1061 Tile := MyMap[Loc];
1062 if ShowObjects and (Options and (1 shl moEditMode) = 0) and
1063 (Tile and fCity <> 0) then
1064 GetCityInfo(Loc, cix, CityInfo);
1065 if (y <= FTop - yyt * 2) or (y > FBottom) or (x <= FLeft - xxt * 2) or
1066 (x > FRight) then
1067 begin
1068 NameCity;
1069 ShowSpacePort;
1070 exit;
1071 end;
1072 if Tile and fTerrain = fUNKNOWN then
1073 begin
1074 NameCity;
1075 ShowSpacePort;
1076 exit
1077 end; { square not discovered }
1078
1079 if not(FoW and (Tile and fObserved = 0)) then
1080 PaintBorder;
1081
1082 if (Loc >= 0) and (Loc < G.lx * G.ly) and (Loc = FAdviceLoc) then
1083 TSprite(x, y, spPlain);
1084
1085 if (Loc >= 0) and (Loc < G.lx * G.ly) and (Tile and fSpecial <> 0)
1086 then { special resources }
1087 begin
1088 dy := Loc div G.lx;
1089 SpecialCol := Tile and fTerrain;
1090 SpecialRow := Tile and fSpecial shr 5;
1091 if SpecialCol < fForest then
1092 TSprite(x, y, SpecialCol + SpecialRow * TerrainIconCols)
1093 else if (SpecialCol = fForest) and IsJungle(dy) then
1094 TSprite(x, y, spJungle - 1 + SpecialRow * TerrainIconCols)
1095 else
1096 TSprite(x, y, spForest - 1 + ((SpecialCol - fForest) * 2 + SpecialRow) * TerrainIconCols);
1097 end;
1098
1099 if ShowObjects then
1100 begin
1101 if Tile and fTerImp = tiMine then
1102 TSprite(x, y, spMine);
1103 if Tile and fTerImp = tiBase then
1104 TSprite(x, y, spBase);
1105 if Tile and fPoll <> 0 then
1106 TSprite(x, y, spPollution);
1107 if Tile and fTerImp = tiFort then
1108 begin
1109 TSprite(x, y, spFortBack);
1110 if Tile and fObserved = 0 then
1111 TSprite(x, y, spFortFront);
1112 end;
1113 end;
1114 if Tile and fDeadLands <> 0 then
1115 TSprite(x, y, (12 + Tile shr 25 and 3) * TerrainIconCols + 8);
1116
1117 if Options and (1 shl moEditMode) <> 0 then
1118 fog := (Loc < 0) or (Loc >= G.lx * G.ly)
1119 // else if CityLoc>=0 then
1120 // fog:= (Loc<0) or (Loc>=G.lx*G.ly) or (Distance(Loc,CityLoc)>5)
1121 else if ShowGrWall then
1122 fog := Tile and fGrWall = 0
1123 else
1124 fog := FoW and (Tile and fObserved = 0);
1125 if fog and ShowObjects then
1126 if Loc < -G.lx then
1127 Sprite(HGrTerrain, x, y + yyt, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),
1128 1 + yyt * 2 + 15 * (yyt * 3 + 1))
1129 else if Loc >= G.lx * (G.ly + 1) then
1130 Sprite(HGrTerrain, x, y, xxt * 2, yyt, 1 + 6 * (xxt * 2 + 1),
1131 1 + yyt + 15 * (yyt * 3 + 1))
1132 else
1133 TSprite(x, y, 6 + TerrainIconCols * 15, xxt <> 33);
1134
1135 if FoW and (Tile and fObserved = 0) then
1136 PaintBorder;
1137
1138{$IFNDEF SCR}
1139 // paint goto destination mark
1140 if DestinationMarkON and (CityOwner < 0) and (UnFocus >= 0) and
1141 (MyUn[UnFocus].Status and usGoto <> 0) then
1142 begin
1143 Destination := MyUn[UnFocus].Status shr 16;
1144 if (Destination = Loc) and (Destination <> MyUn[UnFocus].Loc) then
1145 if not UseBlink or BlinkOn then
1146 TSprite(x, y, spBlink1)
1147 else
1148 TSprite(x, y, spBlink2)
1149 end;
1150{$ENDIF}
1151 if Options and (1 shl moEditMode) <> 0 then
1152 begin
1153 if Tile and fPrefStartPos <> 0 then
1154 TSprite(x, y, spPrefStartPos)
1155 else if Tile and fStartPos <> 0 then
1156 TSprite(x, y, spStartPos);
1157 end
1158 else if ShowObjects then
1159 begin
1160 { if (CityLoc<0) and (UnFocus>=0) and (Loc=MyUn[UnFocus].Loc) then
1161 if BlinkOn then TSprite(x,y,8+9*0)
1162 else TSprite(x,y,8+9*1); }
1163
1164 NameCity;
1165 ShowSpacePort;
1166 if Tile and fCity <> 0 then
1167 PaintCity(x + xxt, y + yyt, CityInfo, CityOwner < 0);
1168
1169 if (Tile and fUnit <> 0) and (Loc <> AttLoc) and
1170 ((Loc <> DefLoc) or (DefHealth <> 0))
1171{$IFNDEF SCR} and ((CityOwner >= 0) or (UnFocus < 0) or not UseBlink or
1172 BlinkOn or (Loc <> MyUn[UnFocus].Loc)){$ENDIF}
1173 and ((Tile and fCity <> fCity) or (Loc = DefLoc)
1174{$IFNDEF SCR} or (not UseBlink or BlinkOn) and (UnFocus >= 0) and
1175 (Loc = MyUn[UnFocus].Loc){$ENDIF}) then
1176 begin { unit }
1177 GetUnitInfo(Loc, uix, UnitInfo);
1178 if (Loc = DefLoc) and (DefHealth >= 0) then
1179 UnitInfo.Health := DefHealth;
1180 if (UnitInfo.Owner <> CityOwner) and
1181 not((CityOwner = me) and (MyRO.Treaty[UnitInfo.Owner] = trAlliance))
1182 then
1183{$IFNDEF SCR} if (UnFocus >= 0) and (Loc = MyUn[UnFocus].Loc) then { active unit }
1184 begin
1185 Multi := UnitInfo.Flags and unMulti;
1186 MakeUnitInfo(me, MyUn[UnFocus], UnitInfo);
1187 UnitInfo.Flags := UnitInfo.Flags or Multi;
1188 PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo,
1189 MyUn[UnFocus].Status);
1190 end
1191 else if UnitInfo.Owner = me then
1192 begin
1193 if ClientMode = cMovieTurn then
1194 PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo, 0)
1195 // status is not set with precise timing during loading
1196 else
1197 PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo,
1198 MyUn[uix].Status);
1199 // if Showuix then Textout(x+16,y+5,$80FF00,IntToStr(uix));
1200 end
1201 else {$ENDIF} PaintUnit(x + (xxt - xxu), y + (yyt - yyu_anchor), UnitInfo, 0);
1202 end
1203 else if Tile and fHiddenUnit <> 0 then
1204 Sprite(HGrStdUnits, x + (xxt - xxu), y + (yyt - yyu_anchor), xxu * 2,
1205 yyu * 2, 1 + 5 * (xxu * 2 + 1), 1)
1206 else if Tile and fStealthUnit <> 0 then
1207 Sprite(HGrStdUnits, x + (xxt - xxu), y + (yyt - yyu_anchor), xxu * 2,
1208 yyu * 2, 1 + 5 * (xxu * 2 + 1), 1 + 1 * (yyu * 2 + 1))
1209 end;
1210
1211 if ShowObjects and (Tile and fTerImp = tiFort) and (Tile and fObserved <> 0)
1212 then
1213 TSprite(x, y, spFortFront);
1214
1215 if (Loc >= 0) and (Loc < G.lx * G.ly) then
1216 if ShowLoc then
1217 Textout(x + xxt - 16, y + yyt - 9, $FFFF00, IntToStr(Loc))
1218 else if ShowDebug and (DebugMap <> nil) and (Loc >= 0) and
1219 (Loc < G.lx * G.ly) and (DebugMap[Loc] <> 0) then
1220 Textout(x + xxt - 16, y + yyt - 9, $00E0FF,
1221 IntToStr(integer(DebugMap[Loc])))
1222end; { PaintTileObjects }
1223
1224procedure TIsoMap.PaintGrid(x, y, nx, ny: integer);
1225
1226 procedure ClippedLine(dx0, dy0: integer; mirror: boolean);
1227 var
1228 x0, x1, dxmin, dymin, dxmax, dymax, n: integer;
1229 begin
1230 with FOutput.Canvas do
1231 begin
1232 dxmin := (FLeft - x) div xxt;
1233 dymin := (RealTop - y) div yyt;
1234 dxmax := (FRight - x - 1) div xxt + 1;
1235 dymax := (RealBottom - y - 1) div yyt + 1;
1236 n := dymax - dy0;
1237 if mirror then
1238 begin
1239 if dx0 - dxmin < n then
1240 n := dx0 - dxmin;
1241 if dx0 > dxmax then
1242 begin
1243 n := n - (dx0 - dxmax);
1244 dy0 := dy0 + (dx0 - dxmax);
1245 dx0 := dxmax
1246 end;
1247 if dy0 < dymin then
1248 begin
1249 n := n - (dymin - dy0);
1250 dx0 := dx0 - (dymin - dy0);
1251 dy0 := dymin
1252 end;
1253 end
1254 else
1255 begin
1256 if dxmax - dx0 < n then
1257 n := dxmax - dx0;
1258 if dx0 < dxmin then
1259 begin
1260 n := n - (dxmin - dx0);
1261 dy0 := dy0 + (dxmin - dx0);
1262 dx0 := dxmin
1263 end;
1264 if dy0 < dymin then
1265 begin
1266 n := n - (dymin - dy0);
1267 dx0 := dx0 + (dymin - dy0);
1268 dy0 := dymin
1269 end;
1270 end;
1271 if n <= 0 then
1272 exit;
1273 if mirror then
1274 begin
1275 x0 := x + dx0 * xxt - 1;
1276 x1 := x + (dx0 - n) * xxt - 1;
1277 end
1278 else
1279 begin
1280 x0 := x + dx0 * xxt;
1281 x1 := x + (dx0 + n) * xxt;
1282 end;
1283 moveto(x0, y + dy0 * yyt);
1284 lineto(x1, y + (dy0 + n) * yyt);
1285 end
1286 end;
1287
1288var
1289 i: integer;
1290begin
1291 FOutput.Canvas.pen.Color := $000000; // $FF shl (8*random(3));
1292 for i := 0 to nx div 2 do
1293 ClippedLine(i * 2, 0, false);
1294 for i := 1 to (nx + 1) div 2 do
1295 ClippedLine(i * 2, 0, true);
1296 for i := 0 to ny div 2 do
1297 begin
1298 ClippedLine(0, 2 * i + 2, false);
1299 ClippedLine(nx + 1, 2 * i + 1 + nx and 1, true);
1300 end;
1301end;
1302
1303function TIsoMap.IsShoreTile(Loc: integer): boolean;
1304const
1305 Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0);
1306 Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2);
1307var
1308 Dir, ConnLoc: integer;
1309begin
1310 result := false;
1311 for Dir := 0 to 7 do
1312 begin
1313 ConnLoc := dLoc(Loc, Dirx[Dir], Diry[Dir]);
1314 if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or
1315 ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
1316 result := true
1317 end
1318end;
1319
1320procedure TIsoMap.MakeDark(Line: PPixelPointer; Length: Integer);
1321var
1322 I: Integer;
1323begin
1324 for I := 0 to Length - 1 do begin
1325 Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7f;
1326 Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7f;
1327 Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7f;
1328 Line^.NextPixel;
1329 end;
1330end;
1331
1332procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer);
1333const
1334 rShade = 3.75;
1335var
1336 y, wBright: integer;
1337 y_n, w_n: single;
1338 Line: TPixelPointer;
1339begin
1340 FOutput.BeginUpdate;
1341 for y := y0 to y1 - 1 do begin
1342 Line.Init(FOutput, 0, y);
1343 y_n := (y - ym) / yyt;
1344 if abs(y_n) < rShade then begin
1345 // Darken left and right parts of elipsis
1346 w_n := sqrt(sqr(rShade) - sqr(y_n));
1347 wBright := trunc(w_n * xxt + 0.5);
1348 Line.SetX(x0);
1349 MakeDark(@Line, xm - x0 - wBright);
1350 Line.SetX(xm + wBright);
1351 MakeDark(@Line, x1 - xm - wBright);
1352 end else begin
1353 // Darken entire line
1354 Line.SetX(x0);
1355 MakeDark(@Line, x1 - x0);
1356 end;
1357 end;
1358 FOutput.EndUpdate;
1359end;
1360
1361procedure TIsoMap.CityGrid(xm, ym: integer; CityAllowClick: Boolean);
1362var
1363 i: integer;
1364begin
1365 with FOutput.Canvas do
1366 begin
1367 if CityAllowClick then
1368 pen.Color := $FFFFFF
1369 else
1370 pen.Color := $000000;
1371 pen.Width := 1;
1372 for i := 0 to 3 do
1373 begin
1374 moveto(xm - xxt * (4 - i), ym + yyt * (1 + i));
1375 lineto(xm + xxt * (1 + i), ym - yyt * (4 - i));
1376 moveto(xm - xxt * (4 - i), ym - yyt * (1 + i));
1377 lineto(xm + xxt * (1 + i), ym + yyt * (4 - i));
1378 end;
1379 moveto(xm - xxt * 4, ym + yyt * 1);
1380 lineto(xm - xxt * 1, ym + yyt * 4);
1381 moveto(xm + xxt * 1, ym + yyt * 4);
1382 lineto(xm + xxt * 4, ym + yyt * 1);
1383 moveto(xm - xxt * 4, ym - yyt * 1);
1384 lineto(xm - xxt * 1, ym - yyt * 4);
1385 moveto(xm + xxt * 1, ym - yyt * 4);
1386 lineto(xm + xxt * 4, ym - yyt * 1);
1387 pen.Width := 1;
1388 end
1389end;
1390
1391procedure TIsoMap.Paint(x, y, Loc, nx, ny, CityLoc, CityOwner: integer;
1392 UseBlink: boolean; CityAllowClick: boolean);
1393var
1394 dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: integer;
1395begin
1396 FoW := true;
1397 ShowLoc := Options and (1 shl moLocCodes) <> 0;
1398 ShowDebug := pDebugMap >= 0;
1399 ShowObjects := (CityOwner >= 0) or (Options and (1 shl moBareTerrain) = 0);
1400 ShowCityNames := ShowObjects and (CityOwner < 0) and
1401 (Options and (1 shl moCityNames) <> 0);
1402 ShowBorder := true;
1403 ShowMyBorder := CityOwner < 0;
1404 ShowGrWall := (CityOwner < 0) and (Options and (1 shl moGreatWall) <> 0);
1405 if ShowDebug then
1406 Server(sGetDebugMap, me, pDebugMap, DebugMap)
1407 else
1408 DebugMap := nil;
1409 with FOutput.Canvas do
1410 begin
1411 RealTop := y - ((Loc + 12345 * G.lx) div G.lx - 12345) * yyt;
1412 RealBottom := y + (G.ly - ((Loc + 12345 * G.lx) div G.lx - 12345) +
1413 3) * yyt;
1414 Brush.Color := EmptySpaceColor;
1415 if RealTop > FTop then
1416 FillRect(Rect(FLeft, FTop, FRight, RealTop))
1417 else
1418 RealTop := FTop;
1419 if RealBottom < FBottom then
1420 FillRect(Rect(FLeft, RealBottom, FRight, FBottom))
1421 else
1422 RealBottom := FBottom;
1423 Brush.Color := $000000;
1424 FillRect(Rect(FLeft, RealTop, FRight, RealBottom));
1425 Brush.Style := bsClear;
1426 end;
1427
1428 for dy := 0 to ny + 1 do
1429 if (Loc + dy * G.lx >= 0) and (Loc + (dy - 3) * G.lx < G.lx * G.ly) then
1430 for dx := 0 to nx do
1431 begin
1432 ALoc := dLoc(Loc, dx - (dy + dx) and 1, dy - 2);
1433 BLoc := dLoc(Loc, dx - (dy + dx + 1) and 1, dy - 1);
1434 if (ALoc < 0) or (ALoc >= G.lx * G.ly) then
1435 ATer := PoleTile(ALoc) and fTerrain
1436 else
1437 ATer := MyMap[ALoc] and fTerrain;
1438 if (BLoc < 0) or (BLoc >= G.lx * G.ly) then
1439 BTer := PoleTile(BLoc) and fTerrain
1440 else
1441 BTer := MyMap[BLoc] and fTerrain;
1442
1443 if (ATer <> fUNKNOWN) or (BTer <> fUNKNOWN) then
1444 if ((ATer < fGrass) or (ATer = fUNKNOWN)) and
1445 ((BTer < fGrass) or (BTer = fUNKNOWN)) then
1446 begin
1447 if ATer = fUNKNOWN then
1448 Aix := 0
1449 else if IsShoreTile(ALoc) then
1450 if ATer = fOcean then
1451 Aix := -1
1452 else
1453 Aix := 1
1454 else
1455 Aix := ATer + 2;
1456 if BTer = fUNKNOWN then
1457 bix := 0
1458 else if IsShoreTile(BLoc) then
1459 if BTer = fOcean then
1460 bix := -1
1461 else
1462 bix := 1
1463 else
1464 bix := BTer + 2;
1465 if (Aix > 1) or (bix > 1) then
1466 begin
1467 if Aix = -1 then
1468 if bix = fOcean + 2 then
1469 begin
1470 Aix := 0;
1471 bix := 0
1472 end
1473 else
1474 begin
1475 Aix := 0;
1476 bix := 1
1477 end
1478 else if bix = -1 then
1479 if Aix = fOcean + 2 then
1480 begin
1481 Aix := 1;
1482 bix := 1
1483 end
1484 else
1485 begin
1486 Aix := 1;
1487 bix := 0
1488 end;
1489 BitBlt(OceanPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
1490 Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
1491 end
1492 end
1493 else
1494 begin
1495 if ATer = fUNKNOWN then
1496 Aix := 0
1497 else if (ALoc >= 0) and (ALoc < G.lx * G.ly) and
1498 (MyMap[ALoc] and fDeadLands <> 0) then
1499 Aix := -2
1500 else if ATer = fOcean then
1501 Aix := -1
1502 else if ATer = fShore then
1503 Aix := 1
1504 else if ATer >= fForest then
1505 Aix := 8
1506 else
1507 Aix := ATer;
1508 if BTer = fUNKNOWN then
1509 bix := 0
1510 else if (BLoc >= 0) and (BLoc < G.lx * G.ly) and
1511 (MyMap[BLoc] and fDeadLands <> 0) then
1512 bix := -2
1513 else if BTer = fOcean then
1514 bix := -1
1515 else if BTer = fShore then
1516 bix := 1
1517 else if BTer >= fForest then
1518 bix := 8
1519 else
1520 bix := BTer;
1521 if (Aix = -2) and (bix = -2) then
1522 begin
1523 Aix := fDesert;
1524 bix := fDesert
1525 end
1526 else if Aix = -2 then
1527 if bix < 2 then
1528 Aix := 8
1529 else
1530 Aix := bix
1531 else if bix = -2 then
1532 if Aix < 2 then
1533 bix := 8
1534 else
1535 bix := Aix;
1536 if Aix = -1 then
1537 BitBlt(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
1538 yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt,
1539 SRCCOPY) // arctic <-> ocean
1540 else if bix = -1 then
1541 BitBlt(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
1542 yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt,
1543 1 + yyt * 2, SRCCOPY) // arctic <-> ocean
1544 else
1545 BitBlt(LandPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
1546 Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
1547 end
1548 end;
1549
1550 DataDC := GrExt[HGrTerrain].Data.Canvas.Handle;
1551 MaskDC := GrExt[HGrTerrain].Mask.Canvas.Handle;
1552 for dy := -2 to ny + 1 do
1553 for dx := -1 to nx do
1554 if (dx + dy) and 1 = 0 then
1555 PaintShore(x + xxt * dx, y + yyt + yyt * dy, dLoc(Loc, dx, dy));
1556 for dy := -2 to ny + 1 do
1557 for dx := -1 to nx do
1558 if (dx + dy) and 1 = 0 then
1559 PaintTileExtraTerrain(x + xxt * dx, y + yyt + yyt * dy,
1560 dLoc(Loc, dx, dy));
1561 if CityOwner >= 0 then
1562 begin
1563 for dy := -2 to ny + 1 do
1564 for dx := -2 to nx + 1 do
1565 if (dx + dy) and 1 = 0 then
1566 begin
1567 ALoc := dLoc(Loc, dx, dy);
1568 if Distance(ALoc, CityLoc) > 5 then
1569 PaintTileObjects(x + xxt * dx, y + yyt + yyt * dy, ALoc, CityLoc,
1570 CityOwner, UseBlink);
1571 end;
1572 dx := ((CityLoc mod G.lx * 2 + CityLoc div G.lx and 1) -
1573 ((Loc + 666 * G.lx) mod G.lx * 2 + (Loc + 666 * G.lx) div G.lx and 1) + 3
1574 * G.lx) mod (2 * G.lx) - G.lx;
1575 dy := CityLoc div G.lx - (Loc + 666 * G.lx) div G.lx + 666;
1576 xm := x + (dx + 1) * xxt;
1577 ym := y + (dy + 1) * yyt + yyt;
1578 ShadeOutside(FLeft, FTop, FRight, FBottom, xm, ym);
1579 CityGrid(xm, ym, CityAllowClick);
1580 for dy := -2 to ny + 1 do
1581 for dx := -2 to nx + 1 do
1582 if (dx + dy) and 1 = 0 then
1583 begin
1584 ALoc := dLoc(Loc, dx, dy);
1585 if Distance(ALoc, CityLoc) <= 5 then
1586 PaintTileObjects(x + xxt * dx, y + yyt + yyt * dy, ALoc, CityLoc,
1587 CityOwner, UseBlink);
1588 end;
1589 end
1590 else
1591 begin
1592 if ShowLoc or (Options and (1 shl moEditMode) <> 0) or
1593 (Options and (1 shl moGrid) <> 0) then
1594 PaintGrid(x, y, nx, ny);
1595 for dy := -2 to ny + 1 do
1596 for dx := -2 to nx + 1 do
1597 if (dx + dy) and 1 = 0 then
1598 PaintTileObjects(x + xxt * dx, y + yyt + yyt * dy, dLoc(Loc, dx, dy),
1599 CityLoc, CityOwner, UseBlink);
1600 end;
1601
1602 // frame(FOutput.Canvas,x+1,y+1,x+nx*33+33-2,y+ny*16+32-2,$FFFF,$FFFF);
1603end; { Paint }
1604
1605procedure TIsoMap.AttackBegin(const ShowMove: TShowMove);
1606begin
1607 AttLoc := ShowMove.FromLoc;
1608 DefLoc := dLoc(AttLoc, ShowMove.dx, ShowMove.dy);
1609 DefHealth := -1;
1610end;
1611
1612procedure TIsoMap.AttackEffect(const ShowMove: TShowMove);
1613begin
1614 DefHealth := ShowMove.EndHealthDef;
1615end;
1616
1617procedure TIsoMap.AttackEnd;
1618begin
1619 AttLoc := -1;
1620 DefLoc := -1;
1621end;
1622
1623initialization
1624
1625NoMap := nil;
1626LandPatch := nil;
1627OceanPatch := nil;
1628Borders := nil;
1629
1630end.
Note: See TracBrowser for help on using the repository browser.