diff --git a/src/org/apollo/fs/FileSystemConstants.java b/src/org/apollo/fs/FileSystemConstants.java index 3a6f1734..b87d4747 100644 --- a/src/org/apollo/fs/FileSystemConstants.java +++ b/src/org/apollo/fs/FileSystemConstants.java @@ -41,6 +41,7 @@ public final class FileSystemConstants { * Default private constructor to prevent instantiation. */ private FileSystemConstants() { + } } \ No newline at end of file diff --git a/src/org/apollo/fs/decoder/ItemDefinitionDecoder.java b/src/org/apollo/fs/decoder/ItemDefinitionDecoder.java index ba32efc4..ce28391a 100644 --- a/src/org/apollo/fs/decoder/ItemDefinitionDecoder.java +++ b/src/org/apollo/fs/decoder/ItemDefinitionDecoder.java @@ -40,9 +40,8 @@ public final class ItemDefinitionDecoder { ByteBuffer data = config.getEntry("obj.dat").getBuffer(); ByteBuffer idx = config.getEntry("obj.idx").getBuffer(); - int count = idx.getShort(); + int count = idx.getShort(), index = 2; int[] indices = new int[count]; - int index = 2; for (int i = 0; i < count; i++) { indices[i] = index; index += idx.getShort(); diff --git a/src/org/apollo/fs/decoder/NpcDefinitionDecoder.java b/src/org/apollo/fs/decoder/NpcDefinitionDecoder.java index 272b910e..21fdf00b 100644 --- a/src/org/apollo/fs/decoder/NpcDefinitionDecoder.java +++ b/src/org/apollo/fs/decoder/NpcDefinitionDecoder.java @@ -40,9 +40,8 @@ public final class NpcDefinitionDecoder { ByteBuffer data = config.getEntry("npc.dat").getBuffer(); ByteBuffer idx = config.getEntry("npc.idx").getBuffer(); - int count = idx.getShort(); + int count = idx.getShort(), index = 2; int[] indices = new int[count]; - int index = 2; for (int i = 0; i < count; i++) { indices[i] = index; index += idx.getShort(); @@ -66,37 +65,37 @@ public final class NpcDefinitionDecoder { */ private NpcDefinition decode(int id, ByteBuffer buffer) { NpcDefinition definition = new NpcDefinition(id); - while (true) { - int code = buffer.get() & 0xFF; - if (code == 0) { + int opcode = buffer.get() & 0xFF; + + if (opcode == 0) { return definition; - } else if (code == 1) { + } else if (opcode == 1) { int length = buffer.get() & 0xFF; - int[] npcModels = new int[length]; + int[] models = new int[length]; for (int i = 0; i < length; i++) { - npcModels[i] = buffer.getShort(); + models[i] = buffer.getShort(); } - } else if (code == 2) { + } else if (opcode == 2) { definition.setName(BufferUtil.readString(buffer)); - } else if (code == 3) { + } else if (opcode == 3) { definition.setDescription(BufferUtil.readString(buffer)); - } else if (code == 12) { + } else if (opcode == 12) { definition.setSize(buffer.get()); - } else if (code == 13) { + } else if (opcode == 13) { definition.setStandAnimation(buffer.getShort()); - } else if (code == 14) { + } else if (opcode == 14) { definition.setWalkAnimation(buffer.getShort()); - } else if (code == 17) { + } else if (opcode == 17) { definition .setWalkAnimations(buffer.getShort(), buffer.getShort(), buffer.getShort(), buffer.getShort()); - } else if (code >= 30 && code < 40) { + } else if (opcode >= 30 && opcode < 40) { String str = BufferUtil.readString(buffer); if (str.equals("hidden")) { str = null; } - definition.setInteraction(code - 30, str); - } else if (code == 40) { + definition.setInteraction(opcode - 30, str); + } else if (opcode == 40) { int length = buffer.get() & 0xFF; int[] originalColours = new int[length]; int[] replacementColours = new int[length]; @@ -104,45 +103,33 @@ public final class NpcDefinitionDecoder { originalColours[i] = buffer.getShort(); replacementColours[i] = buffer.getShort(); } - } else if (code == 60) { + } else if (opcode == 60) { int length = buffer.get() & 0xFF; int[] additionalModels = new int[length]; for (int i = 0; i < length; i++) { additionalModels[i] = buffer.getShort(); } - } else if (code == 90) { + } else if (opcode == 90) { buffer.getShort(); // Dummy - } else if (code == 91) { + } else if (opcode == 91) { buffer.getShort(); // Dummy - } else if (code == 92) { + } else if (opcode == 92) { buffer.getShort(); // Dummy - } else if (code == 93) { - @SuppressWarnings("unused") - boolean drawMinimapDot = false; - } else if (code == 95) { + } else if (opcode == 95) { definition.setCombatLevel(buffer.getShort()); - } else if (code == 97) { - @SuppressWarnings("unused") - int scaleXZ = buffer.getShort(); - } else if (code == 98) { - @SuppressWarnings("unused") - int scaleY = buffer.getShort(); - } else if (code == 99) { - @SuppressWarnings("unused") - boolean unknown = true; - } else if (code == 100) { - @SuppressWarnings("unused") - int lightModifier = buffer.get(); - } else if (code == 101) { - @SuppressWarnings("unused") - int shadowModifier = buffer.get() * 5; - } else if (code == 102) { - @SuppressWarnings("unused") - int headIcon = buffer.getShort(); - } else if (code == 103) { - @SuppressWarnings("unused") - int degreesToRotate = buffer.getShort(); - } else if (code == 106) { + } else if (opcode == 97) { + buffer.getShort(); + } else if (opcode == 98) { + buffer.getShort(); + } else if (opcode == 100) { + buffer.get(); + } else if (opcode == 101) { + buffer.get(); + } else if (opcode == 102) { + buffer.getShort(); + } else if (opcode == 103) { + buffer.getShort(); + } else if (opcode == 106) { int morphVariableBitsIndex = buffer.getShort(); if (morphVariableBitsIndex == 65535) { morphVariableBitsIndex = -1; @@ -161,7 +148,7 @@ public final class NpcDefinitionDecoder { } morphisms[i] = morphism; } - } else if (code == 107) { + } else if (opcode == 107) { @SuppressWarnings("unused") boolean clickable = false; } diff --git a/src/org/apollo/fs/decoder/ObjectDefinitionDecoder.java b/src/org/apollo/fs/decoder/ObjectDefinitionDecoder.java index 233231d8..890cb49d 100644 --- a/src/org/apollo/fs/decoder/ObjectDefinitionDecoder.java +++ b/src/org/apollo/fs/decoder/ObjectDefinitionDecoder.java @@ -40,9 +40,8 @@ public final class ObjectDefinitionDecoder { ByteBuffer data = config.getEntry("loc.dat").getBuffer(); ByteBuffer idx = config.getEntry("loc.idx").getBuffer(); - int count = idx.getShort(); + int count = idx.getShort(), index = 2; int[] indices = new int[count]; - int index = 2; for (int i = 0; i < count; i++) { indices[i] = index; index += idx.getShort(); @@ -65,7 +64,6 @@ public final class ObjectDefinitionDecoder { */ public ObjectDefinition decode(int id, ByteBuffer data) { ObjectDefinition definition = new ObjectDefinition(id); - while (true) { int opcode = data.get() & 0xFF; @@ -74,8 +72,8 @@ public final class ObjectDefinitionDecoder { } else if (opcode == 1) { int amount = data.get() & 0xFF; for (int i = 0; i < amount; i++) { - data.getShort(); // model id - data.get(); // model position + data.getShort(); + data.get(); } } else if (opcode == 2) { definition.setName(BufferUtil.readString(data)); @@ -84,7 +82,7 @@ public final class ObjectDefinitionDecoder { } else if (opcode == 5) { int amount = data.get() & 0xFF; for (int i = 0; i < amount; i++) { - data.getShort(); // model id + data.getShort(); } } else if (opcode == 14) { definition.setWidth(data.get() & 0xFF); @@ -96,18 +94,12 @@ public final class ObjectDefinitionDecoder { definition.setImpenetrable(false); } else if (opcode == 19) { definition.setInteractive((data.get() & 0xFF) == 1); - } else if (opcode == 21) { - // boolean contouredGround = true; - } else if (opcode == 22) { - // boolean delayShading = true; - } else if (opcode == 23) { - // boolean occlues = true; } else if (opcode == 24) { - data.getShort(); // animation + data.getShort(); } else if (opcode == 28) { - data.get(); // decorDisplacement + data.get(); } else if (opcode == 29) { - data.get(); // ambientLight + data.get(); } else if (opcode >= 30 && opcode < 39) { String[] actions = definition.getMenuActions(); if (actions == null) { @@ -117,41 +109,33 @@ public final class ObjectDefinitionDecoder { actions[opcode - 30] = action; definition.setMenuActions(actions); } else if (opcode == 39) { - data.get(); // light diffusion + data.get(); } else if (opcode == 40) { int amount = data.get() & 0xFF; for (int i = 0; i < amount; i++) { - data.getShort(); // original colour - data.getShort(); // replacement colour + data.getShort(); + data.getShort(); } } else if (opcode == 60) { - data.getShort(); // minimap function - } else if (opcode == 62) { - // boolean inverted = true - } else if (opcode == 64) { - // boolean castsShadow = false; + data.getShort(); } else if (opcode == 65) { - data.getShort(); // scale X + data.getShort(); } else if (opcode == 66) { - data.getShort(); // scale Y + data.getShort(); } else if (opcode == 67) { - data.getShort(); // scale Z + data.getShort(); } else if (opcode == 68) { - data.getShort(); // map scene + data.getShort(); } else if (opcode == 69) { - data.get(); // surroundings + data.get(); } else if (opcode == 70) { - data.getShort(); // translate dX + data.getShort(); } else if (opcode == 71) { - data.getShort(); // translate dY + data.getShort(); } else if (opcode == 72) { - data.getShort(); // translate dZ - } else if (opcode == 73) { - // boolean obstructiveGround = true; - } else if (opcode == 74) { - // boolean ethereal = true; + data.getShort(); } else if (opcode == 75) { - data.get(); // support items + data.get(); } else { continue; } diff --git a/src/org/apollo/game/GameService.java b/src/org/apollo/game/GameService.java index 56a0f46b..6f75989d 100644 --- a/src/org/apollo/game/GameService.java +++ b/src/org/apollo/game/GameService.java @@ -159,7 +159,6 @@ public final class GameService extends Service { } world.pulse(); - synchronizer.synchronize(); } } diff --git a/src/org/apollo/game/model/Direction.java b/src/org/apollo/game/model/Direction.java index 4468c2ad..f0096a7f 100644 --- a/src/org/apollo/game/model/Direction.java +++ b/src/org/apollo/game/model/Direction.java @@ -70,17 +70,15 @@ public enum Direction { return Direction.NORTH_EAST; } else if (deltaX == 0) { return Direction.NORTH; - } else { - return Direction.NORTH_WEST; } + return Direction.NORTH_WEST; } else if (deltaY == -1) { if (deltaX == 1) { return Direction.SOUTH_EAST; } else if (deltaX == 0) { return Direction.SOUTH; - } else { - return Direction.SOUTH_WEST; } + return Direction.SOUTH_WEST; } else { if (deltaX == 1) { return Direction.EAST; diff --git a/src/org/apollo/game/model/Npc.java b/src/org/apollo/game/model/Npc.java index 30f5758d..d7cbe253 100644 --- a/src/org/apollo/game/model/Npc.java +++ b/src/org/apollo/game/model/Npc.java @@ -47,7 +47,7 @@ public final class Npc extends Mob { */ public void transform(int id) { if (id < 0 || id >= NpcDefinition.count()) { - throw new IllegalArgumentException("Id to transform to is out of bounds"); + throw new IllegalArgumentException("id to transform to is out of bounds"); } definition = NpcDefinition.lookup(id); blockSet.add(SynchronizationBlock.createTransformBlock(id)); diff --git a/src/org/apollo/game/model/SkillSet.java b/src/org/apollo/game/model/SkillSet.java index 206605b8..625eb9a8 100644 --- a/src/org/apollo/game/model/SkillSet.java +++ b/src/org/apollo/game/model/SkillSet.java @@ -202,7 +202,7 @@ public final class SkillSet { */ private void init() { for (int id = 0; id < skills.length; id++) { - skills[id] = id == Skill.HITPOINTS ? new Skill(1154, 10, 10) : new Skill(0, 1, 1); + skills[id] = (id == Skill.HITPOINTS ? new Skill(1154, 10, 10) : new Skill(0, 1, 1)); } } @@ -211,15 +211,15 @@ public final class SkillSet { */ public void normalize() { for (int id = 0; id < skills.length; id++) { - int cur = skills[id].getCurrentLevel(); + int current = skills[id].getCurrentLevel(); int max = skills[id].getMaximumLevel(); - if (cur == max) { + if (current == max) { continue; } - cur += cur < max ? 1 : -1; + current += current < max ? 1 : -1; - setSkill(id, new Skill(skills[id].getExperience(), cur, max)); + setSkill(id, new Skill(skills[id].getExperience(), current, max)); } } diff --git a/src/org/apollo/game/model/WalkingQueue.java b/src/org/apollo/game/model/WalkingQueue.java index 7934abad..38651f5c 100644 --- a/src/org/apollo/game/model/WalkingQueue.java +++ b/src/org/apollo/game/model/WalkingQueue.java @@ -147,9 +147,9 @@ public final class WalkingQueue { Direction direction = Direction.fromDeltas(deltaX, deltaY); if (direction != Direction.NONE) { - Point p = new Point(new Position(x, y, mob.getPosition().getHeight()), direction); - points.add(p); - oldPoints.add(p); + Point point = new Point(new Position(x, y, mob.getPosition().getHeight()), direction); + points.add(point); + oldPoints.add(point); } } diff --git a/src/org/apollo/game/model/World.java b/src/org/apollo/game/model/World.java index 2a21ae7c..bf641575 100644 --- a/src/org/apollo/game/model/World.java +++ b/src/org/apollo/game/model/World.java @@ -124,6 +124,7 @@ public final class World { * Creates the world. */ private World() { + } /** @@ -156,9 +157,6 @@ public final class World { /** * Gets the player repository. - *
- * Note: players should be registered and unregistered using {@link World#register(Player)} and
- * {@link World#unregister(Player)} respectively, not by adding to or removing from this repository directly.
*
* @return The player repository.
*/
@@ -209,18 +207,18 @@ public final class World {
is.close();
}
- NpcDefinitionDecoder npcDefParser = new NpcDefinitionDecoder(fs);
- NpcDefinition[] npcDefs = npcDefParser.decode();
+ NpcDefinitionDecoder npcDecoder = new NpcDefinitionDecoder(fs);
+ NpcDefinition[] npcDefs = npcDecoder.decode();
NpcDefinition.init(npcDefs);
logger.info("Loaded " + npcDefs.length + " npc definitions.");
- ObjectDefinitionDecoder objDefParser = new ObjectDefinitionDecoder(fs);
- ObjectDefinition[] objDefs = objDefParser.decode();
+ ObjectDefinitionDecoder objectDecoder = new ObjectDefinitionDecoder(fs);
+ ObjectDefinition[] objDefs = objectDecoder.decode();
ObjectDefinition.init(objDefs);
logger.info("Loaded " + objDefs.length + " object definitions.");
- StaticObjectDecoder objectParser = new StaticObjectDecoder(fs);
- StaticObject[] objects = objectParser.decode();
+ StaticObjectDecoder staticDecoder = new StaticObjectDecoder(fs);
+ StaticObject[] objects = staticDecoder.decode();
placeEntities(objects);
logger.info("Loaded " + objects.length + " static objects.");
diff --git a/src/org/apollo/game/model/WorldConstants.java b/src/org/apollo/game/model/WorldConstants.java
index 1ec864f1..b4470971 100644
--- a/src/org/apollo/game/model/WorldConstants.java
+++ b/src/org/apollo/game/model/WorldConstants.java
@@ -21,6 +21,7 @@ public final class WorldConstants {
* Default private constructor to prevent instantiation by other classes.
*/
private WorldConstants() {
+
}
}
\ No newline at end of file
diff --git a/src/org/apollo/game/model/inter/InterfaceConstants.java b/src/org/apollo/game/model/inter/InterfaceConstants.java
index e3dec1ca..41758107 100644
--- a/src/org/apollo/game/model/inter/InterfaceConstants.java
+++ b/src/org/apollo/game/model/inter/InterfaceConstants.java
@@ -57,6 +57,7 @@ public class InterfaceConstants {
* Prevent instantiation.
*/
private InterfaceConstants() {
+
}
}
\ No newline at end of file
diff --git a/src/org/apollo/game/sync/task/PhasedSynchronizationTask.java b/src/org/apollo/game/sync/task/PhasedSynchronizationTask.java
index 7087bf30..31ae0c61 100644
--- a/src/org/apollo/game/sync/task/PhasedSynchronizationTask.java
+++ b/src/org/apollo/game/sync/task/PhasedSynchronizationTask.java
@@ -43,4 +43,4 @@ public final class PhasedSynchronizationTask extends SynchronizationTask {
}
}
-}
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/sync/task/PostPlayerSynchronizationTask.java b/src/org/apollo/game/sync/task/PostPlayerSynchronizationTask.java
index fa7acea9..5a4275f8 100644
--- a/src/org/apollo/game/sync/task/PostPlayerSynchronizationTask.java
+++ b/src/org/apollo/game/sync/task/PostPlayerSynchronizationTask.java
@@ -36,4 +36,4 @@ public final class PostPlayerSynchronizationTask extends SynchronizationTask {
}
}
-}
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/sync/task/SynchronizationTask.java b/src/org/apollo/game/sync/task/SynchronizationTask.java
index 6017f793..8716a5d6 100644
--- a/src/org/apollo/game/sync/task/SynchronizationTask.java
+++ b/src/org/apollo/game/sync/task/SynchronizationTask.java
@@ -10,4 +10,4 @@ import org.apollo.game.sync.ClientSynchronizer;
*/
public abstract class SynchronizationTask implements Runnable {
-}
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/sync/task/package-info.java b/src/org/apollo/game/sync/task/package-info.java
index 1ad610da..b45ff20d 100644
--- a/src/org/apollo/game/sync/task/package-info.java
+++ b/src/org/apollo/game/sync/task/package-info.java
@@ -3,5 +3,4 @@
* {@link org.apollo.game.sync.task.SynchronizationTask}s, small chunks of work
* executed during the client synchronization process.
*/
-package org.apollo.game.sync.task;
-
+package org.apollo.game.sync.task;
\ No newline at end of file
diff --git a/src/org/apollo/net/codec/login/LoginConstants.java b/src/org/apollo/net/codec/login/LoginConstants.java
index 59437491..d74604ea 100644
--- a/src/org/apollo/net/codec/login/LoginConstants.java
+++ b/src/org/apollo/net/codec/login/LoginConstants.java
@@ -7,6 +7,26 @@ package org.apollo.net.codec.login;
*/
public final class LoginConstants {
+ /**
+ * Exchange data login status.
+ */
+ public static final int STATUS_EXCHANGE_DATA = 0;
+
+ /**
+ * Delay for 2 seconds login status.
+ */
+ public static final int STATUS_DELAY = 1;
+
+ /**
+ * OK login status.
+ */
+ public static final int STATUS_OK = 2;
+
+ /**
+ * Invalid credentials login status.
+ */
+ public static final int STATUS_INVALID_CREDENTIALS = 3;
+
/**
* Account disabled login status.
*/
@@ -17,51 +37,31 @@ public final class LoginConstants {
*/
public static final int STATUS_ACCOUNT_ONLINE = 5;
- /**
- * Bad session id login status.
- */
- public static final int STATUS_BAD_SESSION_ID = 10;
-
- /**
- * Could not complete login status.
- */
- public static final int STATUS_COULD_NOT_COMPLETE = 13;
-
- /**
- * Delay for 2 seconds login status.
- */
- public static final int STATUS_DELAY = 1;
-
- /**
- * Exchange data login status.
- */
- public static final int STATUS_EXCHANGE_DATA = 0;
-
/**
* Game updated login status.
*/
public static final int STATUS_GAME_UPDATED = 6;
/**
- * Standing in members area on free world status.
+ * Server full login status.
*/
- public static final int STATUS_IN_MEMBERS_AREA = 17;
-
- /**
- * Invalid credentials login status.
- */
- public static final int STATUS_INVALID_CREDENTIALS = 3;
-
- /**
- * Invalid login server status.
- */
- public static final int STATUS_INVALID_LOGIN_SERVER = 20;
+ public static final int STATUS_SERVER_FULL = 7;
/**
* Login server offline login status.
*/
public static final int STATUS_LOGIN_SERVER_OFFLINE = 8;
+ /**
+ * Too many connections login status.
+ */
+ public static final int STATUS_TOO_MANY_CONNECTIONS = 9;
+
+ /**
+ * Bad session id login status.
+ */
+ public static final int STATUS_BAD_SESSION_ID = 10;
+
/**
* Login server rejected session login status.
*/
@@ -73,34 +73,9 @@ public final class LoginConstants {
public static final int STATUS_MEMBERS_ACCOUNT_REQUIRED = 12;
/**
- * OK login status.
+ * Could not complete login status.
*/
- public static final int STATUS_OK = 2;
-
- /**
- * Profile transfer login status.
- */
- public static final int STATUS_PROFILE_TRANSFER = 21;
-
- /**
- * Reconnection OK login status.
- */
- public static final int STATUS_RECONNECTION_OK = 15;
-
- /**
- * Server full login status.
- */
- public static final int STATUS_SERVER_FULL = 7;
-
- /**
- * Too many connections login status.
- */
- public static final int STATUS_TOO_MANY_CONNECTIONS = 9;
-
- /**
- * Too many login attempts login status.
- */
- public static final int STATUS_TOO_MANY_LOGINS = 16;
+ public static final int STATUS_COULD_NOT_COMPLETE = 13;
/**
* Server updating login status.
@@ -108,15 +83,40 @@ public final class LoginConstants {
public static final int STATUS_UPDATING = 14;
/**
- * Reconnection login type id.
+ * Reconnection OK login status.
*/
- public static final int TYPE_RECONNECTION = 18;
+ public static final int STATUS_RECONNECTION_OK = 15;
+
+ /**
+ * Too many login attempts login status.
+ */
+ public static final int STATUS_TOO_MANY_LOGINS = 16;
+
+ /**
+ * Standing in members area on free world status.
+ */
+ public static final int STATUS_IN_MEMBERS_AREA = 17;
+
+ /**
+ * Invalid login server status.
+ */
+ public static final int STATUS_INVALID_LOGIN_SERVER = 20;
+
+ /**
+ * Profile transfer login status.
+ */
+ public static final int STATUS_PROFILE_TRANSFER = 21;
/**
* Standard login type id.
*/
public static final int TYPE_STANDARD = 16;
+ /**
+ * Reconnection login type id.
+ */
+ public static final int TYPE_RECONNECTION = 18;
+
/**
* Default private constructor to prevent instantiation.
*/
diff --git a/src/org/apollo/util/StatefulFrameDecoder.java b/src/org/apollo/util/StatefulFrameDecoder.java
index 784674df..3a4a60e8 100644
--- a/src/org/apollo/util/StatefulFrameDecoder.java
+++ b/src/org/apollo/util/StatefulFrameDecoder.java
@@ -4,13 +4,12 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
-import io.netty.handler.codec.ReplayingDecoder;
import java.util.List;
/**
- * A stateful implementation of a {@link FrameDecoder} which may be extended and used by other classes. The current
- * state is tracked by this class and is a user-specified enumeration.
+ * A stateful implementation of a {@link ByteToMessageDecoder} which may be extended and used by other classes. The
+ * current state is tracked by this class and is a user-specified enumeration.
*
* The state may be changed by calling the {@link StatefulFrameDecoder#setState(Enum)} method.
*
@@ -20,8 +19,7 @@ import java.util.List;
*
* This class is not thread safe: it is recommended that the state is only set in the decode methods overriden.
*
- * {@code null} states are not permitted. This means you cannot use {@link VoidEnum} like used in a
- * {@link ReplayingDecoder}. If you do not need state management, the {@link FrameDecoder} class should be used instead.
+ * {@code null} states are not permitted.
*
* @author Graham
* @param