Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.map;
28 import java.util.Collection;
29 import java.util.HashMap;
30 import java.util.HashSet;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
134 public void reset(
final int mapWidth,
final int mapHeight) {
160 public void setDarkness(
final int x,
final int y,
final int darkness) {
161 assert Thread.holdsLock(
this);
177 assert Thread.holdsLock(
this);
189 public void setSmooth(
final int x,
final int y,
final int layer,
final int smooth) {
191 if ((result&1) != 0) {
196 if ((result&2) != 0) {
197 for (
int dx = -1; dx <= +1; dx++) {
198 for (
int dy = -1; dy <= +1; dy++) {
212 public int getSmooth(
final int x,
final int y,
final int layer) {
223 public void setMagicMap(
final int x0,
final int y0,
final byte @NotNull [] @NotNull [] 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++) {
240 assert Thread.holdsLock(
this);
253 public void setFace(
final int x,
final int y,
final int layer, @Nullable
final Face face) {
254 assert Thread.holdsLock(
this);
277 if (oldFace !=
null) {
278 expandFace(x, y, layer, oldFace, headMapSquare,
null);
280 headMapSquare.
setFace(layer, face);
282 expandFace(x, y, layer, face, headMapSquare, headMapSquare);
297 final int sx = face.getTileWidth();
298 final int sy = face.getTileHeight();
299 for (
int dx = 0; dx < sx; dx++) {
300 for (
int dy = 0; dy < sy; dy++) {
301 if (dx > 0 || dy > 0) {
302 if (newMapSquare !=
null) {
320 private void dirtyFace(
final int x,
final int y,
final int layer, @NotNull
final Face face) {
321 final int sx = face.getTileWidth();
322 final int sy = face.getTileHeight();
323 for (
int dx = 0; dx < sx; dx++) {
324 for (
int dy = 0; dy < sy; dy++) {
325 if (dx > 0 || dy > 0) {
345 assert Thread.holdsLock(
this);
375 assert Thread.holdsLock(
this);
387 assert Thread.holdsLock(
this);
403 public void dirty(
final int x,
final int y) {
404 assert Thread.holdsLock(
this);
415 assert Thread.holdsLock(
this);
430 if (x < minX || x >
maxX || y < minY || y >
maxY) {
447 assert
patch !=
null;
448 assert
patch[px] !=
null;
450 if (mapPatch !=
null) {
455 assert
patch !=
null;
456 assert
patch[px] !=
null;
457 return patch[px][py];
465 private void scroll(
final int dx,
final int dy) {
466 assert Thread.holdsLock(
this);
467 if (dx == 0 && dy == 0) {
517 assert result !=
null;
528 private void increase(
final int dx,
final int dy) {
530 final int newMinX =
minX+dx;
532 final int diffPw =
minPx-newMinPx;
544 assert
patch !=
null;
545 final int oldPw =
patch.length;
546 final int oldPh =
patch[0].length;
549 assert newPw > oldPw;
550 assert newPw == oldPw+diffPw;
551 assert newPh == oldPh;
558 final int newMaxX =
maxX+dx;
560 final int diffPw = newMaxPx-
maxPx;
572 assert
patch !=
null;
573 final int oldPw =
patch.length;
574 final int oldPh =
patch[0].length;
577 assert newPw > oldPw;
578 assert newPw == oldPw+diffPw;
579 assert newPh == oldPh;
588 final int newMinY =
minY+dy;
590 final int diffPh =
minPy-newMinPy;
602 assert
patch !=
null;
603 final int oldPw =
patch.length;
604 final int oldPh =
patch[0].length;
607 assert newPh > oldPh;
608 assert newPh == oldPh+diffPh;
609 assert newPw == oldPw;
616 final int newMaxY =
maxY+dy;
618 final int diffPh = newMaxPy-
maxPy;
630 assert
patch !=
null;
631 final int oldPw =
patch.length;
632 final int oldPh =
patch[0].length;
635 assert newPh > oldPh;
636 assert newPh == oldPh+diffPh;
637 assert newPw == oldPw;
653 private static int size(
final int min,
final int max) {
665 assert Thread.holdsLock(
this);
677 assert Thread.holdsLock(
this);
688 assert Thread.holdsLock(
this);
698 assert Thread.holdsLock(
this);
713 private CfMapPatch @NotNull [] @NotNull []
copyPatches(
final int newWidth,
final int newHeight,
final int offsetX,
final int offsetY,
final int height,
final int width) {
714 assert
patch !=
null;
716 for (
int y = 0; y < width; y++) {
717 for (
int x = 0; x < height; x++) {
718 newPatch[offsetX+x][offsetY+y] =
patch[x][y];
729 assert Thread.holdsLock(
this);
740 assert Thread.holdsLock(
this);
750 assert Thread.holdsLock(
this);
762 public void updateFace(
final int faceNum,
final int width,
final int height) {
763 for (
int y = 0; y < height; y++) {
764 for (
int x = 0; x < width; x++) {
767 if (face !=
null && face.
getFaceNum() == faceNum) {
776 if (mapSquares !=
null) {
789 public boolean processMapScroll(
final int dx,
final int dy,
final int width,
final int height) {
790 if (Math.abs(dx) >= width || Math.abs(dy) >= height) {
792 for (
int y = 0; y < height; y++) {
793 for (
int x = 0; x < width; x++) {
804 for (
int y = 0; y < height; y++) {
812 for (
int y = 0; y < height; y++) {
822 for (
int x = 0; x < width; x++) {
830 for (
int x = 0; x <= width; x++) {
Face getFace(final int x, final int y, final int layer)
void setFaceInternal(final int x, final int y, final int layer, @Nullable final Face face)
static final int DEFAULT_DARKNESS
int getColor(final int x, final int y)
final Set< CfMapSquare > dirtyMapSquares
void setFace(final int x, final int y, final int layer, @Nullable final Face face)
CfMapSquare getSquare(final int x, final int y)
void scroll(final int dx, final int dy)
CfMapSquare getHeadMapSquare(final int x, final int y, final int layer)
static final Face DEFAULT_FACE
void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways)
CfMapPatch getMapPatch(final int x, final int y)
boolean isFogOfWar(final int x, final int y)
int getDarkness(final int x, final int y)
void setDarkness(final int x, final int y, final int darkness)
static int size(final int min, final int max)
boolean isFogOfWar(final int x, final int y)
static final int SIZE_LOG
void increase(final int dx, final int dy)
void reset(final int mapWidth, final int mapHeight)
void squareModified(@NotNull final CfMapSquare mapSquare)
int getSmooth(final int x, final int y, final int layer)
int getDarkness(final int x, final int y)
void setSmooth(final int x, final int y, final int layer, final int smooth)
CfMapSquare getMapSquare(final int x, final int y)
void setHeadMapSquare(final int x, final int y, final int layer, @Nullable final CfMapSquare mapSquare, final boolean setAlways)
void clearSquare(final int x, final int y)
Face getFace(final int layer)
CfMapPatch expandTo(final int x, final int y)
int getColor(final int x, final int y)
CfMapSquare getMapSquareUnlessDirty(final int x, final int y)
int setSmooth(final int x, final int y, final int layer, final int smooth)
void squarePendingFace(final int x, final int y, final int faceNum)
final Map< Integer, Collection< CfMapSquare > > pendingFaceSquares
void dirty(final int x, final int y)
CfMapPatch[][] copyPatches(final int newWidth, final int newHeight, final int offsetX, final int offsetY, final int height, final int width)
boolean processMapScroll(final int dx, final int dy, final int width, final int height)
static final int DEFAULT_SMOOTH
Set< CfMapSquare > getDirtyMapSquares()
void expandFace(final int x, final int y, final int layer, @NotNull final Face face, @NotNull final CfMapSquare oldMapSquare, @Nullable final CfMapSquare newMapSquare)
void setColor(final int x, final int y, final int color)
void setMagicMap(final int x0, final int y0, final byte @NotNull[] @NotNull[] data)
void setFace(final int layer, @Nullable final Face face)
static final int DEFAULT_COLOR
void updateFace(final int faceNum, final int width, final int height)
CfMapSquare getHeadMapSquare(final int x, final int y, final int layer)
Face getFace(final int x, final int y, final int layer)
void dirtyFace(final int x, final int y, final int layer, @NotNull final Face face)
int getSmooth(final int x, final int y, final int layer)
void dirty(final int x, final int y)
void clearSquare(final int x, final int y)