From 0da0ddbb8ac5c4c8306101f160b5be54b3fa54ac Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 11 Apr 2018 07:55:02 +0000 Subject: [PATCH] Prevent client SP value overflow. --- L2J_Mobius_CT_2.6_HighFive/dist/game/config/Character.ini | 6 +++--- .../scripts/handlers/admincommandhandlers/AdminExpSp.java | 7 ++++--- .../l2jmobius/gameserver/model/CharSelectInfoPackage.java | 6 +++--- .../gameserver/model/actor/instance/L2PcInstance.java | 4 ++-- .../network/serverpackets/CharSelectionInfo.java | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Character.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Character.ini index 20c7670138..6a6764bb26 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Character.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Character.ini @@ -346,9 +346,9 @@ MinAbnormalStateSuccessRate = 10 MaxAbnormalStateSuccessRate = 90 # Maximum amount of SP a character can posses. -# Current retail limit is 50 billion, use -1 to set it to unlimited. -# Default: 50000000000 -MaxSp = 50000000000 +# Current retail limit is max integer number, use -1 to set it to unlimited. +# Default: 2147483647 +MaxSp = 2000000000 # Maximum number of allowed subclasses for every player. # Default: 3 diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminExpSp.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminExpSp.java index 96cf09739b..550778dc9f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminExpSp.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminExpSp.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ClassListData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -133,7 +134,7 @@ public class AdminExpSp implements IAdminCommandHandler try { expval = Long.parseLong(exp); - spval = Long.parseLong(sp); + spval = Math.min(Long.parseLong(sp), Config.MAX_SP); } catch (Exception e) { @@ -172,11 +173,11 @@ public class AdminExpSp implements IAdminCommandHandler final String exp = st.nextToken(); final String sp = st.nextToken(); long expval = 0; - int spval = 0; + long spval = 0; try { expval = Long.parseLong(exp); - spval = Integer.parseInt(sp); + spval = Long.parseLong(sp); } catch (Exception e) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/CharSelectInfoPackage.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/CharSelectInfoPackage.java index 26072c8a99..d36c0154c2 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/CharSelectInfoPackage.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/CharSelectInfoPackage.java @@ -29,7 +29,7 @@ public class CharSelectInfoPackage private String _name; private int _objectId = 0; private long _exp = 0; - private int _sp = 0; + private long _sp = 0; private int _clanId = 0; private int _race = 0; private int _classId = 0; @@ -302,12 +302,12 @@ public class CharSelectInfoPackage _sex = sex; } - public int getSp() + public long getSp() { return _sp; } - public void setSp(int sp) + public void setSp(long sp) { _sp = sp; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index d978cf3e25..fb9e71b35f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -6715,7 +6715,7 @@ public final class L2PcInstance extends L2Playable player.getStat().setExp(rset.getLong("exp")); player.setExpBeforeDeath(rset.getLong("expBeforeDeath")); player.getStat().setLevel(rset.getByte("level")); - player.getStat().setSp(rset.getInt("sp")); + player.getStat().setSp(rset.getLong("sp")); player.setWantsPeace(rset.getInt("wantspeace")); @@ -7031,7 +7031,7 @@ public final class L2PcInstance extends L2Playable subClass.setClassId(rs.getInt("class_id")); subClass.setLevel(rs.getByte("level")); subClass.setExp(rs.getLong("exp")); - subClass.setSp(rs.getInt("sp")); + subClass.setSp(rs.getLong("sp")); subClass.setClassIndex(rs.getInt("class_index")); // Enforce the correct indexing of _subClasses against their class indexes. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/CharSelectionInfo.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/CharSelectionInfo.java index cb39a05e0a..33580c5142 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/CharSelectionInfo.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/serverpackets/CharSelectionInfo.java @@ -117,7 +117,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket packet.writeF(charInfoPackage.getCurrentHp()); packet.writeF(charInfoPackage.getCurrentMp()); - packet.writeD(charInfoPackage.getSp()); + packet.writeD((int) charInfoPackage.getSp()); packet.writeQ(charInfoPackage.getExp()); packet.writeF((float) (charInfoPackage.getExp() - ExperienceData.getInstance().getExpForLevel(charInfoPackage.getLevel())) / (ExperienceData.getInstance().getExpForLevel(charInfoPackage.getLevel() + 1) - ExperienceData.getInstance().getExpForLevel(charInfoPackage.getLevel()))); // High // Five @@ -259,7 +259,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket charInfopackage.setSex(chardata.getInt("sex")); charInfopackage.setExp(chardata.getLong("exp")); - charInfopackage.setSp(chardata.getInt("sp")); + charInfopackage.setSp(chardata.getLong("sp")); charInfopackage.setVitalityPoints(chardata.getInt("vitality_points")); charInfopackage.setClanId(chardata.getInt("clanid"));