From 2b976a804107eac4ff26d3e66efad99dd71ce2f4 Mon Sep 17 00:00:00 2001 From: CodeForFame Date: Thu, 21 Jul 2011 15:14:52 -0500 Subject: [PATCH] Players are now destroyed once they hit the threshold (fixed an off by one bug). --- GameServer/src/org/moparscape/msc/config/Formulae.java | 6 ++++++ GameServer/src/org/moparscape/msc/gs/model/Player.java | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/GameServer/src/org/moparscape/msc/config/Formulae.java b/GameServer/src/org/moparscape/msc/config/Formulae.java index 5720514..747e942 100644 --- a/GameServer/src/org/moparscape/msc/config/Formulae.java +++ b/GameServer/src/org/moparscape/msc/config/Formulae.java @@ -79,6 +79,12 @@ public class Formulae { private static Random r = new Random(); public static final int[] runeIDs = { 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 46, 619, 825 }; + /** + * Safe packets:
+ * PlayerAppearanceUpdater
+ * FollowRequest
+ * InvUseOnItem
+ */ public static final int[] safePacketIDs = { 70, 123, 128, 255 }; public static final String[] statArray = { "attack", "defense", "strength", "hits", "ranged", "prayer", "magic", "cooking", "woodcut", diff --git a/GameServer/src/org/moparscape/msc/gs/model/Player.java b/GameServer/src/org/moparscape/msc/gs/model/Player.java index 42e6ff2..8697ece 100644 --- a/GameServer/src/org/moparscape/msc/gs/model/Player.java +++ b/GameServer/src/org/moparscape/msc/gs/model/Player.java @@ -584,6 +584,12 @@ public final class Player extends Mob { } } + /** + * This method acts as a throttle for packets, and adds them to a list.
+ * If the player sends more than 20 packets per second they're disconnected (60 packets per 3000ms) + * + * @param p - the packet to add... + */ public void addPacket(RSCPacket p) { long now = GameEngine.getTime(); if (now - lastCount > 3000) { @@ -591,7 +597,7 @@ public final class Player extends Mob { packetCount = 0; } if (!DataConversions.inArray(Formulae.safePacketIDs, p.getID()) - && packetCount++ >= 60) { + && ++packetCount >= 60) { destroy(false); } if (lastPackets.size() >= 60) {