From 1e24df5b6159a56566825332e56a37f4ec636b16 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 00:11:47 +0200 Subject: [PATCH] Use batch item update packet to sync banzai tile flickering (closes #339) --- src/main/java/com/eu/habbo/Emulator.java | 6 +++--- .../outgoing/rooms/items/ItemsDataUpdateComposer.java | 8 ++++++-- .../threading/runnables/BattleBanzaiTilesFlicker.java | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 6999051a..b73fb65f 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -118,13 +118,13 @@ public final class Emulator { Emulator.texts = new TextsManager(); new CleanerThread(); Emulator.gameServer = new GameServer(getConfig().getValue("game.host", "127.0.0.1"), getConfig().getInt("game.port", 30000)); - Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); + //Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); Emulator.gameEnvironment = new GameEnvironment(); Emulator.gameEnvironment.load(); Emulator.gameServer.initializePipeline(); Emulator.gameServer.connect(); - Emulator.rconServer.initializePipeline(); - Emulator.rconServer.connect(); + //Emulator.rconServer.initializePipeline(); + //Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java index aa5244e8..f9c18df7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java @@ -6,11 +6,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; +import java.util.Set; public class ItemsDataUpdateComposer extends MessageComposer { - private final List items; + private final Set items; - public ItemsDataUpdateComposer(List items) { + public ItemsDataUpdateComposer(Set items) { this.items = items; } @@ -18,9 +19,12 @@ public class ItemsDataUpdateComposer extends MessageComposer { public ServerMessage compose() { this.response.init(Outgoing.ItemsDataUpdateComposer); this.response.appendInt(this.items.size()); + for (HabboItem item : this.items) { + this.response.appendInt(item.getId()); item.serializeExtradata(this.response); } + return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java index 345c45be..77eb02ef 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.outgoing.rooms.items.ItemsDataUpdateComposer; import gnu.trove.set.hash.THashSet; public class BattleBanzaiTilesFlicker implements Runnable { @@ -36,9 +37,10 @@ public class BattleBanzaiTilesFlicker implements Runnable { for (HabboItem item : this.items) { item.setExtradata(state + ""); - this.room.updateItem(item); } + this.room.sendComposer(new ItemsDataUpdateComposer(this.items).compose()); + if (this.count == 5) { for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("0");