forked from MagicBane/Server
Project cleanup pre merge.
This commit is contained in:
@@ -22,74 +22,74 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Update trade window message. Send item info to other player.
|
||||
*
|
||||
* @author Eighty
|
||||
*/
|
||||
public class UpdateTradeWindowMsg extends ClientNetMsg {
|
||||
|
||||
PlayerCharacter pc1;
|
||||
PlayerCharacter pc2;
|
||||
PlayerCharacter pc1;
|
||||
PlayerCharacter pc2;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public UpdateTradeWindowMsg(PlayerCharacter pc1, PlayerCharacter pc2) {
|
||||
super(Protocol.UPDATETRADEWINDOW);
|
||||
this.pc1 = pc1;
|
||||
this.pc2 = pc2;
|
||||
}
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public UpdateTradeWindowMsg(PlayerCharacter pc1, PlayerCharacter pc2) {
|
||||
super(Protocol.UPDATETRADEWINDOW);
|
||||
this.pc1 = pc1;
|
||||
this.pc2 = pc2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer)
|
||||
throws SerializationException {
|
||||
|
||||
writer.putInt(pc1.getObjectType().ordinal());
|
||||
writer.putInt(pc1.getObjectUUID());
|
||||
|
||||
writer.putInt(pc2.getObjectType().ordinal());
|
||||
writer.putInt(pc2.getObjectUUID());
|
||||
|
||||
|
||||
/**
|
||||
* 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 UpdateTradeWindowMsg(AbstractConnection origin,
|
||||
ByteBufferReader reader) {
|
||||
super(Protocol.UPDATETRADEWINDOW, origin, reader);
|
||||
}
|
||||
|
||||
ArrayList<Item> trading1 = new ArrayList<>();
|
||||
|
||||
for (int itemID : pc1.getCharItemManager().getTrading()){
|
||||
Item item = Item.getFromCache(itemID);
|
||||
if (item == null)
|
||||
continue;
|
||||
trading1.add(item);
|
||||
}
|
||||
|
||||
ArrayList<Item> trading2 = new ArrayList<>();
|
||||
for (int itemID : pc2.getCharItemManager().getTrading()){
|
||||
Item item = Item.getFromCache(itemID);
|
||||
if (item == null)
|
||||
continue;
|
||||
trading2.add(item);
|
||||
}
|
||||
Item.putTradingList(pc1,writer, trading1, false, pc1.getObjectUUID(),false,null);
|
||||
Item.putTradingList(pc2,writer, trading2, false, pc2.getObjectUUID(),false,null);
|
||||
}
|
||||
/**
|
||||
* Serializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer)
|
||||
throws SerializationException {
|
||||
|
||||
/**
|
||||
* 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 UpdateTradeWindowMsg(AbstractConnection origin,
|
||||
ByteBufferReader reader) {
|
||||
super(Protocol.UPDATETRADEWINDOW, origin, reader);
|
||||
}
|
||||
writer.putInt(pc1.getObjectType().ordinal());
|
||||
writer.putInt(pc1.getObjectUUID());
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
}
|
||||
writer.putInt(pc2.getObjectType().ordinal());
|
||||
writer.putInt(pc2.getObjectUUID());
|
||||
|
||||
@Override
|
||||
protected int getPowerOfTwoBufferSize() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
ArrayList<Item> trading1 = new ArrayList<>();
|
||||
|
||||
for (int itemID : pc1.getCharItemManager().getTrading()) {
|
||||
Item item = Item.getFromCache(itemID);
|
||||
if (item == null)
|
||||
continue;
|
||||
trading1.add(item);
|
||||
}
|
||||
|
||||
ArrayList<Item> trading2 = new ArrayList<>();
|
||||
for (int itemID : pc2.getCharItemManager().getTrading()) {
|
||||
Item item = Item.getFromCache(itemID);
|
||||
if (item == null)
|
||||
continue;
|
||||
trading2.add(item);
|
||||
}
|
||||
Item.putTradingList(pc1, writer, trading1, false, pc1.getObjectUUID(), false, null);
|
||||
Item.putTradingList(pc2, writer, trading2, false, pc2.getObjectUUID(), false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerOfTwoBufferSize() {
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user