Crossfire JXClient, Trunk  R20561
CfMap.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.map;
23 
27 import java.util.Collection;
28 import java.util.HashMap;
29 import java.util.HashSet;
30 import java.util.Map;
31 import java.util.Set;
32 import org.jetbrains.annotations.NotNull;
33 import org.jetbrains.annotations.Nullable;
34 
45 public class CfMap {
46 
50  private int minX;
51 
55  private int maxX = -1;
56 
60  private int minY;
61 
65  private int maxY = -1;
66 
70  private int minPx;
71 
75  private int maxPx = -1;
76 
80  private int minPy;
81 
85  private int maxPy = -1;
86 
91  private int ox;
92 
97  private int oy;
98 
102  private int patchX;
103 
107  private int patchY;
108 
112  @Nullable
113  private CfMapPatch[][] patch;
114 
118  @NotNull
119  private final Set<CfMapSquare> dirtyMapSquares = new HashSet<>();
120 
125  @NotNull
126  private final Map<Integer, Collection<CfMapSquare>> pendingFaceSquares = new HashMap<>();
127 
133  public void reset(final int mapWidth, final int mapHeight) {
134  minX = 0;
135  maxX = -1;
136  minY = 0;
137  maxY = -1;
138  minPx = 0;
139  maxPx = -1;
140  minPy = 0;
141  maxPy = -1;
142  patchX = 0;
143  patchY = 0;
144  patch = null;
145  dirtyMapSquares.clear();
146  pendingFaceSquares.clear();
147 
148  // force dirty flags to be set for the visible map region
149  clearSquare(0, 0);
150  clearSquare(mapWidth-1, mapHeight-1);
151  }
152 
159  public void setDarkness(final int x, final int y, final int darkness) {
160  assert Thread.holdsLock(this);
161  if (expandTo(x, y).setDarkness(ox, oy, darkness)) {
162  for (int l = 0; l < Map2.NUM_LAYERS; l++) {
164  }
165  }
166  }
167 
175  public int getDarkness(final int x, final int y) {
176  assert Thread.holdsLock(this);
177  final CfMapPatch mapPatch = getMapPatch(x, y);
178  return mapPatch == null ? CfMapSquare.DEFAULT_DARKNESS : mapPatch.getDarkness(ox, oy);
179  }
180 
188  public void setSmooth(final int x, final int y, final int layer, final int smooth) {
189  final int result = expandTo(x, y).setSmooth(ox, oy, layer, smooth);
190  if ((result&1) != 0) {
191  for (int l = 0; l < Map2.NUM_LAYERS; l++) {
193  }
194  }
195  if ((result&2) != 0) {
196  for (int dx = -1; dx <= +1; dx++) {
197  for (int dy = -1; dy <= +1; dy++) {
198  squareModified(getMapSquare(x+dx, y+dy));
199  }
200  }
201  }
202  }
203 
211  public int getSmooth(final int x, final int y, final int layer) {
212  final CfMapPatch mapPatch = getMapPatch(x, y);
213  final int result = mapPatch == null ? CfMapSquare.DEFAULT_SMOOTH : mapPatch.getSmooth(ox, oy, layer);
214  return result;
215  }
216 
223  public void setMagicMap(final int x0, final int y0, final byte[][] data) {
224  assert Thread.holdsLock(this);
225  for (int y = 0; y < data.length; y++) {
226  for (int x = 0; x < data[y].length; x++) {
227  final int color = data[y][x]&MagicMap.FACE_COLOR_MASK;
228  if (expandTo(x0+x, y0+y).setColor(ox, oy, color)) {
229  for (int l = 0; l < Map2.NUM_LAYERS; l++) {
231  }
232  }
233  }
234  }
235  }
236 
243  public int getColor(final int x, final int y) {
244  assert Thread.holdsLock(this);
245  final CfMapPatch mapPatch = getMapPatch(x, y);
246  return mapPatch == null ? CfMapSquare.DEFAULT_COLOR : mapPatch.getColor(ox, oy);
247  }
248 
257  public void setFace(final int x, final int y, final int layer, @Nullable final Face face) {
258  assert Thread.holdsLock(this);
259  if (expandTo(x, y).resetFogOfWar(ox, oy)) {
261  for (int l = 0; l < Map2.NUM_LAYERS; l++) {
262  setFaceInternal(x, y, l, l == layer ? face : CfMapSquare.DEFAULT_FACE);
263  }
264  dirty(x, y);
265  } else {
266  setFaceInternal(x, y, layer, face);
267  }
268  }
269 
277  private void setFaceInternal(final int x, final int y, final int layer, @Nullable final Face face) {
278  final CfMapSquare headMapSquare = expandTo(x, y).getSquare(ox, oy);
279 
280  final Face oldFace = headMapSquare.getFace(layer);
281  if (oldFace != null) {
282  expandFace(x, y, layer, oldFace, headMapSquare, null);
283  }
284  headMapSquare.setFace(layer, face);
285  if (face != null) {
286  expandFace(x, y, layer, face, headMapSquare, headMapSquare);
287  }
288  }
289 
300  private void expandFace(final int x, final int y, final int layer, @NotNull final Face face, @NotNull final CfMapSquare oldMapSquare, @Nullable final CfMapSquare newMapSquare) {
301  final int sx = face.getTileWidth();
302  final int sy = face.getTileHeight();
303  for (int dx = 0; dx < sx; dx++) {
304  for (int dy = 0; dy < sy; dy++) {
305  if (dx > 0 || dy > 0) {
306  if (newMapSquare != null) {
307  setHeadMapSquare(x-dx, y-dy, layer, newMapSquare, true);
308  } else if (getHeadMapSquare(x-dx, y-dy, layer) == oldMapSquare) {
309  setHeadMapSquare(x-dx, y-dy, layer, null, true);
310  }
311  }
312  }
313  }
314  }
315 
324  private void dirtyFace(final int x, final int y, final int layer, @NotNull final Face face) {
325  final int sx = face.getTileWidth();
326  final int sy = face.getTileHeight();
327  for (int dx = 0; dx < sx; dx++) {
328  for (int dy = 0; dy < sy; dy++) {
329  if (dx > 0 || dy > 0) {
330  if (isFogOfWar(x-dx, y-dy)) {
331  dirty(x-dx, y-dy);
332  } else {
333  setHeadMapSquare(x-dx, y-dy, layer, null, false);
334  }
335  }
336  }
337  }
338  }
339 
347  @Nullable
348  public Face getFace(final int x, final int y, final int layer) {
349  assert Thread.holdsLock(this);
350  final CfMapPatch mapPatch = getMapPatch(x, y);
351  return mapPatch == null ? CfMapSquare.DEFAULT_FACE : mapPatch.getFace(ox, oy, layer);
352  }
353 
365  private void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways) {
366  expandTo(x, y).setHeadMapSquare(ox, oy, layer, mapSquare, setAlways);
367  }
368 
377  @Nullable
378  public CfMapSquare getHeadMapSquare(final int x, final int y, final int layer) {
379  assert Thread.holdsLock(this);
380  final CfMapPatch mapPatch = getMapPatch(x, y);
381  return mapPatch == null ? null : mapPatch.getHeadMapSquare(ox, oy, layer);
382  }
383 
390  public void clearSquare(final int x, final int y) {
391  assert Thread.holdsLock(this);
392  final CfMapPatch mapPatch = expandTo(x, y);
393  mapPatch.clearSquare(ox, oy);
394  for (int layer = 0; layer < Map2.NUM_LAYERS; layer++) {
395  final Face face = mapPatch.getFace(ox, oy, layer);
396  if (face != null) {
397  dirtyFace(x, y, layer, face);
398  }
399  }
400  }
401 
407  public void dirty(final int x, final int y) {
408  assert Thread.holdsLock(this);
409  expandTo(x, y).dirty(ox, oy);
410  }
411 
418  public boolean isFogOfWar(final int x, final int y) {
419  assert Thread.holdsLock(this);
420  final CfMapPatch mapPatch = getMapPatch(x, y);
421  return mapPatch != null && mapPatch.isFogOfWar(ox, oy);
422  }
423 
432  @Nullable
433  private CfMapPatch getMapPatch(final int x, final int y) {
434  if (x < minX || x > maxX || y < minY || y > maxY) {
435  return null;
436  }
437 
438  final int px = ((x-patchX)>>CfMapPatch.SIZE_LOG)-minPx;
439  final int py = ((y-patchY)>>CfMapPatch.SIZE_LOG)-minPy;
440  assert px >= 0;
441  assert py >= 0;
442  assert px <= maxPx-minPx;
443  assert py <= maxPy-minPy;
444  ox = (x-patchX)&(CfMapPatch.SIZE-1);
445  oy = (y-patchY)&(CfMapPatch.SIZE-1);
446  assert ox >= 0;
447  assert oy >= 0;
448  assert ox < CfMapPatch.SIZE;
449  assert oy < CfMapPatch.SIZE;
450 
451  assert patch != null;
452  assert patch[px] != null;
453  final CfMapPatch mapPatch = patch[px][py];
454  if (mapPatch != null) {
455  return mapPatch;
456  }
457 
458  patch[px][py] = new CfMapPatch(this, x-patchX-ox, y-patchY-oy);
459  assert patch != null;
460  assert patch[px] != null;
461  return patch[px][py];
462  }
463 
469  private void scroll(final int dx, final int dy) {
470  assert Thread.holdsLock(this);
471  if (dx == 0 && dy == 0) {
472  return;
473  }
474 
475  minX += dx;
476  maxX += dx;
477  minY += dy;
478  maxY += dy;
479  patchX += dx;
480  patchY += dy;
481  }
482 
490  @NotNull
491  private CfMapPatch expandTo(final int x, final int y) {
492  if (minX > maxX || minY > maxY) {
493  // current map is undefined ==> start with 1x1 map
494  minX = x;
495  maxX = x;
496  minY = y;
497  maxY = y;
498  minPx = (x-patchX)>>CfMapPatch.SIZE_LOG;
499  maxPx = minPx;
500  minPy = (y-patchY)>>CfMapPatch.SIZE_LOG;
501  maxPy = minPy;
502  patch = new CfMapPatch[1][1];
503  //noinspection AssignmentToNull
504  patch[0][0] = null;
505  } else {
506  if (x < minX) {
507  increase(x-minX, 0);
508  }
509  if (x > maxX) {
510  increase(x-maxX, 0);
511  }
512  if (y < minY) {
513  increase(0, y-minY);
514  }
515  if (y > maxY) {
516  increase(0, y-maxY);
517  }
518  }
519 
520  final CfMapPatch result = getMapPatch(x, y);
521  assert result != null;
522  return result;
523  }
524 
532  private void increase(final int dx, final int dy) {
533  if (dx < 0) {
534  final int newMinX = minX+dx;
535  final int newMinPx = (newMinX-patchX)>>CfMapPatch.SIZE_LOG;
536  final int diffPw = minPx-newMinPx;
537  if (diffPw == 0) {
538  // new size fits within current patch ==> no change to
539  // <code>patch</code>
540  minX = newMinX;
541  } else {
542  // need to add (diffPw) patches to the left
543 
544  assert diffPw > 0;
545 
546  final int newPw = size(newMinPx, maxPx);
547  final int newPh = size(minPy, maxPy);
548  assert patch != null;
549  final int oldPw = patch.length;
550  final int oldPh = patch[0].length;
551 
552  // new width must be more than old size
553  assert newPw > oldPw;
554  assert newPw == oldPw+diffPw;
555  assert newPh == oldPh;
556 
557  minX = newMinX;
558  minPx = newMinPx;
559  patch = copyPatches(newPw, newPh, diffPw, 0, oldPw, oldPh);
560  }
561  } else if (dx > 0) {
562  final int newMaxX = maxX+dx;
563  final int newMaxPx = (newMaxX-patchX)>>CfMapPatch.SIZE_LOG;
564  final int diffPw = newMaxPx-maxPx;
565  if (diffPw == 0) {
566  // new size fits within current patch ==> no change to
567  // <code>patch</code>
568  maxX = newMaxX;
569  } else {
570  // need to add (diffPw) patches to the right
571 
572  assert diffPw > 0;
573 
574  final int newPw = size(minPx, newMaxPx);
575  final int newPh = size(minPy, maxPy);
576  assert patch != null;
577  final int oldPw = patch.length;
578  final int oldPh = patch[0].length;
579 
580  // new width must be more than old size
581  assert newPw > oldPw;
582  assert newPw == oldPw+diffPw;
583  assert newPh == oldPh;
584 
585  maxX = newMaxX;
586  maxPx = newMaxPx;
587  patch = copyPatches(newPw, newPh, 0, 0, oldPw, oldPh);
588  }
589  }
590 
591  if (dy < 0) {
592  final int newMinY = minY+dy;
593  final int newMinPy = (newMinY-patchY)>>CfMapPatch.SIZE_LOG;
594  final int diffPh = minPy-newMinPy;
595  if (diffPh == 0) {
596  // new size fits within current patch ==> no change to
597  // <code>patch</code>
598  minY = newMinY;
599  } else {
600  // need to add (diffPh) patches to the top
601 
602  assert diffPh > 0;
603 
604  final int newPw = size(minPx, maxPx);
605  final int newPh = size(newMinPy, maxPy);
606  assert patch != null;
607  final int oldPw = patch.length;
608  final int oldPh = patch[0].length;
609 
610  // new height must be more than old size
611  assert newPh > oldPh;
612  assert newPh == oldPh+diffPh;
613  assert newPw == oldPw;
614 
615  minY = newMinY;
616  minPy = newMinPy;
617  patch = copyPatches(newPw, newPh, 0, diffPh, oldPw, oldPh);
618  }
619  } else if (dy > 0) {
620  final int newMaxY = maxY+dy;
621  final int newMaxPy = (newMaxY-patchY)>>CfMapPatch.SIZE_LOG;
622  final int diffPh = newMaxPy-maxPy;
623  if (diffPh == 0) {
624  // new size fits within current patch ==> no change to
625  // <code>patch</code>
626  maxY = newMaxY;
627  } else {
628  // need to add (diffPh) patches to the bottom
629 
630  assert diffPh > 0;
631 
632  final int newPw = size(minPx, maxPx);
633  final int newPh = size(minPy, newMaxPy);
634  assert patch != null;
635  final int oldPw = patch.length;
636  final int oldPh = patch[0].length;
637 
638  // new height must be more than old size
639  assert newPh > oldPh;
640  assert newPh == oldPh+diffPh;
641  assert newPw == oldPw;
642 
643  maxY = newMaxY;
644  maxPy = newMaxPy;
645  patch = copyPatches(newPw, newPh, 0, 0, oldPw, oldPh);
646  }
647  }
648  }
649 
657  private static int size(final int min, final int max) {
658  return max-min+1;
659  }
660 
667  @NotNull
668  public CfMapSquare getMapSquare(final int x, final int y) {
669  assert Thread.holdsLock(this);
670  return expandTo(x, y).getSquare(ox, oy);
671  }
672 
679  @Nullable
680  public CfMapSquare getMapSquareUnlessDirty(final int x, final int y) {
681  assert Thread.holdsLock(this);
682  final CfMapSquare mapSquare = getMapSquare(x, y);
683  return dirtyMapSquares.contains(mapSquare) ? null : mapSquare;
684  }
685 
691  public int getOffsetX() {
692  assert Thread.holdsLock(this);
693  return patchX;
694  }
695 
701  public int getOffsetY() {
702  assert Thread.holdsLock(this);
703  return patchY;
704  }
705 
716  @NotNull
717  private CfMapPatch[][] copyPatches(final int newWidth, final int newHeight, final int offsetX, final int offsetY, final int height, final int width) {
718  assert patch != null;
719  final CfMapPatch[][] newPatch = new CfMapPatch[newWidth][newHeight];
720  for (int y = 0; y < width; y++) {
721  for (int x = 0; x < height; x++) {
722  newPatch[offsetX+x][offsetY+y] = patch[x][y];
723  }
724  }
725  return newPatch;
726  }
727 
732  public void squareModified(@NotNull final CfMapSquare mapSquare) {
733  assert Thread.holdsLock(this);
734  dirtyMapSquares.add(mapSquare);
735  }
736 
743  public void squarePendingFace(final int x, final int y, final int faceNum) {
744  assert Thread.holdsLock(this);
745  final Integer tmpFaceNum = faceNum;
746  Collection<CfMapSquare> mapSquares = pendingFaceSquares.get(tmpFaceNum);
747  if (mapSquares == null) {
748  mapSquares = new HashSet<>();
749  pendingFaceSquares.put(tmpFaceNum, mapSquares);
750  }
751  mapSquares.add(getMapSquare(x, y));
752  }
753 
758  @NotNull
759  public Set<CfMapSquare> getDirtyMapSquares() {
760  assert Thread.holdsLock(this);
761  final Set<CfMapSquare> result = new HashSet<>(dirtyMapSquares);
762  dirtyMapSquares.clear();
763  return result;
764  }
765 
772  public void updateFace(final int faceNum, final int width, final int height) {
773  for (int y = 0; y < height; y++) {
774  for (int x = 0; x < width; x++) {
775  for (int layer = 0; layer < Map2.NUM_LAYERS; layer++) {
776  final Face face = getFace(x, y, layer);
777  if (face != null && face.getFaceNum() == faceNum) {
778  setFace(x, y, layer, face);
779  dirty(x, y);
780  }
781  }
782  }
783  }
784 
785  final Collection<CfMapSquare> mapSquares = pendingFaceSquares.remove(faceNum);
786  if (mapSquares != null) {
787  dirtyMapSquares.addAll(mapSquares);
788  }
789  }
790 
799  public boolean processMapScroll(final int dx, final int dy, final int width, final int height) {
800  if (Math.abs(dx) >= width || Math.abs(dy) >= height) {
801  scroll(dx, dy);
802  for (int y = 0; y < height; y++) {
803  for (int x = 0; x < width; x++) {
804  clearSquare(x, y);
805  }
806  }
807 
808  return true;
809  }
810 
811  int tx = dx;
812  while (tx > 0) {
813  scroll(-1, 0);
814  for (int y = 0; y < height; y++) {
815  clearSquare(-1, y);
816  clearSquare(width-1, y);
817  }
818  tx--;
819  }
820  while (tx < 0) {
821  scroll(+1, 0);
822  for (int y = 0; y < height; y++) {
823  clearSquare(0, y);
824  clearSquare(width, y);
825  }
826  tx++;
827  }
828 
829  int ty = dy;
830  while (ty > 0) {
831  scroll(0, -1);
832  for (int x = 0; x < width; x++) {
833  clearSquare(x, -1);
834  clearSquare(x, height-1);
835  }
836  ty--;
837  }
838  while (ty < 0) {
839  scroll(0, +1);
840  for (int x = 0; x <= width; x++) {
841  clearSquare(x, 0);
842  clearSquare(x, height);
843  }
844  ty++;
845  }
846 
847  return false;
848  }
849 
850 }
int maxX
The right edge of the defined tiles.
Definition: CfMap.java:55
void squarePendingFace(final int x, final int y, final int faceNum)
Marks a CfMapSquare as containing a pending face.
Definition: CfMap.java:743
int maxY
The bottom edge of the defined tiles.
Definition: CfMap.java:65
CfMapSquare getSquare(final int x, final int y)
Returns one map square.
void setFace(final int x, final int y, final int layer, @Nullable final Face face)
Sets the face of one square.
Definition: CfMap.java:257
void setDarkness(final int x, final int y, final int darkness)
Sets the darkness value of one square.
Definition: CfMap.java:159
Represents a square in a CfMap.
int oy
Result values for getMapPatch(int, int) and expandTo(int, int).
Definition: CfMap.java:97
static final int DEFAULT_DARKNESS
The default darkness value for newly created squares.
Represents a map (as seen by the client).
Definition: CfMap.java:45
Face getFace(final int x, final int y, final int layer)
Determines the face of one square.
Definition: CfMap.java:348
static final int SIZE
Size of patches in x- and y-direction.
Definition: CfMapPatch.java:42
void clearSquare(final int x, final int y)
Clears the content of one square.
Definition: CfMapPatch.java:82
void setFace(final int layer, @Nullable final Face face)
Sets the face of a layer.
int getOffsetX()
Returns the offset to convert an absolute x-coordinate of a map square (CfMapSquare#getX() to a relat...
Definition: CfMap.java:691
void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways)
Sets the map square containing the head face for a layer.
void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways)
Sets the map square containing the head face for a layer.
Definition: CfMap.java:365
int getDarkness(final int x, final int y)
Returns the darkness value of one square.
Definition: CfMap.java:175
void scroll(final int dx, final int dy)
Scrolls the map.
Definition: CfMap.java:469
void clearSquare(final int x, final int y)
Clears the content of one square.
Definition: CfMap.java:390
CfMapSquare getMapSquare(final int x, final int y)
Returns a map square.
Definition: CfMap.java:668
Set< CfMapSquare > getDirtyMapSquares()
Returns the dirty map squares.
Definition: CfMap.java:759
void dirty(final int x, final int y)
Marks a square as dirty.
Definition: CfMapPatch.java:72
CfMapSquare getHeadMapSquare(final int x, final int y, final int layer)
Returns the map square of the head of a multi-square object.
Definition: CfMap.java:378
int minY
The top edge of the defined tiles.
Definition: CfMap.java:60
Face getFace(final int x, final int y, final int layer)
Determines the face of one square.
final Set< CfMapSquare > dirtyMapSquares
The "dirty" map squares that have been modified.
Definition: CfMap.java:119
Manages image information ("faces") needed to display the map view, items, and spell icons...
CfMapSquare getHeadMapSquare(final int x, final int y, final int layer)
Returns the map square of the head of a multi-square object.
CfMapSquare getMapSquareUnlessDirty(final int x, final int y)
Returns a map square.
Definition: CfMap.java:680
int NUM_LAYERS
The total number of map layers to display.
Definition: Map2.java:33
void expandFace(final int x, final int y, final int layer, @NotNull final Face face, @NotNull final CfMapSquare oldMapSquare, @Nullable final CfMapSquare newMapSquare)
Adds or removes "head" pointer to/from tail-parts of a face.
Definition: CfMap.java:300
boolean processMapScroll(final int dx, final int dy, final int width, final int height)
Processes a map scroll command.
Definition: CfMap.java:799
CfMapPatch getMapPatch(final int x, final int y)
Checks if a given position is within the defined map area.
Definition: CfMap.java:433
int maxPy
The bottom edge of the defined patches in patch.
Definition: CfMap.java:85
void reset(final int mapWidth, final int mapHeight)
Clears the map contents.
Definition: CfMap.java:133
void setFaceInternal(final int x, final int y, final int layer, @Nullable final Face face)
Sets the face of one square.
Definition: CfMap.java:277
void dirtyFace(final int x, final int y, final int layer, @NotNull final Face face)
Marks one face as "dirty".
Definition: CfMap.java:324
static final int DEFAULT_COLOR
The default magic map color for newly created squares.
int FACE_COLOR_MASK
Bitmask in magic map information to extract the color information of a tile.
Definition: MagicMap.java:34
int ox
Result values for getMapPatch(int, int) and expandTo(int, int).
Definition: CfMap.java:91
void updateFace(final int faceNum, final int width, final int height)
Processes an updated face image.
Definition: CfMap.java:772
void increase(final int dx, final int dy)
Increases the defined area of the map.
Definition: CfMap.java:532
Interface defining constants for the "map2" Crossfire protocol message.
Definition: Map2.java:28
CfMapPatch expandTo(final int x, final int y)
(Possibly) expands the defined area of the map to a given position.
Definition: CfMap.java:491
int maxPx
The right edge of the defined patches in patch.
Definition: CfMap.java:75
void setMagicMap(final int x0, final int y0, final byte[][] data)
Sets the magic map color of one square.
Definition: CfMap.java:223
static final int DEFAULT_SMOOTH
The default smooth value for newly created squares.
int getColor(final int x, final int y)
Determines the magic map color value of one square.
int getDarkness(final int x, final int y)
Determines the darkness value of one square.
static int size(final int min, final int max)
Calculates the number of patches needed to hold tiles between two patch coordinates.
Definition: CfMap.java:657
final Map< Integer, Collection< CfMapSquare > > pendingFaceSquares
The map squares containing pending faces.
Definition: CfMap.java:126
void squareModified(@NotNull final CfMapSquare mapSquare)
Marks a CfMapSquare as dirty.
Definition: CfMap.java:732
boolean isFogOfWar(final int x, final int y)
Determines if a square is not up-to-date.
CfMapPatch [][] copyPatches(final int newWidth, final int newHeight, final int offsetX, final int offsetY, final int height, final int width)
Returns a copy of a rectangular area of patch.
Definition: CfMap.java:717
int minPy
The top edge of the defined patches in patch.
Definition: CfMap.java:80
int getSmooth(final int x, final int y, final int layer)
Returns the smooth value of one square.
Definition: CfMap.java:211
static final Face DEFAULT_FACE
The default face value for newly creates squares.
Represents a square area of CfMapSquares.
Definition: CfMapPatch.java:32
CfMapPatch [][] patch
Array of (possibly) defined squares.
Definition: CfMap.java:113
int minPx
The left edge of the defined patches in patch.
Definition: CfMap.java:70
void dirty(final int x, final int y)
Marks a single square as dirty.
Definition: CfMap.java:407
Face getFace(final int layer)
Returns the face of a layer.
int getOffsetY()
Returns the offset to convert an absolute y-coordinate of a map square (CfMapSquare#getY() to a relat...
Definition: CfMap.java:701
int patchY
Top edge of viewable area.
Definition: CfMap.java:107
Interface defining constants for the "magicmap" Crossfire protocol message.
Definition: MagicMap.java:28
int patchX
Left edge of viewable area.
Definition: CfMap.java:102
int setSmooth(final int x, final int y, final int layer, final int smooth)
Sets the smooth value of one square.
int getFaceNum()
Returns the unique face id.
Definition: Face.java:105
static final int SIZE_LOG
Log2 of SIZE.
Definition: CfMapPatch.java:37
boolean isFogOfWar(final int x, final int y)
Determines if the tile is not up-to-date.
Definition: CfMap.java:418
int getSmooth(final int x, final int y, final int layer)
Determines the smooth value of one square.
void setSmooth(final int x, final int y, final int layer, final int smooth)
Sets the smooth value of one square.
Definition: CfMap.java:188
int minX
The left edge of the defined tiles.
Definition: CfMap.java:50
int getColor(final int x, final int y)
Returns the magic map color value of one square.
Definition: CfMap.java:243