mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-06 08:39:06 +00:00
more stuff
This commit is contained in:
@@ -6,14 +6,19 @@ import redone.game.players.Client;
|
|||||||
import redone.game.players.Player;
|
import redone.game.players.Player;
|
||||||
import redone.game.players.PlayerHandler;
|
import redone.game.players.PlayerHandler;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import static redone.game.players.PlayerSave.loadPlayerInfo;
|
import static redone.game.players.PlayerSave.loadPlayerInfo;
|
||||||
|
|
||||||
public class Bot {
|
public class Bot {
|
||||||
|
|
||||||
private Client botClient;
|
private Client botClient;
|
||||||
|
static Timer timer = new Timer();
|
||||||
|
|
||||||
public Bot(String username) {
|
public Bot(String username) {
|
||||||
botClient = new Client(null, -1);
|
botClient = new Client(null);
|
||||||
botClient.playerName = username;
|
botClient.playerName = username;
|
||||||
|
|
||||||
botClient.playerName = username;
|
botClient.playerName = username;
|
||||||
@@ -31,9 +36,26 @@ public class Bot {
|
|||||||
System.out.println(botClient.getPlayerAssistant().getTotalLevel());
|
System.out.println(botClient.getPlayerAssistant().getTotalLevel());
|
||||||
Server.playerHandler.newPlayerClient(botClient);
|
Server.playerHandler.newPlayerClient(botClient);
|
||||||
loadPlayerInfo(botClient, username, "bot_password", false);
|
loadPlayerInfo(botClient, username, "bot_password", false);
|
||||||
|
new TradeChat().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Client getBotClient() {
|
public Client getBotClient() {
|
||||||
return botClient;
|
return botClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TradeChat extends TimerTask {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendTradeChat();
|
||||||
|
int delay = (15 + new Random().nextInt(25)) * 1000;
|
||||||
|
timer.schedule(new TradeChat(), delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendTradeChat() {
|
||||||
|
botClient.setChatTextColor(9);
|
||||||
|
botClient.setChatTextEffects(2);
|
||||||
|
botClient.forcedChat("<col=#FF0033>Selling Rune Platebody 210k ea - " + botClient.playerName + "</col>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class BotHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String botName = "bot" + random.nextInt(9999) + random.nextInt(9999);
|
final String botName = "bot" + random.nextInt(9999);
|
||||||
|
|
||||||
bot = new Bot(botName);
|
bot = new Bot(botName);
|
||||||
botList.add(bot);
|
botList.add(bot);
|
||||||
|
|||||||
@@ -1804,7 +1804,8 @@ public class ItemAssistant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (totalItems != totalItemsAfter) {
|
if (totalItems != totalItemsAfter) {
|
||||||
c.disconnected = true;
|
if (!c.isBot)
|
||||||
|
c.disconnected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1826,15 +1827,19 @@ public class ItemAssistant {
|
|||||||
|
|
||||||
public void resetBank() {
|
public void resetBank() {
|
||||||
synchronized (c) {
|
synchronized (c) {
|
||||||
c.getOutStream().createFrameVarSizeWord(53);
|
if (c.getOutStream() != null) {
|
||||||
c.getOutStream().writeWord(5382); // bank
|
c.getOutStream().createFrameVarSizeWord(53);
|
||||||
c.getOutStream().writeWord(Constants.BANK_SIZE);
|
c.getOutStream().writeWord(5382); // bank
|
||||||
|
c.getOutStream().writeWord(Constants.BANK_SIZE);
|
||||||
|
}
|
||||||
for (int i = 0; i < Constants.BANK_SIZE; i++) {
|
for (int i = 0; i < Constants.BANK_SIZE; i++) {
|
||||||
if (c.bankItemsN[i] > 254) {
|
if (c.getOutStream() != null) {
|
||||||
c.getOutStream().writeByte(255);
|
if (c.bankItemsN[i] > 254) {
|
||||||
c.getOutStream().writeDWord_v2(c.bankItemsN[i]);
|
c.getOutStream().writeByte(255);
|
||||||
} else {
|
c.getOutStream().writeDWord_v2(c.bankItemsN[i]);
|
||||||
c.getOutStream().writeByte(c.bankItemsN[i]);
|
} else {
|
||||||
|
c.getOutStream().writeByte(c.bankItemsN[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (c.bankItemsN[i] < 1) {
|
if (c.bankItemsN[i] < 1) {
|
||||||
c.bankItems[i] = 0;
|
c.bankItems[i] = 0;
|
||||||
@@ -1842,10 +1847,15 @@ public class ItemAssistant {
|
|||||||
if (c.bankItems[i] > Constants.ITEM_LIMIT || c.bankItems[i] < 0) {
|
if (c.bankItems[i] > Constants.ITEM_LIMIT || c.bankItems[i] < 0) {
|
||||||
c.bankItems[i] = Constants.ITEM_LIMIT;
|
c.bankItems[i] = Constants.ITEM_LIMIT;
|
||||||
}
|
}
|
||||||
c.getOutStream().writeWordBigEndianA(c.bankItems[i]);
|
if (c.getOutStream() != null) {
|
||||||
|
c.getOutStream().writeWordBigEndianA(c.bankItems[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.getOutStream() != null) {
|
||||||
|
c.getOutStream().endFrameVarSizeWord();
|
||||||
|
c.flushOutStream();
|
||||||
}
|
}
|
||||||
c.getOutStream().endFrameVarSizeWord();
|
|
||||||
c.flushOutStream();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1857,24 +1867,32 @@ public class ItemAssistant {
|
|||||||
itemCount = i;
|
itemCount = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.getOutStream().createFrameVarSizeWord(53);
|
if (c.getOutStream() != null){
|
||||||
c.getOutStream().writeWord(5064);
|
c.getOutStream().createFrameVarSizeWord(53);
|
||||||
c.getOutStream().writeWord(itemCount + 1);
|
c.getOutStream().writeWord(5064);
|
||||||
|
c.getOutStream().writeWord(itemCount + 1);
|
||||||
|
}
|
||||||
for (int i = 0; i < itemCount + 1; i++) {
|
for (int i = 0; i < itemCount + 1; i++) {
|
||||||
if (c.playerItemsN[i] > 254) {
|
|
||||||
c.getOutStream().writeByte(255);
|
if (c.getOutStream() != null) {
|
||||||
c.getOutStream().writeDWord_v2(c.playerItemsN[i]);
|
if (c.playerItemsN[i] > 254) {
|
||||||
} else {
|
c.getOutStream().writeByte(255);
|
||||||
c.getOutStream().writeByte(c.playerItemsN[i]);
|
c.getOutStream().writeDWord_v2(c.playerItemsN[i]);
|
||||||
|
} else {
|
||||||
|
c.getOutStream().writeByte(c.playerItemsN[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (c.playerItems[i] > Constants.ITEM_LIMIT || c.playerItems[i] < 0) {
|
if (c.playerItems[i] > Constants.ITEM_LIMIT || c.playerItems[i] < 0) {
|
||||||
c.playerItems[i] = Constants.ITEM_LIMIT;
|
c.playerItems[i] = Constants.ITEM_LIMIT;
|
||||||
}
|
}
|
||||||
c.getOutStream().writeWordBigEndianA(c.playerItems[i]);
|
if (c.getOutStream() != null) {
|
||||||
|
c.getOutStream().writeWordBigEndianA(c.playerItems[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c.getOutStream() != null) {
|
||||||
|
c.getOutStream().endFrameVarSizeWord();
|
||||||
|
c.flushOutStream();
|
||||||
}
|
}
|
||||||
c.getOutStream().endFrameVarSizeWord();
|
|
||||||
c.flushOutStream();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bankItem(int itemID, int fromSlot, int amount) {
|
public boolean bankItem(int itemID, int fromSlot, int amount) {
|
||||||
@@ -2287,18 +2305,20 @@ public class ItemAssistant {
|
|||||||
|
|
||||||
public void setEquipment(int wearID, int amount, int targetSlot) {
|
public void setEquipment(int wearID, int amount, int targetSlot) {
|
||||||
// synchronized(c) {
|
// synchronized(c) {
|
||||||
c.getOutStream().createFrameVarSizeWord(34);
|
if (c.getOutStream() != null) {
|
||||||
c.getOutStream().writeWord(1688);
|
c.getOutStream().createFrameVarSizeWord(34);
|
||||||
c.getOutStream().writeByte(targetSlot);
|
c.getOutStream().writeWord(1688);
|
||||||
c.getOutStream().writeWord(wearID + 1);
|
c.getOutStream().writeByte(targetSlot);
|
||||||
if (amount > 254) {
|
c.getOutStream().writeWord(wearID + 1);
|
||||||
c.getOutStream().writeByte(255);
|
if (amount > 254) {
|
||||||
c.getOutStream().writeDWord(amount);
|
c.getOutStream().writeByte(255);
|
||||||
} else {
|
c.getOutStream().writeDWord(amount);
|
||||||
c.getOutStream().writeByte(amount);
|
} else {
|
||||||
|
c.getOutStream().writeByte(amount);
|
||||||
|
}
|
||||||
|
c.getOutStream().endFrameVarSizeWord();
|
||||||
|
c.flushOutStream();
|
||||||
}
|
}
|
||||||
c.getOutStream().endFrameVarSizeWord();
|
|
||||||
c.flushOutStream();
|
|
||||||
c.playerEquipment[targetSlot] = wearID;
|
c.playerEquipment[targetSlot] = wearID;
|
||||||
c.playerEquipmentN[targetSlot] = amount;
|
c.playerEquipmentN[targetSlot] = amount;
|
||||||
c.updateRequired = true;
|
c.updateRequired = true;
|
||||||
@@ -2385,12 +2405,15 @@ public class ItemAssistant {
|
|||||||
|
|
||||||
c.playerEquipment[j] = -1;
|
c.playerEquipment[j] = -1;
|
||||||
c.playerEquipmentN[j] = c.playerEquipmentN[j] - 1;
|
c.playerEquipmentN[j] = c.playerEquipmentN[j] - 1;
|
||||||
c.getOutStream().createFrame(34);
|
|
||||||
c.getOutStream().writeWord(6);
|
if (c.getOutStream() != null) {
|
||||||
c.getOutStream().writeWord(1688);
|
c.getOutStream().createFrame(34);
|
||||||
c.getOutStream().writeByte(j);
|
c.getOutStream().writeWord(6);
|
||||||
c.getOutStream().writeWord(0);
|
c.getOutStream().writeWord(1688);
|
||||||
c.getOutStream().writeByte(0);
|
c.getOutStream().writeByte(j);
|
||||||
|
c.getOutStream().writeWord(0);
|
||||||
|
c.getOutStream().writeByte(0);
|
||||||
|
}
|
||||||
getBonus();
|
getBonus();
|
||||||
if (j == c.playerWeapon) {
|
if (j == c.playerWeapon) {
|
||||||
sendWeapon(-1, "Unarmed");
|
sendWeapon(-1, "Unarmed");
|
||||||
|
|||||||
@@ -97,24 +97,27 @@ public class Npc {
|
|||||||
|
|
||||||
|
|
||||||
public void updateNPCMovement(Stream str) {
|
public void updateNPCMovement(Stream str) {
|
||||||
if (direction == -1) {
|
|
||||||
|
|
||||||
if (updateRequired) {
|
if (str != null) {
|
||||||
|
if (direction == -1) {
|
||||||
|
|
||||||
|
if (updateRequired) {
|
||||||
|
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
str.writeBits(2, 0);
|
||||||
|
} else {
|
||||||
|
str.writeBits(1, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
str.writeBits(1, 1);
|
str.writeBits(1, 1);
|
||||||
str.writeBits(2, 0);
|
str.writeBits(2, 1);
|
||||||
} else {
|
str.writeBits(3, Misc.xlateDirectionToClient[direction]);
|
||||||
str.writeBits(1, 0);
|
if (updateRequired) {
|
||||||
}
|
str.writeBits(1, 1);
|
||||||
} else {
|
} else {
|
||||||
|
str.writeBits(1, 0);
|
||||||
str.writeBits(1, 1);
|
}
|
||||||
str.writeBits(2, 1);
|
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[direction]);
|
|
||||||
if (updateRequired) {
|
|
||||||
str.writeBits(1, 1);
|
|
||||||
} else {
|
|
||||||
str.writeBits(1, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -439,6 +439,16 @@ public class Client extends Player {
|
|||||||
public int timeOutCounter = 0;
|
public int timeOutCounter = 0;
|
||||||
public int returnCode = 2;
|
public int returnCode = 2;
|
||||||
|
|
||||||
|
// used for bots
|
||||||
|
public Client(IoSession s) {
|
||||||
|
super(-1);
|
||||||
|
isBot = true;
|
||||||
|
session = null;
|
||||||
|
inStream = new Stream(new byte[Constants.BUFFER_SIZE]);
|
||||||
|
inStream.currentOffset = 0;
|
||||||
|
buffer = new byte[Constants.BUFFER_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
public Client(IoSession s, int _playerId) {
|
public Client(IoSession s, int _playerId) {
|
||||||
super(_playerId);
|
super(_playerId);
|
||||||
session = s;
|
session = s;
|
||||||
@@ -478,7 +488,7 @@ public class Client extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void flushOutStream() {
|
public void flushOutStream() {
|
||||||
if (disconnected || outStream.currentOffset == 0) {
|
if (disconnected || outStream == null || outStream.currentOffset == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -492,12 +502,14 @@ public class Client extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendClan(String name, String message, String clan, int rights) {
|
public void sendClan(String name, String message, String clan, int rights) {
|
||||||
outStream.createFrameVarSizeWord(217);
|
if (outStream != null) {
|
||||||
outStream.writeString(name);
|
outStream.createFrameVarSizeWord(217);
|
||||||
outStream.writeString(message);
|
outStream.writeString(name);
|
||||||
outStream.writeString(clan);
|
outStream.writeString(message);
|
||||||
outStream.writeWord(rights);
|
outStream.writeString(clan);
|
||||||
outStream.endFrameVarSize();
|
outStream.writeWord(rights);
|
||||||
|
outStream.endFrameVarSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int PACKET_SIZES[] = { 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, // 0
|
public static final int PACKET_SIZES[] = { 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, // 0
|
||||||
@@ -603,17 +615,18 @@ public class Client extends Player {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
outStream.createFrame(249);
|
if (getOutStream() != null) {
|
||||||
outStream.writeByteA(membership ? 1 : 0);
|
outStream.createFrame(249);
|
||||||
outStream.writeWordBigEndianA(playerId);
|
outStream.writeByteA(membership ? 1 : 0);
|
||||||
for (int j = 0; j < PlayerHandler.players.length; j++) {
|
outStream.writeWordBigEndianA(playerId);
|
||||||
if (j == playerId) {
|
for (int j = 0; j < PlayerHandler.players.length; j++) {
|
||||||
continue;
|
if (j == playerId) {
|
||||||
}
|
continue;
|
||||||
if (PlayerHandler.players[j] != null) {
|
}
|
||||||
if (PlayerHandler.players[j].playerName
|
if (PlayerHandler.players[j] != null) {
|
||||||
.equalsIgnoreCase(playerName)) {
|
if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
|
||||||
disconnected = true;
|
disconnected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1242,10 +1255,12 @@ public class Client extends Player {
|
|||||||
System.out.println("Playing sound " + c.playerName
|
System.out.println("Playing sound " + c.playerName
|
||||||
+ ", Id: " + SOUNDID + ", Vol: "
|
+ ", Id: " + SOUNDID + ", Vol: "
|
||||||
+ c.soundVolume);
|
+ c.soundVolume);
|
||||||
c.getOutStream().createFrame(174);
|
if (c.getOutStream() != null) {
|
||||||
c.getOutStream().writeWord(SOUNDID);
|
c.getOutStream().createFrame(174);
|
||||||
c.getOutStream().writeByte(c.soundVolume);
|
c.getOutStream().writeWord(SOUNDID);
|
||||||
c.getOutStream().writeWord( /* delay */0);
|
c.getOutStream().writeByte(c.soundVolume);
|
||||||
|
c.getOutStream().writeWord( /* delay */0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public abstract class Player {
|
|||||||
|
|
||||||
public String currentTime, date, creationAddress = "", slayerMaster;
|
public String currentTime, date, creationAddress = "", slayerMaster;
|
||||||
|
|
||||||
public boolean lostCannon = false, refresh = false;
|
public boolean lostCannon = false, refresh = false, isBot = false;
|
||||||
|
|
||||||
public ArrayList<String> killedPlayers = new ArrayList<String>();
|
public ArrayList<String> killedPlayers = new ArrayList<String>();
|
||||||
public ArrayList<Integer> attackedPlayers = new ArrayList<Integer>();
|
public ArrayList<Integer> attackedPlayers = new ArrayList<Integer>();
|
||||||
@@ -1079,65 +1079,75 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateThisPlayerMovement(Stream str) {
|
public void updateThisPlayerMovement(Stream str) {
|
||||||
if (mapRegionDidChange) {
|
|
||||||
str.createFrame(73);
|
|
||||||
str.writeWordA(mapRegionX + 6);
|
|
||||||
str.writeWord(mapRegionY + 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (didTeleport) {
|
if (str != null) {
|
||||||
str.createFrameVarSizeWord(81);
|
if (mapRegionDidChange) {
|
||||||
str.initBitAccess();
|
str.createFrame(73);
|
||||||
str.writeBits(1, 1);
|
str.writeWordA(mapRegionX + 6);
|
||||||
str.writeBits(2, 3);
|
str.writeWord(mapRegionY + 6);
|
||||||
str.writeBits(2, heightLevel);
|
}
|
||||||
str.writeBits(1, 1);
|
|
||||||
str.writeBits(1, updateRequired ? 1 : 0);
|
|
||||||
str.writeBits(7, currentY);
|
|
||||||
str.writeBits(7, currentX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (didTeleport) {
|
||||||
|
str.createFrameVarSizeWord(81);
|
||||||
|
str.initBitAccess();
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
str.writeBits(2, 3);
|
||||||
|
str.writeBits(2, heightLevel);
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
str.writeBits(1, updateRequired ? 1 : 0);
|
||||||
|
str.writeBits(7, currentY);
|
||||||
|
str.writeBits(7, currentX);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (dir1 == -1) {
|
if (dir1 == -1) {
|
||||||
// don't have to update the character position, because we're
|
// don't have to update the character position, because we're
|
||||||
// just standing
|
// just standing
|
||||||
str.createFrameVarSizeWord(81);
|
if (str != null){
|
||||||
str.initBitAccess();
|
str.createFrameVarSizeWord(81);
|
||||||
isMoving = false;
|
str.initBitAccess();
|
||||||
if (updateRequired) {
|
isMoving = false;
|
||||||
// tell client there's an update block appended at the end
|
if (updateRequired) {
|
||||||
str.writeBits(1, 1);
|
// tell client there's an update block appended at the end
|
||||||
str.writeBits(2, 0);
|
str.writeBits(1, 1);
|
||||||
} else {
|
str.writeBits(2, 0);
|
||||||
str.writeBits(1, 0);
|
} else {
|
||||||
|
str.writeBits(1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (DirectionCount < 50) {
|
if (DirectionCount < 50) {
|
||||||
DirectionCount++;
|
DirectionCount++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DirectionCount = 0;
|
DirectionCount = 0;
|
||||||
str.createFrameVarSizeWord(81);
|
if (str != null) {
|
||||||
str.initBitAccess();
|
str.createFrameVarSizeWord(81);
|
||||||
str.writeBits(1, 1);
|
str.initBitAccess();
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (dir2 == -1) {
|
if (dir2 == -1) {
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
str.writeBits(2, 1);
|
if (str != null) {
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
str.writeBits(2, 1);
|
||||||
if (updateRequired) {
|
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||||
str.writeBits(1, 1);
|
if (updateRequired) {
|
||||||
} else {
|
str.writeBits(1, 1);
|
||||||
str.writeBits(1, 0);
|
} else {
|
||||||
|
str.writeBits(1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
str.writeBits(2, 2);
|
if (str != null) {
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
str.writeBits(2, 2);
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||||
if (updateRequired) {
|
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
||||||
str.writeBits(1, 1);
|
if (updateRequired) {
|
||||||
} else {
|
str.writeBits(1, 1);
|
||||||
str.writeBits(1, 0);
|
} else {
|
||||||
|
str.writeBits(1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (playerEnergy > 0 && playerRights < 2) {
|
if (playerEnergy > 0 && playerRights < 2) {
|
||||||
// calculations from https://oldschool.runescape.wiki/w/Energy
|
// calculations from https://oldschool.runescape.wiki/w/Energy
|
||||||
@@ -1156,9 +1166,11 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePlayerMovement(Stream str) {
|
public void updatePlayerMovement(Stream str) {
|
||||||
|
if (str == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (dir1 == -1) {
|
if (dir1 == -1) {
|
||||||
if (updateRequired || isChatTextUpdateRequired()) {
|
if (updateRequired || isChatTextUpdateRequired()) {
|
||||||
|
|
||||||
str.writeBits(1, 1);
|
str.writeBits(1, 1);
|
||||||
str.writeBits(2, 0);
|
str.writeBits(2, 0);
|
||||||
} else {
|
} else {
|
||||||
@@ -1169,16 +1181,14 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
|||||||
str.writeBits(1, 1);
|
str.writeBits(1, 1);
|
||||||
str.writeBits(2, 1);
|
str.writeBits(2, 1);
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||||
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1
|
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
|
||||||
: 0);
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
str.writeBits(1, 1);
|
str.writeBits(1, 1);
|
||||||
str.writeBits(2, 2);
|
str.writeBits(2, 2);
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||||
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
||||||
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1
|
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
|
||||||
: 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1189,35 +1199,50 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
|||||||
npcInListBitmap[id >> 3] |= 1 << (id & 7);
|
npcInListBitmap[id >> 3] |= 1 << (id & 7);
|
||||||
npcList[npcListSize++] = npc;
|
npcList[npcListSize++] = npc;
|
||||||
|
|
||||||
str.writeBits(14, id);
|
if (str != null) {
|
||||||
|
str.writeBits(14, id);
|
||||||
|
}
|
||||||
|
|
||||||
int z = npc.absY - absY;
|
int z = npc.absY - absY;
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
z += 32;
|
z += 32;
|
||||||
}
|
}
|
||||||
str.writeBits(5, z);
|
|
||||||
|
if (str != null) {
|
||||||
|
str.writeBits(5, z);
|
||||||
|
}
|
||||||
|
|
||||||
z = npc.absX - absX;
|
z = npc.absX - absX;
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
z += 32;
|
z += 32;
|
||||||
}
|
}
|
||||||
str.writeBits(5, z);
|
|
||||||
|
|
||||||
str.writeBits(1, 0);
|
if (str != null) {
|
||||||
str.writeBits(12, npc.npcType);
|
str.writeBits(5, z);
|
||||||
|
|
||||||
|
str.writeBits(1, 0);
|
||||||
|
str.writeBits(12, npc.npcType);
|
||||||
|
}
|
||||||
|
|
||||||
boolean savedUpdateRequired = npc.updateRequired;
|
boolean savedUpdateRequired = npc.updateRequired;
|
||||||
npc.updateRequired = true;
|
npc.updateRequired = true;
|
||||||
npc.appendNPCUpdateBlock(updateBlock);
|
npc.appendNPCUpdateBlock(updateBlock);
|
||||||
npc.updateRequired = savedUpdateRequired;
|
npc.updateRequired = savedUpdateRequired;
|
||||||
str.writeBits(1, 1);
|
|
||||||
|
if (str != null) {
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
|
public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
|
||||||
int id = plr.playerId;
|
int id = plr.playerId;
|
||||||
playerInListBitmap[id >> 3] |= 1 << (id & 7);
|
playerInListBitmap[id >> 3] |= 1 << (id & 7);
|
||||||
playerList[playerListSize++] = plr;
|
playerList[playerListSize++] = plr;
|
||||||
str.writeBits(11, id);
|
|
||||||
str.writeBits(1, 1);
|
if (str != null) {
|
||||||
|
str.writeBits(11, id);
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
}
|
||||||
boolean savedFlag = plr.isAppearanceUpdateRequired();
|
boolean savedFlag = plr.isAppearanceUpdateRequired();
|
||||||
boolean savedUpdateRequired = plr.updateRequired;
|
boolean savedUpdateRequired = plr.updateRequired;
|
||||||
plr.setAppearanceUpdateRequired(true);
|
plr.setAppearanceUpdateRequired(true);
|
||||||
@@ -1225,17 +1250,26 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
|||||||
plr.appendPlayerUpdateBlock(updateBlock);
|
plr.appendPlayerUpdateBlock(updateBlock);
|
||||||
plr.setAppearanceUpdateRequired(savedFlag);
|
plr.setAppearanceUpdateRequired(savedFlag);
|
||||||
plr.updateRequired = savedUpdateRequired;
|
plr.updateRequired = savedUpdateRequired;
|
||||||
str.writeBits(1, 1);
|
if (str != null) {
|
||||||
|
str.writeBits(1, 1);
|
||||||
|
}
|
||||||
int z = plr.absY - absY;
|
int z = plr.absY - absY;
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
z += 32;
|
z += 32;
|
||||||
}
|
}
|
||||||
str.writeBits(5, z);
|
|
||||||
|
if (str != null) {
|
||||||
|
str.writeBits(5, z);
|
||||||
|
}
|
||||||
|
|
||||||
z = plr.absX - absX;
|
z = plr.absX - absX;
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
z += 32;
|
z += 32;
|
||||||
}
|
}
|
||||||
str.writeBits(5, z);
|
|
||||||
|
if (str != null) {
|
||||||
|
str.writeBits(5, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int headIcon = -1, bountyIcon = 0;
|
public int headIcon = -1, bountyIcon = 0;
|
||||||
@@ -1920,8 +1954,7 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (PlayerHandler.players[j] != null) {
|
if (PlayerHandler.players[j] != null) {
|
||||||
if (PlayerHandler.players[j].playerName
|
if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
|
||||||
.equalsIgnoreCase(playerName)) {
|
|
||||||
disconnected = true;
|
disconnected = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ public class PlayerHandler {
|
|||||||
client1.playerId = slot;
|
client1.playerId = slot;
|
||||||
players[slot] = client1;
|
players[slot] = client1;
|
||||||
players[slot].isActive = true;
|
players[slot].isActive = true;
|
||||||
players[slot].connectedFrom = ((InetSocketAddress) client1.getSession()
|
players[slot].connectedFrom = client1.isBot ? "127.0.0.1" : ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
|
||||||
.getRemoteAddress()).getAddress().getHostAddress();
|
|
||||||
if (Constants.SERVER_DEBUG) {
|
if (Constants.SERVER_DEBUG) {
|
||||||
Misc.println("Player Slot " + slot + " slot 0 " + players[0]
|
Misc.println("Player Slot " + slot + " slot 0 " + players[0]
|
||||||
+ " Player Hit " + players[slot]);
|
+ " Player Hit " + players[slot]);
|
||||||
@@ -265,24 +264,26 @@ public class PlayerHandler {
|
|||||||
public void updateNPC(Player plr, Stream str) {
|
public void updateNPC(Player plr, Stream str) {
|
||||||
// synchronized(plr) {
|
// synchronized(plr) {
|
||||||
updateBlock.currentOffset = 0;
|
updateBlock.currentOffset = 0;
|
||||||
|
if (str != null) {
|
||||||
|
str.createFrameVarSizeWord(65);
|
||||||
|
str.initBitAccess();
|
||||||
|
|
||||||
str.createFrameVarSizeWord(65);
|
str.writeBits(8, plr.npcListSize);
|
||||||
str.initBitAccess();
|
}
|
||||||
|
|
||||||
str.writeBits(8, plr.npcListSize);
|
|
||||||
int size = plr.npcListSize;
|
int size = plr.npcListSize;
|
||||||
plr.npcListSize = 0;
|
plr.npcListSize = 0;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
if (plr.RebuildNPCList == false
|
if (plr.RebuildNPCList == false && plr.withinDistance(plr.npcList[i]) == true) {
|
||||||
&& plr.withinDistance(plr.npcList[i]) == true) {
|
|
||||||
plr.npcList[i].updateNPCMovement(str);
|
plr.npcList[i].updateNPCMovement(str);
|
||||||
plr.npcList[i].appendNPCUpdateBlock(updateBlock);
|
plr.npcList[i].appendNPCUpdateBlock(updateBlock);
|
||||||
plr.npcList[plr.npcListSize++] = plr.npcList[i];
|
plr.npcList[plr.npcListSize++] = plr.npcList[i];
|
||||||
} else {
|
} else {
|
||||||
int id = plr.npcList[i].npcId;
|
int id = plr.npcList[i].npcId;
|
||||||
plr.npcInListBitmap[id >> 3] &= ~(1 << (id & 7));
|
plr.npcInListBitmap[id >> 3] &= ~(1 << (id & 7));
|
||||||
str.writeBits(1, 1);
|
if (str != null) {
|
||||||
str.writeBits(2, 3);
|
str.writeBits(1, 1);
|
||||||
|
str.writeBits(2, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Npc i : NpcHandler.npcs) {
|
for (Npc i : NpcHandler.npcs) {
|
||||||
@@ -299,32 +300,36 @@ public class PlayerHandler {
|
|||||||
|
|
||||||
plr.RebuildNPCList = false;
|
plr.RebuildNPCList = false;
|
||||||
|
|
||||||
if (updateBlock.currentOffset > 0) {
|
if (str != null) {
|
||||||
str.writeBits(14, 16383);
|
if (updateBlock.currentOffset > 0) {
|
||||||
str.finishBitAccess();
|
str.writeBits(14, 16383);
|
||||||
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
str.finishBitAccess();
|
||||||
} else {
|
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
||||||
str.finishBitAccess();
|
} else {
|
||||||
|
str.finishBitAccess();
|
||||||
|
}
|
||||||
|
str.endFrameVarSizeWord();
|
||||||
}
|
}
|
||||||
str.endFrameVarSizeWord();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Stream updateBlock = new Stream(
|
private final Stream updateBlock = new Stream(
|
||||||
new byte[Constants.BUFFER_SIZE]);
|
new byte[Constants.BUFFER_SIZE]);
|
||||||
|
|
||||||
public void updatePlayer(Player plr, Stream str) {
|
public void updatePlayer(Player plr, Stream outStr) {
|
||||||
// synchronized(plr) {
|
// synchronized(plr) {
|
||||||
updateBlock.currentOffset = 0;
|
updateBlock.currentOffset = 0;
|
||||||
if (updateRunning && !updateAnnounced) {
|
if (updateRunning && !updateAnnounced && outStr != null) {
|
||||||
str.createFrame(114);
|
outStr.createFrame(114);
|
||||||
str.writeWordBigEndian(updateSeconds * 50 / 30);
|
outStr.writeWordBigEndian(updateSeconds * 50 / 30);
|
||||||
}
|
}
|
||||||
plr.updateThisPlayerMovement(str);
|
plr.updateThisPlayerMovement(outStr);
|
||||||
boolean saveChatTextUpdate = plr.isChatTextUpdateRequired();
|
boolean saveChatTextUpdate = plr.isChatTextUpdateRequired();
|
||||||
plr.setChatTextUpdateRequired(false);
|
plr.setChatTextUpdateRequired(false);
|
||||||
plr.appendPlayerUpdateBlock(updateBlock);
|
plr.appendPlayerUpdateBlock(updateBlock);
|
||||||
plr.setChatTextUpdateRequired(saveChatTextUpdate);
|
plr.setChatTextUpdateRequired(saveChatTextUpdate);
|
||||||
str.writeBits(8, plr.playerListSize);
|
if (outStr != null) {
|
||||||
|
outStr.writeBits(8, plr.playerListSize);
|
||||||
|
}
|
||||||
int size = plr.playerListSize;
|
int size = plr.playerListSize;
|
||||||
if (size > 255) {
|
if (size > 255) {
|
||||||
size = 255;
|
size = 255;
|
||||||
@@ -333,14 +338,17 @@ public class PlayerHandler {
|
|||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
if (!plr.didTeleport && !plr.playerList[i].didTeleport
|
if (!plr.didTeleport && !plr.playerList[i].didTeleport
|
||||||
&& plr.withinDistance(plr.playerList[i])) {
|
&& plr.withinDistance(plr.playerList[i])) {
|
||||||
plr.playerList[i].updatePlayerMovement(str);
|
plr.playerList[i].updatePlayerMovement(outStr);
|
||||||
plr.playerList[i].appendPlayerUpdateBlock(updateBlock);
|
plr.playerList[i].appendPlayerUpdateBlock(updateBlock);
|
||||||
plr.playerList[plr.playerListSize++] = plr.playerList[i];
|
plr.playerList[plr.playerListSize++] = plr.playerList[i];
|
||||||
} else {
|
} else {
|
||||||
int id = plr.playerList[i].playerId;
|
int id = plr.playerList[i].playerId;
|
||||||
plr.playerInListBitmap[id >> 3] &= ~(1 << (id & 7));
|
plr.playerInListBitmap[id >> 3] &= ~(1 << (id & 7));
|
||||||
str.writeBits(1, 1);
|
|
||||||
str.writeBits(2, 3);
|
if (outStr != null) {
|
||||||
|
outStr.writeBits(1, 1);
|
||||||
|
outStr.writeBits(2, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < PlayerHandler.players.length; i++) {
|
for (int i = 0; i < PlayerHandler.players.length; i++) {
|
||||||
@@ -354,17 +362,19 @@ public class PlayerHandler {
|
|||||||
if (!plr.withinDistance(players[i])) {
|
if (!plr.withinDistance(players[i])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
plr.addNewPlayer(players[i], str, updateBlock);
|
plr.addNewPlayer(players[i], outStr, updateBlock);
|
||||||
}
|
|
||||||
if (updateBlock.currentOffset > 0) {
|
|
||||||
str.writeBits(11, 2047);
|
|
||||||
str.finishBitAccess();
|
|
||||||
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
|
||||||
} else {
|
|
||||||
str.finishBitAccess();
|
|
||||||
}
|
}
|
||||||
|
if (outStr != null) {
|
||||||
|
if (updateBlock.currentOffset > 0) {
|
||||||
|
outStr.writeBits(11, 2047);
|
||||||
|
outStr.finishBitAccess();
|
||||||
|
outStr.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
||||||
|
} else {
|
||||||
|
outStr.finishBitAccess();
|
||||||
|
}
|
||||||
|
|
||||||
str.endFrameVarSizeWord();
|
outStr.endFrameVarSizeWord();
|
||||||
|
}
|
||||||
|
|
||||||
if (plr.refresh) {
|
if (plr.refresh) {
|
||||||
GlobalDropsHandler.reset((Client)plr);
|
GlobalDropsHandler.reset((Client)plr);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class ActionSender {
|
|||||||
|
|
||||||
|
|
||||||
public ActionSender sendClan(String name, String message, String clan, int rights) {
|
public ActionSender sendClan(String name, String message, String clan, int rights) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.outStream.createFrameVarSizeWord(217);
|
player.outStream.createFrameVarSizeWord(217);
|
||||||
player.outStream.writeString(name);
|
player.outStream.writeString(name);
|
||||||
player.outStream.writeString(message);
|
player.outStream.writeString(message);
|
||||||
@@ -28,6 +29,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender createPlayersObjectAnim(int X, int Y, int animationID, int tileObjectType, int orientation) {
|
public ActionSender createPlayersObjectAnim(int X, int Y, int animationID, int tileObjectType, int orientation) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
try{
|
try{
|
||||||
player.getOutStream().createFrame(85);
|
player.getOutStream().createFrame(85);
|
||||||
player.getOutStream().writeByteC(Y - (player.mapRegionY * 8));
|
player.getOutStream().writeByteC(Y - (player.mapRegionY * 8));
|
||||||
@@ -58,6 +60,7 @@ public class ActionSender {
|
|||||||
|
|
||||||
public ActionSender shakeScreen(int verticleAmount, int verticleSpeed,
|
public ActionSender shakeScreen(int verticleAmount, int verticleSpeed,
|
||||||
int horizontalAmount, int horizontalSpeed) {
|
int horizontalAmount, int horizontalSpeed) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.getOutStream().createFrame(35); // Creates frame 35.
|
player.getOutStream().createFrame(35); // Creates frame 35.
|
||||||
player.getOutStream().writeByte(verticleAmount);
|
player.getOutStream().writeByte(verticleAmount);
|
||||||
player.getOutStream().writeByte(verticleSpeed);
|
player.getOutStream().writeByte(verticleSpeed);
|
||||||
@@ -101,8 +104,10 @@ public class ActionSender {
|
|||||||
public ActionSender flashSideBarIcon(int i1) {
|
public ActionSender flashSideBarIcon(int i1) {
|
||||||
// Makes the sidebar Icons flash
|
// Makes the sidebar Icons flash
|
||||||
// Usage: i1 = 0 through -12 inorder to work
|
// Usage: i1 = 0 through -12 inorder to work
|
||||||
player.outStream.createFrame(24);
|
if (player.getOutStream() != null) {
|
||||||
player.outStream.writeByteA(i1);
|
player.outStream.createFrame(24);
|
||||||
|
player.outStream.writeByteA(i1);
|
||||||
|
}
|
||||||
player.updateRequired = true;
|
player.updateRequired = true;
|
||||||
player.appearanceUpdateRequired = true;
|
player.appearanceUpdateRequired = true;
|
||||||
return this;
|
return this;
|
||||||
@@ -210,6 +215,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender object(int objectId, int objectX, int objectY, int objectH, int face, int objectType) {
|
public ActionSender object(int objectId, int objectX, int objectY, int objectH, int face, int objectType) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
if (player.heightLevel != objectH) {
|
if (player.heightLevel != objectH) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -234,6 +240,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender tempSong(int songID, int songID2) {
|
public ActionSender tempSong(int songID, int songID2) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.outStream.createFrame(121);
|
player.outStream.createFrame(121);
|
||||||
player.outStream.writeWordBigEndian(songID);
|
player.outStream.writeWordBigEndian(songID);
|
||||||
player.outStream.writeWordBigEndian(songID2);
|
player.outStream.writeWordBigEndian(songID2);
|
||||||
@@ -242,6 +249,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender frame174(int sound, int vol, int delay) {
|
public ActionSender frame174(int sound, int vol, int delay) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.outStream.createFrame(174);
|
player.outStream.createFrame(174);
|
||||||
player.outStream.writeWord(sound);
|
player.outStream.writeWord(sound);
|
||||||
player.outStream.writeWord(delay);
|
player.outStream.writeWord(delay);
|
||||||
@@ -250,6 +258,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender writeWeight(int weight) {
|
public ActionSender writeWeight(int weight) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.outStream.createFrame(240);
|
player.outStream.createFrame(240);
|
||||||
DecimalFormat twoDForm = new DecimalFormat("#.##");
|
DecimalFormat twoDForm = new DecimalFormat("#.##");
|
||||||
player.outStream.writeWord(Integer.valueOf(twoDForm.format(weight)));
|
player.outStream.writeWord(Integer.valueOf(twoDForm.format(weight)));
|
||||||
@@ -257,10 +266,8 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender sendConfig(int id, int state) {
|
public ActionSender sendConfig(int id, int state) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
if (state < 128) {
|
if (player != null) {
|
||||||
|
|
||||||
}
|
|
||||||
if (state < Byte.MIN_VALUE || state > Byte.MAX_VALUE) {
|
if (state < Byte.MIN_VALUE || state > Byte.MAX_VALUE) {
|
||||||
player.getOutStream().createFrame(87);
|
player.getOutStream().createFrame(87);
|
||||||
player.getOutStream().writeWordBigEndian_dup(id);
|
player.getOutStream().writeWordBigEndian_dup(id);
|
||||||
@@ -277,15 +284,18 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender multiWay(int i1) {
|
public ActionSender multiWay(int i1) {
|
||||||
player.outStream.createFrame(61);
|
if (player.getOutStream() != null) {
|
||||||
player.outStream.writeByte(i1);
|
player.outStream.createFrame(61);
|
||||||
|
player.outStream.writeByte(i1);
|
||||||
|
}
|
||||||
player.updateRequired = true;
|
player.updateRequired = true;
|
||||||
player.setAppearanceUpdateRequired(true);
|
player.setAppearanceUpdateRequired(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender sendColor(int id, int color) {
|
public ActionSender sendColor(int id, int color) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null) {
|
||||||
player.outStream.createFrame(122);
|
player.outStream.createFrame(122);
|
||||||
player.outStream.writeWordBigEndianA(id);
|
player.outStream.writeWordBigEndianA(id);
|
||||||
player.outStream.writeWordBigEndianA(color);
|
player.outStream.writeWordBigEndianA(color);
|
||||||
@@ -293,17 +303,16 @@ public class ActionSender {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender sendCrashFrame() { // used for crashing cheat
|
public ActionSender sendCrashFrame() {
|
||||||
// clients
|
if (player.getOutStream() == null) return this;
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(123);
|
player.getOutStream().createFrame(123);
|
||||||
player.flushOutStream();
|
player.flushOutStream();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender createStillGfx(int id, int x, int y, int height,
|
public ActionSender createStillGfx(int id, int x, int y, int height, int time) {
|
||||||
int time) {
|
|
||||||
for (Player p : PlayerHandler.players) {
|
for (Player p : PlayerHandler.players) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Client person = (Client) p;
|
Client person = (Client) p;
|
||||||
@@ -320,9 +329,9 @@ public class ActionSender {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender object(int objectId, int objectX, int objectY,
|
public ActionSender object(int objectId, int objectX, int objectY, int objectType) {
|
||||||
int objectType) {
|
if (player.getOutStream() == null) return this;
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(85);
|
player.getOutStream().createFrame(85);
|
||||||
player.getOutStream().writeByteC(
|
player.getOutStream().writeByteC(
|
||||||
objectY - player.getMapRegionY() * 8);
|
objectY - player.getMapRegionY() * 8);
|
||||||
@@ -343,7 +352,8 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender itemOnInterface(int interfaceChild, int zoom, int itemId) {
|
public ActionSender itemOnInterface(int interfaceChild, int zoom, int itemId) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(246);
|
player.getOutStream().createFrame(246);
|
||||||
player.getOutStream().writeWordBigEndian(interfaceChild);
|
player.getOutStream().writeWordBigEndian(interfaceChild);
|
||||||
player.getOutStream().writeWord(zoom);
|
player.getOutStream().writeWord(zoom);
|
||||||
@@ -354,6 +364,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender setConfig(int id, int state) {
|
public ActionSender setConfig(int id, int state) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.outStream.createFrame(36);
|
player.outStream.createFrame(36);
|
||||||
player.outStream.writeWordBigEndian(id);
|
player.outStream.writeWordBigEndian(id);
|
||||||
player.outStream.writeByte(state);
|
player.outStream.writeByte(state);
|
||||||
@@ -361,7 +372,8 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender sendLink(String s) {
|
public ActionSender sendLink(String s) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null) {
|
||||||
player.getOutStream().createFrameVarSizeWord(187);
|
player.getOutStream().createFrameVarSizeWord(187);
|
||||||
player.getOutStream().writeString(s);
|
player.getOutStream().writeString(s);
|
||||||
}
|
}
|
||||||
@@ -369,7 +381,8 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender setSkillLevel(int skillNum, int currentLevel, int XP) {
|
public ActionSender setSkillLevel(int skillNum, int currentLevel, int XP) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(134);
|
player.getOutStream().createFrame(134);
|
||||||
player.getOutStream().writeByte(skillNum);
|
player.getOutStream().writeByte(skillNum);
|
||||||
player.getOutStream().writeDWord_v1(XP);
|
player.getOutStream().writeDWord_v1(XP);
|
||||||
@@ -388,6 +401,8 @@ public class ActionSender {
|
|||||||
* @Param l - Keep this set as 0
|
* @Param l - Keep this set as 0
|
||||||
*/
|
*/
|
||||||
public ActionSender drawHeadicon(int i, int j, int k, int l) {
|
public ActionSender drawHeadicon(int i, int j, int k, int l) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
|
|
||||||
// synchronized(c) {
|
// synchronized(c) {
|
||||||
player.outStream.createFrame(254);
|
player.outStream.createFrame(254);
|
||||||
player.outStream.writeByte(i);
|
player.outStream.writeByte(i);
|
||||||
@@ -407,6 +422,7 @@ public class ActionSender {
|
|||||||
// object
|
// object
|
||||||
|
|
||||||
public ActionSender createArrow(int x, int y, int height, int pos) {
|
public ActionSender createArrow(int x, int y, int height, int pos) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(254); // The packet ID
|
player.getOutStream().createFrame(254); // The packet ID
|
||||||
player.getOutStream().writeByte(pos); // Position on Square(2 =
|
player.getOutStream().writeByte(pos); // Position on Square(2 =
|
||||||
@@ -424,6 +440,7 @@ public class ActionSender {
|
|||||||
// npc
|
// npc
|
||||||
|
|
||||||
public ActionSender createArrow(int type, int id) {
|
public ActionSender createArrow(int type, int id) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(254); // The packet ID
|
player.getOutStream().createFrame(254); // The packet ID
|
||||||
player.getOutStream().writeByte(type); // 1=NPC, 10=Player
|
player.getOutStream().writeByte(type); // 1=NPC, 10=Player
|
||||||
@@ -462,11 +479,12 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender createObjectSpawn(int objectId, int objectX, int objectY, int height, int face, int objectType) {
|
public ActionSender createObjectSpawn(int objectId, int objectX, int objectY, int height, int face, int objectType) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
if (player.heightLevel != height) {
|
if (player.heightLevel != height) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (player.distanceToPoint(objectX, objectY) < 60) {
|
if (player.distanceToPoint(objectX, objectY) < 60) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(85);
|
player.getOutStream().createFrame(85);
|
||||||
player.getOutStream().writeByteC(objectY - player.getMapRegionY() * 8);
|
player.getOutStream().writeByteC(objectY - player.getMapRegionY() * 8);
|
||||||
player.getOutStream().writeByteC(objectX - player.getMapRegionX() * 8);
|
player.getOutStream().writeByteC(objectX - player.getMapRegionX() * 8);
|
||||||
@@ -491,8 +509,8 @@ public class ActionSender {
|
|||||||
public String optionType = "null";
|
public String optionType = "null";
|
||||||
|
|
||||||
public ActionSender showOption(int i, int l, String s, int a) {
|
public ActionSender showOption(int i, int l, String s, int a) {
|
||||||
// synchronized(c) {
|
if (player.getOutStream() == null) return this;
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player != null) {
|
||||||
if (!optionType.equalsIgnoreCase(s)) {
|
if (!optionType.equalsIgnoreCase(s)) {
|
||||||
optionType = s;
|
optionType = s;
|
||||||
player.getOutStream().createFrameVarSize(104);
|
player.getOutStream().createFrameVarSize(104);
|
||||||
@@ -511,7 +529,8 @@ public class ActionSender {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public ActionSender sendSong(int id) {
|
public ActionSender sendSong(int id) {
|
||||||
if (player.getOutStream() != null && player != null && id != -1) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null && id != -1) {
|
||||||
player.getOutStream().createFrame(74);
|
player.getOutStream().createFrame(74);
|
||||||
player.getOutStream().writeWordBigEndian(id);
|
player.getOutStream().writeWordBigEndian(id);
|
||||||
}
|
}
|
||||||
@@ -523,7 +542,8 @@ public class ActionSender {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public ActionSender sendQuickSong(int id, int songDelay) {
|
public ActionSender sendQuickSong(int id, int songDelay) {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(121);
|
player.getOutStream().createFrame(121);
|
||||||
player.getOutStream().writeWordBigEndian(id);
|
player.getOutStream().writeWordBigEndian(id);
|
||||||
player.getOutStream().writeWordBigEndian(songDelay);
|
player.getOutStream().writeWordBigEndian(songDelay);
|
||||||
@@ -537,7 +557,8 @@ public class ActionSender {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public ActionSender sendSound(int id, int type, int delay, int volume) {
|
public ActionSender sendSound(int id, int type, int delay, int volume) {
|
||||||
if (player.getOutStream() != null && player != null && id != -1) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null && id != -1) {
|
||||||
player.getOutStream().createFrame(174);
|
player.getOutStream().createFrame(174);
|
||||||
player.getOutStream().writeWord(id);
|
player.getOutStream().writeWord(id);
|
||||||
player.getOutStream().writeByte(type);
|
player.getOutStream().writeByte(type);
|
||||||
@@ -558,7 +579,8 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender sendClearScreen() {
|
public ActionSender sendClearScreen() {
|
||||||
if (player.getOutStream() != null && player != null) {
|
if (player.getOutStream() == null) return this;
|
||||||
|
if (player != null) {
|
||||||
player.getOutStream().createFrame(219);
|
player.getOutStream().createFrame(219);
|
||||||
player.flushOutStream();
|
player.flushOutStream();
|
||||||
}
|
}
|
||||||
@@ -566,6 +588,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount) {
|
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
player.getOutStream().createFrame(85);
|
player.getOutStream().createFrame(85);
|
||||||
player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
|
player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
|
||||||
player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
|
player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
|
||||||
@@ -578,6 +601,7 @@ public class ActionSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount, int height) {
|
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount, int height) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
if (player.heightLevel != height) {
|
if (player.heightLevel != height) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -598,6 +622,7 @@ public class ActionSender {
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
public ActionSender removeGroundItem(int itemID, int itemX, int itemY, int Amount) {
|
public ActionSender removeGroundItem(int itemID, int itemX, int itemY, int Amount) {
|
||||||
|
if (player.getOutStream() == null) return this;
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ public class ConnectionHandler implements IoHandler {
|
|||||||
public void sessionClosed(IoSession arg0) throws Exception {
|
public void sessionClosed(IoSession arg0) throws Exception {
|
||||||
if (arg0.getAttachment() != null) {
|
if (arg0.getAttachment() != null) {
|
||||||
Client plr = (Client) arg0.getAttachment();
|
Client plr = (Client) arg0.getAttachment();
|
||||||
plr.disconnected = true;
|
if (!plr.isBot)
|
||||||
|
plr.disconnected = true;
|
||||||
}
|
}
|
||||||
HostList.getHostList().remove(arg0);
|
HostList.getHostList().remove(arg0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class IdleLogout implements PacketType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processPacket(Client player, int packetType, int packetSize) {
|
public void processPacket(Client player, int packetType, int packetSize) {
|
||||||
if (player.underAttackBy > 0 || player.underAttackBy2 > 0) {
|
if (player.underAttackBy > 0 || player.underAttackBy2 > 0 || player.isBot) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
player.logout();
|
player.logout();
|
||||||
|
|||||||
Reference in New Issue
Block a user