|
From: Crossfire C. r. messages.
<cro...@li...> - 2011-06-30 19:43:08
|
Revision: 14739
http://crossfire.svn.sourceforge.net/crossfire/?rev=14739&view=rev
Author: akirschbaum
Date: 2011-06-30 19:43:01 +0000 (Thu, 30 Jun 2011)
Log Message:
-----------
Simplify code.
Modified Paths:
--------------
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/CfMapUpdater.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/MapUpdaterState.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/CrossfireUpdateMapListener.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/DefaultCrossfireServerConnection.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:27:35 UTC (rev 14738)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/CfMapUpdater.java 2011-06-30 19:43:01 UTC (rev 14739)
@@ -86,23 +86,23 @@
}
@Override
- public void mapFace(final int x, final int y, final int layer, final int faceNum) {
- mapUpdaterState.mapFace(new Location(x, y, layer), faceNum, true);
+ public void mapFace(@NotNull final Location location, final int faceNum) {
+ mapUpdaterState.mapFace(location, faceNum, true);
}
@Override
- public void mapAnimation(final int x, final int y, final int layer, final int animationNum, final int animationType) {
- mapUpdaterState.mapAnimation(x, y, layer, animationNum, animationType);
+ public void mapAnimation(@NotNull final Location location, final int animationNum, final int animationType) {
+ mapUpdaterState.mapAnimation(location, animationNum, animationType);
}
@Override
- public void mapAnimationSpeed(final int x, final int y, final int layer, final int animationSpeed) {
- mapUpdaterState.mapAnimationSpeed(x, y, layer, animationSpeed);
+ public void mapAnimationSpeed(@NotNull final Location location, final int animationSpeed) {
+ mapUpdaterState.mapAnimationSpeed(location, animationSpeed);
}
@Override
- public void mapSmooth(final int x, final int y, final int layer, final int smooth) {
- mapUpdaterState.mapSmooth(x, y, layer, smooth);
+ public void mapSmooth(@NotNull final Location location, final int smooth) {
+ mapUpdaterState.mapSmooth(location, smooth);
}
/**
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:27:35 UTC (rev 14738)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/mapupdater/MapUpdaterState.java 2011-06-30 19:43:01 UTC (rev 14739)
@@ -258,13 +258,11 @@
/**
* Updates a map square by changing an animation.
- * @param x the x-coordinate of the square
- * @param y the y-coordinate of the square
- * @param layer the layer to update
+ * @param location the location
* @param animationNum the animation number to set
* @param animationType the animation type
*/
- public void mapAnimation(final int x, final int y, final int layer, final int animationNum, final int animationType) {
+ public void mapAnimation(@NotNull final Location location, final int animationNum, final int animationType) {
final Animation animation = animations.get(animationNum);
if (animation == null) {
System.err.println("unknown animation id "+animationNum+", ignoring");
@@ -274,8 +272,7 @@
synchronized (sync) {
//noinspection NestedSynchronizedStatement,SynchronizeOnNonFinalField
synchronized (map) {
- map.setFace(x, y, layer, null);
- final Location location = new Location(x, y, layer);
+ map.setFace(location.getX(), location.getY(), location.getLayer(), null);
visibleAnimations.add(location, animation, animationType);
}
}
@@ -283,30 +280,25 @@
/**
* Updates a map square by changing the animation speed.
- * @param x the x-coordinate of the square
- * @param y the y-coordinate of the square
- * @param layer the layer to update
+ * @param location the location
* @param animationSpeed the animation speed to set
*/
- public void mapAnimationSpeed(final int x, final int y, final int layer, final int animationSpeed) {
+ public void mapAnimationSpeed(@NotNull final Location location, final int animationSpeed) {
synchronized (sync) {
- final Location location = new Location(x, y, layer);
visibleAnimations.updateSpeed(location, animationSpeed);
}
}
/**
* Updates a map square by changing the smooth value.
- * @param x the x-coordinate of the square
- * @param y the y-coordinate of the square
- * @param layer the layer to update
+ * @param location the location
* @param smooth the smooth value to set
*/
- public void mapSmooth(final int x, final int y, final int layer, final int smooth) {
+ public void mapSmooth(@NotNull final Location location, final int smooth) {
synchronized (sync) {
//noinspection NestedSynchronizedStatement,SynchronizeOnNonFinalField
synchronized (map) {
- map.setSmooth(x, y, layer, smooth);
+ map.setSmooth(location.getX(), location.getY(), location.getLayer(), smooth);
}
}
}
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/CrossfireUpdateMapListener.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/CrossfireUpdateMapListener.java 2011-06-30 19:27:35 UTC (rev 14738)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/CrossfireUpdateMapListener.java 2011-06-30 19:43:01 UTC (rev 14739)
@@ -76,40 +76,32 @@
/**
* Part of "map2" parsing: set the face of a cell.
- * @param x the x-coordinate
- * @param y the y-coordinate
- * @param layer the layer
+ * @param location the location
* @param faceNum the face ID
*/
- void mapFace(int x, int y, int layer, int faceNum);
+ void mapFace(@NotNull Location location, int faceNum);
/**
* Part of "map2" parsing: set the animation of a cell.
- * @param x the x-coordinate
- * @param y the y-coordinate
- * @param layer the layer
+ * @param location the location
* @param animationNum the animation ID
* @param animationType the animation type
*/
- void mapAnimation(int x, int y, int layer, int animationNum, int animationType);
+ void mapAnimation(@NotNull Location location, int animationNum, int animationType);
/**
* Part of "map2" parsing: set the animation speed.
- * @param x the x-coordinate
- * @param y the y-coordinate
- * @param layer the layer
+ * @param location the location
* @param animationSpeed the animation speed
*/
- void mapAnimationSpeed(int x, int y, int layer, int animationSpeed);
+ void mapAnimationSpeed(@NotNull Location location, int animationSpeed);
/**
* Part of "map2" parsing: set the smooth level.
- * @param x the x-coordinate
- * @param y the y-coordinate
- * @param layer the layer
+ * @param location the location
* @param smooth the smooth value
*/
- void mapSmooth(int x, int y, int layer, int smooth);
+ void mapSmooth(@NotNull Location location, int smooth);
/**
* Part of "map2" parsing: scroll the map view.
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/DefaultCrossfireServerConnection.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/DefaultCrossfireServerConnection.java 2011-06-30 19:27:35 UTC (rev 14738)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/crossfire/DefaultCrossfireServerConnection.java 2011-06-30 19:43:01 UTC (rev 14739)
@@ -21,6 +21,7 @@
package com.realtime.crossfire.jxclient.server.crossfire;
+import com.realtime.crossfire.jxclient.map.Location;
import com.realtime.crossfire.jxclient.server.crossfire.messages.Map2;
import com.realtime.crossfire.jxclient.server.crossfire.messages.UpdItem;
import com.realtime.crossfire.jxclient.server.server.DefaultServerConnection;
@@ -2002,26 +2003,27 @@
if (len < 2) {
throw new UnknownCommandException("map2 command contains image command with length "+len);
}
+ final Location location = new Location(x, y, layer);
final int face = getInt2(packet);
if ((face&Map2.FACE_ANIMATION) == 0) {
if (debugProtocol != null) {
- debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" face="+face);
+ debugProtocol.debugProtocolWrite("recv map2 "+location+" face="+face);
}
if (crossfireUpdateMapListener != null) {
- crossfireUpdateMapListener.mapFace(x, y, layer, face);
+ crossfireUpdateMapListener.mapFace(location, face);
}
} else {
if (debugProtocol != null) {
- debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" anim="+(face&Map2.ANIM_MASK)+" type="+((face>>Map2.ANIM_TYPE_SHIFT)&Map2.ANIM_TYPE_MASK));
+ debugProtocol.debugProtocolWrite("recv map2 "+location+" anim="+(face&Map2.ANIM_MASK)+" type="+((face>>Map2.ANIM_TYPE_SHIFT)&Map2.ANIM_TYPE_MASK));
}
if (crossfireUpdateMapListener != null) {
- crossfireUpdateMapListener.mapAnimation(x, y, layer, face&Map2.ANIM_MASK, (face>>Map2.ANIM_TYPE_SHIFT)&Map2.ANIM_TYPE_MASK);
+ crossfireUpdateMapListener.mapAnimation(location, face&Map2.ANIM_MASK, (face>>Map2.ANIM_TYPE_SHIFT)&Map2.ANIM_TYPE_MASK);
}
}
if (len == 3) {
- cmdMap2CoordinateLayer3(packet, x, y, layer, face);
+ cmdMap2CoordinateLayer3(packet, location, face);
} else if (len == 4) {
- cmdMap2CoordinateLayer4(packet, x, y, layer, face);
+ cmdMap2CoordinateLayer4(packet, location, face);
} else if (len != 2) {
if (debugProtocol != null) {
debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" <invalid>");
@@ -2034,13 +2036,11 @@
* Processes the additional payload data for a map2 coordinate "layer"
* sub-command having 4 bytes payload.
* @param packet the packet contents
+ * @param location the location
* @param face the face number
- * @param x the x-coordinate of the currently processed square
- * @param y the y-coordinate of the currently processed square
- * @param layer the layer to update
* @throws UnknownCommandException if the command cannot be parsed
*/
- private void cmdMap2CoordinateLayer3(@NotNull final ByteBuffer packet, final int x, final int y, final int layer, final int face) throws UnknownCommandException {
+ private void cmdMap2CoordinateLayer3(@NotNull final ByteBuffer packet, @NotNull final Location location, final int face) throws UnknownCommandException {
if (face == 0) {
throw new UnknownCommandException("map2 command contains smoothing or animation information for empty face");
}
@@ -2048,18 +2048,18 @@
if ((face&Map2.FACE_ANIMATION) == 0) {
final int smooth = getInt1(packet);
if (debugProtocol != null) {
- debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" smooth="+smooth);
+ debugProtocol.debugProtocolWrite("recv map2 "+location+" smooth="+smooth);
}
if (crossfireUpdateMapListener != null) {
- crossfireUpdateMapListener.mapSmooth(x, y, layer, smooth);
+ crossfireUpdateMapListener.mapSmooth(location, smooth);
}
} else {
final int animSpeed = getInt1(packet);
if (debugProtocol != null) {
- debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" anim_speed="+animSpeed);
+ debugProtocol.debugProtocolWrite("recv map2 "+location+" anim_speed="+animSpeed);
}
if (crossfireUpdateMapListener != null) {
- crossfireUpdateMapListener.mapAnimationSpeed(x, y, layer, animSpeed);
+ crossfireUpdateMapListener.mapAnimationSpeed(location, animSpeed);
}
}
}
@@ -2068,31 +2068,29 @@
* Processes the additional payload data for a map2 coordinate "layer"
* sub-command having 4 bytes payload.
* @param packet the packet contents
+ * @param location the location
* @param face the face number
- * @param x the x-coordinate of the currently processed square
- * @param y the y-coordinate of the currently processed square
- * @param layer the layer to update
* @throws UnknownCommandException if the command cannot be parsed
*/
- private void cmdMap2CoordinateLayer4(@NotNull final ByteBuffer packet, final int x, final int y, final int layer, final int face) throws UnknownCommandException {
+ private void cmdMap2CoordinateLayer4(@NotNull final ByteBuffer packet, @NotNull final Location location, final int face) throws UnknownCommandException {
if (face == 0) {
throw new UnknownCommandException("map2 command contains smoothing or animation information for empty face");
}
final int animSpeed = getInt1(packet);
if (debugProtocol != null) {
- debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" anim_speed="+animSpeed);
+ debugProtocol.debugProtocolWrite("recv map2 "+location+" anim_speed="+animSpeed);
}
if (crossfireUpdateMapListener != null) {
- crossfireUpdateMapListener.mapAnimationSpeed(x, y, layer, animSpeed);
+ crossfireUpdateMapListener.mapAnimationSpeed(location, animSpeed);
}
final int smooth = getInt1(packet);
if (debugProtocol != null) {
- debugProtocol.debugProtocolWrite("recv map2 "+x+"/"+y+"/"+layer+" smooth="+smooth);
+ debugProtocol.debugProtocolWrite("recv map2 "+location+" smooth="+smooth);
}
if (crossfireUpdateMapListener != null) {
- crossfireUpdateMapListener.mapSmooth(x, y, layer, smooth);
+ crossfireUpdateMapListener.mapSmooth(location, smooth);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|