diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java index 3faa3313..698f480c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index fc549cb9..0439a1ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; +import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import java.sql.ResultSet; import java.sql.SQLException; @@ -66,7 +66,7 @@ public class PetCommand implements Comparable { } pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, this.action.gestureToSet); - pet.getRoom().sendComposer(new RoomUserStatusComposer(pet.getRoomUnit()).compose()); + pet.getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); pet.addEnergy(-this.energyCost); pet.addHappyness(-this.happynessCost); pet.addExperience(this.xp); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java index 3475237c..5829f69f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java @@ -51,7 +51,7 @@ public class SetStackHelperHeightEvent extends MessageHandler { item.needsUpdate(true); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HeightMapUpdateMessageComposer(room, tiles).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HeightMapUpdateMessageComposer (room, tiles).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java new file mode 100644 index 00000000..4be988f5 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/HeightMapUpdateMessageComposer.java @@ -0,0 +1,82 @@ +package com.eu.habbo.messages.outgoing.rooms; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.MessageComposer; +import com.eu.habbo.messages.outgoing.Outgoing; +import gnu.trove.set.hash.THashSet; + +public class HeightMapUpdateMessageComposer extends MessageComposer { + private int x; + private int y; + private short z; + private double height; + + private THashSet updateTiles; + private Room room; + + public HeightMapUpdateMessageComposer(int x, int y, short z, double height) { + this.x = x; + this.y = y; + this.z = z; + this.height = height; + } + + public HeightMapUpdateMessageComposer(Room room, THashSet updateTiles) { + this.updateTiles = updateTiles; + this.room = room; + } + + @Override + protected ServerMessage composeInternal() { + //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done + this.response.init(Outgoing.HeightMapUpdateMessageComposer); + if (this.updateTiles != null) { + // prevent overflow. Byte max value is 127 + if(this.updateTiles.size() > 127) { + RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); + this.response.appendByte(127); + for(int i = 0; i < 127; i++) { + RoomTile t = tiles[i]; + updateTiles.remove(t); // remove it from the set + this.response.appendByte((int) t.x); + this.response.appendByte((int) t.y); + if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { + this.response.appendShort((short) (t.z * 256.0)); + } + else { + this.response.appendShort(t.relativeHeight()); + } + } + //send the remaining tiles in a new message + this.room.sendComposer(new HeightMapUpdateMessageComposer(this.room, updateTiles).compose()); + return this.response; + } + + this.response.appendByte(this.updateTiles.size()); + for (RoomTile t : this.updateTiles) { + this.response.appendByte((int) t.x); + this.response.appendByte((int) t.y); + if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { + this.response.appendShort((short) (t.z * 256.0)); + } + else { + this.response.appendShort(t.relativeHeight()); + } + } + } else { + this.response.appendByte(1); + this.response.appendByte(this.x); + this.response.appendByte(this.y); + if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { + this.response.appendShort((short) (this.z * 256.0)); + } + else { + this.response.appendShort((int) (this.height)); + } + } + return this.response; + } +}