List of usage examples for io.netty.buffer ByteBuf writeShort
public abstract ByteBuf writeShort(int value);
From source file:eu.jangos.realm.network.packet.server.query.SMSG_GUILD_QUERY.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b - ?b - [?b*10] - 4b - 4b - 4b - 4b - 4b // Size (Little Endian) - Opcode (Big Endian) - Guild ID - Guild name - [x Ranks name] - emblem style // - emblem color - border style - border color - background color int strSize = 0; strSize += this.name.length(); for (String rankName : this.listRanks) { strSize += rankName.length();/* w ww . j ava 2 s . c o m*/ } buf.writeShort(this.size + strSize); buf.writeShort(this.code.getValue()); buf.writeInt(this.id); ByteBufUtil.writeAscii(buf, this.name); buf.writeByte((byte) 0); // End of string // We add ranks name. for (int i = 0; i < GUILD_RANKS_MAX_COUNT; i++) { if (i < this.listRanks.size()) ByteBufUtil.writeAscii(buf, this.listRanks.get(i)); buf.writeByte((byte) 0); // End of string } buf.writeInt(this.emblemStyle); buf.writeInt(this.emblemColor); buf.writeInt(this.borderlStyle); buf.writeInt(this.borderColor); buf.writeInt(this.backgroundColor); }
From source file:eu.jangos.realm.network.packet.server.query.SMSG_ITEM_QUERY_SINGLE.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - // Size (Little Endian) - Opcode (Big Endian) - ItemService itemService = ItemServiceFactory.getInstance(); buf.writeShort(this.size + this.item.getName().length() + this.item.getDescription().length()); buf.writeShort(this.code.getValue()); buf.writeInt(this.item.getEntry()); buf.writeInt(this.item.getItemsubclass().getItemclass().getId()); buf.writeInt(this.item.getItemsubclass().getId().getId()); // 12//from www . jav a 2 s. c om ByteBufUtil.writeAscii(buf, this.item.getName()); buf.writeByte(0); // End of string buf.writeByte(0); // End of string 2 buf.writeByte(0); // End of string 3 buf.writeByte(0); // End of string 4 // 16 + ? buf.writeInt(this.item.getDisplayid()); buf.writeInt(this.item.getItemquality().getId()); buf.writeInt(this.item.getFlags()); buf.writeInt(this.item.getBuyprice()); buf.writeInt(this.item.getSellprice()); buf.writeInt(this.item.getInventorytype().getId()); buf.writeInt(this.item.getAllowableclass()); buf.writeInt(this.item.getAllowablerace()); buf.writeInt(this.item.getItemlevel()); buf.writeInt(this.item.getRequiredlevel()); buf.writeInt(this.item.getRequiredskill()); buf.writeInt(this.item.getRequiredskillrank()); buf.writeInt(this.item.getRequiredhonorrank()); buf.writeInt(this.item.getRequiredcityrank()); buf.writeInt(this.item.getRequiredreputationfaction()); buf.writeInt((this.item.getRequiredreputationfaction() > 0 ? this.item.getRequiredreputationrank() : 0)); buf.writeInt(this.item.getMaxcount()); buf.writeInt(this.item.getStackable()); buf.writeInt(this.item.getContainerslots()); // 92 buf.writeInt(this.item.getStatType1()); buf.writeInt(this.item.getStatValue1()); buf.writeInt(this.item.getStatType2()); buf.writeInt(this.item.getStatValue2()); buf.writeInt(this.item.getStatType3()); buf.writeInt(this.item.getStatValue3()); buf.writeInt(this.item.getStatType4()); buf.writeInt(this.item.getStatValue4()); buf.writeInt(this.item.getStatType5()); buf.writeInt(this.item.getStatValue5()); buf.writeInt(this.item.getStatType6()); buf.writeInt(this.item.getStatValue6()); buf.writeInt(this.item.getStatType7()); buf.writeInt(this.item.getStatValue7()); buf.writeInt(this.item.getStatType8()); buf.writeInt(this.item.getStatValue8()); buf.writeInt(this.item.getStatType9()); buf.writeInt(this.item.getStatValue9()); buf.writeInt(this.item.getStatType10()); buf.writeInt(this.item.getStatValue10()); // 172 buf.writeFloat(this.item.getDmgMin1()); buf.writeFloat(this.item.getDmgMax1()); buf.writeInt(this.item.getDmgType1()); buf.writeFloat(this.item.getDmgMin2()); buf.writeFloat(this.item.getDmgMax2()); buf.writeInt(this.item.getDmgType2()); buf.writeFloat(this.item.getDmgMin3()); buf.writeFloat(this.item.getDmgMax3()); buf.writeInt(this.item.getDmgType3()); buf.writeFloat(this.item.getDmgMin4()); buf.writeFloat(this.item.getDmgMax4()); buf.writeInt(this.item.getDmgType4()); buf.writeFloat(this.item.getDmgMin5()); buf.writeFloat(this.item.getDmgMax5()); buf.writeInt(this.item.getDmgType5()); // 232 // resistances buf.writeInt(this.item.getArmor()); buf.writeInt(this.item.getHolyRes()); buf.writeInt(this.item.getFireRes()); buf.writeInt(this.item.getNatureRes()); buf.writeInt(this.item.getFrostRes()); buf.writeInt(this.item.getShadowRes()); buf.writeInt(this.item.getArcaneRes()); // 260 buf.writeInt(this.item.getDelay()); buf.writeInt(this.item.getAmmoType()); buf.writeFloat(this.item.getRangedModRange()); // 272 // spells buf.writeInt(this.item.getSpellid1()); buf.writeInt(this.item.getSpelltrigger1()); buf.writeInt(this.item.getSpellcharges1()); buf.writeInt(this.item.getSpellcooldown1()); buf.writeInt(this.item.getSpellcategory1()); buf.writeInt(this.item.getSpellcategorycooldown1()); buf.writeInt(this.item.getSpellid2()); buf.writeInt(this.item.getSpelltrigger2()); buf.writeInt(this.item.getSpellcharges2()); buf.writeInt(this.item.getSpellcooldown2()); buf.writeInt(this.item.getSpellcategory2()); buf.writeInt(this.item.getSpellcategorycooldown2()); buf.writeInt(this.item.getSpellid3()); buf.writeInt(this.item.getSpelltrigger3()); buf.writeInt(this.item.getSpellcharges3()); buf.writeInt(this.item.getSpellcooldown3()); buf.writeInt(this.item.getSpellcategory3()); buf.writeInt(this.item.getSpellcategorycooldown3()); buf.writeInt(this.item.getSpellid4()); buf.writeInt(this.item.getSpelltrigger4()); buf.writeInt(this.item.getSpellcharges4()); buf.writeInt(this.item.getSpellcooldown4()); buf.writeInt(this.item.getSpellcategory4()); buf.writeInt(this.item.getSpellcategorycooldown4()); buf.writeInt(this.item.getSpellid5()); buf.writeInt(this.item.getSpelltrigger5()); buf.writeInt(this.item.getSpellcharges5()); buf.writeInt(this.item.getSpellcooldown5()); buf.writeInt(this.item.getSpellcategory5()); buf.writeInt(this.item.getSpellcategorycooldown5()); // 392 buf.writeInt(this.item.getBonding()); // 396 ByteBufUtil.writeAscii(buf, this.item.getDescription()); buf.writeByte(0); // end of string // 397 + ? buf.writeInt(this.item.getPagetext().getId()); buf.writeInt(this.item.getLanguageid()); buf.writeInt(this.item.getPagematerial()); buf.writeInt(this.item.getStartquest()); buf.writeInt(this.item.getLockid()); buf.writeInt(this.item.getMaterial()); buf.writeInt(this.item.getSheath()); buf.writeInt(this.item.getRandomproperty()); buf.writeInt(this.item.getBlock()); buf.writeInt(this.item.getItemset()); buf.writeInt(this.item.getMaxdurability()); buf.writeInt(this.item.getArea()); buf.writeInt(this.item.getMap()); buf.writeInt(this.item.getBagfamily()); // 453 }
From source file:eu.jangos.realm.network.packet.server.query.SMSG_NAME_QUERY.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // If player exists: // 2b - 2b - ?b - ?b - 4b - 4b - 4b // Size (Little Endian) - Opcode (Big Endian) - Player name - Realm name - race - gender - class buf.writeShort(this.size + this.name.length() + this.realm.length() + 2); buf.writeShort(this.code.getValue()); ByteBufUtil.writeAscii(buf, this.name); buf.writeByte((byte) 0); // End of string ByteBufUtil.writeAscii(buf, this.realm); buf.writeByte((byte) 0); // End of string buf.writeInt(this.race.getValue()); buf.writeInt(this.gender.getValue()); buf.writeInt(this.prof.getValue()); }
From source file:eu.jangos.realm.network.packet.server.query.SMSG_PAGE_TEXT_QUERY.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b - ?b // Size (Little Endian) - Opcode (Big Endian) - Page ID - Page Text buf.writeShort(this.size + this.text.length()); buf.writeShort(this.code.getValue()); buf.writeInt(this.id); ByteBufUtil.writeAscii(buf, this.text); buf.writeByte((byte) 0); // End of string }
From source file:eu.jangos.realm.network.packet.server.query.SMSG_PET_NAME_QUERY.java
License:Apache License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b - ?b - 4b // Size (Little Endian) - Opcode (Big Endian) - Pet number - Pet name - Pet Field buf.writeShort(this.size + this.name.length() + 1); buf.writeShort(this.code.getValue()); buf.writeInt(this.number); ByteBufUtil.writeAscii(buf, this.name); buf.writeByte((byte) 0); // End of string buf.writeInt(this.field); }
From source file:eu.jangos.realm.network.packet.server.SMSG_PING.java
License:Open Source License
@Override public void encode(ByteBuf buf) throws Exception { // Packet structure: // 2b - 2b - 4b // Size (Little Endian) - Opcode (Big Endian) - ping buf.writeShort(this.size); buf.writeShort(this.code.getValue()); buf.writeInt(this.ping); }
From source file:eu.matejkormuth.rpgdavid.starving.remote.netty.handlers.ByteBufToPacketEncoder.java
License:Open Source License
@Override protected void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception { out.writeShort(protocol.getId(msg)); msg.writeTo(out);// www . ja va2s . c o m }
From source file:eu.matejkormuth.rpgdavid.starving.remote.netty.handlers.ShortHeaderFrameEncoder.java
License:Open Source License
@Override protected void encode(final ChannelHandlerContext paramChannelHandlerContext, final ByteBuf msg, final ByteBuf out) throws Exception { out.writeShort(msg.readableBytes()); out.writeBytes(msg);//from w w w.j a v a 2s.co m }
From source file:eu.matejkormuth.rpgdavid.starving.remote.netty.packets.CommandPacket.java
License:Open Source License
@Override public void writeTo(ByteBuf toBuffer) { toBuffer.writeShort(command.length()); toBuffer.writeBytes(command.getBytes(PROTOCOL_ENCODING)); }
From source file:eu.matejkormuth.rpgdavid.starving.remote.netty.packets.DisconnectPacket.java
License:Open Source License
@Override public void writeTo(ByteBuf toBuffer) { toBuffer.writeShort(reason.length()); toBuffer.writeBytes(reason.getBytes(PROTOCOL_ENCODING)); }