mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Add reliability to packets and actually clear the message buffer.
This commit is contained in:
parent
f9d81ea198
commit
ee5a97bbae
@ -3726,35 +3726,59 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendComposer(ServerMessage message) {
|
public void sendComposer(ServerMessage message) {
|
||||||
for (Habbo habbo : this.getHabbos()) {
|
message.retain();
|
||||||
if (habbo.getClient() == null) {
|
|
||||||
this.removeHabbo(habbo, true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
habbo.getClient().sendResponse(message);
|
try {
|
||||||
|
for (Habbo habbo : this.getHabbos()) {
|
||||||
|
if (habbo.getClient() == null) {
|
||||||
|
this.removeHabbo(habbo, true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(message);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
message.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendComposerToHabbosWithRights(ServerMessage message) {
|
public void sendComposerToHabbosWithRights(ServerMessage message) {
|
||||||
for (Habbo habbo : this.getHabbos()) {
|
message.retain();
|
||||||
if (this.hasRights(habbo)) {
|
|
||||||
habbo.getClient().sendResponse(message);
|
try {
|
||||||
|
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) {
|
||||||
for (Habbo habbo : this.getHabbos()) {
|
message.retain();
|
||||||
if (!habbo.getHabboStats().ignorePets)
|
|
||||||
habbo.getClient().sendResponse(message);
|
try {
|
||||||
|
for (Habbo habbo : this.getHabbos()) {
|
||||||
|
if (!habbo.getHabboStats().ignorePets)
|
||||||
|
habbo.getClient().sendResponse(message);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
message.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void botChat(ServerMessage message) {
|
public void botChat(ServerMessage message) {
|
||||||
for (Habbo habbo : this.getHabbos()) {
|
message.retain();
|
||||||
if (!habbo.getHabboStats().ignoreBots)
|
|
||||||
habbo.getClient().sendResponse(message);
|
try {
|
||||||
|
for (Habbo habbo : this.getHabbos()) {
|
||||||
|
if (!habbo.getHabboStats().ignoreBots)
|
||||||
|
habbo.getClient().sendResponse(message);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
message.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ 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;
|
||||||
@ -310,8 +311,16 @@ public class RoomTrade {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessageToUsers(MessageComposer message) {
|
public void sendMessageToUsers(MessageComposer message) {
|
||||||
for (RoomTradeUser roomTradeUser : this.users) {
|
ServerMessage messageComposed = message.compose();
|
||||||
roomTradeUser.getHabbo().getClient().sendResponse(message);
|
|
||||||
|
messageComposed.retain();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (RoomTradeUser roomTradeUser : this.users) {
|
||||||
|
roomTradeUser.getHabbo().getClient().sendResponse(message);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
messageComposed.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.eu.habbo.messages;
|
package com.eu.habbo.messages;
|
||||||
|
|
||||||
import com.eu.habbo.util.DebugUtils;
|
|
||||||
import com.eu.habbo.util.PacketUtils;
|
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;
|
||||||
@ -194,23 +193,13 @@ public class ServerMessage implements ReferenceCounted {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReferenceCounted retain() {
|
public ReferenceCounted retain() {
|
||||||
int result = this.refs.incrementAndGet();
|
this.refs.incrementAndGet();
|
||||||
|
|
||||||
if (this.header == 1167 || this.header == 2024 || this.header == 2505) {
|
|
||||||
System.out.printf("retain Packet: %d Count: %d From: %s%n", this.header, result, DebugUtils.getCallerCallerStacktrace());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReferenceCounted retain(int i) {
|
public ReferenceCounted retain(int i) {
|
||||||
int result = this.refs.addAndGet(i);
|
this.refs.addAndGet(i);
|
||||||
|
|
||||||
if (this.header == 1167 || this.header == 2024 || this.header == 2505) {
|
|
||||||
System.out.printf("retain Packet: %d Count: %d From: %s%n", this.header, result, DebugUtils.getCallerCallerStacktrace());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,17 +221,12 @@ public class ServerMessage implements ReferenceCounted {
|
|||||||
@Override
|
@Override
|
||||||
public boolean release(int i) {
|
public boolean release(int i) {
|
||||||
int value = this.refs.addAndGet(-i);
|
int value = this.refs.addAndGet(-i);
|
||||||
|
|
||||||
if (this.header == 1167 || this.header == 2024 || this.header == 2505) {
|
|
||||||
System.out.printf("release Packet: %d Count: %d From: %s%n", this.header, value, DebugUtils.getCallerCallerStacktrace());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
throw new IllegalReferenceCountException("Decremented below 0 (packet " + this.header + " value " + value + ").");
|
throw new IllegalReferenceCountException("Decremented below 0 (packet " + this.header + " value " + value + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
this.channelBuffer.release();
|
this.channelBuffer.release(this.channelBuffer.refCnt());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user