Search in sources :

Example 1 with FlaggedMouseEventMessage

use of org.apollo.game.message.impl.FlaggedMouseEventMessage in project apollo by apollo-rsps.

the class FlaggedMouseEventMessageDecoder method decode.

@Override
public FlaggedMouseEventMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int read, clicks, x, y;
    if (reader.getLength() == 2) {
        read = (int) reader.getUnsigned(DataType.SHORT);
        clicks = read >> 12;
        x = read >> 6 & 0x3f;
        y = read & 0x3f;
        return new FlaggedMouseEventMessage(clicks, x, y, true);
    } else if (reader.getLength() == 3) {
        read = (int) reader.getUnsigned(DataType.TRI_BYTE) & ~0x800000;
    } else {
        read = (int) reader.getUnsigned(DataType.INT) & ~0xc0000000;
    }
    clicks = read >> 19;
    x = (read & 0x7f) % 765;
    y = (read & 0x7f) / 765;
    return new FlaggedMouseEventMessage(clicks, x, y, false);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) FlaggedMouseEventMessage(org.apollo.game.message.impl.FlaggedMouseEventMessage)

Example 2 with FlaggedMouseEventMessage

use of org.apollo.game.message.impl.FlaggedMouseEventMessage in project apollo by apollo-rsps.

the class FlaggedMouseEventMessageDecoder method decode.

@Override
public FlaggedMouseEventMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int read;
    if (reader.getLength() == 2) {
        read = (int) reader.getUnsigned(DataType.SHORT);
        int clicks = read >> 12;
        int dX = read >> 6 & 0x3f;
        int dY = read & 0x3f;
        return new FlaggedMouseEventMessage(clicks, dX, dY, true);
    } else if (reader.getLength() == 3) {
        read = (int) reader.getUnsigned(DataType.TRI_BYTE) & ~0x800000;
    } else {
        read = (int) reader.getUnsigned(DataType.INT) & ~0xc0000000;
    }
    int clicks = read >> 19;
    int x = (read & 0x7f) % 765;
    int y = (read & 0x7f) / 765;
    return new FlaggedMouseEventMessage(clicks, x, y, false);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) FlaggedMouseEventMessage(org.apollo.game.message.impl.FlaggedMouseEventMessage)

Aggregations

FlaggedMouseEventMessage (org.apollo.game.message.impl.FlaggedMouseEventMessage)2 GamePacketReader (org.apollo.net.codec.game.GamePacketReader)2