Fix calling Eluna functions from coroutines.

Fixes #126.
This commit is contained in:
Patman64
2014-12-15 00:33:46 -05:00
parent 3f08b37fd0
commit 967a8045eb
21 changed files with 2548 additions and 2548 deletions

View File

@@ -15,10 +15,10 @@ namespace LuaGroup
* @param uint64 guid : guid of a possible leader
* @return bool isLeader
*/
int IsLeader(Eluna* E, Group* group)
int IsLeader(Eluna* /*E*/, lua_State* L, Group* group)
{
uint64 guid = Eluna::CHECKVAL<uint64>(E->L, 2);
Eluna::Push(E->L, group->IsLeader(ObjectGuid(guid)));
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
Eluna::Push(L, group->IsLeader(ObjectGuid(guid)));
return 1;
}
@@ -27,9 +27,9 @@ namespace LuaGroup
*
* @return bool isFull
*/
int IsFull(Eluna* E, Group* group)
int IsFull(Eluna* /*E*/, lua_State* L, Group* group)
{
Eluna::Push(E->L, group->IsFull());
Eluna::Push(L, group->IsFull());
return 1;
}
@@ -38,9 +38,9 @@ namespace LuaGroup
*
* @return bool isRaid
*/
int IsRaidGroup(Eluna* E, Group* group)
int IsRaidGroup(Eluna* /*E*/, lua_State* L, Group* group)
{
Eluna::Push(E->L, group->isRaidGroup());
Eluna::Push(L, group->isRaidGroup());
return 1;
}
@@ -49,9 +49,9 @@ namespace LuaGroup
*
* @return bool isBG
*/
int IsBGGroup(Eluna* E, Group* group)
int IsBGGroup(Eluna* /*E*/, lua_State* L, Group* group)
{
Eluna::Push(E->L, group->isBGGroup());
Eluna::Push(L, group->isBGGroup());
return 1;
}
@@ -61,10 +61,10 @@ namespace LuaGroup
* @param [Player] player : [Player] to check
* @return bool isMember
*/
int IsMember(Eluna* E, Group* group)
int IsMember(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
Eluna::Push(E->L, group->IsMember(player->GET_GUID()));
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
Eluna::Push(L, group->IsMember(player->GET_GUID()));
return 1;
}
@@ -74,11 +74,11 @@ namespace LuaGroup
* @param [Player] player : [Player] to check
* @return bool isAssistant
*/
int IsAssistant(Eluna* E, Group* group)
int IsAssistant(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
Eluna::Push(E->L, group->IsAssistant(player->GET_GUID()));
Eluna::Push(L, group->IsAssistant(player->GET_GUID()));
return 1;
}
@@ -89,11 +89,11 @@ namespace LuaGroup
* @param [Player] player2 : second [Player] to check
* @return bool sameSubGroup
*/
int SameSubGroup(Eluna* E, Group* group)
int SameSubGroup(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player1 = Eluna::CHECKOBJ<Player>(E->L, 2);
Player* player2 = Eluna::CHECKOBJ<Player>(E->L, 3);
Eluna::Push(E->L, group->SameSubGroup(player1, player2));
Player* player1 = Eluna::CHECKOBJ<Player>(L, 2);
Player* player2 = Eluna::CHECKOBJ<Player>(L, 3);
Eluna::Push(L, group->SameSubGroup(player1, player2));
return 1;
}
@@ -103,10 +103,10 @@ namespace LuaGroup
* @param uint8 subGroup : subGroup ID to check
* @return bool hasFreeSlot
*/
int HasFreeSlotSubGroup(Eluna* E, Group* group)
int HasFreeSlotSubGroup(Eluna* /*E*/, lua_State* L, Group* group)
{
uint8 subGroup = Eluna::CHECKVAL<uint8>(E->L, 2);
Eluna::Push(E->L, group->HasFreeSlotSubGroup(subGroup));
uint8 subGroup = Eluna::CHECKVAL<uint8>(L, 2);
Eluna::Push(L, group->HasFreeSlotSubGroup(subGroup));
return 1;
}
@@ -116,23 +116,23 @@ namespace LuaGroup
* @param [Player] player : [Player] to invite
* @return bool invited
*/
int AddInvite(Eluna* E, Group* group)
int AddInvite(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
Eluna::Push(E->L, group->AddInvite(player));
Eluna::Push(L, group->AddInvite(player));
return 1;
}
/*int IsLFGGroup(Eluna* E, Group* group) // TODO: Implementation
/*int IsLFGGroup(Eluna* E, lua_State* L, Group* group) // TODO: Implementation
{
Eluna::Push(E->L, group->isLFGGroup());
Eluna::Push(L, group->isLFGGroup());
return 1;
}*/
/*int IsBFGroup(Eluna* E, Group* group) // TODO: Implementation
/*int IsBFGroup(Eluna* E, lua_State* L, Group* group) // TODO: Implementation
{
Eluna::Push(E->L, group->isBFGroup());
Eluna::Push(L, group->isBFGroup());
return 1;
}*/
@@ -141,10 +141,10 @@ namespace LuaGroup
*
* @return table groupPlayers : table of [Player]s
*/
int GetMembers(Eluna* E, Group* group)
int GetMembers(Eluna* /*E*/, lua_State* L, Group* group)
{
lua_newtable(E->L);
int tbl = lua_gettop(E->L);
lua_newtable(L);
int tbl = lua_gettop(L);
uint32 i = 0;
for (GroupReference* itr = group->GetFirstMember(); itr; itr = itr->next())
@@ -159,12 +159,12 @@ namespace LuaGroup
continue;
++i;
Eluna::Push(E->L, i);
Eluna::Push(E->L, member);
lua_settable(E->L, tbl);
Eluna::Push(L, i);
Eluna::Push(L, member);
lua_settable(L, tbl);
}
lua_settop(E->L, tbl); // push table to top of stack
lua_settop(L, tbl); // push table to top of stack
return 1;
}
@@ -173,12 +173,12 @@ namespace LuaGroup
*
* @return uint64 leaderGUID
*/
int GetLeaderGUID(Eluna* E, Group* group)
int GetLeaderGUID(Eluna* /*E*/, lua_State* L, Group* group)
{
#ifndef TRINITY
Eluna::Push(E->L, group->GetLeaderGuid());
Eluna::Push(L, group->GetLeaderGuid());
#else
Eluna::Push(E->L, group->GetLeaderGUID());
Eluna::Push(L, group->GetLeaderGUID());
#endif
return 1;
}
@@ -188,12 +188,12 @@ namespace LuaGroup
*
* @return [Player] leader
*/
int GetLeader(Eluna* E, Group* group)
int GetLeader(Eluna* /*E*/, lua_State* L, Group* group)
{
#ifndef TRINITY
Eluna::Push(E->L, eObjectAccessor->FindPlayer(group->GetLeaderGuid()));
Eluna::Push(L, eObjectAccessor->FindPlayer(group->GetLeaderGuid()));
#else
Eluna::Push(E->L, eObjectAccessor->FindPlayer(group->GetLeaderGUID()));
Eluna::Push(L, eObjectAccessor->FindPlayer(group->GetLeaderGUID()));
#endif
return 1;
}
@@ -203,12 +203,12 @@ namespace LuaGroup
*
* @return uint64 groupGUID
*/
int GetGUID(Eluna* E, Group* group)
int GetGUID(Eluna* /*E*/, lua_State* L, Group* group)
{
#ifdef CLASSIC
Eluna::Push(E->L, group->GetId());
Eluna::Push(L, group->GetId());
#else
Eluna::Push(E->L, group->GET_GUID());
Eluna::Push(L, group->GET_GUID());
#endif
return 1;
}
@@ -219,13 +219,13 @@ namespace LuaGroup
* @param string name : the [Player]'s name
* @return uint64 memberGUID
*/
int GetMemberGUID(Eluna* E, Group* group)
int GetMemberGUID(Eluna* /*E*/, lua_State* L, Group* group)
{
const char* name = Eluna::CHECKVAL<const char*>(E->L, 2);
const char* name = Eluna::CHECKVAL<const char*>(L, 2);
#ifndef TRINITY
Eluna::Push(E->L, group->GetMemberGuid(name));
Eluna::Push(L, group->GetMemberGuid(name));
#else
Eluna::Push(E->L, group->GetMemberGUID(name));
Eluna::Push(L, group->GetMemberGUID(name));
#endif
return 1;
}
@@ -235,9 +235,9 @@ namespace LuaGroup
*
* @return uint32 memberCount
*/
int GetMembersCount(Eluna* E, Group* group)
int GetMembersCount(Eluna* /*E*/, lua_State* L, Group* group)
{
Eluna::Push(E->L, group->GetMembersCount());
Eluna::Push(L, group->GetMembersCount());
return 1;
}
@@ -247,11 +247,11 @@ namespace LuaGroup
* @param [Player] player : the [Player] to check
* @return uint8 subGroupID
*/
int GetMemberGroup(Eluna* E, Group* group)
int GetMemberGroup(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
Eluna::Push(E->L, group->GetMemberGroup(player->GET_GUID()));
Eluna::Push(L, group->GetMemberGroup(player->GET_GUID()));
return 1;
}
@@ -260,9 +260,9 @@ namespace LuaGroup
*
* @param [Player] leader : the [Player] leader to change
*/
int SetLeader(Eluna* E, Group* group)
int SetLeader(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* leader = Eluna::CHECKOBJ<Player>(E->L, 2);
Player* leader = Eluna::CHECKOBJ<Player>(L, 2);
group->ChangeLeader(leader->GET_GUID());
return 0;
@@ -275,11 +275,11 @@ namespace LuaGroup
* @param bool ignorePlayersInBg : ignores [Player]s in a battleground
* @param uint64 ignore : ignore a [Player] by their GUID
*/
int SendPacket(Eluna* E, Group* group)
int SendPacket(Eluna* /*E*/, lua_State* L, Group* group)
{
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(E->L, 2);
bool ignorePlayersInBg = Eluna::CHECKVAL<bool>(E->L, 3);
uint64 ignore = Eluna::CHECKVAL<uint64>(E->L, 4);
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
bool ignorePlayersInBg = Eluna::CHECKVAL<bool>(L, 3);
uint64 ignore = Eluna::CHECKVAL<uint64>(L, 4);
group->BroadcastPacket(data, ignorePlayersInBg, -1, ObjectGuid(ignore));
return 0;
@@ -302,15 +302,15 @@ namespace LuaGroup
* @param [RemoveMethod] method : method used to remove the player
* @return bool removed
*/
int RemoveMember(Eluna* E, Group* group)
int RemoveMember(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
uint32 method = Eluna::CHECKVAL<uint32>(E->L, 3, 0);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint32 method = Eluna::CHECKVAL<uint32>(L, 3, 0);
#ifndef TRINITY
Eluna::Push(E->L, group->RemoveMember(player->GET_GUID(), method));
Eluna::Push(L, group->RemoveMember(player->GET_GUID(), method));
#else
Eluna::Push(E->L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method));
Eluna::Push(L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method));
#endif
return 1;
}
@@ -319,7 +319,7 @@ namespace LuaGroup
* Disbands this [Group]
*
*/
int Disband(Eluna* /*E*/, Group* group)
int Disband(Eluna* /*E*/, lua_State* /*L*/, Group* group)
{
group->Disband();
return 0;
@@ -329,7 +329,7 @@ namespace LuaGroup
* Converts this [Group] to a raid [Group]
*
*/
int ConvertToRaid(Eluna* /*E*/, Group* group)
int ConvertToRaid(Eluna* /*E*/, lua_State* /*L*/, Group* group)
{
group->ConvertToRaid();
return 0;
@@ -341,10 +341,10 @@ namespace LuaGroup
* @param [Player] player : [Player] to move
* @param uint8 groupID : the subGroup's ID
*/
int SetMembersGroup(Eluna* E, Group* group)
int SetMembersGroup(Eluna* /*E*/, lua_State* L, Group* group)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
uint8 groupID = Eluna::CHECKVAL<uint8>(E->L, 3);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 groupID = Eluna::CHECKVAL<uint8>(L, 3);
group->ChangeMembersGroup(player->GET_GUID(), groupID);
return 0;
@@ -357,14 +357,14 @@ namespace LuaGroup
* @param uint64 target : GUID of the icon target, 0 is to clear the icon
* @param uint64 setter : GUID of the icon setter
*/
int SetTargetIcon(Eluna* E, Group* group)
int SetTargetIcon(Eluna* /*E*/, lua_State* L, Group* group)
{
uint8 icon = Eluna::CHECKVAL<uint8>(E->L, 2);
uint64 target = Eluna::CHECKVAL<uint64>(E->L, 3);
uint64 setter = Eluna::CHECKVAL<uint64>(E->L, 4, 0);
uint8 icon = Eluna::CHECKVAL<uint8>(L, 2);
uint64 target = Eluna::CHECKVAL<uint64>(L, 3);
uint64 setter = Eluna::CHECKVAL<uint64>(L, 4, 0);
if (icon >= TARGETICONCOUNT)
return luaL_argerror(E->L, 2, "valid target icon expected");
return luaL_argerror(L, 2, "valid target icon expected");
#if (defined(CLASSIC) || defined(TBC))
group->SetTargetIcon(icon, ObjectGuid(target));
@@ -374,7 +374,7 @@ namespace LuaGroup
return 0;
}
/*int ConvertToLFG(Eluna* E, Group* group) // TODO: Implementation
/*int ConvertToLFG(Eluna* E, lua_State* L, Group* group) // TODO: Implementation
{
group->ConvertToLFG();
return 0;