Fix snapshot wired updating position even if not enabled

This commit is contained in:
Alejandro 2020-02-01 13:13:21 +02:00
parent ff2256f30a
commit 24f84a5b02

View File

@ -16,7 +16,6 @@ import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -75,50 +74,50 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
}); });
} }
RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y); RoomTile t = null;
if (this.position) { if (this.position) {
if (t != null) { t = room.getLayout().getTile((short) setting.x, (short) setting.y);
if (t.state != RoomTileState.INVALID) {
boolean canMove = true;
if (t.x == item.getX() && t.y == item.getY()) { if (t != null && t.state != RoomTileState.INVALID) {
canMove = !(room.getTopItemAt(t.x, t.y) == item); boolean canMove = true;
slideAnimation = false;
}
if (canMove && !room.hasHabbosAt(t.x, t.y)) { if (t.x == item.getX() && t.y == item.getY()) {
THashSet<RoomTile> tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation); canMove = !(room.getTopItemAt(t.x, t.y) == item);
double highestZ = -1d; slideAnimation = false;
for (RoomTile tile : tiles) { }
if (tile.state == RoomTileState.INVALID) {
highestZ = -1d;
break;
}
if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y)) { if (canMove && !room.hasHabbosAt(t.x, t.y)) {
highestZ = -1d; THashSet<RoomTile> tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation);
break; double highestZ = -1d;
} for (RoomTile tile : tiles) {
if (tile.state == RoomTileState.INVALID) {
double stackHeight = room.getStackHeight(tile.x, tile.y, false, item); highestZ = -1d;
if (stackHeight > highestZ) { break;
highestZ = stackHeight;
}
} }
if (highestZ != -1d) { if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y)) {
tilesToUpdate.addAll(tiles); highestZ = -1d;
break;
}
offsetZ = highestZ - item.getZ(); double stackHeight = room.getStackHeight(tile.x, tile.y, false, item);
double totalHeight = item.getZ() + offsetZ; if (stackHeight > highestZ) {
if (totalHeight > 40) break; highestZ = stackHeight;
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation)); }
}
if (!slideAnimation) { if (highestZ != -1d) {
item.setX(t.x); tilesToUpdate.addAll(tiles);
item.setY(t.y);
} offsetZ = highestZ - item.getZ();
double totalHeight = item.getZ() + offsetZ;
if (totalHeight > 40) break;
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
if (!slideAnimation) {
item.setX(t.x);
item.setY(t.y);
} }
} }
} }
@ -127,6 +126,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
if (slideAnimation && t != null) { if (slideAnimation && t != null) {
room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose()); room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose());
room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
} else { } else {
room.updateItem(item); room.updateItem(item);
} }