mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Change getSigned -> getUnsigned in NpcActionMessages, resolve merge conflict.
This commit is contained in:
@@ -4,13 +4,14 @@ package org.apollo.game.message.impl;
|
||||
* The fifth {@link NpcActionMessage}.
|
||||
*
|
||||
* @author Major
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class FifthNpcActionMessage extends NpcActionMessage {
|
||||
|
||||
/**
|
||||
* Creates a new fifth npc action message.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
* Creates the FifthNpcActionMessage.
|
||||
*
|
||||
* @param index The index of the Npc.
|
||||
*/
|
||||
public FifthNpcActionMessage(int index) {
|
||||
super(5, index);
|
||||
|
||||
@@ -4,13 +4,14 @@ package org.apollo.game.message.impl;
|
||||
* The fourth {@link NpcActionMessage}.
|
||||
*
|
||||
* @author Major
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class FourthNpcActionMessage extends NpcActionMessage {
|
||||
|
||||
/**
|
||||
* Creates a new fourth npc action message.
|
||||
* Creates the FourthNpcActionMessage.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
* @param index The index of the Npc.
|
||||
*/
|
||||
public FourthNpcActionMessage(int index) {
|
||||
super(4, index);
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.entity.Entity;
|
||||
|
||||
/**
|
||||
* A {@link Message} sent by the client when a Player uses a magic spell on a Mob.
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public abstract class MagicOnMobMessage extends Message {
|
||||
|
||||
/**
|
||||
* The type of the Mob.
|
||||
*/
|
||||
private final Entity.EntityType type;
|
||||
|
||||
/**
|
||||
* The index of the Mob.
|
||||
*/
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* The spell if used.
|
||||
*/
|
||||
private final int spellId;
|
||||
|
||||
/**
|
||||
* Creates the MagicOnMobMessage.
|
||||
*
|
||||
* @param type The Mob type.
|
||||
* @param index The Mob index.
|
||||
* @param spellId The spell id.
|
||||
*/
|
||||
public MagicOnMobMessage(Entity.EntityType type, int index, int spellId) {
|
||||
this.type = type;
|
||||
this.index = index;
|
||||
this.spellId = spellId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the Mob the spell is being used on.
|
||||
*
|
||||
* @return The Mob type.
|
||||
*/
|
||||
public Entity.EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the Mob the spell is being used on.
|
||||
*
|
||||
* @return The Mob index.
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spell id that is being used.
|
||||
*
|
||||
* @return The spell id.
|
||||
*/
|
||||
public int getSpellId() {
|
||||
return spellId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
import org.apollo.game.model.entity.Entity;
|
||||
|
||||
/**
|
||||
* The magic on npc {@link MagicOnNpcMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MagicOnNpcMessage extends MagicOnMobMessage {
|
||||
|
||||
/**
|
||||
* Creates the MagicOnMobMessage.
|
||||
*
|
||||
* @param index The Npc index.
|
||||
* @param spellId The spell id used.
|
||||
*/
|
||||
public MagicOnNpcMessage(int index, int spellId) {
|
||||
super(Entity.EntityType.NPC, index, spellId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
import org.apollo.game.model.entity.Entity;
|
||||
|
||||
/**
|
||||
* The Player {@link MagicOnMobMessage}.
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MagicOnPlayerMessage extends MagicOnMobMessage {
|
||||
|
||||
/**
|
||||
* Creates the MagicOnPlayerMessage.
|
||||
*
|
||||
* @param index The index of the player.
|
||||
* @param spellId The spell id used.
|
||||
*/
|
||||
public MagicOnPlayerMessage(int index, int spellId) {
|
||||
super(Entity.EntityType.PLAYER, index, spellId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,79 +4,82 @@ import org.apollo.game.message.Message;
|
||||
|
||||
/**
|
||||
* A {@link Message} sent by the client to indicate when the mouse button/s have been clicked. This can be used in
|
||||
* combination with {@link org.apollo.game.message.impl.FocusUpdateMessage} to work out if the player is clicking
|
||||
* whilst the client is closed
|
||||
* combination with {@link FocusUpdateMessage} to work out if the player is clicking whilst the client is closed.
|
||||
*
|
||||
* @author Stuart
|
||||
* @author Major
|
||||
*/
|
||||
public final class MouseClickedMessage extends Message {
|
||||
|
||||
/**
|
||||
* Time in milliseconds since the last click
|
||||
*/
|
||||
private final long lastClickedDelay;
|
||||
/**
|
||||
* Right mouse button flag
|
||||
*/
|
||||
private final boolean rightMouseButton;
|
||||
/**
|
||||
* The y position of the cursor
|
||||
*/
|
||||
private final int x;
|
||||
/**
|
||||
* The x position of the cursor
|
||||
*/
|
||||
private final int y;
|
||||
/**
|
||||
* The time, in milliseconds, since the last click.
|
||||
*/
|
||||
private final long clickDelay;
|
||||
|
||||
/**
|
||||
* Creates a new mouse clicked message
|
||||
*
|
||||
* @param lastClickedDelay The delay since the last click
|
||||
* @param rightMouseButton Whether or not the right mouse button was used
|
||||
* @param x The x cursor position when clicked
|
||||
* @param y The y cursor position when clicked
|
||||
*/
|
||||
public MouseClickedMessage(long lastClickedDelay, boolean rightMouseButton, int x, int y) {
|
||||
this.lastClickedDelay = lastClickedDelay;
|
||||
this.rightMouseButton = rightMouseButton;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
/**
|
||||
* Indicates whether or not the mouse button pressed was the right mouse button.
|
||||
*/
|
||||
private final boolean right;
|
||||
|
||||
/**
|
||||
* Gets the time in milliseconds since the last click
|
||||
*
|
||||
* @return The time in milliseconds since the last click
|
||||
*/
|
||||
public long getLastClickedDelay() {
|
||||
return lastClickedDelay;
|
||||
}
|
||||
/**
|
||||
* The y position of the cursor.
|
||||
*/
|
||||
private final int x;
|
||||
|
||||
/**
|
||||
* Gets whether the right mouse button was used or not
|
||||
*
|
||||
* @return If the mouse right button was used to click
|
||||
*/
|
||||
public boolean usingRightMouseButton() {
|
||||
return rightMouseButton;
|
||||
}
|
||||
/**
|
||||
* The x position of the cursor.
|
||||
*/
|
||||
private final int y;
|
||||
|
||||
/**
|
||||
* Gets the x position of the cursor
|
||||
*
|
||||
* @return The x position of the cursor when clicked
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
/**
|
||||
* Creates the MouseClickedMessage.
|
||||
*
|
||||
* @param clickDelay The delay, in milliseconds, since the last click.
|
||||
* @param right Whether or not the mouse button pressed was the right mouse button.
|
||||
* @param x The x cursor position when clicked.
|
||||
* @param y The y cursor position when clicked.
|
||||
*/
|
||||
public MouseClickedMessage(long clickDelay, boolean right, int x, int y) {
|
||||
this.clickDelay = clickDelay;
|
||||
this.right = right;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the y position of the cursor
|
||||
*
|
||||
* @return The y position of the cursor when clicked
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
/**
|
||||
* Gets the delay, in milliseconds, since the last click.
|
||||
*
|
||||
* @return The time delay.
|
||||
*/
|
||||
public long getClickDelay() {
|
||||
return clickDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the x position of the cursor.
|
||||
*
|
||||
* @return The x position of the cursor when clicked.
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the y position of the cursor.
|
||||
*
|
||||
* @return The y position of the cursor when clicked.
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the right mouse button was used.
|
||||
*
|
||||
* @return {@code true} if the right mouse button was used to click, {@code false} if not.
|
||||
*/
|
||||
public boolean wasRightMouseButton() {
|
||||
return right;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.apollo.game.model.inv;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apollo.game.model.Item;
|
||||
import org.apollo.game.model.def.ItemDefinition;
|
||||
@@ -116,84 +117,90 @@ public final class Inventory {
|
||||
* @return The amount that remains.
|
||||
*/
|
||||
public int add(int id, int amount) {
|
||||
Item item = add(new Item(id, amount));
|
||||
return (item != null) ? item.getAmount() : 0;
|
||||
Optional<Item> item = add(new Item(id, amount));
|
||||
return item.isPresent() ? item.get().getAmount() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item to this inventory. This will attempt to add as much of the item that is possible. If the item
|
||||
* remains, it will be returned (in the case of stackable items, any quantity that remains in the stack is
|
||||
* returned). If nothing remains, the method will return {@code null}. If something remains, the listener will also
|
||||
* be notified which could be used, for example, to send a message to the player.
|
||||
*
|
||||
* Attempts to add as much of the specified {@code item} to this inventory as possible. If any of the item remains,
|
||||
* an {@link Item item with the remainder} will be returned (in the case of stack-able items, any quantity that
|
||||
* remains in the stack is returned). If nothing remains, the method will return {@link Optional#empty an empty
|
||||
* Optional}.
|
||||
*
|
||||
* <p>
|
||||
* If anything remains at all, the listener will be notified which could be used for notifying a player that their
|
||||
* inventory is full, for example.
|
||||
*
|
||||
* @param item The item to add to this inventory.
|
||||
* @return The item that remains if there is not enough room in the inventory. If nothing remains, {@code null}.
|
||||
* @return The item that may remain, if nothing remains, {@link Optional#empty an empty Optional} is returned.
|
||||
*/
|
||||
public Item add(Item item) {
|
||||
public Optional<Item> add(Item item) {
|
||||
int id = item.getId();
|
||||
boolean stackable = isStackable(item.getDefinition());
|
||||
|
||||
if (stackable) {
|
||||
for (int slot = 0; slot < capacity; slot++) {
|
||||
int slot = slotOf(id);
|
||||
|
||||
if (slot != -1) {
|
||||
Item other = items[slot];
|
||||
|
||||
if (other != null && other.getId() == id) {
|
||||
long total = item.getAmount() + other.getAmount();
|
||||
int amount, remaining;
|
||||
long total = (long) item.getAmount() + other.getAmount();
|
||||
int amount, remaining;
|
||||
|
||||
if (total > Integer.MAX_VALUE) {
|
||||
amount = (int) (total - Integer.MAX_VALUE);
|
||||
remaining = (int) (total - amount);
|
||||
notifyCapacityExceeded();
|
||||
} else {
|
||||
amount = (int) total;
|
||||
remaining = 0;
|
||||
}
|
||||
|
||||
set(slot, new Item(id, amount));
|
||||
return remaining > 0 ? new Item(id, remaining) : null;
|
||||
if (total > Integer.MAX_VALUE) {
|
||||
amount = (int) (total - Integer.MAX_VALUE);
|
||||
remaining = (int) (total - amount);
|
||||
notifyCapacityExceeded();
|
||||
} else {
|
||||
amount = (int) total;
|
||||
remaining = 0;
|
||||
}
|
||||
|
||||
set(slot, new Item(id, amount));
|
||||
return remaining > 0 ? Optional.of(new Item(id, remaining)) : Optional.empty();
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < capacity; slot++) {
|
||||
Item other = items[slot];
|
||||
if (other == null) {
|
||||
for (slot = 0; slot < capacity; slot++) {
|
||||
if (items[slot] == null) {
|
||||
set(slot, item);
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
notifyCapacityExceeded();
|
||||
return item;
|
||||
return Optional.of(item);
|
||||
}
|
||||
|
||||
int remaining = item.getAmount();
|
||||
|
||||
if (remaining == 0) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
stopFiringEvents();
|
||||
try {
|
||||
Item single = new Item(item.getId(), 1);
|
||||
|
||||
for (int slot = 0; slot < capacity; slot++) {
|
||||
if (items[slot] == null) {
|
||||
remaining--;
|
||||
set(slot, single); // share the instances
|
||||
|
||||
if (remaining <= 0) {
|
||||
break;
|
||||
if (--remaining <= 0) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
startFiringEvents();
|
||||
|
||||
if (remaining != item.getAmount()) {
|
||||
notifyItemsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
if (remaining != item.getAmount()) {
|
||||
notifyItemsUpdated();
|
||||
}
|
||||
if (remaining > 0) {
|
||||
notifyCapacityExceeded();
|
||||
}
|
||||
notifyCapacityExceeded();
|
||||
|
||||
return new Item(item.getId(), remaining);
|
||||
return Optional.of(new Item(item.getId(), remaining));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,38 +449,48 @@ public final class Inventory {
|
||||
* @return The amount that was removed.
|
||||
*/
|
||||
public int remove(int id, int amount) {
|
||||
ItemDefinition definition = ItemDefinition.lookup(id);
|
||||
boolean stackable = isStackable(definition);
|
||||
ItemDefinition def = ItemDefinition.lookup(id);
|
||||
boolean stackable = isStackable(def);
|
||||
|
||||
if (stackable) {
|
||||
for (int slot = 0; slot < capacity; slot++) {
|
||||
int slot = slotOf(id);
|
||||
|
||||
if (slot != -1) {
|
||||
Item item = items[slot];
|
||||
|
||||
if (item != null && item.getId() == id) {
|
||||
if (amount >= item.getAmount()) {
|
||||
set(slot, null);
|
||||
return item.getAmount();
|
||||
}
|
||||
|
||||
set(slot, new Item(item.getId(), item.getAmount() - amount));
|
||||
return amount;
|
||||
if (amount >= item.getAmount()) {
|
||||
set(slot, null);
|
||||
return item.getAmount();
|
||||
}
|
||||
|
||||
set(slot, new Item(item.getId(), item.getAmount() - amount));
|
||||
return amount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int removed = 0;
|
||||
for (int slot = 0; slot < capacity; slot++) {
|
||||
Item item = items[slot];
|
||||
|
||||
if (item != null && item.getId() == id) {
|
||||
set(slot, null);
|
||||
removed++;
|
||||
stopFiringEvents();
|
||||
|
||||
try {
|
||||
for (int slot = 0; slot < capacity; slot++) {
|
||||
Item item = items[slot];
|
||||
if (item != null && item.getId() == id) {
|
||||
set(slot, null);
|
||||
|
||||
if (++removed >= amount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (removed >= amount) {
|
||||
break;
|
||||
} finally {
|
||||
startFiringEvents();
|
||||
|
||||
if (removed > 0) {
|
||||
notifyItemsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.message.impl.FifthNpcActionMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link FifthNpcActionMessage}.
|
||||
*
|
||||
* @author Stuart
|
||||
* @author Major
|
||||
*/
|
||||
public final class FifthNpcActionMessageDecoder extends MessageDecoder<FifthNpcActionMessage> {
|
||||
|
||||
@Override
|
||||
public FifthNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new FifthNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.message.impl.FourthNpcActionMessage;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link FourthNpcActionMessage}.
|
||||
*
|
||||
* @author Stuart
|
||||
* @author Major
|
||||
*/
|
||||
public final class FourthNpcActionMessageDecoder extends MessageDecoder<FourthNpcActionMessage> {
|
||||
|
||||
@Override
|
||||
public FourthNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT);
|
||||
return new FourthNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,8 @@ public final class HintIconMessageEncoder extends MessageEncoder<HintIconMessage
|
||||
throw new IllegalStateException("Unsupported hint icon type " + type + ".");
|
||||
}
|
||||
|
||||
System.out.println("type=" + type + ", index=" + message.getIndex().get());
|
||||
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.message.impl.MagicOnNpcMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
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.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link MagicOnNpcMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MagicOnNpcMessageDecoder extends MessageDecoder<MagicOnNpcMessage> {
|
||||
|
||||
@Override
|
||||
public MagicOnNpcMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
int spell = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
|
||||
return new MagicOnNpcMessage(index, spell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.message.impl.MagicOnPlayerMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
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.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link MagicOnPlayerMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MagicOnPlayerMessageDecoder extends MessageDecoder<MagicOnPlayerMessage> {
|
||||
|
||||
@Override
|
||||
public MagicOnPlayerMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
int spell = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
|
||||
return new MagicOnPlayerMessage(index, spell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,26 +7,25 @@ import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link org.apollo.net.release.MessageDecoder} for the {@link org.apollo.game.message.impl.MouseClickedMessage}
|
||||
* A {@link MessageDecoder} for the {@link MouseClickedMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MouseClickedMessageDecoder extends MessageDecoder<MouseClickedMessage> {
|
||||
|
||||
@Override
|
||||
public MouseClickedMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int value = (int)reader.getUnsigned(DataType.INT);
|
||||
@Override
|
||||
public MouseClickedMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int value = (int) reader.getUnsigned(DataType.INT);
|
||||
|
||||
long delay = (value >> 20) * 50;
|
||||
long delay = (value >> 20) * 50;
|
||||
boolean right = ((value >> 19) & 0x1) == 1;
|
||||
|
||||
boolean rightMouseButton = ((value >> 19) & 0x1) == 1;
|
||||
int cords = (value & 0x3FFFF);
|
||||
int x = cords % 765;
|
||||
int y = cords / 765;
|
||||
|
||||
int cords = (value & 0x3FFFF);
|
||||
int x = cords % 765;
|
||||
int y = cords / 765;
|
||||
|
||||
return new MouseClickedMessage(delay, rightMouseButton, x, y);
|
||||
}
|
||||
return new MouseClickedMessage(delay, right, x, y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,10 +127,11 @@ public final class Release317 extends Release {
|
||||
|
||||
register(53, new ItemOnItemMessageDecoder());
|
||||
register(237, new MagicOnItemMessageDecoder());
|
||||
register(249, new MagicOnPlayerMessageDecoder());
|
||||
|
||||
register(3, new FocusUpdateMessageDecoder());
|
||||
register(45, new FlaggedMouseEventMessageDecoder());
|
||||
register(241, new MouseClickedMessageDecoder());
|
||||
register(241, new MouseClickedMessageDecoder());
|
||||
register(86, new ArrowKeyMessageDecoder());
|
||||
register(95, new PrivacyOptionMessageDecoder());
|
||||
|
||||
@@ -144,9 +145,11 @@ public final class Release317 extends Release {
|
||||
register(121, spamMessageDecoder);
|
||||
|
||||
register(155, new FirstNpcActionMessageDecoder());
|
||||
register(17, new SecondNpcActionMessageDecoder());
|
||||
register(21, new ThirdNpcActionMessageDecoder());
|
||||
|
||||
register(72, new SecondNpcActionMessageDecoder());
|
||||
register(17, new ThirdNpcActionMessageDecoder());
|
||||
register(21, new FourthNpcActionMessageDecoder());
|
||||
register(18, new FifthNpcActionMessageDecoder());
|
||||
|
||||
register(236, new TakeTileItemMessageDecoder());
|
||||
register(192, new ItemOnObjectMessageDecoder());
|
||||
|
||||
@@ -205,5 +208,4 @@ public final class Release317 extends Release {
|
||||
register(SendFriendMessage.class, new SendFriendMessageEncoder());
|
||||
register(HintIconMessage.class, new HintIconMessageEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public final class SecondNpcActionMessageDecoder extends MessageDecoder<SecondNp
|
||||
@Override
|
||||
public SecondNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
int index = (int) reader.getSigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new SecondNpcActionMessage(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.message.impl.ThirdNpcActionMessage;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.codec.game.*;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
@@ -16,7 +14,7 @@ public final class ThirdNpcActionMessageDecoder extends MessageDecoder<ThirdNpcA
|
||||
@Override
|
||||
public ThirdNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getSigned(DataType.SHORT);
|
||||
int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
return new ThirdNpcActionMessage(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.FifthNpcActionMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link FifthNpcActionMessage}.
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class FifthNpcActionMessageDecoder extends MessageDecoder<FifthNpcActionMessage> {
|
||||
|
||||
@Override
|
||||
public FifthNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new FifthNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.FirstNpcActionMessage;
|
||||
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.GamePacketReader;
|
||||
import org.apollo.net.codec.game.*;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
@@ -14,11 +11,11 @@ import org.apollo.net.release.MessageDecoder;
|
||||
*/
|
||||
public final class FirstNpcActionMessageDecoder extends MessageDecoder<FirstNpcActionMessage> {
|
||||
|
||||
@Override
|
||||
public FirstNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new FirstNpcActionMessage(index);
|
||||
}
|
||||
@Override
|
||||
public FirstNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new FirstNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.FourthNpcActionMessage;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link FourthNpcActionMessage}.
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class FourthNpcActionMessageDecoder extends MessageDecoder<FourthNpcActionMessage> {
|
||||
|
||||
@Override
|
||||
public FourthNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT);
|
||||
return new FourthNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.MagicOnNpcMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
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.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link MagicOnNpcMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MagicOnNpcMessageDecoder extends MessageDecoder<MagicOnNpcMessage> {
|
||||
|
||||
@Override
|
||||
public MagicOnNpcMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
int spell = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
|
||||
return new MagicOnNpcMessage(index, spell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.MagicOnPlayerMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
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.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageDecoder} for the {@link MagicOnPlayerMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MagicOnPlayerMessageDecoder extends MessageDecoder<MagicOnPlayerMessage> {
|
||||
|
||||
@Override
|
||||
public MagicOnPlayerMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
int spell = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
|
||||
return new MagicOnPlayerMessage(index, spell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,26 +7,25 @@ import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
* A {@link org.apollo.net.release.MessageDecoder} for the {@link org.apollo.game.message.impl.MouseClickedMessage}
|
||||
* A {@link MessageDecoder} for the {@link MouseClickedMessage}
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public final class MouseClickedMessageDecoder extends MessageDecoder<MouseClickedMessage> {
|
||||
|
||||
@Override
|
||||
public MouseClickedMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int value = (int)reader.getUnsigned(DataType.INT);
|
||||
@Override
|
||||
public MouseClickedMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int value = (int) reader.getUnsigned(DataType.INT);
|
||||
|
||||
long delay = (value >> 20) * 50;
|
||||
long delay = (value >> 20) * 50;
|
||||
boolean right = ((value >> 19) & 0x1) == 1;
|
||||
|
||||
boolean rightMouseButton = ((value >> 19) & 0x1) == 1;
|
||||
int cords = (value & 0x3FFFF);
|
||||
int x = cords % 765;
|
||||
int y = cords / 765;
|
||||
|
||||
int cords = (value & 0x3FFFF);
|
||||
int x = cords % 765;
|
||||
int y = cords / 765;
|
||||
|
||||
return new MouseClickedMessage(delay, rightMouseButton, x, y);
|
||||
}
|
||||
return new MouseClickedMessage(delay, right, x, y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -128,6 +128,8 @@ public final class Release377 extends Release {
|
||||
|
||||
register(1, new ItemOnItemMessageDecoder());
|
||||
register(36, new MagicOnItemMessageDecoder());
|
||||
register(31, new MagicOnPlayerMessageDecoder());
|
||||
register(104, new MagicOnNpcMessageDecoder());
|
||||
|
||||
register(187, new FocusUpdateMessageDecoder());
|
||||
register(19, new MouseClickedMessageDecoder());
|
||||
@@ -139,9 +141,12 @@ public final class Release377 extends Release {
|
||||
register(40, spamMessageDecoder);
|
||||
register(244, spamMessageDecoder);
|
||||
|
||||
register(67, new FirstNpcActionMessageDecoder());
|
||||
register(112, new SecondNpcActionMessageDecoder());
|
||||
register(112, new FirstNpcActionMessageDecoder());
|
||||
register(67, new SecondNpcActionMessageDecoder());
|
||||
register(13, new ThirdNpcActionMessageDecoder());
|
||||
register(42, new FourthNpcActionMessageDecoder());
|
||||
register(8, new FifthNpcActionMessageDecoder());
|
||||
|
||||
register(71, new TakeTileItemMessageDecoder());
|
||||
register(152, new ItemOnObjectMessageDecoder());
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.message.impl.SecondNpcActionMessage;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.codec.game.*;
|
||||
import org.apollo.net.release.MessageDecoder;
|
||||
|
||||
/**
|
||||
@@ -16,9 +13,9 @@ public final class SecondNpcActionMessageDecoder extends MessageDecoder<SecondNp
|
||||
|
||||
@Override
|
||||
public SecondNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new SecondNpcActionMessage(index);
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getSigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new SecondNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,9 +17,9 @@ public final class ThirdNpcActionMessageDecoder extends MessageDecoder<ThirdNpcA
|
||||
|
||||
@Override
|
||||
public ThirdNpcActionMessage decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
return new ThirdNpcActionMessage(index);
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
return new ThirdNpcActionMessage(index);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user