Revert ServerMessage release/retain.

This commit is contained in:
Mike 2020-05-13 20:55:07 +02:00
parent 40818513aa
commit 492c8f6142
18 changed files with 148 additions and 342 deletions

View File

@ -35,18 +35,12 @@ public class EventCommand extends Command {
ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose(); ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose();
msg.retain(); for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
try { habbo.getClient().sendResponse(msg);
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(msg);
}
} finally {
msg.release();
} }
return true; return true;

View File

@ -24,17 +24,13 @@ public class HotelAlertCommand extends Command {
} }
ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose(); ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose();
msg.retain();
try {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(msg); for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
} Habbo habbo = set.getValue();
} finally { if (habbo.getHabboStats().blockStaffAlerts)
msg.release(); continue;
habbo.getClient().sendResponse(msg);
} }
} else { } else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT);

View File

@ -32,25 +32,21 @@ public class MassBadgeCommand extends Command {
keys.put("image", "${image.library.url}album1584/" + badge + ".gif"); keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
message.retain();
try {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
if (habbo.isOnline()) { for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { Habbo habbo = set.getValue();
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
if (b != null) { if (habbo.isOnline()) {
habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
habbo.getClient().sendResponse(message); if (b != null) {
} habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
habbo.getClient().sendResponse(message);
} }
} }
} }
} finally {
message.release();
} }
} }
return true; return true;

View File

@ -60,26 +60,20 @@ public class MassGiftCommand extends Command {
ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
giftNotificiationMessage.retain(); for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
try { HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId();
extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
String extraData = "1\t" + item.getId(); Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(giftNotificiationMessage);
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(giftNotificiationMessage);
}
} finally {
giftNotificiationMessage.release();
} }
}); });

View File

@ -24,13 +24,8 @@ public class ReloadRoomCommand extends Command {
Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
message.retain(); for (Habbo habbo : habbos) {
try { habbo.getClient().sendResponse(message);
for (Habbo habbo : habbos) {
habbo.getClient().sendResponse(message);
}
} finally {
message.release();
} }
} }
}, 100); }, 100);

View File

@ -96,7 +96,7 @@ public class GameClient {
return; return;
} }
this.channel.write(response.retain(), this.channel.voidPromise()); this.channel.write(response, this.channel.voidPromise());
this.channel.flush(); this.channel.flush();
} }
} }
@ -108,7 +108,7 @@ public class GameClient {
return; return;
} }
this.channel.write(response.retain()); this.channel.write(response);
} }
this.channel.flush(); this.channel.flush();

View File

@ -134,47 +134,32 @@ public class GameClientManager {
public void sendBroadcastResponse(ServerMessage message) { public void sendBroadcastResponse(ServerMessage message) {
message.retain(); for (GameClient client : this.clients.values()) {
try { client.sendResponse(message);
for (GameClient client : this.clients.values()) {
client.sendResponse(message);
}
} finally {
message.release();
} }
} }
public void sendBroadcastResponse(ServerMessage message, GameClient exclude) { public void sendBroadcastResponse(ServerMessage message, GameClient exclude) {
message.retain(); for (GameClient client : this.clients.values()) {
try { if (client.equals(exclude))
for (GameClient client : this.clients.values()) { continue;
if (client.equals(exclude))
continue;
client.sendResponse(message); client.sendResponse(message);
}
} finally {
message.release();
} }
} }
public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) { public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) {
message.retain(); for (GameClient client : this.clients.values()) {
try { if (client.equals(exclude))
for (GameClient client : this.clients.values()) { continue;
if (client.equals(exclude))
continue;
if (client.getHabbo() != null) { if (client.getHabbo() != null) {
if (client.getHabbo().hasPermission(minPermission)) { if (client.getHabbo().hasPermission(minPermission)) {
client.sendResponse(message); client.sendResponse(message);
}
} }
} }
} finally {
message.release();
} }
} }
} }

View File

