/** * 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 P129_MissionMapIconAddAction extends GenericAction { private int localID; private float[] position; private short plane; private byte color; private int data6; private int iconHash; private char[] text; public short getHeader() { return 129; } public void setLocalID(int newValue) { localID = newValue; } /** * the x/y-coordinates */ public void setPosition(float[] newValue) { position = newValue; } public void setPlane(short newValue) { plane = newValue; } public void setColor(byte newValue) { color = newValue; } public void setData6(int newValue) { data6 = newValue; } public void setIconHash(int newValue) { iconHash = newValue; } public void setText(char[] newValue) { text = newValue; } private int getSize() { int size = 27; if (position == null) { return 0; } if (position.length != 2) { return 0; } if (text != null) { size += 2 * text.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.putInt(localID); buffer.putFloat(position[0]); buffer.putFloat(position[1]); buffer.putShort(plane); buffer.put(color); buffer.putInt(data6); buffer.putInt(iconHash); short prefix_text; if (text == null) { prefix_text = 0; } else { prefix_text = (short) text.length; } buffer.putShort(prefix_text); for (int i = 0; i < prefix_text; i++) { buffer.putChar(text[i]); } } catch (BufferOverflowException e) { return false; } setBuffer(buffer); return true; } }