threadless client (for web)

This commit is contained in:
Mister Hat 2021-07-18 21:51:38 -05:00
parent 092b3669d9
commit 5583ddff51
26 changed files with 20125 additions and 0 deletions

View File

@ -0,0 +1,513 @@
public class BZLib {
public static int decompress(byte out[], int outSize, byte in[], int inSize, int offset) {
BZState block = new BZState();
block.input = in;
block.nextIn = offset;
block.output = out;
block.availOut = 0;
block.availIn = inSize;
block.decompressedSize = outSize;
block.bsLive = 0;
block.bsBuff = 0;
block.totalInLo32 = 0;
block.totalInHi32 = 0;
block.totalOutLo32 = 0;
block.totalOutHi32 = 0;
block.blockNo = 0;
decompress(block);
outSize -= block.decompressedSize;
return outSize;
}
private static void nextHeader(BZState state) {
byte cStateOutCh = state.stateOutCh;
int cStateOutLen = state.stateOutLen;
int cNblockUsed = state.nblockUsed;
int cK0 = state.k0;
int cTt[] = state.tt;
int cTpos = state.tpos;
byte output[] = state.output;
int csNextOut = state.availOut;
int csAvailOut = state.decompressedSize;
int asdasdasd = csAvailOut;
int sSaveNblockPP = state.saveNblock + 1;
returnNotr:
do {
if (cStateOutLen > 0) {
do {
if (csAvailOut == 0)
break returnNotr;
if (cStateOutLen == 1)
break;
output[csNextOut] = cStateOutCh;
cStateOutLen--;
csNextOut++;
csAvailOut--;
} while (true);
if (csAvailOut == 0) {
cStateOutLen = 1;
break;
}
output[csNextOut] = cStateOutCh;
csNextOut++;
csAvailOut--;
}
boolean flag = true;
while (flag) {
flag = false;
if (cNblockUsed == sSaveNblockPP) {
cStateOutLen = 0;
break returnNotr;
}
cStateOutCh = (byte) cK0;
cTpos = cTt[cTpos];
byte k1 = (byte) (cTpos & 0xff);
cTpos >>= 8;
cNblockUsed++;
if (k1 != cK0) {
cK0 = k1;
if (csAvailOut == 0) {
cStateOutLen = 1;
} else {
output[csNextOut] = cStateOutCh;
csNextOut++;
csAvailOut--;
flag = true;
continue;
}
break returnNotr;
}
if (cNblockUsed != sSaveNblockPP)
continue;
if (csAvailOut == 0) {
cStateOutLen = 1;
break returnNotr;
}
output[csNextOut] = cStateOutCh;
csNextOut++;
csAvailOut--;
flag = true;
}
cStateOutLen = 2;
cTpos = cTt[cTpos];
byte k2 = (byte) (cTpos & 0xff);
cTpos >>= 8;
if (++cNblockUsed != sSaveNblockPP)
if (k2 != cK0) {
cK0 = k2;
} else {
cStateOutLen = 3;
cTpos = cTt[cTpos];
byte k3 = (byte) (cTpos & 0xff);
cTpos >>= 8;
if (++cNblockUsed != sSaveNblockPP)
if (k3 != cK0) {
cK0 = k3;
} else {
cTpos = cTt[cTpos];
byte byte3 = (byte) (cTpos & 0xff);
cTpos >>= 8;
cNblockUsed++;
cStateOutLen = (byte3 & 0xff) + 4;
cTpos = cTt[cTpos];
cK0 = (byte) (cTpos & 0xff);
cTpos >>= 8;
cNblockUsed++;
}
}
} while (true);
int i2 = state.totalOutLo32;
state.totalOutLo32 += asdasdasd - csAvailOut;
if (state.totalOutLo32 < i2)
state.totalOutHi32++;
state.stateOutCh = cStateOutCh;
state.stateOutLen = cStateOutLen;
state.nblockUsed = cNblockUsed;
state.k0 = cK0;
state.tt = cTt;
state.tpos = cTpos;
state.output = output;
state.availOut = csNextOut;
state.decompressedSize = csAvailOut;
}
private static void decompress(BZState state) {
/*boolean flag = false;
boolean flag1 = false;
boolean flag2 = false;
boolean flag3 = false;
boolean flag4 = false;
boolean flag5 = false;
boolean flag6 = false;
boolean flag7 = false;
boolean flag8 = false;
boolean flag9 = false;
boolean flag10 = false;
boolean flag11 = false;
boolean flag12 = false;
boolean flag13 = false;
boolean flag14 = false;
boolean flag15 = false;
boolean flag16 = false;
boolean flag17 = false;
boolean flag18 = false;*/
int gMinLen = 0;
int gLimit[] = null;
int gBase[] = null;
int gPerm[] = null;
state.blocksize100k = 1;
if (state.tt == null)
state.tt = new int[state.blocksize100k * 100000];
boolean goingandshit = true;
while (goingandshit) {
byte uc = getUchar(state);
if (uc == 23)
return;
uc = getUchar(state);
uc = getUchar(state);
uc = getUchar(state);
uc = getUchar(state);
uc = getUchar(state);
state.blockNo++;
uc = getUchar(state);
uc = getUchar(state);
uc = getUchar(state);
uc = getUchar(state);
uc = getBit(state);
state.blockRandomised = uc != 0;
if (state.blockRandomised)
System.out.println("PANIC! RANDOMISED BLOCK!");
state.origPtr = 0;
uc = getUchar(state);
state.origPtr = state.origPtr << 8 | uc & 0xff;
uc = getUchar(state);
state.origPtr = state.origPtr << 8 | uc & 0xff;
uc = getUchar(state);
state.origPtr = state.origPtr << 8 | uc & 0xff;
for (int i = 0; i < 16; i++) {
uc = getBit(state);
state.inUse_16[i] = uc == 1;
}
for (int i = 0; i < 256; i++)
state.inUse[i] = false;
for (int i = 0; i < 16; i++)
if (state.inUse_16[i]) {
for (int j = 0; j < 16; j++) {
uc = getBit(state);
if (uc == 1)
state.inUse[i * 16 + j] = true;
}
}
makeMaps(state);
int alphaSize = state.nInUse + 2;
int nGroups = getBits(3, state);
int nSelectors = getBits(15, state);
for (int i = 0; i < nSelectors; i++) {
int j = 0;
do {
uc = getBit(state);
if (uc == 0)
break;
j++;
} while (true);
state.selectorMtf[i] = (byte) j;
}
byte pos[] = new byte[6];
for (byte v = 0; v < nGroups; v++)
pos[v] = v;
for (int i = 0; i < nSelectors; i++) {
byte v = state.selectorMtf[i];
byte tmp = pos[v];
for (; v > 0; v--)
pos[v] = pos[v - 1];
pos[0] = tmp;
state.selector[i] = tmp;
}
for (int t = 0; t < nGroups; t++) {
int curr = getBits(5, state);
for (int i = 0; i < alphaSize; i++) {
do {
uc = getBit(state);
if (uc == 0)
break;
uc = getBit(state);
if (uc == 0)
curr++;
else
curr--;
} while (true);
state.len[t][i] = (byte) curr;
}
}
for (int t = 0; t < nGroups; t++) {
byte minLen = 32;
int maxLen = 0;
for (int l1 = 0; l1 < alphaSize; l1++) {
if (state.len[t][l1] > maxLen)
maxLen = state.len[t][l1];
if (state.len[t][l1] < minLen)
minLen = state.len[t][l1];
}
createDecodeTables(state.limit[t], state.base[t], state.perm[t], state.len[t], minLen, maxLen, alphaSize);
state.minLens[t] = minLen;
}
int eob = state.nInUse + 1;
int nblockMax = 100000 * state.blocksize100k;
int groupNo = -1;
int groupPos = 0;
for (int i = 0; i <= 255; i++)
state.unzftab[i] = 0;
int kk = 4095; // MTFASIZE-1;
for (int ii = 15; ii >= 0; ii--) {
for (int jj = 15; jj >= 0; jj--) {
state.mtfa[kk] = (byte) (ii * 16 + jj);
kk--;
}
state.mtfbase[ii] = kk + 1;
}
int nblock = 0;
// GETMTFVAL
if (groupPos == 0) {
groupNo++;
groupPos = 50; // BZGSIZE
byte gSel = state.selector[groupNo];
gMinLen = state.minLens[gSel];
gLimit = state.limit[gSel];
gPerm = state.perm[gSel];
gBase = state.base[gSel];
}
groupPos--;
int zn = gMinLen;
int zvec;
byte zj;
for (zvec = getBits(zn, state); zvec > gLimit[zn]; zvec = zvec << 1 | zj) {
zn++;
zj = getBit(state);
}
for (int nextSym = gPerm[zvec - gBase[zn]]; nextSym != eob; )
if (nextSym == 0 || nextSym == 1) { // BZRUNA, BZRUNB
int es = -1;
int N = 1;
do {
if (nextSym == 0)
es += N;
else if (nextSym == 1)
es += 2 * N;
N *= 2;
// GETMTFVAL, y da fuk did they not subroutine this
if (groupPos == 0) {
groupNo++;
groupPos = 50;
byte gSel = state.selector[groupNo];
gMinLen = state.minLens[gSel];
gLimit = state.limit[gSel];
gPerm = state.perm[gSel];
gBase = state.base[gSel];
}
groupPos--;
int zn_2 = gMinLen;
int zvec_2;
byte zj_2;
for (zvec_2 = getBits(zn_2, state); zvec_2 > gLimit[zn_2]; zvec_2 = zvec_2 << 1 | zj_2) {
zn_2++;
zj_2 = getBit(state);
}
nextSym = gPerm[zvec_2 - gBase[zn_2]];
} while (nextSym == 0 || nextSym == 1);
es++;
uc = state.setToUnseq[state.mtfa[state.mtfbase[0]] & 0xff];
state.unzftab[uc & 0xff] += es;
for (; es > 0; es--) {
state.tt[nblock] = uc & 0xff;
nblock++;
}
} else {
int nn = nextSym - 1;
if (nn < 16) { // MTFLSIZE
int pp = state.mtfbase[0];
uc = state.mtfa[pp + nn];
for (; nn > 3; nn -= 4) {
int z = pp + nn;
state.mtfa[z] = state.mtfa[z - 1];
state.mtfa[z - 1] = state.mtfa[z - 2];
state.mtfa[z - 2] = state.mtfa[z - 3];
state.mtfa[z - 3] = state.mtfa[z - 4];
}
for (; nn > 0; nn--)
state.mtfa[pp + nn] = state.mtfa[(pp + nn) - 1];
state.mtfa[pp] = uc;
} else {
int lno = nn / 16;
int off = nn % 16;
int pp = state.mtfbase[lno] + off;
uc = state.mtfa[pp];
for (; pp > state.mtfbase[lno]; pp--)
state.mtfa[pp] = state.mtfa[pp - 1];
state.mtfbase[lno]++;
for (; lno > 0; lno--) {
state.mtfbase[lno]--;
state.mtfa[state.mtfbase[lno]] = state.mtfa[(state.mtfbase[lno - 1] + 16) - 1];
}
state.mtfbase[0]--;
state.mtfa[state.mtfbase[0]] = uc;
if (state.mtfbase[0] == 0) {
kk = 4095; // MTFASIZE - 1
for (int ii = 15; ii >= 0; ii--) {
for (int jj = 15; jj >= 0; jj--) {
state.mtfa[kk] = state.mtfa[state.mtfbase[ii] + jj];
kk--;
}
state.mtfbase[ii] = kk + 1;
}
}
}
state.unzftab[state.setToUnseq[uc & 0xff] & 0xff]++;
state.tt[nblock] = state.setToUnseq[uc & 0xff] & 0xff;
nblock++;
// GETMTFVAL here we go AGAIN
if (groupPos == 0) {
groupNo++;
groupPos = 50;
byte gSel = state.selector[groupNo];
gMinLen = state.minLens[gSel];
gLimit = state.limit[gSel];
gPerm = state.perm[gSel];
gBase = state.base[gSel];
}
groupPos--;
int zn_2 = gMinLen;
int zvec_2;
byte zj_2;
for (zvec_2 = getBits(zn_2, state); zvec_2 > gLimit[zn_2]; zvec_2 = zvec_2 << 1 | zj_2) {
zn_2++;
zj_2 = getBit(state);
}
nextSym = gPerm[zvec_2 - gBase[zn_2]];
}
state.stateOutLen = 0;
state.stateOutCh = 0;
state.cftab[0] = 0;
for (int i = 1; i <= 256; i++)
state.cftab[i] = state.unzftab[i - 1];
for (int i = 1; i <= 256; i++)
state.cftab[i] += state.cftab[i - 1];
for (int i = 0; i < nblock; i++) {
uc = (byte) (state.tt[i] & 0xff);
state.tt[state.cftab[uc & 0xff]] |= i << 8;
state.cftab[uc & 0xff]++;
}
state.tpos = state.tt[state.origPtr] >> 8;
state.nblockUsed = 0;
state.tpos = state.tt[state.tpos];
state.k0 = (byte) (state.tpos & 0xff);
state.tpos >>= 8;
state.nblockUsed++;
state.saveNblock = nblock;
nextHeader(state);
goingandshit = state.nblockUsed == state.saveNblock + 1 && state.stateOutLen == 0;
}
}
private static byte getUchar(BZState state) {
return (byte) getBits(8, state);
}
private static byte getBit(BZState state) {
return (byte) getBits(1, state);
}
private static int getBits(int i, BZState state) {
int vvv;
do {
if (state.bsLive >= i) {
int v = state.bsBuff >> state.bsLive - i & (1 << i) - 1;
state.bsLive -= i;
vvv = v;
break;
}
state.bsBuff = state.bsBuff << 8 | state.input[state.nextIn] & 0xff;
state.bsLive += 8;
state.nextIn++;
state.availIn--;
state.totalInLo32++;
if (state.totalInLo32 == 0)
state.totalInHi32++;
} while (true);
return vvv;
}
private static void makeMaps(BZState state) {
state.nInUse = 0;
for (int i = 0; i < 256; i++)
if (state.inUse[i]) {
state.setToUnseq[state.nInUse] = (byte) i;
state.nInUse++;
}
}
private static void createDecodeTables(int limit[], int base[], int perm[], byte length[], int minLen, int maxLen, int alphaSize) {
int pp = 0;
for (int i = minLen; i <= maxLen; i++) {
for (int j = 0; j < alphaSize; j++)
if (length[j] == i) {
perm[pp] = j;
pp++;
}
}
for (int i = 0; i < 23; i++)
base[i] = 0;
for (int i = 0; i < alphaSize; i++)
base[length[i] + 1]++;
for (int i = 1; i < 23; i++)
base[i] += base[i - 1];
for (int i = 0; i < 23; i++)
limit[i] = 0;
int vec = 0;
for (int i = minLen; i <= maxLen; i++) {
vec += base[i + 1] - base[i];
limit[i] = vec - 1;
vec <<= 1;
}
for (int i = minLen + 1; i <= maxLen; i++)
base[i] = (limit[i - 1] + 1 << 1) - base[i];
}
}

View File

@ -0,0 +1,70 @@
class BZState {
//int anIntArray488[]; // unused
public int tt[]; // this was static, wonder why?
/* unused
int anInt456 = 4096; // MTFASIZE ?
int anInt457 = 16; // MTFLSIZE
int anInt458 = 258;
int anInt459 = 23;
int anInt460 = 1;
int anInt461 = 6; // BZNGROUPS ?
int anInt462 = 50; // BZGSIZE ?
int anInt463 = 4;
int anInt464 = 18002; */
byte input[];
int nextIn;
int availIn;
int totalInLo32;
int totalInHi32;
byte output[];
int availOut;
int decompressedSize;
int totalOutLo32;
int totalOutHi32;
byte stateOutCh;
int stateOutLen;
boolean blockRandomised;
int bsBuff;
int bsLive;
int blocksize100k;
int blockNo;
int origPtr;
int tpos;
int k0;
int unzftab[];
int nblockUsed;
int cftab[];
int nInUse;
boolean inUse[];
boolean inUse_16[];
byte setToUnseq[];
byte mtfa[];
int mtfbase[];
byte selector[];
byte selectorMtf[];
byte len[][];
int limit[][];
int base[][];
int perm[][];
int minLens[];
int saveNblock;
BZState() {
unzftab = new int[256];
cftab = new int[257];
//anIntArray488 = new int[257]; // unused
inUse = new boolean[256];
inUse_16 = new boolean[16];
setToUnseq = new byte[256];
mtfa = new byte[4096];
mtfbase = new int[16];
selector = new byte[18002];
selectorMtf = new byte[18002];
len = new byte[6][258];
limit = new int[6][258];
base = new int[6][258];
perm = new int[6][258];
minLens = new int[6];
}
}

View File

@ -0,0 +1,79 @@
import java.math.BigInteger;
public class Buffer {
/*static CRC32 unusedCRC = new CRC32();
private static int unusedArray[] = {
0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff,
0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff,
0x3fffffff, 0x7fffffff, -1
};*/
public byte buffer[];
public int offset;
public Buffer(byte buff[]) {
buffer = buff;
offset = 0;
}
public void putByte(int i) {
buffer[offset++] = (byte) i;
}
public void putInt(int i) {
buffer[offset++] = (byte) (i >> 24);
buffer[offset++] = (byte) (i >> 16);
buffer[offset++] = (byte) (i >> 8);
buffer[offset++] = (byte) i;
}
public void putString(String s) {
//s.getBytes(0, s.length(), buffer, offset);
System.arraycopy(s.getBytes(), 0, buffer, offset, s.length());
offset += s.length();
buffer[offset++] = 10; // null terminate
}
public void putBytes(byte src[], int srcPos, int len) {
//for (int k = srcPos; k < srcPos + len; k++)
// buffer[offset++] = src[k];
System.arraycopy(src, srcPos, buffer, offset, len);
offset += len;
}
public int getUnsignedByte() {
return buffer[offset++] & 0xff;
}
public int getUnsignedShort() {
offset += 2;
return ((buffer[offset - 2] & 0xff) << 8) + (buffer[offset - 1] & 0xff);
}
public int getUnsignedInt() {
offset += 4;
return ((buffer[offset - 4] & 0xff) << 24) + ((buffer[offset - 3] & 0xff) << 16) + ((buffer[offset - 2] & 0xff) << 8) + (buffer[offset - 1] & 0xff);
}
public void getBytes(byte dest[], int destPos, int len) {
//for (int k = destPos; k < destPos + len; k++)
// dest[k] = buffer[offset++];
System.arraycopy(buffer, offset, dest, destPos, len);
offset += len;
}
public void encrypt(BigInteger exponent, BigInteger modulus) {
int i = offset;
offset = 0;
byte buf[] = new byte[i];
getBytes(buf, 0, i);
BigInteger biginteger2 = new BigInteger(buf);
BigInteger biginteger3 = biginteger2.modPow(exponent, modulus);
byte abyte1[] = biginteger3.toByteArray();
offset = 0;
putByte(abyte1.length);
putBytes(abyte1, 0, abyte1.length);
}
}

View File

@ -0,0 +1,101 @@
public class ChatMessage {
public static byte scrambledbytes[] = new byte[100];
public static char chars[] = new char[100];
private static char charmap[] = {
' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r',
'd', 'l', 'u', 'm', 'w', 'c', 'y', 'f', 'g', 'p',
'b', 'v', 'k', 'x', 'j', 'q', 'z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', ' ', '!', '?',
'.', ',', ':', ';', '(', ')', '-', '&', '*', '\\',
'\'', '@', '#', '+', '=', '\243', '$', '%', '"', '[',
']'
};
public static String descramble(byte buff[], int off, int len) {
try {
int newLen = 0;
int l = -1;
for (int idx = 0; idx < len; idx++) {
int current = buff[off++] & 0xff;
int k1 = current >> 4 & 0xf;
if (l == -1) {
if (k1 < 13)
chars[newLen++] = charmap[k1];
else
l = k1;
} else {
chars[newLen++] = charmap[((l << 4) + k1) - 195];
l = -1;
}
k1 = current & 0xf;
if (l == -1) {
if (k1 < 13)
chars[newLen++] = charmap[k1];
else
l = k1;
} else {
chars[newLen++] = charmap[((l << 4) + k1) - 195];
l = -1;
}
}
boolean flag = true;
for (int l1 = 0; l1 < newLen; l1++) {
char c = chars[l1];
if (l1 > 4 && c == '@')
chars[l1] = ' ';
if (c == '%')
chars[l1] = ' ';
if (flag && c >= 'a' && c <= 'z') {
chars[l1] += '\uFFE0';// ????? 65504
flag = false;
}
if (c == '.' || c == '!')
flag = true;
}
return new String(chars, 0, newLen);
} catch (Exception Ex) {
return ".";
}
}
public static int scramble(String s) {
if (s.length() > 80)
s = s.substring(0, 80);
s = s.toLowerCase();
int off = 0;
int lshift = -1;
for (int k = 0; k < s.length(); k++) {
char currentchar = s.charAt(k);
int foundcharmapidx = 0;
for (int n = 0; n < charmap.length; n++) {
if (currentchar != charmap[n])
continue;
foundcharmapidx = n;
break;
}
if (foundcharmapidx > 12)
foundcharmapidx += 195;
if (lshift == -1) {
if (foundcharmapidx < 13)
lshift = foundcharmapidx;
else
scrambledbytes[off++] = (byte) foundcharmapidx;
} else if (foundcharmapidx < 13) {
scrambledbytes[off++] = (byte) ((lshift << 4) + foundcharmapidx);
lshift = -1;
} else {
scrambledbytes[off++] = (byte) ((lshift << 4) + (foundcharmapidx >> 4));
lshift = foundcharmapidx & 0xf;
}
}
if (lshift != -1)
scrambledbytes[off++] = (byte) (lshift << 4);
return off;
}
}

View File

@ -0,0 +1,130 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
public class ClientStream extends Packet {
private InputStream instream;
private OutputStream outstream;
private Socket socket;
private boolean closing;
private byte buffer[];
private int endoffset;
private int offset;
private boolean closed;
public ClientStream(Socket socket, GameShell applet) throws IOException {
closing = false;
closed = true;
this.socket = socket;
instream = socket.getInputStream();
outstream = socket.getOutputStream();
closed = false;
//applet.startThread(this);
}
public void closeStream() {
super.closeStream();
closing = true;
try {
if (instream != null)
instream.close();
if (outstream != null)
outstream.close();
if (socket != null)
socket.close();
} catch (IOException Ex) {
System.out.println("Error closing stream");
}
closed = true;
//synchronized (this) {
notify();
//}
buffer = null;
}
public int readStream()
throws IOException {
if (closing)
return 0;
else
return instream.read();
}
public int availableStream()
throws IOException {
if (closing)
return 0;
else
return instream.available();
}
public void readStreamBytes(int len, int off, byte buff[])
throws IOException {
if (closing)
return;
int k = 0;
boolean flag = false;
int l;
for (; k < len; k += l)
if ((l = instream.read(buff, k + off, len - k)) <= 0)
throw new IOException("EOF");
}
public void writeStreamBytes(byte buff[], int off, int len)
throws IOException {
if (closing)
return;
if (buffer == null)
buffer = new byte[5000];
//synchronized (this) {
for (int l = 0; l < len; l++) {
buffer[offset] = buff[l + off];
offset = (offset + 1) % 5000;
if (offset == (endoffset + 4900) % 5000)
throw new IOException("buffer overflow");
}
notify();
//}
}
public void run() {
while (!closed) {
int len;
int off;
//synchronized (this) {
if (offset == endoffset)
try {
wait();
} catch (InterruptedException Ex) {
}
if (closed)
return;
off = endoffset;
if (offset >= endoffset)
len = offset - endoffset;
else
len = 5000 - endoffset;
//}
if (len > 0) {
try {
outstream.write(buffer, off, len);
} catch (IOException ioexception) {
super.socketException = true;
super.socketExceptionMessage = "Twriter:" + ioexception;
}
endoffset = (endoffset + len) % 5000;
try {
if (offset == endoffset)
outstream.flush();
} catch (IOException ioexception1) {
super.socketException = true;
super.socketExceptionMessage = "Twriter:" + ioexception1;
}
}
}
}
}

View File

@ -0,0 +1,133 @@
public class Command {
public static final int CL_TRADE_CONFIRM_ACCEPT = 104;
public static final int CL_APPEARANCE = 235;
public static final int CL_BANK_CLOSE = 212;
public static final int CL_BANK_DEPOSIT = 23;
public static final int CL_BANK_WITHDRAW = 22;
public static final int CL_CAST_GROUND = 158;
public static final int CL_CAST_INVITEM = 4;
public static final int CL_CAST_NPC = 50;
public static final int CL_CAST_OBJECT = 99;
public static final int CL_CAST_PLAYER = 229;
public static final int CL_CAST_SELF = 137;
public static final int CL_CHAT = 216;
public static final int CL_CHOOSE_OPTION = 116;
public static final int CL_CLOSE_CONNECTION = 31;
public static final int CL_COMBAT_STYLE = 29;
public static final int CL_COMMAND = 38;
public static final int CL_DUEL_ACCEPT = 176;
public static final int CL_DUEL_CONFIRM_ACCEPT = 77;
public static final int CL_DUEL_DECLINE = 197;
public static final int CL_DUEL_ITEM_UPDATE = 33;
public static final int CL_DUEL_SETTINGS = 8;
public static final int CL_FRIEND_ADD = 195;
public static final int CL_FRIEND_REMOVE = 167;
public static final int CL_CAST_GROUNDITEM = 249;
public static final int CL_GROUNDITEM_TAKE = 247;
public static final int CL_IGNORE_ADD = 132;
public static final int CL_IGNORE_REMOVE = 241;
public static final int CL_INV_CMD = 90;
public static final int CL_INV_DROP = 246;
public static final int CL_INV_UNEQUIP = 170;
public static final int CL_INV_WEAR = 169;
public static final int CL_KNOWN_PLAYERS = 163;
public static final int CL_LOGIN = 0;
public static final int CL_LOGOUT = 102;
public static final int CL_NPC_ATTACK = 190;
public static final int CL_NPC_CMD = 202;
public static final int CL_NPC_TALK = 153;
public static final int CL_OBJECT_CMD1 = 136;
public static final int CL_OBJECT_CMD2 = 79;
public static final int CL_PACKET_EXCEPTION = 3;
public static final int CL_PING = 67;
public static final int CL_PLAYER_ATTACK = 171;
public static final int CL_PLAYER_DUEL = 103;
public static final int CL_PLAYER_FOLLOW = 165;
public static final int CL_PLAYER_TRADE = 142;
public static final int CL_PM = 218;
public static final int CL_PRAYER_OFF = 254;
public static final int CL_PRAYER_ON = 60;
public static final int CL_REPORT_ABUSE = 206;
public static final int CL_SESSION = 32;
public static final int CL_SETTINGS_GAME = 111;
public static final int CL_SETTINGS_PRIVACY = 64;
public static final int CL_SHOP_BUY = 236;
public static final int CL_SHOP_CLOSE = 166;
public static final int CL_SHOP_SELL = 221;
public static final int CL_SLEEP_WORD = 45;
public static final int CL_TRADE_ACCEPT = 55;
public static final int CL_TRADE_DECLINE = 230;
public static final int CL_TRADE_ITEM_UPDATE = 46;
public static final int CL_USEWITH_GROUNDITEM = 53;
public static final int CL_USEWITH_INVITEM = 91;
public static final int CL_USEWITH_NPC = 135;
public static final int CL_USEWITH_OBJECT = 115;
public static final int CL_USEWITH_PLAYER = 113;
public static final int CL_WALK = 187;
public static final int CL_WALK_ACTION = 16;
public static final int CL_WALL_OBJECT_COMMAND1 = 14;
public static final int CL_WALL_OBJECT_COMMAND2 = 127;
public static final int CL_CAST_WALLOBJECT = 180;
public static final int CL_USEWITH_WALLOBJECT = 161;
public static final int SV_APPEARANCE = 59;
public static final int SV_BANK_CLOSE = 203;
public static final int SV_BANK_OPEN = 42;
public static final int SV_BANK_UPDATE = 249;
public static final int SV_CLOSE_CONNECTION = 4;
public static final int SV_DUEL_ACCEPTED = 210;
public static final int SV_DUEL_CLOSE = 225;
public static final int SV_DUEL_CONFIRM_OPEN = 172;
public static final int SV_DUEL_OPEN = 176;
public static final int SV_DUEL_OPPONENT_ACCEPTED = 253;
public static final int SV_DUEL_SETTINGS = 30;
public static final int SV_DUEL_UPDATE = 6;
public static final int SV_FRIEND_LIST = 71;
public static final int SV_FRIEND_MESSAGE = 120;
public static final int SV_FRIEND_STATUS_CHANGE = 149;
public static final int SV_GAME_SETTINGS = 240;
public static final int SV_IGNORE_LIST = 109;
public static final int SV_INVENTORY_ITEMS = 53;
public static final int SV_INVENTORY_ITEM_REMOVE = 123;
public static final int SV_INVENTORY_ITEM_UPDATE = 90;
public static final int SV_LOGOUT_DENY = 183;
public static final int SV_MESSAGE = 131;
public static final int SV_OPTION_LIST = 245;
public static final int SV_OPTION_LIST_CLOSE = 252;
public static final int SV_PLAYER_DIED = 83;
public static final int SV_PLAYER_QUEST_LIST = 5;
public static final int SV_PLAYER_STAT_EQUIPMENT_BONUS = 153;
public static final int SV_PLAYER_STAT_EXPERIENCE_UPDATE = 33;
public static final int SV_PLAYER_STAT_FATIGUE = 114;
public static final int SV_PLAYER_STAT_FATIGUE_ASLEEP = 244;
public static final int SV_PLAYER_STAT_LIST = 156;
public static final int SV_PLAYER_STAT_UPDATE = 159;
public static final int SV_PRAYER_STATUS = 206;
public static final int SV_PRIVACY_SETTINGS = 51;
public static final int SV_REGION_ENTITY_UPDATE = 211;
public static final int SV_REGION_GROUND_ITEMS = 99;
public static final int SV_REGION_NPCS = 79;
public static final int SV_REGION_NPC_UPDATE = 104;
public static final int SV_REGION_OBJECTS = 48;
public static final int SV_REGION_PLAYERS = 191;
public static final int SV_REGION_PLAYER_UPDATE = 234;
public static final int SV_REGION_WALL_OBJECTS = 91;
public static final int SV_SERVER_MESSAGE = 89;
public static final int SV_SERVER_MESSAGE_ONTOP = 222;
public static final int SV_SHOP_CLOSE = 137;
public static final int SV_SHOP_OPEN = 101;
public static final int SV_SLEEP_CLOSE = 84;
public static final int SV_SLEEP_INCORRECT = 194;
public static final int SV_SLEEP_OPEN = 117;
public static final int SV_SOUND = 204;
public static final int SV_SYSTEM_UPDATE = 52;
public static final int SV_TELEPORT_BUBBLE = 36;
public static final int SV_TRADE_CLOSE = 128;
public static final int SV_TRADE_CONFIRM_OPEN = 20;
public static final int SV_TRADE_ITEMS = 97;
public static final int SV_TRADE_OPEN = 92;
public static final int SV_TRADE_RECIPIENT_STATUS = 162;
public static final int SV_TRADE_STATUS = 15;
public static final int SV_WELCOME = 182;
public static final int SV_WORLD_INFO = 25;
}

View File

@ -0,0 +1,47 @@
final class GameCharacter {
public long hash;
public String name;
public int serverIndex;
public int serverId;
public int currentX;
public int currentY;
public int npcId;
public int stepCount;
public int animationCurrent;
public int animationNext;
public int movingStep;
public int waypointCurrent;
public int waypointsX[];
public int waypointsY[];
public int equippedItem[];
public String message;
public int messageTimeout;
public int bubbleItem;
public int bubbleTimeout;
public int damageTaken;
public int healthCurrent;
public int healthMax;
public int combatTimer;
public int level;
public int colourHair;
public int colourTop;
public int colourBottom;
public int colourSkin;
public int incomingProjectileSprite;
public int attackingPlayerServerIndex;
public int attackingNpcServerIndex;
public int projectileRange;
//public boolean unused;
//public int unused1;
public int skullVisible;
GameCharacter() {
waypointsX = new int[10];
waypointsY = new int[10];
equippedItem = new int[12];
level = -1;
//unused = false;
//unused1 = -1;
}
}

View File