@ -3115,107 +3115,69 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
roomChatMessage.setMessage(trimmedMessage); roomChatMessage.setMessage(trimmedMessage);
if (prefixMessage != null) { if (chatType == RoomChatType.WHISPER) {
prefixMessage.retain(); if (roomChatMessage.getTargetHabbo() == null) {
} return;
if (clearPrefixMessage != null) {
clearPrefixMessage.retain();
}
try {
if (chatType == RoomChatType.WHISPER) {
if (roomChatMessage.getTargetHabbo() == null) {
return;
}
RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage);
staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage());
final ServerMessage message = new RoomUserWhisperComposer(roomChatMessage).compose();
final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose();
message.retain();
staffMessage.retain();
try {
for (Habbo h : this.getHabbos()) {
if (h == roomChatMessage.getTargetHabbo() || h == habbo) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
if (prefixMessage != null) {
h.getClient().sendResponse(prefixMessage);
}
h.getClient().sendResponse(message);
if (clearPrefixMessage != null) {
h.getClient().sendResponse(clearPrefixMessage);
}
}
continue;
}
if (h.hasPermission("acc_see_whispers")) {
h.getClient().sendResponse(staffMessage);
}
}
} finally {
message.release();
staffMessage.release();
}
} else if (chatType == RoomChatType.TALK) {
ServerMessage message = new RoomUserTalkComposer(roomChatMessage).compose();
boolean noChatLimit = habbo.hasPermission("acc_chat_no_limit");
message.retain();
try {
for (Habbo h : this.getHabbos()) {
if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance ||
h.equals(habbo) ||
this.hasRights(h) ||
noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
if (prefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(prefixMessage);
}
h.getClient().sendResponse(message);
if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(clearPrefixMessage);
}
}
}
}
} finally {
message.release();
}
} else if (chatType == RoomChatType.SHOUT) {
ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose();
message.retain();
try {
for (Habbo h : this.getHabbos()) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) {
if (prefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(prefixMessage);
}
h.getClient().sendResponse(message);
if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(clearPrefixMessage);
}
}
}
} finally {
message.release();
}
}
} finally {
if (prefixMessage != null) {
prefixMessage.release();
} }
if (clearPrefixMessage != null) { RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage);
clearPrefixMessage.release(); staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage());
final ServerMessage message = new RoomUserWhisperComposer(roomChatMessage).compose();
final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose();
for (Habbo h : this.getHabbos()) {
if (h == roomChatMessage.getTargetHabbo() || h == habbo) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
if (prefixMessage != null) {
h.getClient().sendResponse(prefixMessage);
}
h.getClient().sendResponse(message);
if (clearPrefixMessage != null) {
h.getClient().sendResponse(clearPrefixMessage);
}
}
continue;
}
if (h.hasPermission("acc_see_whispers")) {
h.getClient().sendResponse(staffMessage);
}
}
} else if (chatType == RoomChatType.TALK) {
ServerMessage message = new RoomUserTalkComposer(roomChatMessage).compose();
boolean noChatLimit = habbo.hasPermission("acc_chat_no_limit");
for (Habbo h : this.getHabbos()) {
if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance ||
h.equals(habbo) ||
this.hasRights(h) ||
noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
if (prefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(prefixMessage);
}
h.getClient().sendResponse(message);
if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(clearPrefixMessage);
}
}
}
}
} else if (chatType == RoomChatType.SHOUT) {
ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose();
for (Habbo h : this.getHabbos()) {
if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) {
if (prefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(prefixMessage);
}
h.getClient().sendResponse(message);
if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) {
h.getClient().sendResponse(clearPrefixMessage);
}
}
} }
} }
@ -3765,46 +3727,28 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void sendComposer(ServerMessage message) { public void sendComposer(ServerMessage message) {
message.retain(); for (Habbo habbo : this.getHabbos()) {
if (habbo.getClient() == null) {
try { this.removeHabbo(habbo, true);
for (Habbo habbo : this.getHabbos()) { continue;
if (habbo.getClient() == null) {
this.removeHabbo(habbo, true);
continue;
}
habbo.getClient().sendResponse(message);
} }
} finally {
message.release(); habbo.getClient().sendResponse(message);
} }
} }
public void sendComposerToHabbosWithRights(ServerMessage message) { public void sendComposerToHabbosWithRights(ServerMessage message) {
message.retain(); for (Habbo habbo : this.getHabbos()) {
if (this.hasRights(habbo)) {
try { habbo.getClient().sendResponse(message);
for (Habbo habbo : this.getHabbos()) {
if (this.hasRights(habbo)) {
habbo.getClient().sendResponse(message);
}
} }
} finally {
message.release();
} }
} }
public void petChat(ServerMessage message) { public void petChat(ServerMessage message) {
message.retain(); for (Habbo habbo : this.getHabbos()) {
if (!habbo.getHabboStats().ignorePets)
try { habbo.getClient().sendResponse(message);
for (Habbo habbo : this.getHabbos()) {
if (!habbo.getHabboStats().ignorePets)
habbo.getClient().sendResponse(message);
}
} finally {
message.release();
} }
} }
@ -3813,15 +3757,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return; return;
} }
message.retain(); for (Habbo habbo : this.getHabbos()) {
if (!habbo.getHabboStats().ignoreBots)
try { habbo.getClient().sendResponse(message);
for (Habbo habbo : this.getHabbos()) {
if (!habbo.getHabboStats().ignoreBots)
habbo.getClient().sendResponse(message);
}
} finally {
message.release();
} }
} }

View File

@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
@ -311,16 +310,8 @@ public class RoomTrade {
} }
public void sendMessageToUsers(MessageComposer message) { public void sendMessageToUsers(MessageComposer message) {
ServerMessage messageComposed = message.compose(); for (RoomTradeUser roomTradeUser : this.users) {
roomTradeUser.getHabbo().getClient().sendResponse(message);
messageComposed.retain();
try {
for (RoomTradeUser roomTradeUser : this.users) {
roomTradeUser.getHabbo().getClient().sendResponse(message);
}
} finally {
messageComposed.release();
} }
} }

View File

@ -179,15 +179,10 @@ public class HabboManager {
public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) { public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) {
synchronized (this.onlineHabbos) { synchronized (this.onlineHabbos) {
message.retain(); for (Habbo habbo : this.onlineHabbos.values()) {
try { if (habbo.hasPermission(perm)) {
for (Habbo habbo : this.onlineHabbos.values()) { habbo.getClient().sendResponse(message);
if (habbo.hasPermission(perm)) {
habbo.getClient().sendResponse(message);
}
} }
} finally {
message.release();
} }
} }
} }

View File

@ -4,15 +4,13 @@ import com.eu.habbo.util.PacketUtils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.util.IllegalReferenceCountException;
import io.netty.util.ReferenceCounted;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class ServerMessage implements ReferenceCounted { public class ServerMessage {
private static final Logger LOGGER = LoggerFactory.getLogger(ServerMessage.class); private static final Logger LOGGER = LoggerFactory.getLogger(ServerMessage.class);
private boolean initialized; private boolean initialized;
@ -35,6 +33,7 @@ public class ServerMessage implements ReferenceCounted {
throw new ServerMessageException("ServerMessage was already initialized."); throw new ServerMessageException("ServerMessage was already initialized.");
} }
this.initialized = true;
this.header = id; this.header = id;
this.refs = new AtomicInteger(0); this.refs = new AtomicInteger(0);
this.channelBuffer = Unpooled.buffer(); this.channelBuffer = Unpooled.buffer();
@ -186,51 +185,4 @@ public class ServerMessage implements ReferenceCounted {
return this.channelBuffer.copy(); return this.channelBuffer.copy();
} }
@Override
public int refCnt() {
return this.refs.get();
}
@Override
public ReferenceCounted retain() {
this.refs.incrementAndGet();
return this;
}
@Override
public ReferenceCounted retain(int i) {
this.refs.addAndGet(i);
return this;
}
@Override
public ReferenceCounted touch() {
return this;
}
@Override
public ReferenceCounted touch(Object o) {
return this;
}
@Override
public boolean release() {
return this.release(1);
}
@Override
public boolean release(int i) {
int value = this.refs.addAndGet(-i);
if (value < 0) {
throw new IllegalReferenceCountException("Decremented below 0 (packet " + this.header + " value " + value + ").");
}
if (value == 0) {
this.channelBuffer.release(this.channelBuffer.refCnt());
return true;
}
return false;
}
} }

View File

@ -148,13 +148,8 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
message.retain(); for (Habbo habbo : habbos) {
try { habbo.getClient().sendResponse(message);
for (Habbo habbo : habbos) {
habbo.getClient().sendResponse(message);
}
} finally {
message.release();
} }
} }
} }

View File

@ -25,17 +25,12 @@ public class HotelAlert extends RCONMessage<HotelAlert.JSONHotelAlert> {
} }
if (serverMessage != null) { if (serverMessage != null) {
serverMessage.retain(); for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
try { Habbo habbo = set.getValue();
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { if (habbo.getHabboStats().blockStaffAlerts)
Habbo habbo = set.getValue(); continue;
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(serverMessage); habbo.getClient().sendResponse(serverMessage);
}
} finally {
serverMessage.release();
} }
} }
} }

View File

@ -43,17 +43,13 @@ public class ImageHotelAlert extends RCONMessage<ImageHotelAlert.JSON> {
} }
ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose(); ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose();
message.retain();
try {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(message); for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
} Habbo habbo = set.getValue();
} finally { if (habbo.getHabboStats().blockStaffAlerts)
message.release(); continue;
habbo.getClient().sendResponse(message);
} }
} }

View File

@ -30,9 +30,6 @@ public class GameServer extends Server {
public void initChannel(SocketChannel ch) throws Exception { public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("logger", new LoggingHandler()); ch.pipeline().addLast("logger", new LoggingHandler());
// Logger.
// Decoders. // Decoders.
ch.pipeline().addLast(new GamePolicyDecoder()); ch.pipeline().addLast(new GamePolicyDecoder());
ch.pipeline().addLast(new GameByteFrameDecoder()); ch.pipeline().addLast(new GameByteFrameDecoder());

View File

@ -63,14 +63,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter {
if (cause instanceof TooLongFrameException) { if (cause instanceof TooLongFrameException) {
LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\".");
} else { } else {
cause.printStackTrace(); LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause);
LOGGER.error("Disconnecting client, exception in GameMessageHander:");
LOGGER.error(cause.toString());
for (StackTraceElement element : cause.getStackTrace()) {
LOGGER.error(element.toString());
}
} }
ctx.channel().close(); ctx.channel().close();

View File

@ -27,7 +27,7 @@ public class GameServerMessageLogger extends MessageToMessageEncoder<ServerMessa
this.names.getOutgoingName(message.getHeader()), this.names.getOutgoingName(message.getHeader()),
message.getBodyString())); message.getBodyString()));
out.add(message.retain()); out.add(message);
} }
} }

View File

@ -38,19 +38,13 @@ public class CannonKickAction implements Runnable {
ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose(); ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose();
message.retain(); for (RoomTile t : tiles) {
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
try { if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) {
for (RoomTile t : tiles) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) { habbo.getClient().sendResponse(message); //kicked composer
if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) {
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
habbo.getClient().sendResponse(message); //kicked composer
}
} }
} }
} finally {
message.release();
} }
} }
} }