diff --git a/src/main/java/tools/PacketCreator.java b/src/main/java/tools/PacketCreator.java index fa0d8fe580..b9d9b9c946 100644 --- a/src/main/java/tools/PacketCreator.java +++ b/src/main/java/tools/PacketCreator.java @@ -2127,9 +2127,9 @@ public class PacketCreator { } /** - * Adds a announcement box to an existing MaplePacketLittleEndianWriter. + * Adds an announcement box to an existing OutPacket. * - * @param p The MaplePacketLittleEndianWriter to add an announcement box + * @param p The OutPacket to add an announcement box * to. * @param shop The shop to announce. */ @@ -5844,7 +5844,7 @@ public class PacketCreator { boolean hasOtherJunior = false; int entryCount = 2; //2 guaranteed, leader and self entryCount += Math.min(2, entry.getTotalSeniors()); - //needed since MaplePacketLittleEndianWriter doesn't have any seek functionality + //needed since OutPacket doesn't have any seek functionality if (entry.getSenior() != null) { if (entry.getSenior().getJuniorCount() == 2) { entryCount++; diff --git a/src/main/java/tools/data/output/BAOSByteOutputStream.java b/src/main/java/tools/data/output/BAOSByteOutputStream.java deleted file mode 100644 index 80cbc9301e..0000000000 --- a/src/main/java/tools/data/output/BAOSByteOutputStream.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ -package tools.data.output; - -import java.io.ByteArrayOutputStream; - -/** - * Uses a byte array to output a stream of bytes. - * - * @author Frz - * @version 1.0 - * @since Revision 352 - */ -class BAOSByteOutputStream implements ByteOutputStream { - private ByteArrayOutputStream baos; - - /** - * Class constructor - Wraps the stream around a Java BAOS. - * - * @param baos The ByteArrayOutputStream to wrap this around. - */ - BAOSByteOutputStream(ByteArrayOutputStream baos) { - super(); - this.baos = baos; - } - - /** - * Writes a byte to the stream. - * - * @param b The byte to write to the stream. - * @see tools.data.output.ByteOutputStream#writeByte(byte) - */ - @Override - public void writeByte(byte b) { - baos.write(b); - } -} diff --git a/src/main/java/tools/data/output/ByteOutputStream.java b/src/main/java/tools/data/output/ByteOutputStream.java deleted file mode 100644 index 0df7ca7753..0000000000 --- a/src/main/java/tools/data/output/ByteOutputStream.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ -package tools.data.output; - -/** - * Provides an interface to an output stream of bytes. - * - * @author Frz - * @since Revision 323 - * @version 1.0 - */ -interface ByteOutputStream { - /** - * Writes a byte to the stream. - * - * @param b The byte to write. - */ - void writeByte(byte b); -} diff --git a/src/main/java/tools/data/output/GenericLittleEndianWriter.java b/src/main/java/tools/data/output/GenericLittleEndianWriter.java deleted file mode 100644 index 70965077ca..0000000000 --- a/src/main/java/tools/data/output/GenericLittleEndianWriter.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ -package tools.data.output; - -import constants.string.CharsetConstants.MapleLanguageType; - -import java.awt.*; -import java.nio.charset.Charset; - -/** - * Provides a generic writer of a little-endian sequence of bytes. - * - * @author Frz - * @version 1.0 - * @since Revision 323 - */ -public class GenericLittleEndianWriter implements LittleEndianWriter { - private static Charset ASCII = Charset.forName(MapleLanguageType.LANGUAGE_US.getAscii()); - private ByteOutputStream bos; - - /** - * Class constructor - Protected to prevent instantiation with no arguments. - */ - protected GenericLittleEndianWriter() { - // Blah! - } - - /** - * Sets the byte-output stream for this instance of the object. - * - * @param bos The new output stream to set. - */ - void setByteOutputStream(ByteOutputStream bos) { - this.bos = bos; - } - - /** - * Write an array of bytes to the stream. - * - * @param b The bytes to write. - */ - @Override - public void write(byte[] b) { - for (byte value : b) { - bos.writeByte(value); - } - } - - /** - * Write a byte to the stream. - * - * @param b The byte to write. - */ - @Override - public void write(byte b) { - bos.writeByte(b); - } - - /** - * Write a byte in integer form to the stream. - * - * @param b The byte as an Integer to write. - */ - @Override - public void write(int b) { - bos.writeByte((byte) b); - } - - @Override - public void skip(int b) { - write(new byte[b]); - } - - /** - * Write a short integer to the stream. - * - * @param i The short integer to write. - */ - @Override - public void writeShort(int i) { - bos.writeByte((byte) (i & 0xFF)); - bos.writeByte((byte) ((i >>> 8) & 0xFF)); - } - - /** - * Writes an integer to the stream. - * - * @param i The integer to write. - */ - @Override - public void writeInt(int i) { - bos.writeByte((byte) (i & 0xFF)); - bos.writeByte((byte) ((i >>> 8) & 0xFF)); - bos.writeByte((byte) ((i >>> 16) & 0xFF)); - bos.writeByte((byte) ((i >>> 24) & 0xFF)); - } - - /** - * Writes an ASCII string the the stream. - * - * @param s The ASCII string to write. - */ - @Override - public void writeAsciiString(String s) { - write(s.getBytes(ASCII)); - } - - /** - * Writes a maple-convention ASCII string to the stream. - * - * @param s The ASCII string to use maple-convention to write. - */ - @Override - public void writeMapleAsciiString(String s) { - writeShort((short) s.length()); - writeAsciiString(s); - } - - /** - * Writes a null-terminated ASCII string to the stream. - * - * @param s The ASCII string to write. - */ - @Override - public void writeNullTerminatedAsciiString(String s) { - writeAsciiString(s); - write(0); - } - - /** - * Write a long integer to the stream. - * @param l The long integer to write. - */ - @Override - public void writeLong(long l) { - bos.writeByte((byte) (l & 0xFF)); - bos.writeByte((byte) ((l >>> 8) & 0xFF)); - bos.writeByte((byte) ((l >>> 16) & 0xFF)); - bos.writeByte((byte) ((l >>> 24) & 0xFF)); - bos.writeByte((byte) ((l >>> 32) & 0xFF)); - bos.writeByte((byte) ((l >>> 40) & 0xFF)); - bos.writeByte((byte) ((l >>> 48) & 0xFF)); - bos.writeByte((byte) ((l >>> 56) & 0xFF)); - } - - /** - * Writes a 2D 4 byte position information - * - * @param s The Point position to write. - */ - @Override - public void writePos(Point s) { - writeShort(s.x); - writeShort(s.y); - } - - /** - * Writes a boolean true ? 1 : 0 - * - * @param b The boolean to write. - */ - @Override - public void writeBool(final boolean b) { - write(b ? 1 : 0); - } -} diff --git a/src/main/java/tools/data/output/LittleEndianWriter.java b/src/main/java/tools/data/output/LittleEndianWriter.java deleted file mode 100644 index 0ec260fbaf..0000000000 --- a/src/main/java/tools/data/output/LittleEndianWriter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package tools.data.output; - -import java.awt.*; - -/** - * Provides an interface to a writer class that writes a little-endian sequence - * of bytes. - * - * @author Frz - * @version 1.0 - * @since Revision 323 - */ -public interface LittleEndianWriter { - - /** - * Write an array of bytes to the sequence. - * - * @param b The bytes to write. - */ - void write(byte[] b); - - /** - * Write a byte to the sequence. - * - * @param b The byte to write. - */ - void write(byte b); - - /** - * Write a byte in integer form to the sequence. - * - * @param b The byte as an Integer to write. - */ - void write(int b); - - void skip(int b); - - /** - * Writes an integer to the sequence. - * - * @param i The integer to write. - */ - void writeInt(int i); - - /** - * Write a short integer to the sequence. - * - * @param s The short integer to write. - */ - void writeShort(int s); - - /** - * Write a long integer to the sequence. - * - * @param l The long integer to write. - */ - void writeLong(long l); - - /** - * Writes an ASCII string the the sequence. - * - * @param s The ASCII string to write. - */ - void writeAsciiString(String s); - - /** - * Writes a null-terminated ASCII string to the sequence. - * - * @param s The ASCII string to write. - */ - void writeNullTerminatedAsciiString(String s); - - /** - * Writes a maple-convention ASCII string to the sequence. - * - * @param s The ASCII string to use maple-convention to write. - */ - void writeMapleAsciiString(String s); - - /** - * Writes a 2D 4 byte position information - * - * @param s The Point position to write. - */ - void writePos(Point s); - - /** - * Writes a boolean true ? 1 : 0 - * - * @param b The boolean to write. - */ - void writeBool(final boolean b); -} diff --git a/src/main/java/tools/data/output/MaplePacketLittleEndianWriter.java b/src/main/java/tools/data/output/MaplePacketLittleEndianWriter.java deleted file mode 100644 index b02365ec62..0000000000 --- a/src/main/java/tools/data/output/MaplePacketLittleEndianWriter.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ -package tools.data.output; - -import java.io.ByteArrayOutputStream; -import tools.HexTool; - -/** - * Writes a maplestory-packet little-endian stream of bytes. - * - * @author Frz - * @version 1.0 - * @since Revision 352 - */ -public class MaplePacketLittleEndianWriter extends GenericLittleEndianWriter { - private ByteArrayOutputStream baos; - - /** - * Constructor - initializes this stream with a default size. - */ - public MaplePacketLittleEndianWriter() { - this(32); - } - - /** - * Constructor - initializes this stream with size size. - * - * @param size The size of the underlying stream. - */ - public MaplePacketLittleEndianWriter(int size) { - this.baos = new ByteArrayOutputStream(size); - setByteOutputStream(new BAOSByteOutputStream(baos)); - } - - /** - * Gets a MaplePacket instance representing this - * sequence of bytes. - * - * @return A MaplePacket with the bytes in this stream. - */ - public byte[] getPacket() { - return baos.toByteArray(); - } - - /** - * Changes this packet into a human-readable hexadecimal stream of bytes. - * - * @return This packet as hex digits. - */ - @Override - public String toString() { - return HexTool.toString(baos.toByteArray()); - } -}