mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-05 16:49:06 +00:00
Cleanup part 1 (#213)
* Clean up part 1 - Removed lots of dead code - Removed unncessary files not in use - Cleaned up small bits of code - Removed a few warnings - Server.java ---> GameEngine.java - Constants.java ---> GameConstants.java * Cape Dye Rewrote cape dying * Packaging - redone ----> com.rebotted * PacketSender/clean up - ActionSender ---> PacketSender - Moved many more packets to packetsender - Cleaned up more dead code * Merge Client/Player - Merged Client.java with Player.java (both were doing same thing so redundant to have both) - Removed some more dead code - Tidy a few small things up * Quests/more clean up - Removed more dead code - Made quests static in order to clean them up a bit * More cleanup - Removed some more of the dead quest code - Correcting naming of some of the shop variables
This commit is contained in:
committed by
Daniel Ginovker
parent
3d1ae1b288
commit
d876a923b9
@@ -0,0 +1,175 @@
|
||||
package com.rebotted.net.packets;
|
||||
|
||||
import com.rebotted.GameConstants;
|
||||
import com.rebotted.game.dialogues.Dialogue;
|
||||
import com.rebotted.game.players.Client;
|
||||
import com.rebotted.game.players.Player;
|
||||
import com.rebotted.net.packets.impl.AttackPlayer;
|
||||
import com.rebotted.net.packets.impl.Bank10;
|
||||
import com.rebotted.net.packets.impl.Bank5;
|
||||
import com.rebotted.net.packets.impl.BankAll;
|
||||
import com.rebotted.net.packets.impl.BankX1;
|
||||
import com.rebotted.net.packets.impl.BankX2;
|
||||
import com.rebotted.net.packets.impl.ChallengePlayer;
|
||||
import com.rebotted.net.packets.impl.ChangeAppearance;
|
||||
import com.rebotted.net.packets.impl.ChangeRegions;
|
||||
import com.rebotted.net.packets.impl.Chat;
|
||||
import com.rebotted.net.packets.impl.ClickItem;
|
||||
import com.rebotted.net.packets.impl.ClickNPC;
|
||||
import com.rebotted.net.packets.impl.ClickObject;
|
||||
import com.rebotted.net.packets.impl.ClickTab;
|
||||
import com.rebotted.net.packets.impl.ClickingButtons;
|
||||
import com.rebotted.net.packets.impl.ClickingInGame;
|
||||
import com.rebotted.net.packets.impl.ClickingStuff;
|
||||
import com.rebotted.net.packets.impl.Commands;
|
||||
import com.rebotted.net.packets.impl.DropItem;
|
||||
import com.rebotted.net.packets.impl.FollowPlayer;
|
||||
import com.rebotted.net.packets.impl.IdleLogout;
|
||||
import com.rebotted.net.packets.impl.ItemClick2;
|
||||
import com.rebotted.net.packets.impl.ItemClick2OnGroundItem;
|
||||
import com.rebotted.net.packets.impl.ItemClick3;
|
||||
import com.rebotted.net.packets.impl.ItemOnGroundItem;
|
||||
import com.rebotted.net.packets.impl.ItemOnItem;
|
||||
import com.rebotted.net.packets.impl.ItemOnNpc;
|
||||
import com.rebotted.net.packets.impl.ItemOnObject;
|
||||
import com.rebotted.net.packets.impl.ItemOnPlayer;
|
||||
import com.rebotted.net.packets.impl.MagicOnFloorItems;
|
||||
import com.rebotted.net.packets.impl.MagicOnItems;
|
||||
import com.rebotted.net.packets.impl.MoveItems;
|
||||
import com.rebotted.net.packets.impl.PickupItem;
|
||||
import com.rebotted.net.packets.impl.PrivateMessaging;
|
||||
import com.rebotted.net.packets.impl.RemoveItem;
|
||||
import com.rebotted.net.packets.impl.Report;
|
||||
import com.rebotted.net.packets.impl.SilentPacket;
|
||||
import com.rebotted.net.packets.impl.Trade;
|
||||
import com.rebotted.net.packets.impl.Walking;
|
||||
import com.rebotted.net.packets.impl.WearItem;
|
||||
|
||||
public class PacketHandler {
|
||||
|
||||
private static PacketType packetId[] = new PacketType[256];
|
||||
|
||||
static {
|
||||
|
||||
SilentPacket u = new SilentPacket();
|
||||
packetId[3] = u;
|
||||
packetId[202] = u;
|
||||
packetId[77] = u;
|
||||
packetId[86] = u;
|
||||
packetId[78] = u;
|
||||
packetId[36] = u;
|
||||
packetId[226] = u;
|
||||
packetId[246] = u;
|
||||
packetId[148] = u;
|
||||
packetId[183] = u;
|
||||
packetId[230] = u;
|
||||
packetId[136] = u;
|
||||
packetId[189] = u;
|
||||
packetId[152] = u;
|
||||
packetId[200] = u;
|
||||
packetId[85] = u;
|
||||
packetId[165] = u;
|
||||
packetId[238] = u;
|
||||
packetId[150] = u;
|
||||
packetId[120] = new ClickTab();
|
||||
packetId[14] = new ItemOnPlayer();
|
||||
packetId[40] = new Dialogue();
|
||||
ClickObject co = new ClickObject();
|
||||
packetId[132] = co;
|
||||
packetId[252] = co;
|
||||
packetId[70] = co;
|
||||
packetId[234] = co;
|
||||
packetId[57] = new ItemOnNpc();
|
||||
ClickNPC cn = new ClickNPC();
|
||||
packetId[72] = cn;
|
||||
packetId[131] = cn;
|
||||
packetId[155] = cn;
|
||||
packetId[17] = cn;
|
||||
packetId[21] = cn;
|
||||
packetId[218] = new Report();
|
||||
packetId[16] = new ItemClick2();
|
||||
packetId[75] = new ItemClick3();
|
||||
packetId[122] = new ClickItem();
|
||||
packetId[241] = new ClickingInGame();
|
||||
packetId[4] = new Chat();
|
||||
packetId[236] = new PickupItem();
|
||||
packetId[87] = new DropItem();
|
||||
packetId[185] = new ClickingButtons();
|
||||
packetId[130] = new ClickingStuff();
|
||||
packetId[103] = new Commands();
|
||||
packetId[214] = new MoveItems();
|
||||
packetId[237] = new MagicOnItems();
|
||||
packetId[181] = new MagicOnFloorItems();
|
||||
packetId[202] = new IdleLogout();
|
||||
AttackPlayer ap = new AttackPlayer();
|
||||
packetId[73] = ap;
|
||||
packetId[249] = ap;
|
||||
packetId[128] = new ChallengePlayer();
|
||||
packetId[139] = new Trade();
|
||||
packetId[39] = new FollowPlayer();
|
||||
packetId[41] = new WearItem();
|
||||
packetId[145] = new RemoveItem();
|
||||
packetId[117] = new Bank5();
|
||||
packetId[43] = new Bank10();
|
||||
packetId[129] = new BankAll();
|
||||
packetId[101] = new ChangeAppearance();
|
||||
PrivateMessaging pm = new PrivateMessaging();
|
||||
packetId[188] = pm;
|
||||
packetId[126] = pm;
|
||||
packetId[215] = pm;
|
||||
packetId[59] = pm;
|
||||
packetId[95] = pm;
|
||||
packetId[133] = pm;
|
||||
packetId[135] = new BankX1();
|
||||
packetId[208] = new BankX2();
|
||||
Walking w = new Walking();
|
||||
packetId[98] = w;
|
||||
packetId[164] = w;
|
||||
packetId[248] = w;
|
||||
packetId[53] = new ItemOnItem();
|
||||
packetId[192] = new ItemOnObject();
|
||||
packetId[25] = new ItemOnGroundItem();
|
||||
ChangeRegions cr = new ChangeRegions();
|
||||
packetId[121] = cr;
|
||||
packetId[210] = cr;
|
||||
packetId[253] = new ItemClick2OnGroundItem();
|
||||
// packetId[ContinueDialoguePacketHandler.CONTINUE] = new
|
||||
// ContinueDialoguePacketHandler();
|
||||
}
|
||||
|
||||
/*public static void processPacket(Client c, int packetType, int packetSize) {
|
||||
if (packetType == -1) {
|
||||
return;
|
||||
}
|
||||
PacketType p = packetId[packetType];
|
||||
if (p != null) {
|
||||
try {
|
||||
// System.out.println("packet: " + packetType);
|
||||
p.processPacket(c, packetType, packetSize);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("Unhandled packet type: " + packetType
|
||||
+ " - size: " + packetSize);
|
||||
}
|
||||
}*/
|
||||
|
||||
public static void processPacket(Player player, int packetType, int packetSize) {
|
||||
PacketType p = packetId[packetType];
|
||||
if(p != null && packetType > 0 && packetType < 257 && packetType == player.packetType && packetSize == player.packetSize) {
|
||||
if (GameConstants.sendServerPackets && player.playerRights == 3) {
|
||||
player.getPacketSender().sendMessage("PacketType: " + packetType + ". PacketSize: " + packetSize + ".");
|
||||
}
|
||||
try {
|
||||
p.processPacket(player, packetType, packetSize);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
player.disconnected = true;
|
||||
System.out.println(player.playerName + "is sending invalid PacketType: " + packetType + ". PacketSize: " + packetSize);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user