Improved pushing so that a single userdata is used per object pushed.
Made everything use the singleton less, allowing more free code and easier to implement multithreading later.
Made macros for hookmgr and fixed the issue with hooks called inside hooks.
This commit is contained in:
Rochet2
2014-06-01 23:58:28 +03:00
committed by Foereaper
parent e131f36d39
commit b1f85bfc21
25 changed files with 3169 additions and 3666 deletions

View File

@@ -12,63 +12,63 @@ namespace LuaGameObject
/* BOOLEAN */
int HasQuest(lua_State* L, GameObject* go)
{
uint32 questId = sEluna->CHECKVAL<uint32>(L, 2);
uint32 questId = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS
sEluna->Push(L, go->HasQuest(questId));
Eluna::Push(L, go->HasQuest(questId));
#else
sEluna->Push(L, go->hasQuest(questId));
Eluna::Push(L, go->hasQuest(questId));
#endif
return 1;
}
int IsSpawned(lua_State* L, GameObject* go)
{
sEluna->Push(L, go->isSpawned());
Eluna::Push(L, go->isSpawned());
return 1;
}
int IsTransport(lua_State* L, GameObject* go)
{
sEluna->Push(L, go->IsTransport());
Eluna::Push(L, go->IsTransport());
return 1;
}
int IsActive(lua_State* L, GameObject* go)
{
sEluna->Push(L, go->isActiveObject());
Eluna::Push(L, go->isActiveObject());
return 1;
}
/*int IsDestructible(lua_State* L, GameObject* go) // TODO: Implementation core side
{
sEluna->Push(L, go->IsDestructibleBuilding());
Eluna::Push(L, go->IsDestructibleBuilding());
return 1;
}*/
/* GETTERS */
int GetDisplayId(lua_State* L, GameObject* go)
{
sEluna->Push(L, go->GetDisplayId());
Eluna::Push(L, go->GetDisplayId());
return 1;
}
int GetGoState(lua_State* L, GameObject* go)
{
sEluna->Push(L, go->GetGoState());
Eluna::Push(L, go->GetGoState());
return 1;
}
int GetLootState(lua_State* L, GameObject* go)
{
sEluna->Push(L, go->getLootState());
Eluna::Push(L, go->getLootState());
return 1;
}
/* SETTERS */
int SetGoState(lua_State* L, GameObject* go)
{
uint32 state = sEluna->CHECKVAL<uint32>(L, 2, 0);
uint32 state = Eluna::CHECKVAL<uint32>(L, 2, 0);
if (state == 0)
go->SetGoState(GO_STATE_ACTIVE);
@@ -82,7 +82,7 @@ namespace LuaGameObject
int SetLootState(lua_State* L, GameObject* go)
{
uint32 state = sEluna->CHECKVAL<uint32>(L, 2, 0);
uint32 state = Eluna::CHECKVAL<uint32>(L, 2, 0);
if (state == 0)
go->SetLootState(GO_NOT_READY);
@@ -105,7 +105,7 @@ namespace LuaGameObject
int RemoveFromWorld(lua_State* L, GameObject* go)
{
bool deldb = sEluna->CHECKVAL<bool>(L, 2, false);
bool deldb = Eluna::CHECKVAL<bool>(L, 2, false);
if (deldb)
go->DeleteFromDB();
go->RemoveFromWorld();
@@ -115,33 +115,33 @@ namespace LuaGameObject
int RegisterEvent(lua_State* L, GameObject* go)
{
luaL_checktype(L, 2, LUA_TFUNCTION);
uint32 delay = sEluna->CHECKVAL<uint32>(L, 3);
uint32 repeats = sEluna->CHECKVAL<uint32>(L, 4);
uint32 delay = Eluna::CHECKVAL<uint32>(L, 3);
uint32 repeats = Eluna::CHECKVAL<uint32>(L, 4);
lua_pushvalue(L, 2);
int functionRef = lua_ref(L, true);
functionRef = sEluna->m_EventMgr.AddEvent(&go->m_Events, functionRef, delay, repeats, go);
functionRef = sEluna->m_EventMgr->AddEvent(&go->m_Events, functionRef, delay, repeats, go);
if (functionRef)
sEluna->Push(L, functionRef);
Eluna::Push(L, functionRef);
return 1;
}
int RemoveEventById(lua_State* L, GameObject* go)
{
int eventId = sEluna->CHECKVAL<int>(L, 2);
sEluna->m_EventMgr.RemoveEvent(&go->m_Events, eventId);
int eventId = Eluna::CHECKVAL<int>(L, 2);
sEluna->m_EventMgr->RemoveEvent(&go->m_Events, eventId);
return 0;
}
int RemoveEvents(lua_State* L, GameObject* go)
{
sEluna->m_EventMgr.RemoveEvents(&go->m_Events);
sEluna->m_EventMgr->RemoveEvents(&go->m_Events);
return 0;
}
int UseDoorOrButton(lua_State* L, GameObject* go)
{
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2, 0);
uint32 delay = Eluna::CHECKVAL<uint32>(L, 2, 0);
go->UseDoorOrButton(delay);
return 0;
@@ -149,7 +149,7 @@ namespace LuaGameObject
int Despawn(lua_State* L, GameObject* go)
{
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2, 1);
uint32 delay = Eluna::CHECKVAL<uint32>(L, 2, 1);
if (!delay)
delay = 1;
@@ -160,7 +160,7 @@ namespace LuaGameObject
int Respawn(lua_State* L, GameObject* go)
{
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2, 1);
uint32 delay = Eluna::CHECKVAL<uint32>(L, 2, 1);
if (!delay)
delay = 1;