package NET.worlds.network; import NET.worlds.scape.Drone; import NET.worlds.scape.Room; import java.io.IOException; public class roomChangeCmd extends receivedNetPacket { public static final byte ROOMCHNGCMD = 5; protected int _roomID; protected short _x; protected short _y; protected short _z; protected short _direction; public roomChangeCmd() { this._commandType = 5; } public roomChangeCmd(Room room, short x, short y, short z, short direction) { super(null, 5); this._roomID = room.getNetworkRoom().getRoomID(); assert this._roomID != 0; this._x = x; this._y = y; this._z = z; this._direction = direction; } @Override void parseNetData(ServerInputStream data) throws IOException { this._roomID = data.readUnsignedShort(); this._x = data.readShort(); this._y = data.readShort(); this._z = data.readShort(); this._direction = data.readShort(); } @Override int packetSize() { return 10 + super.packetSize(); } @Override void send(ServerOutputStream o) throws IOException { super.send(o); o.writeShort(this._roomID); o.writeShort(this._x); o.writeShort(this._y); o.writeShort(this._z); o.writeShort(this._direction); } @Override void process(WorldServer _serv) throws Exception { NetworkObject o = _serv.getObject(this._objID); if (o instanceof Drone) { assert this._roomID != 0; Room newroom = null; NetworkRoom netroom = _serv.getNetworkRoom(this._roomID); if (netroom != null) { newroom = netroom.getRoom(); } this._direction = (short)(90 - this._direction); this._direction = (short)(360 - this._direction); ((Drone)o).roomChange(newroom, this._x, this._y, this._z, this._direction); } } @Override public String toString(WorldServer serv) { return "ROOMCHNG " + this._objID.toString(serv) + " in " + this._roomID + " @ " + this._x + "," + this._y + "," + this._z + "," + this._direction; } }