TA的每日心情 | 开心 2024-11-6 23:36 |
---|
签到天数: 319 天 [LV.8]以坛为家I

管理员
  
- 积分
- 86133
|
此修复方法是防止使用负数进行购买商店物品,并且购买金额不减反增的问题
首先,先找到源码内MapleShop.java
找到buy这个函数
在一个判断内有个一变量
- final int price = GameConstants.isRechargable(itemId) ? item.getPrice() : (item.getPrice() * quantity);
复制代码
首先要把int型改成一个long型
就变成以下
- final long price = GameConstants.isRechargable(itemId) ? item.getPrice() : (long) item.getPrice() * quantity;
复制代码
同时还需要加一个判断在下面
- if(price <= 0 || price >= Integer.MAX_VALUE){
- c.sendPacket(MaplePacketCreator.confirmShopTransaction((byte)0));
- c.sendPacket(MaplePacketCreator.enableActions());
- return;
- }
复制代码
然后会发现以下-price会变成红色
- c.getPlayer().gainMeso(-price, false);
复制代码
毕竟gainMeso是给金币,里面定义的是int型,其实给值强转回int型就可以了
- c.getPlayer().gainMeso((int)-price, false);
复制代码
还有不严谨的,请各位多多提意见! |
|