Skip to content

Commit

Permalink
fix: add premium and daily reward (#1600)
Browse files Browse the repository at this point in the history
• negative timeLeft on premium is no longer casted to an unsigned integer
• it is now possible to collect daily reward (if statement reversed)
  • Loading branch information
sebbesiren authored Sep 15, 2023
1 parent 2d1aa9e commit 41ec6bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/modules/scripts/daily_reward/daily_reward.lua
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function Player.selectDailyReward(self, msg)

-- Adding items to store inbox
local inbox = self:getSlotItem(CONST_SLOT_STORE_INBOX)
if inbox then
if not inbox then
self:sendError("You do not have enough space in your store inbox.")
return false
end
Expand Down
6 changes: 3 additions & 3 deletions src/account/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace account {
}

void Account::addPremiumDays(const int32_t &days) {
uint32_t timeLeft = static_cast<int>((m_account.premiumLastDay - getTimeNow()) % 86400);
auto timeLeft = static_cast<int32_t>((m_account.premiumLastDay - getTimeNow()) % 86400);
setPremiumDays(m_account.premiumRemainingDays + days);

if (timeLeft > 0) {
Expand Down Expand Up @@ -199,8 +199,8 @@ namespace account {

time_t currentTime = getTimeNow();

uint32_t daysLeft = static_cast<int>((lastDay - currentTime) / 86400);
uint32_t timeLeft = static_cast<int>((lastDay - currentTime) % 86400);
auto daysLeft = static_cast<int32_t>((lastDay - currentTime) / 86400);
auto timeLeft = static_cast<int32_t>((lastDay - currentTime) % 86400);

m_account.premiumRemainingDays = daysLeft > 0 ? daysLeft : 0;

Expand Down

0 comments on commit 41ec6bb

Please sign in to comment.