Files
Server/src/engine/net/client/msg/UpdateInventoryMsg.java
T
MagicBotandClaude Opus 5.5 6b4e9815e0 Switch Item.template and MobLoot to CObjectTemplate
Item.template is now the cache template from CObjectTemplate.lookup
instead of the legacy DB ItemTemplate, so item.template.cacheTemplate.X
becomes item.template.X. MobLoot, LootManager, ItemManager.isTwoHanded/
isShield and CombatManager.getSwingAnimation take a CObjectTemplate.

No value changes: every getter already read the cache template through
the bridge, and the lookup resolves the same 7586 ids as
static_item_templates with the same item_type (offline parity p17.py,
0 differences).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 07:55:28 -04:00

107 lines
3.2 KiB
Java

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2026
// https://www.magicbane.com
package engine.net.client.msg;
import engine.mbEnums.ItemType;
import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.Protocol;
import engine.objects.Item;
import java.util.ArrayList;
public class UpdateInventoryMsg extends ClientNetMsg {
private ArrayList<Item> toAdd;
private ArrayList<Item> bank;
/**
* This is the general purpose constructor.
*/
public UpdateInventoryMsg(ArrayList<Item> inventory, ArrayList<Item> bank, Item gold, boolean add) {
super(Protocol.UPDATECLIENTINVENTORIES);
toAdd = inventory;
if (gold != null)
toAdd.add(gold);
this.bank = bank;
}
/**
* 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 UpdateInventoryMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.UPDATECLIENTINVENTORIES, origin, reader);
}
public static void putList(ByteBufferWriter writer, ArrayList<Item> list) {
int indexPosition = writer.position();
writer.putInt(0);
int serialized = 0;
for (Item item : list) {
if (item.template.getItemType().equals(ItemType.GOLD)) {
if (item.getNumOfItems() == 0)
continue;
}
Item.serializeForClientMsgWithoutSlot(item, writer);
++serialized;
}
writer.putIntAt(serialized, indexPosition);
}
/**
* Serializes the subclass specific items to the supplied NetMsgWriter.
*/
@Override
protected void _serialize(ByteBufferWriter writer) {
putList(writer, this.toAdd);
if (bank != null)
putList(writer, this.bank);
else
writer.putInt(0);
}
/**
* Deserializes the subclass specific items from the supplied NetMsgReader.
*/
@Override
protected void _deserialize(ByteBufferReader reader) {
}
public ArrayList<Item> getToAdd() {
return this.toAdd;
}
public void setToAdd(ArrayList<Item> value) {
this.toAdd = value;
}
public void addToInventory(Item value) {
this.toAdd.add(value);
}
@Override
protected int getPowerOfTwoBufferSize() {
return 20;
}
}