Fix all last edge cases.

This commit is contained in:
Mike 2020-05-10 00:11:56 +02:00
parent 463fb82654
commit 46ff22f720
7 changed files with 146 additions and 90 deletions

View File

@ -24,7 +24,8 @@ 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()) { for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue(); Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts) if (habbo.getHabboStats().blockStaffAlerts)
@ -32,7 +33,9 @@ public class HotelAlertCommand extends Command {
habbo.getClient().sendResponse(msg); habbo.getClient().sendResponse(msg);
} }
} finally {
msg.release();
}
} 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

@ -24,9 +24,14 @@ 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();
try {
for (Habbo habbo : habbos) { for (Habbo habbo : habbos) {
habbo.getClient().sendResponse(message); habbo.getClient().sendResponse(message);
} }
} finally {
message.release();
}
} }
}, 100); }, 100);

View File

@ -134,23 +134,35 @@ public class GameClientManager {
public void sendBroadcastResponse(ServerMessage message) { public void sendBroadcastResponse(ServerMessage message) {
message.retain();
try {
for (GameClient client : this.clients.values()) { for (GameClient client : this.clients.values()) {
client.sendResponse(message); client.sendResponse(message);
} }
} finally {
message.release();
}
} }
public void sendBroadcastResponse(ServerMessage message, GameClient exclude) { public void sendBroadcastResponse(ServerMessage message, GameClient exclude) {
message.retain();
try {
for (GameClient client : this.clients.values()) { for (GameClient client : this.clients.values()) {
if (client.equals(exclude)) if (client.equals(exclude))
continue; 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();
try {
for (GameClient client : this.clients.values()) { for (GameClient client : this.clients.values()) {
if (client.equals(exclude)) if (client.equals(exclude))
continue; continue;
@ -161,5 +173,8 @@ public class GameClientManager {
} }
} }
} }
} finally {
message.release();
}
} }
} }

View File

@ -3115,6 +3115,15 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
roomChatMessage.setMessage(trimmedMessage); roomChatMessage.setMessage(trimmedMessage);
if (prefixMessage != null) {
prefixMessage.retain();
}
if (clearPrefixMessage != null) {
clearPrefixMessage.retain();
}
try {
if (chatType == RoomChatType.WHISPER) { if (chatType == RoomChatType.WHISPER) {
if (roomChatMessage.getTargetHabbo() == null) { if (roomChatMessage.getTargetHabbo() == null) {
return; return;
@ -3200,6 +3209,15 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
message.release(); message.release();
} }
} }
} finally {
if (prefixMessage != null) {
prefixMessage.release();
}
if (clearPrefixMessage != null) {
clearPrefixMessage.release();
}
}
if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) { if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) {
synchronized (this.currentBots) { synchronized (this.currentBots) {

View File

@ -179,11 +179,16 @@ 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();
try {
for (Habbo habbo : this.onlineHabbos.values()) { for (Habbo habbo : this.onlineHabbos.values()) {
if (habbo.hasPermission(perm)) { if (habbo.hasPermission(perm)) {
habbo.getClient().sendResponse(message); habbo.getClient().sendResponse(message);
} }
} }
} finally {
message.release();
}
} }
} }

View File

@ -148,9 +148,14 @@ 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();
try {
for (Habbo habbo : habbos) { for (Habbo habbo : habbos) {
habbo.getClient().sendResponse(message); habbo.getClient().sendResponse(message);
} }
} finally {
message.release();
}
} }
} }
} }

View File

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