@ -0,0 +1,544 @@
import java.io.IOException;
import java.math.BigInteger;
public class GameConnection extends GameShell {
public static int clientVersion = 1;
public static int maxReadTries;
private static BigInteger rsaExponent = new BigInteger("58778699976184461502525193738213253649000149147835990136706041084440742975821");
//private static BigInteger rsaModulus = new BigInteger("7162900525229798032761816791230527296329313291232324290237849263501208207972894053929065636522363163621000728841182238772712427862772219676577293600221789");
private static BigInteger rsaModulus = new BigInteger("7656522762491711741880224224809835569769759737077076094091609307381193032090602256314159126169417567841597729801408692196383745596665658895073411749475443");
private final int maxSocialListSize = 100;
public String server;
public int port;
public ClientStream clientStream;
public int friendListCount;
public long friendListHashes[];
public int friendListOnline[];
public int ignoreListCount;
public long ignoreList[];
public int settingsBlockChat;
public int settingsBlockPrivate;
public int settingsBlockTrade;
public int settingsBlockDuel;
public long sessionID;
public int worldFullTimeout;
public int moderatorLevel;
String username;
String password;
byte incomingPacket[];
int autoLoginTimeout;
long packetLastRead;
private int anIntArray629[];
private int anInt630;
public GameConnection() {
server = "127.0.0.1";
port = 43594;
username = "";
password = "";
incomingPacket = new byte[5000];
friendListHashes = new long[200];
friendListOnline = new int[200];
ignoreList = new long[maxSocialListSize];
anIntArray629 = new int[maxSocialListSize];
}
protected void login(String u, String p, boolean reconnecting) {
if (worldFullTimeout > 0) {
showLoginScreenStatus("Please wait...", "Connecting to server");
try {
Thread.sleep(2000L);
} catch (Exception Ex) {
}
showLoginScreenStatus("Sorry! The server is currently full.", "Please try again later");
return;
}
try {
username = u;
u = Utility.formatAuthString(u, 20);
password = p;
p = Utility.formatAuthString(p, 20);
if (u.trim().length() == 0) {
showLoginScreenStatus("You must enter both a username", "and a password - Please try again");
return;
}
if (reconnecting)
drawTextBox("Connection lost! Please wait...", "Attempting to re-establish");
else
showLoginScreenStatus("Please wait...", "Connecting to server");
clientStream = new ClientStream(createSocket(server, port), this);
clientStream.maxReadTries = maxReadTries;
long l = Utility.username2hash(u);
clientStream.newPacket((Command.CL_SESSION));
clientStream.putByte((int) (l >> 16 & 31L));
clientStream.flushPacket();
long sessid = clientStream.getLong();
sessionID = sessid;
if (sessid == 0L) {
showLoginScreenStatus("Login server offline.", "Please try again in a few mins");
return;
}
System.out.println("Verb: Session id: " + sessid);
int limit30 = 0;
/*
try {
if (getStartedAsApplet()) {
String s2 = getParameter("limit30");
if (s2.equals("1"))
limit30 = 1;
}
} catch (Exception Ex) {
}*/
int ai[] = new int[4];
ai[0] = (int) (Math.random() * 99999999D);
ai[1] = (int) (Math.random() * 99999999D);
ai[2] = (int) (sessid >> 32);
ai[3] = (int) sessid;
// TODO maybe re-enable RSA later
/*
Buffer buffer = new Buffer(new byte[500]);
buffer.offset = 0;
buffer.putByte(10);
buffer.putInt(ai[0]);
buffer.putInt(ai[1]);
buffer.putInt(ai[2]);
buffer.putInt(ai[3]);
buffer.putInt(getLinkUID());
buffer.putString(u);
buffer.putString(p);
buffer.encrypt(rsaExponent, rsaModulus);
*/
clientStream.newPacket((Command.CL_LOGIN));
if (reconnecting)
clientStream.putByte(1);
else
clientStream.putByte(0);
clientStream.putShort(clientVersion);
clientStream.putByte(limit30);
clientStream.putByte(10);
clientStream.putInt(ai[0]);
clientStream.putInt(ai[1]);
clientStream.putInt(ai[2]);
clientStream.putInt(ai[3]);
clientStream.putInt(getLinkUID());
clientStream.putString(u);
clientStream.putString(p);
//clientStream.putBytes(buffer.buffer, 0, buffer.offset);
clientStream.flushPacket();
clientStream.seedIsaac(ai);
int resp = clientStream.readStream();
System.out.println("login response:" + resp);
if (resp == 25) {
moderatorLevel = 1;
autoLoginTimeout = 0;
resetGame();
return;
}
if (resp == 0) {
moderatorLevel = 0;
autoLoginTimeout = 0;
resetGame();
return;
}
if (resp == 1) {
autoLoginTimeout = 0;
method37();
return;
}
if (reconnecting) {
u = "";
p = "";
resetLoginVars();
return;
}
if (resp == -1) {
showLoginScreenStatus("Error unable to login.", "Server timed out");
return;
}
if (resp == 3) {
showLoginScreenStatus("Invalid username or password.", "Try again, or create a new account");
return;
}
if (resp == 4) {
showLoginScreenStatus("That username is already logged in.", "Wait 60 seconds then retry");
return;
}
if (resp == 5) {
showLoginScreenStatus("The client has been updated.", "Please reload this page");
return;
}
if (resp == 6) {
showLoginScreenStatus("You may only use 1 character at once.", "Your ip-address is already in use");
return;
}
if (resp == 7) {
showLoginScreenStatus("Login attempts exceeded!", "Please try again in 5 minutes");
return;
}
if (resp == 8) {
showLoginScreenStatus("Error unable to login.", "Server rejected session");
return;
}
if (resp == 9) {
showLoginScreenStatus("Error unable to login.", "Loginserver rejected session");
return;
}
if (resp == 10) {
showLoginScreenStatus("That username is already in use.", "Wait 60 seconds then retry");
return;
}
if (resp == 11) {
showLoginScreenStatus("Account temporarily disabled.", "Check your message inbox for details");
return;
}
if (resp == 12) {
showLoginScreenStatus("Account permanently disabled.", "Check your message inbox for details");
return;
}
if (resp == 14) {
showLoginScreenStatus("Sorry! This world is currently full.", "Please try a different world");
worldFullTimeout = 1500;
return;
}
if (resp == 15) {
showLoginScreenStatus("You need a members account", "to login to this world");
return;
}
if (resp == 16) {
showLoginScreenStatus("Error - no reply from loginserver.", "Please try again");
return;
}
if (resp == 17) {
showLoginScreenStatus("Error - failed to decode profile.", "Contact customer support");
return;
}
if (resp == 18) {
showLoginScreenStatus("Account suspected stolen.", "Press 'recover a locked account' on front page.");
return;
}
if (resp == 20) {
showLoginScreenStatus("Error - loginserver mismatch", "Please try a different world");
return;
}
if (resp == 21) {
showLoginScreenStatus("Unable to login.", "That is not an RS-Classic account");
return;
}
if (resp == 22) {
showLoginScreenStatus("Password suspected stolen.", "Press 'change your password' on front page.");
return;
} else {
showLoginScreenStatus("Error unable to login.", "Unrecognised response code");
return;
}
} catch (Exception exception) {
System.out.println(String.valueOf(exception));
}
if (autoLoginTimeout > 0) {
try {
Thread.sleep(5000L);
} catch (Exception Ex) {
}
autoLoginTimeout--;
login(username, password, reconnecting);
}
if (reconnecting) {
username = "";
password = "";
resetLoginVars();
} else {
showLoginScreenStatus("Sorry! Unable to connect.", "Check internet settings or try another world");
}
}
protected void closeConnection() {
if (clientStream != null)
try {
clientStream.newPacket((Command.CL_CLOSE_CONNECTION));
clientStream.flushPacket();
} catch (IOException Ex) {
}
username = "";
password = "";
resetLoginVars();
}
protected void lostConnection() {
try {
throw new Exception("");
} catch (Exception ex) {
System.out.println("loast connection: ");
ex.printStackTrace();
}
System.out.println("Lost connection");
autoLoginTimeout = 10;
login(username, password, true);
}
protected void drawTextBox(String s, String s1) {
/*Graphics g = getGraphics();
Font font = new Font("Helvetica", 1, 15);
char c = '\u0200';
char c1 = '\u0158';
g.setColor(Color.black);
g.fillRect(c / 2 - 140, c1 / 2 - 25, 280, 50);
g.setColor(Color.white);
g.drawRect(c / 2 - 140, c1 / 2 - 25, 280, 50);
drawString(g, s, font, c / 2, c1 / 2 - 10);
drawString(g, s1, font, c / 2, c1 / 2 + 10);*/
}
protected void checkConnection() {
long l = System.currentTimeMillis();
if (clientStream.hasPacket())
packetLastRead = l;
if (l - packetLastRead > 5000L) {
packetLastRead = l;
clientStream.newPacket((Command.CL_PING));
clientStream.sendPacket();
}
try {
clientStream.writePacket(20);
} catch (IOException Ex) {
lostConnection();
return;
}
if (!method43())
return;
int psize = clientStream.readPacket(incomingPacket);
if (psize > 0) {
int ptype = clientStream.isaacCommand(incomingPacket[0] & 0xff);
handlePacket(ptype, ptype, psize);
}
}
private void handlePacket(int opcode, int ptype, int psize) {
//ptype = clientStream.isaacCommand(ptype);
//System.out.println(String.format("opcode:%s(%d) psize:%d", opcode.name(), ptype, psize));
System.out.println("opcode:" + opcode + " psize:" + psize);
if (opcode == Command.SV_MESSAGE) {
String s = new String(incomingPacket, 1, psize - 1);
showServerMessage(s);
}
if (opcode == Command.SV_CLOSE_CONNECTION)
closeConnection();
if (opcode == Command.SV_LOGOUT_DENY) {
cantLogout();
return;
}
if (opcode == Command.SV_FRIEND_LIST) {
friendListCount = Utility.getUnsignedByte(incomingPacket[1]);
for (int k = 0; k < friendListCount; k++) {
friendListHashes[k] = Utility.getUnsignedLong(incomingPacket, 2 + k * 9);
friendListOnline[k] = Utility.getUnsignedByte(incomingPacket[10 + k * 9]);
}
sortFriendsList();
return;
}
if (opcode == Command.SV_FRIEND_STATUS_CHANGE) {
long hash = Utility.getUnsignedLong(incomingPacket, 1);
int online = incomingPacket[9] & 0xff;
for (int i2 = 0; i2 < friendListCount; i2++)
if (friendListHashes[i2] == hash) {
if (friendListOnline[i2] == 0 && online != 0)
showServerMessage("@pri@" + Utility.hash2username(hash) + " has logged in");
if (friendListOnline[i2] != 0 && online == 0)
showServerMessage("@pri@" + Utility.hash2username(hash) + " has logged out");
friendListOnline[i2] = online;
psize = 0; // not sure what this is for
sortFriendsList();
return;
}
friendListHashes[friendListCount] = hash;
friendListOnline[friendListCount] = online;
friendListCount++;
sortFriendsList();
return;
}
if (opcode == Command.SV_IGNORE_LIST) {
ignoreListCount = Utility.getUnsignedByte(incomingPacket[1]);
for (int i1 = 0; i1 < ignoreListCount; i1++)
ignoreList[i1] = Utility.getUnsignedLong(incomingPacket, 2 + i1 * 8);
return;
}
if (opcode == Command.SV_PRIVACY_SETTINGS) {
settingsBlockChat = incomingPacket[1];
settingsBlockPrivate = incomingPacket[2];
settingsBlockTrade = incomingPacket[3];
settingsBlockDuel = incomingPacket[4];
return;
}
if (opcode == Command.SV_FRIEND_MESSAGE) {
long from = Utility.getUnsignedLong(incomingPacket, 1);
int k1 = Utility.getUnsignedInt(incomingPacket, 9); // is this some sort of message id ?
for (int j2 = 0; j2 < maxSocialListSize; j2++)
if (anIntArray629[j2] == k1)
return;
anIntArray629[anInt630] = k1;
anInt630 = (anInt630 + 1) % maxSocialListSize;
String msg = WordFilter.filter(ChatMessage.descramble(incomingPacket, 13, psize - 13));
showServerMessage("@pri@" + Utility.hash2username(from) + ": tells you " + msg);
return;
} else {
handleIncomingPacket(opcode, ptype, psize, incomingPacket);
return;
}
}
private void sortFriendsList() {
boolean flag = true;
while (flag) {
flag = false;
for (int i = 0; i < friendListCount - 1; i++)
if (friendListOnline[i] != 255 && friendListOnline[i + 1] == 255 || friendListOnline[i] == 0 && friendListOnline[i + 1] != 0) {
int j = friendListOnline[i];
friendListOnline[i] = friendListOnline[i + 1];
friendListOnline[i + 1] = j;
long l = friendListHashes[i];
friendListHashes[i] = friendListHashes[i + 1];
friendListHashes[i + 1] = l;
flag = true;
}
}
}
protected void sendPrivacySettings(int chat, int priv, int trade, int duel) {
clientStream.newPacket((Command.CL_SETTINGS_PRIVACY));
clientStream.putByte(chat);
clientStream.putByte(priv);
clientStream.putByte(trade);
clientStream.putByte(duel);
clientStream.sendPacket();
}
protected void ignoreAdd(String s) {
long l = Utility.username2hash(s);
clientStream.newPacket((Command.CL_IGNORE_ADD));
clientStream.putLong(l);
clientStream.sendPacket();
for (int i = 0; i < ignoreListCount; i++)
if (ignoreList[i] == l)
return;
if (ignoreListCount >= maxSocialListSize) {
return;
} else {
ignoreList[ignoreListCount++] = l;
return;
}
}
protected void ignoreRemove(long l) {
clientStream.newPacket((Command.CL_IGNORE_REMOVE));
clientStream.putLong(l);
clientStream.sendPacket();
for (int i = 0; i < ignoreListCount; i++)
if (ignoreList[i] == l) {
ignoreListCount--;
for (int j = i; j < ignoreListCount; j++)
ignoreList[j] = ignoreList[j + 1];
return;
}
}
protected void friendAdd(String s) {
clientStream.newPacket((Command.CL_FRIEND_ADD));
clientStream.putLong(Utility.username2hash(s));
clientStream.sendPacket();
long l = Utility.username2hash(s);
for (int i = 0; i < friendListCount; i++)
if (friendListHashes[i] == l)
return;
if (friendListCount >= maxSocialListSize) {
return;
} else {
friendListHashes[friendListCount] = l;
friendListOnline[friendListCount] = 0;
friendListCount++;
return;
}
}
protected void friendRemove(long l) {
clientStream.newPacket((Command.CL_FRIEND_REMOVE));
clientStream.putLong(l);
clientStream.sendPacket();
for (int i = 0; i < friendListCount; i++) {
if (friendListHashes[i] != l)
continue;
friendListCount--;
for (int j = i; j < friendListCount; j++) {
friendListHashes[j] = friendListHashes[j + 1];
friendListOnline[j] = friendListOnline[j + 1];
}
break;
}
showServerMessage("@pri@" + Utility.hash2username(l) + " has been removed from your friends list");
}
protected void sendPrivateMessage(long u, byte buff[], int len) {
clientStream.newPacket((Command.CL_PM));
clientStream.putLong(u);
clientStream.putBytes(buff, 0, len);
clientStream.sendPacket();
}
protected void sendChatMessage(byte buff[], int len) {
clientStream.newPacket((Command.CL_CHAT));
clientStream.putBytes(buff, 0, len);
clientStream.sendPacket();
}
protected void sendCommandString(String s) {
clientStream.newPacket((Command.CL_COMMAND));
clientStream.putString(s);
clientStream.sendPacket();
}
protected void showLoginScreenStatus(String s, String s1) {
}
protected void method37() {
}
protected void resetGame() {
}
protected void resetLoginVars() {
}
protected void cantLogout() {
}
protected void handleIncomingPacket(int opcode, int ptype, int len, byte data[]) {
}
protected void showServerMessage(String s) {
}
protected boolean method43() {
return true;
}
protected int getLinkUID() {
return 0;
}
}

View File

@ -0,0 +1,474 @@
public class GameData {
public static String modelName[] = new String[5000];
public static String textureName[];
public static String textureSubtypeName[];
public static int objectModelIndex[];
public static int objectWidth[];
public static int objectHeight[];
public static int objectType[];
public static int objectElevation[];
public static int spellCount;
public static int npcWidth[];
public static int npcHeight[];
public static int npcSprite[][];
public static int npcAttack[];
public static int npcStrength[];
public static int npcHits[];
public static int npcDefense[];
public static int npcAttackable[];
public static int spellLevel[];
public static int spellRunesRequired[];
public static int spellType[];
public static int spellRunesId[][];
public static int spellRunesCount[][];
//public static String unused[] = new String[5000];
public static int itemCount;
public static int itemSpriteCount;
public static int npcColourHair[];
public static int npcColourTop[];
public static int npcColorBottom[];
public static int npcColourSkin[];
public static int wallObjectHeight[];
public static int wallObjectTextureFront[];
public static int wallObjectTextureBack[];
public static int wallObjectAdjacent[];
public static int wallObjectInvisible[];
//public static String unused2[] = new String[5000];
public static int tileCount;
public static int animationCharacterColour[];
public static int animationSomething[];
public static int animationHasA[];
public static int animationHasF[];
public static int animationNumber[];
public static int wallObjectCount;
public static int prayerLevel[];
public static int prayerDrain[];
public static int tileDecoration[];
public static int tileType[];
public static int tileAdjacent[];
public static int modelCount;
public static int roofHeight[];
public static int roofNumVertices[];
public static int prayerCount;
public static String itemName[];
public static String itemDescription[];
public static String itemCommand[];
public static int projectileSprite;
public static int npcCount;
public static String spellName[];
public static String spellDescription[];
public static int textureCount;
public static String wallObjectName[];
public static String wallObjectDescription[];
public static String wallObjectCommand1[];
public static String wallObjectCommand2[];
public static int roofCount;
public static int objectCount;
public static String npcName[];
public static String npcDescription[];
public static String npcCommand[];
public static String animationName[];
public static int itemPicture[];
public static int itemBasePrice[];
public static int itemStackable[];
public static int itemUnused[];
public static int itemWearable[];
public static int itemMask[];
public static int itemSpecial[];
public static int itemMembers[];
public static int animationCount;
public static String prayerName[];
public static String prayerDescription[];
public static String objectName[];
public static String objectDescription[];
public static String objectCommand1[];
public static String objectCommand2[];
public static int npcWalkModel[];
public static int npcCombatModel[];
public static int npcCombatAnimation[];
static byte dataString[];
static byte dataInteger[];
static int stringOffset;
static int offset;
public static int getModelIndex(String s) {
if (s.equalsIgnoreCase("na"))
return 0;
for (int i = 0; i < modelCount; i++)
if (modelName[i].equalsIgnoreCase(s))
return i;
modelName[modelCount++] = s;
return modelCount - 1;
}
public static int getUnsignedByte() {
int i = dataInteger[offset] & 0xff;
offset++;
return i;
}
public static int getUnsignedShort() {
int i = Utility.getUnsignedShort(dataInteger, offset);
offset += 2;
return i;
}
public static int getUnsignedInt() {
int i = Utility.getUnsignedInt(dataInteger, offset);
offset += 4;
if (i > 99999999)
i = 99999999 - i;
return i;
}
public static String getString() {
String s;
for (s = ""; dataString[stringOffset] != 0; s = s + (char) dataString[stringOffset++]) ;
stringOffset++;
return s;
}
public static void loadData(byte buffer[], boolean isMembers) {
dataString = Utility.loadData("string.dat", 0, buffer);
stringOffset = 0;
dataInteger = Utility.loadData("integer.dat", 0, buffer);
offset = 0;
System.out.println("dataString " + dataString);
System.out.println("dataInteger " + dataInteger);
int i;
itemCount = getUnsignedShort();
itemName = new String[itemCount];
itemDescription = new String[itemCount];
itemCommand = new String[itemCount];
itemPicture = new int[itemCount];
itemBasePrice = new int[itemCount];
itemStackable = new int[itemCount];
itemUnused = new int[itemCount];
itemWearable = new int[itemCount];
itemMask = new int[itemCount];
itemSpecial = new int[itemCount];
itemMembers = new int[itemCount];
for (i = 0; i < itemCount; i++)
itemName[i] = getString();
for (i = 0; i < itemCount; i++)
itemDescription[i] = getString();
for (i = 0; i < itemCount; i++)
itemCommand[i] = getString();
for (i = 0; i < itemCount; i++) {
itemPicture[i] = getUnsignedShort();
if (itemPicture[i] + 1 > itemSpriteCount)
itemSpriteCount = itemPicture[i] + 1;
}
for (i = 0; i < itemCount; i++)
itemBasePrice[i] = getUnsignedInt();
for (i = 0; i < itemCount; i++)
itemStackable[i] = getUnsignedByte();
for (i = 0; i < itemCount; i++)
itemUnused[i] = getUnsignedByte();
for (i = 0; i < itemCount; i++)
itemWearable[i] = getUnsignedShort();
for (i = 0; i < itemCount; i++)
itemMask[i] = getUnsignedInt();
for (i = 0; i < itemCount; i++)
itemSpecial[i] = getUnsignedByte();
for (i = 0; i < itemCount; i++)
itemMembers[i] = getUnsignedByte();
for (i = 0; i < itemCount; i++)
if (!isMembers && itemMembers[i] == 1) {
itemName[i] = "Members object";
itemDescription[i] = "You need to be a member to use this object";
itemBasePrice[i] = 0;
itemCommand[i] = "";
itemUnused[0] = 0;
itemWearable[i] = 0;
itemSpecial[i] = 1;
}
npcCount = getUnsignedShort();
npcName = new String[npcCount];
npcDescription = new String[npcCount];
npcCommand = new String[npcCount];
npcAttack = new int[npcCount];
npcStrength = new int[npcCount];
npcHits = new int[npcCount];
npcDefense = new int[npcCount];
npcAttackable = new int[npcCount];
npcSprite = new int[npcCount][12];
npcColourHair = new int[npcCount];
npcColourTop = new int[npcCount];
npcColorBottom = new int[npcCount];
npcColourSkin = new int[npcCount];
npcWidth = new int[npcCount];
npcHeight = new int[npcCount];
npcWalkModel = new int[npcCount];
npcCombatModel = new int[npcCount];
npcCombatAnimation = new int[npcCount];
for (i = 0; i < npcCount; i++)
npcName[i] = getString();
for (i = 0; i < npcCount; i++)
npcDescription[i] = getString();
for (i = 0; i < npcCount; i++)
npcAttack[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcStrength[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcHits[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcDefense[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcAttackable[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++) {
for (int i5 = 0; i5 < 12; i5++) {
npcSprite[i][i5] = getUnsignedByte();
if (npcSprite[i][i5] == 255)
npcSprite[i][i5] = -1;
}
}
for (i = 0; i < npcCount; i++)
npcColourHair[i] = getUnsignedInt();
for (i = 0; i < npcCount; i++)
npcColourTop[i] = getUnsignedInt();
for (i = 0; i < npcCount; i++)
npcColorBottom[i] = getUnsignedInt();
for (i = 0; i < npcCount; i++)
npcColourSkin[i] = getUnsignedInt();
for (i = 0; i < npcCount; i++)
npcWidth[i] = getUnsignedShort();
for (i = 0; i < npcCount; i++)
npcHeight[i] = getUnsignedShort();
for (i = 0; i < npcCount; i++)
npcWalkModel[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcCombatModel[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcCombatAnimation[i] = getUnsignedByte();
for (i = 0; i < npcCount; i++)
npcCommand[i] = getString();
textureCount = getUnsignedShort();
textureName = new String[textureCount];
textureSubtypeName = new String[textureCount];
for (i = 0; i < textureCount; i++)
textureName[i] = getString();
for (i = 0; i < textureCount; i++)
textureSubtypeName[i] = getString();
animationCount = getUnsignedShort();
animationName = new String[animationCount];
animationCharacterColour = new int[animationCount];
animationSomething = new int[animationCount];
animationHasA = new int[animationCount];
animationHasF = new int[animationCount];
animationNumber = new int[animationCount];
for (i = 0; i < animationCount; i++)
animationName[i] = getString();
for (i = 0; i < animationCount; i++)
animationCharacterColour[i] = getUnsignedInt();
for (i = 0; i < animationCount; i++)
animationSomething[i] = getUnsignedByte();
for (i = 0; i < animationCount; i++)
animationHasA[i] = getUnsignedByte();
for (i = 0; i < animationCount; i++)
animationHasF[i] = getUnsignedByte();
for (i = 0; i < animationCount; i++)
animationNumber[i] = getUnsignedByte();
objectCount = getUnsignedShort();
objectName = new String[objectCount];
objectDescription = new String[objectCount];
objectCommand1 = new String[objectCount];
objectCommand2 = new String[objectCount];
objectModelIndex = new int[objectCount];
objectWidth = new int[objectCount];
objectHeight = new int[objectCount];
objectType = new int[objectCount];
objectElevation = new int[objectCount];
for (i = 0; i < objectCount; i++)
objectName[i] = getString();
for (i = 0; i < objectCount; i++)
objectDescription[i] = getString();
for (i = 0; i < objectCount; i++)
objectCommand1[i] = getString();
for (i = 0; i < objectCount; i++)
objectCommand2[i] = getString();
for (i = 0; i < objectCount; i++)
objectModelIndex[i] = getModelIndex(getString());
for (i = 0; i < objectCount; i++)
objectWidth[i] = getUnsignedByte();
for (i = 0; i < objectCount; i++)
objectHeight[i] = getUnsignedByte();
for (i = 0; i < objectCount; i++)
objectType[i] = getUnsignedByte();
for (i = 0; i < objectCount; i++)
objectElevation[i] = getUnsignedByte();
wallObjectCount = getUnsignedShort();
wallObjectName = new String[wallObjectCount];
wallObjectDescription = new String[wallObjectCount];
wallObjectCommand1 = new String[wallObjectCount];
wallObjectCommand2 = new String[wallObjectCount];
wallObjectHeight = new int[wallObjectCount];
wallObjectTextureFront = new int[wallObjectCount];
wallObjectTextureBack = new int[wallObjectCount];
wallObjectAdjacent = new int[wallObjectCount];
wallObjectInvisible = new int[wallObjectCount];
for (i = 0; i < wallObjectCount; i++)
wallObjectName[i] = getString();
for (i = 0; i < wallObjectCount; i++)
wallObjectDescription[i] = getString();
for (i = 0; i < wallObjectCount; i++)
wallObjectCommand1[i] = getString();
for (i = 0; i < wallObjectCount; i++)
wallObjectCommand2[i] = getString();
for (i = 0; i < wallObjectCount; i++)
wallObjectHeight[i] = getUnsignedShort();
for (i = 0; i < wallObjectCount; i++)
wallObjectTextureFront[i] = getUnsignedInt();
for (i = 0; i < wallObjectCount; i++)
wallObjectTextureBack[i] = getUnsignedInt();
for (i = 0; i < wallObjectCount; i++)
wallObjectAdjacent[i] = getUnsignedByte();// what's this?
for (i = 0; i < wallObjectCount; i++)
wallObjectInvisible[i] = getUnsignedByte();// value is 0 if visible
roofCount = getUnsignedShort();// the World class does something with these
roofHeight = new int[roofCount];
roofNumVertices = new int[roofCount];
for (i = 0; i < roofCount; i++)
roofHeight[i] = getUnsignedByte();
for (i = 0; i < roofCount; i++)
roofNumVertices[i] = getUnsignedByte();
tileCount = getUnsignedShort();// and these
tileDecoration = new int[tileCount];
tileType = new int[tileCount];
tileAdjacent = new int[tileCount];
for (i = 0; i < tileCount; i++)
tileDecoration[i] = getUnsignedInt();
for (i = 0; i < tileCount; i++)
tileType[i] = getUnsignedByte();
for (i = 0; i < tileCount; i++)
tileAdjacent[i] = getUnsignedByte();
projectileSprite = getUnsignedShort();
spellCount = getUnsignedShort();
spellName = new String[spellCount];
spellDescription = new String[spellCount];
spellLevel = new int[spellCount];
spellRunesRequired = new int[spellCount];
spellType = new int[spellCount];
spellRunesId = new int[spellCount][];
spellRunesCount = new int[spellCount][];
for (i = 0; i < spellCount; i++)
spellName[i] = getString();
for (i = 0; i < spellCount; i++)
spellDescription[i] = getString();
for (i = 0; i < spellCount; i++)
spellLevel[i] = getUnsignedByte();
for (i = 0; i < spellCount; i++)
spellRunesRequired[i] = getUnsignedByte();
for (i = 0; i < spellCount; i++)
spellType[i] = getUnsignedByte();
for (i = 0; i < spellCount; i++) {
int j = getUnsignedByte();
spellRunesId[i] = new int[j];
for (int k = 0; k < j; k++)
spellRunesId[i][k] = getUnsignedShort();
}
for (i = 0; i < spellCount; i++) {
int j = getUnsignedByte();
spellRunesCount[i] = new int[j];
for (int k = 0; k < j; k++)
spellRunesCount[i][k] = getUnsignedByte();
}
prayerCount = getUnsignedShort();
prayerName = new String[prayerCount];
prayerDescription = new String[prayerCount];
prayerLevel = new int[prayerCount];
prayerDrain = new int[prayerCount];
for (i = 0; i < prayerCount; i++)
prayerName[i] = getString();
for (i = 0; i < prayerCount; i++)
prayerDescription[i] = getString();
for (i = 0; i < prayerCount; i++)
prayerLevel[i] = getUnsignedByte();
for (i = 0; i < prayerCount; i++)
prayerDrain[i] = getUnsignedByte();
dataString = null;
dataInteger = null;
}
//public static int unused3;
}

View File

@ -0,0 +1,64 @@
/*
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;*/
public class GameFrame {
int windowWidth;
int windowHeight;
int translationMode;
int windowYTranslation;
GameShell gameShell;
public GameFrame(GameShell game, int width, int height, String title, boolean resizable, boolean flag1) {
windowYTranslation = 28;
windowWidth = width;
windowHeight = height;
this.gameShell = game;
if (flag1)
windowYTranslation = 48;
else
windowYTranslation = 28;
/*
setTitle(title);
setResizable(resizable);
setVisible(true);
toFront();
setSize(windowWidth, windowHeight);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
gameShell.destroy();
}
});
*/
}
/*public Graphics getGraphics() {
Graphics g = super.getGraphics();
if (translationMode == 0)
g.translate(0, 24);
else
g.translate(-5, 0);
return g;
}
public void setSize(int x, int y) {
super.setSize(x, y + windowYTranslation);
}
protected void processEvent(AWTEvent e) {
if (e instanceof MouseEvent) {
MouseEvent evt = (MouseEvent) e;
e = new MouseEvent(evt.getComponent(), evt.getID(), evt.getWhen(), evt.getModifiers(), evt.getX(), evt.getY() - 24, evt.getClickCount(), evt.isPopupTrigger());
}
super.processEvent(e);
}
public void paint(Graphics g) {
gameShell.paint(g);
}*/
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,565 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
class KeyEvent {
static final int VK_LEFT = -12345678;
static final int VK_RIGHT = -12345678;
static final int VK_UP = -12345678;
static final int VK_DOWN = -12345678;
static final int VK_SPACE = -12345678;
static final int VK_F1 = -12345678;
static final int VK_BACK_SPACE = -12345678;
static final int VK_ENTER = -12345678;
}
public class GameShell {
public static GameFrame gameFrame = null;
private static String charMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";
public int mouseActionTimeout;
public int loadingStep;
public String logoHeaderText;
public boolean keyLeft;
public boolean keyRight;
public boolean keyUp;
public boolean keyDown;
public boolean keySpace;
public int threadSleep;
public int mouseX;
public int mouseY;
public int mouseButtonDown;
public int lastMouseButtonDown;
public boolean interlace;
public String inputTextCurrent;
public String inputTextFinal;
public String inputPmCurrent;
public String inputPmFinal;
public int appletWidth;
public int appletHeight;
//private Thread appletThread;
private int targetFps;
private int maxDrawTime;
private long timings[];
private boolean startedAsApplet;
private int stopTimeout;
private int interlaceTimer;
private boolean hasRefererLogoNotused;
private int loadingProgressPercent;
private String loadingProgessText;
/*
private Font fontTimesRoman15;
private Font fontHelvetica13b;
private Font fontHelvetica12;
private Image imageLogo;*/
protected int fps;
public GameShell() {
appletWidth = 512;
appletHeight = 344;
targetFps = 20;
maxDrawTime = 1000;
timings = new long[10];
loadingStep = 1;
hasRefererLogoNotused = false;
loadingProgessText = "Loading";
/*
fontTimesRoman15 = new Font("TimesRoman", 0, 15);
fontHelvetica13b = new Font("Helvetica", Font.BOLD, 13);
fontHelvetica12 = new Font("Helvetica", 0, 12);*/
keyLeft = false;
keyRight = false;
keyUp = false;
keyDown = false;
keySpace = false;
threadSleep = 1;
interlace = false;
inputTextCurrent = "";
inputTextFinal = "";
inputPmCurrent = "";
inputPmFinal = "";
}
private void dummy() {
this.keyPressed('A', 97);
this.keyReleased(97);
this.mouseMoved(0, 0);
this.mouseReleased(0, 0);
this.mousePressed(0, 0, 0);
this.mouseDragged(0, 0, 0);
}
protected void startGame() {
}
protected synchronized void handleInputs() {
}
protected void onClosing() {
}
protected synchronized void draw() {
}
protected void startApplication(int width, int height, String title, boolean resizeable) {
startedAsApplet = false;
System.out.println("Started application");
appletWidth = width;
appletHeight = height;
gameFrame = new GameFrame(this, width, height, title, resizeable, false);
loadingStep = 1;
//appletThread = new Thread(this);
//appletThread.start();
//appletThread.setPriority(1);
dummy();
start();
run();
}
protected void setTargetFps(int i) {
targetFps = 1000 / i;
}
protected void resetTimings() {
for (int i = 0; i < 10; i++) {
timings[i] = 0L;
}
}
public synchronized void keyPressed(char chr, int code) {
handleKeyPress(chr);
mouseActionTimeout = 0;
if (code == KeyEvent.VK_LEFT) {
keyLeft = true;
} else if (code == KeyEvent.VK_RIGHT) {
keyRight = true;
} else if (code == KeyEvent.VK_UP) {
keyUp = true;
} else if (code == KeyEvent.VK_DOWN) {
keyDown = true;
} else if (code == KeyEvent.VK_SPACE) {
keySpace = true;
} else if (code == KeyEvent.VK_F1) {
interlace = !interlace;
} else {
boolean foundText = false;
for (int i = 0; i < charMap.length(); i++) {
if (charMap.charAt(i) == chr) {
foundText = true;
break;
}
}
if (foundText) {
if (inputTextCurrent.length() < 20) {
inputTextCurrent += chr;
}
if (inputPmCurrent.length() < 80) {
inputPmCurrent += chr;
}
}
}
if (code == KeyEvent.VK_BACK_SPACE) {
if (inputTextCurrent.length() > 0) {
inputTextCurrent = inputTextCurrent.substring(0, inputTextCurrent.length() - 1);
}
if (inputPmCurrent.length() > 0) {
inputPmCurrent = inputPmCurrent.substring(0, inputPmCurrent.length() - 1);
}
}
if (code == KeyEvent.VK_ENTER) {
inputTextFinal = inputTextCurrent;
inputPmFinal = inputPmCurrent;
}
}
protected void handleKeyPress(int i) {
}
public synchronized void keyReleased(int code) {
if (code == KeyEvent.VK_LEFT) {
keyLeft = false;
} else if (code == KeyEvent.VK_RIGHT) {
keyRight = false;
} else if (code == KeyEvent.VK_UP) {
keyUp = false;
} else if (code == KeyEvent.VK_DOWN) {
keyDown = false;
} else if (code == KeyEvent.VK_SPACE) {
keySpace = false;
}
}
public synchronized void mouseMoved(int x, int y) {
mouseX = x;
mouseY = y;
mouseButtonDown = 0;
mouseActionTimeout = 0;
}
public synchronized void mouseReleased(int x, int y) {
mouseX = x;
mouseY = y;
mouseButtonDown = 0;
}
public synchronized void mousePressed(int x, int y, int button) {
mouseX = x;
mouseY = y;
mouseButtonDown = button;
lastMouseButtonDown = mouseButtonDown;
mouseActionTimeout = 0;
handleMouseDown(mouseButtonDown, x, y);
}
public synchronized void mouseDragged(int x, int y, int button) {
mouseX = x;
mouseY = y;
mouseButtonDown = button;
}
protected void handleMouseDown(int i, int j, int k) {
}
/*
public void init() {
startedAsApplet = true;
System.out.println("Started applet");
appletWidth = 512;
appletHeight = 344;
loadingStep = 1;
Utility.appletCodeBase = getCodeBase();
addMouseListener(this);
addMouseMotionListener(this);
addKeyListener(this);
startThread(this);
}*/
public void start() {
if (stopTimeout >= 0)
stopTimeout = 0;
}
public void stop() {
if (stopTimeout >= 0)
stopTimeout = 4000 / targetFps;
}
public void destroy() {
stopTimeout = -1;
try {
Thread.sleep(5000L);
} catch (Exception ignored) {
}
if (stopTimeout == -1) {
System.out.println("5 seconds expired, forcing kill");
closeProgram();
}
}
private void closeProgram() {
stopTimeout = -2;
System.out.println("Closing program");
onClosing();
try {
Thread.sleep(1000L);
} catch (Exception ignored) {
}
System.exit(0);
}
public void run() {
if (loadingStep == 1) {
loadingStep = 2;
//graphics = getGraphics();
loadJagex();
drawLoadingScreen(0, "Loading...");
startGame();
loadingStep = 0;
}
int i = 0;
int j = 256;
int sleep = 1;
int i1 = 0;
for (int j1 = 0; j1 < 10; j1++) {
timings[j1] = System.currentTimeMillis();
}
while (stopTimeout >= 0) {
if (stopTimeout > 0) {
stopTimeout--;
if (stopTimeout == 0) {
closeProgram();
//appletThread = null;
return;
}
}
int k1 = j;
int lastSleep = sleep;
j = 300;
sleep = 1;
long time = System.currentTimeMillis();
if (timings[i] == 0L) {
j = k1;
sleep = lastSleep;
} else if (time > timings[i])
j = (int) ((long) (2560 * targetFps) / (time - timings[i]));
if (j < 25)
j = 25;
if (j > 256) {
j = 256;
sleep = (int) ((long) targetFps - (time - timings[i]) / 10L);
if (sleep < threadSleep)
sleep = threadSleep;
}
try {
Thread.sleep(sleep);
} catch (InterruptedException ignored) {
}
timings[i] = time;
i = (i + 1) % 10;
if (sleep > 1) {
for (int j2 = 0; j2 < 10; j2++)
if (timings[j2] != 0L)
timings[j2] += sleep;
}
int k2 = 0;
while (i1 < 256) {
handleInputs();
i1 += j;
if (++k2 > maxDrawTime) {
i1 = 0;
interlaceTimer += 6;
if (interlaceTimer > 25) {
interlaceTimer = 0;
interlace = true;
}
break;
}
}
interlaceTimer--;
i1 &= 0xff;
draw();
this.fps = (1000 * j) / (this.targetFps * 256);
}
if (stopTimeout == -1)
closeProgram();
//appletThread = null;
}
/*
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
if (loadingStep == 2 && imageLogo != null) {
drawLoadingScreen(loadingProgressPercent, loadingProgessText);
}
}*/
private void loadJagex() {
//graphics.setColor(Color.black);
//graphics.fillRect(0, 0, appletWidth, appletHeight);
byte buff[] = readDataFile("jagex.jag", "Jagex library", 0);
if (buff != null) {
byte logo[] = Utility.loadData("logo.tga", 0, buff);
//imageLogo = createImage(logo);
}
buff = readDataFile("fonts" + Version.FONTS + ".jag", "Game fonts", 5);
if (buff != null) {
Surface.createFont(Utility.loadData("h11p.jf", 0, buff), 0);
Surface.createFont(Utility.loadData("h12b.jf", 0, buff), 1);
Surface.createFont(Utility.loadData("h12p.jf", 0, buff), 2);
Surface.createFont(Utility.loadData("h13b.jf", 0, buff), 3);
Surface.createFont(Utility.loadData("h14b.jf", 0, buff), 4);
Surface.createFont(Utility.loadData("h16b.jf", 0, buff), 5);
Surface.createFont(Utility.loadData("h20b.jf", 0, buff), 6);
Surface.createFont(Utility.loadData("h24b.jf", 0, buff), 7);
}
}
private void drawLoadingScreen(int percent, String text) {
/*
try {
int midx = (appletWidth - 281) / 2;
int midy = (appletHeight - 148) / 2;
graphics.setColor(Color.black);
graphics.fillRect(0, 0, appletWidth, appletHeight);
if (!hasRefererLogoNotused) {
graphics.drawImage(imageLogo, midx, midy, this);
}
midx += 2;
midy += 90;
loadingProgressPercent = percent;
loadingProgessText = text;
graphics.setColor(new Color(132, 132, 132));
if (hasRefererLogoNotused) {
graphics.setColor(new Color(220, 0, 0));
}
graphics.drawRect(midx - 2, midy - 2, 280, 23);
graphics.fillRect(midx, midy, (277 * percent) / 100, 20);
graphics.setColor(new Color(198, 198, 198));
if (hasRefererLogoNotused) {
graphics.setColor(new Color(255, 255, 255));
}
drawString(graphics, text, fontTimesRoman15, midx + 138, midy + 10);
if (!hasRefererLogoNotused) {
drawString(graphics, "Created by JAGeX - visit www.jagex.com", fontHelvetica13b, midx + 138, midy + 30);
drawString(graphics, "\2512001-2002 Andrew Gower and Jagex Ltd", fontHelvetica13b, midx + 138, midy + 44);
} else {
graphics.setColor(new Color(132, 132, 152));
drawString(graphics, "\2512001-2002 Andrew Gower and Jagex Ltd", fontHelvetica12, midx + 138, appletHeight - 20);
}
if (logoHeaderText != null) {
graphics.setColor(Color.white);
drawString(graphics, logoHeaderText, fontHelvetica13b, midx + 138, midy - 120);
}
} catch (Exception ignored) {
}*/
}
protected void showLoadingProgress(int i, String s) {
/*
try {
int j = (appletWidth - 281) / 2;
int k = (appletHeight - 148) / 2;
j += 2;
k += 90;
loadingProgressPercent = i;
loadingProgessText = s;
int l = (277 * i) / 100;
graphics.setColor(new Color(132, 132, 132));
if (hasRefererLogoNotused)
graphics.setColor(new Color(220, 0, 0));
graphics.fillRect(j, k, l, 20);
graphics.setColor(Color.black);
graphics.fillRect(j + l, k, 277 - l, 20);
graphics.setColor(new Color(198, 198, 198));
if (hasRefererLogoNotused)
graphics.setColor(new Color(255, 255, 255));
drawString(graphics, s, fontTimesRoman15, j + 138, k + 10);
} catch (Exception ignored) {
}*/
}
/*
protected void drawString(Graphics g, String s, Font font, int i, int j) {
Object obj;
if (gameFrame == null)
obj = this;
else
obj = gameFrame;
FontMetrics fontmetrics = ((Component) (obj)).getFontMetrics(font);
fontmetrics.stringWidth(s);
g.setFont(font);
g.drawString(s, i - fontmetrics.stringWidth(s) / 2, j + fontmetrics.getHeight() / 4);
}
private Image createImage(byte buff[]) {
int i = buff[13] * 256 + buff[12];
int j = buff[15] * 256 + buff[14];
byte abyte1[] = new byte[256];
byte abyte2[] = new byte[256];
byte abyte3[] = new byte[256];
for (int k = 0; k < 256; k++) {
abyte1[k] = buff[20 + k * 3];
abyte2[k] = buff[19 + k * 3];
abyte3[k] = buff[18 + k * 3];
}
IndexColorModel indexcolormodel = new IndexColorModel(8, 256, abyte1, abyte2, abyte3);
byte abyte4[] = new byte[i * j];
int l = 0;
for (int i1 = j - 1; i1 >= 0; i1--) {
for (int j1 = 0; j1 < i; j1++)
abyte4[l++] = buff[786 + j1 + i1 * i];
}
MemoryImageSource memoryimagesource = new MemoryImageSource(i, j, indexcolormodel, abyte4, 0, i);
return createImage(memoryimagesource);
}*/
protected byte[] readDataFile(String file, String description, int percent) {
file = "./data204/" + file;
int archiveSize = 0;
int archiveSizeCompressed = 0;
byte archiveData[] = null;
try {
showLoadingProgress(percent, "Loading " + description + " - 0%");
java.io.InputStream inputstream = Utility.openFile(file);
DataInputStream datainputstream = new DataInputStream(inputstream);
byte header[] = new byte[6];
datainputstream.readFully(header, 0, 6);
archiveSize = ((header[0] & 0xff) << 16) + ((header[1] & 0xff) << 8) + (header[2] & 0xff);
archiveSizeCompressed = ((header[3] & 0xff) << 16) + ((header[4] & 0xff) << 8) + (header[5] & 0xff);
showLoadingProgress(percent, "Loading " + description + " - 5%");
int read = 0;
archiveData = new byte[archiveSizeCompressed];
while (read < archiveSizeCompressed) {
int length = archiveSizeCompressed - read;
if (length > 1000)
length = 1000;
datainputstream.readFully(archiveData, read, length);
read += length;
showLoadingProgress(percent, "Loading " + description + " - " + (5 + (read * 95) / archiveSizeCompressed) + "%");
}
datainputstream.close();
} catch (IOException ignored) {
}
showLoadingProgress(percent, "Unpacking " + description);
if (archiveSizeCompressed != archiveSize) {
byte decompressed[] = new byte[archiveSize];
BZLib.decompress(decompressed, archiveSize, archiveData, archiveSizeCompressed, 0);
return decompressed;
} else {
return archiveData;
}
}
protected Socket createSocket(String s, int i) throws IOException {
Socket socket = new Socket(InetAddress.getByName(s), i);
socket.setSoTimeout(30000);
socket.setTcpNoDelay(true);
return socket;
}
/*protected void startThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
thread.start();
}*/
}

View File

@ -0,0 +1,181 @@
public class ISAAC {
private int count;
private int results[];
private int memory[];
private int a;
private int b;
private int c;
public ISAAC(int seed[]) {
memory = new int[256];
results = new int[256];
for (int i = 0; i < seed.length; i++)
results[i] = seed[i];
init();
}
public int getNextValue() {
if (count-- == 0) {
isaac();
count = 255;
}
return results[count];
}
private void isaac() {
b += ++c;
for (int i = 0; i < 256; i++) {
int x = memory[i];
switch (i & 3) {
case 0: // '\0'
a ^= a << 13;
break;
case 1: // '\001'
a ^= a >>> 6;
break;
case 2: // '\002'
a ^= a << 2;
break;
case 3: // '\003'
a ^= a >>> 16;
break;
}
a += memory[i + 128 & 0xff];
int k;
memory[i] = k = memory[(x & 0x3fc) >> 2] + a + b;
results[i] = b = memory[(k >> 8 & 0x3fc) >> 2] + x;
}
}
private void init() {
int i1;
int j1;
int k1;
int l1;
int i2;
int j2;
int k2;
int l = i1 = j1 = k1 = l1 = i2 = j2 = k2 = 0x9e3779b9;
for (int i = 0; i < 4; i++) {
l ^= i1 << 11;
k1 += l;
i1 += j1;
i1 ^= j1 >>> 2;
l1 += i1;
j1 += k1;
j1 ^= k1 << 8;
i2 += j1;
k1 += l1;
k1 ^= l1 >>> 16;
j2 += k1;
l1 += i2;
l1 ^= i2 << 10;
k2 += l1;
i2 += j2;
i2 ^= j2 >>> 4;
l += i2;
j2 += k2;
j2 ^= k2 << 8;
i1 += j2;
k2 += l;
k2 ^= l >>> 9;
j1 += k2;
l += i1;
}
for (int j = 0; j < 256; j += 8) {
l += results[j];
i1 += results[j + 1];
j1 += results[j + 2];
k1 += results[j + 3];
l1 += results[j + 4];
i2 += results[j + 5];
j2 += results[j + 6];
k2 += results[j + 7];
l ^= i1 << 11;
k1 += l;
i1 += j1;
i1 ^= j1 >>> 2;
l1 += i1;
j1 += k1;
j1 ^= k1 << 8;
i2 += j1;
k1 += l1;
k1 ^= l1 >>> 16;
j2 += k1;
l1 += i2;
l1 ^= i2 << 10;
k2 += l1;
i2 += j2;
i2 ^= j2 >>> 4;
l += i2;
j2 += k2;
j2 ^= k2 << 8;
i1 += j2;
k2 += l;
k2 ^= l >>> 9;
j1 += k2;
l += i1;
memory[j] = l;
memory[j + 1] = i1;
memory[j + 2] = j1;
memory[j + 3] = k1;
memory[j + 4] = l1;
memory[j + 5] = i2;
memory[j + 6] = j2;
memory[j + 7] = k2;
}
for (int k = 0; k < 256; k += 8) {
l += memory[k];
i1 += memory[k + 1];
j1 += memory[k + 2];
k1 += memory[k + 3];
l1 += memory[k + 4];
i2 += memory[k + 5];
j2 += memory[k + 6];
k2 += memory[k + 7];
l ^= i1 << 11;
k1 += l;
i1 += j1;
i1 ^= j1 >>> 2;
l1 += i1;
j1 += k1;
j1 ^= k1 << 8;
i2 += j1;
k1 += l1;
k1 ^= l1 >>> 16;
j2 += k1;
l1 += i2;
l1 ^= i2 << 10;
k2 += l1;
i2 += j2;
i2 ^= j2 >>> 4;
l += i2;
j2 += k2;
j2 ^= k2 << 8;
i1 += j2;
k2 += l;
k2 ^= l >>> 9;
j1 += k2;
l += i1;
memory[k] = l;
memory[k + 1] = i1;
memory[k + 2] = j1;
memory[k + 3] = k1;
memory[k + 4] = l1;
memory[k + 5] = i2;
memory[k + 6] = j2;
memory[k + 7] = k2;
}
isaac();
count = 256;
}
}

View File

@ -0,0 +1,266 @@
import java.io.IOException;
public class Packet {
//static char charMap[];
public static int anIntArray537[] = new int[256];
public static int anIntArray541[] = new int[256];
public int readTries;
public int maxReadTries;
public int packetStart;
public byte packetData[];
/*private static int anIntArray521[] = {
0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff,
0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff,
0x3fffffff, 0x7fffffff, -1
};
int anInt522 = 61;
int anInt523 = 59;
int anInt524 = 42;
int anInt525 = 43;
int anInt526 = 44; // index list for charMap
int anInt527 = 45;
int anInt528 = 46;
int anInt529 = 47;
int anInt530 = 92;
int anInt531 = 32;
int anInt532 = 124;
int anInt533 = 34; */
public ISAAC isaacIncoming;
public ISAAC isaacOutgoing;
protected int length;
protected int packetMaxLength;
protected boolean socketException;
protected String socketExceptionMessage;
protected int delay;
private int packetEnd;
private int packet8Check;
public Packet() {
packetEnd = 3;
packet8Check = 8;
packetMaxLength = 5000;
socketException = false;
socketExceptionMessage = "";
}
public void seedIsaac(int seed[]) {
// TODO toggle isaac
//isaacIncoming = new ISAAC(seed);
//isaacOutgoing = new ISAAC(seed);
}
public void closeStream() {
}
public void readBytes(int len, byte buff[])
throws IOException {
readStreamBytes(len, 0, buff);
}
public int readPacket(byte buff[]) {
try {
readTries++;
if (maxReadTries > 0 && readTries > maxReadTries) {
socketException = true;
socketExceptionMessage = "time-out";
maxReadTries += maxReadTries;
return 0;
}
if (length == 0 && availableStream() >= 2) {
length = readStream();
if (length >= 160)
length = (length - 160) * 256 + readStream();
}
if (length > 0 && availableStream() >= length) {
if (length >= 160) {
readBytes(length, buff);
} else {
buff[length - 1] = (byte) readStream();
if (length > 1)
readBytes(length - 1, buff);
}
int i = length;
length = 0;
readTries = 0;
return i;
}
} catch (IOException ioexception) {
socketException = true;
socketExceptionMessage = ioexception.getMessage();
}
return 0;
}
public int availableStream()
throws IOException {
return 0;
}
public void readStreamBytes(int i, int j, byte abyte0[])
throws IOException {
}
public boolean hasPacket() {
return packetStart > 0;
}
public void writePacket(int i)
throws IOException {
if (socketException) {
packetStart = 0;
packetEnd = 3;
socketException = false;
throw new IOException(socketExceptionMessage);
}
delay++;
if (delay < i)
return;
if (packetStart > 0) {
delay = 0;
writeStreamBytes(packetData, 0, packetStart);
}
packetStart = 0;
packetEnd = 3;
}
public void sendPacket() {
if (isaacOutgoing != null) {
int i = packetData[packetStart + 2] & 0xff;
packetData[packetStart + 2] = (byte) (i + isaacOutgoing.getNextValue());
}
if (packet8Check != 8) // what the fuck is this even for? legacy?
packetEnd++;
int j = packetEnd - packetStart - 2;
if (j >= 160) {
packetData[packetStart] = (byte) (160 + j / 256);
packetData[packetStart + 1] = (byte) (j & 0xff);
} else {
packetData[packetStart] = (byte) j;
packetEnd--;
packetData[packetStart + 1] = packetData[packetEnd];
}
if (packetMaxLength <= 10000) // this keeps count of how many times we send each opcode, and how much bandwidth each opcode uses per session
{
int k = packetData[packetStart + 2] & 0xff;
anIntArray537[k]++;
anIntArray541[k] += packetEnd - packetStart;
}
packetStart = packetEnd;
}
public void putBytes(byte src[], int srcPos, int len) {
//for (int k = 0; k < len; k++)
// packetData[packetEnd++] = src[srcPos + k];
System.arraycopy(src, srcPos, packetData, packetEnd, len);
packetEnd += len;
}
public void putLong(long l) {
putInt((int) (l >> 32));
putInt((int) (l & -1L));
}
public void newPacket(int i) {
if (packetStart > (packetMaxLength * 4) / 5)
try {
writePacket(0);
} catch (IOException ioexception) {
socketException = true;
socketExceptionMessage = ioexception.getMessage();
}
if (packetData == null)
packetData = new byte[packetMaxLength];
packetData[packetStart + 2] = (byte) i;
packetData[packetStart + 3] = 0;
packetEnd = packetStart + 3;
packet8Check = 8;
}
public void writeStreamBytes(byte abyte0[], int i, int j)
throws IOException {
}
public int readStream()
throws IOException {
return 0;
}
public long getLong()
throws IOException {
long l = getShort();
long l1 = getShort();
long l2 = getShort();
long l3 = getShort();
return (l << 48) + (l1 << 32) + (l2 << 16) + l3;
}
public void putShort(int i) {
packetData[packetEnd++] = (byte) (i >> 8);
packetData[packetEnd++] = (byte) i;
}
public void putInt(int i) {
packetData[packetEnd++] = (byte) (i >> 24);
packetData[packetEnd++] = (byte) (i >> 16);
packetData[packetEnd++] = (byte) (i >> 8);
packetData[packetEnd++] = (byte) i;
}
public int getShort()
throws IOException {
int i = getByte();
int j = getByte();
return i * 256 + j;
}
public void putString(String s) {
//s.getBytes(0, s.length(), packetData, packetEnd);
System.arraycopy(s.getBytes(), 0, packetData, packetEnd, s.length());
packetEnd += s.length();
}
public void putByte(int i) {
packetData[packetEnd++] = (byte) i;
}
public int isaacCommand(int i) {
// TODO toggle isaac
//return i - isaacIncoming.getNextValue() & 0xff;
return i;
}
public int getByte()
throws IOException {
return readStream();
}
public void flushPacket()
throws IOException {
sendPacket();
writePacket(0);
}
// public static int anInt543;
/*static
{
charMap = new char[256];
for(int i = 0; i < 256; i++)
charMap[i] = (char)i;
charMap[61] = '=';
charMap[59] = ';';
charMap[42] = '*';
charMap[43] = '+';
charMap[44] = ',';
charMap[45] = '-';
charMap[46] = '.';
charMap[47] = '/';
charMap[92] = '\\';
charMap[124] = '|';
charMap[33] = '!';
charMap[34] = '"';
} */
}

View File

@ -0,0 +1,708 @@
public class Panel {
public static boolean drawBackgroundArrow = true;
public static int baseSpriteStart;
public static int redMod = 114;
public static int greenMod = 114;
public static int blueMod = 176;
public static int textListEntryHeightMod;
public boolean controlShown[];
public boolean controlListScrollbarHandleDragged[];
public boolean controlMaskText[];
public boolean controlClicked[];
public int controlFlashText[];
public int controlListEntryCount[];
public int controlListEntryMouseButtonDown[];
public int controlListEntryMouseOver[];
public boolean aBoolean219;
protected Surface surface;
int controlCount;
int maxControls;
boolean controlUseAlternativeColour[];
int controlX[];
int controlY[];
int controlType[];
int controlWidth[];
int controlHeight[];
int controlInputMaxLen[];
int controlTextSize[];
String controlText[];
String controlListEntries[][];
int mouseX;
int mouseY;
int mouseLastButtonDown;
int mouseButtonDown;
int focusControlIndex;
int mouseMetaButtonHeld;
int colourScrollbarTop;
int colourScrollbarBottom;
int colourScrollbarHandleLeft;
int colourScrollbarHandleMid;
int colourScrollbarHandleRight;
int colourRoundedBoxOut;
int colourRoundedBoxMid;
int colourRoundedBoxIn;
int colourBoxTopNBottom;
int colourBoxTopNBottom2;
int colourBoxLeftNRight2;
int colourBoxLeftNRight;
public Panel(Surface surface, int max) {
focusControlIndex = -1;
aBoolean219 = true;
this.surface = surface;
maxControls = max;
controlShown = new boolean[max];
controlListScrollbarHandleDragged = new boolean[max];
controlMaskText = new boolean[max];
controlClicked = new boolean[max];
controlUseAlternativeColour = new boolean[max];
controlFlashText = new int[max];// not so sure
controlListEntryCount = new int[max];
controlListEntryMouseButtonDown = new int[max];
controlListEntryMouseOver = new int[max];
controlX = new int[max];
controlY = new int[max];
controlType = new int[max];
controlWidth = new int[max];
controlHeight = new int[max];
controlInputMaxLen = new int[max];
controlTextSize = new int[max];
controlText = new String[max];
controlListEntries = new String[max][];
colourScrollbarTop = rgb2longMod(114, 114, 176);
colourScrollbarBottom = rgb2longMod(14, 14, 62);
colourScrollbarHandleLeft = rgb2longMod(200, 208, 232);
colourScrollbarHandleMid = rgb2longMod(96, 129, 184);
colourScrollbarHandleRight = rgb2longMod(53, 95, 115);
colourRoundedBoxOut = rgb2longMod(117, 142, 171);
colourRoundedBoxMid = rgb2longMod(98, 122, 158);
colourRoundedBoxIn = rgb2longMod(86, 100, 136);
colourBoxTopNBottom = rgb2longMod(135, 146, 179);
colourBoxTopNBottom2 = rgb2longMod(97, 112, 151);
colourBoxLeftNRight2 = rgb2longMod(88, 102, 136);
colourBoxLeftNRight = rgb2longMod(84, 93, 120);
}
public int rgb2longMod(int i, int j, int k) {
return Surface.rgb2long((redMod * i) / 114, (greenMod * j) / 114, (blueMod * k) / 176);
}
public void handleMouse(int mx, int my, int lastmb, int mbdown) {
mouseX = mx;
mouseY = my;
mouseButtonDown = mbdown;
if (lastmb != 0)
mouseLastButtonDown = lastmb;
if (lastmb == 1) {
for (int i1 = 0; i1 < controlCount; i1++) {
if (controlShown[i1] && controlType[i1] == 10 && mouseX >= controlX[i1] && mouseY >= controlY[i1] && mouseX <= controlX[i1] + controlWidth[i1] && mouseY <= controlY[i1] + controlHeight[i1])
controlClicked[i1] = true;
if (controlShown[i1] && controlType[i1] == 14 && mouseX >= controlX[i1] && mouseY >= controlY[i1] && mouseX <= controlX[i1] + controlWidth[i1] && mouseY <= controlY[i1] + controlHeight[i1])
controlListEntryMouseButtonDown[i1] = 1 - controlListEntryMouseButtonDown[i1];
}
}
if (mbdown == 1)
mouseMetaButtonHeld++;
else
mouseMetaButtonHeld = 0;
if (lastmb == 1 || mouseMetaButtonHeld > 20) {
for (int j1 = 0; j1 < controlCount; j1++)
if (controlShown[j1] && controlType[j1] == 15 && mouseX >= controlX[j1] && mouseY >= controlY[j1] && mouseX <= controlX[j1] + controlWidth[j1] && mouseY <= controlY[j1] + controlHeight[j1])
controlClicked[j1] = true;
mouseMetaButtonHeld -= 5;
}
}
public boolean isClicked(int i) {
if (controlShown[i] && controlClicked[i]) {
controlClicked[i] = false;
return true;
} else {
return false;
}
}
public void keyPress(int key) {
if (key == 0)
return;
if (focusControlIndex != -1 && controlText[focusControlIndex] != null && controlShown[focusControlIndex]) {
int inputLen = controlText[focusControlIndex].length();
if (key == 8 && inputLen > 0)
controlText[focusControlIndex] = controlText[focusControlIndex].substring(0, inputLen - 1);
if ((key == 10 || key == 13) && inputLen > 0)
controlClicked[focusControlIndex] = true;
String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";
if (inputLen < controlInputMaxLen[focusControlIndex]) {
for (int k = 0; k < s.length(); k++)
if (key == s.charAt(k))
controlText[focusControlIndex] += (char) key;
}
if (key == 9)
do
focusControlIndex = (focusControlIndex + 1) % controlCount;
while (controlType[focusControlIndex] != 5 && controlType[focusControlIndex] != 6);
}
}
public void drawPanel() {
for (int i = 0; i < controlCount; i++)
if (controlShown[i])
if (controlType[i] == 0)// text
drawText(i, controlX[i], controlY[i], controlText[i], controlTextSize[i]);
else if (controlType[i] == 1)// text (centered)
drawText(i, controlX[i] - surface.textWidth(controlText[i], controlTextSize[i]) / 2, controlY[i], controlText[i], controlTextSize[i]);
else if (controlType[i] == 2)// component gradient bg
drawBox(controlX[i], controlY[i], controlWidth[i], controlHeight[i]);
else if (controlType[i] == 3)// horiz line
drawLineHoriz(controlX[i], controlY[i], controlWidth[i]);
else if (controlType[i] == 4)// text list (no interaction)
drawTextList(i, controlX[i], controlY[i], controlWidth[i], controlHeight[i], controlTextSize[i], controlListEntries[i], controlListEntryCount[i], controlFlashText[i]);
else if (controlType[i] == 5 || controlType[i] == 6)// input text
drawTextInput(i, controlX[i], controlY[i], controlWidth[i], controlHeight[i], controlText[i], controlTextSize[i]);
else if (controlType[i] == 7)// option list horiz
drawOptionListHoriz(i, controlX[i], controlY[i], controlTextSize[i], controlListEntries[i]);
else if (controlType[i] == 8)// option list vert
drawOptionListVert(i, controlX[i], controlY[i], controlTextSize[i], controlListEntries[i]);
else if (controlType[i] == 9)// text list (interaction)
drawTextListInteractive(i, controlX[i], controlY[i], controlWidth[i], controlHeight[i], controlTextSize[i], controlListEntries[i], controlListEntryCount[i], controlFlashText[i]);
else if (controlType[i] == 11)// rounded box
drawRoundedBox(controlX[i], controlY[i], controlWidth[i], controlHeight[i]);
else if (controlType[i] == 12)// image
drawPicture(controlX[i], controlY[i], controlTextSize[i]);
else if (controlType[i] == 14)// checkbox
drawCheckbox(i, controlX[i], controlY[i], controlWidth[i], controlHeight[i]);
mouseLastButtonDown = 0;
}
protected void drawCheckbox(int control, int x, int y, int width, int height) {
surface.drawBox(x, y, width, height, 0xffffff);
surface.drawLineHoriz(x, y, width, colourBoxTopNBottom);
surface.drawLineVert(x, y, height, colourBoxTopNBottom);
surface.drawLineHoriz(x, (y + height) - 1, width, colourBoxLeftNRight);
surface.drawLineVert((x + width) - 1, y, height, colourBoxLeftNRight);
if (controlListEntryMouseButtonDown[control] == 1) {
for (int j1 = 0; j1 < height; j1++) {
surface.drawLineHoriz(x + j1, y + j1, 1, 0);
surface.drawLineHoriz((x + width) - 1 - j1, y + j1, 1, 0);
}
}
}
protected void drawText(int control, int x, int y, String text, int textSize) {
int y2 = y + surface.textHeight(textSize) / 3;
drawstring(control, x, y2, text, textSize);
}
protected void drawstring(int control, int x, int y, String text, int textSize) {
int i1;
if (controlUseAlternativeColour[control])
i1 = 0xffffff;
else
i1 = 0;
surface.drawstring(text, x, y, textSize, i1);
}
protected void drawTextInput(int control, int x, int y, int width, int height, String text, int textSize) {
if (controlMaskText[control]) {
int len = text.length();
text = "";
for (int i2 = 0; i2 < len; i2++)
text = text + "X";
}
if (controlType[control] == 5) {// "list input"
if (mouseLastButtonDown == 1 && mouseX >= x && mouseY >= y - height / 2 && mouseX <= x + width && mouseY <= y + height / 2)
focusControlIndex = control;
} else if (controlType[control] == 6) {// "text input"
if (mouseLastButtonDown == 1 && mouseX >= x - width / 2 && mouseY >= y - height / 2 && mouseX <= x + width / 2 && mouseY <= y + height / 2)
focusControlIndex = control;
x -= surface.textWidth(text, textSize) / 2;
}
if (focusControlIndex == control)
text = text + "*";
int y2 = y + surface.textHeight(textSize) / 3;
drawstring(control, x, y2, text, textSize);
}
public void drawBox(int x, int y, int width, int height) {
surface.setBounds(x, y, x + width, y + height);
surface.drawGradient(x, y, width, height, colourBoxLeftNRight, colourBoxTopNBottom);
if (drawBackgroundArrow) {// set to false inside startGame, draw some kindof an arrow??
for (int i1 = x - (y & 0x3f); i1 < x + width; i1 += 128) {
for (int j1 = y - (y & 0x1f); j1 < y + height; j1 += 128)
surface.drawSpriteAlpha(i1, j1, 6 + baseSpriteStart, 128);
}
}
surface.drawLineHoriz(x, y, width, colourBoxTopNBottom);
surface.drawLineHoriz(x + 1, y + 1, width - 2, colourBoxTopNBottom);
surface.drawLineHoriz(x + 2, y + 2, width - 4, colourBoxTopNBottom2);
surface.drawLineVert(x, y, height, colourBoxTopNBottom);
surface.drawLineVert(x + 1, y + 1, height - 2, colourBoxTopNBottom);
surface.drawLineVert(x + 2, y + 2, height - 4, colourBoxTopNBottom2);
surface.drawLineHoriz(x, (y + height) - 1, width, colourBoxLeftNRight);
surface.drawLineHoriz(x + 1, (y + height) - 2, width - 2, colourBoxLeftNRight);
surface.drawLineHoriz(x + 2, (y + height) - 3, width - 4, colourBoxLeftNRight2);
surface.drawLineVert((x + width) - 1, y, height, colourBoxLeftNRight);
surface.drawLineVert((x + width) - 2, y + 1, height - 2, colourBoxLeftNRight);
surface.drawLineVert((x + width) - 3, y + 2, height - 4, colourBoxLeftNRight2);
surface.resetBounds();
}
public void drawRoundedBox(int x, int y, int width, int height) {
surface.drawBox(x, y, width, height, 0);
surface.drawBoxEdge(x, y, width, height, colourRoundedBoxOut);
surface.drawBoxEdge(x + 1, y + 1, width - 2, height - 2, colourRoundedBoxMid);
surface.drawBoxEdge(x + 2, y + 2, width - 4, height - 4, colourRoundedBoxIn);
surface.drawSprite(x, y, 2 + baseSpriteStart);
surface.drawSprite((x + width) - 7, y, 3 + baseSpriteStart);
surface.drawSprite(x, (y + height) - 7, 4 + baseSpriteStart);
surface.drawSprite((x + width) - 7, (y + height) - 7, 5 + baseSpriteStart);
}
protected void drawPicture(int x, int y, int size) {
surface.drawSprite(x, y, size);
}
protected void drawLineHoriz(int x, int y, int width) {
surface.drawLineHoriz(x, y, width, 0xffffff);
}
protected void drawTextList(int control, int x, int y, int width, int height, int textSize,
String listEntries[], int listEntryCount, int l1) {
int displayedEntryCount = height / surface.textHeight(textSize);
if (l1 > listEntryCount - displayedEntryCount)
l1 = listEntryCount - displayedEntryCount;
if (l1 < 0)
l1 = 0;
controlFlashText[control] = l1;
if (displayedEntryCount < listEntryCount) {
int cornerTopRight = (x + width) - 12;
int cornerBottomLeft = ((height - 27) * displayedEntryCount) / listEntryCount;
if (cornerBottomLeft < 6)
cornerBottomLeft = 6;
int j3 = ((height - 27 - cornerBottomLeft) * l1) / (listEntryCount - displayedEntryCount);
if (mouseButtonDown == 1 && mouseX >= cornerTopRight && mouseX <= cornerTopRight + 12) {
if (mouseY > y && mouseY < y + 12 && l1 > 0)
l1--;
if (mouseY > (y + height) - 12 && mouseY < y + height && l1 < listEntryCount - displayedEntryCount)
l1++;
controlFlashText[control] = l1;
}
if (mouseButtonDown == 1 && (mouseX >= cornerTopRight && mouseX <= cornerTopRight + 12 || mouseX >= cornerTopRight - 12 && mouseX <= cornerTopRight + 24 && controlListScrollbarHandleDragged[control])) {
if (mouseY > y + 12 && mouseY < (y + height) - 12) {
controlListScrollbarHandleDragged[control] = true;
int l3 = mouseY - y - 12 - cornerBottomLeft / 2;
l1 = (l3 * listEntryCount) / (height - 24);
if (l1 > listEntryCount - displayedEntryCount)
l1 = listEntryCount - displayedEntryCount;
if (l1 < 0)
l1 = 0;
controlFlashText[control] = l1;
}
} else {
controlListScrollbarHandleDragged[control] = false;
}
j3 = ((height - 27 - cornerBottomLeft) * l1) / (listEntryCount - displayedEntryCount);
drawListContainer(x, y, width, height, j3, cornerBottomLeft);
}
int entryListStartY = height - displayedEntryCount * surface.textHeight(textSize);
int y2 = y + (surface.textHeight(textSize) * 5) / 6 + entryListStartY / 2;
for (int entry = l1; entry < listEntryCount; entry++) {
drawstring(control, x + 2, y2, listEntries[entry], textSize);
y2 += surface.textHeight(textSize) - textListEntryHeightMod;
if (y2 >= y + height)
return;
}
}
protected void drawListContainer(int x, int y, int width, int height, int corner1, int corner2) {
int x2 = (x + width) - 12;
surface.drawBoxEdge(x2, y, 12, height, 0);
surface.drawSprite(x2 + 1, y + 1, baseSpriteStart);// up arrow?
surface.drawSprite(x2 + 1, (y + height) - 12, 1 + baseSpriteStart);// down arrow?
surface.drawLineHoriz(x2, y + 13, 12, 0);
surface.drawLineHoriz(x2, (y + height) - 13, 12, 0);
surface.drawGradient(x2 + 1, y + 14, 11, height - 27, colourScrollbarTop, colourScrollbarBottom);
surface.drawBox(x2 + 3, corner1 + y + 14, 7, corner2, colourScrollbarHandleMid);
surface.drawLineVert(x2 + 2, corner1 + y + 14, corner2, colourScrollbarHandleLeft);
surface.drawLineVert(x2 + 2 + 8, corner1 + y + 14, corner2, colourScrollbarHandleRight);
}
protected void drawOptionListHoriz(int control, int x, int y, int textSize, String listEntries[]) {
int listTotalTextWidth = 0;
int listEntryCount = listEntries.length;
for (int idx = 0; idx < listEntryCount; idx++) {
listTotalTextWidth += surface.textWidth(listEntries[idx], textSize);
if (idx < listEntryCount - 1)
listTotalTextWidth += surface.textWidth(" ", textSize);
}
int left = x - listTotalTextWidth / 2;
int bottom = y + surface.textHeight(textSize) / 3;
for (int idx = 0; idx < listEntryCount; idx++) {
int colour;
if (controlUseAlternativeColour[control])
colour = 0xffffff;
else
colour = 0;
if (mouseX >= left && mouseX <= left + surface.textWidth(listEntries[idx], textSize) && mouseY <= bottom && mouseY > bottom - surface.textHeight(textSize)) {
if (controlUseAlternativeColour[control])
colour = 0x808080;
else
colour = 0xffffff;
if (mouseLastButtonDown == 1) {
controlListEntryMouseButtonDown[control] = idx;
controlClicked[control] = true;
}
}
if (controlListEntryMouseButtonDown[control] == idx)
if (controlUseAlternativeColour[control])
colour = 0xff0000;
else
colour = 0xc00000;
surface.drawstring(listEntries[idx], left, bottom, textSize, colour);
left += surface.textWidth(listEntries[idx] + " ", textSize);
}
}
protected void drawOptionListVert(int control, int x, int y, int textSize, String listEntries[]) {
int listEntryCount = listEntries.length;
int listTotalTextHeightMid = y - (surface.textHeight(textSize) * (listEntryCount - 1)) / 2;
for (int idx = 0; idx < listEntryCount; idx++) {
int colour;
if (controlUseAlternativeColour[control])
colour = 0xffffff;
else
colour = 0;
int entryTextWidth = surface.textWidth(listEntries[idx], textSize);
if (mouseX >= x - entryTextWidth / 2 && mouseX <= x + entryTextWidth / 2 && mouseY - 2 <= listTotalTextHeightMid && mouseY - 2 > listTotalTextHeightMid - surface.textHeight(textSize)) {
if (controlUseAlternativeColour[control])
colour = 0x808080;
else
colour = 0xffffff;
if (mouseLastButtonDown == 1) {
controlListEntryMouseButtonDown[control] = idx;
controlClicked[control] = true;
}
}
if (controlListEntryMouseButtonDown[control] == idx)
if (controlUseAlternativeColour[control])
colour = 0xff0000;
else
colour = 0xc00000;
surface.drawstring(listEntries[idx], x - entryTextWidth / 2, listTotalTextHeightMid, textSize, colour);
listTotalTextHeightMid += surface.textHeight(textSize);
}
}
protected void drawTextListInteractive(int control, int x, int y, int width, int height, int textSize,
String listEntries[], int listEntryCount, int l1) {
int displayedEntryCount = height / surface.textHeight(textSize);
if (displayedEntryCount < listEntryCount) {
int right = (x + width) - 12;
int l2 = ((height - 27) * displayedEntryCount) / listEntryCount;
if (l2 < 6)
l2 = 6;
int j3 = ((height - 27 - l2) * l1) / (listEntryCount - displayedEntryCount);
if (mouseButtonDown == 1 && mouseX >= right && mouseX <= right + 12) {
if (mouseY > y && mouseY < y + 12 && l1 > 0)
l1--;
if (mouseY > (y + height) - 12 && mouseY < y + height && l1 < listEntryCount - displayedEntryCount)
l1++;
controlFlashText[control] = l1;
}
if (mouseButtonDown == 1 && (mouseX >= right && mouseX <= right + 12 || mouseX >= right - 12 && mouseX <= right + 24 && controlListScrollbarHandleDragged[control])) {
if (mouseY > y + 12 && mouseY < (y + height) - 12) {
controlListScrollbarHandleDragged[control] = true;
int l3 = mouseY - y - 12 - l2 / 2;
l1 = (l3 * listEntryCount) / (height - 24);
if (l1 < 0)
l1 = 0;
if (l1 > listEntryCount - displayedEntryCount)
l1 = listEntryCount - displayedEntryCount;
controlFlashText[control] = l1;
}
} else {
controlListScrollbarHandleDragged[control] = false;
}
j3 = ((height - 27 - l2) * l1) / (listEntryCount - displayedEntryCount);
drawListContainer(x, y, width, height, j3, l2);
} else {
l1 = 0;
controlFlashText[control] = 0;
}
controlListEntryMouseOver[control] = -1;
int k2 = height - displayedEntryCount * surface.textHeight(textSize);
int i3 = y + (surface.textHeight(textSize) * 5) / 6 + k2 / 2;
for (int k3 = l1; k3 < listEntryCount; k3++) {
int i4;
if (controlUseAlternativeColour[control])
i4 = 0xffffff;
else
i4 = 0;
if (mouseX >= x + 2 && mouseX <= x + 2 + surface.textWidth(listEntries[k3], textSize) && mouseY - 2 <= i3 && mouseY - 2 > i3 - surface.textHeight(textSize)) {
if (controlUseAlternativeColour[control])
i4 = 0x808080;
else
i4 = 0xffffff;
controlListEntryMouseOver[control] = k3;
if (mouseLastButtonDown == 1) {
controlListEntryMouseButtonDown[control] = k3;
controlClicked[control] = true;
}
}
if (controlListEntryMouseButtonDown[control] == k3 && aBoolean219)
i4 = 0xff0000;
surface.drawstring(listEntries[k3], x + 2, i3, textSize, i4);
i3 += surface.textHeight(textSize);
if (i3 >= y + height)
return;
}
}
public int addText(int x, int y, String text, int size, boolean flag) {
controlType[controlCount] = 1;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlTextSize[controlCount] = size;
controlUseAlternativeColour[controlCount] = flag;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlText[controlCount] = text;
return controlCount++;
}
public int addButtonBackground(int x, int y, int width, int height) {
controlType[controlCount] = 2;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlX[controlCount] = x - width / 2;
controlY[controlCount] = y - height / 2;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
return controlCount++;
}
public int addBoxRounded(int x, int y, int width, int height) {
controlType[controlCount] = 11;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlX[controlCount] = x - width / 2;
controlY[controlCount] = y - height / 2;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
return controlCount++;
}
public int addSprite(int x, int y, int spriteId) {
int imgWidth = surface.spriteWidth[spriteId];
int imgHeight = surface.spriteHeight[spriteId];
controlType[controlCount] = 12;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlX[controlCount] = x - imgWidth / 2;
controlY[controlCount] = y - imgHeight / 2;
controlWidth[controlCount] = imgWidth;
controlHeight[controlCount] = imgHeight;
controlTextSize[controlCount] = spriteId;
return controlCount++;
}
public int addTextList(int x, int y, int width, int height, int size, int maxLength, boolean flag) {
controlType[controlCount] = 4;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
controlUseAlternativeColour[controlCount] = flag;
controlTextSize[controlCount] = size;
controlInputMaxLen[controlCount] = maxLength;
controlListEntryCount[controlCount] = 0;
controlFlashText[controlCount] = 0;
controlListEntries[controlCount] = new String[maxLength];
return controlCount++;
}
public int addTextListInput(int x, int y, int width, int height, int size, int maxLength, boolean flag,
boolean flag1) {
controlType[controlCount] = 5;
controlShown[controlCount] = true;
controlMaskText[controlCount] = flag;
controlClicked[controlCount] = false;
controlTextSize[controlCount] = size;
controlUseAlternativeColour[controlCount] = flag1;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
controlInputMaxLen[controlCount] = maxLength;
controlText[controlCount] = "";
return controlCount++;
}
public int addTextInput(int x, int y, int width, int height, int size, int maxLength, boolean flag,
boolean flag1) {
controlType[controlCount] = 6;
controlShown[controlCount] = true;
controlMaskText[controlCount] = flag;
controlClicked[controlCount] = false;
controlTextSize[controlCount] = size;
controlUseAlternativeColour[controlCount] = flag1;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
controlInputMaxLen[controlCount] = maxLength;
controlText[controlCount] = "";
return controlCount++;
}
public int addTextListInteractive(int x, int y, int width, int height, int textSize, int maxLength, boolean flag) {
controlType[controlCount] = 9;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlTextSize[controlCount] = textSize;
controlUseAlternativeColour[controlCount] = flag;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
controlInputMaxLen[controlCount] = maxLength;
controlListEntries[controlCount] = new String[maxLength];
controlListEntryCount[controlCount] = 0;
controlFlashText[controlCount] = 0;
controlListEntryMouseButtonDown[controlCount] = -1;
controlListEntryMouseOver[controlCount] = -1;
return controlCount++;
}
public int addButton(int x, int y, int width, int height) {
controlType[controlCount] = 10;
controlShown[controlCount] = true;
controlClicked[controlCount] = false;
controlX[controlCount] = x - width / 2;
controlY[controlCount] = y - height / 2;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
return controlCount++;
}
public int addLineHoriz(int x, int y, int width) {
controlType[controlCount] = 3;
controlShown[controlCount] = true;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlWidth[controlCount] = width;
return controlCount++;
}
public int addOptionListHoriz(int x, int y, int textSize, int maxListCount,
boolean useAltColour) {
controlType[controlCount] = 7;
controlShown[controlCount] = true;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlTextSize[controlCount] = textSize;
controlListEntries[controlCount] = new String[maxListCount];
controlListEntryCount[controlCount] = 0;
controlUseAlternativeColour[controlCount] = useAltColour;
controlClicked[controlCount] = false;
return controlCount++;
}
public int addOptionListVert(int x, int y, int textSize, int maxListCount,
boolean useAltColour) {
controlType[controlCount] = 8;
controlShown[controlCount] = true;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlTextSize[controlCount] = textSize;
controlListEntries[controlCount] = new String[maxListCount];
controlListEntryCount[controlCount] = 0;
controlUseAlternativeColour[controlCount] = useAltColour;
controlClicked[controlCount] = false;
return controlCount++;
}
public int addCheckbox(int x, int y, int width, int height) {
controlType[controlCount] = 14;
controlShown[controlCount] = true;
controlX[controlCount] = x;
controlY[controlCount] = y;
controlWidth[controlCount] = width;
controlHeight[controlCount] = height;
controlListEntryMouseButtonDown[controlCount] = 0;
return controlCount++;
}
public void clearList(int control) {
controlListEntryCount[control] = 0;
}
public void resetListProps(int control) {
controlFlashText[control] = 0;
controlListEntryMouseOver[control] = -1;
}
public void addListEntry(int control, int index, String text) {
controlListEntries[control][index] = text;
if (index + 1 > controlListEntryCount[control])
controlListEntryCount[control] = index + 1;
}
public void removeListEntry(int control, String text, boolean flag) {
int j = controlListEntryCount[control]++;
if (j >= controlInputMaxLen[control]) {
j--;
controlListEntryCount[control]--;
for (int k = 0; k < j; k++)
controlListEntries[control][k] = controlListEntries[control][k + 1];
}
controlListEntries[control][j] = text;
if (flag)
controlFlashText[control] = 999999;// 0xf423f;
}
public void updateText(int control, String s) {
controlText[control] = s;
}
public String getText(int control) {
if (controlText[control] == null)
return "null";
else
return controlText[control];
}
public void show(int control) {
controlShown[control] = true;
}
public void hide(int control) {
controlShown[control] = false;
}
public void setFocus(int control) {
focusControlIndex = control;
}
public int getListEntryIndex(int control) {
return controlListEntryMouseOver[control];
}
}

View File

@ -0,0 +1,25 @@
public class Polygon {
protected int minPlaneX;
protected int minPlaneY;
protected int maxPlaneX;
protected int maxPlaneY;
protected int minZ;
protected int maxZ;
protected GameModel model;
protected int face;
protected int depth;
protected int normalX;
protected int normalY;
protected int normalZ;
protected int visibility;
protected int facefill;
protected boolean skipSomething;
protected int index;
protected int index2;
public Polygon() {
skipSomething = false;
index2 = -1;
}
}

View File

@ -0,0 +1,10 @@
public class Scanline {
int startX;
int endX;
int startS;
int endS;
public Scanline() {
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
public class StreamAudioPlayer {
public void stopPlayer() {}
public synchronized void writeStream(byte buff[], int off, int len) {
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
//import java.awt.*;
public class SurfaceSprite extends Surface {
public mudclient mudclientref;
public SurfaceSprite(int width, int height, int k, mudclient component) {
super(width, height, k, component);
}
public void spriteClipping(int x, int y, int w, int h, int id, int tx, int ty) {
if (id >= 50000) {
mudclientref.drawTeleportBubble(x, y, w, h, id - 50000, tx, ty);
return;
}
if (id >= 40000) {
mudclientref.drawItem(x, y, w, h, id - 40000, tx, ty);
return;
}
if (id >= 20000) {
mudclientref.drawNpc(x, y, w, h, id - 20000, tx, ty);
return;
}
if (id >= 5000) {
mudclientref.drawPlayer(x, y, w, h, id - 5000, tx, ty);
return;
} else {
super.spriteClipping(x, y, w, h, id);
return;
}
}
}

View File

@ -0,0 +1,238 @@
import java.io.*;
import java.net.URL;
public class Utility {
//public static String lastFile;
public static URL appletCodeBase = null;
public static boolean aBoolean546;
private static int bitmask[] = {
0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff,
0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff,
0x3fffffff, 0x7fffffff, -1
};
public static InputStream openFile(String s)
throws IOException {
//lastFile = s;
Object obj;
if (appletCodeBase == null) {
obj = new BufferedInputStream(new FileInputStream(s));
} else {
URL url = new URL(appletCodeBase, s);
obj = url.openStream();
}
return ((InputStream) (obj));
}
public static void readFully(String s, byte abyte0[], int i)
throws IOException {
InputStream inputstream = openFile(s);
DataInputStream datainputstream = new DataInputStream(inputstream);
try {
datainputstream.readFully(abyte0, 0, i);
} catch (EOFException Ex) {
}
datainputstream.close();
}
public static int getUnsignedByte(byte byte0) {
return byte0 & 0xff;
}
public static int getUnsignedShort(byte abyte0[], int i) {
return ((abyte0[i] & 0xff) << 8) + (abyte0[i + 1] & 0xff);
}
public static int getUnsignedInt(byte abyte0[], int i) {
return ((abyte0[i] & 0xff) << 24) + ((abyte0[i + 1] & 0xff) << 16) + ((abyte0[i + 2] & 0xff) << 8) + (abyte0[i + 3] & 0xff);
}
public static long getUnsignedLong(byte buff[], int off) {
return (((long) getUnsignedInt(buff, off) & 0xffffffffL) << 32) + ((long) getUnsignedInt(buff, off + 4) & 0xffffffffL);
}
public static int getSignedShort(byte abyte0[], int i) {
int j = getUnsignedByte(abyte0[i]) * 256 + getUnsignedByte(abyte0[i + 1]);
if (j > 32767)
j -= 0x10000;
return j;
}
public static int getUnsignedInt2(byte abyte0[], int i) {
if ((abyte0[i] & 0xff) < 128)
return abyte0[i];
else
return ((abyte0[i] & 0xff) - 128 << 24) + ((abyte0[i + 1] & 0xff) << 16) + ((abyte0[i + 2] & 0xff) << 8) + (abyte0[i + 3] & 0xff);
}
public static int getBitMask(byte buff[], int off, int len) {
int k = off >> 3;
int l = 8 - (off & 7);
int i1 = 0;
for (; len > l; l = 8) {
i1 += (buff[k++] & bitmask[l]) << len - l;
len -= l;
}
if (len == l)
i1 += buff[k] & bitmask[l];
else
i1 += buff[k] >> l - len & bitmask[len];
return i1;
}
public static String formatAuthString(String s, int maxlen) {
String s1 = "";
for (int j = 0; j < maxlen; j++)
if (j >= s.length()) {
s1 = s1 + " ";
} else {
char c = s.charAt(j);
if (c >= 'a' && c <= 'z')
s1 = s1 + c;
else if (c >= 'A' && c <= 'Z')
s1 = s1 + c;
else if (c >= '0' && c <= '9')
s1 = s1 + c;
else
s1 = s1 + '_';
}
return s1;
}
public static String ip2string(int i) {
return (i >> 24 & 0xff) + "." + (i >> 16 & 0xff) + "." + (i >> 8 & 0xff) + "." + (i & 0xff);
}
public static long username2hash(String s) {
String s1 = "";
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c >= 'a' && c <= 'z')
s1 = s1 + c;
else if (c >= 'A' && c <= 'Z')
s1 = s1 + (char) ((c + 97) - 65);
else if (c >= '0' && c <= '9')
s1 = s1 + c;
else
s1 = s1 + ' ';
}
s1 = s1.trim();
if (s1.length() > 12)
s1 = s1.substring(0, 12);
long hash = 0L;
for (int j = 0; j < s1.length(); j++) {
char c1 = s1.charAt(j);
hash *= 37L;
if (c1 >= 'a' && c1 <= 'z')
hash += (1 + c1) - 97;
else if (c1 >= '0' && c1 <= '9')
hash += (27 + c1) - 48;
}
return hash;
}
public static String hash2username(long hash) {
if (hash < 0L)
return "invalidName";
String s = "";
while (hash != 0L) {
int i = (int) (hash % 37L);
hash /= 37L;
if (i == 0)
s = " " + s;
else if (i < 27) {
if (hash % 37L == 0L)
s = (char) ((i + 65) - 1) + s;
else
s = (char) ((i + 97) - 1) + s;
} else {
s = (char) ((i + 48) - 27) + s;
}
}
return s;
}
public static int getDataFileOffset(String filename, byte data[]) {
int numEntries = getUnsignedShort(data, 0);
int wantedHash = 0;
filename = filename.toUpperCase();
for (int k = 0; k < filename.length(); k++)
wantedHash = (wantedHash * 61 + filename.charAt(k)) - 32;
int offset = 2 + numEntries * 10;
for (int entry = 0; entry < numEntries; entry++) {
int fileHash = (data[entry * 10 + 2] & 0xff) * 0x1000000 + (data[entry * 10 + 3] & 0xff) * 0x10000 + (data[entry * 10 + 4] & 0xff) * 256 + (data[entry * 10 + 5] & 0xff);
int fileSize = (data[entry * 10 + 9] & 0xff) * 0x10000 + (data[entry * 10 + 10] & 0xff) * 256 + (data[entry * 10 + 11] & 0xff);
if (fileHash == wantedHash)
return offset;
offset += fileSize;
}
return 0;
}
public static int getDataFileLength(String filename, byte data[]) {
int numEntries = getUnsignedShort(data, 0);
int wantedHash = 0;
filename = filename.toUpperCase();
for (int k = 0; k < filename.length(); k++)
wantedHash = (wantedHash * 61 + filename.charAt(k)) - 32;
int offset = 2 + numEntries * 10;
for (int i1 = 0; i1 < numEntries; i1++) {
int fileHash = (data[i1 * 10 + 2] & 0xff) * 0x1000000 + (data[i1 * 10 + 3] & 0xff) * 0x10000 + (data[i1 * 10 + 4] & 0xff) * 256 + (data[i1 * 10 + 5] & 0xff);
int fileSize = (data[i1 * 10 + 6] & 0xff) * 0x10000 + (data[i1 * 10 + 7] & 0xff) * 256 + (data[i1 * 10 + 8] & 0xff);
int fileSizeCompressed = (data[i1 * 10 + 9] & 0xff) * 0x10000 + (data[i1 * 10 + 10] & 0xff) * 256 + (data[i1 * 10 + 11] & 0xff);
if (fileHash == wantedHash)
return fileSize;
offset += fileSizeCompressed;
}
return 0;
}
public static byte[] loadData(String s, int i, byte abyte0[]) {
byte[] b = unpackData(s, i, abyte0, null);
return b;
}
public static byte[] unpackData(String filename, int i, byte archiveData[], byte fileData[]) {
int numEntries = (archiveData[0] & 0xff) * 256 + (archiveData[1] & 0xff);
int wantedHash = 0;
filename = filename.toUpperCase();
for (int l = 0; l < filename.length(); l++){
wantedHash = (wantedHash * 61 + filename.charAt(l)) - 32;
}
int offset = 2 + numEntries * 10;
for (int entry = 0; entry < numEntries; entry++) {
int fileHash = (archiveData[entry * 10 + 2] & 0xff) * 0x1000000 + (archiveData[entry * 10 + 3] & 0xff) * 0x10000 + (archiveData[entry * 10 + 4] & 0xff) * 256 + (archiveData[entry * 10 + 5] & 0xff);
int fileSize = (archiveData[entry * 10 + 6] & 0xff) * 0x10000 + (archiveData[entry * 10 + 7] & 0xff) * 256 + (archiveData[entry * 10 + 8] & 0xff);
int fileSizeCompressed = (archiveData[entry * 10 + 9] & 0xff) * 0x10000 + (archiveData[entry * 10 + 10] & 0xff) * 256 + (archiveData[entry * 10 + 11] & 0xff);
if (fileHash == wantedHash) {
if (fileData == null)
fileData = new byte[fileSize + i];
if (fileSize != fileSizeCompressed) {
BZLib.decompress(fileData, fileSize, archiveData, fileSizeCompressed, offset);
} else {
for (int j = 0; j < fileSize; j++)
fileData[j] = archiveData[offset + j];
}
return fileData;
}
offset += fileSizeCompressed;
}
return null;
}
}

View File

@ -0,0 +1,15 @@
public class Version {
//public static int unused = 203;
public static int CLIENT = 204;
public static int CONFIG = 85;
public static int MAPS = 63;
public static int MEDIA = 58;
public static int MODELS = 36;
public static int TEXTURES = 17;
public static int ENTITY = 24;
public static int SOUNDS = 1;
public static int FILTER = 2;
public static int FONTS = 1;
}

View File

@ -0,0 +1,711 @@
public class WordFilter {
static boolean DEBUGTLD;
static boolean DEBUGWORD;
static boolean forceLowercase = true;
//static int unused = 3;// todo
static int hashFragments[];
static char badList[][];
static byte badCharIds[][][];
static char hostList[][];
static byte hostCharIds[][][];
static char tldList[][];
static int tldType[];
static String ignoreList[] = {
"cook", "cook's", "cooks", "seeks", "sheet"
};
public static void loadFilters(Buffer fragments, Buffer bad, Buffer host, Buffer tld) {
loadBad(bad);
loadHost(host);
loadFragments(fragments);
loadTld(tld);
}
public static void loadTld(Buffer buffer) {
int wordcount = buffer.getUnsignedInt();
tldList = new char[wordcount][];
tldType = new int[wordcount];
for (int idx = 0; idx < wordcount; idx++) {
tldType[idx] = buffer.getUnsignedByte();
char ac[] = new char[buffer.getUnsignedByte()];
for (int k = 0; k < ac.length; k++)
ac[k] = (char) buffer.getUnsignedByte();
tldList[idx] = ac;
}
}
public static void loadBad(Buffer buffer) {
int wordcount = buffer.getUnsignedInt();
badList = new char[wordcount][];
badCharIds = new byte[wordcount][][];
readBuffer(buffer, badList, badCharIds);
}
public static void loadHost(Buffer buffer) {
int wordcount = buffer.getUnsignedInt();
hostList = new char[wordcount][];
hostCharIds = new byte[wordcount][][];
readBuffer(buffer, hostList, hostCharIds);
}
public static void loadFragments(Buffer buffer) {
hashFragments = new int[buffer.getUnsignedInt()];
for (int i = 0; i < hashFragments.length; i++) {
hashFragments[i] = buffer.getUnsignedShort();
}
}
public static void readBuffer(Buffer buffer, char wordList[][], byte charIds[][][]) {
for (int i = 0; i < wordList.length; i++) {
char currentWord[] = new char[buffer.getUnsignedByte()];
for (int j = 0; j < currentWord.length; j++)
currentWord[j] = (char) buffer.getUnsignedByte();
wordList[i] = currentWord;
byte ids[][] = new byte[buffer.getUnsignedInt()][2];
for (int j = 0; j < ids.length; j++) {
ids[j][0] = (byte) buffer.getUnsignedByte();
ids[j][1] = (byte) buffer.getUnsignedByte();
}
if (ids.length > 0)
charIds[i] = ids;
}
}
public static String filter(String input) {
char inputChars[] = input.toLowerCase().toCharArray();
applyDotSlashFilter(inputChars);
applyBadwordFilter(inputChars);
applyHostFilter(inputChars);
heywhathteufck(inputChars);
for (int ignoreIdx = 0; ignoreIdx < ignoreList.length; ignoreIdx++) {
for (int inputIgnoreIdx = -1; (inputIgnoreIdx = input.indexOf(ignoreList[ignoreIdx], inputIgnoreIdx + 1)) != -1; ) {
char ignorewordChars[] = ignoreList[ignoreIdx].toCharArray();
for (int ignorewordIdx = 0; ignorewordIdx < ignorewordChars.length; ignorewordIdx++)
inputChars[ignorewordIdx + inputIgnoreIdx] = ignorewordChars[ignorewordIdx];
}
}
if (forceLowercase) {
stripLowercase(input.toCharArray(), inputChars);
toLowercase(inputChars);
}
return new String(inputChars);
}
public static void stripLowercase(char input[], char output[]) {
for (int i = 0; i < input.length; i++)
if (output[i] != '*' && isUppercase(input[i]))
output[i] = input[i];
}
public static void toLowercase(char input[]) {
boolean isUppercase = true;
for (int i = 0; i < input.length; i++) {
char current = input[i];
if (isLetter(current)) {
if (isUppercase) {
if (isLowercase(current))
isUppercase = false;
} else if (isUppercase(current))
input[i] = (char) ((current + 97) - 65);
} else {
isUppercase = true;
}
}
}
public static void applyBadwordFilter(char input[]) {
for (int i = 0; i < 2; i++) {// why lol
for (int j = badList.length - 1; j >= 0; j--)
applyWordFilter(input, badList[j], badCharIds[j]);
}
}
public static void applyHostFilter(char input[]) {
for (int i = hostList.length - 1; i >= 0; i--)
applyWordFilter(input, hostList[i], hostCharIds[i]);
}
public static void applyDotSlashFilter(char input[]) {
char input1[] = input.clone();
char dot[] = {
'd', 'o', 't'
};
applyWordFilter(input1, dot, null);
char input2[] = input.clone();
char slash[] = {
's', 'l', 'a', 's', 'h'
};
applyWordFilter(input2, slash, null);
for (int i = 0; i < tldList.length; i++)
applyTldFilter(input, input1, input2, tldList[i], tldType[i]);
}
public static void applyTldFilter(char input[], char input1[], char input2[], char tld[], int type) {
if (tld.length > input.length)
return;
for (int charIndex = 0; charIndex <= input.length - tld.length; charIndex++) {
int inputCharCount = charIndex;
int l = 0;
while (inputCharCount < input.length) {
int i1 = 0;
char current = input[inputCharCount];
char next = '\0';
if (inputCharCount + 1 < input.length)
next = input[inputCharCount + 1];
if (l < tld.length && (i1 = compareLettersNumbers(tld[l], current, next)) > 0) {
inputCharCount += i1;
l++;
continue;
}
if (l == 0)
break;
if ((i1 = compareLettersNumbers(tld[l - 1], current, next)) > 0) {
inputCharCount += i1;
continue;
}
if (l >= tld.length || !isSpecial(current))
break;
inputCharCount++;
}
if (l >= tld.length) {
boolean flag = false;
int startMatch = getAsteriskCount(input, input1, charIndex);
int endMatch = getAsteriskCount2(input, input2, inputCharCount - 1);
if (DEBUGTLD)
System.out.println("Potential tld: " + tld + " at char " + charIndex + " (type=" + type + ", startmatch=" + startMatch + ", endmatch=" + endMatch + ")");
if (type == 1 && startMatch > 0 && endMatch > 0)
flag = true;
if (type == 2 && (startMatch > 2 && endMatch > 0 || startMatch > 0 && endMatch > 2))
flag = true;
if (type == 3 && startMatch > 0 && endMatch > 2)
flag = true;
boolean tmp = type == 3 && startMatch > 2 && endMatch > 0;
if (flag) {
if (DEBUGTLD)
System.out.println("Filtered tld: " + tld + " at char " + charIndex);
int l1 = charIndex;
int i2 = inputCharCount - 1;
if (startMatch > 2) {
if (startMatch == 4) {
boolean flag1 = false;
for (int k2 = l1 - 1; k2 >= 0; k2--)
if (flag1) {
if (input1[k2] != '*')
break;
l1 = k2;
} else if (input1[k2] == '*') {
l1 = k2;
flag1 = true;
}
}
boolean flag2 = false;
for (int l2 = l1 - 1; l2 >= 0; l2--)
if (flag2) {
if (isSpecial(input[l2]))
break;
l1 = l2;
} else if (!isSpecial(input[l2])) {
flag2 = true;
l1 = l2;
}
}
if (endMatch > 2) {
if (endMatch == 4) {
boolean flag3 = false;
for (int i3 = i2 + 1; i3 < input.length; i3++)
if (flag3) {
if (input2[i3] != '*')
break;
i2 = i3;
} else if (input2[i3] == '*') {
i2 = i3;
flag3 = true;
}
}
boolean flag4 = false;
for (int j3 = i2 + 1; j3 < input.length; j3++)
if (flag4) {
if (isSpecial(input[j3]))
break;
i2 = j3;
} else if (!isSpecial(input[j3])) {
flag4 = true;
i2 = j3;
}
}
for (int j2 = l1; j2 <= i2; j2++)
input[j2] = '*';
}
}
}
}
public static int getAsteriskCount(char input[], char input1[], int len) {// fldajmolfmiALFKM
if (len == 0)
return 2;
for (int j = len - 1; j >= 0; j--) {
if (!isSpecial(input[j]))
break;
if (input[j] == ',' || input[j] == '.')
return 3;
}
int filtered = 0;
for (int l = len - 1; l >= 0; l--) {
if (!isSpecial(input1[l]))
break;
if (input1[l] == '*')
filtered++;
}
if (filtered >= 3)
return 4;
return isSpecial(input[len - 1]) ? 1 : 0;
}
public static int getAsteriskCount2(char input[], char input1[], int len) {// lolmnafomLMAFOA
if (len + 1 == input.length)
return 2;
for (int j = len + 1; j < input.length; j++) {
if (!isSpecial(input[j]))
break;
if (input[j] == '\\' || input[j] == '/')
return 3;
}
int filtered = 0;
for (int l = len + 1; l < input.length; l++) {
if (!isSpecial(input1[l]))
break;
if (input1[l] == '*')
filtered++;
}
if (filtered >= 5)
return 4;
return isSpecial(input[len + 1]) ? 1 : 0;
}
public static void applyWordFilter(char input[], char wordlist[], byte charIds[][]) {
if (wordlist.length > input.length)
return;
for (int charIndex = 0; charIndex <= input.length - wordlist.length; charIndex++) {
int inputCharCount = charIndex;
int k = 0;
boolean specialChar = false;
while (inputCharCount < input.length) {
int l = 0;
char inputChar = input[inputCharCount];
char nextChar = '\0';
if (inputCharCount + 1 < input.length)
nextChar = input[inputCharCount + 1];
if (k < wordlist.length && (l = compareLettersSymbols(wordlist[k], inputChar, nextChar)) > 0) {
inputCharCount += l;
k++;
continue;
}
if (k == 0)
break;
if ((l = compareLettersSymbols(wordlist[k - 1], inputChar, nextChar)) > 0) {
inputCharCount += l;
continue;
}
if (k >= wordlist.length || !isNotLowercase(inputChar))
break;
if (isSpecial(inputChar) && inputChar != '\'')
specialChar = true;
inputCharCount++;
}
if (k >= wordlist.length) {
boolean filter = true;
if (DEBUGTLD)
System.out.println("Potential word: " + wordlist + " at char " + charIndex);
if (!specialChar) {
char prevChar = ' ';
if (charIndex - 1 >= 0)
prevChar = input[charIndex - 1];
char curChar = ' ';
if (inputCharCount < input.length)
curChar = input[inputCharCount];
byte prevId = getCharId(prevChar);
byte curId = getCharId(curChar);
if (charIds != null && compareCharIds(charIds, prevId, curId))
filter = false;
} else {
boolean flag2 = false;
boolean flag3 = false;
if (charIndex - 1 < 0 || isSpecial(input[charIndex - 1]) && input[charIndex - 1] != '\'')
flag2 = true;
if (inputCharCount >= input.length || isSpecial(input[inputCharCount]) && input[inputCharCount] != '\'')
flag3 = true;
if (!flag2 || !flag3) {
boolean flag4 = false;
int j1 = charIndex - 2;
if (flag2)
j1 = charIndex;
for (; !flag4 && j1 < inputCharCount; j1++)
if (j1 >= 0 && (!isSpecial(input[j1]) || input[j1] == '\'')) {
char ac2[] = new char[3];
int k1;
for (k1 = 0; k1 < 3; k1++) {
if (j1 + k1 >= input.length || isSpecial(input[j1 + k1]) && input[j1 + k1] != '\'')
break;
ac2[k1] = input[j1 + k1];
}
boolean flag5 = true;
if (k1 == 0)
flag5 = false;
if (k1 < 3 && j1 - 1 >= 0 && (!isSpecial(input[j1 - 1]) || input[j1 - 1] == '\''))
flag5 = false;
if (flag5 && !containsFragmentHashes(ac2))
flag4 = true;
}
if (!flag4)
filter = false;
}
}
if (filter) {
if (DEBUGWORD)
System.out.println("Filtered word: " + wordlist + " at char " + charIndex);
for (int i1 = charIndex; i1 < inputCharCount; i1++)
input[i1] = '*';
}
}
}
}
public static boolean compareCharIds(byte charIdData[][], byte prevCharId, byte curCharId) {
int first = 0;
if (charIdData[first][0] == prevCharId && charIdData[first][1] == curCharId)
return true;
int last = charIdData.length - 1;
if (charIdData[last][0] == prevCharId && charIdData[last][1] == curCharId)
return true;
while (first != last && first + 1 != last) {
int middle = (first + last) / 2;
if (charIdData[middle][0] == prevCharId && charIdData[middle][1] == curCharId)
return true;
if (prevCharId < charIdData[middle][0] || prevCharId == charIdData[middle][0] && curCharId < charIdData[middle][1])
last = middle;
else
first = middle;
}
return false;
}
/**
* @param filterChar
* @param currentChar
* @param nextChar
* @return 0 for no match, 1 for currentChar matches, 2 for both currentChar and nextChar matching
*/
public static int compareLettersNumbers(char filterChar, char currentChar, char nextChar) {
if (filterChar == currentChar)
return 1;
if (filterChar == 'e' && currentChar == '3')
return 1;
if (filterChar == 't' && (currentChar == '7' || currentChar == '+'))
return 1;
if (filterChar == 'a' && (currentChar == '4' || currentChar == '@'))
return 1;
if (filterChar == 'o' && currentChar == '0')
return 1;
if (filterChar == 'i' && currentChar == '1')
return 1;
if (filterChar == 's' && currentChar == '5')
return 1;
if (filterChar == 'f' && currentChar == 'p' && nextChar == 'h')
return 2;
return filterChar == 'g' && currentChar == '9' ? 1 : 0;
}
/**
* @param filterChar character to compare against
* @param currentChar current character
* @param nextChar next character
* @return 0 for no match, 1 for currentChar matches, 2 for both currentChar and nextChar matching
*/
public static int compareLettersSymbols(char filterChar, char currentChar, char nextChar) {
if (filterChar == '*')
return 0;
if (filterChar == currentChar)
return 1;
if (filterChar >= 'a' && filterChar <= 'z') {
if (filterChar == 'e')
return currentChar == '3' ? 1 : 0;
if (filterChar == 't')
return currentChar == '7' ? 1 : 0;
if (filterChar == 'a')
return currentChar == '4' || currentChar == '@' ? 1 : 0;
if (filterChar == 'o') {
if (currentChar == '0' || currentChar == '*')
return 1;
return currentChar == '(' && nextChar == ')' ? 2 : 0;
}
if (filterChar == 'i')
return currentChar == 'y' || currentChar == 'l' || currentChar == 'j' || currentChar == 'l' || currentChar == '!' || currentChar == ':' || currentChar == ';' ? 1 : 0;
if (filterChar == 'n')
return 0;
if (filterChar == 's')
return currentChar == '5' || currentChar == 'z' || currentChar == '$' ? 1 : 0;
if (filterChar == 'r')
return 0;
if (filterChar == 'h')
return 0;
if (filterChar == 'l')
return currentChar == '1' ? 1 : 0;
if (filterChar == 'd')
return 0;
if (filterChar == 'c')
return currentChar == '(' ? 1 : 0;
if (filterChar == 'u')
return currentChar == 'v' ? 1 : 0;
if (filterChar == 'm')
return 0;
if (filterChar == 'f')
return currentChar == 'p' && nextChar == 'h' ? 2 : 0;
if (filterChar == 'p')
return 0;
if (filterChar == 'g')
return currentChar == '9' || currentChar == '6' ? 1 : 0;
if (filterChar == 'w')
return currentChar == 'v' && nextChar == 'v' ? 2 : 0;
if (filterChar == 'y')
return 0;
if (filterChar == 'b')
return currentChar == '1' && nextChar == '3' ? 2 : 0;
if (filterChar == 'v')
return 0;
if (filterChar == 'k')
return 0;
if (filterChar == 'x')
return currentChar == ')' && nextChar == '(' ? 2 : 0;
if (filterChar == 'j')
return 0;
if (filterChar == 'q')
return 0;
if (filterChar == 'z')
return 0;
}
if (filterChar >= '0' && filterChar <= '9') {
if (filterChar == '0') {
if (currentChar == 'o' || currentChar == 'O')
return 1;
return currentChar == '(' && nextChar == ')' ? 2 : 0;
}
if (filterChar == '1')
return currentChar != 'l' ? 0 : 1;
if (filterChar == '2')
return 0;
if (filterChar == '3')
return 0;
if (filterChar == '4')
return 0;
if (filterChar == '5')
return 0;
if (filterChar == '6')
return 0;
if (filterChar == '7')
return 0;
if (filterChar == '8')
return 0;
if (filterChar == '9')
return 0;
}
if (filterChar == '-')
return 0;
if (filterChar == ',')
return currentChar == '.' ? 1 : 0;
if (filterChar == '.')
return currentChar == ',' ? 1 : 0;
if (filterChar == '(')
return 0;
if (filterChar == ')')
return 0;
if (filterChar == '!')
return currentChar == 'i' ? 1 : 0;
if (filterChar == '\'')
return 0;
if (DEBUGWORD)
System.out.println("Letter=" + filterChar + " not matched");
return 0;
}
/**
* Returns the id for the given char, ranging from {@code 1} to {@code 38}.
* <p>
* <pre>
* id range
* 1-26 a-z
* 27 unknown
* 28 apostrophe
* 29-38 0-9
* </pre>
*
* @param c
* @return id for char {@code c}
*/
public static byte getCharId(char c) {
if (c >= 'a' && c <= 'z')
return (byte) (c - 97 + 1);
if (c == '\'')
return 28;
if (c >= '0' && c <= '9')
return (byte) (c - 48 + 29);
else
return 27;
}
public static void heywhathteufck(char input[]) {
int digitIndex = 0;
int fromIndex = 0;
int k = 0;
int l = 0;
while ((digitIndex = indexOfDigit(input, fromIndex)) != -1) {
boolean flag = false;
for (int i = fromIndex; i >= 0 && i < digitIndex && !flag; i++)
if (!isSpecial(input[i]) && !isNotLowercase(input[i]))
flag = true;
if (flag)
k = 0;
if (k == 0)
l = digitIndex;
fromIndex = indexOfNonDigit(input, digitIndex);
int j1 = 0;
for (int k1 = digitIndex; k1 < fromIndex; k1++)
j1 = (j1 * 10 + input[k1]) - 48;
if (j1 > 255 || fromIndex - digitIndex > 8)
k = 0;
else
k++;
if (k == 4) {
for (int i = l; i < fromIndex; i++)
input[i] = '*';
k = 0;
}
}
}
public static int indexOfDigit(char input[], int fromIndex) {
for (int i = fromIndex; i < input.length && i >= 0; i++)
if (input[i] >= '0' && input[i] <= '9')
return i;
return -1;
}
public static int indexOfNonDigit(char input[], int fromIndex) {
for (int i = fromIndex; i < input.length && i >= 0; i++)
if (input[i] < '0' || input[i] > '9')
return i;
return input.length;
}
public static boolean isSpecial(char c) {
return !isLetter(c) && !isDigit(c);
}
public static boolean isNotLowercase(char c) {
if (c < 'a' || c > 'z')
return true;
return c == 'v' || c == 'x' || c == 'j' || c == 'q' || c == 'z';
}
public static boolean isLetter(char c) {
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z';
}
public static boolean isDigit(char c) {
return c >= '0' && c <= '9';
}
public static boolean isLowercase(char c) {
return c >= 'a' && c <= 'z';
}
public static boolean isUppercase(char c) {
return c >= 'A' && c <= 'Z';
}
public static boolean containsFragmentHashes(char input[]) {
boolean notNum = true;
for (int i = 0; i < input.length; i++)
if (!isDigit(input[i]) && input[i] != 0)
notNum = false;
if (notNum)
return true;
int inputHash = word2hash(input);
int first = 0;
int last = hashFragments.length - 1;
if (inputHash == hashFragments[first] || inputHash == hashFragments[last])
return true;
while (first != last && first + 1 != last) {
int middle = (first + last) / 2;
if (inputHash == hashFragments[middle])
return true;
if (inputHash < hashFragments[middle])
last = middle;
else
first = middle;
}
return false;
}
/**
* @param word
* @return
* @see WordFilter#getCharId(char)
*/
public static int word2hash(char word[]) {
if (word.length > 6)
return 0;
int hash = 0;
for (int i = 0; i < word.length; i++) {
char c = word[word.length - i - 1];
if (c >= 'a' && c <= 'z')
hash = hash * 38 + c - 97 + 1;
else if (c == '\'')
hash = hash * 38 + 27;
else if (c >= '0' && c <= '9')
hash = hash * 38 + c - 48 + 28;
else if (c != 0) {
if (DEBUGWORD)
System.out.println("word2hash failed on " + new String(word));
return 0;
}
}
return hash;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff