Fixes users being sent into an endless loop in various edge cases when it tries to teleport them to a tile they're already on. Now it won't bother.

This commit is contained in:
Harmonic 2020-06-05 04:06:48 -04:00
parent c19ef29cf9
commit de1b59acab

View File

@ -47,14 +47,20 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
Room room = roomUnit.getRoom(); Room room = roomUnit.getRoom();
if (room == null) if (room == null) {
return; return;
}
// makes a temporary effect // makes a temporary effect
roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit)); roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose()); room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000);
if (tile == roomUnit.getCurrentLocation()) {
return;
}
if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) { if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) {
RoomTile alternativeTile = null; RoomTile alternativeTile = null;
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile); List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile);
@ -146,6 +152,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
if (!this.items.isEmpty()) { if (!this.items.isEmpty()) {
int i = Emulator.getRandom().nextInt(this.items.size()); int i = Emulator.getRandom().nextInt(this.items.size());
HabboItem item = this.items.get(i); HabboItem item = this.items.get(i);
teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY())); teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
return true; return true;
} }