Merge branch 'patch-heightmap-bug' into 'dev'

fixed byte-overflow in UpdateStackHeightComposer

See merge request morningstar/Arcturus-Community!74
This commit is contained in:
Harmonic 2020-01-21 06:26:44 -05:00
commit c7edfc14ea
3 changed files with 15 additions and 8 deletions

View File

@ -547,7 +547,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
tile.setState(this.calculateTileState(tile)); tile.setState(this.calculateTileState(tile));
} }
this.sendComposer(new UpdateStackHeightComposer(tiles).compose()); this.sendComposer(new UpdateStackHeightComposer(this, tiles).compose());
} }
private RoomTileState calculateTileState(RoomTile tile) { private RoomTileState calculateTileState(RoomTile tile) {
@ -655,7 +655,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
} }
this.sendComposer(new UpdateStackHeightComposer(updatedTiles).compose()); this.sendComposer(new UpdateStackHeightComposer(this, updatedTiles).compose());
this.updateTiles(updatedTiles); this.updateTiles(updatedTiles);
for (RoomTile tile : updatedTiles) { for (RoomTile tile : updatedTiles) {
this.updateHabbosAt(tile.x, tile.y); this.updateHabbosAt(tile.x, tile.y);

View File

@ -51,7 +51,7 @@ public class SetStackHelperHeightEvent extends MessageHandler {
item.needsUpdate(true); item.needsUpdate(true);
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item);
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles);
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tiles).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(room, tiles).compose());
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose());
} }
} }

View File

@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms; package com.eu.habbo.messages.outgoing.rooms;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.MessageComposer;
@ -12,6 +13,7 @@ public class UpdateStackHeightComposer extends MessageComposer {
private double height; private double height;
private THashSet<RoomTile> updateTiles; private THashSet<RoomTile> updateTiles;
private Room room;
public UpdateStackHeightComposer(int x, int y, double height) { public UpdateStackHeightComposer(int x, int y, double height) {
this.x = x; this.x = x;
@ -19,24 +21,29 @@ public class UpdateStackHeightComposer extends MessageComposer {
this.height = height; this.height = height;
} }
public UpdateStackHeightComposer(THashSet<RoomTile> updateTiles) { public UpdateStackHeightComposer(Room room, THashSet<RoomTile> updateTiles) {
this.updateTiles = updateTiles; this.updateTiles = updateTiles;
this.room = room;
} }
@Override @Override
public ServerMessage compose() { public ServerMessage compose() {
//TODO: THIS IS A TEMP FIX. THERE IS AN ISSUE WITH BAD PACKET STRUCTURE HERE CAUSING ISSUES WITH MOVING LARGE FURNITURE //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done
this.response.init(Outgoing.UpdateStackHeightComposer); this.response.init(Outgoing.UpdateStackHeightComposer);
if (this.updateTiles != null) { if (this.updateTiles != null) {
if(this.updateTiles.size() > 4) { // prevent overflow. Byte max value is 127
if(this.updateTiles.size() > 127) {
RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]);
this.response.appendByte(4); this.response.appendByte(127);
for(int i = 0; i < 4; i++) { for(int i = 0; i < 127; i++) {
RoomTile t = tiles[i]; RoomTile t = tiles[i];
updateTiles.remove(t); // remove it from the set
this.response.appendByte((int) t.x); this.response.appendByte((int) t.x);
this.response.appendByte((int) t.y); this.response.appendByte((int) t.y);
this.response.appendShort(t.relativeHeight()); this.response.appendShort(t.relativeHeight());
} }
//send the remaining tiles in a new message
this.room.sendComposer(new UpdateStackHeightComposer(this.room, updateTiles).compose());
return this.response; return this.response;
} }