/** * For copyright information see the LICENSE document. */ /** * Auto-generated by PacketCodeGen, on 2012-09-28 */ package com.gamerevision.gwlpr.actions.gameserver.stoc; import com.realityshard.shardlet.utils.GenericAction; import java.nio.BufferOverflowException; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** * This is an automatically generated ShardletAction. * It resembles the packet template that has been * parsed from our packet templates xml. * * * @author GWLPR Template Updater */ public final class P256_ObjectDialogButtonAction extends GenericAction { private byte icon; private char[] caption; private int buttonID; private short skillID; public short getHeader() { return 256; } public void setIcon(byte newValue) { icon = newValue; } public void setCaption(char[] newValue) { caption = newValue; } public void setButtonID(int newValue) { buttonID = newValue; } public void setSkillID(short newValue) { skillID = newValue; } private int getSize() { int size = 11; if (caption != null) { size += 2 * caption.length; } return size; } @Override public boolean serialize() { int size = getSize(); if (size == 0) { return false; } ByteBuffer buffer = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN); try { buffer.putShort(getHeader()); buffer.put(icon); short prefix_caption; if (caption == null) { prefix_caption = 0; } else { prefix_caption = (short) caption.length; } buffer.putShort(prefix_caption); for (int i = 0; i < prefix_caption; i++) { buffer.putChar(caption[i]); } buffer.putInt(buttonID); buffer.putShort(skillID); } catch (BufferOverflowException e) { return false; } setBuffer(buffer); return true; } }