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
This commit is contained in:
Gptaqbc
2019-12-24 13:40:50 -05:00
committed by Daniel Ginovker
parent 850b09e6fc
commit 287018346b
5 changed files with 17 additions and 13 deletions
@@ -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);
}
}
@@ -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;
}
/**
@@ -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);
}
}
@@ -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) {
@@ -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