Skip to content

Commit

Permalink
fix: xp rates display (opentibiabr#3123)
Browse files Browse the repository at this point in the history
This fixes the display xp rates with low level bonus and boost xp.
  • Loading branch information
phacUFPE authored Nov 18, 2024
1 parent 4655357 commit 5072de8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2739,6 +2739,10 @@ uint16_t Player::getGrindingXpBoost() const {
return grindingXpBoost;
}

uint16_t Player::getDisplayGrindingXpBoost() const {
return std::clamp<uint16_t>(grindingXpBoost * (baseXpGain / 100), 0, std::numeric_limits<uint16_t>::max());
}

void Player::setGrindingXpBoost(uint16_t value) {
grindingXpBoost = std::min<uint16_t>(std::numeric_limits<uint16_t>::max(), value);
}
Expand All @@ -2747,6 +2751,10 @@ uint16_t Player::getXpBoostPercent() const {
return xpBoostPercent;
}

uint16_t Player::getDisplayXpBoostPercent() const {
return std::clamp<uint16_t>(xpBoostPercent * (baseXpGain / 100), 0, std::numeric_limits<uint16_t>::max());
}

void Player::setXpBoostPercent(uint16_t percent) {
xpBoostPercent = percent;
}
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,10 @@ class Player final : public Creature, public Cylinder, public Bankable {
uint16_t getVoucherXpBoost() const;
void setVoucherXpBoost(uint16_t value);
uint16_t getGrindingXpBoost() const;
uint16_t getDisplayGrindingXpBoost() const;
void setGrindingXpBoost(uint16_t value);
uint16_t getXpBoostPercent() const;
uint16_t getDisplayXpBoostPercent() const;
void setXpBoostPercent(uint16_t percent);
uint16_t getStaminaXpBoost() const;
void setStaminaXpBoost(uint16_t value);
Expand Down
8 changes: 4 additions & 4 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3480,8 +3480,8 @@ void ProtocolGame::sendCyclopediaCharacterGeneralStats() {
msg.add<uint16_t>(player->getLevel());
msg.addByte(player->getLevelPercent());
msg.add<uint16_t>(player->getBaseXpGain()); // BaseXPGainRate
msg.add<uint16_t>(player->getGrindingXpBoost()); // LowLevelBonus
msg.add<uint16_t>(player->getXpBoostPercent()); // XPBoost
msg.add<uint16_t>(player->getDisplayGrindingXpBoost()); // LowLevelBonus
msg.add<uint16_t>(player->getDisplayXpBoostPercent()); // XPBoost
msg.add<uint16_t>(player->getStaminaXpBoost()); // StaminaMultiplier(100=x1.0)
msg.add<uint16_t>(player->getXpBoostTime()); // xpBoostRemainingTime
msg.addByte(player->getXpBoostTime() > 0 ? 0x00 : 0x01); // canBuyXpBoost
Expand Down Expand Up @@ -7840,8 +7840,8 @@ void ProtocolGame::AddPlayerStats(NetworkMessage &msg) {
msg.add<uint16_t>(player->getVoucherXpBoost()); // xp voucher
}

msg.add<uint16_t>(player->getGrindingXpBoost()); // low level bonus
msg.add<uint16_t>(player->getXpBoostPercent()); // xp boost
msg.add<uint16_t>(player->getDisplayGrindingXpBoost()); // low level bonus
msg.add<uint16_t>(player->getDisplayXpBoostPercent()); // xp boost
msg.add<uint16_t>(player->getStaminaXpBoost()); // stamina multiplier (100 = 1.0x)

if (!oldProtocol) {
Expand Down

0 comments on commit 5072de8

Please sign in to comment.