Merge branch 'master' of bitbucket.org:Major-/apollo.

This commit is contained in:
Major-
2015-03-03 01:25:03 +00:00
66 changed files with 242 additions and 292 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
/** /**
* Contains classes which deal with the file system that the client uses to * Contains classes which deal with the file system that the client uses to store game data files.
* store game data files.
*/ */
package org.apollo.fs; package org.apollo.fs;
+2 -4
View File
@@ -49,8 +49,7 @@ public final class GameService extends Service {
/** /**
* The scheduled executor service. * The scheduled executor service.
*/ */
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory( private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("GameService"));
"GameService"));
/** /**
* The {@link ClientSynchronizer}. * The {@link ClientSynchronizer}.
@@ -170,8 +169,7 @@ public final class GameService extends Service {
*/ */
@Override @Override
public void start() { public void start() {
scheduledExecutor.scheduleAtFixedRate(new GamePulseHandler(this), GameConstants.PULSE_DELAY, GameConstants.PULSE_DELAY, scheduledExecutor.scheduleAtFixedRate(new GamePulseHandler(this), GameConstants.PULSE_DELAY, GameConstants.PULSE_DELAY, TimeUnit.MILLISECONDS);
TimeUnit.MILLISECONDS);
} }
/** /**
+1 -2
View File
@@ -1,5 +1,4 @@
/** /**
* Contains classes related to actions, specialised scheduled tasks which * Contains classes related to actions, specialised scheduled tasks which mobs perform.
* mobs perform.
*/ */
package org.apollo.game.action; package org.apollo.game.action;
@@ -41,8 +41,8 @@ public final class MessageHandlerChain<M extends Message> {
} }
/** /**
* Handles the message, passing it down the chain until the chain is broken * Handles the message, passing it down the chain until the chain is broken or the message reaches the end of the
* or the message reaches the end of the chain. * chain.
* *
* @param player The player. * @param player The player.
* @param message The message. * @param message The message.
@@ -25,16 +25,16 @@ public final class BankMessageHandler extends MessageHandler<ItemActionMessage>
*/ */
private static final int optionToAmount(int option) { private static final int optionToAmount(int option) {
switch (option) { switch (option) {
case 1: case 1:
return 1; return 1;
case 2: case 2:
return 5; return 5;
case 3: case 3:
return 10; return 10;
case 4: case 4:
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
case 5: case 5:
return -1; return -1;
} }
throw new IllegalArgumentException("Invalid option supplied."); throw new IllegalArgumentException("Invalid option supplied.");
@@ -21,19 +21,19 @@ public final class ItemOnItemVerificationHandler extends MessageHandler<ItemOnIt
Inventory inventory; Inventory inventory;
switch (message.getInterfaceId()) { switch (message.getInterfaceId()) {
case SynchronizationInventoryListener.INVENTORY_ID: case SynchronizationInventoryListener.INVENTORY_ID:
case BankConstants.SIDEBAR_INVENTORY_ID: case BankConstants.SIDEBAR_INVENTORY_ID:
inventory = player.getInventory(); inventory = player.getInventory();
break; break;
case SynchronizationInventoryListener.EQUIPMENT_ID: case SynchronizationInventoryListener.EQUIPMENT_ID:
inventory = player.getEquipment(); inventory = player.getEquipment();
break; break;
case BankConstants.BANK_INVENTORY_ID: case BankConstants.BANK_INVENTORY_ID:
inventory = player.getBank(); inventory = player.getBank();
break; break;
default: default:
ctx.breakHandlerChain(); ctx.breakHandlerChain();
return; return;
} }
int slot = message.getTargetSlot(); int slot = message.getTargetSlot();
@@ -18,8 +18,7 @@ public final class ItemOnObjectVerificationHandler extends MessageHandler<ItemOn
@Override @Override
public void handle(MessageHandlerContext ctx, Player player, ItemOnObjectMessage message) { public void handle(MessageHandlerContext ctx, Player player, ItemOnObjectMessage message) {
if (message.getInterfaceId() != SynchronizationInventoryListener.INVENTORY_ID if (message.getInterfaceId() != SynchronizationInventoryListener.INVENTORY_ID && message.getInterfaceId() != BankConstants.SIDEBAR_INVENTORY_ID) {
&& message.getInterfaceId() != BankConstants.SIDEBAR_INVENTORY_ID) {
ctx.breakHandlerChain(); ctx.breakHandlerChain();
return; return;
} }
@@ -22,23 +22,22 @@ public final class SwitchItemMessageHandler extends MessageHandler<SwitchItemMes
boolean insertPermitted = false; boolean insertPermitted = false;
switch (message.getInterfaceId()) { switch (message.getInterfaceId()) {
case SynchronizationInventoryListener.INVENTORY_ID: case SynchronizationInventoryListener.INVENTORY_ID:
case BankConstants.SIDEBAR_INVENTORY_ID: case BankConstants.SIDEBAR_INVENTORY_ID:
inventory = player.getInventory(); inventory = player.getInventory();
break; break;
case SynchronizationInventoryListener.EQUIPMENT_ID: case SynchronizationInventoryListener.EQUIPMENT_ID:
inventory = player.getEquipment(); inventory = player.getEquipment();
break; break;
case BankConstants.BANK_INVENTORY_ID: case BankConstants.BANK_INVENTORY_ID:
inventory = player.getBank(); inventory = player.getBank();
insertPermitted = true; insertPermitted = true;
break; break;
default: default:
return; // not a known inventory, ignore return; // not a known inventory, ignore
} }
if (message.getOldSlot() >= 0 && message.getNewSlot() >= 0 && message.getOldSlot() < inventory.capacity() if (message.getOldSlot() >= 0 && message.getNewSlot() >= 0 && message.getOldSlot() < inventory.capacity() && message.getNewSlot() < inventory.capacity()) {
&& message.getNewSlot() < inventory.capacity()) {
// events must be fired for it to work if a sidebar inventory overlay is used // events must be fired for it to work if a sidebar inventory overlay is used
inventory.swap(insertPermitted && message.isInserting(), message.getOldSlot(), message.getNewSlot()); inventory.swap(insertPermitted && message.isInserting(), message.getOldSlot(), message.getNewSlot());
} }
@@ -36,6 +36,11 @@ public final class WalkMessageHandler extends MessageHandler<WalkMessage> {
player.stopAction(); player.stopAction();
} }
player.getInterfaceSet().close(); player.getInterfaceSet().close();
if (player.getInteractingMob() != null) {
player.resetInteractingMob();
}
} }
} }
@@ -53,8 +53,7 @@ public final class PlayerSynchronizationMessage extends Message {
* @param localPlayers The number of local players. * @param localPlayers The number of local players.
* @param segments A list of segments. * @param segments A list of segments.
*/ */
public PlayerSynchronizationMessage(Position lastKnownSector, Position position, boolean sectorChanged, public PlayerSynchronizationMessage(Position lastKnownSector, Position position, boolean sectorChanged, SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) {
SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) {
this.lastKnownSector = lastKnownSector; this.lastKnownSector = lastKnownSector;
this.position = position; this.position = position;
this.sectorChanged = sectorChanged; this.sectorChanged = sectorChanged;
+2 -2
View File
@@ -14,8 +14,8 @@ public final class Appearance {
/** /**
* The default appearance. * The default appearance.
*/ */
public static final Appearance DEFAULT_APPEARANCE = new Appearance(Gender.MALE, new int[] { 0, 10, 18, 26, 33, 36, 42 }, public static final Appearance DEFAULT_APPEARANCE = new Appearance(Gender.MALE, new int[] { 0, 10, 18, 26, 33, 36,
new int[5]); 42 }, new int[5]);
/** /**
* The array of clothing/skin colors. * The array of clothing/skin colors.
+1 -5
View File
@@ -1,9 +1,5 @@
package org.apollo.game.model; package org.apollo.game.model;
/** /**
* Represents a single movement direction. * Represents a single movement direction.
* *
@@ -90,7 +86,7 @@ public enum Direction {
return Direction.WEST; return Direction.WEST;
} }
} }
return Direction.NONE; return Direction.NONE;
} }
+2 -3
View File
@@ -221,13 +221,12 @@ public final class Position {
public boolean isWithinDistance(Position other, int distance) { public boolean isWithinDistance(Position other, int distance) {
int deltaX = Math.abs(getX() - other.getX()); int deltaX = Math.abs(getX() - other.getX());
int deltaY = Math.abs(getY() - other.getY()); int deltaY = Math.abs(getY() - other.getY());
return deltaX <= distance && deltaY <= distance; return deltaX <= distance && deltaY <= distance && getHeight() == other.getHeight();
} }
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this).add("x", getX()).add("y", getY()).add("height", getHeight()) return MoreObjects.toStringHelper(this).add("x", getX()).add("y", getY()).add("height", getHeight()).add("sector", getSectorCoordinates()).toString();
.add("sector", getSectorCoordinates()).toString();
} }
} }
+1 -2
View File
@@ -242,8 +242,7 @@ public final class Sector {
* @throws IllegalArgumentException If the specified position is not included in this sector. * @throws IllegalArgumentException If the specified position is not included in this sector.
*/ */
private void checkPosition(Position position) { private void checkPosition(Position position) {
Preconditions.checkArgument(coordinates.equals(SectorCoordinates.fromPosition(position)), Preconditions.checkArgument(coordinates.equals(SectorCoordinates.fromPosition(position)), "Position is not included in this sector.");
"Position is not included in this sector.");
} }
} }
@@ -161,8 +161,7 @@ public final class CollisionMatrix {
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix)) return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix)).toString();
.toString();
} }
/** /**
@@ -1,5 +1,5 @@
/** /**
* Contains classes which represent in-game sectors - blocks of 8x8 tiles used to store ground items, temporary objects, etc. * Contains classes which represent in-game sectors - blocks of 8x8 tiles used to store ground items, temporary objects,
* efficiently. * etc. efficiently.
*/ */
package org.apollo.game.model.area; package org.apollo.game.model.area;
@@ -178,8 +178,7 @@ public final class ObjectDefinition {
/** /**
* Indicates the impenetrability of this object. * Indicates the impenetrability of this object.
* *
* @return {@code true} if this object is impenetrable, otherwise * @return {@code true} if this object is impenetrable, otherwise {@code false}.
* {@code false}.
*/ */
public boolean isImpenetrable() { public boolean isImpenetrable() {
return impenetrable; return impenetrable;
@@ -188,8 +187,7 @@ public final class ObjectDefinition {
/** /**
* Indicates the interactivity of this object. * Indicates the interactivity of this object.
* *
* @return {@code true} if the object is interactive, otherwise * @return {@code true} if the object is interactive, otherwise {@code false}.
* {@code false}.
*/ */
public boolean isInteractive() { public boolean isInteractive() {
return interactive; return interactive;
@@ -198,8 +196,7 @@ public final class ObjectDefinition {
/** /**
* Indicates whether or not this object obstructs the ground. * Indicates whether or not this object obstructs the ground.
* *
* @return {@code true} if the object obstructs the ground otherwise * @return {@code true} if the object obstructs the ground otherwise {@code false}.
* {@code false}.
*/ */
public boolean isObstructive() { public boolean isObstructive() {
return obstructive; return obstructive;
@@ -1,5 +1,4 @@
/** /**
* Contains definition classes which contain information about types of items, * Contains definition classes which contain information about types of items, NPCs, etc.
* NPCs, etc.
*/ */
package org.apollo.game.model.def; package org.apollo.game.model.def;
@@ -89,8 +89,7 @@ public final class GameObject extends Entity {
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this).add("id", getId()).add("type", getType()).add("rotation", getRotation()) return MoreObjects.toStringHelper(this).add("id", getId()).add("type", getType()).add("rotation", getRotation()).toString();
.toString();
} }
} }
+2 -2
View File
@@ -194,8 +194,8 @@ public abstract class Mob extends Entity {
*/ */
public final Direction[] getDirections() { public final Direction[] getDirections() {
if (firstDirection != Direction.NONE) { if (firstDirection != Direction.NONE) {
return secondDirection == Direction.NONE ? new Direction[] { firstDirection } : new Direction[] { firstDirection, return secondDirection == Direction.NONE ? new Direction[] { firstDirection } : new Direction[] {
secondDirection }; firstDirection, secondDirection };
} }
return Direction.EMPTY_DIRECTION_ARRAY; return Direction.EMPTY_DIRECTION_ARRAY;
+3 -6
View File
@@ -943,8 +943,7 @@ public final class Player extends Mob {
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this).add("username", getUsername()).add("privilege", privilegeLevel) return MoreObjects.toStringHelper(this).add("username", getUsername()).add("privilege", privilegeLevel).add("client version", getClientVersion()).toString();
.add("client version", getClientVersion()).toString();
} }
/** /**
@@ -968,11 +967,9 @@ public final class Player extends Mob {
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE); InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
InventoryListener appearanceListener = new AppearanceInventoryListener(this); InventoryListener appearanceListener = new AppearanceInventoryListener(this);
InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this, InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this, SynchronizationInventoryListener.INVENTORY_ID);
SynchronizationInventoryListener.INVENTORY_ID);
InventoryListener syncBankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID); InventoryListener syncBankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID);
InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this, InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this, SynchronizationInventoryListener.EQUIPMENT_ID);
SynchronizationInventoryListener.EQUIPMENT_ID);
inventory.addListener(syncInventoryListener); inventory.addListener(syncInventoryListener);
inventory.addListener(fullInventoryListener); inventory.addListener(fullInventoryListener);
+3 -3
View File
@@ -115,9 +115,9 @@ public final class Skill {
/** /**
* The skill names. * The skill names.
*/ */
private static final String[] SKILL_NAMES = { "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", private static final String[] SKILL_NAMES = { "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer",
"Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining",
"Agility", "Thieving", "Slayer", "Farming", "Runecraft" }; "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft" };
/** /**
* Gets the name of a skill. * Gets the name of a skill.
@@ -57,8 +57,7 @@ public final class SkillSet {
* @return The minimum level. * @return The minimum level.
*/ */
public static int getLevelForExperience(double experience) { public static int getLevelForExperience(double experience) {
Preconditions.checkArgument(experience >= 0 && experience <= MAXIMUM_EXP, "Experience must be between 0 and " Preconditions.checkArgument(experience >= 0 && experience <= MAXIMUM_EXP, "Experience must be between 0 and " + MAXIMUM_EXP + ", inclusive.");
+ MAXIMUM_EXP + ", inclusive.");
for (int level = 1; level <= 98; level++) { for (int level = 1; level <= 98; level++) {
if (experience < EXPERIENCE_FOR_LEVEL[level + 1]) { if (experience < EXPERIENCE_FOR_LEVEL[level + 1]) {
@@ -80,8 +80,7 @@ public final class AttributeMap {
AttributeDefinition<T> definition = getDefinition(name); AttributeDefinition<T> definition = getDefinition(name);
Preconditions.checkNotNull(definition, "Attributes must be defined before their value can be retreived."); Preconditions.checkNotNull(definition, "Attributes must be defined before their value can be retreived.");
return (Attribute<T>) attributes.computeIfAbsent(name, return (Attribute<T>) attributes.computeIfAbsent(name, key -> createAttribute(definition.getDefault(), definition.getType()));
key -> createAttribute(definition.getDefault(), definition.getType()));
} }
/** /**
+2 -2
View File
@@ -6,7 +6,7 @@ package org.apollo.game.model.event;
* @author Major * @author Major
*/ */
public abstract class Event { public abstract class Event {
/** /**
* Indicates whether or not the Event chain has been terminated. * Indicates whether or not the Event chain has been terminated.
*/ */
@@ -27,5 +27,5 @@ public abstract class Event {
public final boolean terminated() { public final boolean terminated() {
return terminated; return terminated;
} }
} }
@@ -10,8 +10,8 @@ public class InterfaceConstants {
/** /**
* The default inventory tab ids. * The default inventory tab ids.
*/ */
public static final int[] DEFAULT_INVENTORY_TABS = { 2423, 3917, 638, 3213, 1644, 5608, 1151, -1, 5065, 5715, 2449, 904, 147, public static final int[] DEFAULT_INVENTORY_TABS = { 2423, 3917, 638, 3213, 1644, 5608, 1151, -1, 5065, 5715, 2449,
962, }; 904, 147, 962, };
// 6299 = music tab, music disabled // 6299 = music tab, music disabled
// 4445 = settings tab, music disabled // 4445 = settings tab, music disabled
// 12855 = ancients magic // 12855 = ancients magic
@@ -19,8 +19,8 @@ public class InterfaceConstants {
/** /**
* The level-up dialogue interface ids. * The level-up dialogue interface ids.
*/ */
public static final int[] LEVEL_UP_INTERFACES = { 6247, 6253, 6206, 6216, 4443, 6242, 6211, 6226, 4272, 6231, 6258, 4282, public static final int[] LEVEL_UP_INTERFACES = { 6247, 6253, 6206, 6216, 4443, 6242, 6211, 6226, 4272, 6231, 6258,
6263, 6221, 4416, 6237, 4277, 4261, 12122, 4887, 4267 }; 4282, 6263, 6221, 4416, 6237, 4277, 4261, 12122, 4887, 4267 };
/** /**
* The quest interface id. * The quest interface id.
@@ -35,12 +35,13 @@ public class InterfaceConstants {
/** /**
* The array of widgets that display the text. * The array of widgets that display the text.
*/ */
public static final int[] QUEST_TEXT = { 8144, 8145, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 8158, public static final int[] QUEST_TEXT = { 8144, 8145, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156,
8159, 8160, 8161, 8162, 8163, 8164, 8165, 8166, 8167, 8168, 8169, 8170, 8171, 8172, 8173, 8174, 8175, 8176, 8177, 8157, 8158, 8159, 8160, 8161, 8162, 8163, 8164, 8165, 8166, 8167, 8168, 8169, 8170, 8171, 8172, 8173, 8174,
8178, 8179, 8180, 8181, 8182, 8183, 8184, 8185, 8186, 8187, 8188, 8189, 8190, 8191, 8192, 8193, 8194, 8195, 12174, 8175, 8176, 8177, 8178, 8179, 8180, 8181, 8182, 8183, 8184, 8185, 8186, 8187, 8188, 8189, 8190, 8191, 8192,
12175, 12176, 12177, 12178, 12179, 12180, 12181, 12182, 12183, 12184, 12185, 12186, 12187, 12188, 12189, 12190, 8193, 8194, 8195, 12174, 12175, 12176, 12177, 12178, 12179, 12180, 12181, 12182, 12183, 12184, 12185,
12191, 12192, 12193, 12194, 12195, 12196, 12197, 12198, 12199, 12200, 12201, 12202, 12203, 12204, 12205, 12206, 12186, 12187, 12188, 12189, 12190, 12191, 12192, 12193, 12194, 12195, 12196, 12197, 12198, 12199, 12200,
12207, 12208, 12209, 12210, 12211, 12212, 12213, 12214, 12215, 12216, 12217, 12218, 12219, 12220, 12221, 12222, 12223 }; 12201, 12202, 12203, 12204, 12205, 12206, 12207, 12208, 12209, 12210, 12211, 12212, 12213, 12214, 12215,
12216, 12217, 12218, 12219, 12220, 12221, 12222, 12223 };
/** /**
* The quest title widget id. * The quest title widget id.
+1 -2
View File
@@ -1,5 +1,4 @@
/** /**
* Contains classes which represent things in the in-game world such as items, * Contains classes which represent things in the in-game world such as items, players and NPCs.
* players and NPCs.
*/ */
package org.apollo.game.model; package org.apollo.game.model;
@@ -31,8 +31,7 @@ public final class LevelUpSkillListener extends SkillAdapter {
// TODO show the interface // TODO show the interface
String name = Skill.getName(id); String name = Skill.getName(id);
String article = LanguageUtil.getIndefiniteArticle(name); String article = LanguageUtil.getIndefiniteArticle(name);
player.sendMessage("You've just advanced " + article + " " + name + " level! You have reached level " player.sendMessage("You've just advanced " + article + " " + name + " level! You have reached level " + skill.getMaximumLevel() + ".");
+ skill.getMaximumLevel() + ".");
if (Skill.isCombatSkill(id)) { if (Skill.isCombatSkill(id)) {
player.getSkillSet().calculateCombatLevel(); player.getSkillSet().calculateCombatLevel();
@@ -1,5 +1,4 @@
/** /**
* Contains classes related to scheduling which allow tasks to be executed in * Contains classes related to scheduling which allow tasks to be executed in future pulses periodically.
* future pulses periodically.
*/ */
package org.apollo.game.scheduling; package org.apollo.game.scheduling;
@@ -77,8 +77,7 @@ public final class AppearanceBlock extends SynchronizationBlock {
* @param isSkulled Whether or not the player is skulled. * @param isSkulled Whether or not the player is skulled.
* @param npcId The npc id of the player, if they are appearing as an npc, (otherwise {@code -1}). * @param npcId The npc id of the player, if they are appearing as an npc, (otherwise {@code -1}).
*/ */
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon, AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int headIcon, boolean isSkulled, int npcId) {
boolean isSkulled, int npcId) {
this.name = name; this.name = name;
this.appearance = appearance; this.appearance = appearance;
this.combat = combat; this.combat = combat;
@@ -48,8 +48,7 @@ public final class ForceMovementBlock extends SynchronizationBlock {
* @param travelDurationY The length of time (in game pulses) the player's movement along the Y-axis will last. * @param travelDurationY The length of time (in game pulses) the player's movement along the Y-axis will last.
* @param direction The direction the player should move. * @param direction The direction the player should move.
*/ */
ForceMovementBlock(Position initialPosition, Position finalPosition, int travelDurationX, int travelDurationY, ForceMovementBlock(Position initialPosition, Position finalPosition, int travelDurationX, int travelDurationY, Direction direction) {
Direction direction) {
this.initialPosition = initialPosition; this.initialPosition = initialPosition;
this.finalPosition = finalPosition; this.finalPosition = finalPosition;
this.travelDurationX = travelDurationX; this.travelDurationX = travelDurationX;
@@ -37,8 +37,7 @@ public abstract class SynchronizationBlock {
int combat = player.getSkillSet().getCombatLevel(); int combat = player.getSkillSet().getCombatLevel();
int id = player.hasNpcDefinition() ? player.getDefinition().getId() : -1; int id = player.hasNpcDefinition() ? player.getDefinition().getId() : -1;
return new AppearanceBlock(player.getEncodedName(), player.getAppearance(), combat, 0, player.getEquipment(), return new AppearanceBlock(player.getEncodedName(), player.getAppearance(), combat, 0, player.getEquipment(), player.getPrayerIcon(), player.isSkulled(), id);
player.getPrayerIcon(), player.isSkulled(), id);
} }
/** /**
@@ -72,8 +71,7 @@ public abstract class SynchronizationBlock {
* @param direction The {@link Direction} the player should move. * @param direction The {@link Direction} the player should move.
* @return The force movement block. * @return The force movement block.
*/ */
public static SynchronizationBlock createForceMovementBlock(Position initialPosition, Position finalPosition, public static SynchronizationBlock createForceMovementBlock(Position initialPosition, Position finalPosition, int travelDurationX, int travelDurationY, Direction direction) {
int travelDurationX, int travelDurationY, Direction direction) {
return new ForceMovementBlock(initialPosition, finalPosition, travelDurationX, travelDurationY, direction); return new ForceMovementBlock(initialPosition, finalPosition, travelDurationX, travelDurationY, direction);
} }
@@ -98,10 +96,8 @@ public abstract class SynchronizationBlock {
* @param secondary If the block is a secondary hit or not. * @param secondary If the block is a secondary hit or not.
* @return The hit update block. * @return The hit update block.
*/ */
public static SynchronizationBlock createHitUpdateBlock(int damage, int type, int currentHealth, int maximumHealth, public static SynchronizationBlock createHitUpdateBlock(int damage, int type, int currentHealth, int maximumHealth, boolean secondary) {
boolean secondary) { return secondary ? new SecondaryHitUpdateBlock(damage, type, currentHealth, maximumHealth) : new HitUpdateBlock(damage, type, currentHealth, maximumHealth);
return secondary ? new SecondaryHitUpdateBlock(damage, type, currentHealth, maximumHealth) : new HitUpdateBlock(damage,
type, currentHealth, maximumHealth);
} }
/** /**
+2 -2
View File
@@ -1,5 +1,5 @@
/** /**
* Contains classes related to client synchronization - the process where the * Contains classes related to client synchronization - the process where the client's state is updated by the server so
* client's state is updated by the server so it matches the server's state. * it matches the server's state.
*/ */
package org.apollo.game.sync; package org.apollo.game.sync;
@@ -26,8 +26,7 @@ public final class MovementSegment extends SynchronizationSegment {
*/ */
public MovementSegment(SynchronizationBlockSet blockSet, Direction[] directions) { public MovementSegment(SynchronizationBlockSet blockSet, Direction[] directions) {
super(blockSet); super(blockSet);
Preconditions.checkArgument(directions.length >= 0 && directions.length < 3, Preconditions.checkArgument(directions.length >= 0 && directions.length < 3, "Directions length must be between 0 and 2 inclusive.");
"Directions length must be between 0 and 2 inclusive.");
this.directions = directions; this.directions = directions;
} }
@@ -43,14 +42,14 @@ public final class MovementSegment extends SynchronizationSegment {
@Override @Override
public SegmentType getType() { public SegmentType getType() {
switch (directions.length) { switch (directions.length) {
case 0: case 0:
return SegmentType.NO_MOVEMENT; return SegmentType.NO_MOVEMENT;
case 1: case 1:
return SegmentType.WALK; return SegmentType.WALK;
case 2: case 2:
return SegmentType.RUN; return SegmentType.RUN;
default: default:
throw new IllegalStateException("Direction type unsupported."); throw new IllegalStateException("Direction type unsupported.");
} }
} }
@@ -1,6 +1,5 @@
/** /**
* Contains classes related to synchronization segments. Each segment contains * Contains classes related to synchronization segments. Each segment contains multiple blocks and can be used to add,
* multiple blocks and can be used to add, remove, teleport or move a * remove, teleport or move a mob.
* mob.
*/ */
package org.apollo.game.sync.seg; package org.apollo.game.sync.seg;
@@ -50,8 +50,7 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
for (Iterator<Npc> it = localNpcs.iterator(); it.hasNext();) { for (Iterator<Npc> it = localNpcs.iterator(); it.hasNext();) {
Npc npc = it.next(); Npc npc = it.next();
if (!npc.isActive() || npc.isTeleporting() if (!npc.isActive() || npc.isTeleporting() || npc.getPosition().getLongestDelta(playerPosition) > player.getViewingDistance()) {
|| npc.getPosition().getLongestDelta(playerPosition) > player.getViewingDistance()) {
it.remove(); it.remove();
segments.add(new RemoveMobSegment()); segments.add(new RemoveMobSegment());
} else { } else {
@@ -70,8 +69,7 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
} }
Position npcPosition = npc.getPosition(); Position npcPosition = npc.getPosition();
if (npcPosition.isWithinDistance(playerPosition, player.getViewingDistance()) && !localNpcs.contains(npc) if (npcPosition.isWithinDistance(playerPosition, player.getViewingDistance()) && !localNpcs.contains(npc) && npcPosition.getHeight() == playerPosition.getHeight()) {
&& npcPosition.getHeight() == playerPosition.getHeight()) {
localNpcs.add(npc); localNpcs.add(npc);
added++; added++;
npc.turnTo(npc.getFacingPosition()); npc.turnTo(npc.getFacingPosition());
@@ -70,8 +70,7 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
for (Iterator<Player> it = localPlayers.iterator(); it.hasNext();) { for (Iterator<Player> it = localPlayers.iterator(); it.hasNext();) {
Player other = it.next(); Player other = it.next();
if (!other.isActive() || other.isTeleporting() if (!other.isActive() || other.isTeleporting() || other.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|| other.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
it.remove(); it.remove();
segments.add(new RemoveMobSegment()); segments.add(new RemoveMobSegment());
} else { } else {
@@ -91,8 +90,7 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
break; break;
} }
if (other != player && other.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance()) if (other != player && other.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance()) && !localPlayers.contains(other)) {
&& !localPlayers.contains(other)) {
localPlayers.add(other); localPlayers.add(other);
added++; added++;
@@ -107,8 +105,7 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
} }
} }
PlayerSynchronizationMessage message = new PlayerSynchronizationMessage(lastKnownSector, player.getPosition(), PlayerSynchronizationMessage message = new PlayerSynchronizationMessage(lastKnownSector, player.getPosition(), sectorChanged, segment, oldLocalPlayers, segments);
sectorChanged, segment, oldLocalPlayers, segments);
player.send(message); player.send(message);
} }
@@ -1,6 +1,5 @@
/** /**
* Contains classes related to * Contains classes related to {@link org.apollo.game.sync.task.SynchronizationTask}s, small chunks of work executed
* {@link org.apollo.game.sync.task.SynchronizationTask}s, small chunks of work * during the client synchronization process.
* executed during the client synchronization process.
*/ */
package org.apollo.game.sync.task; package org.apollo.game.sync.task;
@@ -53,8 +53,7 @@ public final class MessageHandlerChainParser {
* @return A {@link MessageHandlerChainGroup}. * @return A {@link MessageHandlerChainGroup}.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MessageHandlerChainGroup parse() throws IOException, SAXException, ClassNotFoundException, InstantiationException, public MessageHandlerChainGroup parse() throws IOException, SAXException, ClassNotFoundException, InstantiationException, IllegalAccessException {
IllegalAccessException {
XmlNode messages = parser.parse(is); XmlNode messages = parser.parse(is);
if (!messages.getName().equals("messages")) { if (!messages.getName().equals("messages")) {
throw new IOException("Root node name is not 'messages'."); throw new IOException("Root node name is not 'messages'.");
@@ -94,8 +93,7 @@ public final class MessageHandlerChainParser {
throw new IOException("Handler node must have a value."); throw new IOException("Handler node must have a value.");
} }
Class<? extends MessageHandler<?>> handlerClass = (Class<? extends MessageHandler<?>>) Class Class<? extends MessageHandler<?>> handlerClass = (Class<? extends MessageHandler<?>>) Class.forName(handlerClassName);
.forName(handlerClassName);
MessageHandler<?> handler = handlerClass.newInstance(); MessageHandler<?> handler = handlerClass.newInstance();
handlers.add(handler); handlers.add(handler);
} }
@@ -32,8 +32,7 @@ public final class PlayerLoaderResponse {
* {@link LoginConstants#STATUS_RECONNECTION_OK}. * {@link LoginConstants#STATUS_RECONNECTION_OK}.
*/ */
public PlayerLoaderResponse(int status) { public PlayerLoaderResponse(int status) {
Preconditions.checkArgument(status != LoginConstants.STATUS_OK && status != LoginConstants.STATUS_RECONNECTION_OK, Preconditions.checkArgument(status != LoginConstants.STATUS_OK && status != LoginConstants.STATUS_RECONNECTION_OK, "Player required for this status code.");
"Player required for this status code.");
this.status = status; this.status = status;
player = Optional.empty(); player = Optional.empty();
} }
@@ -47,8 +46,7 @@ public final class PlayerLoaderResponse {
* @throws NullPointerException If the specified player is null. * @throws NullPointerException If the specified player is null.
*/ */
public PlayerLoaderResponse(int status, Player player) { public PlayerLoaderResponse(int status, Player player) {
Preconditions.checkArgument(status == LoginConstants.STATUS_OK || status == LoginConstants.STATUS_RECONNECTION_OK, Preconditions.checkArgument(status == LoginConstants.STATUS_OK || status == LoginConstants.STATUS_RECONNECTION_OK, "Player not required for this status code.");
"Player not required for this status code.");
this.status = status; this.status = status;
this.player = Optional.of(player); this.player = Optional.of(player);
} }
+6 -6
View File
@@ -85,13 +85,13 @@ public final class ApolloHandler extends ChannelInboundHandlerAdapter {
HandshakeMessage handshakeMessage = (HandshakeMessage) message; HandshakeMessage handshakeMessage = (HandshakeMessage) message;
switch (handshakeMessage.getServiceId()) { switch (handshakeMessage.getServiceId()) {
case HandshakeConstants.SERVICE_GAME: case HandshakeConstants.SERVICE_GAME:
attribute.set(new LoginSession(ctx, serverContext)); attribute.set(new LoginSession(ctx, serverContext));
break; break;
case HandshakeConstants.SERVICE_UPDATE: case HandshakeConstants.SERVICE_UPDATE:
attribute.set(new UpdateSession(ctx.channel(), serverContext)); attribute.set(new UpdateSession(ctx.channel(), serverContext));
break; break;
} }
} }
@@ -62,17 +62,17 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
@Override @Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, GameDecoderState state) { protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, GameDecoderState state) {
switch (state) { switch (state) {
case GAME_OPCODE: case GAME_OPCODE:
decodeOpcode(in, out); decodeOpcode(in, out);
break; break;
case GAME_LENGTH: case GAME_LENGTH:
decodeLength(in); decodeLength(in);
break; break;
case GAME_PAYLOAD: case GAME_PAYLOAD:
decodePayload(in, out); decodePayload(in, out);
break; break;
default: default:
throw new IllegalStateException("Invalid game decoder state."); throw new IllegalStateException("Invalid game decoder state.");
} }
} }
@@ -106,20 +106,20 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
type = metaData.getType(); type = metaData.getType();
switch (type) { switch (type) {
case FIXED: case FIXED:
length = metaData.getLength(); length = metaData.getLength();
if (length == 0) { if (length == 0) {
setState(GameDecoderState.GAME_OPCODE); setState(GameDecoderState.GAME_OPCODE);
out.add(new GamePacket(opcode, type, Unpooled.EMPTY_BUFFER)); out.add(new GamePacket(opcode, type, Unpooled.EMPTY_BUFFER));
} else { } else {
setState(GameDecoderState.GAME_PAYLOAD); setState(GameDecoderState.GAME_PAYLOAD);
} }
break; break;
case VARIABLE_BYTE: case VARIABLE_BYTE:
setState(GameDecoderState.GAME_LENGTH); setState(GameDecoderState.GAME_LENGTH);
break; break;
default: default:
throw new IllegalStateException("Illegal packet type: " + type + "."); throw new IllegalStateException("Illegal packet type: " + type + ".");
} }
} }
} }
@@ -34,23 +34,23 @@ public final class HandshakeDecoder extends ByteToMessageDecoder {
int id = buffer.readUnsignedByte(); int id = buffer.readUnsignedByte();
switch (id) { switch (id) {
case HandshakeConstants.SERVICE_GAME: case HandshakeConstants.SERVICE_GAME:
ctx.pipeline().addFirst("loginEncoder", new LoginEncoder()); ctx.pipeline().addFirst("loginEncoder", new LoginEncoder());
ctx.pipeline().addAfter("handshakeDecoder", "loginDecoder", new LoginDecoder()); ctx.pipeline().addAfter("handshakeDecoder", "loginDecoder", new LoginDecoder());
break; break;
case HandshakeConstants.SERVICE_UPDATE: case HandshakeConstants.SERVICE_UPDATE:
ctx.pipeline().addFirst("updateEncoder", new UpdateEncoder()); ctx.pipeline().addFirst("updateEncoder", new UpdateEncoder());
ctx.pipeline().addBefore("handler", "updateDecoder", new UpdateDecoder()); ctx.pipeline().addBefore("handler", "updateDecoder", new UpdateDecoder());
ByteBuf buf = ctx.alloc().buffer(8).writeLong(0); ByteBuf buf = ctx.alloc().buffer(8).writeLong(0);
ctx.channel().writeAndFlush(buf); ctx.channel().writeAndFlush(buf);
break; break;
default: default:
ByteBuf data = buffer.readBytes(buffer.readableBytes()); ByteBuf data = buffer.readBytes(buffer.readableBytes());
logger.info(String.format("Unexpected handshake request received: %d data: %s", id, data.toString())); logger.info(String.format("Unexpected handshake request received: %d data: %s", id, data.toString()));
return; return;
} }
ctx.pipeline().remove(this); ctx.pipeline().remove(this);
@@ -60,17 +60,17 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
@Override @Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, LoginDecoderState state) { protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, LoginDecoderState state) {
switch (state) { switch (state) {
case LOGIN_HANDSHAKE: case LOGIN_HANDSHAKE:
decodeHandshake(ctx, in, out); decodeHandshake(ctx, in, out);
break; break;
case LOGIN_HEADER: case LOGIN_HEADER:
decodeHeader(ctx, in, out); decodeHeader(ctx, in, out);
break; break;
case LOGIN_PAYLOAD: case LOGIN_PAYLOAD:
decodePayload(ctx, in, out); decodePayload(ctx, in, out);
break; break;
default: default:
throw new IllegalStateException("Invalid login decoder state: " + state); throw new IllegalStateException("Invalid login decoder state: " + state);
} }
} }
@@ -56,8 +56,7 @@ public final class LoginRequest {
* @param archiveCrcs The archive CRCs. * @param archiveCrcs The archive CRCs.
* @param clientVersion The client version. * @param clientVersion The client version.
*/ */
public LoginRequest(PlayerCredentials credentials, IsaacRandomPair randomPair, boolean lowMemory, boolean reconnecting, public LoginRequest(PlayerCredentials credentials, IsaacRandomPair randomPair, boolean lowMemory, boolean reconnecting, int releaseNumber, int[] archiveCrcs, int clientVersion) {
int releaseNumber, int[] archiveCrcs, int clientVersion) {
this.credentials = credentials; this.credentials = credentials;
this.randomPair = randomPair; this.randomPair = randomPair;
this.lowMemory = lowMemory; this.lowMemory = lowMemory;
@@ -41,14 +41,14 @@ public final class OnDemandRequest implements Comparable<OnDemandRequest> {
*/ */
public static Priority valueOf(int value) { public static Priority valueOf(int value) {
switch (value) { switch (value) {
case 0: case 0:
return HIGH; return HIGH;
case 1: case 1:
return MEDIUM; return MEDIUM;
case 2: case 2:
return LOW; return LOW;
default: default:
throw new IllegalArgumentException("Priority out of range - received " + value + "."); throw new IllegalArgumentException("Priority out of range - received " + value + ".");
} }
} }
+2 -2
View File
@@ -1,5 +1,5 @@
/** /**
* Contains classes related to networking. Many of these extend Netty's set of * Contains classes related to networking. Many of these extend Netty's set of classes - such as the pipeline factory,
* classes - such as the pipeline factory, handler and codecs. * handler and codecs.
*/ */
package org.apollo.net; package org.apollo.net;
+2 -2
View File
@@ -1,5 +1,5 @@
/** /**
* Contains abstract classes which should be extended by a particular release, * Contains abstract classes which should be extended by a particular release, allowing for portability between various
* allowing for portability between various protocol and client releases. * protocol and client releases.
*/ */
package org.apollo.net.release; package org.apollo.net.release;
@@ -227,8 +227,7 @@ public final class NpcSynchronizationMessageEncoder extends MessageEncoder<NpcSy
* @param message The message. * @param message The message.
* @param builder The builder. * @param builder The builder.
*/ */
private static void putMovementUpdate(SynchronizationSegment segment, NpcSynchronizationMessage message, private static void putMovementUpdate(SynchronizationSegment segment, NpcSynchronizationMessage message, GamePacketBuilder builder) {
GamePacketBuilder builder) {
boolean updateRequired = segment.getBlockSet().size() > 0; boolean updateRequired = segment.getBlockSet().size() > 0;
if (segment.getType() == SegmentType.RUN) { if (segment.getType() == SegmentType.RUN) {
Direction[] directions = ((MovementSegment) segment).getDirections(); Direction[] directions = ((MovementSegment) segment).getDirections();
@@ -388,8 +388,7 @@ public final class PlayerSynchronizationMessageEncoder extends MessageEncoder<Pl
* @param message The message. * @param message The message.
* @param builder The builder. * @param builder The builder.
*/ */
private static void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationMessage message, private static void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationMessage message, GamePacketBuilder builder) {
GamePacketBuilder builder) {
boolean updateRequired = seg.getBlockSet().size() > 0; boolean updateRequired = seg.getBlockSet().size() > 0;
if (seg.getType() == SegmentType.TELEPORT) { if (seg.getType() == SegmentType.TELEPORT) {
Position position = ((TeleportSegment) seg).getDestination(); Position position = ((TeleportSegment) seg).getDestination();
@@ -11,11 +11,11 @@ import org.apollo.net.release.MessageDecoder;
*/ */
public final class FirstNpcActionMessageDecoder extends MessageDecoder<FirstNpcActionMessage> { public final class FirstNpcActionMessageDecoder extends MessageDecoder<FirstNpcActionMessage> {
@Override @Override
public FirstNpcActionMessage decode(GamePacket packet) { public FirstNpcActionMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet); GamePacketReader reader = new GamePacketReader(packet);
int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE); int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE);
return new FirstNpcActionMessage(index); return new FirstNpcActionMessage(index);
} }
} }
@@ -29,7 +29,7 @@ public final class FlaggedMouseEventMessageDecoder extends MessageDecoder<Flagge
} else { } else {
read = (int) reader.getUnsigned(DataType.INT) & ~0xc0000000; read = (int) reader.getUnsigned(DataType.INT) & ~0xc0000000;
} }
clicks = (read >> 19); clicks = (read >> 19);
x = (read & 0x7f) % 765; x = (read & 0x7f) % 765;
y = (read & 0x7f) / 765; y = (read & 0x7f) / 765;
@@ -15,14 +15,14 @@ import org.apollo.net.release.MessageDecoder;
*/ */
public final class MagicOnNpcMessageDecoder extends MessageDecoder<MagicOnNpcMessage> { public final class MagicOnNpcMessageDecoder extends MessageDecoder<MagicOnNpcMessage> {
@Override @Override
public MagicOnNpcMessage decode(GamePacket packet) { public MagicOnNpcMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet); GamePacketReader reader = new GamePacketReader(packet);
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD); int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
int spell = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD); int spell = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
return new MagicOnNpcMessage(index, spell); return new MagicOnNpcMessage(index, spell);
} }
} }
@@ -388,8 +388,7 @@ public final class PlayerSynchronizationMessageEncoder extends MessageEncoder<Pl
* @param message The message. * @param message The message.
* @param builder The builder. * @param builder The builder.
*/ */
private static void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationMessage message, private static void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationMessage message, GamePacketBuilder builder) {
GamePacketBuilder builder) {
boolean updateRequired = seg.getBlockSet().size() > 0; boolean updateRequired = seg.getBlockSet().size() > 0;
if (seg.getType() == SegmentType.TELEPORT) { if (seg.getType() == SegmentType.TELEPORT) {
Position pos = ((TeleportSegment) seg).getDestination(); Position pos = ((TeleportSegment) seg).getDestination();
@@ -13,9 +13,9 @@ public final class SecondNpcActionMessageDecoder extends MessageDecoder<SecondNp
@Override @Override
public SecondNpcActionMessage decode(GamePacket packet) { public SecondNpcActionMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet); GamePacketReader reader = new GamePacketReader(packet);
int index = (int) reader.getSigned(DataType.SHORT, DataTransformation.ADD); int index = (int) reader.getSigned(DataType.SHORT, DataTransformation.ADD);
return new SecondNpcActionMessage(index); return new SecondNpcActionMessage(index);
} }
} }
@@ -17,9 +17,9 @@ public final class ThirdNpcActionMessageDecoder extends MessageDecoder<ThirdNpcA
@Override @Override
public ThirdNpcActionMessage decode(GamePacket packet) { public ThirdNpcActionMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet); GamePacketReader reader = new GamePacketReader(packet);
int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD); int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
return new ThirdNpcActionMessage(index); return new ThirdNpcActionMessage(index);
} }
} }
+2 -4
View File
@@ -103,8 +103,7 @@ public final class LoginSession extends Session {
optional = Optional.empty(); optional = Optional.empty();
rights = 0; rights = 0;
status = (registration == RegistrationStatus.ALREADY_ONLINE) ? LoginConstants.STATUS_ACCOUNT_ONLINE status = (registration == RegistrationStatus.ALREADY_ONLINE) ? LoginConstants.STATUS_ACCOUNT_ONLINE : LoginConstants.STATUS_SERVER_FULL;
: LoginConstants.STATUS_SERVER_FULL;
} }
} }
@@ -119,8 +118,7 @@ public final class LoginSession extends Session {
channel.pipeline().addFirst("eventEncoder", new GameMessageEncoder(release)); channel.pipeline().addFirst("eventEncoder", new GameMessageEncoder(release));
channel.pipeline().addBefore("eventEncoder", "gameEncoder", new GamePacketEncoder(randomPair.getEncodingRandom())); channel.pipeline().addBefore("eventEncoder", "gameEncoder", new GamePacketEncoder(randomPair.getEncodingRandom()));
channel.pipeline().addBefore("handler", "gameDecoder", channel.pipeline().addBefore("handler", "gameDecoder", new GamePacketDecoder(randomPair.getDecodingRandom(), serverContext.getRelease()));
new GamePacketDecoder(randomPair.getDecodingRandom(), serverContext.getRelease()));
channel.pipeline().addAfter("gameDecoder", "eventDecoder", new GameMessageDecoder(release)); channel.pipeline().addAfter("gameDecoder", "eventDecoder", new GameMessageDecoder(release));
channel.pipeline().remove("loginDecoder"); channel.pipeline().remove("loginDecoder");
+2 -3
View File
@@ -1,7 +1,6 @@
/** /**
* Contains {@link org.apollo.net.session.Session} classes which are the * Contains {@link org.apollo.net.session.Session} classes which are the equivalent of Netty's
* equivalent of Netty's {@link io.netty.channel.Channel}s but are * {@link io.netty.channel.Channel}s but are designed for Apollo to use itself - unlike Netty's which are purely
* designed for Apollo to use itself - unlike Netty's which are purely
* designed for networking. * designed for networking.
*/ */
package org.apollo.net.session; package org.apollo.net.session;
+1 -2
View File
@@ -1,5 +1,4 @@
/** /**
* Contains core Apollo server classes such as service management and the * Contains core Apollo server classes such as service management and the server bootstrap class.
* server bootstrap class.
*/ */
package org.apollo; package org.apollo;
+13 -11
View File
@@ -22,8 +22,9 @@ public final class EquipmentConstants {
/** /**
* Bodies. * Bodies.
*/ */
public static final String[] BODY = { "platebody", "chainbody", "robetop", "leathertop", "platemail", "top", "brassard", public static final String[] BODY = { "platebody", "chainbody", "robetop", "leathertop", "platemail", "top",
"Robe top", "body", "platebody (t)", "platebody (g)", "body(g)", "body_(g)", "chestplate", "torso", "shirt" }; "brassard", "Robe top", "body", "platebody (t)", "platebody (g)", "body(g)", "body_(g)", "chestplate",
"torso", "shirt" };
/** /**
* Boots. * Boots.
@@ -38,8 +39,8 @@ public final class EquipmentConstants {
/** /**
* Full bodies. * Full bodies.
*/ */
public static final String[] FULL_BODIES = { "top", "shirt", "platebody", "Ahrims robetop", "Karils leathertop", "brassard", public static final String[] FULL_BODIES = { "top", "shirt", "platebody", "Ahrims robetop", "Karils leathertop",
"Robe top", "robetop", "platebody (t)", "platebody (g)", "chestplate", "torso" }; "brassard", "Robe top", "robetop", "platebody (t)", "platebody (g)", "chestplate", "torso" };
/** /**
* Full hats. * Full hats.
@@ -50,8 +51,8 @@ public final class EquipmentConstants {
/** /**
* Full masks. * Full masks.
*/ */
public static final String[] FULL_MASKS = { "full helm", "mask", "Veracs helm", "Guthans helm", "Torags helm", "Karils coif", public static final String[] FULL_MASKS = { "full helm", "mask", "Veracs helm", "Guthans helm", "Torags helm",
"full helm (t)", "full helm (g)", "mask" }; "Karils coif", "full helm (t)", "full helm (g)", "mask" };
/** /**
* Gloves. * Gloves.
@@ -61,8 +62,9 @@ public final class EquipmentConstants {
/** /**
* Hats. * Hats.
*/ */
public static final String[] HATS = { "tiara", "helm", "hood", "coif", "Coif", "hat", "partyhat", "Hat", "full helm (t)", public static final String[] HATS = { "tiara", "helm", "hood", "coif", "Coif", "hat", "partyhat", "Hat",
"full helm (g)", "hat (t)", "hat (g)", "cav", "boater", "helmet", "mask", "Helm of neitiznot" }; "full helm (t)", "full helm (g)", "hat (t)", "hat (g)", "cav", "boater", "helmet", "mask",
"Helm of neitiznot" };
/** /**
* Legs. * Legs.
@@ -87,9 +89,9 @@ public final class EquipmentConstants {
*/ */
public static final String[] WEAPONS = { "scimitar", "longsword", "sword", "longbow", "shortbow", "dagger", "mace", public static final String[] WEAPONS = { "scimitar", "longsword", "sword", "longbow", "shortbow", "dagger", "mace",
"halberd", "spear", "Abyssal whip", "axe", "flail", "crossbow", "Torags hammers", "dagger(p)", "dagger(+)", "halberd", "spear", "Abyssal whip", "axe", "flail", "crossbow", "Torags hammers", "dagger(p)", "dagger(+)",
"dagger(s)", "spear(p)", "spear(+)", "spear(s)", "spear(kp)", "maul", "dart", "dart(p)", "javelin", "javelin(p)", "dagger(s)", "spear(p)", "spear(+)", "spear(s)", "spear(kp)", "maul", "dart", "dart(p)", "javelin",
"knife", "knife(p)", "Longbow", "Shortbow", "Crossbow", "Toktz-xil", "Toktz-mej", "Tzhaar-ket", "staff", "Staff", "javelin(p)", "knife", "knife(p)", "Longbow", "Shortbow", "Crossbow", "Toktz-xil", "Toktz-mej",
"godsword", "c'bow", "Crystal bow", "Dark bow", "Magic butterfly net" }; "Tzhaar-ket", "staff", "Staff", "godsword", "c'bow", "Crystal bow", "Dark bow", "Magic butterfly net" };
/** /**
* Default private constructor to prevent instantiation. * Default private constructor to prevent instantiation.
+1 -3
View File
@@ -1169,9 +1169,7 @@ public final class EquipmentUpdater {
Preconditions.checkArgument(args.length == 1, "Usage:\njava -cp ... org.apollo.tools.EquipmentUpdater [release]."); Preconditions.checkArgument(args.length == 1, "Usage:\njava -cp ... org.apollo.tools.EquipmentUpdater [release].");
String release = args[0]; String release = args[0];
try (DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("data/equipment-" + release try (DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("data/equipment-" + release + ".dat"))); IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs/", release), true)) {
+ ".dat")));
IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs/", release), true)) {
ItemDefinitionDecoder decoder = new ItemDefinitionDecoder(fs); ItemDefinitionDecoder decoder = new ItemDefinitionDecoder(fs);
ItemDefinition[] definitions = decoder.decode(); ItemDefinition[] definitions = decoder.decode();
ItemDefinition.init(definitions); ItemDefinition.init(definitions);
+1 -2
View File
@@ -100,8 +100,7 @@ public final class CompressionUtil {
byte[] data = new byte[compressed.remaining()]; byte[] data = new byte[compressed.remaining()];
compressed.get(data); compressed.get(data);
try (InputStream is = new GZIPInputStream(new ByteArrayInputStream(data)); try (InputStream is = new GZIPInputStream(new ByteArrayInputStream(data)); ByteArrayOutputStream os = new ByteArrayOutputStream()) {
ByteArrayOutputStream os = new ByteArrayOutputStream()) {
while (true) { while (true) {
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
int read = is.read(buf, 0, buf.length); int read = is.read(buf, 0, buf.length);
+4 -4
View File
@@ -12,10 +12,10 @@ public final class NameUtil {
/** /**
* An array of valid characters in a player name encoded as a long. * An array of valid characters in a player name encoded as a long.
*/ */
private static final char[] NAME_CHARS = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', private static final char[] NAME_CHARS = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '@', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
'#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', ':', ';', '.', '>', '<', ',', '"', '[', ']', '|', '?', '/', '8', '9', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', ':', ';', '.', '>', '<', ',',
'`' }; '"', '[', ']', '|', '?', '/', '`' };
/** /**
* Converts a long to a player name. * Converts a long to a player name.
+4 -4
View File
@@ -11,10 +11,10 @@ public final class TextUtil {
* An array of characters ordered by frequency - the elements with lower indices (generally) appear more often in * An array of characters ordered by frequency - the elements with lower indices (generally) appear more often in
* chat messages. * chat messages.
*/ */
public static final char[] FREQUENCY_ORDERED_CHARS = { ' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r', 'd', 'l', 'u', 'm', public static final char[] FREQUENCY_ORDERED_CHARS = { ' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r', 'd', 'l',
'w', 'c', 'y', 'f', 'g', 'p', 'b', 'v', 'k', 'x', 'j', 'q', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'u', 'm', 'w', 'c', 'y', 'f', 'g', 'p', 'b', 'v', 'k', 'x', 'j', 'q', 'z', '0', '1', '2', '3', '4', '5',
' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '\243', '$', '%', '"', '6', '7', '8', '9', ' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+',
'[', ']' }; '=', '\243', '$', '%', '"', '[', ']' };
/** /**
* Capitalizes the string correctly. * Capitalizes the string correctly.
@@ -156,8 +156,7 @@ public final class PluginManager {
* @throws DependencyException If a dependency error occurs. * @throws DependencyException If a dependency error occurs.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
private void start(PluginEnvironment env, PluginMetaData plugin, Map<String, PluginMetaData> plugins, private void start(PluginEnvironment env, PluginMetaData plugin, Map<String, PluginMetaData> plugins, Set<PluginMetaData> started) throws DependencyException, IOException {
Set<PluginMetaData> started) throws DependencyException, IOException {
// TODO check for cyclic dependencies! this way just won't cut it, we need an exception // TODO check for cyclic dependencies! this way just won't cut it, we need an exception
if (started.contains(plugin)) { if (started.contains(plugin)) {
return; return;
@@ -61,8 +61,7 @@ public final class PluginMetaData {
* @param dependencies The plugin's dependencies. * @param dependencies The plugin's dependencies.
* @param version The plugin's version. * @param version The plugin's version.
*/ */
public PluginMetaData(String id, File base, String name, String description, String[] authors, String[] scripts, public PluginMetaData(String id, File base, String name, String description, String[] authors, String[] scripts, String[] dependencies, double version) {
String[] dependencies, double version) {
this.id = id; this.id = id;
this.base = base; this.base = base;
this.name = name; this.name = name;