Skip to content

Commit

Permalink
fix: add const auto&
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Nov 28, 2023
1 parent 8653846 commit 5b9a559
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
8 changes: 2 additions & 6 deletions src/lua/functions/core/game/bank_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,14 @@ int BankFunctions::luaBankTransferToGuild(lua_State* L) {

int BankFunctions::luaBankWithdraw(lua_State* L) {
// Bank.withdraw(player, amount[, source = player])
auto player = getPlayer(L, 1);
const auto &player = getPlayer(L, 1);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
}

uint64_t amount = getNumber<uint64_t>(L, 2);
if (lua_gettop(L) == 2) {
if (!player) {
return 1;
}

const auto bank = std::make_shared<Bank>(player);
pushBoolean(L, bank->withdraw(player, amount));
return 1;
Expand All @@ -120,7 +116,7 @@ int BankFunctions::luaBankWithdraw(lua_State* L) {

int BankFunctions::luaBankDeposit(lua_State* L) {
// Bank.deposit(player, amount[, destination = player])
auto player = getPlayer(L, 1);
const auto &player = getPlayer(L, 1);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/lua/functions/core/game/modal_window_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int ModalWindowFunctions::luaModalWindowSetPriority(lua_State* L) {

int ModalWindowFunctions::luaModalWindowSendToPlayer(lua_State* L) {
// modalWindow:sendToPlayer(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down
8 changes: 4 additions & 4 deletions src/lua/functions/creatures/npc/npc_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ int NpcFunctions::luaNpcOpenShopWindow(lua_State* L) {
return 1;
}

auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
Expand All @@ -360,7 +360,7 @@ int NpcFunctions::luaNpcOpenShopWindow(lua_State* L) {

int NpcFunctions::luaNpcCloseShopWindow(lua_State* L) {
// npc:closeShopWindow(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
Expand Down Expand Up @@ -452,7 +452,7 @@ int NpcFunctions::luaNpcFollow(lua_State* L) {
return 1;
}

auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down Expand Up @@ -484,7 +484,7 @@ int NpcFunctions::luaNpcSellItem(lua_State* L) {
return 1;
}

auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
pushBoolean(L, false);
Expand Down
12 changes: 6 additions & 6 deletions src/lua/functions/creatures/player/party_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ int PartyFunctions::luaPartyGetLeader(lua_State* L) {

int PartyFunctions::luaPartySetLeader(lua_State* L) {
// party:setLeader(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
}

std::shared_ptr<Party> party = getUserdataShared<Party>(L, 1);
if (party && player) {
if (party) {
pushBoolean(L, party->passPartyLeadership(player));
} else {
lua_pushnil(L);
Expand Down Expand Up @@ -144,7 +144,7 @@ int PartyFunctions::luaPartyGetInviteeCount(lua_State* L) {

int PartyFunctions::luaPartyAddInvite(lua_State* L) {
// party:addInvite(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand All @@ -161,7 +161,7 @@ int PartyFunctions::luaPartyAddInvite(lua_State* L) {

int PartyFunctions::luaPartyRemoveInvite(lua_State* L) {
// party:removeInvite(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand All @@ -178,7 +178,7 @@ int PartyFunctions::luaPartyRemoveInvite(lua_State* L) {

int PartyFunctions::luaPartyAddMember(lua_State* L) {
// party:addMember(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand All @@ -195,7 +195,7 @@ int PartyFunctions::luaPartyAddMember(lua_State* L) {

int PartyFunctions::luaPartyRemoveMember(lua_State* L) {
// party:removeMember(player)
auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ int PlayerFunctions::luaPlayerGetMaxMana(lua_State* L) {

int PlayerFunctions::luaPlayerSetMaxMana(lua_State* L) {
// player:setMaxMana(maxMana)
auto player = getPlayer(L, 1);
const auto &player = getPlayer(L, 1);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down
6 changes: 3 additions & 3 deletions src/lua/functions/map/house_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ int HouseFunctions::luaHouseCanEditAccessList(lua_State* L) {

uint32_t listId = getNumber<uint32_t>(L, 2);

auto player = getPlayer(L, 3);
const auto &player = getPlayer(L, 3);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down Expand Up @@ -420,7 +420,7 @@ int HouseFunctions::luaHouseKickPlayer(lua_State* L) {
return 1;
}

auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc("Player is nullptr");
return 1;
Expand All @@ -444,7 +444,7 @@ int HouseFunctions::luaHouseIsInvited(lua_State* L) {
return 1;
}

auto player = getPlayer(L, 2);
const auto &player = getPlayer(L, 2);
if (!player) {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
return 1;
Expand Down

0 comments on commit 5b9a559

Please sign in to comment.