forked from MagicBane/Server
Project cleanup pre merge.
This commit is contained in:
@@ -28,11 +28,11 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class UpdateGoldMsg extends ClientNetMsg {
|
||||
|
||||
private AbstractWorldObject looter;
|
||||
CharacterItemManager itemManager;
|
||||
private Item goldInventory;
|
||||
private Item goldBank;
|
||||
private int tradeGold = 0;
|
||||
private AbstractWorldObject looter;
|
||||
private Item goldInventory;
|
||||
private Item goldBank;
|
||||
private int tradeGold = 0;
|
||||
|
||||
|
||||
/**
|
||||
@@ -44,74 +44,73 @@ public class UpdateGoldMsg extends ClientNetMsg {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor
|
||||
*/
|
||||
public UpdateGoldMsg() {
|
||||
super(Protocol.UPDATEGOLDVALUE);
|
||||
}
|
||||
/**
|
||||
* This is the general purpose constructor
|
||||
*/
|
||||
public UpdateGoldMsg() {
|
||||
super(Protocol.UPDATEGOLDVALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 UpdateGoldMsg(AbstractConnection origin,
|
||||
ByteBufferReader reader) {
|
||||
super(Protocol.UPDATEGOLDVALUE, 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 UpdateGoldMsg(AbstractConnection origin,
|
||||
ByteBufferReader reader) {
|
||||
super(Protocol.UPDATEGOLDVALUE, origin, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader)
|
||||
{
|
||||
/**
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-cache and set values so they are available when we
|
||||
// serialize the data.
|
||||
|
||||
public void configure() {
|
||||
|
||||
if (this.looter != null && this.looter.getObjectType() == GameObjectType.PlayerCharacter){
|
||||
itemManager = ((PlayerCharacter)looter).getCharItemManager();
|
||||
if (this.looter != null && this.looter.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
itemManager = ((PlayerCharacter) looter).getCharItemManager();
|
||||
goldInventory = itemManager.getGoldInventory();
|
||||
this.tradeGold = itemManager.getGoldTrading();
|
||||
goldBank = itemManager.getGoldBank();
|
||||
}else{
|
||||
itemManager = null;
|
||||
goldInventory = null;
|
||||
goldBank = null;
|
||||
}
|
||||
} else {
|
||||
itemManager = null;
|
||||
goldInventory = null;
|
||||
goldBank = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer)
|
||||
throws SerializationException {
|
||||
/**
|
||||
* Serializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer)
|
||||
throws SerializationException {
|
||||
|
||||
if (looter == null){
|
||||
if (looter == null) {
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
}else{
|
||||
} else {
|
||||
writer.putInt(looter.getObjectType().ordinal());
|
||||
writer.putInt(looter.getObjectUUID());
|
||||
}
|
||||
}
|
||||
|
||||
if (goldInventory != null && goldInventory.getNumOfItems() - this.tradeGold > 0) {
|
||||
writer.put((byte) 1);
|
||||
Item.serializeForClientMsgWithoutSlot(goldInventory,writer);
|
||||
Item.serializeForClientMsgWithoutSlot(goldInventory, writer);
|
||||
} else
|
||||
writer.put((byte) 0);
|
||||
|
||||
if (goldBank != null && goldBank.getNumOfItems() != 0) {
|
||||
writer.put((byte) 1);
|
||||
Item.serializeForClientMsgWithoutSlot(goldBank,writer);
|
||||
Item.serializeForClientMsgWithoutSlot(goldBank, writer);
|
||||
} else
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user