From 287018346b65b6b93dc491d4a42ed5d258277b59 Mon Sep 17 00:00:00 2001 From: Gptaqbc <56596815+Gptaqbc@users.noreply.github.com> Date: Tue, 24 Dec 2019 13:40:50 -0500 Subject: [PATCH] Some stuff on weight (#323) * Some stuff on weight Some stuff on weight * Cleaned some code related to trading and fixed most likely the issue where the player stays busy and cant trade till relog Cleaned some code related to trading and fixed most likely the issue where the player stays busy and cant trade till relog --- .../src/com/rebotted/game/items/ItemAssistant.java | 11 ++++++----- .../src/com/rebotted/game/items/ItemDefinitions.java | 4 ++-- .../src/com/rebotted/game/items/Weight.java | 4 ++-- .../src/com/rebotted/game/players/Trading.java | 6 +++--- .../src/com/rebotted/net/packets/impl/Walking.java | 5 ++++- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/2006Redone Server/src/com/rebotted/game/items/ItemAssistant.java b/2006Redone Server/src/com/rebotted/game/items/ItemAssistant.java index 18e5b8f2..5a137070 100644 --- a/2006Redone Server/src/com/rebotted/game/items/ItemAssistant.java +++ b/2006Redone Server/src/com/rebotted/game/items/ItemAssistant.java @@ -526,7 +526,7 @@ public class ItemAssistant { c.flushOutStream(); } i = 30; - Weight.calcWeight(c, item, "additem"); + Weight.updateWeight(c); return true; } } @@ -544,7 +544,8 @@ public class ItemAssistant { } resetItems(3214); i = 30; - Weight.calcWeight(c, item, "additem"); + + Weight.updateWeight(c); return true; } } @@ -1662,7 +1663,7 @@ public class ItemAssistant { c.flushOutStream(); c.updateRequired = true; c.setAppearanceUpdateRequired(true); - Weight.calcWeight(c, wearID, "deleteitem"); + Weight.updateWeight(c); } } } @@ -2367,7 +2368,7 @@ public class ItemAssistant { } } resetItems(3214); - Weight.calcWeight(c, id, "deleteitem"); + Weight.updateWeight(c); } public void deleteItem(int id, int slot, int amount) { @@ -2382,7 +2383,7 @@ public class ItemAssistant { c.playerItems[slot] = 0; } resetItems(3214); - Weight.calcWeight(c, id, "deleteitem"); + Weight.updateWeight(c); } } diff --git a/2006Redone Server/src/com/rebotted/game/items/ItemDefinitions.java b/2006Redone Server/src/com/rebotted/game/items/ItemDefinitions.java index 8c5ee3d4..71df7408 100644 --- a/2006Redone Server/src/com/rebotted/game/items/ItemDefinitions.java +++ b/2006Redone Server/src/com/rebotted/game/items/ItemDefinitions.java @@ -230,8 +230,8 @@ public class ItemDefinitions { if (id >= 0 && id < definitions.length) return definitions[id].weight; - System.out.println("WARNING: id " + id + " doesn't have a definition!"); - return 0.0; + System.out.println("WARNING: id " + id + " doesn't have a definition! 2.147kg is used as weight."); + return 2.147; } /** diff --git a/2006Redone Server/src/com/rebotted/game/items/Weight.java b/2006Redone Server/src/com/rebotted/game/items/Weight.java index b535a002..b750cfb7 100644 --- a/2006Redone Server/src/com/rebotted/game/items/Weight.java +++ b/2006Redone Server/src/com/rebotted/game/items/Weight.java @@ -16,7 +16,7 @@ public class Weight extends ItemDefinitions { * @param action * - deleteitem, additem, equip, unequip. */ - public static void calcWeight(Player c, int item, String action) { + private static void calcWeight(Player c, int item, String action) { if (action.equalsIgnoreCase("deleteitem")) { if (getWeight(item) > 99.20) { c.weight -= getWeight(item) / 100; @@ -63,7 +63,7 @@ public class Weight extends ItemDefinitions { else calcWeight(player, element, "addItem"); } } + player.getPacketSender().writeWeight((int) player.weight); } - player.getPacketSender().writeWeight((int) player.weight); } } diff --git a/2006Redone Server/src/com/rebotted/game/players/Trading.java b/2006Redone Server/src/com/rebotted/game/players/Trading.java index 9eee0cb4..daf98ec5 100644 --- a/2006Redone Server/src/com/rebotted/game/players/Trading.java +++ b/2006Redone Server/src/com/rebotted/game/players/Trading.java @@ -51,20 +51,20 @@ public class Trading { return; } - if (!player.inTrade && o.tradeRequested && o.tradeWith == player.playerId && player.playerIsBusy() == false && o.playerIsBusy() == false) { //start trading process + if (!player.inTrade && o.tradeRequested && o.tradeWith == player.playerId && !player.playerIsBusy() && !o.playerIsBusy() ) { //start trading process if (!isCloseTo(o)) { player.getPacketSender().sendMessage("Player is not close enough. Retry when you are closer..."); } else { player.getTrading().openTrade(); o.getTrading().openTrade(); } - } else if (!player.inTrade && player.playerIsBusy() == false && o.playerIsBusy() == false) { //send trade request + } else if (!player.inTrade && !player.playerIsBusy() && !o.playerIsBusy()) { //send trade request //Problem = sends the request then walk to player. Solution= change processing order. Fix= Send message when trying to open the trade interface if the other player isn't closer than 3 tiles. player.tradeRequested = true; player.getPacketSender().sendMessage("Sending trade request..."); o.getPacketSender() .sendMessage(player.playerName + ":tradereq:"); - } else if (player.playerIsBusy() == true || o.playerIsBusy() == true) { + } else if (player.playerIsBusy()|| o.playerIsBusy()) { player.getPacketSender().sendMessage("Other player is busy at the moment."); } } catch (Exception e) { diff --git a/2006Redone Server/src/com/rebotted/net/packets/impl/Walking.java b/2006Redone Server/src/com/rebotted/net/packets/impl/Walking.java index df2e3574..a90c943e 100644 --- a/2006Redone Server/src/com/rebotted/net/packets/impl/Walking.java +++ b/2006Redone Server/src/com/rebotted/net/packets/impl/Walking.java @@ -18,13 +18,16 @@ public class Walking implements PacketType { public void processPacket(Player player, int packetType, int packetSize) { player.getDueling().checkDuelWalk(); + if (player.playerIsBusy()) { + player.playerIsBusy = false; + } if (player.canChangeAppearance) { //|| c.performingAction) { return; } if (player.getCannon().settingUp) { return; } - if (player.isTeleporting == true) { + if (player.isTeleporting) { player.isTeleporting = false; } if (player.playerSkilling[10]) {// fishing