Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+86 -86
View File
@@ -18,100 +18,100 @@ import engine.objects.Mob;
public class PetMsg extends ClientNetMsg {
private int type; //5 or 6
private Mob pet;
private int type; //5 or 6
private Mob pet;
/**
* This is the general purpose constructor.
*/
public PetMsg(int type, Mob pet) {
super(Protocol.PET);
if (this.type != 6)
this.type = 5;
this.pet = pet;
}
/**
* This is the general purpose constructor.
*/
public PetMsg(int type, Mob pet) {
super(Protocol.PET);
if (this.type != 6)
this.type = 5;
this.pet = pet;
}
/**
* This constructor is used by NetMsgFactory. It attempts to deserialize the
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
* past the limit) then this constructor Throws that Exception to the
* caller.
*/
public PetMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.PET, origin, reader);
}
/**
* This constructor is used by NetMsgFactory. It attempts to deserialize the
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
* past the limit) then this constructor Throws that Exception to the
* caller.
*/
public PetMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.PET, origin, reader);
}
/**
* Serializes the subclass specific items to the supplied NetMsgWriter.
*/
@Override
protected void _serialize(ByteBufferWriter writer) {
writer.putInt(this.type);
/**
* Serializes the subclass specific items to the supplied NetMsgWriter.
*/
@Override
protected void _serialize(ByteBufferWriter writer) {
writer.putInt(this.type);
if (this.pet != null) {
writer.putInt(pet.getObjectType().ordinal());
writer.putInt(pet.getObjectUUID());
} else {
writer.putInt(0);
writer.putInt(0);
}
if (this.pet != null) {
writer.putInt(pet.getObjectType().ordinal());
writer.putInt(pet.getObjectUUID());
} else {
writer.putInt(0);
writer.putInt(0);
}
if (type == 6) {
writer.putInt(0);
} else if (type == 5) {
if (pet != null){
writer.putInt((int)(pet.getCurrentHitpoints() / pet.getHealthMax())); //suspect %health left
writer.putInt((int)(pet.getMana() / pet.getManaMax())); //suspect %mana left
writer.putInt((int)(pet.getStamina() / pet.getStaminaMax())); //suspect %stamina left
writer.putString(pet.getName());
writer.putInt(0);
writer.put((byte)0);
}else{
writer.putInt(0); //suspect %health left
writer.putInt(0); //suspect %mana left
writer.putInt(0); //suspect %stamina left
writer.putString("No Pet");
writer.putInt(0);
writer.put((byte)0);
}
}
}
if (type == 6) {
writer.putInt(0);
} else if (type == 5) {
if (pet != null) {
writer.putInt((int) (pet.getCurrentHitpoints() / pet.getHealthMax())); //suspect %health left
writer.putInt((int) (pet.getMana() / pet.getManaMax())); //suspect %mana left
writer.putInt((int) (pet.getStamina() / pet.getStaminaMax())); //suspect %stamina left
writer.putString(pet.getName());
writer.putInt(0);
writer.put((byte) 0);
} else {
writer.putInt(0); //suspect %health left
writer.putInt(0); //suspect %mana left
writer.putInt(0); //suspect %stamina left
writer.putString("No Pet");
writer.putInt(0);
writer.put((byte) 0);
}
/**
* Deserializes the subclass specific items from the supplied NetMsgReader.
*/
@Override
protected void _deserialize(ByteBufferReader reader) {
this.type = reader.getInt();
reader.getInt();
int petID = reader.getInt();
this.pet = Mob.getFromCache(petID);
if (this.type == 5) {
reader.getInt();
} else if (this.type == 6) {
reader.getInt();
reader.getInt();
reader.getInt();
reader.getString();
reader.getInt();
reader.get();
}
}
}
}
public int getType() {
return this.type;
}
/**
* Deserializes the subclass specific items from the supplied NetMsgReader.
*/
@Override
protected void _deserialize(ByteBufferReader reader) {
this.type = reader.getInt();
reader.getInt();
int petID = reader.getInt();
this.pet = Mob.getFromCache(petID);
if (this.type == 5) {
reader.getInt();
} else if (this.type == 6) {
reader.getInt();
reader.getInt();
reader.getInt();
reader.getString();
reader.getInt();
reader.get();
}
}
public Mob getPet() {
return this.pet;
}
public int getType() {
return this.type;
}
public void setType(int value) {
this.type = value;
}
public void setType(int value) {
this.type = value;
}
public void setPet(Mob value) {
this.pet = value;
}
public Mob getPet() {
return this.pet;
}
public void setPet(Mob value) {
this.pet = value;
}
}