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