/** * 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. * * This is used to set the description and objectives * of a quest (after the client requests it with P010) * as seen in the quest log. These descriptions are made * up of somewhat complex combinations of strings. * * @author GWLPR Template Updater */ public final class P064_QuestDescriptionAction extends GenericAction { private int iD; private char[] description; private char[] objectives; public short getHeader() { return 64; } public void setID(int newValue) { iD = newValue; } public void setDescription(char[] newValue) { description = newValue; } public void setObjectives(char[] newValue) { objectives = newValue; } private int getSize() { int size = 10; if (description != null) { size += 2 * description.length; } if (objectives != null) { size += 2 * objectives.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(iD); short prefix_description; if (description == null) { prefix_description = 0; } else { prefix_description = (short) description.length; } buffer.putShort(prefix_description); for (int i = 0; i < prefix_description; i++) { buffer.putChar(description[i]); } short prefix_objectives; if (objectives == null) { prefix_objectives = 0; } else { prefix_objectives = (short) objectives.length; } buffer.putShort(prefix_objectives); for (int i = 0; i < prefix_objectives; i++) { buffer.putChar(objectives[i]); } } catch (BufferOverflowException e) { return false; } setBuffer(buffer); return true; } }