|
From: Crossfire C. r. messages.
<cro...@li...> - 2011-06-30 19:53:25
|
Revision: 14742
http://crossfire.svn.sourceforge.net/crossfire/?rev=14742&view=rev
Author: akirschbaum
Date: 2011-06-30 19:53:19 +0000 (Thu, 30 Jun 2011)
Log Message:
-----------
Simplify CfMapUpdater.
Modified Paths:
--------------
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/CfMapUpdater.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/MapUpdaterState.java
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/CfMapUpdater.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/CfMapUpdater.java 2011-06-30 19:47:22 UTC (rev 14741)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/CfMapUpdater.java 2011-06-30 19:53:19 UTC (rev 14742)
@@ -27,10 +27,8 @@
import com.realtime.crossfire.jxclient.guistate.GuiStateListener;
import com.realtime.crossfire.jxclient.guistate.GuiStateManager;
import com.realtime.crossfire.jxclient.map.CfMap;
-import com.realtime.crossfire.jxclient.map.Location;
import com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection;
import com.realtime.crossfire.jxclient.server.crossfire.CrossfireTickListener;
-import com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener;
import com.realtime.crossfire.jxclient.server.socket.ClientSocketState;
import org.jetbrains.annotations.NotNull;
@@ -60,74 +58,6 @@
};
/**
- * The listener to detect map model changes.
- */
- @NotNull
- private final CrossfireUpdateMapListener crossfireUpdateMapListener = new CrossfireUpdateMapListener() {
-
- @Override
- public void newMap(final int mapWidth, final int mapHeight) {
- mapUpdaterState.newMap(mapWidth, mapHeight);
- }
-
- @Override
- public void mapBegin() {
- mapUpdaterState.mapBegin();
- }
-
- @Override
- public void mapClear(final int x, final int y) {
- mapUpdaterState.mapClear(x, y);
- }
-
- @Override
- public void mapDarkness(final int x, final int y, final int darkness) {
- mapUpdaterState.mapDarkness(x, y, darkness);
- }
-
- @Override
- public void mapFace(@NotNull final Location location, final int faceNum) {
- mapUpdaterState.mapFace(location, faceNum, true);
- }
-
- @Override
- public void mapAnimation(@NotNull final Location location, final int animationNum, final int animationType) {
- mapUpdaterState.mapAnimation(location, animationNum, animationType);
- }
-
- @Override
- public void mapAnimationSpeed(@NotNull final Location location, final int animationSpeed) {
- mapUpdaterState.mapAnimationSpeed(location, animationSpeed);
- }
-
- @Override
- public void mapSmooth(@NotNull final Location location, final int smooth) {
- mapUpdaterState.mapSmooth(location, smooth);
- }
-
- @Override
- public void mapScroll(final int dx, final int dy) {
- mapUpdaterState.mapScroll(dx, dy);
- }
-
- @Override
- public void magicMap(final int x, final int y, final byte[][] data) {
- mapUpdaterState.magicMap(x, y, data);
- }
-
- @Override
- public void mapEnd() {
- mapUpdaterState.mapEnd(true);
- }
-
- @Override
- public void addAnimation(final int animation, final int flags, @NotNull final int[] faces) {
- mapUpdaterState.addAnimation(animation, flags, faces);
- }
-
- };
-
- /**
* The {@link GuiStateListener} for detecting established or dropped
* connections.
*/
@@ -194,7 +124,7 @@
public CfMapUpdater(@NotNull final MapUpdaterState mapUpdaterState, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final FacesManager facesManager, @NotNull final GuiStateManager guiStateManager) {
this.mapUpdaterState = mapUpdaterState;
facesManager.addFacesManagerListener(facesManagerListener);
- crossfireServerConnection.setCrossfireUpdateMapListener(crossfireUpdateMapListener);
+ crossfireServerConnection.setCrossfireUpdateMapListener(mapUpdaterState);
guiStateManager.addGuiStateListener(guiStateListener);
crossfireServerConnection.addCrossfireTickListener(crossfireTickListener);
}
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/MapUpdaterState.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/MapUpdaterState.java 2011-06-30 19:47:22 UTC (rev 14741)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/MapUpdaterState.java 2011-06-30 19:53:19 UTC (rev 14742)
@@ -30,6 +30,7 @@
import com.realtime.crossfire.jxclient.map.CfMapAnimations;
import com.realtime.crossfire.jxclient.map.CfMapSquare;
import com.realtime.crossfire.jxclient.map.Location;
+import com.realtime.crossfire.jxclient.server.crossfire.CrossfireUpdateMapListener;
import com.realtime.crossfire.jxclient.server.crossfire.MapSizeListener;
import com.realtime.crossfire.jxclient.util.EventListenerList2;
import java.util.Collection;
@@ -48,7 +49,7 @@
* applies to the whole map model {@link #map}.
* @author Andreas Kirschbaum
*/
-public class MapUpdaterState {
+public class MapUpdaterState implements CrossfireUpdateMapListener {
/**
* The object used for synchronization.
@@ -207,16 +208,16 @@
}
/**
- * Starts processing of a set of map square changes.
+ * {@inheritDoc}
*/
+ @Override
public void mapBegin() {
}
/**
- * Updates a map square by clearing it.
- * @param x the x-coordinate of the square
- * @param y the y-coordinate of the square
+ * {@inheritDoc}
*/
+ @Override
public void mapClear(final int x, final int y) {
synchronized (sync) {
visibleAnimations.remove(x, y);
@@ -229,6 +230,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mapFace(@NotNull final Location location, final int faceNum) {
+ mapFace(location, faceNum, true);
+ }
+
+ /**
* Updates a map square by changing a face.
* @param location the location to update
* @param faceNum the face to set; <code>0</code> clears the square
@@ -257,11 +266,9 @@
}
/**
- * Updates a map square by changing an animation.
- * @param location the location
- * @param animationNum the animation number to set
- * @param animationType the animation type
+ * {@inheritDoc}
*/
+ @Override
public void mapAnimation(@NotNull final Location location, final int animationNum, final int animationType) {
final Animation animation = animations.get(animationNum);
if (animation == null) {
@@ -279,10 +286,9 @@
}
/**
- * Updates a map square by changing the animation speed.
- * @param location the location
- * @param animationSpeed the animation speed to set
+ * {@inheritDoc}
*/
+ @Override
public void mapAnimationSpeed(@NotNull final Location location, final int animationSpeed) {
synchronized (sync) {
visibleAnimations.updateSpeed(location, animationSpeed);
@@ -290,10 +296,9 @@
}
/**
- * Updates a map square by changing the smooth value.
- * @param location the location
- * @param smooth the smooth value to set
+ * {@inheritDoc}
*/
+ @Override
public void mapSmooth(@NotNull final Location location, final int smooth) {
synchronized (sync) {
//noinspection NestedSynchronizedStatement,SynchronizeOnNonFinalField
@@ -304,11 +309,9 @@
}
/**
- * Updates a map square by changing the darkness value.
- * @param x the x-coordinate of the square
- * @param y the y-coordinate of the square
- * @param darkness the darkness value to set
+ * {@inheritDoc}
*/
+ @Override
public void mapDarkness(final int x, final int y, final int darkness) {
synchronized (sync) {
//noinspection NestedSynchronizedStatement,SynchronizeOnNonFinalField
@@ -319,12 +322,9 @@
}
/**
- * Finishes processing of a set of map square changes. Notifies listeners
- * about changes. present
- * @param x the x-coordinate of the square
- * @param y the y-coordinate of the square
- * @param data the magic map data (y, x); will not be changed
+ * {@inheritDoc}
*/
+ @Override
public void magicMap(final int x, final int y, final byte[][] data) {
synchronized (sync) {
//noinspection NestedSynchronizedStatement,SynchronizeOnNonFinalField
@@ -358,10 +358,9 @@
}
/**
- * Processes a map scroll command.
- * @param dx the distance to scroll in x-direction in squares
- * @param dy the distance to scroll in y-direction in squares
+ * {@inheritDoc}
*/
+ @Override
public void mapScroll(final int dx, final int dy) {
synchronized (sync) {
mapBegin();
@@ -390,6 +389,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mapEnd() {
+ mapEnd(true);
+ }
+
+ /**
* Processes an updated face image.
* @param faceNum the face that has changed
*/
@@ -407,10 +414,9 @@
}
/**
- * Processes a newmap command. This clears the map state.
- * @param mapWidth the width of the visible map area
- * @param mapHeight the height of the visible map area
+ * {@inheritDoc}
*/
+ @Override
public void newMap(final int mapWidth, final int mapHeight) {
synchronized (sync) {
final boolean changed = this.mapWidth != mapWidth || this.mapHeight != mapHeight;
@@ -474,11 +480,9 @@
}
/**
- * Adds a new animation to the map.
- * @param animation the ID f the animation to add
- * @param flags the animation flags
- * @param faces the animation's faces
+ * {@inheritDoc}
*/
+ @Override
public void addAnimation(final int animation, final int flags, @NotNull final int[] faces) {
animations.addAnimation(animation, flags, faces);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|