mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Implement various fixes from Major-/Apollo.
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
This version of Apollo contains code from the following people:
|
||||||
|
Graham and the rest of the Apollo team
|
||||||
|
Chris Fletcher (http://www.rune-server.org/members/chris%20fletcher)
|
||||||
|
Major (http://www.rune-server.org/members/major)
|
||||||
|
The Wanderer (http://www.rune-server.org/members/the%20wanderer)
|
||||||
|
|
||||||
|
Current fixes include:
|
||||||
|
317 ChatEventDecoder fix (data read incorrectly) - http://www.rune-server.org/runescape-development/rs2-server/snippets/420815-apollo-317-chat-event-decoder-bug-fix.html.
|
||||||
|
Player region changing fix (appeared to teleport) - http://www.rune-server.org/runescape-development/rs2-server/snippets/420865-apollo-players-changing-regions-appear-teleport-bug.html
|
||||||
|
Walking height level fix (always set to 0)
|
||||||
|
ThirdObjectActionEvent fix (data read incorrectly)
|
||||||
|
Combat level formula fix (calculated incorrectly)
|
||||||
|
Item equipping fix (wasn't removing them correctly)
|
||||||
|
2-handed weapon equip fix
|
||||||
|
SwitchItemEventDecoder fix (data read incorrectly)
|
||||||
|
SetInterfaceTextEventencoder fix (entire class was missing from 317)
|
||||||
|
317 and 377 packet length fixes.
|
||||||
|
Archive decoding fix (data wasn't being extracted properly)
|
||||||
|
Mining plugin: JRuby name clash with 'Gem'
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
GEMS = {}
|
GEMSTONES = {}
|
||||||
|
|
||||||
class Gem
|
class Gemstone
|
||||||
attr_reader :id, :chance
|
attr_reader :id, :chance
|
||||||
|
|
||||||
def initialize(id, chance)
|
def initialize(id, chance)
|
||||||
@@ -10,10 +10,10 @@ class Gem
|
|||||||
end
|
end
|
||||||
|
|
||||||
def append_gem(gem)
|
def append_gem(gem)
|
||||||
GEMS[gem.id] = gem
|
GEMSTONES[gem.id] = gem
|
||||||
end
|
end
|
||||||
|
|
||||||
append_gem(Gem.new(1623, 0)) # uncut sapphire
|
append_gem(Gemstone.new(1623, 0)) # uncut sapphire
|
||||||
append_gem(Gem.new(1605, 0)) # uncut emerald
|
append_gem(Gemstone.new(1605, 0)) # uncut emerald
|
||||||
append_gem(Gem.new(1619, 0)) # uncut ruby
|
append_gem(Gemstone.new(1619, 0)) # uncut ruby
|
||||||
append_gem(Gem.new(1617, 0)) # uncut diamond
|
append_gem(Gemstone.new(1617, 0)) # uncut diamond
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class MiningAction < DistancedAction
|
|||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
skills = character.skill_set
|
skills = character.skill_set
|
||||||
level = skills.get_skill(Skill::MINING).maximum_level # TODO: is using max level correct?
|
level = skills.get_skill(Skill::MINING).current_level
|
||||||
pickaxe = find_pickaxe
|
pickaxe = find_pickaxe
|
||||||
|
|
||||||
# verify the player can mine with their pickaxe
|
# verify the player can mine with their pickaxe
|
||||||
|
|||||||
@@ -9,21 +9,24 @@ import org.apollo.util.CompressionUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an archive.
|
* Represents an archive.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class Archive {
|
public final class Archive {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes the archive in the specified buffer.
|
* Decodes the archive in the specified buffer.
|
||||||
* @param buffer The buffer.
|
*
|
||||||
|
* @param buffer
|
||||||
|
* The buffer.
|
||||||
* @return The archive.
|
* @return The archive.
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException
|
||||||
|
* if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public static Archive decode(ByteBuffer buffer) throws IOException {
|
public static Archive decode(ByteBuffer buffer) throws IOException {
|
||||||
int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer);
|
int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer);
|
||||||
int size = ByteBufferUtil.readUnsignedTriByte(buffer);
|
int size = ByteBufferUtil.readUnsignedTriByte(buffer);
|
||||||
boolean extracted = false;
|
boolean extracted = false;
|
||||||
|
|
||||||
if (size != extractedSize) {
|
if (size != extractedSize) {
|
||||||
byte[] compressed = new byte[size];
|
byte[] compressed = new byte[size];
|
||||||
byte[] uncompressed = new byte[extractedSize];
|
byte[] uncompressed = new byte[extractedSize];
|
||||||
@@ -32,32 +35,31 @@ public final class Archive {
|
|||||||
buffer = ByteBuffer.wrap(uncompressed);
|
buffer = ByteBuffer.wrap(uncompressed);
|
||||||
extracted = true;
|
extracted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int entries = buffer.getShort() & 0xFFFF;
|
int entries = buffer.getShort() & 0xFFFF;
|
||||||
int[] identifiers = new int[entries];
|
int[] identifiers = new int[entries];
|
||||||
int[] extractedSizes = new int[entries];
|
int[] extractedSizes = new int[entries];
|
||||||
int[] sizes = new int[entries];
|
int[] sizes = new int[entries];
|
||||||
|
|
||||||
for (int i = 0; i < entries; i++) {
|
for (int i = 0; i < entries; i++) {
|
||||||
identifiers[i] = buffer.getInt();
|
identifiers[i] = buffer.getInt();
|
||||||
extractedSizes[i] = ByteBufferUtil.readUnsignedTriByte(buffer);
|
extractedSizes[i] = ByteBufferUtil.readUnsignedTriByte(buffer);
|
||||||
sizes[i] = ByteBufferUtil.readUnsignedTriByte(buffer);
|
sizes[i] = ByteBufferUtil.readUnsignedTriByte(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveEntry[] entry = new ArchiveEntry[entries];
|
ArchiveEntry[] entry = new ArchiveEntry[entries];
|
||||||
|
|
||||||
for (int i = 0; i < entries; i++) {
|
for (int i = 0; i < entries; i++) {
|
||||||
ByteBuffer entryBuffer = ByteBuffer.allocate(extractedSizes[i]);
|
ByteBuffer entryBuffer;
|
||||||
if (!extracted) {
|
if (!extracted) {
|
||||||
byte[] compressed = new byte[sizes[i]];
|
byte[] compressed = new byte[sizes[i]];
|
||||||
byte[] uncompressed = new byte[extractedSizes[i]];
|
byte[] uncompressed = new byte[extractedSizes[i]];
|
||||||
buffer.get(compressed);
|
buffer.get(compressed);
|
||||||
CompressionUtil.unbzip2(compressed, uncompressed);
|
CompressionUtil.unbzip2(compressed, uncompressed);
|
||||||
entryBuffer = ByteBuffer.wrap(uncompressed);
|
entryBuffer = ByteBuffer.wrap(uncompressed);
|
||||||
|
} else {
|
||||||
|
byte[] buf = new byte[extractedSizes[i]];
|
||||||
|
buffer.get(buf);
|
||||||
|
entryBuffer = ByteBuffer.wrap(buf);
|
||||||
}
|
}
|
||||||
entry[i] = new ArchiveEntry(identifiers[i], entryBuffer);
|
entry[i] = new ArchiveEntry(identifiers[i], entryBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Archive(entry);
|
return new Archive(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +70,9 @@ public final class Archive {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new archive.
|
* Creates a new archive.
|
||||||
* @param entries The entries in this archive.
|
*
|
||||||
|
* @param entries
|
||||||
|
* The entries in this archive.
|
||||||
*/
|
*/
|
||||||
public Archive(ArchiveEntry[] entries) {
|
public Archive(ArchiveEntry[] entries) {
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
@@ -76,9 +80,12 @@ public final class Archive {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an entry by its name.
|
* Gets an entry by its name.
|
||||||
* @param name The name.
|
*
|
||||||
|
* @param name
|
||||||
|
* The name.
|
||||||
* @return The entry.
|
* @return The entry.
|
||||||
* @throws FileNotFoundException if the file could not be found.
|
* @throws FileNotFoundException
|
||||||
|
* if the file could not be found.
|
||||||
*/
|
*/
|
||||||
public ArchiveEntry getEntry(String name) throws FileNotFoundException {
|
public ArchiveEntry getEntry(String name) throws FileNotFoundException {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.apollo.util.ByteBufferUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A class which parses item definitions.
|
* A class which parses item definitions.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class ItemDefinitionParser {
|
public final class ItemDefinitionParser {
|
||||||
@@ -21,7 +22,9 @@ public final class ItemDefinitionParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the item definition parser.
|
* Creates the item definition parser.
|
||||||
* @param fs The indexed file system.
|
*
|
||||||
|
* @param fs
|
||||||
|
* The indexed file system.
|
||||||
*/
|
*/
|
||||||
public ItemDefinitionParser(IndexedFileSystem fs) {
|
public ItemDefinitionParser(IndexedFileSystem fs) {
|
||||||
this.fs = fs;
|
this.fs = fs;
|
||||||
@@ -29,8 +32,10 @@ public final class ItemDefinitionParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the item definitions.
|
* Parses the item definitions.
|
||||||
|
*
|
||||||
* @return The item definitions.
|
* @return The item definitions.
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException
|
||||||
|
* if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public ItemDefinition[] parse() throws IOException {
|
public ItemDefinition[] parse() throws IOException {
|
||||||
Archive config = Archive.decode(fs.getFile(0, 2));
|
Archive config = Archive.decode(fs.getFile(0, 2));
|
||||||
@@ -56,65 +61,54 @@ public final class ItemDefinitionParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a single definition.
|
* Parses a single definition.
|
||||||
* @param id The item's id.
|
*
|
||||||
* @param buffer The buffer.
|
* @param id
|
||||||
|
* The item's id.
|
||||||
|
* @param buffer
|
||||||
|
* The buffer.
|
||||||
* @return The definition.
|
* @return The definition.
|
||||||
*/
|
*/
|
||||||
private ItemDefinition parseDefinition(int id, ByteBuffer buffer) {
|
private ItemDefinition parseDefinition(int id, ByteBuffer buffer) {
|
||||||
ItemDefinition def = new ItemDefinition(id);
|
ItemDefinition def = new ItemDefinition(id);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int code = buffer.get() & 0xFF;
|
int code = buffer.get() & 0xFF;
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
return def;
|
return def;
|
||||||
} else if (code == 1) {
|
} else if (code == 1) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort();// & 0xFFFF; // model Id
|
||||||
int modelId = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 2) {
|
} else if (code == 2) {
|
||||||
def.setName(ByteBufferUtil.readString(buffer));
|
def.setName(ByteBufferUtil.readString(buffer));
|
||||||
} else if (code == 3) {
|
} else if (code == 3) {
|
||||||
def.setDescription(ByteBufferUtil.readString(buffer));
|
def.setDescription(ByteBufferUtil.readString(buffer));
|
||||||
} else if (code == 4) {
|
} else if (code == 4) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort();// & 0xFFFF; // sprite scale
|
||||||
int modelScale = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 5) {
|
} else if (code == 5) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort();// & 0xFFFF; // sprite pitch
|
||||||
int modelRotationX = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 6) {
|
} else if (code == 6) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort();// & 0xFFFF; //sprite camera roll
|
||||||
int modelRotationY = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 7) {
|
} else if (code == 7) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // sprite dX
|
||||||
int modelTransformationX = buffer.getShort();
|
|
||||||
} else if (code == 8) {
|
} else if (code == 8) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // sprite dY
|
||||||
int modelTransformationY = buffer.getShort();
|
|
||||||
} else if (code == 10) {
|
} else if (code == 10) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort();// & 0xFFFF;
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 11) {
|
} else if (code == 11) {
|
||||||
def.setStackable(true);
|
def.setStackable(true);
|
||||||
} else if (code == 12) {
|
} else if (code == 12) {
|
||||||
def.setValue(buffer.getInt());
|
buffer.getInt(); // model height
|
||||||
} else if (code == 16) {
|
} else if (code == 16) {
|
||||||
def.setMembersOnly(true);
|
def.setMembersOnly(true);
|
||||||
} else if (code == 23) {
|
} else if (code == 23) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; //primaryMaleEquipModelId
|
||||||
int unknownShort = buffer.getShort() & 0xFFFF;
|
buffer.get(); // maleEquipYTranslation
|
||||||
@SuppressWarnings("unused")
|
|
||||||
int unknownByte = buffer.get();
|
|
||||||
} else if (code == 24) {
|
} else if (code == 24) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // secondaryMaleEquipModelId
|
||||||
int unknownShort = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 25) {
|
} else if (code == 25) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // primaryFemaleEquipModelId
|
||||||
int unknownShort = buffer.getShort() & 0xFFFF;
|
buffer.get(); // femaleEquipYTranslation
|
||||||
@SuppressWarnings("unused")
|
|
||||||
int unknownByte = buffer.get();
|
|
||||||
} else if (code == 26) {
|
} else if (code == 26) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // secondaryFemaleEquipModelId
|
||||||
int unknownShort = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code >= 30 && code < 35) {
|
} else if (code >= 30 && code < 35) {
|
||||||
String str = ByteBufferUtil.readString(buffer);
|
String str = ByteBufferUtil.readString(buffer);
|
||||||
if (str.equalsIgnoreCase("hidden")) {
|
if (str.equalsIgnoreCase("hidden")) {
|
||||||
@@ -125,34 +119,25 @@ public final class ItemDefinitionParser {
|
|||||||
String str = ByteBufferUtil.readString(buffer);
|
String str = ByteBufferUtil.readString(buffer);
|
||||||
def.setInventoryAction(code - 35, str);
|
def.setInventoryAction(code - 35, str);
|
||||||
} else if (code == 40) {
|
} else if (code == 40) {
|
||||||
int colorCount = buffer.get() & 0xFF;
|
int colourCount = buffer.get() & 0xFF;
|
||||||
for (int i = 0; i < colorCount; i++) {
|
for (int i = 0; i < colourCount; i++) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // original colour
|
||||||
int oldColor = buffer.getShort() & 0xFFFF;
|
buffer.getShort(); // & 0xFFFF; // replacement colour
|
||||||
@SuppressWarnings("unused")
|
|
||||||
int newColor = buffer.getShort() & 0xFFFF;
|
|
||||||
}
|
}
|
||||||
} else if (code == 78) {
|
} else if (code == 78) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // tertiaryMaleEquipModelId
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 79) {
|
} else if (code == 79) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // tertiaryFemaleEquipModelId
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 90) {
|
} else if (code == 90) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // primaryMaleHeadPiece
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 91) {
|
} else if (code == 91) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // primaryFemaleHeadPiece
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 92) {
|
} else if (code == 92) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // secondaryMaleHeadPiece
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 93) {
|
} else if (code == 93) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // secondaryFemaleHeadPiece
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 95) {
|
} else if (code == 95) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // spriteCameraYaw
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 97) {
|
} else if (code == 97) {
|
||||||
int noteInfoId = buffer.getShort() & 0xFFFF;
|
int noteInfoId = buffer.getShort() & 0xFFFF;
|
||||||
def.setNoteInfoId(noteInfoId);
|
def.setNoteInfoId(noteInfoId);
|
||||||
@@ -160,25 +145,20 @@ public final class ItemDefinitionParser {
|
|||||||
int noteGraphicId = buffer.getShort() & 0xFFFF;
|
int noteGraphicId = buffer.getShort() & 0xFFFF;
|
||||||
def.setNoteGraphicId(noteGraphicId);
|
def.setNoteGraphicId(noteGraphicId);
|
||||||
} else if (code >= 100 && code < 110) {
|
} else if (code >= 100 && code < 110) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // stack id
|
||||||
int stackId = buffer.getShort() & 0xFFFF;
|
buffer.getShort(); // & 0xFFFF; // stack size
|
||||||
@SuppressWarnings("unused")
|
|
||||||
int stackAmount = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 110) {
|
} else if (code == 110) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // groundScaleX
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 111) {
|
} else if (code == 111) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // groundScaleY
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
|
||||||
} else if (code == 112) {
|
} else if (code == 112) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // & 0xFFFF; // groundScaleZ
|
||||||
int unknown = buffer.getShort() & 0xFFFF;
|
} else if (code == 113) {
|
||||||
|
buffer.get(); // light ambiance
|
||||||
} else if (code == 114) {
|
} else if (code == 114) {
|
||||||
@SuppressWarnings("unused")
|
buffer.getShort(); // * 5; // light diffusion
|
||||||
int unknown = buffer.getShort() * 5;
|
|
||||||
} else if (code == 115) {
|
} else if (code == 115) {
|
||||||
@SuppressWarnings("unused")
|
buffer.get(); // & 0xFF; // team
|
||||||
int team = buffer.get() & 0xFF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public final class EventHandlerChain<E extends Event> {
|
|||||||
* Creates the event handler chain.
|
* Creates the event handler chain.
|
||||||
* @param handlers The handlers.
|
* @param handlers The handlers.
|
||||||
*/
|
*/
|
||||||
|
@SafeVarargs
|
||||||
public EventHandlerChain(EventHandler<E>... handlers) {
|
public EventHandlerChain(EventHandler<E>... handlers) {
|
||||||
this.handlers = handlers;
|
this.handlers = handlers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,13 +78,9 @@ public final class EquipEventHandler extends EventHandler<EquipEvent> {
|
|||||||
|
|
||||||
// check if there is enough space for a two handed weapon
|
// check if there is enough space for a two handed weapon
|
||||||
if (equipDef.isTwoHanded()) {
|
if (equipDef.isTwoHanded()) {
|
||||||
Item currentShield = equipment.get(EquipmentConstants.SHIELD);
|
if(equipment.get(EquipmentConstants.SHIELD) != null){
|
||||||
if (currentShield != null) {
|
Item shield = equipment.reset(EquipmentConstants.SHIELD);
|
||||||
if (inventory.freeSlots() < 1) {
|
inventory.add(shield);
|
||||||
inventory.forceCapacityExceeded();
|
|
||||||
ctx.breakHandlerChain();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,29 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An event handler which removes equipped items.
|
* An event handler which removes equipped items.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
|
public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
public void handle(EventHandlerContext ctx, Player player,
|
||||||
if (event.getOption() == 1 && event.getInterfaceId() == SynchronizationInventoryListener.EQUIPMENT_ID) {
|
ItemActionEvent event) {
|
||||||
|
|
||||||
|
if (event.getOption() == 1
|
||||||
|
&& event.getInterfaceId() == SynchronizationInventoryListener.EQUIPMENT_ID) {
|
||||||
Inventory inventory = player.getInventory();
|
Inventory inventory = player.getInventory();
|
||||||
Inventory equipment = player.getEquipment();
|
Inventory equipment = player.getEquipment();
|
||||||
|
|
||||||
|
if (inventory.freeSlots() < 1) { // TODO what if the item is
|
||||||
|
// stackable and the player has
|
||||||
|
// the item in his inventory
|
||||||
|
// already.
|
||||||
|
inventory.forceCapacityExceeded();
|
||||||
|
ctx.breakHandlerChain();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int slot = event.getSlot();
|
int slot = event.getSlot();
|
||||||
if (slot < 0 || slot >= equipment.capacity()) {
|
if (slot < 0 || slot >= equipment.capacity()) {
|
||||||
ctx.breakHandlerChain();
|
ctx.breakHandlerChain();
|
||||||
@@ -39,10 +52,11 @@ public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
equipment.set(slot, null);
|
equipment.set(slot, null);
|
||||||
Item tmp = inventory.add(item);
|
Item copy = item;
|
||||||
if (tmp != null) {
|
inventory.add(item.getId(), item.getAmount());
|
||||||
|
if (copy != null) {
|
||||||
removed = false;
|
removed = false;
|
||||||
equipment.set(slot, tmp);
|
equipment.set(slot, copy);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
inventory.startFiringEvents();
|
inventory.startFiringEvents();
|
||||||
@@ -50,8 +64,9 @@ public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
inventory.forceRefresh(); // TODO find out the specific slot that got used?
|
inventory.forceRefresh(); // TODO find out the specific slot
|
||||||
equipment.forceRefresh(slot);
|
// that got used?
|
||||||
|
equipment.forceRefresh();
|
||||||
} else {
|
} else {
|
||||||
inventory.forceCapacityExceeded();
|
inventory.forceCapacityExceeded();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.apollo.game.model.skill.SkillListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the set of the player's skills.
|
* Represents the set of the player's skills.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class SkillSet {
|
public final class SkillSet {
|
||||||
@@ -45,6 +46,7 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of skills.
|
* Gets the number of skills.
|
||||||
|
*
|
||||||
* @return The number of skills.
|
* @return The number of skills.
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
@@ -67,9 +69,12 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a skill by its id.
|
* Gets a skill by its id.
|
||||||
* @param id The id.
|
*
|
||||||
|
* @param id
|
||||||
|
* The id.
|
||||||
* @return The skill.
|
* @return The skill.
|
||||||
* @throws IndexOutOfBoundsException if the id is out of bounds.
|
* @throws IndexOutOfBoundsException
|
||||||
|
* if the id is out of bounds.
|
||||||
*/
|
*/
|
||||||
public Skill getSkill(int id) {
|
public Skill getSkill(int id) {
|
||||||
checkBounds(id);
|
checkBounds(id);
|
||||||
@@ -78,8 +83,11 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds experience to the specified skill.
|
* Adds experience to the specified skill.
|
||||||
* @param id The skill id.
|
*
|
||||||
* @param experience The amount of experience.
|
* @param id
|
||||||
|
* The skill id.
|
||||||
|
* @param experience
|
||||||
|
* The amount of experience.
|
||||||
*/
|
*/
|
||||||
public void addExperience(int id, double experience) {
|
public void addExperience(int id, double experience) {
|
||||||
checkBounds(id);
|
checkBounds(id);
|
||||||
@@ -110,6 +118,7 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total level for this skill set.
|
* Gets the total level for this skill set.
|
||||||
|
*
|
||||||
* @return The total level.
|
* @return The total level.
|
||||||
*/
|
*/
|
||||||
public int getTotalLevel() {
|
public int getTotalLevel() {
|
||||||
@@ -122,6 +131,12 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the combat level for this skill set.
|
* Gets the combat level for this skill set.
|
||||||
|
*
|
||||||
|
* @return The combat level.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Gets the combat level for this skill set.
|
||||||
|
*
|
||||||
* @return The combat level.
|
* @return The combat level.
|
||||||
*/
|
*/
|
||||||
public int getCombatLevel() {
|
public int getCombatLevel() {
|
||||||
@@ -133,26 +148,22 @@ public final class SkillSet {
|
|||||||
int ranged = skills[Skill.RANGED].getMaximumLevel();
|
int ranged = skills[Skill.RANGED].getMaximumLevel();
|
||||||
int magic = skills[Skill.MAGIC].getMaximumLevel();
|
int magic = skills[Skill.MAGIC].getMaximumLevel();
|
||||||
|
|
||||||
int combat = (int) (((defence + hitpoints + prayer / 2) * 0.235) + 1);
|
double combatLevel = (defence + hitpoints + Math.floor(prayer / 2)) * 0.25;
|
||||||
|
|
||||||
double melee = (attack + strength) * 0.325;
|
double melee = (attack + strength) * 0.325;
|
||||||
double ranger = Math.floor(ranged * 1.5) * 0.325;
|
|
||||||
double mage = Math.floor(magic * 1.5) * 0.325;
|
|
||||||
|
|
||||||
if (melee >= ranger && melee >= mage) {
|
double range = ranged * 0.4875;
|
||||||
combat += melee;
|
|
||||||
} else if (ranger >= melee && ranger >= mage) {
|
|
||||||
combat += ranger;
|
|
||||||
} else if (mage >= melee && mage >= ranger) {
|
|
||||||
combat += mage;
|
|
||||||
}
|
|
||||||
|
|
||||||
return combat < 126 ? combat : 126;
|
double mage = magic * 0.4875;
|
||||||
|
|
||||||
|
return (int) (combatLevel + Math.max(melee, Math.max(range, mage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the minimum experience required for the specified level.
|
* Gets the minimum experience required for the specified level.
|
||||||
* @param level The level.
|
*
|
||||||
|
* @param level
|
||||||
|
* The level.
|
||||||
* @return The minimum experience.
|
* @return The minimum experience.
|
||||||
*/
|
*/
|
||||||
public static double getExperienceForLevel(int level) {
|
public static double getExperienceForLevel(int level) {
|
||||||
@@ -170,7 +181,9 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the minimum level to get the specified experience.
|
* Gets the minimum level to get the specified experience.
|
||||||
* @param experience The experience.
|
*
|
||||||
|
* @param experience
|
||||||
|
* The experience.
|
||||||
* @return The minimum level.
|
* @return The minimum level.
|
||||||
*/
|
*/
|
||||||
public static int getLevelForExperience(double experience) {
|
public static int getLevelForExperience(double experience) {
|
||||||
@@ -209,9 +222,13 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a skill.
|
* Sets a skill.
|
||||||
* @param id The id.
|
*
|
||||||
* @param skill The skill.
|
* @param id
|
||||||
* @throws IndexOutOfBoundsException if the id is out of bounds.
|
* The id.
|
||||||
|
* @param skill
|
||||||
|
* The skill.
|
||||||
|
* @throws IndexOutOfBoundsException
|
||||||
|
* if the id is out of bounds.
|
||||||
*/
|
*/
|
||||||
public void setSkill(int id, Skill skill) {
|
public void setSkill(int id, Skill skill) {
|
||||||
checkBounds(id);
|
checkBounds(id);
|
||||||
@@ -221,8 +238,11 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the bounds of the id.
|
* Checks the bounds of the id.
|
||||||
* @param id The id.
|
*
|
||||||
* @throws IndexOutOfBoundsException if the id is out of bounds.
|
* @param id
|
||||||
|
* The id.
|
||||||
|
* @throws IndexOutOfBoundsException
|
||||||
|
* if the id is out of bounds.
|
||||||
*/
|
*/
|
||||||
private void checkBounds(int id) {
|
private void checkBounds(int id) {
|
||||||
if (id < 0 || id >= skills.length) {
|
if (id < 0 || id >= skills.length) {
|
||||||
@@ -232,8 +252,11 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies listeners that a skill has been levelled up.
|
* Notifies listeners that a skill has been levelled up.
|
||||||
* @param id The skill's id.
|
*
|
||||||
* @throws IndexOutOfBoundsException if the id is out of bounds.
|
* @param id
|
||||||
|
* The skill's id.
|
||||||
|
* @throws IndexOutOfBoundsException
|
||||||
|
* if the id is out of bounds.
|
||||||
*/
|
*/
|
||||||
private void notifyLevelledUp(int id) {
|
private void notifyLevelledUp(int id) {
|
||||||
checkBounds(id);
|
checkBounds(id);
|
||||||
@@ -246,8 +269,11 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies listeners that a skill has been updated.
|
* Notifies listeners that a skill has been updated.
|
||||||
* @param id The skill's id.
|
*
|
||||||
* @throws IndexOutOfBoundsException if the id is out of bounds.
|
* @param id
|
||||||
|
* The skill's id.
|
||||||
|
* @throws IndexOutOfBoundsException
|
||||||
|
* if the id is out of bounds.
|
||||||
*/
|
*/
|
||||||
private void notifySkillUpdated(int id) {
|
private void notifySkillUpdated(int id) {
|
||||||
checkBounds(id);
|
checkBounds(id);
|
||||||
@@ -292,7 +318,9 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a listener.
|
* Adds a listener.
|
||||||
* @param listener The listener to add.
|
*
|
||||||
|
* @param listener
|
||||||
|
* The listener to add.
|
||||||
*/
|
*/
|
||||||
public void addListener(SkillListener listener) {
|
public void addListener(SkillListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
@@ -300,7 +328,9 @@ public final class SkillSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a listener.
|
* Removes a listener.
|
||||||
* @param listener The listener to remove.
|
*
|
||||||
|
* @param listener
|
||||||
|
* The listener to remove.
|
||||||
*/
|
*/
|
||||||
public void removeListener(SkillListener listener) {
|
public void removeListener(SkillListener listener) {
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.Queue;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A queue of {@link Direction}s which a {@link Character} will follow.
|
* A queue of {@link Direction}s which a {@link Character} will follow.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class WalkingQueue {
|
public final class WalkingQueue {
|
||||||
@@ -18,6 +19,7 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single point in the queue.
|
* Represents a single point in the queue.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
private static final class Point {
|
private static final class Point {
|
||||||
@@ -34,8 +36,11 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a point.
|
* Creates a point.
|
||||||
* @param position The position.
|
*
|
||||||
* @param direction The direction.
|
* @param position
|
||||||
|
* The position.
|
||||||
|
* @param direction
|
||||||
|
* The direction.
|
||||||
*/
|
*/
|
||||||
public Point(Position position, Direction direction) {
|
public Point(Position position, Direction direction) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
@@ -44,7 +49,8 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Point.class.getName() + " [direction=" + direction + ", position=" + position + "]";
|
return Point.class.getName() + " [direction=" + direction
|
||||||
|
+ ", position=" + position + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -71,7 +77,9 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a walking queue for the specified character.
|
* Creates a walking queue for the specified character.
|
||||||
* @param character The character.
|
*
|
||||||
|
* @param character
|
||||||
|
* The character.
|
||||||
*/
|
*/
|
||||||
public WalkingQueue(Character character) {
|
public WalkingQueue(Character character) {
|
||||||
this.character = character;
|
this.character = character;
|
||||||
@@ -106,7 +114,9 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the running queue flag.
|
* Sets the running queue flag.
|
||||||
* @param running The running queue flag.
|
*
|
||||||
|
* @param running
|
||||||
|
* The running queue flag.
|
||||||
*/
|
*/
|
||||||
public void setRunningQueue(boolean running) {
|
public void setRunningQueue(boolean running) {
|
||||||
this.runningQueue = running;
|
this.runningQueue = running;
|
||||||
@@ -115,7 +125,9 @@ public final class WalkingQueue {
|
|||||||
/**
|
/**
|
||||||
* Adds the first step to the queue, attempting to connect the server and
|
* Adds the first step to the queue, attempting to connect the server and
|
||||||
* client position by looking at the previous queue.
|
* client position by looking at the previous queue.
|
||||||
* @param clientConnectionPosition The first step.
|
*
|
||||||
|
* @param clientConnectionPosition
|
||||||
|
* The first step.
|
||||||
* @return {@code true} if the queues could be connected correctly,
|
* @return {@code true} if the queues could be connected correctly,
|
||||||
* {@code false} if not.
|
* {@code false} if not.
|
||||||
*/
|
*/
|
||||||
@@ -163,7 +175,9 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a step to the queue.
|
* Adds a step to the queue.
|
||||||
* @param step The step to add.
|
*
|
||||||
|
* @param step
|
||||||
|
* The step to add.
|
||||||
*/
|
*/
|
||||||
public void addStep(Position step) {
|
public void addStep(Position step) {
|
||||||
Point last = getLast();
|
Point last = getLast();
|
||||||
@@ -195,8 +209,11 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a step.
|
* Adds a step.
|
||||||
* @param x The x coordinate of this step.
|
*
|
||||||
* @param y The y coordinate of this step.
|
* @param x
|
||||||
|
* The x coordinate of this step.
|
||||||
|
* @param y
|
||||||
|
* The y coordinate of this step.
|
||||||
*/
|
*/
|
||||||
private void addStep(int x, int y) {
|
private void addStep(int x, int y) {
|
||||||
if (points.size() >= MAXIMUM_SIZE) {
|
if (points.size() >= MAXIMUM_SIZE) {
|
||||||
@@ -211,7 +228,8 @@ public final class WalkingQueue {
|
|||||||
Direction direction = Direction.fromDeltas(deltaX, deltaY);
|
Direction direction = Direction.fromDeltas(deltaX, deltaY);
|
||||||
|
|
||||||
if (direction != Direction.NONE) {
|
if (direction != Direction.NONE) {
|
||||||
Point p = new Point(new Position(x, y), direction);
|
Point p = new Point(new Position(x, y, character.getPosition()
|
||||||
|
.getHeight()), direction);
|
||||||
points.add(p);
|
points.add(p);
|
||||||
oldPoints.add(p);
|
oldPoints.add(p);
|
||||||
}
|
}
|
||||||
@@ -219,6 +237,7 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the last point.
|
* Gets the last point.
|
||||||
|
*
|
||||||
* @return The last point.
|
* @return The last point.
|
||||||
*/
|
*/
|
||||||
private Point getLast() {
|
private Point getLast() {
|
||||||
@@ -239,6 +258,7 @@ public final class WalkingQueue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the size of the queue.
|
* Gets the size of the queue.
|
||||||
|
*
|
||||||
* @return The size of the queue.
|
* @return The size of the queue.
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.apollo.game.model.def.StaticObjectDefinition;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a static object in the game world.
|
* Represents a static object in the game world.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class StaticObject {
|
public final class StaticObject {
|
||||||
@@ -11,14 +12,25 @@ public final class StaticObject {
|
|||||||
/**
|
/**
|
||||||
* The object definition.
|
* The object definition.
|
||||||
*/
|
*/
|
||||||
private final StaticObjectDefinition def;
|
private final StaticObjectDefinition definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the game object.
|
* Creates the game object.
|
||||||
* @param def The object's definition.
|
*
|
||||||
|
* @param definition
|
||||||
|
* The object's definition.
|
||||||
*/
|
*/
|
||||||
public StaticObject(StaticObjectDefinition def) {
|
public StaticObject(StaticObjectDefinition definition) {
|
||||||
this.def = def;
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the object's definition.
|
||||||
|
*
|
||||||
|
* @return The definition.
|
||||||
|
*/
|
||||||
|
public StaticObjectDefinition getDefinition() {
|
||||||
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,17 +20,17 @@ import org.apollo.game.sync.seg.TeleportSegment;
|
|||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.CharacterRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationTask} which synchronizes the specified
|
* A {@link SynchronizationTask} which synchronizes the specified {@link Player}
|
||||||
* {@link Player}.
|
* .
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class PlayerSynchronizationTask extends SynchronizationTask {
|
public final class PlayerSynchronizationTask extends SynchronizationTask {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of players to load per cycle. This prevents the
|
* The maximum number of players to load per cycle. This prevents the update
|
||||||
* update packet from becoming too large (the client uses a 5000 byte
|
* packet from becoming too large (the client uses a 5000 byte buffer) and
|
||||||
* buffer) and also stops old spec PCs from crashing when they login or
|
* also stops old spec PCs from crashing when they login or teleport.
|
||||||
* teleport.
|
|
||||||
*/
|
*/
|
||||||
private static final int NEW_PLAYERS_PER_CYCLE = 20;
|
private static final int NEW_PLAYERS_PER_CYCLE = 20;
|
||||||
|
|
||||||
@@ -41,7 +41,9 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the {@link PlayerSynchronizationTask} for the specified player.
|
* Creates the {@link PlayerSynchronizationTask} for the specified player.
|
||||||
* @param player The player.
|
*
|
||||||
|
* @param player
|
||||||
|
* The player.
|
||||||
*/
|
*/
|
||||||
public PlayerSynchronizationTask(Player player) {
|
public PlayerSynchronizationTask(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@@ -59,7 +61,7 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
blockSet.remove(ChatBlock.class);
|
blockSet.remove(ChatBlock.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isTeleporting()) {
|
if (player.isTeleporting() || player.hasRegionChanged()) {
|
||||||
segment = new TeleportSegment(blockSet, player.getPosition());
|
segment = new TeleportSegment(blockSet, player.getPosition());
|
||||||
} else {
|
} else {
|
||||||
segment = new MovementSegment(blockSet, player.getDirections());
|
segment = new MovementSegment(blockSet, player.getDirections());
|
||||||
@@ -71,17 +73,22 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
|
|
||||||
for (Iterator<Player> it = localPlayers.iterator(); it.hasNext();) {
|
for (Iterator<Player> it = localPlayers.iterator(); it.hasNext();) {
|
||||||
Player p = it.next();
|
Player p = it.next();
|
||||||
if (!p.isActive() || p.isTeleporting() || p.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|
if (!p.isActive()
|
||||||
|
|| p.isTeleporting()
|
||||||
|
|| p.getPosition().getLongestDelta(player.getPosition()) > player
|
||||||
|
.getViewingDistance()) {
|
||||||
it.remove();
|
it.remove();
|
||||||
segments.add(new RemoveCharacterSegment());
|
segments.add(new RemoveCharacterSegment());
|
||||||
} else {
|
} else {
|
||||||
segments.add(new MovementSegment(p.getBlockSet(), p.getDirections()));
|
segments.add(new MovementSegment(p.getBlockSet(), p
|
||||||
|
.getDirections()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int added = 0;
|
int added = 0;
|
||||||
|
|
||||||
CharacterRepository<Player> repository = World.getWorld().getPlayerRepository();
|
CharacterRepository<Player> repository = World.getWorld()
|
||||||
|
.getPlayerRepository();
|
||||||
for (Iterator<Player> it = repository.iterator(); it.hasNext();) {
|
for (Iterator<Player> it = repository.iterator(); it.hasNext();) {
|
||||||
Player p = it.next();
|
Player p = it.next();
|
||||||
if (localPlayers.size() >= 255) {
|
if (localPlayers.size() >= 255) {
|
||||||
@@ -90,8 +97,12 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
} else if (added >= NEW_PLAYERS_PER_CYCLE) {
|
} else if (added >= NEW_PLAYERS_PER_CYCLE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// we do not check p.isActive() here, since if they are active they must be in the repository
|
// we do not check p.isActive() here, since if they are active they
|
||||||
if (p != player && p.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance()) && !localPlayers.contains(p)) {
|
// must be in the repository
|
||||||
|
if (p != player
|
||||||
|
&& p.getPosition().isWithinDistance(player.getPosition(),
|
||||||
|
player.getViewingDistance())
|
||||||
|
&& !localPlayers.contains(p)) {
|
||||||
localPlayers.add(p);
|
localPlayers.add(p);
|
||||||
added++;
|
added++;
|
||||||
|
|
||||||
@@ -102,11 +113,14 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
blockSet.add(SynchronizationBlock.createAppearanceBlock(p));
|
blockSet.add(SynchronizationBlock.createAppearanceBlock(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
segments.add(new AddCharacterSegment(blockSet, p.getIndex(), p.getPosition()));
|
segments.add(new AddCharacterSegment(blockSet, p.getIndex(), p
|
||||||
|
.getPosition()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerSynchronizationEvent event = new PlayerSynchronizationEvent(lastKnownRegion, player.getPosition(), regionChanged, segment, oldLocalPlayers, segments);
|
PlayerSynchronizationEvent event = new PlayerSynchronizationEvent(
|
||||||
|
lastKnownRegion, player.getPosition(), regionChanged, segment,
|
||||||
|
oldLocalPlayers, segments);
|
||||||
player.send(event);
|
player.send(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasLastKnownRegion() || isRegionUpdateRequired()) {
|
if (!player.hasLastKnownRegion() || isRegionUpdateRequired()) {
|
||||||
player.setTeleporting(true);
|
|
||||||
player.setRegionChanged(true);
|
player.setRegionChanged(true);
|
||||||
|
|
||||||
Position position = player.getPosition();
|
Position position = player.getPosition();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.xml.sax.SAXException;
|
|||||||
/**
|
/**
|
||||||
* A class which parses the {@code events.xml} file to produce
|
* A class which parses the {@code events.xml} file to produce
|
||||||
* {@link EventHandlerChainGroup}s.
|
* {@link EventHandlerChainGroup}s.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class EventHandlerChainParser {
|
public final class EventHandlerChainParser {
|
||||||
@@ -34,8 +35,11 @@ public final class EventHandlerChainParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the event chain parser.
|
* Creates the event chain parser.
|
||||||
* @param is The source {@link InputStream}.
|
*
|
||||||
* @throws SAXException if a SAX error occurs.
|
* @param is
|
||||||
|
* The source {@link InputStream}.
|
||||||
|
* @throws SAXException
|
||||||
|
* if a SAX error occurs.
|
||||||
*/
|
*/
|
||||||
public EventHandlerChainParser(InputStream is) throws SAXException {
|
public EventHandlerChainParser(InputStream is) throws SAXException {
|
||||||
this.parser = new XmlParser();
|
this.parser = new XmlParser();
|
||||||
@@ -44,15 +48,23 @@ public final class EventHandlerChainParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the XML and produces a group of {@link EventHandlerChain}s.
|
* Parses the XML and produces a group of {@link EventHandlerChain}s.
|
||||||
* @throws IOException if an I/O error occurs.
|
*
|
||||||
* @throws SAXException if a SAX error occurs.
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException if a class was not found.
|
* if an I/O error occurs.
|
||||||
* @throws IllegalAccessException if a class was accessed illegally.
|
* @throws SAXException
|
||||||
* @throws InstantiationException if a class could not be instantiated.
|
* if a SAX error occurs.
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* if a class was not found.
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* if a class was accessed illegally.
|
||||||
|
* @throws InstantiationException
|
||||||
|
* if a class could not be instantiated.
|
||||||
* @return An {@link EventHandlerChainGroup}.
|
* @return An {@link EventHandlerChainGroup}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public EventHandlerChainGroup parse() throws IOException, SAXException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
public EventHandlerChainGroup parse() throws IOException, SAXException,
|
||||||
|
ClassNotFoundException, InstantiationException,
|
||||||
|
IllegalAccessException {
|
||||||
XmlNode rootNode = parser.parse(is);
|
XmlNode rootNode = parser.parse(is);
|
||||||
if (!rootNode.getName().equals("events")) {
|
if (!rootNode.getName().equals("events")) {
|
||||||
throw new IOException("root node name is not 'events'");
|
throw new IOException("root node name is not 'events'");
|
||||||
@@ -62,16 +74,19 @@ public final class EventHandlerChainParser {
|
|||||||
|
|
||||||
for (XmlNode eventNode : rootNode) {
|
for (XmlNode eventNode : rootNode) {
|
||||||
if (!eventNode.getName().equals("event")) {
|
if (!eventNode.getName().equals("event")) {
|
||||||
throw new IOException("only expected nodes named 'event' beneath the root node");
|
throw new IOException(
|
||||||
|
"only expected nodes named 'event' beneath the root node");
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode typeNode = eventNode.getChild("type");
|
XmlNode typeNode = eventNode.getChild("type");
|
||||||
if (typeNode == null) {
|
if (typeNode == null) {
|
||||||
throw new IOException("no node named 'type' beneath current event node");
|
throw new IOException(
|
||||||
|
"no node named 'type' beneath current event node");
|
||||||
}
|
}
|
||||||
XmlNode chainNode = eventNode.getChild("chain");
|
XmlNode chainNode = eventNode.getChild("chain");
|
||||||
if (chainNode == null) {
|
if (chainNode == null) {
|
||||||
throw new IOException("no node named 'chain' beneath current event node");
|
throw new IOException(
|
||||||
|
"no node named 'chain' beneath current event node");
|
||||||
}
|
}
|
||||||
|
|
||||||
String eventClassName = typeNode.getValue();
|
String eventClassName = typeNode.getValue();
|
||||||
@@ -79,12 +94,14 @@ public final class EventHandlerChainParser {
|
|||||||
throw new IOException("type node must have a value");
|
throw new IOException("type node must have a value");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<? extends Event> eventClass = (Class<? extends Event>) Class.forName(eventClassName);
|
Class<? extends Event> eventClass = (Class<? extends Event>) Class
|
||||||
|
.forName(eventClassName);
|
||||||
List<EventHandler<?>> handlers = new ArrayList<EventHandler<?>>();
|
List<EventHandler<?>> handlers = new ArrayList<EventHandler<?>>();
|
||||||
|
|
||||||
for (XmlNode handlerNode : chainNode) {
|
for (XmlNode handlerNode : chainNode) {
|
||||||
if (!handlerNode.getName().equals("handler")) {
|
if (!handlerNode.getName().equals("handler")) {
|
||||||
throw new IOException("only expected nodes named 'handler' beneath the root node");
|
throw new IOException(
|
||||||
|
"only expected nodes named 'handler' beneath the root node");
|
||||||
}
|
}
|
||||||
|
|
||||||
String handlerClassName = handlerNode.getValue();
|
String handlerClassName = handlerNode.getValue();
|
||||||
@@ -92,12 +109,15 @@ public final class EventHandlerChainParser {
|
|||||||
throw new IOException("handler node must have a value");
|
throw new IOException("handler node must have a value");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<? extends EventHandler<?>> handlerClass = (Class<? extends EventHandler<?>>) Class.forName(handlerClassName);
|
Class<? extends EventHandler<?>> handlerClass = (Class<? extends EventHandler<?>>) Class
|
||||||
|
.forName(handlerClassName);
|
||||||
EventHandler<?> handler = handlerClass.newInstance();
|
EventHandler<?> handler = handlerClass.newInstance();
|
||||||
handlers.add(handler);
|
handlers.add(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler<?>[] handlersArray = handlers.toArray(new EventHandler<?>[handlers.size()]);
|
EventHandler<?>[] handlersArray = handlers
|
||||||
|
.toArray(new EventHandler<?>[handlers.size()]);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
EventHandlerChain<?> chain = new EventHandlerChain(handlersArray);
|
EventHandlerChain<?> chain = new EventHandlerChain(handlersArray);
|
||||||
|
|
||||||
chains.put(eventClass, chain);
|
chains.put(eventClass, chain);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.apollo.util.TextUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link ChatEvent}.
|
* An {@link EventDecoder} for the {@link ChatEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class ChatEventDecoder extends EventDecoder<ChatEvent> {
|
public final class ChatEventDecoder extends EventDecoder<ChatEvent> {
|
||||||
@@ -18,8 +19,10 @@ public final class ChatEventDecoder extends EventDecoder<ChatEvent> {
|
|||||||
public ChatEvent decode(GamePacket packet) {
|
public ChatEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
|
|
||||||
int effects = (int) reader.getUnsigned(DataType.BYTE, DataTransformation.ADD);
|
int effects = (int) reader.getUnsigned(DataType.BYTE,
|
||||||
int color = (int) reader.getUnsigned(DataType.BYTE, DataTransformation.ADD);
|
DataTransformation.SUBTRACT);
|
||||||
|
int color = (int) reader.getUnsigned(DataType.BYTE,
|
||||||
|
DataTransformation.SUBTRACT);
|
||||||
int length = packet.getLength() - 2;
|
int length = packet.getLength() - 2;
|
||||||
|
|
||||||
byte[] originalCompressed = new byte[length];
|
byte[] originalCompressed = new byte[length];
|
||||||
@@ -30,7 +33,8 @@ public final class ChatEventDecoder extends EventDecoder<ChatEvent> {
|
|||||||
uncompressed = TextUtil.capitalize(uncompressed);
|
uncompressed = TextUtil.capitalize(uncompressed);
|
||||||
|
|
||||||
byte[] recompressed = new byte[length];
|
byte[] recompressed = new byte[length];
|
||||||
TextUtil.compress(uncompressed, recompressed); // in case invalid data gets sent, this effectively verifies it
|
TextUtil.compress(uncompressed, recompressed);
|
||||||
|
// in case invalid data gets sent, this effectively verifies it
|
||||||
|
|
||||||
return new ChatEvent(uncompressed, recompressed, color, effects);
|
return new ChatEvent(uncompressed, recompressed, color, effects);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.apollo.net.release.r317;
|
package org.apollo.net.release.r317;
|
||||||
|
|
||||||
import org.apollo.game.event.impl.FifthItemActionEvent;
|
import org.apollo.game.event.impl.FifthItemActionEvent;
|
||||||
import org.apollo.game.event.impl.FourthItemActionEvent;
|
|
||||||
import org.apollo.net.codec.game.DataOrder;
|
import org.apollo.net.codec.game.DataOrder;
|
||||||
import org.apollo.net.codec.game.DataTransformation;
|
import org.apollo.net.codec.game.DataTransformation;
|
||||||
import org.apollo.net.codec.game.DataType;
|
import org.apollo.net.codec.game.DataType;
|
||||||
@@ -10,16 +9,19 @@ import org.apollo.net.codec.game.GamePacketReader;
|
|||||||
import org.apollo.net.release.EventDecoder;
|
import org.apollo.net.release.EventDecoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link FourthItemActionEvent}.
|
* An {@link EventDecoder} for the {@link FifthItemActionEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class FifthItemActionEventDecoder extends EventDecoder<FifthItemActionEvent> {
|
public final class FifthItemActionEventDecoder extends
|
||||||
|
EventDecoder<FifthItemActionEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FifthItemActionEvent decode(GamePacket packet) {
|
public FifthItemActionEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
int slot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int slot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||||
int interfaceId = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
int interfaceId = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
|
DataTransformation.ADD);
|
||||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||||
return new FifthItemActionEvent(interfaceId, id, slot);
|
return new FifthItemActionEvent(interfaceId, id, slot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,19 @@ import org.apollo.net.release.EventDecoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link FirstObjectActionEvent}.
|
* An {@link EventDecoder} for the {@link FirstObjectActionEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class FirstObjectActionEventDecoder extends EventDecoder<FirstObjectActionEvent> {
|
public final class FirstObjectActionEventDecoder extends
|
||||||
|
EventDecoder<FirstObjectActionEvent> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public FirstObjectActionEvent decode(GamePacket packet) {
|
public FirstObjectActionEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE,
|
||||||
int y = (int) reader.getUnsigned(DataType.SHORT);
|
DataTransformation.ADD);
|
||||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
int id = (int) reader.getUnsigned(DataType.SHORT);
|
||||||
|
int y = (int) reader
|
||||||
|
.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||||
return new FirstObjectActionEvent(id, new Position(x, y));
|
return new FirstObjectActionEvent(id, new Position(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,16 @@ import org.apollo.net.release.EventEncoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventEncoder} for the {@link PlayerSynchronizationEvent}.
|
* An {@link EventEncoder} for the {@link PlayerSynchronizationEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class PlayerSynchronizationEventEncoder extends EventEncoder<PlayerSynchronizationEvent> {
|
public final class PlayerSynchronizationEventEncoder extends
|
||||||
|
EventEncoder<PlayerSynchronizationEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GamePacket encode(PlayerSynchronizationEvent event) {
|
public GamePacket encode(PlayerSynchronizationEvent event) {
|
||||||
GamePacketBuilder builder = new GamePacketBuilder(81, PacketType.VARIABLE_SHORT);
|
GamePacketBuilder builder = new GamePacketBuilder(81,
|
||||||
|
PacketType.VARIABLE_SHORT);
|
||||||
builder.switchToBitAccess();
|
builder.switchToBitAccess();
|
||||||
|
|
||||||
GamePacketBuilder blockBuilder = new GamePacketBuilder();
|
GamePacketBuilder blockBuilder = new GamePacketBuilder();
|
||||||
@@ -53,7 +56,8 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
if (type == SegmentType.REMOVE_CHARACTER) {
|
if (type == SegmentType.REMOVE_CHARACTER) {
|
||||||
putRemoveCharacterUpdate(builder);
|
putRemoveCharacterUpdate(builder);
|
||||||
} else if (type == SegmentType.ADD_CHARACTER) {
|
} else if (type == SegmentType.ADD_CHARACTER) {
|
||||||
putAddCharacterUpdate((AddCharacterSegment) segment, event, builder);
|
putAddCharacterUpdate((AddCharacterSegment) segment, event,
|
||||||
|
builder);
|
||||||
putBlocks(segment, blockBuilder);
|
putBlocks(segment, blockBuilder);
|
||||||
} else {
|
} else {
|
||||||
putMovementUpdate(segment, event, builder);
|
putMovementUpdate(segment, event, builder);
|
||||||
@@ -74,7 +78,9 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts a remove character update.
|
* Puts a remove character update.
|
||||||
* @param builder The builder.
|
*
|
||||||
|
* @param builder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putRemoveCharacterUpdate(GamePacketBuilder builder) {
|
private void putRemoveCharacterUpdate(GamePacketBuilder builder) {
|
||||||
builder.putBits(1, 1);
|
builder.putBits(1, 1);
|
||||||
@@ -83,11 +89,16 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts an add character update.
|
* Puts an add character update.
|
||||||
* @param seg The segment.
|
*
|
||||||
* @param event The event.
|
* @param seg
|
||||||
* @param builder The builder.
|
* The segment.
|
||||||
|
* @param event
|
||||||
|
* The event.
|
||||||
|
* @param builder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putAddCharacterUpdate(AddCharacterSegment seg, PlayerSynchronizationEvent event, GamePacketBuilder builder) {
|
private void putAddCharacterUpdate(AddCharacterSegment seg,
|
||||||
|
PlayerSynchronizationEvent event, GamePacketBuilder builder) {
|
||||||
boolean updateRequired = seg.getBlockSet().size() > 0;
|
boolean updateRequired = seg.getBlockSet().size() > 0;
|
||||||
Position player = event.getPosition();
|
Position player = event.getPosition();
|
||||||
Position other = seg.getPosition();
|
Position other = seg.getPosition();
|
||||||
@@ -100,11 +111,16 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts a movement update for the specified segment.
|
* Puts a movement update for the specified segment.
|
||||||
* @param seg The segment.
|
*
|
||||||
* @param event The event.
|
* @param seg
|
||||||
* @param builder The builder.
|
* The segment.
|
||||||
|
* @param event
|
||||||
|
* The event.
|
||||||
|
* @param builder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationEvent event, GamePacketBuilder builder) {
|
private void putMovementUpdate(SynchronizationSegment seg,
|
||||||
|
PlayerSynchronizationEvent event, 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();
|
||||||
@@ -140,10 +156,14 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts the blocks for the specified segment.
|
* Puts the blocks for the specified segment.
|
||||||
* @param segment The segment.
|
*
|
||||||
* @param blockBuilder The block builder.
|
* @param segment
|
||||||
|
* The segment.
|
||||||
|
* @param blockBuilder
|
||||||
|
* The block builder.
|
||||||
*/
|
*/
|
||||||
private void putBlocks(SynchronizationSegment segment, GamePacketBuilder blockBuilder) {
|
private void putBlocks(SynchronizationSegment segment,
|
||||||
|
GamePacketBuilder blockBuilder) {
|
||||||
SynchronizationBlockSet blockSet = segment.getBlockSet();
|
SynchronizationBlockSet blockSet = segment.getBlockSet();
|
||||||
if (blockSet.size() > 0) {
|
if (blockSet.size() > 0) {
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
@@ -180,7 +200,8 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (blockSet.contains(AnimationBlock.class)) {
|
if (blockSet.contains(AnimationBlock.class)) {
|
||||||
putAnimationBlock(blockSet.get(AnimationBlock.class), blockBuilder);
|
putAnimationBlock(blockSet.get(AnimationBlock.class),
|
||||||
|
blockBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockSet.contains(ChatBlock.class)) {
|
if (blockSet.contains(ChatBlock.class)) {
|
||||||
@@ -188,67 +209,93 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (blockSet.contains(AppearanceBlock.class)) {
|
if (blockSet.contains(AppearanceBlock.class)) {
|
||||||
putAppearanceBlock(blockSet.get(AppearanceBlock.class), blockBuilder);
|
putAppearanceBlock(blockSet.get(AppearanceBlock.class),
|
||||||
|
blockBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockSet.contains(TurnToPositionBlock.class)) {
|
if (blockSet.contains(TurnToPositionBlock.class)) {
|
||||||
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class), blockBuilder);
|
putTurnToPositionBlock(blockSet.get(TurnToPositionBlock.class),
|
||||||
|
blockBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts a turn to position block into the specified builder.
|
* Puts a turn to position block into the specified builder.
|
||||||
* @param block The block.
|
*
|
||||||
* @param blockBuilder The builder.
|
* @param block
|
||||||
|
* The block.
|
||||||
|
* @param blockBuilder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putTurnToPositionBlock(TurnToPositionBlock block, GamePacketBuilder blockBuilder) {
|
private void putTurnToPositionBlock(TurnToPositionBlock block,
|
||||||
|
GamePacketBuilder blockBuilder) {
|
||||||
Position pos = block.getPosition();
|
Position pos = block.getPosition();
|
||||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD, pos.getX() * 2 + 1);
|
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE,
|
||||||
|
DataTransformation.ADD, pos.getX() * 2 + 1);
|
||||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, pos.getY() * 2 + 1);
|
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, pos.getY() * 2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts a graphic block into the specified builder.
|
* Puts a graphic block into the specified builder.
|
||||||
* @param block The block.
|
*
|
||||||
* @param blockBuilder The builder.
|
* @param block
|
||||||
|
* The block.
|
||||||
|
* @param blockBuilder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putGraphicBlock(GraphicBlock block, GamePacketBuilder blockBuilder) {
|
private void putGraphicBlock(GraphicBlock block,
|
||||||
|
GamePacketBuilder blockBuilder) {
|
||||||
Graphic graphic = block.getGraphic();
|
Graphic graphic = block.getGraphic();
|
||||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, graphic.getId());
|
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, graphic.getId());
|
||||||
blockBuilder.put(DataType.INT, ((graphic.getHeight() >> 16) & 0x0000FFFF) | (graphic.getDelay() & 0xFFFF));
|
blockBuilder.put(DataType.INT,
|
||||||
|
(graphic.getHeight() << 16) | (graphic.getDelay() & 0xFFFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts an animation block into the specified builder.
|
* Puts an animation block into the specified builder.
|
||||||
* @param block The block.
|
*
|
||||||
* @param blockBuilder The builder.
|
* @param block
|
||||||
|
* The block.
|
||||||
|
* @param blockBuilder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putAnimationBlock(AnimationBlock block, GamePacketBuilder blockBuilder) {
|
private void putAnimationBlock(AnimationBlock block,
|
||||||
|
GamePacketBuilder blockBuilder) {
|
||||||
Animation animation = block.getAnimation();
|
Animation animation = block.getAnimation();
|
||||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, animation.getId());
|
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, animation.getId());
|
||||||
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE, animation.getDelay());
|
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE,
|
||||||
|
animation.getDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts a chat block into the specified builder.
|
* Puts a chat block into the specified builder.
|
||||||
* @param block The block.
|
*
|
||||||
* @param blockBuilder The builder.
|
* @param block
|
||||||
|
* The block.
|
||||||
|
* @param blockBuilder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putChatBlock(ChatBlock block, GamePacketBuilder blockBuilder) {
|
private void putChatBlock(ChatBlock block, GamePacketBuilder blockBuilder) {
|
||||||
byte[] bytes = block.getCompressedMessage();
|
byte[] bytes = block.getCompressedMessage();
|
||||||
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE, (block.getTextColor() << 8) | block.getTextEffects());
|
blockBuilder.put(DataType.SHORT, DataOrder.LITTLE,
|
||||||
|
(block.getTextColor() << 8) | block.getTextEffects());
|
||||||
blockBuilder.put(DataType.BYTE, block.getPrivilegeLevel().toInteger());
|
blockBuilder.put(DataType.BYTE, block.getPrivilegeLevel().toInteger());
|
||||||
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE, bytes.length);
|
blockBuilder
|
||||||
|
.put(DataType.BYTE, DataTransformation.NEGATE, bytes.length);
|
||||||
blockBuilder.putBytesReverse(bytes);
|
blockBuilder.putBytesReverse(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts an appearance block into the specified builder.
|
* Puts an appearance block into the specified builder.
|
||||||
* @param block The block.
|
*
|
||||||
* @param blockBuilder The builder.
|
* @param block
|
||||||
|
* The block.
|
||||||
|
* @param blockBuilder
|
||||||
|
* The builder.
|
||||||
*/
|
*/
|
||||||
private void putAppearanceBlock(AppearanceBlock block, GamePacketBuilder blockBuilder) {
|
private void putAppearanceBlock(AppearanceBlock block,
|
||||||
|
GamePacketBuilder blockBuilder) {
|
||||||
Appearance appearance = block.getAppearance();
|
Appearance appearance = block.getAppearance();
|
||||||
GamePacketBuilder playerProperties = new GamePacketBuilder();
|
GamePacketBuilder playerProperties = new GamePacketBuilder();
|
||||||
|
|
||||||
@@ -323,7 +370,8 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
if (helm != null) {
|
if (helm != null) {
|
||||||
def = EquipmentDefinition.forId(helm.getId());
|
def = EquipmentDefinition.forId(helm.getId());
|
||||||
}
|
}
|
||||||
if ((def != null && (def.isFullHat() || def.isFullMask())) || appearance.getGender() == Gender.FEMALE) {
|
if ((def != null && (def.isFullHat() || def.isFullMask()))
|
||||||
|
|| appearance.getGender() == Gender.FEMALE) {
|
||||||
playerProperties.put(DataType.BYTE, 0);
|
playerProperties.put(DataType.BYTE, 0);
|
||||||
} else {
|
} else {
|
||||||
playerProperties.put(DataType.SHORT, 0x100 + style[1]);
|
playerProperties.put(DataType.SHORT, 0x100 + style[1]);
|
||||||
@@ -343,10 +391,14 @@ public final class PlayerSynchronizationEventEncoder extends EventEncoder<Player
|
|||||||
playerProperties.put(DataType.SHORT, 0x338); // run
|
playerProperties.put(DataType.SHORT, 0x338); // run
|
||||||
|
|
||||||
playerProperties.put(DataType.LONG, block.getName());
|
playerProperties.put(DataType.LONG, block.getName());
|
||||||
playerProperties.put(DataType.BYTE, block.getCombatLevel()); // combat level
|
playerProperties.put(DataType.BYTE, block.getCombatLevel()); // combat
|
||||||
playerProperties.put(DataType.SHORT, block.getSkillLevel()); // total skill level
|
// level
|
||||||
|
playerProperties.put(DataType.SHORT, block.getSkillLevel()); // total
|
||||||
|
// skill
|
||||||
|
// level
|
||||||
|
|
||||||
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE, playerProperties.getLength());
|
blockBuilder.put(DataType.BYTE, DataTransformation.NEGATE,
|
||||||
|
playerProperties.getLength());
|
||||||
blockBuilder.putRawBuilder(playerProperties);
|
blockBuilder.putRawBuilder(playerProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.apollo.game.event.impl.OpenInterfaceSidebarEvent;
|
|||||||
import org.apollo.game.event.impl.PlayerSynchronizationEvent;
|
import org.apollo.game.event.impl.PlayerSynchronizationEvent;
|
||||||
import org.apollo.game.event.impl.RegionChangeEvent;
|
import org.apollo.game.event.impl.RegionChangeEvent;
|
||||||
import org.apollo.game.event.impl.ServerMessageEvent;
|
import org.apollo.game.event.impl.ServerMessageEvent;
|
||||||
|
import org.apollo.game.event.impl.SetInterfaceTextEvent;
|
||||||
import org.apollo.game.event.impl.SwitchTabInterfaceEvent;
|
import org.apollo.game.event.impl.SwitchTabInterfaceEvent;
|
||||||
import org.apollo.game.event.impl.UpdateItemsEvent;
|
import org.apollo.game.event.impl.UpdateItemsEvent;
|
||||||
import org.apollo.game.event.impl.UpdateSkillEvent;
|
import org.apollo.game.event.impl.UpdateSkillEvent;
|
||||||
@@ -103,6 +104,7 @@ public final class Release317 extends Release {
|
|||||||
register(UpdateSkillEvent.class, new UpdateSkillEventEncoder());
|
register(UpdateSkillEvent.class, new UpdateSkillEventEncoder());
|
||||||
register(OpenInterfaceSidebarEvent.class, new OpenInterfaceSidebarEventEncoder());
|
register(OpenInterfaceSidebarEvent.class, new OpenInterfaceSidebarEventEncoder());
|
||||||
register(EnterAmountEvent.class, new EnterAmountEventEncoder());
|
register(EnterAmountEvent.class, new EnterAmountEventEncoder());
|
||||||
|
register(SetInterfaceTextEvent.class, new SetInterfaceTextEventEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,16 +10,20 @@ import org.apollo.net.release.EventDecoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link SecondItemActionEvent}.
|
* An {@link EventDecoder} for the {@link SecondItemActionEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class SecondItemActionEventDecoder extends EventDecoder<SecondItemActionEvent> {
|
public final class SecondItemActionEventDecoder extends
|
||||||
|
EventDecoder<SecondItemActionEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecondItemActionEvent decode(GamePacket packet) {
|
public SecondItemActionEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
int interfaceId = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int interfaceId = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
DataOrder.LITTLE, DataTransformation.ADD);
|
||||||
int slot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE,
|
||||||
|
DataTransformation.ADD);
|
||||||
|
int slot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||||
return new SecondItemActionEvent(interfaceId, id, slot);
|
return new SecondItemActionEvent(interfaceId, id, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.apollo.net.release.r317;
|
||||||
|
|
||||||
|
import org.apollo.game.event.impl.SetInterfaceTextEvent;
|
||||||
|
import org.apollo.net.codec.game.DataTransformation;
|
||||||
|
import org.apollo.net.codec.game.DataType;
|
||||||
|
import org.apollo.net.codec.game.GamePacket;
|
||||||
|
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||||
|
import org.apollo.net.meta.PacketType;
|
||||||
|
import org.apollo.net.release.EventEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@link EventEncoder} for the {@link SetInterfaceTextEvent}.
|
||||||
|
*
|
||||||
|
* @author The Wanderer
|
||||||
|
*/
|
||||||
|
public final class SetInterfaceTextEventEncoder extends
|
||||||
|
EventEncoder<SetInterfaceTextEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GamePacket encode(SetInterfaceTextEvent event) {
|
||||||
|
GamePacketBuilder builder = new GamePacketBuilder(126,
|
||||||
|
PacketType.VARIABLE_SHORT);
|
||||||
|
builder.putString(event.getText());
|
||||||
|
builder.put(DataType.SHORT, DataTransformation.ADD,
|
||||||
|
event.getInterfaceId());
|
||||||
|
|
||||||
|
return builder.toGamePacket();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import org.apollo.net.release.EventDecoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link SwitchItemEvent}.
|
* An {@link EventDecoder} for the {@link SwitchItemEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class SwitchItemEventDecoder extends EventDecoder<SwitchItemEvent> {
|
public final class SwitchItemEventDecoder extends EventDecoder<SwitchItemEvent> {
|
||||||
@@ -17,10 +18,14 @@ public final class SwitchItemEventDecoder extends EventDecoder<SwitchItemEvent>
|
|||||||
@Override
|
@Override
|
||||||
public SwitchItemEvent decode(GamePacket packet) {
|
public SwitchItemEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
int interfaceId = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int interfaceId = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
boolean inserting = reader.getUnsigned(DataType.BYTE, DataTransformation.NEGATE) == 1;
|
DataOrder.LITTLE, DataTransformation.ADD);
|
||||||
int oldSlot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
boolean inserting = reader.getUnsigned(DataType.BYTE,
|
||||||
int newSlot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
DataTransformation.NEGATE) == 1;
|
||||||
|
int oldSlot = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
|
DataOrder.LITTLE, DataTransformation.ADD);
|
||||||
|
int newSlot = (int) reader
|
||||||
|
.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||||
return new SwitchItemEvent(interfaceId, inserting, oldSlot, newSlot);
|
return new SwitchItemEvent(interfaceId, inserting, oldSlot, newSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,21 @@ import org.apollo.net.release.EventDecoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link ThirdItemActionEvent}.
|
* An {@link EventDecoder} for the {@link ThirdItemActionEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class ThirdItemActionEventDecoder extends EventDecoder<ThirdItemActionEvent> {
|
public final class ThirdItemActionEventDecoder extends
|
||||||
|
EventDecoder<ThirdItemActionEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ThirdItemActionEvent decode(GamePacket packet) {
|
public ThirdItemActionEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
int interfaceId = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int interfaceId = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
DataOrder.LITTLE);
|
||||||
int slot = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
int id = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
|
DataTransformation.ADD);
|
||||||
|
int slot = (int) reader.getUnsigned(DataType.SHORT,
|
||||||
|
DataTransformation.ADD);
|
||||||
return new ThirdItemActionEvent(interfaceId, id, slot);
|
return new ThirdItemActionEvent(interfaceId, id, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.apollo.net.release.Release;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link Release} for the 377 protocol.
|
* An implementation of {@link Release} for the 377 protocol.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class Release377 extends Release {
|
public final class Release377 extends Release {
|
||||||
@@ -26,94 +27,33 @@ public final class Release377 extends Release {
|
|||||||
/**
|
/**
|
||||||
* The incoming packet lengths array.
|
* The incoming packet lengths array.
|
||||||
*/
|
*/
|
||||||
public static final int[] PACKET_LENGTHS = new int[256];
|
public static final int[] PACKET_LENGTHS = { 0, 12, 0, 6, 6, 0, 0, 0, 2, 0, // 0
|
||||||
|
0, 0, 0, 2, 0, 0, 0, 0, 0, 4, // 10
|
||||||
/**
|
0, 0, 2, 0, 6, 0, 0, 0, -1, 0, // 20
|
||||||
* Initialises the {@link #PACKET_LENGTHS} array.
|
0, 4, 0, 0, 0, 0, 8, 0, 0, 0, // 30
|
||||||
* TODO make it like the 317 one.
|
0, 0, 2, 0, 0, 2, 0, 0, 0, -1, // 40
|
||||||
*/
|
6, 0, 0, 0, 6, 6, -1, 8, 0, 0, // 50
|
||||||
static {
|
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, // 60
|
||||||
PACKET_LENGTHS[1] = 12;
|
0, 6, 0, 0, 0, 4, 0, 6, 4, 2, // 70
|
||||||
PACKET_LENGTHS[3] = 6;
|
2, 0, 0, 8, 0, 0, 0, 0, 0, 0, // 80
|
||||||
PACKET_LENGTHS[4] = 6;
|
0, 6, 0, 0, 0, 4, 0, 0, 0, 0, // 90
|
||||||
PACKET_LENGTHS[6] = 0;
|
6, 0, 0, 0, 4, 0, 0, 0, 0, 0, // 100
|
||||||
PACKET_LENGTHS[8] = 2;
|
0, 0, 2, 0, 0, 0, 2, 0, 0, 1, // 110
|
||||||
PACKET_LENGTHS[13] = 2;
|
8, 0, 0, 7, 0, 0, 1, 0, 0, 0, // 120
|
||||||
PACKET_LENGTHS[19] = 4;
|
0, 0, 0, 0, 0, 0, 6, 0, 0, 0, // 130
|
||||||
PACKET_LENGTHS[22] = 2;
|
4, 8, 0, 8, 0, 0, 0, 0, 0, 0, // 140
|
||||||
PACKET_LENGTHS[24] = 6;
|
0, 0, 12, 0, 0, 0, 0, 4, 6, 0, // 150
|
||||||
PACKET_LENGTHS[28] = -1;
|
8, 6, 0, 13, 0, 1, 0, 0, 0, 0, // 160
|
||||||
PACKET_LENGTHS[31] = 4;
|
0, -1, 0, 3, 0, 0, 3, 6, 0, 0, // 170
|
||||||
PACKET_LENGTHS[36] = 8;
|
0, 6, 0, 0, 10, 0, 0, 1, 0, 0, // 180
|
||||||
PACKET_LENGTHS[40] = 0;
|
0, 0, 0, 0, 2, 0, 0, 4, 0, 0, // 190
|
||||||
PACKET_LENGTHS[42] = 2;
|
0, 0, 0, 6, 0, 0, 8, 0, 0, 0, // 200
|
||||||
PACKET_LENGTHS[45] = 2;
|
8, 12, 0, -1, 0, 0, 0, 8, 0, 0, // 210
|
||||||
PACKET_LENGTHS[49] = -1;
|
0, 0, 3, 0, 0, 0, 2, 9, 6, 0, // 220
|
||||||
PACKET_LENGTHS[50] = 6;
|
6, 6, 0, 2, 0, 0, 0, 0, 0, 0, // 230
|
||||||
PACKET_LENGTHS[54] = 6;
|
0, 6, 0, 0, -1, 2, 0, -1, 0, 0, // 240
|
||||||
PACKET_LENGTHS[55] = 6;
|
0, 0, 0, 0, 0, 0 // 250
|
||||||
PACKET_LENGTHS[56] = -1;
|
};
|
||||||
PACKET_LENGTHS[57] = 8;
|
|
||||||
PACKET_LENGTHS[67] = 2;
|
|
||||||
PACKET_LENGTHS[71] = 6;
|
|
||||||
PACKET_LENGTHS[75] = 4;
|
|
||||||
PACKET_LENGTHS[77] = 6;
|
|
||||||
PACKET_LENGTHS[78] = 4;
|
|
||||||
PACKET_LENGTHS[79] = 2;
|
|
||||||
PACKET_LENGTHS[80] = 2;
|
|
||||||
PACKET_LENGTHS[83] = 8;
|
|
||||||
PACKET_LENGTHS[91] = 6;
|
|
||||||
PACKET_LENGTHS[95] = 4;
|
|
||||||
PACKET_LENGTHS[100] = 6;
|
|
||||||
PACKET_LENGTHS[104] = 4;
|
|
||||||
PACKET_LENGTHS[110] = 0;
|
|
||||||
PACKET_LENGTHS[112] = 2;
|
|
||||||
PACKET_LENGTHS[116] = 2;
|
|
||||||
PACKET_LENGTHS[119] = 1;
|
|
||||||
PACKET_LENGTHS[120] = 8;
|
|
||||||
PACKET_LENGTHS[123] = 7;
|
|
||||||
PACKET_LENGTHS[126] = 1;
|
|
||||||
PACKET_LENGTHS[136] = 6;
|
|
||||||
PACKET_LENGTHS[140] = 4;
|
|
||||||
PACKET_LENGTHS[141] = 8;
|
|
||||||
PACKET_LENGTHS[143] = 8;
|
|
||||||
PACKET_LENGTHS[152] = 12;
|
|
||||||
PACKET_LENGTHS[157] = 4;
|
|
||||||
PACKET_LENGTHS[158] = 6;
|
|
||||||
PACKET_LENGTHS[160] = 8;
|
|
||||||
PACKET_LENGTHS[161] = 6;
|
|
||||||
PACKET_LENGTHS[163] = 13;
|
|
||||||
PACKET_LENGTHS[165] = 1;
|
|
||||||
PACKET_LENGTHS[168] = 0;
|
|
||||||
PACKET_LENGTHS[171] = -1;
|
|
||||||
PACKET_LENGTHS[173] = 3;
|
|
||||||
PACKET_LENGTHS[176] = 3;
|
|
||||||
PACKET_LENGTHS[177] = 6;
|
|
||||||
PACKET_LENGTHS[181] = 6;
|
|
||||||
PACKET_LENGTHS[184] = 10;
|
|
||||||
PACKET_LENGTHS[187] = 1;
|
|
||||||
PACKET_LENGTHS[194] = 2;
|
|
||||||
PACKET_LENGTHS[197] = 4;
|
|
||||||
PACKET_LENGTHS[202] = 0;
|
|
||||||
PACKET_LENGTHS[203] = 6;
|
|
||||||
PACKET_LENGTHS[206] = 8;
|
|
||||||
PACKET_LENGTHS[210] = 8;
|
|
||||||
PACKET_LENGTHS[211] = 12;
|
|
||||||
PACKET_LENGTHS[213] = -1;
|
|
||||||
PACKET_LENGTHS[217] = 8;
|
|
||||||
PACKET_LENGTHS[222] = 3;
|
|
||||||
PACKET_LENGTHS[226] = 2;
|
|
||||||
PACKET_LENGTHS[227] = 9;
|
|
||||||
PACKET_LENGTHS[228] = 6;
|
|
||||||
PACKET_LENGTHS[230] = 6;
|
|
||||||
PACKET_LENGTHS[231] = 6;
|
|
||||||
PACKET_LENGTHS[233] = 2;
|
|
||||||
PACKET_LENGTHS[241] = 6;
|
|
||||||
PACKET_LENGTHS[244] = -1;
|
|
||||||
PACKET_LENGTHS[245] = 2;
|
|
||||||
PACKET_LENGTHS[247] = -1;
|
|
||||||
PACKET_LENGTHS[248] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and initialises this release.
|
* Creates and initialises this release.
|
||||||
@@ -154,17 +94,22 @@ public final class Release377 extends Release {
|
|||||||
register(IdAssignmentEvent.class, new IdAssignmentEventEncoder());
|
register(IdAssignmentEvent.class, new IdAssignmentEventEncoder());
|
||||||
register(RegionChangeEvent.class, new RegionChangeEventEncoder());
|
register(RegionChangeEvent.class, new RegionChangeEventEncoder());
|
||||||
register(ServerMessageEvent.class, new ServerMessageEventEncoder());
|
register(ServerMessageEvent.class, new ServerMessageEventEncoder());
|
||||||
register(PlayerSynchronizationEvent.class, new PlayerSynchronizationEventEncoder());
|
register(PlayerSynchronizationEvent.class,
|
||||||
|
new PlayerSynchronizationEventEncoder());
|
||||||
register(OpenInterfaceEvent.class, new OpenInterfaceEventEncoder());
|
register(OpenInterfaceEvent.class, new OpenInterfaceEventEncoder());
|
||||||
register(CloseInterfaceEvent.class, new CloseInterfaceEventEncoder());
|
register(CloseInterfaceEvent.class, new CloseInterfaceEventEncoder());
|
||||||
register(SwitchTabInterfaceEvent.class, new SwitchTabInterfaceEventEncoder());
|
register(SwitchTabInterfaceEvent.class,
|
||||||
|
new SwitchTabInterfaceEventEncoder());
|
||||||
register(LogoutEvent.class, new LogoutEventEncoder());
|
register(LogoutEvent.class, new LogoutEventEncoder());
|
||||||
register(UpdateItemsEvent.class, new UpdateItemsEventEncoder());
|
register(UpdateItemsEvent.class, new UpdateItemsEventEncoder());
|
||||||
register(UpdateSlottedItemsEvent.class, new UpdateSlottedItemsEventEncoder());
|
register(UpdateSlottedItemsEvent.class,
|
||||||
|
new UpdateSlottedItemsEventEncoder());
|
||||||
register(UpdateSkillEvent.class, new UpdateSkillEventEncoder());
|
register(UpdateSkillEvent.class, new UpdateSkillEventEncoder());
|
||||||
register(OpenInterfaceSidebarEvent.class, new OpenInterfaceSidebarEventEncoder());
|
register(OpenInterfaceSidebarEvent.class,
|
||||||
|
new OpenInterfaceSidebarEventEncoder());
|
||||||
register(EnterAmountEvent.class, new EnterAmountEventEncoder());
|
register(EnterAmountEvent.class, new EnterAmountEventEncoder());
|
||||||
register(SetInterfaceTextEvent.class, new SetInterfaceTextEventEncoder());
|
register(SetInterfaceTextEvent.class,
|
||||||
|
new SetInterfaceTextEventEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,20 @@ import org.apollo.net.release.EventDecoder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link EventDecoder} for the {@link ThirdObjectActionEvent}.
|
* An {@link EventDecoder} for the {@link ThirdObjectActionEvent}.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class ThirdObjectActionEventDecoder extends EventDecoder<ThirdObjectActionEvent> {
|
public final class ThirdObjectActionEventDecoder extends
|
||||||
|
EventDecoder<ThirdObjectActionEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ThirdObjectActionEvent decode(GamePacket packet) {
|
public ThirdObjectActionEvent decode(GamePacket packet) {
|
||||||
GamePacketReader reader = new GamePacketReader(packet);
|
GamePacketReader reader = new GamePacketReader(packet);
|
||||||
int y = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
int y = (int) reader
|
||||||
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||||
|
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE,
|
||||||
|
DataTransformation.ADD);
|
||||||
return new ThirdObjectActionEvent(id, new Position(x, y));
|
return new ThirdObjectActionEvent(id, new Position(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.apollo.tools;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains equipment name constants.
|
* Contains equipment name constants.
|
||||||
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
* @author Palidino76
|
* @author Palidino76
|
||||||
*/
|
*/
|
||||||
@@ -15,7 +16,10 @@ public final class EquipmentConstants {
|
|||||||
/**
|
/**
|
||||||
* Hats.
|
* Hats.
|
||||||
*/
|
*/
|
||||||
public static final String[] HATS = {"helm","hood","coif","Coif","hat","partyhat","Hat","full helm (t)","full helm (g)","hat (t)","hat (g)","cav","boater","helmet","mask","Helm of neitiznot"};
|
public static final String[] HATS = { "helm", "hood", "coif", "Coif",
|
||||||
|
"hat", "partyhat", "Hat", "full helm (t)", "full helm (g)",
|
||||||
|
"hat (t)", "hat (g)", "cav", "boater", "helmet", "mask",
|
||||||
|
"Helm of neitiznot" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boots.
|
* Boots.
|
||||||
@@ -25,12 +29,15 @@ public final class EquipmentConstants {
|
|||||||
/**
|
/**
|
||||||
* Gloves.
|
* Gloves.
|
||||||
*/
|
*/
|
||||||
public static final String[] GLOVES = {"gloves","gauntlets","Gloves","vambraces","vamb","bracers"};
|
public static final String[] GLOVES = { "gloves", "gauntlets", "Gloves",
|
||||||
|
"vambraces", "vamb", "bracers" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shields.
|
* Shields.
|
||||||
*/
|
*/
|
||||||
public static final String[] SHIELDS = {"kiteshield","sq shield","Toktz-ket","books","book","kiteshield (t)","kiteshield (g)","kiteshield(h)","defender","shield"};
|
public static final String[] SHIELDS = { "kiteshield", "sq shield",
|
||||||
|
"Toktz-ket", "books", "book", "kiteshield (t)", "kiteshield (g)",
|
||||||
|
"kiteshield(h)", "defender", "shield" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amulets.
|
* Amulets.
|
||||||
@@ -40,45 +47,64 @@ public final class EquipmentConstants {
|
|||||||
/**
|
/**
|
||||||
* Arrows.
|
* Arrows.
|
||||||
*/
|
*/
|
||||||
public static final String[] ARROWS = {"arrow","arrows","arrow(p)","arrow(+)","arrow(s)","bolt","Bolt rack","Opal bolts","Dragon bolts"};
|
public static final String[] ARROWS = { "arrow", "arrows", "arrow(p)",
|
||||||
|
"arrow(+)", "arrow(s)", "bolt", "Bolt rack", "Opal bolts",
|
||||||
|
"Dragon bolts" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rings.
|
* Rings.
|
||||||
*/
|
*/
|
||||||
public static final String[] RINGS = {"ring"};
|
public static final String[] RINGS = { "ring", "Ring of" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bodies.
|
* Bodies.
|
||||||
*/
|
*/
|
||||||
public static final String[] BODY = {"platebody","chainbody","robetop","leathertop","platemail","top","brassard","Robe top","body","platebody (t)","platebody (g)","body(g)","body_(g)","chestplate","torso","shirt"};
|
public static final String[] BODY = { "platebody", "chainbody", "robetop",
|
||||||
|
"leathertop", "platemail", "top", "brassard", "Robe top", "body",
|
||||||
|
"platebody (t)", "platebody (g)", "body(g)", "body_(g)",
|
||||||
|
"chestplate", "torso", "shirt" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legs.
|
* Legs.
|
||||||
*/
|
*/
|
||||||
public static final String[] LEGS = {"platelegs","plateskirt","skirt","bottoms","chaps","platelegs (t)","platelegs (g)","bottom","skirt","skirt (g)","skirt (t)","chaps (g)","chaps (t)","tassets","legs","Flared trousers"};
|
public static final String[] LEGS = { "platelegs", "plateskirt", "skirt",
|
||||||
|
"bottoms", "chaps", "platelegs (t)", "platelegs (g)", "bottom",
|
||||||
|
"skirt", "skirt (g)", "skirt (t)", "chaps (g)", "chaps (t)",
|
||||||
|
"tassets", "legs", "Flared trousers" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Weapons.
|
* Weapons.
|
||||||
*/
|
*/
|
||||||
public static final String[] WEAPONS = {"scimitar","longsword","sword","longbow","shortbow","dagger","mace","halberd","spear",
|
public static final String[] WEAPONS = { "scimitar", "longsword", "sword",
|
||||||
"Abyssal whip","axe","flail","crossbow","Torags hammers","dagger(p)","dagger(+)","dagger(s)","spear(p)","spear(+)",
|
"longbow", "shortbow", "dagger", "mace", "halberd", "spear",
|
||||||
"spear(s)","spear(kp)","maul","dart","dart(p)","javelin","javelin(p)","knife","knife(p)","Longbow","Shortbow",
|
"Abyssal whip", "axe", "flail", "crossbow", "Torags hammers",
|
||||||
"Crossbow","Toktz-xil","Toktz-mej","Tzhaar-ket","staff","Staff","godsword","c'bow","Crystal bow","Dark bow", "Magic butterfly net"};
|
"dagger(p)", "dagger(+)", "dagger(s)", "spear(p)", "spear(+)",
|
||||||
|
"spear(s)", "spear(kp)", "maul", "dart", "dart(p)", "javelin",
|
||||||
|
"javelin(p)", "knife", "knife(p)", "Longbow", "Shortbow",
|
||||||
|
"Crossbow", "Toktz-xil", "Toktz-mej", "Tzhaar-ket", "staff",
|
||||||
|
"Staff", "godsword", "c'bow", "Crystal bow", "Dark bow",
|
||||||
|
"Magic butterfly net" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full bodies.
|
* Full bodies.
|
||||||
*/
|
*/
|
||||||
public static final String[] FULL_BODIES = {"top","shirt","platebody","Ahrims robetop","Karils leathertop","brassard","Robe top","robetop","platebody (t)","platebody (g)","chestplate","torso"};
|
public static final String[] FULL_BODIES = { "top", "shirt", "platebody",
|
||||||
|
"Ahrims robetop", "Karils leathertop", "brassard", "Robe top",
|
||||||
|
"robetop", "platebody (t)", "platebody (g)", "chestplate", "torso" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full hats.
|
* Full hats.
|
||||||
*/
|
*/
|
||||||
public static final String[] FULL_HATS = {"med helm","coif","Dharoks helm","hood","Initiate helm","Coif","Helm of neitiznot"};
|
public static final String[] FULL_HATS = { "med helm", "coif",
|
||||||
|
"Dharoks helm", "hood", "Initiate helm", "Coif",
|
||||||
|
"Helm of neitiznot" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full masks.
|
* Full masks.
|
||||||
*/
|
*/
|
||||||
public static final String[] FULL_MASKS = {"full helm","mask","Veracs helm","Guthans helm","Torags helm","Karils coif","full helm (t)","full helm (g)","mask"};
|
public static final String[] FULL_MASKS = { "full helm", "mask",
|
||||||
|
"Veracs helm", "Guthans helm", "Torags helm", "Karils coif",
|
||||||
|
"full helm (t)", "full helm (g)", "mask" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private construcotr to prevent instantiation.
|
* Default private construcotr to prevent instantiation.
|
||||||
|
|||||||
Reference in New Issue
Block a user