/** * 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 P272_TownAllianceAction extends GenericAction { private short mapID; private byte data2; private byte allegiance; private int faction; private char[] name; private char[] tag; private byte capeBackgroundColor; private byte capePatternColor; private byte capeEmblemColor; private byte capeShape; private byte capePattern; private short capeEmblem; private byte capeTrim; public short getHeader() { return 272; } public void setMapID(short newValue) { mapID = newValue; } public void setData2(byte newValue) { data2 = newValue; } public void setAllegiance(byte newValue) { allegiance = newValue; } public void setFaction(int newValue) { faction = newValue; } public void setName(char[] newValue) { name = newValue; } public void setTag(char[] newValue) { tag = newValue; } public void setCapeBackgroundColor(byte newValue) { capeBackgroundColor = newValue; } public void setCapePatternColor(byte newValue) { capePatternColor = newValue; } public void setCapeEmblemColor(byte newValue) { capeEmblemColor = newValue; } public void setCapeShape(byte newValue) { capeShape = newValue; } public void setCapePattern(byte newValue) { capePattern = newValue; } public void setCapeEmblem(short newValue) { capeEmblem = newValue; } public void setCapeTrim(byte newValue) { capeTrim = newValue; } private int getSize() { int size = 22; if (name != null) { size += 2 * name.length; } if (tag != null) { size += 2 * tag.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.putShort(mapID); buffer.put(data2); buffer.put(allegiance); buffer.putInt(faction); short prefix_name; if (name == null) { prefix_name = 0; } else { prefix_name = (short) name.length; } buffer.putShort(prefix_name); for (int i = 0; i < prefix_name; i++) { buffer.putChar(name[i]); } short prefix_tag; if (tag == null) { prefix_tag = 0; } else { prefix_tag = (short) tag.length; } buffer.putShort(prefix_tag); for (int i = 0; i < prefix_tag; i++) { buffer.putChar(tag[i]); } buffer.put(capeBackgroundColor); buffer.put(capePatternColor); buffer.put(capeEmblemColor); buffer.put(capeShape); buffer.put(capePattern); buffer.putShort(capeEmblem); buffer.put(capeTrim); } catch (BufferOverflowException e) { return false; } setBuffer(buffer); return true; } }