mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Revert ServerMessage release/retain.
This commit is contained in:
parent
40818513aa
commit
492c8f6142
@ -35,9 +35,6 @@ public class EventCommand extends Command {
|
||||
|
||||
ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose();
|
||||
|
||||
msg.retain();
|
||||
|
||||
try {
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
if (habbo.getHabboStats().blockStaffAlerts)
|
||||
@ -45,9 +42,6 @@ public class EventCommand extends Command {
|
||||
|
||||
habbo.getClient().sendResponse(msg);
|
||||
}
|
||||
} finally {
|
||||
msg.release();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ 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)
|
||||
@ -33,9 +32,6 @@ public class HotelAlertCommand extends Command {
|
||||
|
||||
habbo.getClient().sendResponse(msg);
|
||||
}
|
||||
} finally {
|
||||
msg.release();
|
||||
}
|
||||
} else {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ 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();
|
||||
|
||||
@ -49,9 +48,6 @@ public class MassBadgeCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -60,9 +60,6 @@ public class MassGiftCommand extends Command {
|
||||
ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
giftNotificiationMessage.retain();
|
||||
|
||||
try {
|
||||
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
||||
Habbo habbo = set.getValue();
|
||||
|
||||
@ -78,9 +75,6 @@ public class MassGiftCommand extends Command {
|
||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
habbo.getClient().sendResponse(giftNotificiationMessage);
|
||||
}
|
||||
} finally {
|
||||
giftNotificiationMessage.release();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -24,14 +24,9 @@ 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();
|
||||
}
|
||||
}
|
||||
}, 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,35 +134,23 @@ public class GameClientManager {
|
||||
|
||||
|
||||
public void sendBroadcastResponse(ServerMessage message) {
|
||||
message.retain();
|
||||
try {
|
||||
for (GameClient client : this.clients.values()) {
|
||||
client.sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendBroadcastResponse(ServerMessage message, GameClient exclude) {
|
||||
message.retain();
|
||||
try {
|
||||
for (GameClient client : this.clients.values()) {
|
||||
if (client.equals(exclude))
|
||||
continue;
|
||||
|
||||
client.sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) {
|
||||
message.retain();
|
||||
try {
|
||||
for (GameClient client : this.clients.values()) {
|
||||
if (client.equals(exclude))
|
||||
continue;
|
||||
@ -173,8 +161,5 @@ public class GameClientManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
}
|
@ -3115,15 +3115,6 @@ 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;
|
||||
@ -3135,10 +3126,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
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())) {
|
||||
@ -3158,17 +3145,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
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) ||
|
||||
@ -3185,15 +3165,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
@ -3205,18 +3179,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (prefixMessage != null) {
|
||||
prefixMessage.release();
|
||||
}
|
||||
|
||||
if (clearPrefixMessage != null) {
|
||||
clearPrefixMessage.release();
|
||||
}
|
||||
}
|
||||
|
||||
if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) {
|
||||
@ -3765,9 +3727,6 @@ 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);
|
||||
@ -3776,36 +3735,21 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendComposerToHabbosWithRights(ServerMessage message) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void botChat(ServerMessage message) {
|
||||
@ -3813,16 +3757,10 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadRights(Connection connection) {
|
||||
|
@ -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,17 +310,9 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
public List<RoomTradeUser> getRoomTradeUsers() {
|
||||
|
@ -179,16 +179,11 @@ 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);
|
||||
}
|
||||
}
|
||||
} 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,14 +148,9 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,6 @@ 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)
|
||||
@ -34,9 +32,6 @@ public class HotelAlert extends RCONMessage<HotelAlert.JSONHotelAlert> {
|
||||
|
||||
habbo.getClient().sendResponse(serverMessage);
|
||||
}
|
||||
} finally {
|
||||
serverMessage.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,7 @@ 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)
|
||||
@ -52,9 +51,6 @@ public class ImageHotelAlert extends RCONMessage<ImageHotelAlert.JSON> {
|
||||
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
static class JSON {
|
||||
|
@ -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,9 +38,6 @@ 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)) {
|
||||
@ -49,8 +46,5 @@ public class CannonKickAction implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user