Add consistent formatting.

This commit is contained in:
Major-
2014-01-27 18:36:29 +00:00
parent 3b80e399c4
commit efdb651f34
20 changed files with 153 additions and 184 deletions
@@ -41,6 +41,7 @@ public final class FileSystemConstants {
* Default private constructor to prevent instantiation.
*/
private FileSystemConstants() {
}
}
@@ -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();
@@ -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;
}
@@ -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;
}
-1
View File
@@ -159,7 +159,6 @@ public final class GameService extends Service {
}
world.pulse();
synchronizer.synchronize();
}
}
+2 -4
View File
@@ -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;
+1 -1
View File
@@ -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));
+5 -5
View File
@@ -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));
}
}
+3 -3
View File
@@ -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);
}
}
+7 -9
View File
@@ -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.
* <p>
* 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.");
@@ -21,6 +21,7 @@ public final class WorldConstants {
* Default private constructor to prevent instantiation by other classes.
*/
private WorldConstants() {
}
}
@@ -57,6 +57,7 @@ public class InterfaceConstants {
* Prevent instantiation.
*/
private InterfaceConstants() {
}
}
@@ -43,4 +43,4 @@ public final class PhasedSynchronizationTask extends SynchronizationTask {
}
}
}
}
@@ -36,4 +36,4 @@ public final class PostPlayerSynchronizationTask extends SynchronizationTask {
}
}
}
}
@@ -10,4 +10,4 @@ import org.apollo.game.sync.ClientSynchronizer;
*/
public abstract class SynchronizationTask implements Runnable {
}
}
@@ -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;
@@ -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.
*/
@@ -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 <T> The state enumeration.
@@ -5,9 +5,13 @@ package org.apollo.util.plugin;
*
* @author Graham
*/
@SuppressWarnings("serial")
public final class DependencyException extends Exception {
/**
* A generated serial version id.
*/
private static final long serialVersionUID = -3335727281501054641L;
/**
* Creates the dependency exception.
*
@@ -39,10 +39,10 @@ public final class RubyPluginEnvironment implements PluginEnvironment {
* @throws IOException If an I/O error occurs.
*/
private void parseBootstrapper() throws IOException {
File f = new File("./data/plugins/bootstrap.rb");
InputStream is = new FileInputStream(f);
File bootstrap = new File("./data/plugins/bootstrap.rb");
InputStream is = new FileInputStream(bootstrap);
try {
parse(is, f.getAbsolutePath());
parse(is, bootstrap.getAbsolutePath());
} finally {
is.close();
}