Skip to content

Commit

Permalink
fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel committed Jun 21, 2024
1 parent ef54336 commit d64b4f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/account/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ uint8_t Account::addCoins(const uint8_t &type, const uint32_t &amount, const std
return enumToValue(AccountErrors_t::Storage);
}

registerCoinTransaction(enumToValue(CoinTransactionType::Add), type, amount, detail);
if (!detail.empty()) {
registerCoinTransaction(enumToValue(CoinTransactionType::Add), type, amount, detail);
}

return enumToValue(AccountErrors_t::Ok);
}
Expand Down
8 changes: 4 additions & 4 deletions src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2561,15 +2561,15 @@ int PlayerFunctions::luaPlayerGetTibiaCoins(lua_State* L) {
}

int PlayerFunctions::luaPlayerAddTibiaCoins(lua_State* L) {
// player:addTibiaCoins(coins)
// player:addTibiaCoins(coins[, detail = ""])
std::shared_ptr<Player> player = getUserdataShared<Player>(L, 1);
if (!player || !player->getAccount()) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnil(L);
return 1;
}

if (player->account->addCoins(enumToValue(CoinType::Normal), getNumber<uint32_t>(L, 2), "") != enumToValue(AccountErrors_t::Ok)) {
if (player->account->addCoins(enumToValue(CoinType::Normal), getNumber<uint32_t>(L, 2), getString(L, 3, "")) != enumToValue(AccountErrors_t::Ok)) {
reportErrorFunc("Failed to add coins");
lua_pushnil(L);
return 1;
Expand Down Expand Up @@ -2630,15 +2630,15 @@ int PlayerFunctions::luaPlayerGetTransferableCoins(lua_State* L) {
}

int PlayerFunctions::luaPlayerAddTransferableCoins(lua_State* L) {
// player:addTransferableCoins(coins)
// player:addTransferableCoins(coins[, detail = ""])
std::shared_ptr<Player> player = getUserdataShared<Player>(L, 1);
if (!player || !player->getAccount()) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnil(L);
return 1;
}

if (player->account->addCoins(enumToValue(CoinType::Transferable), getNumber<uint32_t>(L, 2)) != enumToValue(AccountErrors_t::Ok)) {
if (player->account->addCoins(enumToValue(CoinType::Transferable), getNumber<uint32_t>(L, 2), getString(L, 3, "")) != enumToValue(AccountErrors_t::Ok)) {
reportErrorFunc("failed to add transferable coins");
lua_pushnil(L);
return 1;
Expand Down

0 comments on commit d64b4f4

Please sign in to comment.