Exception fixes

Fixed a bug that could occasionally cause the sandwich lady interface to become unresponsive
Fixed an issue that could cause shade random events to not spawn for max-level players
Fixed an issue that could cause zombie random events to not spawn for max-level players
Fixed a widespread book issue that resulted from not resetting the current page index when closing a book, and then trying to open another book with less pages.
Converted bogrog pouch swap to the generic item select interface, and removed relevant code from the grand exchange code
Fixed an issue that could occasionally prevent exchange of item sets
Fixed an issue with Diango's reclaim interface that could result in items other than the ones you clicked being claimed
Made incubation moderately more reliable, and incubation timers now pass even while offline
Fixed an issue that prevented the leather crafting dialogue from accepting tokenized amounts (e.g. 100k)
Fixed an issue that prevented the tool leprechaun interface from allowing tokenized amounts
Fixed an issue that prevented players from using tokenized amounts in the ogleroot purchase dialogue for vinesweeper
Fixed an issue that prevented Zaff's batttlestaff dialogue from accepting tokenized amounts
Fixed an issue that prevented shop buy-x options from accepting tokenized amounts
Various shop-related exception fixes
Added some ingame player messages for when a Hunter "catch" option isn't being handled properly
Fixed some exceptions being thrown by lunar spells
Pyramid Plunder is now better at detecting when a player is in the minigame erroneously and kicking them out
Fixed an issue that would lead to incorrect Kalphite Queen behavior when killing her with multiple players in the room
Fixed an issue that could cause the Bedabin Nomad's dialogue to hang during Tourist Trap
Fixed several more issues with Fight Arena cutscenes
Fixed an issue that could prevent the dwarf dialogue from opening while trying to enter the mountain shortcut before finishing Fishing Contest
Fixed an issue that could cause dialogue option hangs in certain unusual circumstances
Fixed an issue that could result in non-movement for interactions where the override location was the same as the target node's location and there was no destination flag set
Fixed an issue where setting invalid node data could cause issues with NPC rendering
Server can now detect when a session is sending up multiple invalid packets and automatically disconnect the player
Fixed an issue that could lead to unintended saving of varps/varbits
Fixed an issue that could cause some interactions in shops to silently fail. The user will now receive a relevant message when these situations occur
Users may now find they could occasionally receive a very snarky response when incorrectly using commands
Users now receive messages when they try to make use of unimplemented friends/clan/etc features.
Errors in string parsing will no longer result in "dead" inputs when attempting to add friends/update clan ranks/etc
Fixed an issue that could lead to loss of some alerts in the Discord integration. Discord integration will now detect problems and queue the failed messages to be resent later.
Added more safety checks to item-on-grounditem packet handling to prevent throwing exceptions
Exceptions in string parsing for command packets will now inform the user that something went wrong, and ask them to try again.
Improved drop table parsing and fixed incorrect drop tables
This commit is contained in:
Ceikry
2023-07-17 08:12:57 +00:00
committed by Ryan
parent 0372937353
commit 845d8b383b
61 changed files with 547 additions and 337 deletions
@@ -20,6 +20,7 @@ abstract class DialogueFile {
this.player = player
this.npc = npc
this.interpreter = interpreter
interpreter.activeTopics.clear()
return this
}
@@ -142,8 +142,9 @@ public final class DialogueInterpreter {
close();
return;
}
DialogueFile file = dialogue.file;
if (!activeTopics.isEmpty()) {
if (!activeTopics.isEmpty() && buttonId >= 2) {
Topic<?> topic = activeTopics.get(buttonId - 2);
if (!topic.getSkipPlayer())
@@ -573,4 +574,4 @@ public final class DialogueInterpreter {
public List<DialogueAction> getActions() {
return actions;
}
}
}
@@ -194,6 +194,7 @@ public abstract class DialoguePlugin implements Plugin<Player> {
* @return {@code True} if the dialogue plugin succesfully opened.
*/
public boolean open(Object... args) {
player.getDialogueInterpreter().activeTopics.clear();
if (args.length > 0 && args[0] instanceof NPC) {
npc = (NPC)args[0];
}
@@ -1,46 +0,0 @@
package core.game.dialogue;
import core.plugin.Initializable;
import core.game.node.entity.player.Player;
/**
* Handles the SimpleEntityMessage dialogue.
* @author 'Vexia
*/
@Initializable
public class SimpleEntityMessage extends DialoguePlugin {
public SimpleEntityMessage() {
}
public SimpleEntityMessage(Player player) {
super(player);
}
@Override
public int[] getIds() {
return new int[] { 8000 };
}
@Override
public boolean handle(int interfaceId, int buttonId) {
end();
return true;
}
@Override
public DialoguePlugin newInstance(Player player) {
return new SimpleEntityMessage(player);
}
@Override
public boolean open(Object... args) {
String[] messages = new String[args.length];
for (int i = 0; i < messages.length; i++)
messages[i] = (String) args[i];
interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, messages);
return true;
}
}
@@ -51,7 +51,7 @@ public final class AbuseReport {
CommandMapping.INSTANCE.get("mute").attemptHandling(player, new String[] {"mute", victim, "48h"});
}
player.getPacketDispatch().sendMessage("Thank-you, your abuse report has been received.");
Discord.INSTANCE.postPlayerAlert(victim, "Abuse Report - " + rule.name());
Discord.postPlayerAlert(victim, "Abuse Report - " + rule.name());
}
/**
@@ -267,7 +267,8 @@ public abstract class MovementPulse extends Pulse {
}
else if(overrideMethod != null){
loc = overrideMethod.invoke(mover,destination);
if(loc == destination.getLocation()) loc = destinationFlag.getDestination(mover,destination);
if(loc == destination.getLocation() && destinationFlag != null) loc = destinationFlag.getDestination(mover,destination);
else if (loc == destination.getLocation()) loc = null;
}
if (loc == null) {
+2
View File
@@ -197,6 +197,8 @@ public abstract class Node {
* @param direction The direction to set.
*/
public void setDirection(Direction direction) {
if (direction == null)
return;
this.direction = direction;
}
@@ -42,7 +42,7 @@ public final class NPCDropTables {
*/
public static final int[] MESSAGE_NPCS = { 50, 7133, 7134, 2881, 2882, 2883, 3200, 3340, 6247, 6203, 6260, 6222, 2745, 1160, 8133, 8610, 8611, 8612, 8613, 8614, 6204, 6206, 6208, 6261, 6263, 6265, 6223, 6225, 6227 };
public final NPCDropTable table = new NPCDropTable();
public NPCDropTable table = new NPCDropTable();
/**
* The NPC definitions.
@@ -317,6 +317,8 @@ public class Player extends Entity {
public byte[] opCounts = new byte[255];
public int invalidPacketCount = 0;
/**
* Constructs a new {@code Player} {@code Object}.
* @param details The player's details.
@@ -1386,4 +1388,12 @@ public class Player extends Entity {
public void updateAppearance() {
getUpdateMasks().register(EntityFlag.Appearance, this);
}
public void incrementInvalidPacketCount() {
invalidPacketCount++;
if (invalidPacketCount >= 5) {
clear();
log(this.getClass(), Log.ERR, "Disconnecting " + getName() + " for having a high rate of invalid packets. Potential packet bot misbehaving, or simply really bad connection.");
}
}
}
@@ -643,6 +643,8 @@ class PlayerSaver (val player: Player){
val varpData = JSONArray()
for ((index, value) in player.varpMap) {
if (!(player.saveVarp[index] ?: false)) continue
val varpObj = JSONObject()
varpObj["index"] = index.toString()
varpObj["value"] = value.toString()
@@ -570,7 +570,7 @@ public final class InterfaceManager {
*/
public void setViewedTab(int tabIndex) {
if (tabs[tabIndex] == null) {
throw new IllegalStateException("Tab at index " + tabIndex + " is null!");
return;
}
currentTabIndex = tabIndex;
switch (tabIndex) {
@@ -27,7 +27,7 @@ class StateRepository : StartupListener{
@JvmStatic
fun forKey(key: String, player: Player): State?{
val state = states[key]
if(player.states[key] != null){
if(player.hasActiveState(key)){
return null
}
if(state != null){
@@ -38,4 +38,4 @@ class StateRepository : StartupListener{
return null
}
}
}
}
@@ -46,7 +46,6 @@ public final class SceneryBuilder {
remove = remove.getWrapper();
Scenery current = LandscapeParser.removeScenery(remove);
if (current == null) {
log(SceneryBuilder.class, Log.ERR, "Object could not be replaced with " + construct + " - object to remove is invalid.");
return false;
}
if (current.getRestorePulse() != null) {
@@ -119,7 +118,6 @@ public final class SceneryBuilder {
remove = remove.getWrapper();
Scenery current = LandscapeParser.removeScenery(remove);
if (current == null) {
log(SceneryBuilder.class, Log.ERR, "Object could not be replaced with " + construct + " - object to remove is invalid.");
return false;
}
if (current.getRestorePulse() != null) {
+13
View File
@@ -158,6 +158,12 @@ class Shop(val title: String, val stock: Array<ShopItem>, val general: Boolean =
val isMainStock = getAttribute(player, "shop-main", true)
val cont = if (isMainStock) getAttribute<Container?>(player, "shop-cont", null) ?: return Item(-1,-1) else playerStock
val item = cont[slot]
if (item == null) {
player.sendMessage("That item doesn't appear to be there anymore. Please try again.")
return Item(-1, -1)
}
val price = when(currency)
{
Items.TOKKUL_6529 -> item.definition.getConfiguration(ItemConfigParser.TOKKUL_PRICE, 1)
@@ -173,6 +179,13 @@ class Shop(val title: String, val stock: Array<ShopItem>, val general: Boolean =
{
val shopCont = getAttribute<Container?>(player, "shop-cont", null) ?: return Pair(null, Item(-1,-1))
val item = player.inventory[slot]
if (item == null) {
player.debug("Inventory slot $slot does not contain an item!")
player.sendMessage("That item doesn't seem to be there anymore. Please try again.")
return Pair(null, Item(-1,-1))
}
val shopItemId = if (item.definition.isUnnoted) {
item.id
}
+8 -2
View File
@@ -184,7 +184,7 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe
OP_BUY_1 -> shop.buy(player, slot, 1)
OP_BUY_5 -> shop.buy(player, slot, 5)
OP_BUY_10 -> shop.buy(player, slot, 10)
OP_BUY_X -> sendInputDialogue(player, true, "Enter the amount to buy:"){value ->
OP_BUY_X -> sendInputDialogue(player, InputType.AMOUNT, "Enter the amount to buy:"){value ->
val amt = value as Int
shop.buy(player, slot, amt)
}
@@ -226,6 +226,12 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe
val shop = getAttribute<Shop?>(player, "shop", null) ?: return@on false
val itemInSlot = player.inventory[slot]
if (itemInSlot == null) {
player.sendMessage("That item doesn't appear to be there anymore. Please try again.")
return@on true
}
val (_,price) = shop.getSellPrice(player, slot)
val def = itemDefinition(player.inventory[slot].id)
@@ -243,7 +249,7 @@ class Shops : StartupListener, TickListener, InteractionListener, InterfaceListe
OP_SELL_1 -> shop.sell(player, slot, 1)
OP_SELL_5 -> shop.sell(player, slot, 5)
OP_SELL_10 -> shop.sell(player, slot, 10)
OP_SELL_X -> sendInputDialogue(player, true, "Enter the amount to sell:"){value ->
OP_SELL_X -> sendInputDialogue(player, InputType.AMOUNT, "Enter the amount to sell:"){value ->
val amt = value as Int
shop.sell(player, slot, amt)
}
@@ -258,6 +258,10 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
reject(player, "Usage: ::commands <lt>page<gt>")
}
if (page > pages.size) {
reject(player, "That page number is too high, you don't have access to that many.")
}
for (i in 0..310) {
player.packetDispatch.sendString("", Components.QUESTJOURNAL_SCROLL_275, i)
}
@@ -46,6 +46,8 @@ class MusicCommandSet : CommandSet(Privilege.STANDARD){
* music player yet.
*/
define("playid"){player,arg ->
if (arg.size < 2)
reject(player, "Needs more args.")
val id = arg[1].toIntOrNull()
if(id != null){
PacketRepository.send(MusicPacket::class.java, MusicContext(player, id))
@@ -63,4 +65,4 @@ class MusicCommandSet : CommandSet(Privilege.STANDARD){
}
}
}
}
}
@@ -257,6 +257,10 @@ public final class CommunicationInfo {
*/
public static void add(Player player, String contact) {
CommunicationInfo info = player.getDetails().getCommunication();
if (contact.isEmpty()) {
player.sendMessage("Unable to find a player by that name. Please try again.");
return;
}
if (WorldCommunicator.isEnabled()) {
MSPacketRepository.sendContactUpdate(player.getName(), contact, false, false, null);
return;
@@ -291,6 +295,10 @@ public final class CommunicationInfo {
* @param block If the contact should be removed from the block list.
*/
public static void remove(Player player, String contact, boolean block) {
if (contact.isEmpty()) {
player.sendMessage("Unable to find a player by that name. Please try again.");
return;
}
if (WorldCommunicator.isEnabled()) {
MSPacketRepository.sendContactUpdate(player.getName(), contact, true, block, null);
return;
@@ -326,6 +334,10 @@ public final class CommunicationInfo {
* @param contact The contact to block.
*/
public static void block(Player player, String contact) {
if (contact.isEmpty()) {
player.sendMessage("Unable to find a player by that name. Please try again.");
return;
}
if (WorldCommunicator.isEnabled()) {
MSPacketRepository.sendContactUpdate(player.getName(), contact, false, true, null);
return;
@@ -352,6 +364,10 @@ public final class CommunicationInfo {
* @param clanRank The clan rank to set.
*/
public static void updateClanRank(Player player, String contact, ClanRank clanRank) {
if (contact.isEmpty()) {
player.sendMessage("Unable to find a player by that name. Please try again.");
return;
}
CommunicationInfo info = player.getDetails().getCommunication();
Contact c = info.contacts.get(contact);
if (c == null) {
@@ -5,13 +5,13 @@ import org.json.simple.JSONArray
import org.json.simple.JSONObject
import org.json.simple.parser.JSONParser
import core.ServerConstants
import core.api.log
import core.api.utils.NPCDropTable
import core.api.utils.WeightedItem
import core.api.*
import core.api.utils.*
import core.tools.Log
import core.tools.SystemLogger
import java.io.FileReader
class DropTableParser {
val parser = JSONParser()
var reader: FileReader? = null
@@ -22,13 +22,21 @@ class DropTableParser {
for(i in obj){
val tab = i as JSONObject
val ids = tab["ids"].toString().split(",")
for(n in ids){
val def = NPCDefinition.forId(n.toInt()).dropTables
def ?: continue
parseTable(tab["main"] as JSONArray, def.table, false)
parseTable(tab["charm"] as JSONArray, def.table, false, true)
parseTable(tab["default"] as JSONArray,def.table,true)
count++
try {
val table = NPCDropTable()
parseTable(tab["main"] as JSONArray, table, false)
parseTable(tab["charm"] as JSONArray, table, false, true)
parseTable(tab["default"] as JSONArray, table, true)
for(n in ids){
val def = NPCDefinition.forId(n.toInt()).dropTables
def ?: continue
def.table = table
count++
}
} catch (e: ConfigParseException) {
log (this::class.java, Log.ERR, "Error parsing drop tables for NPC ${NPCDefinition.forId(ids[0].toInt()).name}: ${exceptionToString(e)}")
}
}
log(this::class.java, Log.FINE, "Parsed $count drop tables.")
@@ -40,10 +48,15 @@ class DropTableParser {
val id = item["id"].toString().toInt()
val minAmount = item["minAmount"].toString().toInt()
val maxAmount = item["maxAmount"].toString().toInt()
if (minAmount > maxAmount) {
throw ConfigParseException("Table is invalid! Specified minimum amount is > specified maximum amount.")
}
val weight = item["weight"].toString().toDouble()
val newItem = WeightedItem(id,minAmount,maxAmount,weight.toDouble(),isAlways)
if(isCharms) destTable.addToCharms(newItem)
else destTable.add(newItem)
}
}
}
}