forked from 2009Scape/Server
Another batch of preemptive bugfixing
This commit is contained in:
parent
b151cb852b
commit
1b7c2914cb
19 changed files with 84 additions and 84 deletions
|
|
@ -137,15 +137,15 @@ public class IoSession {
|
|||
*/
|
||||
public void queue(ByteBuffer buffer) {
|
||||
try {
|
||||
writingLock.tryLock(1000L, TimeUnit.MILLISECONDS);
|
||||
if(writingLock.tryLock(1000L, TimeUnit.MILLISECONDS)){
|
||||
writingQueue.add(buffer);
|
||||
writingLock.unlock();
|
||||
write();
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
writingLock.unlock();
|
||||
return;
|
||||
}
|
||||
writingQueue.add(buffer);
|
||||
writingLock.unlock();
|
||||
write();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -168,10 +168,11 @@ public class IoSession {
|
|||
}
|
||||
writingQueue.remove(0);
|
||||
}
|
||||
writingLock.unlock();
|
||||
} catch (IOException e) {
|
||||
disconnect();
|
||||
writingLock.unlock();
|
||||
}
|
||||
writingLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ms.net.packet;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import ms.system.util.ByteBufferUtils;
|
||||
|
||||
|
|
@ -301,7 +302,7 @@ public class IoBuffer {
|
|||
* @return
|
||||
*/
|
||||
public IoBuffer putString(String val) {
|
||||
buf.put(val.getBytes());
|
||||
buf.put(val.getBytes(StandardCharsets.UTF_8));
|
||||
buf.put((byte) 0);
|
||||
return this;
|
||||
}
|
||||
|
|
@ -313,7 +314,7 @@ public class IoBuffer {
|
|||
*/
|
||||
public IoBuffer putJagString(String val) {
|
||||
buf.put((byte) 0);
|
||||
buf.put(val.getBytes());
|
||||
buf.put(val.getBytes(StandardCharsets.UTF_8));
|
||||
buf.put((byte) 0);
|
||||
return this;
|
||||
}
|
||||
|
|
@ -557,18 +558,6 @@ public class IoBuffer {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ object WorldPacketRepository {
|
|||
* @param message The message to send.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun sendPlayerMessage(player: PlayerSession?, message: String?) {
|
||||
fun sendPlayerMessage(player: PlayerSession?, message: String) {
|
||||
if (player == null) {
|
||||
return
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ object WorldPacketRepository {
|
|||
player.world.session.write(buffer)
|
||||
}
|
||||
|
||||
fun sendPlayerMessage(player: PlayerSession?, messages: Array<String?>) {
|
||||
fun sendPlayerMessage(player: PlayerSession?, messages: Array<String>) {
|
||||
if (player == null) {
|
||||
return
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ object WorldPacketRepository {
|
|||
@JvmStatic
|
||||
fun sendContactUpdate(
|
||||
player: PlayerSession,
|
||||
contact: String?,
|
||||
contact: String,
|
||||
block: Boolean,
|
||||
remove: Boolean,
|
||||
worldId: Int,
|
||||
|
|
@ -127,7 +127,7 @@ object WorldPacketRepository {
|
|||
* @param type The message type.
|
||||
*/
|
||||
@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)
|
||||
buffer.putString(player.username)
|
||||
buffer.putString(p.username)
|
||||
|
|
@ -184,7 +184,7 @@ object WorldPacketRepository {
|
|||
* @param names The names.
|
||||
*/
|
||||
@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)
|
||||
buffer.putString(player.username)
|
||||
buffer.put(player.worldId)
|
||||
|
|
@ -227,7 +227,7 @@ object WorldPacketRepository {
|
|||
* @param duration The duration of the punishment.
|
||||
*/
|
||||
@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)
|
||||
buffer.putString(key)
|
||||
buffer.put(type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue