mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Another batch of preemptive bugfixing
This commit is contained in:
parent
b151cb852b
commit
1b7c2914cb
19 changed files with 84 additions and 84 deletions
|
|
@ -13,8 +13,10 @@ import ms.world.WorldDatabase;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -138,7 +140,7 @@ public final class Management {
|
||||||
Runtime.getRuntime().addShutdownHook(new ShutdownSequence());
|
Runtime.getRuntime().addShutdownHook(new ShutdownSequence());
|
||||||
System.out.println("Status: ready.");
|
System.out.println("Status: ready.");
|
||||||
System.out.println("Use -commands for a list of commands!");
|
System.out.println("Use -commands for a list of commands!");
|
||||||
Scanner s = new Scanner(System.in);
|
Scanner s = new Scanner(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||||
while (s.hasNext()) {
|
while (s.hasNext()) {
|
||||||
try {
|
try {
|
||||||
String command = s.nextLine();
|
String command = s.nextLine();
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class ClassLoadServer extends Thread {
|
||||||
/**
|
/**
|
||||||
* Holds classes and resources already added in the server
|
* Holds classes and resources already added in the server
|
||||||
*/
|
*/
|
||||||
protected static HashMap<String, byte[]> resourceCache = new HashMap<String, byte[]>();
|
protected final static HashMap<String, byte[]> resourceCache = new HashMap<String, byte[]>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New socket
|
* New socket
|
||||||
|
|
@ -60,7 +60,9 @@ public class ClassLoadServer extends Thread {
|
||||||
//System.out.println("New Connection from : " + clientSocket.getInetAddress());
|
//System.out.println("New Connection from : " + clientSocket.getInetAddress());
|
||||||
WorkerThread wcs = new WorkerThread(clientSocket);
|
WorkerThread wcs = new WorkerThread(clientSocket);
|
||||||
wcs.start();
|
wcs.start();
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,15 +137,15 @@ public class IoSession {
|
||||||
*/
|
*/
|
||||||
public void queue(ByteBuffer buffer) {
|
public void queue(ByteBuffer buffer) {
|
||||||
try {
|
try {
|
||||||
writingLock.tryLock(1000L, TimeUnit.MILLISECONDS);
|
if(writingLock.tryLock(1000L, TimeUnit.MILLISECONDS)){
|
||||||
|
writingQueue.add(buffer);
|
||||||
|
writingLock.unlock();
|
||||||
|
write();
|
||||||
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
writingLock.unlock();
|
writingLock.unlock();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
writingQueue.add(buffer);
|
|
||||||
writingLock.unlock();
|
|
||||||
write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -168,10 +168,11 @@ public class IoSession {
|
||||||
}
|
}
|
||||||
writingQueue.remove(0);
|
writingQueue.remove(0);
|
||||||
}
|
}
|
||||||
|
writingLock.unlock();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
disconnect();
|
disconnect();
|
||||||
|
writingLock.unlock();
|
||||||
}
|
}
|
||||||
writingLock.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package ms.net.packet;
|
package ms.net.packet;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import ms.system.util.ByteBufferUtils;
|
import ms.system.util.ByteBufferUtils;
|
||||||
|
|
||||||
|
|
@ -301,7 +302,7 @@ public class IoBuffer {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IoBuffer putString(String val) {
|
public IoBuffer putString(String val) {
|
||||||
buf.put(val.getBytes());
|
buf.put(val.getBytes(StandardCharsets.UTF_8));
|
||||||
buf.put((byte) 0);
|
buf.put((byte) 0);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -313,7 +314,7 @@ public class IoBuffer {
|
||||||
*/
|
*/
|
||||||
public IoBuffer putJagString(String val) {
|
public IoBuffer putJagString(String val) {
|
||||||
buf.put((byte) 0);
|
buf.put((byte) 0);
|
||||||
buf.put(val.getBytes());
|
buf.put(val.getBytes(StandardCharsets.UTF_8));
|
||||||
buf.put((byte) 0);
|
buf.put((byte) 0);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -557,18 +558,6 @@ public class IoBuffer {
|
||||||
return buf.getLong();
|
return buf.getLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getSmart() {
|
|
||||||
int peek = buf.get(buf.position());
|
|
||||||
if (peek <= Byte.MAX_VALUE) {
|
|
||||||
return buf.get() & 0xFF;
|
|
||||||
}
|
|
||||||
return (buf.getShort() & 0xFFFF) - 32768;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ object WorldPacketRepository {
|
||||||
* @param message The message to send.
|
* @param message The message to send.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendPlayerMessage(player: PlayerSession?, message: String?) {
|
fun sendPlayerMessage(player: PlayerSession?, message: String) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ object WorldPacketRepository {
|
||||||
player.world.session.write(buffer)
|
player.world.session.write(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendPlayerMessage(player: PlayerSession?, messages: Array<String?>) {
|
fun sendPlayerMessage(player: PlayerSession?, messages: Array<String>) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +98,7 @@ object WorldPacketRepository {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendContactUpdate(
|
fun sendContactUpdate(
|
||||||
player: PlayerSession,
|
player: PlayerSession,
|
||||||
contact: String?,
|
contact: String,
|
||||||
block: Boolean,
|
block: Boolean,
|
||||||
remove: Boolean,
|
remove: Boolean,
|
||||||
worldId: Int,
|
worldId: Int,
|
||||||
|
|
@ -127,7 +127,7 @@ object WorldPacketRepository {
|
||||||
* @param type The message type.
|
* @param type The message type.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendMessage(player: PlayerSession, p: PlayerSession, type: Int, message: String?) {
|
fun sendMessage(player: PlayerSession, p: PlayerSession, type: Int, message: String) {
|
||||||
val buffer = IoBuffer(5, PacketHeader.BYTE)
|
val buffer = IoBuffer(5, PacketHeader.BYTE)
|
||||||
buffer.putString(player.username)
|
buffer.putString(player.username)
|
||||||
buffer.putString(p.username)
|
buffer.putString(p.username)
|
||||||
|
|
@ -184,7 +184,7 @@ object WorldPacketRepository {
|
||||||
* @param names The names.
|
* @param names The names.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun notifyPlayers(server: GameServer, player: PlayerSession, names: List<String?>) {
|
fun notifyPlayers(server: GameServer, player: PlayerSession, names: List<String>) {
|
||||||
val buffer = IoBuffer(8, PacketHeader.SHORT)
|
val buffer = IoBuffer(8, PacketHeader.SHORT)
|
||||||
buffer.putString(player.username)
|
buffer.putString(player.username)
|
||||||
buffer.put(player.worldId)
|
buffer.put(player.worldId)
|
||||||
|
|
@ -227,7 +227,7 @@ object WorldPacketRepository {
|
||||||
* @param duration The duration of the punishment.
|
* @param duration The duration of the punishment.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendPunishUpdate(world: GameServer, key: String?, type: Int, duration: Long) {
|
fun sendPunishUpdate(world: GameServer, key: String, type: Int, duration: Long) {
|
||||||
val buffer = IoBuffer(11, PacketHeader.BYTE)
|
val buffer = IoBuffer(11, PacketHeader.BYTE)
|
||||||
buffer.putString(key)
|
buffer.putString(key)
|
||||||
buffer.put(type)
|
buffer.put(type)
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,9 @@ public final class PunishmentStorage {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
return;
|
return;
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
SQLManager.close(connection);
|
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
ban(player.getIpAddress(), type);
|
ban(player.getIpAddress(), type);
|
||||||
|
|
@ -152,8 +153,9 @@ public final class PunishmentStorage {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
SQLManager.close(connection);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,8 +177,9 @@ public final class PunishmentStorage {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
SQLManager.close(connection);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,8 +242,9 @@ public final class PunishmentStorage {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
SQLManager.close(connection);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,9 +256,9 @@ public final class PunishmentStorage {
|
||||||
private static String getDuration(long end) {
|
private static String getDuration(long end) {
|
||||||
String time = "indefinite time";
|
String time = "indefinite time";
|
||||||
if (end != Long.MAX_VALUE) {
|
if (end != Long.MAX_VALUE) {
|
||||||
int days = (int) ((end -= System.currentTimeMillis()) / (24 * 60 * 60_000));
|
int days = (int) ((System.currentTimeMillis()) / (24 * 60 * 60_000));
|
||||||
int hours = (int) ((end -= (days * 24 * 60 * 60_000)) / (60 * 60_000));
|
int hours = (int) (((24L * days * 60 * 60_000)) / (60 * 60_000));
|
||||||
int minutes = (int) ((end -= (hours * (60 * 60_000))) / 60_000);
|
int minutes = (int) (((hours * (60 * 60_000))) / 60_000);
|
||||||
time = days + "d, " + hours + "h, " + minutes + "m";
|
time = days + "d, " + hours + "h, " + minutes + "m";
|
||||||
}
|
}
|
||||||
return time;
|
return time;
|
||||||
|
|
|
||||||
|
|
@ -141,14 +141,20 @@ public final class CommunicationInfo {
|
||||||
public void save(PreparedStatement statement) throws SQLException {
|
public void save(PreparedStatement statement) throws SQLException {
|
||||||
String contacts = "";
|
String contacts = "";
|
||||||
String blocked = "";
|
String blocked = "";
|
||||||
|
StringBuilder blockedBuilder = new StringBuilder();
|
||||||
for (int i = 0; i < this.blocked.size(); i++) {
|
for (int i = 0; i < this.blocked.size(); i++) {
|
||||||
blocked += (i == 0 ? "" : ",") + this.blocked.get(i);
|
String blockline = (i == 0 ? "" : ",") + this.blocked.get(i);
|
||||||
|
blockedBuilder.append(blockline);
|
||||||
}
|
}
|
||||||
|
blocked = blockedBuilder.toString();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
StringBuilder contactBuilder = new StringBuilder();
|
||||||
for (Entry<String, ClanRank> entry : this.contacts.entrySet()) {
|
for (Entry<String, ClanRank> entry : this.contacts.entrySet()) {
|
||||||
contacts += "{" + entry.getKey() + "," + entry.getValue().ordinal() + "}" + (count == this.contacts.size() - 1 ? "" : "~");
|
String contactLine = "{" + entry.getKey() + "," + entry.getValue().ordinal() + "}" + (count == this.contacts.size() - 1 ? "" : "~");
|
||||||
|
contactBuilder.append(contactLine);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
contacts = contactBuilder.toString();
|
||||||
statement.setString(3, contacts);
|
statement.setString(3, contacts);
|
||||||
statement.setString(4, blocked);
|
statement.setString(4, blocked);
|
||||||
statement.setString(5, clanName);
|
statement.setString(5, clanName);
|
||||||
|
|
@ -211,6 +217,8 @@ public final class CommunicationInfo {
|
||||||
case 3:
|
case 3:
|
||||||
lootRequirement = rank;
|
lootRequirement = rank;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,9 +247,9 @@ public final class CommunicationInfo {
|
||||||
*/
|
*/
|
||||||
public void save(ByteBuffer buffer) {
|
public void save(ByteBuffer buffer) {
|
||||||
buffer.put((byte) contacts.size());
|
buffer.put((byte) contacts.size());
|
||||||
for (String name : contacts.keySet()) {
|
for(Entry<String,ClanRank> contact : contacts.entrySet()){
|
||||||
ByteBufferUtils.putString(name, buffer);
|
ByteBufferUtils.putString(contact.getKey(), buffer);
|
||||||
buffer.put((byte) contacts.get(name).ordinal());
|
buffer.put((byte) contact.getValue().ordinal());
|
||||||
}
|
}
|
||||||
buffer.put((byte) blocked.size());
|
buffer.put((byte) blocked.size());
|
||||||
for (String name : blocked) {
|
for (String name : blocked) {
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,4 @@ public final class SQLTable {
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the columns.
|
|
||||||
* @return The columns.
|
|
||||||
*/
|
|
||||||
public SQLColumn[] getColumns() {
|
|
||||||
return columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -31,12 +31,16 @@ public final class WorldListSQLHandler extends SQLEntryHandler<GameServer> {
|
||||||
* Clears the world list.
|
* Clears the world list.
|
||||||
*/
|
*/
|
||||||
public static void clearWorldList() {
|
public static void clearWorldList() {
|
||||||
|
Connection connection = SQLManager.getConnection();
|
||||||
|
if(connection == null) return;
|
||||||
try {
|
try {
|
||||||
Connection connection = SQLManager.getConnection();
|
|
||||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM " + TABLE);
|
PreparedStatement statement = connection.prepareStatement("DELETE FROM " + TABLE);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
SQLManager.close(connection);
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package ms.system.util;
|
package ms.system.util;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,7 +31,7 @@ public final class ByteBufferUtils {
|
||||||
* @param buffer The byte buffer.
|
* @param buffer The byte buffer.
|
||||||
*/
|
*/
|
||||||
public static void putString(String s, ByteBuffer buffer) {
|
public static void putString(String s, ByteBuffer buffer) {
|
||||||
buffer.put(s.getBytes()).put((byte) 0);
|
buffer.put(s.getBytes(StandardCharsets.UTF_8)).put((byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@ public class EncryptionManager {
|
||||||
* @return the decoded value of x
|
* @return the decoded value of x
|
||||||
*/
|
*/
|
||||||
private static byte char64(char x) {
|
private static byte char64(char x) {
|
||||||
if ((int)x < 0 || (int)x > index_64.length)
|
if ((int)x > index_64.length)
|
||||||
return -1;
|
return -1;
|
||||||
return index_64[(int)x];
|
return index_64[(int)x];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,26 +14,16 @@ public final class StringUtils {
|
||||||
/**
|
/**
|
||||||
* The valid characters to be used in names/messages/...
|
* The valid characters to be used in names/messages/...
|
||||||
*/
|
*/
|
||||||
public static final char[] VALID_CHARS = {
|
private static final char[] VALID_CHARS = {
|
||||||
'_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
'_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||||
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
|
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
|
||||||
'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Character mapping.
|
|
||||||
*/
|
|
||||||
public static char[] mapping = {
|
|
||||||
'\n',
|
|
||||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
||||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
||||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ' };
|
|
||||||
/**
|
/**
|
||||||
* The an int array241.
|
* The an int array241.
|
||||||
*/
|
*/
|
||||||
public static int[] anIntArray241 = { 215, 203, 83, 158, 104, 101, 93, 84,
|
private final static int[] anIntArray241 = { 215, 203, 83, 158, 104, 101, 93, 84,
|
||||||
107, 103, 109, 95, 94, 98, 89, 86, 70, 41, 32, 27, 24, 23, -1, -2,
|
107, 103, 109, 95, 94, 98, 89, 86, 70, 41, 32, 27, 24, 23, -1, -2,
|
||||||
26, -3, -4, 31, 30, -5, -6, -7, 37, 38, 36, -8, -9, -10, 40, -11,
|
26, -3, -4, 31, 30, -5, -6, -7, 37, 38, 36, -8, -9, -10, 40, -11,
|
||||||
-12, 55, 48, 46, 47, -13, -14, -15, 52, 51, -16, -17, 54, -18, -19,
|
-12, 55, 48, 46, 47, -13, -14, -15, 52, 51, -16, -17, 54, -18, -19,
|
||||||
|
|
@ -173,7 +163,7 @@ public final class StringUtils {
|
||||||
boolean wasSpace = true;
|
boolean wasSpace = true;
|
||||||
for (int i = 0; i < name.length(); i++) {
|
for (int i = 0; i < name.length(); i++) {
|
||||||
if (wasSpace) {
|
if (wasSpace) {
|
||||||
newName.append((new String() + name.charAt(i)).toUpperCase());
|
newName.append(("" + name.charAt(i)).toUpperCase());
|
||||||
wasSpace = false;
|
wasSpace = false;
|
||||||
} else {
|
} else {
|
||||||
newName.append(name.charAt(i));
|
newName.append(name.charAt(i));
|
||||||
|
|
@ -306,9 +296,8 @@ public final class StringUtils {
|
||||||
* @return The string value.
|
* @return The string value.
|
||||||
*/
|
*/
|
||||||
public static String getString(String s) {
|
public static String getString(String s) {
|
||||||
String string = s.replaceAll("\\<.*?>", "").replaceAll(" ", "")
|
return s.replaceAll("\\<.*?>", "").replaceAll(" ", "")
|
||||||
.replaceAll("Discontinued Item:", "");
|
.replaceAll("Discontinued Item:", "");
|
||||||
return string;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Characters used to convert a String to a Long.
|
* Characters used to convert a String to a Long.
|
||||||
|
|
@ -319,7 +308,7 @@ public final class StringUtils {
|
||||||
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
|
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
|
||||||
'3', '4', '5', '6', '7', '8', '9'
|
'3', '4', '5', '6', '7', '8', '9'
|
||||||
};
|
};
|
||||||
public static int[] anIntArray233 = {
|
private final static int[] anIntArray233 = {
|
||||||
0, 1024, 2048, 3072, 4096, 5120,
|
0, 1024, 2048, 3072, 4096, 5120,
|
||||||
6144, 8192, 9216, 12288, 10240, 11264, 16384, 18432, 17408, 20480,
|
6144, 8192, 9216, 12288, 10240, 11264, 16384, 18432, 17408, 20480,
|
||||||
21504, 22528, 23552, 24576, 25600, 26624, 27648, 28672, 29696,
|
21504, 22528, 23552, 24576, 25600, 26624, 27648, 28672, 29696,
|
||||||
|
|
@ -362,7 +351,7 @@ public final class StringUtils {
|
||||||
301188096, 301189120, 301190144, 301191168, 301193216, 301195264,
|
301188096, 301189120, 301190144, 301191168, 301193216, 301195264,
|
||||||
301194240, 301197312, 301198336, 301199360, 301201408, 301202432
|
301194240, 301197312, 301198336, 301199360, 301201408, 301202432
|
||||||
};
|
};
|
||||||
public static byte[] aByteArray235 = {
|
private final static byte[] aByteArray235 = {
|
||||||
22, 22, 22, 22, 22, 22, 21, 22, 22,
|
22, 22, 22, 22, 22, 22, 21, 22, 22,
|
||||||
20, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
20, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||||
22, 22, 22, 22, 22, 22, 3, 8, 22, 16, 22, 16, 17, 7, 13, 13, 13,
|
22, 22, 22, 22, 22, 22, 3, 8, 22, 16, 22, 16, 17, 7, 13, 13, 13,
|
||||||
|
|
@ -387,16 +376,16 @@ public final class StringUtils {
|
||||||
try {
|
try {
|
||||||
i_27_ += i_25_;
|
i_27_ += i_25_;
|
||||||
int i_29_ = 0;
|
int i_29_ = 0;
|
||||||
int i_30_ = i_26_ << -2116795453;
|
int i_30_ = i_26_ << 3;
|
||||||
for (; i_27_ > i_25_; i_25_++) {
|
for (; i_27_ > i_25_; i_25_++) {
|
||||||
int i_31_ = 0xff & is_28_[i_25_];
|
int i_31_ = 0xff & is_28_[i_25_];
|
||||||
int i_32_ = anIntArray233[i_31_];
|
int i_32_ = anIntArray233[i_31_];
|
||||||
int i_33_ = aByteArray235[i_31_];
|
int i_33_ = aByteArray235[i_31_];
|
||||||
int i_34_ = i_30_ >> -1445887805;
|
int i_34_ = i_30_ >> 3;
|
||||||
int i_35_ = i_30_ & 0x7;
|
int i_35_ = i_30_ & 0x7;
|
||||||
i_29_ &= (-i_35_ >> 473515839);
|
i_29_ &= (-i_35_ >> 31);
|
||||||
i_30_ += i_33_;
|
i_30_ += i_33_;
|
||||||
int i_36_ = ((-1 + (i_35_ - -i_33_)) >> -1430991229) + i_34_;
|
int i_36_ = ((-1 + (i_35_ - -i_33_)) >> 3) + i_34_;
|
||||||
i_35_ += 24;
|
i_35_ += 24;
|
||||||
is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_)));
|
is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_)));
|
||||||
if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) {
|
if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) {
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,8 @@ public final class PlayerSession {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -160,6 +162,8 @@ public final class PlayerSession {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
communication.clear();
|
communication.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -201,6 +205,8 @@ public final class PlayerSession {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
SQLManager.close(connection);
|
SQLManager.close(connection);
|
||||||
|
} finally {
|
||||||
|
SQLManager.close(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -459,7 +465,9 @@ public final class PlayerSession {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return username.equals(((PlayerSession) o).username);
|
if(o instanceof PlayerSession) {
|
||||||
|
return username.equals(((PlayerSession) o).username);
|
||||||
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class WorldDatabase {
|
||||||
/**
|
/**
|
||||||
* The game servers.
|
* The game servers.
|
||||||
*/
|
*/
|
||||||
public static final GameServer[] DATABASE = new GameServer[ServerConstants.WORLD_LIMIT];
|
private static final GameServer[] DATABASE = new GameServer[ServerConstants.WORLD_LIMIT];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The update time stamp.
|
* The update time stamp.
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,8 @@ public class UIDInfo {
|
||||||
case 4:
|
case 4:
|
||||||
serial = ByteBufferUtils.getString(buffer);
|
serial = ByteBufferUtils.getString(buffer);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +114,7 @@ public class UIDInfo {
|
||||||
* @return the string.
|
* @return the string.
|
||||||
*/
|
*/
|
||||||
private String parseFormat(String string) {
|
private String parseFormat(String string) {
|
||||||
if (string == null || string == "") {
|
if (string == null || string.equals("")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringTokenizer token = new StringTokenizer(string, "|");
|
StringTokenizer token = new StringTokenizer(string, "|");
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,8 @@ public class Definition<T extends Node> {
|
||||||
public String getExamine() {
|
public String getExamine() {
|
||||||
if (examine == null) {
|
if (examine == null) {
|
||||||
try {
|
try {
|
||||||
examine = handlers.get("examine").toString();
|
if(handlers.get("examine") != null)
|
||||||
|
examine = handlers.get("examine").toString();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,8 @@ public final class NPCDefinition extends Definition<NPC> {
|
||||||
*/
|
*/
|
||||||
public boolean isVisibleOnMap;
|
public boolean isVisibleOnMap;
|
||||||
|
|
||||||
/* *//**
|
|
||||||
* The examine option value
|
public String examine;
|
||||||
*//*
|
|
||||||
public String examine;*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The drop tables.
|
* The drop tables.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import core.cache.misc.buffer.ByteBufferUtils;
|
||||||
import core.game.interaction.OptionHandler;
|
import core.game.interaction.OptionHandler;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
import core.game.node.object.Scenery;
|
import core.game.node.object.Scenery;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
||||||
import rs09.game.system.SystemLogger;
|
import rs09.game.system.SystemLogger;
|
||||||
import rs09.game.world.GameWorld;
|
import rs09.game.world.GameWorld;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ object RegionManager {
|
||||||
val region = forId(regionId)
|
val region = forId(regionId)
|
||||||
Region.load(region)
|
Region.load(region)
|
||||||
val `object`: Scenery? = region.planes[z].getChunkObject(x, y, objectId)
|
val `object`: Scenery? = region.planes[z].getChunkObject(x, y, objectId)
|
||||||
return if (`object` != null && !`object`.isRenderable()) {
|
return if (`object` != null && !`object`.isRenderable) {
|
||||||
null
|
null
|
||||||
} else `object`
|
} else `object`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue