diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 23f8efaf..c937d10f 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -91,3 +91,6 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.mannequin.name.defa -- RCON: Change Username INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('rcon.alert.user.change_username', 'You can change your username. Click on yourself to change it.'); + +-- Custom Stacking Setting +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('custom.stacking.enabled', '0'); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java index 3662378b..f9508582 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/OpenRecycleBoxEvent.java @@ -3,9 +3,7 @@ package com.eu.habbo.messages.incoming.catalog.recycler; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; -import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; @@ -58,7 +56,15 @@ public class OpenRecycleBoxEvent extends MessageHandler { if (item.getRoomId() == 0) { room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); - room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), room.getStackHeight(item.getX(), item.getY(), true)).compose()); + RoomLayout roomLayout = room.getLayout(); + short z = (short)room.getStackHeight(item.getX(), item.getY(), true); + if(roomLayout != null) { + RoomTile roomTile = roomLayout.getTile(item.getX(), item.getY()); + if(roomTile != null) { + z = roomTile.z; + } + } + room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), z, room.getStackHeight(item.getX(), item.getY(), true)).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java index 20f46659..2d489be7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java @@ -40,7 +40,7 @@ public class RedeemClothingEvent extends MessageHandler { RoomTile tile = this.client.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(item.getX(), item.getY()); this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.relativeHeight()).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.z, tile.relativeHeight()).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item, true).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java index 3533ca6d..fa5ce66b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java @@ -102,7 +102,7 @@ public class RedeemItemEvent extends MessageHandler { RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); t.setStackHeight(room.getStackHeight(item.getX(), item.getY(), false)); room.updateTile(t); - room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), t.relativeHeight()).compose()); + room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), t.z, t.relativeHeight()).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); switch (furniRedeemEvent.currencyID) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java index fd9617c1..9fa2f4cb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPackageNameEvent.java @@ -62,7 +62,7 @@ public class PetPackageNameEvent extends MessageHandler { room.sendComposer(new RemoveFloorItemComposer(item).compose()); RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); - room.sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.relativeHeight()).compose()); + room.sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.z, tile.relativeHeight()).compose()); item.setUserId(0); } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java index 1b31cb35..8236b453 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRelativeMapComposer.java @@ -1,5 +1,6 @@ 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; @@ -22,10 +23,17 @@ public class RoomRelativeMapComposer extends MessageComposer { for (short x = 0; x < this.room.getLayout().getMapSizeX(); x++) { RoomTile t = this.room.getLayout().getTile(x, y); - if (t != null) - this.response.appendShort(t.relativeHeight()); - else + if (t != null) { + if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) { + this.response.appendShort((short) (t.z * 256.0)); + } + else { + this.response.appendShort(t.relativeHeight()); + } + } + else { this.response.appendShort(Short.MAX_VALUE); + } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index 334581c6..a6d5d643 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -1,5 +1,6 @@ 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; @@ -10,14 +11,16 @@ import gnu.trove.set.hash.THashSet; public class UpdateStackHeightComposer extends MessageComposer { private int x; private int y; + private short z; private double height; private THashSet updateTiles; private Room room; - public UpdateStackHeightComposer(int x, int y, double height) { + public UpdateStackHeightComposer(int x, int y, short z, double height) { this.x = x; this.y = y; + this.z = z; this.height = height; } @@ -40,7 +43,12 @@ public class UpdateStackHeightComposer extends MessageComposer { updateTiles.remove(t); // remove it from the set this.response.appendByte((int) t.x); this.response.appendByte((int) t.y); - this.response.appendShort(t.relativeHeight()); + 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 UpdateStackHeightComposer(this.room, updateTiles).compose()); @@ -51,13 +59,23 @@ public class UpdateStackHeightComposer extends MessageComposer { for (RoomTile t : this.updateTiles) { this.response.appendByte((int) t.x); this.response.appendByte((int) t.y); - this.response.appendShort(t.relativeHeight()); + 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); - this.response.appendShort((int) (this.height)); + 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; } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java index f03b76d9..3a5b7aa7 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java @@ -24,6 +24,6 @@ class RemoveFloorItemTask implements Runnable { this.room.removeHabboItem(this.item); this.room.updateTile(tile); this.room.sendComposer(new RemoveFloorItemComposer(this.item, true).compose()); - this.room.sendComposer(new UpdateStackHeightComposer(this.item.getX(), this.item.getY(), tile.relativeHeight()).compose()); + this.room.sendComposer(new UpdateStackHeightComposer(this.item.getX(), this.item.getY(), tile.z, tile.relativeHeight()).compose()); } }