From 996841e82ec63048adade3a25a7fa798c1bce169 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Sun, 23 Jul 2023 14:30:43 +1000 Subject: [PATCH] Restore level 50 experience cap from Diablo --- Source/playerdat.cpp | 7 ++++--- Source/qol/xpbar.cpp | 2 +- test/writehero_test.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/playerdat.cpp b/Source/playerdat.cpp index a7e407989..1e30277aa 100644 --- a/Source/playerdat.cpp +++ b/Source/playerdat.cpp @@ -20,7 +20,7 @@ namespace devilution { namespace { constexpr uint8_t MaxCharacterLevel = 50; /** Specifies the experience point limit of each level. */ -const std::array ExpLvlsTbl { +const std::array ExpLvlsTbl { 0, 2000, 4620, @@ -70,13 +70,14 @@ const std::array ExpLvlsTbl { 733825617, 892680222, 1082908612, - 1310707109 + 1310707109, + 1583495809 }; } // namespace uint32_t GetNextExperienceThresholdForLevel(unsigned level) { - return ExpLvlsTbl[std::min(level, ExpLvlsTbl.size() - 1)]; + return ExpLvlsTbl[std::min(level, static_cast(GetMaximumCharacterLevel()))]; } uint8_t GetMaximumCharacterLevel() diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index 6f8d79d0d..d0298e2be 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -128,7 +128,7 @@ bool CheckXPBarInfo() // Show a maximum level indicator for max level players. InfoColor = UiFlags::ColorWhitegold; - AddPanelString(fmt::format(fmt::runtime(_("Experience: {:s}")), FormatInteger(GetNextExperienceThresholdForLevel(charLevel - 1)))); + AddPanelString(fmt::format(fmt::runtime(_("Experience: {:s}")), FormatInteger(player._pExperience))); AddPanelString(_("Maximum Level")); return true; diff --git a/test/writehero_test.cpp b/test/writehero_test.cpp index 988f40fa7..7998f8d3a 100644 --- a/test/writehero_test.cpp +++ b/test/writehero_test.cpp @@ -323,7 +323,7 @@ void AssertPlayer(Player &player) ASSERT_EQ(player._pMaxHP, 16640); ASSERT_EQ(player._pMana, 14624); ASSERT_EQ(player._pMaxMana, 14624); - ASSERT_EQ(player.getNextExperienceThreshold(), 1310707109); + ASSERT_EQ(player.getNextExperienceThreshold(), 1583495809); ASSERT_EQ(player._pMagResist, 75); ASSERT_EQ(player._pFireResist, 16); ASSERT_EQ(player._pLghtResist, 75);