mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Revert ServerMessage release/retain.
This commit is contained in:
parent
40818513aa
commit
492c8f6142
@ -35,18 +35,12 @@ public class EventCommand extends Command {
|
||||
|
||||
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 {
|
||||
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();
|
||||
habbo.getClient().sendResponse(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -24,17 +24,13 @@ public class HotelAlertCommand extends Command {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
} finally {
|
||||
msg.release();
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
if (habbo.getHabboStats().blockStaffAlerts)
|
||||
continue;
|
||||
|
||||
habbo.getClient().sendResponse(msg);
|
||||
}
|
||||
} else {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT);
|
||||
|
@ -32,25 +32,21 @@ public class MassBadgeCommand extends Command {
|
||||
keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
|
||||
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
|
||||
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()) {
|
||||
if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
|
||||
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
|
||||
if (b != null) {
|
||||
habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
|
||||
if (habbo.isOnline()) {
|
||||
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;
|
||||
|
@ -60,26 +60,20 @@ public class MassGiftCommand extends Command {
|
||||
ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
giftNotificiationMessage.retain();
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
|
||||
try {
|
||||
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, "");
|
||||
|
||||
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();
|
||||
extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
|
||||
Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
|
||||
|
||||
Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
|
||||
|
||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
habbo.getClient().sendResponse(giftNotificiationMessage);
|
||||
}
|
||||
} finally {
|
||||
giftNotificiationMessage.release();
|
||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
habbo.getClient().sendResponse(giftNotificiationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -24,13 +24,8 @@ public class ReloadRoomCommand extends Command {
|
||||
Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
|
||||
room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
|
||||
ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
|
||||
message.retain();
|
||||
try {
|
||||
for (Habbo habbo : habbos) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
for (Habbo habbo : habbos) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
@ -96,7 +96,7 @@ public class GameClient {
|
||||
return;
|
||||
}
|
||||
|
||||
this.channel.write(response.retain(), this.channel.voidPromise());
|
||||
this.channel.write(response, this.channel.voidPromise());
|
||||
this.channel.flush();
|
||||
}
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class GameClient {
|
||||
return;
|
||||
}
|
||||
|
||||
this.channel.write(response.retain());
|
||||
this.channel.write(response);
|
||||
}
|
||||
|
||||
this.channel.flush();
|
||||
|
@ -134,47 +134,32 @@ public class GameClientManager {
|
||||
|
||||
|
||||
public void sendBroadcastResponse(ServerMessage message) {
|
||||
message.retain();
|
||||
try {
|
||||
for (GameClient client : this.clients.values()) {
|
||||
client.sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
for (GameClient client : this.clients.values()) {
|
||||
client.sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendBroadcastResponse(ServerMessage message, GameClient exclude) {
|
||||
message.retain();
|
||||
try {
|
||||
for (GameClient client : this.clients.values()) {
|
||||
if (client.equals(exclude))
|
||||
continue;
|
||||
for (GameClient client : this.clients.values()) {
|
||||
if (client.equals(exclude))
|
||||
continue;
|
||||
|
||||
client.sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
client.sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) {
|
||||
message.retain();
|
||||
try {
|
||||
for (GameClient client : this.clients.values()) {
|
||||
if (client.equals(exclude))
|
||||
continue;
|
||||
for (GameClient client : this.clients.values()) {
|
||||
if (client.equals(exclude))
|
||||
continue;
|
||||
|
||||
if (client.getHabbo() != null) {
|
||||
if (client.getHabbo().hasPermission(minPermission)) {
|
||||
client.sendResponse(message);
|
||||
}
|
||||
if (client.getHabbo() != null) {
|
||||
if (client.getHabbo().hasPermission(minPermission)) {
|
||||
client.sendResponse(message);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
}
|
@ -3115,107 +3115,69 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
roomChatMessage.setMessage(trimmedMessage);
|
||||
|
||||
if (prefixMessage != null) {
|
||||
prefixMessage.retain();
|
||||
}
|
||||
|
||||
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 (chatType == RoomChatType.WHISPER) {
|
||||
if (roomChatMessage.getTargetHabbo() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clearPrefixMessage != null) {
|
||||
clearPrefixMessage.release();
|
||||
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();
|
||||
|
||||
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) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (habbo.getClient() == null) {
|
||||
this.removeHabbo(habbo, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(message);
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (habbo.getClient() == null) {
|
||||
this.removeHabbo(habbo, true);
|
||||
continue;
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendComposerToHabbosWithRights(ServerMessage message) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (this.hasRights(habbo)) {
|
||||
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) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (!habbo.getHabboStats().ignorePets)
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (!habbo.getHabboStats().ignorePets)
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3813,15 +3757,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (!habbo.getHabboStats().ignoreBots)
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (!habbo.getHabboStats().ignoreBots)
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
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.inventory.AddHabboItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||
@ -311,16 +310,8 @@ public class RoomTrade {
|
||||
}
|
||||
|
||||
public void sendMessageToUsers(MessageComposer message) {
|
||||
ServerMessage messageComposed = message.compose();
|
||||
|
||||
messageComposed.retain();
|
||||
|
||||
try {
|
||||
for (RoomTradeUser roomTradeUser : this.users) {
|
||||
roomTradeUser.getHabbo().getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
messageComposed.release();
|
||||
for (RoomTradeUser roomTradeUser : this.users) {
|
||||
roomTradeUser.getHabbo().getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,15 +179,10 @@ public class HabboManager {
|
||||
|
||||
public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) {
|
||||
synchronized (this.onlineHabbos) {
|
||||
message.retain();
|
||||
try {
|
||||
for (Habbo habbo : this.onlineHabbos.values()) {
|
||||
if (habbo.hasPermission(perm)) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
for (Habbo habbo : this.onlineHabbos.values()) {
|
||||
if (habbo.hasPermission(perm)) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,13 @@ import com.eu.habbo.util.PacketUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import io.netty.util.ReferenceCounted;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ServerMessage implements ReferenceCounted {
|
||||
public class ServerMessage {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ServerMessage.class);
|
||||
private boolean initialized;
|
||||
@ -35,6 +33,7 @@ public class ServerMessage implements ReferenceCounted {
|
||||
throw new ServerMessageException("ServerMessage was already initialized.");
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
this.header = id;
|
||||
this.refs = new AtomicInteger(0);
|
||||
this.channelBuffer = Unpooled.buffer();
|
||||
@ -186,51 +185,4 @@ public class ServerMessage implements ReferenceCounted {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -148,13 +148,8 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
|
||||
Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
|
||||
room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
|
||||
ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
|
||||
message.retain();
|
||||
try {
|
||||
for (Habbo habbo : habbos) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
for (Habbo habbo : habbos) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,17 +25,12 @@ public class HotelAlert extends RCONMessage<HotelAlert.JSONHotelAlert> {
|
||||
}
|
||||
|
||||
if (serverMessage != null) {
|
||||
serverMessage.retain();
|
||||
try {
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
if (habbo.getHabboStats().blockStaffAlerts)
|
||||
continue;
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
if (habbo.getHabboStats().blockStaffAlerts)
|
||||
continue;
|
||||
|
||||
habbo.getClient().sendResponse(serverMessage);
|
||||
}
|
||||
} finally {
|
||||
serverMessage.release();
|
||||
habbo.getClient().sendResponse(serverMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,17 +43,13 @@ public class ImageHotelAlert extends RCONMessage<ImageHotelAlert.JSON> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
if (habbo.getHabboStats().blockStaffAlerts)
|
||||
continue;
|
||||
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,6 @@ public class GameServer extends Server {
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
ch.pipeline().addLast("logger", new LoggingHandler());
|
||||
|
||||
// Logger.
|
||||
|
||||
|
||||
// Decoders.
|
||||
ch.pipeline().addLast(new GamePolicyDecoder());
|
||||
ch.pipeline().addLast(new GameByteFrameDecoder());
|
||||
|
@ -63,14 +63,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter {
|
||||
if (cause instanceof TooLongFrameException) {
|
||||
LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\".");
|
||||
} else {
|
||||
cause.printStackTrace();
|
||||
|
||||
LOGGER.error("Disconnecting client, exception in GameMessageHander:");
|
||||
LOGGER.error(cause.toString());
|
||||
|
||||
for (StackTraceElement element : cause.getStackTrace()) {
|
||||
LOGGER.error(element.toString());
|
||||
}
|
||||
LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause);
|
||||
}
|
||||
|
||||
ctx.channel().close();
|
||||
|
@ -27,7 +27,7 @@ public class GameServerMessageLogger extends MessageToMessageEncoder<ServerMessa
|
||||
this.names.getOutgoingName(message.getHeader()),
|
||||
message.getBodyString()));
|
||||
|
||||
out.add(message.retain());
|
||||
out.add(message);
|
||||
}
|
||||
|
||||
}
|
@ -38,19 +38,13 @@ public class CannonKickAction implements Runnable {
|
||||
|
||||
ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose();
|
||||
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (RoomTile t : tiles) {
|
||||
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
|
||||
if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) {
|
||||
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
|
||||
habbo.getClient().sendResponse(message); //kicked composer
|
||||
}
|
||||
for (RoomTile t : tiles) {
|
||||
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user