Code Coupons + Worldmap update + Mini-games + Player Interaction wrap
Fixed several cases on the Cash Shop that would freeze some player actions when triggered, requiring exit Cash Shop to unstuck. Implemented Code Coupons, supporting several items bundled on the same code, and also devised a way to automate code generation. Added a current status on-demand option on the Buyback command. Info such as "current fee" or "time remaining" are available now. Reviewed several cases where non-owned items would get stacked with owner-tagged items. Added Door support for Happyville, Crimsonwood Keep. Added worldmap tooltip support for some maps in Masteria's C. Keep and H. House. Added Masteria region to the world map. C. Keep interiors no longer relocates players to entrance after actions such as logout. Overhauled minigame mechanics: from player boxes tooltip and in-match improvements to deploy different minigame types, accordingly with item description or player choice. Fixed Amoria outskirts not relocating players to city after getting KO'ed. Fixed issues with pets, rings and cash items being assigned the same cash unique ids leading to some quirks on the cash shop inventory. Fixed an issue with the recently added HP/MP ratio update, arbitrarily taking off 1 point in certain cases. Answer positions on the explorer's 3rd job quiz are now randomed. Fixed several issues that showed up when the bcrypt system is disabled. DOT from maps such as El Nath and Aqua Road now procs at a 5sec interval, GMS-like. Improved performance of Whodrops and Search commands. Concurrently protected player interaction handlers, thus mitigating several exploits on these lines. Adjusted several expedition timers, such as Horntail, now having a more sane deadline. Concurrently protected chair modules. Fixed "seduce" debuff not working on chairs.
This commit is contained in:
87
tools/SpiderDropFetcher/src/tools/HexTool.java
Normal file
87
tools/SpiderDropFetcher/src/tools/HexTool.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class HexTool {
|
||||
private static final char[] HEX = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
private static String toString(byte byteValue) {
|
||||
int tmp = byteValue << 8;
|
||||
char[] retstr = new char[]{HEX[(tmp >> 12) & 0x0F], HEX[(tmp >> 8) & 0x0F]};
|
||||
return String.valueOf(retstr);
|
||||
}
|
||||
|
||||
public static String toString(byte[] bytes) {
|
||||
StringBuilder hexed = new StringBuilder();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
hexed.append(toString(bytes[i]));
|
||||
hexed.append(' ');
|
||||
}
|
||||
return hexed.substring(0, hexed.length() - 1);
|
||||
}
|
||||
|
||||
public static String toCompressedString(byte[] bytes) {
|
||||
StringBuilder hexed = new StringBuilder();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
hexed.append(toString(bytes[i]));
|
||||
}
|
||||
return hexed.substring(0, hexed.length());
|
||||
}
|
||||
|
||||
public static byte[] getByteArrayFromHexString(String hex) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int nexti = 0;
|
||||
int nextb = 0;
|
||||
boolean highoc = true;
|
||||
outer:
|
||||
for (;;) {
|
||||
int number = -1;
|
||||
while (number == -1) {
|
||||
if (nexti == hex.length()) {
|
||||
break outer;
|
||||
}
|
||||
char chr = hex.charAt(nexti);
|
||||
if (chr >= '0' && chr <= '9') {
|
||||
number = chr - '0';
|
||||
} else if (chr >= 'a' && chr <= 'f') {
|
||||
number = chr - 'a' + 10;
|
||||
} else if (chr >= 'A' && chr <= 'F') {
|
||||
number = chr - 'A' + 10;
|
||||
} else {
|
||||
number = -1;
|
||||
}
|
||||
nexti++;
|
||||
}
|
||||
if (highoc) {
|
||||
nextb = number << 4;
|
||||
highoc = false;
|
||||
} else {
|
||||
nextb |= number;
|
||||
highoc = true;
|
||||
baos.write(nextb);
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
}
|
||||
123
tools/SpiderDropFetcher/src/tools/Pair.java
Normal file
123
tools/SpiderDropFetcher/src/tools/Pair.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package tools;
|
||||
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Represents a pair of values.
|
||||
*
|
||||
* @author Frz
|
||||
* @since Revision 333
|
||||
* @version 1.0
|
||||
*
|
||||
* @param <E> The type of the left value.
|
||||
* @param <F> The type of the right value.
|
||||
*/
|
||||
public class Pair<E, F> {
|
||||
|
||||
public E left;
|
||||
public F right;
|
||||
|
||||
/**
|
||||
* Class constructor - pairs two objects together.
|
||||
*
|
||||
* @param left The left object.
|
||||
* @param right The right object.
|
||||
*/
|
||||
public Pair(E left, F right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the left value.
|
||||
*
|
||||
* @return The left value.
|
||||
*/
|
||||
public E getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right value.
|
||||
*
|
||||
* @return The right value.
|
||||
*/
|
||||
public F getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the pair into a string.
|
||||
*
|
||||
* @return Each value of the pair as a string joined by a colon.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return left.toString() + ":" + right.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hash code of this pair.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((left == null) ? 0 : left.hashCode());
|
||||
result = prime * result + ((right == null) ? 0 : right.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if two pairs are equal.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Pair other = (Pair) obj;
|
||||
if (left == null) {
|
||||
if (other.left != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!left.equals(other.left)) {
|
||||
return false;
|
||||
}
|
||||
if (right == null) {
|
||||
if (other.right != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!right.equals(other.right)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.io.IOException;
|
||||
import tools.HexTool;
|
||||
|
||||
public class ByteArrayByteStream implements SeekableInputStreamBytestream {
|
||||
private int pos = 0;
|
||||
private long bytesRead = 0;
|
||||
private byte[] arr;
|
||||
|
||||
public ByteArrayByteStream(byte[] arr) {
|
||||
this.arr = arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPosition() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seek(long offset) throws IOException {
|
||||
pos = (int) offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytesRead() {
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readByte() {
|
||||
bytesRead++;
|
||||
return ((int) arr[pos++]) & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String nows = "kevintjuh93 pwns";//I lol'd
|
||||
if (arr.length - pos > 0) {
|
||||
byte[] now = new byte[arr.length - pos];
|
||||
System.arraycopy(arr, pos, now, 0, arr.length - pos);
|
||||
nows = HexTool.toString(now);
|
||||
}
|
||||
return "All: " + HexTool.toString(arr) + "\nNow: " + nows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long available() {
|
||||
return arr.length - pos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
/**
|
||||
* Represents an abstract stream of bytes.
|
||||
*
|
||||
* @author Frz
|
||||
* @version 1.0
|
||||
* @since Revision 323
|
||||
*/
|
||||
public interface ByteInputStream {
|
||||
int readByte();
|
||||
long getBytesRead();
|
||||
long available();
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* Provides a generic interface to a Little Endian stream of bytes.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Frz
|
||||
* @since Revision 323
|
||||
*/
|
||||
public class GenericLittleEndianAccessor implements LittleEndianAccessor {
|
||||
private ByteInputStream bs;
|
||||
|
||||
/**
|
||||
* Class constructor - Wraps the accessor around a stream of bytes.
|
||||
*
|
||||
* @param bs The byte stream to wrap the accessor around.
|
||||
*/
|
||||
public GenericLittleEndianAccessor(ByteInputStream bs) {
|
||||
this.bs = bs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a single byte from the stream.
|
||||
*
|
||||
* @return The byte read.
|
||||
* @see tools.data.input.ByteInputStream#readByte
|
||||
*/
|
||||
@Override
|
||||
public byte readByte() {
|
||||
return (byte) bs.readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an integer from the stream.
|
||||
*
|
||||
* @return The integer read.
|
||||
*/
|
||||
@Override
|
||||
public int readInt() {
|
||||
return bs.readByte() + (bs.readByte() << 8) + (bs.readByte() << 16) + (bs.readByte() << 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a short integer from the stream.
|
||||
*
|
||||
* @return The short read.
|
||||
*/
|
||||
@Override
|
||||
public short readShort() {
|
||||
return (short) (bs.readByte() + (bs.readByte() << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a single character from the stream.
|
||||
*
|
||||
* @return The character read.
|
||||
*/
|
||||
@Override
|
||||
public char readChar() {
|
||||
return (char) readShort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a long integer from the stream.
|
||||
*
|
||||
* @return The long integer read.
|
||||
*/
|
||||
@Override
|
||||
public long readLong() {
|
||||
long byte1 = bs.readByte();
|
||||
long byte2 = bs.readByte();
|
||||
long byte3 = bs.readByte();
|
||||
long byte4 = bs.readByte();
|
||||
long byte5 = bs.readByte();
|
||||
long byte6 = bs.readByte();
|
||||
long byte7 = bs.readByte();
|
||||
long byte8 = bs.readByte();
|
||||
return (byte8 << 56) + (byte7 << 48) + (byte6 << 40) + (byte5 << 32) + (byte4 << 24) + (byte3 << 16) + (byte2 << 8) + byte1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a floating point integer from the stream.
|
||||
*
|
||||
* @return The float-type integer read.
|
||||
*/
|
||||
@Override
|
||||
public float readFloat() {
|
||||
return Float.intBitsToFloat(readInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a double-precision integer from the stream.
|
||||
*
|
||||
* @return The double-type integer read.
|
||||
*/
|
||||
@Override
|
||||
public double readDouble() {
|
||||
return Double.longBitsToDouble(readLong());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an ASCII string from the stream with length <code>n</code>.
|
||||
*
|
||||
* @param n Number of characters to read.
|
||||
* @return The string read.
|
||||
*/
|
||||
public final String readAsciiString(int n) {
|
||||
char ret[] = new char[n];
|
||||
for (int x = 0; x < n; x++) {
|
||||
ret[x] = (char) readByte();
|
||||
}
|
||||
return String.valueOf(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a null-terminated string from the stream.
|
||||
*
|
||||
* @return The string read.
|
||||
*/
|
||||
public final String readNullTerminatedAsciiString() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte b;
|
||||
while (true) {
|
||||
b = readByte();
|
||||
if (b == 0) {
|
||||
break;
|
||||
}
|
||||
baos.write(b);
|
||||
}
|
||||
byte[] buf = baos.toByteArray();
|
||||
char[] chrBuf = new char[buf.length];
|
||||
for (int x = 0; x < buf.length; x++) {
|
||||
chrBuf[x] = (char) buf[x];
|
||||
}
|
||||
return String.valueOf(chrBuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of bytes read from the stream so far.
|
||||
*
|
||||
* @return A long integer representing the number of bytes read.
|
||||
* @see tools.data.input.ByteInputStream#getBytesRead()
|
||||
*/
|
||||
public long getBytesRead() {
|
||||
return bs.getBytesRead();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a MapleStory convention lengthed ASCII string.
|
||||
* This consists of a short integer telling the length of the string,
|
||||
* then the string itself.
|
||||
*
|
||||
* @return The string read.
|
||||
*/
|
||||
@Override
|
||||
public String readMapleAsciiString() {
|
||||
return readAsciiString(readShort());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <code>num</code> bytes off the stream.
|
||||
*
|
||||
* @param num The number of bytes to read.
|
||||
* @return An array of bytes with the length of <code>num</code>
|
||||
*/
|
||||
@Override
|
||||
public byte[] read(int num) {
|
||||
byte[] ret = new byte[num];
|
||||
for (int x = 0; x < num; x++) {
|
||||
ret[x] = readByte();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a MapleStory Position information.
|
||||
* This consists of 2 short integer.
|
||||
*
|
||||
* @return The Position read.
|
||||
*/
|
||||
@Override
|
||||
public final Point readPos() {
|
||||
final int x = readShort();
|
||||
final int y = readShort();
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the current position of the stream <code>num</code> bytes ahead.
|
||||
*
|
||||
* @param num Number of bytes to skip.
|
||||
*/
|
||||
@Override
|
||||
public void skip(int num) {
|
||||
for (int x = 0; x < num; x++) {
|
||||
readByte();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see tools.data.input.ByteInputStream#available
|
||||
*/
|
||||
@Override
|
||||
public long available() {
|
||||
return bs.available();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return bs.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Provides an abstract accessor to a generic Little Endian byte stream. This
|
||||
* accessor is seekable.
|
||||
*
|
||||
* @author Frz
|
||||
* @version 1.0
|
||||
* @since Revision 323
|
||||
* @see tools.data.input.GenericLittleEndianAccessor
|
||||
*/
|
||||
public class GenericSeekableLittleEndianAccessor extends GenericLittleEndianAccessor implements SeekableLittleEndianAccessor {
|
||||
private SeekableInputStreamBytestream bs;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
* Provide a seekable input stream to wrap this object around.
|
||||
*
|
||||
* @param bs The byte stream to wrap this around.
|
||||
*/
|
||||
public GenericSeekableLittleEndianAccessor(SeekableInputStreamBytestream bs) {
|
||||
super(bs);
|
||||
this.bs = bs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek the pointer to <code>offset</code>
|
||||
*
|
||||
* @param offset The offset to seek to.
|
||||
* @see tools.data.input.SeekableInputStreamBytestream#seek
|
||||
*/
|
||||
@Override
|
||||
public void seek(long offset) {
|
||||
try {
|
||||
bs.seek(offset);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Seek failed " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current position of the pointer.
|
||||
*
|
||||
* @return The current position of the pointer as a long integer.
|
||||
* @see tools.data.input.SeekableInputStreamBytestream#getPosition
|
||||
*/
|
||||
@Override
|
||||
public long getPosition() {
|
||||
try {
|
||||
return bs.getPosition();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("getPosition failed" + e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip <code>num</code> number of bytes in the stream.
|
||||
*
|
||||
* @param num The number of bytes to skip.
|
||||
*/
|
||||
@Override
|
||||
public void skip(int num) {
|
||||
seek(getPosition() + num);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Provides an abstract wrapper to a stream of bytes.
|
||||
*
|
||||
* @author Frz
|
||||
* @version 1.0
|
||||
* @since Revision 323
|
||||
*/
|
||||
public class InputStreamByteStream implements ByteInputStream {
|
||||
private InputStream is;
|
||||
private long read = 0;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Provide an input stream to wrap this around.
|
||||
*
|
||||
* @param is The input stream to wrap this object around.
|
||||
*/
|
||||
public InputStreamByteStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the next byte from the stream.
|
||||
*
|
||||
* @return Then next byte in the stream.
|
||||
*/
|
||||
@Override
|
||||
public int readByte() {
|
||||
int temp;
|
||||
try {
|
||||
temp = is.read();
|
||||
if (temp == -1) {
|
||||
throw new RuntimeException("EOF");
|
||||
}
|
||||
read++;
|
||||
return temp;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of bytes read from the stream.
|
||||
*
|
||||
* @return The number of bytes read as a long integer.
|
||||
*/
|
||||
@Override
|
||||
public long getBytesRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes left in the stream.
|
||||
*
|
||||
* @return The number of bytes available for reading as a long integer.
|
||||
*/
|
||||
@Override
|
||||
public long available() {
|
||||
try {
|
||||
return is.available();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("ERROR" + e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
/**
|
||||
* @author Frz
|
||||
*/
|
||||
public interface LittleEndianAccessor {
|
||||
byte readByte();
|
||||
char readChar();
|
||||
short readShort();
|
||||
int readInt();
|
||||
Point readPos();
|
||||
long readLong();
|
||||
void skip(int num);
|
||||
byte[] read(int num);
|
||||
float readFloat();
|
||||
double readDouble();
|
||||
String readAsciiString(int n);
|
||||
String readNullTerminatedAsciiString();
|
||||
String readMapleAsciiString();
|
||||
long getBytesRead();
|
||||
long available();
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* Provides an abstract layer to a byte stream. This layer can be accessed
|
||||
* randomly.
|
||||
*
|
||||
* @author Frz
|
||||
* @version 1.0
|
||||
* @since Revision 323
|
||||
*/
|
||||
public class RandomAccessByteStream implements SeekableInputStreamBytestream {
|
||||
private RandomAccessFile raf;
|
||||
private long read = 0;
|
||||
|
||||
public RandomAccessByteStream(RandomAccessFile raf) {
|
||||
super();
|
||||
this.raf = raf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readByte() {
|
||||
int temp;
|
||||
try {
|
||||
temp = raf.read();
|
||||
if (temp == -1) {
|
||||
throw new RuntimeException("EOF");
|
||||
}
|
||||
read++;
|
||||
return temp;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seek(long offset) throws IOException {
|
||||
raf.seek(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPosition() throws IOException {
|
||||
return raf.getFilePointer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytesRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long available() {
|
||||
try {
|
||||
return raf.length() - raf.getFilePointer();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("ERROR " + e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Provides an abstract interface to a stream of bytes. This stream can be
|
||||
* seeked.
|
||||
*
|
||||
* @author Frz
|
||||
* @version 1.0
|
||||
* @since 299
|
||||
*/
|
||||
public interface SeekableInputStreamBytestream extends ByteInputStream {
|
||||
/**
|
||||
* Seeks the stream by the specified offset.
|
||||
*
|
||||
* @param offset
|
||||
* Number of bytes to seek.
|
||||
* @throws IOException
|
||||
*/
|
||||
void seek(long offset) throws IOException;
|
||||
|
||||
/**
|
||||
* Gets the current position of the stream.
|
||||
*
|
||||
* @return The stream position as a long integer.
|
||||
* @throws IOException
|
||||
*/
|
||||
long getPosition() throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.input;
|
||||
|
||||
public interface SeekableLittleEndianAccessor extends LittleEndianAccessor {
|
||||
void seek(long offset);
|
||||
long getPosition();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 <code>The ByteArrayOutputStream</code> 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.output;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.nio.charset.Charset;
|
||||
import constants.CharsetConstants.MapleLanguageType;
|
||||
|
||||
/**
|
||||
* 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 (int x = 0; x < b.length; x++) {
|
||||
bos.writeByte(b[x]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <code>Integer</code> 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package tools.data.output;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void write(byte b[]);
|
||||
|
||||
/**
|
||||
* Write a byte to the sequence.
|
||||
*
|
||||
* @param b The byte to write.
|
||||
*/
|
||||
public void write(byte b);
|
||||
|
||||
/**
|
||||
* Write a byte in integer form to the sequence.
|
||||
*
|
||||
* @param b The byte as an <code>Integer</code> to write.
|
||||
*/
|
||||
public void write(int b);
|
||||
|
||||
public void skip(int b);
|
||||
|
||||
/**
|
||||
* Writes an integer to the sequence.
|
||||
*
|
||||
* @param i The integer to write.
|
||||
*/
|
||||
public void writeInt(int i);
|
||||
|
||||
/**
|
||||
* Write a short integer to the sequence.
|
||||
*
|
||||
* @param s The short integer to write.
|
||||
*/
|
||||
public void writeShort(int s);
|
||||
|
||||
/**
|
||||
* Write a long integer to the sequence.
|
||||
*
|
||||
* @param l The long integer to write.
|
||||
*/
|
||||
public 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);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 <code>size</code>.
|
||||
*
|
||||
* @param size The size of the underlying stream.
|
||||
*/
|
||||
public MaplePacketLittleEndianWriter(int size) {
|
||||
this.baos = new ByteArrayOutputStream(size);
|
||||
setByteOutputStream(new BAOSByteOutputStream(baos));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a <code>MaplePacket</code> instance representing this
|
||||
* sequence of bytes.
|
||||
*
|
||||
* @return A <code>MaplePacket</code> 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user