Skip to content

Commit

Permalink
Merge branch 'shared_ptr-party' of https://github.com/ramon-bernardo/…
Browse files Browse the repository at this point in the history
…forgottenserver into shared_ptr-party
  • Loading branch information
ramon-bernardo committed Sep 1, 2024
2 parents a62b520 + 0b8f40d commit a3a24cb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,13 @@ bool Events::eventPartyOnJoin(Party_ptr party, Player* player)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnJoin);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

tfs::lua::pushUserdata(L, player);
tfs::lua::setMetatable(L, -1, "Player");
Expand All @@ -425,8 +430,13 @@ bool Events::eventPartyOnLeave(Party_ptr party, Player* player)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnLeave);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

tfs::lua::pushUserdata(L, player);
tfs::lua::setMetatable(L, -1, "Player");
Expand All @@ -452,8 +462,13 @@ bool Events::eventPartyOnDisband(Party_ptr party)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnDisband);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

return scriptInterface.callFunction(1);
}
Expand All @@ -476,8 +491,13 @@ bool Events::eventPartyOnInvite(Party_ptr party, Player* player)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnInvite);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

tfs::lua::pushUserdata(L, player);
tfs::lua::setMetatable(L, -1, "Player");
Expand All @@ -503,8 +523,13 @@ bool Events::eventPartyOnRevokeInvitation(Party_ptr party, Player* player)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnRevokeInvitation);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

tfs::lua::pushUserdata(L, player);
tfs::lua::setMetatable(L, -1, "Player");
Expand All @@ -530,8 +555,13 @@ bool Events::eventPartyOnPassLeadership(Party_ptr party, Player* player)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnPassLeadership);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

tfs::lua::pushUserdata(L, player);
tfs::lua::setMetatable(L, -1, "Player");
Expand All @@ -557,8 +587,13 @@ void Events::eventPartyOnShareExperience(Party_ptr party, uint64_t& exp)
lua_State* L = scriptInterface.getLuaState();
scriptInterface.pushFunction(info.partyOnShareExperience);

<<<<<<< HEAD
tfs::lua::pushUserdata(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
LuaScriptInterface::pushSharedPtr(L, party);
LuaScriptInterface::setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

lua_pushnumber(L, exp);

Expand Down
14 changes: 14 additions & 0 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10429,8 +10429,13 @@ int LuaScriptInterface::luaPlayerGetParty(lua_State* L)
}

if (const auto& party = player->getParty()) {
<<<<<<< HEAD

Check failure on line 10432 in src/luascript.cpp

View workflow job for this annotation

GitHub Actions / test

version control conflict marker in file
tfs::lua::pushSharedPtr(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======

Check failure on line 10435 in src/luascript.cpp

View workflow job for this annotation

GitHub Actions / test

version control conflict marker in file
pushSharedPtr(L, party);
setMetatable(L, -1, "Party");

Check failure on line 10437 in src/luascript.cpp

View workflow job for this annotation

GitHub Actions / test

‘setMetatable’ was not declared in this scope; did you mean ‘tfs::lua::setMetatable’?
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1

Check failure on line 10438 in src/luascript.cpp

View workflow job for this annotation

GitHub Actions / test

version control conflict marker in file
} else {
lua_pushnil(L);
}
Expand Down Expand Up @@ -16366,8 +16371,13 @@ int32_t LuaScriptInterface::luaPartyCreate(lua_State* L)
g_game.updatePlayerShield(player);
player->sendCreatureSkull(player);

<<<<<<< HEAD
tfs::lua::pushSharedPtr(L, party);
tfs::lua::setMetatable(L, -1, "Party");
=======
pushSharedPtr(L, party);
setMetatable(L, -1, "Party");
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1
}
return 1;
}
Expand Down Expand Up @@ -16408,7 +16418,11 @@ int LuaScriptInterface::luaPartyGetLeader(lua_State* L)
int LuaScriptInterface::luaPartySetLeader(lua_State* L)
{
// party:setLeader(player)
<<<<<<< HEAD
const auto& party = tfs::lua::getSharedPtr<Party>(L, 1);
=======
const auto& party = getSharedPtr<Party>(L, 1);
>>>>>>> 0b8f40dc406a0333322781831e63bab402bee0e1
if (!party) {
lua_pushnil(L);
return 1;
Expand Down

0 comments on commit a3a24cb

Please sign in to comment.