Fixed issues with pet branch merge into 4.0

This commit is contained in:
Harmonic 2022-04-21 16:20:41 -07:00
parent 4f0143e982
commit 6fbf3ca271
4 changed files with 85 additions and 4 deletions

View File

@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.PetClearPosture;
import java.sql.ResultSet;

View File

@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -66,7 +66,7 @@ public class PetCommand implements Comparable<PetCommand> {
}
pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, this.action.gestureToSet);
pet.getRoom().sendComposer(new RoomUserStatusComposer(pet.getRoomUnit()).compose());
pet.getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
pet.addEnergy(-this.energyCost);
pet.addHappyness(-this.happynessCost);
pet.addExperience(this.xp);

View File

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

View File

@ -0,0 +1,82 @@
package com.eu.habbo.messages.outgoing.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.set.hash.THashSet;
public class HeightMapUpdateMessageComposer extends MessageComposer {
private int x;
private int y;
private short z;
private double height;
private THashSet<RoomTile> updateTiles;
private Room room;
public HeightMapUpdateMessageComposer(int x, int y, short z, double height) {
this.x = x;
this.y = y;
this.z = z;
this.height = height;
}
public HeightMapUpdateMessageComposer(Room room, THashSet<RoomTile> updateTiles) {
this.updateTiles = updateTiles;
this.room = room;
}
@Override
protected ServerMessage composeInternal() {
//TODO: maybe do this another way? doesn't seem to be very clean but gets the job done
this.response.init(Outgoing.HeightMapUpdateMessageComposer);
if (this.updateTiles != null) {
// prevent overflow. Byte max value is 127
if(this.updateTiles.size() > 127) {
RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]);
this.response.appendByte(127);
for(int i = 0; i < 127; i++) {
RoomTile t = tiles[i];
updateTiles.remove(t); // remove it from the set
this.response.appendByte((int) t.x);
this.response.appendByte((int) t.y);
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (t.z * 256.0));
}
else {
this.response.appendShort(t.relativeHeight());
}
}
//send the remaining tiles in a new message
this.room.sendComposer(new HeightMapUpdateMessageComposer(this.room, updateTiles).compose());
return this.response;
}
this.response.appendByte(this.updateTiles.size());
for (RoomTile t : this.updateTiles) {
this.response.appendByte((int) t.x);
this.response.appendByte((int) t.y);
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (t.z * 256.0));
}
else {
this.response.appendShort(t.relativeHeight());
}
}
} else {
this.response.appendByte(1);
this.response.appendByte(this.x);
this.response.appendByte(this.y);
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (this.z * 256.0));
}
else {
this.response.appendShort((int) (this.height));
}
}
return this.response;
}
}