Change Eluna to a global variable

Remove Eluna* from being passed. You can now get it through Eluna::GetEluna(L)
Change function call cleanup to lua_settop instead of manual loop
Explicitly delete the copy constructor and copy assignment operators
This commit is contained in:
Rochet2
2017-03-19 15:48:48 +02:00
parent 8d3433f4b5
commit b7c379a42c
23 changed files with 990 additions and 976 deletions

View File

@@ -17,7 +17,7 @@ namespace LuaWorldObject
*
* @return string name
*/
int GetName(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetName(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetName());
return 1;
@@ -28,7 +28,7 @@ namespace LuaWorldObject
*
* @return [Map] mapObject
*/
int GetMap(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetMap(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetMap());
return 1;
@@ -40,7 +40,7 @@ namespace LuaWorldObject
*
* @return uint32 phase
*/
int GetPhaseMask(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetPhaseMask(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetPhaseMask());
return 1;
@@ -52,7 +52,7 @@ namespace LuaWorldObject
* @param uint32 phaseMask
* @param bool update = true : update visibility to nearby objects
*/
int SetPhaseMask(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int SetPhaseMask(lua_State* L, WorldObject* obj)
{
uint32 phaseMask = Eluna::CHECKVAL<uint32>(L, 2);
bool update = Eluna::CHECKVAL<bool>(L, 3, true);
@@ -66,7 +66,7 @@ namespace LuaWorldObject
*
* @return uint32 instanceId
*/
int GetInstanceId(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetInstanceId(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetInstanceId());
return 1;
@@ -77,7 +77,7 @@ namespace LuaWorldObject
*
* @return uint32 areaId
*/
int GetAreaId(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetAreaId(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetAreaId());
return 1;
@@ -88,7 +88,7 @@ namespace LuaWorldObject
*
* @return uint32 zoneId
*/
int GetZoneId(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetZoneId(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetZoneId());
return 1;
@@ -99,7 +99,7 @@ namespace LuaWorldObject
*
* @return uint32 mapId
*/
int GetMapId(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetMapId(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetMapId());
return 1;
@@ -110,7 +110,7 @@ namespace LuaWorldObject
*
* @return float x
*/
int GetX(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetX(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetPositionX());
return 1;
@@ -121,7 +121,7 @@ namespace LuaWorldObject
*
* @return float y
*/
int GetY(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetY(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetPositionY());
return 1;
@@ -132,7 +132,7 @@ namespace LuaWorldObject
*
* @return float z
*/
int GetZ(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetZ(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetPositionZ());
return 1;
@@ -143,7 +143,7 @@ namespace LuaWorldObject
*
* @return float orientation / facing
*/
int GetO(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetO(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetOrientation());
return 1;
@@ -157,7 +157,7 @@ namespace LuaWorldObject
* @return float z : z coordinate (height) of the [WorldObject]
* @return float o : facing / orientation of the [WorldObject]
*/
int GetLocation(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetLocation(lua_State* L, WorldObject* obj)
{
Eluna::Push(L, obj->GetPositionX());
Eluna::Push(L, obj->GetPositionY());
@@ -175,7 +175,7 @@ namespace LuaWorldObject
*
* @return [Player] nearestPlayer
*/
int GetNearestPlayer(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetNearestPlayer(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint32 hostile = Eluna::CHECKVAL<uint32>(L, 3, 0);
@@ -204,7 +204,7 @@ namespace LuaWorldObject
*
* @return [GameObject] nearestGameObject
*/
int GetNearestGameObject(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetNearestGameObject(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
@@ -234,7 +234,7 @@ namespace LuaWorldObject
*
* @return [Creature] nearestCreature
*/
int GetNearestCreature(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetNearestCreature(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
@@ -264,7 +264,7 @@ namespace LuaWorldObject
*
* @return table playersInRange : table of [Player]s
*/
int GetPlayersInRange(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetPlayersInRange(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint32 hostile = Eluna::CHECKVAL<uint32>(L, 3, 0);
@@ -305,7 +305,7 @@ namespace LuaWorldObject
*
* @return table creaturesInRange : table of [Creature]s
*/
int GetCreaturesInRange(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetCreaturesInRange(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
@@ -346,7 +346,7 @@ namespace LuaWorldObject
*
* @return table gameObjectsInRange : table of [GameObject]s
*/
int GetGameObjectsInRange(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetGameObjectsInRange(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
@@ -389,7 +389,7 @@ namespace LuaWorldObject
*
* @return [WorldObject] worldObject
*/
int GetNearObject(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetNearObject(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint16 type = Eluna::CHECKVAL<uint16>(L, 3, 0); // TypeMask
@@ -426,7 +426,7 @@ namespace LuaWorldObject
*
* @return table worldObjectList : table of [WorldObject]s
*/
int GetNearObjects(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetNearObjects(lua_State* L, WorldObject* obj)
{
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
uint16 type = Eluna::CHECKVAL<uint16>(L, 3, 0); // TypeMask
@@ -477,7 +477,7 @@ namespace LuaWorldObject
*
* @return float dist : the distance in yards
*/
int GetDistance(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetDistance(lua_State* L, WorldObject* obj)
{
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
if (target && target->IsInWorld())
@@ -507,7 +507,7 @@ namespace LuaWorldObject
*
* @return float dist : the distance in yards
*/
int GetExactDistance(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetExactDistance(lua_State* L, WorldObject* obj)
{
float x, y, z;
obj->GetPosition(x, y, z);
@@ -545,7 +545,7 @@ namespace LuaWorldObject
*
* @return float dist : the distance in yards
*/
int GetDistance2d(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetDistance2d(lua_State* L, WorldObject* obj)
{
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
if (target && target->IsInWorld())
@@ -573,7 +573,7 @@ namespace LuaWorldObject
*
* @return float dist : the distance in yards
*/
int GetExactDistance2d(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetExactDistance2d(lua_State* L, WorldObject* obj)
{
float x, y, z;
obj->GetPosition(x, y, z);
@@ -605,7 +605,7 @@ namespace LuaWorldObject
* @return float y
* @return float z
*/
int GetRelativePoint(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetRelativePoint(lua_State* L, WorldObject* obj)
{
float dist = Eluna::CHECKVAL<float>(L, 2);
float rad = Eluna::CHECKVAL<float>(L, 3);
@@ -633,7 +633,7 @@ namespace LuaWorldObject
*
* @return float angle : angle in radians in range 0..2*pi
*/
int GetAngle(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int GetAngle(lua_State* L, WorldObject* obj)
{
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
@@ -653,7 +653,7 @@ namespace LuaWorldObject
*
* @param [WorldPacket] packet
*/
int SendPacket(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int SendPacket(lua_State* L, WorldObject* obj)
{
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
#ifdef CMANGOS
@@ -675,7 +675,7 @@ namespace LuaWorldObject
* @param uint32 respawnDelay = 30 : respawn time in seconds
* @return [GameObject] gameObject
*/
int SummonGameObject(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int SummonGameObject(lua_State* L, WorldObject* obj)
{
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
float x = Eluna::CHECKVAL<float>(L, 3);
@@ -718,7 +718,7 @@ namespace LuaWorldObject
* @param uint32 despawnTimer = 0 : despawn time in milliseconds
* @return [Creature] spawnedCreature
*/
int SpawnCreature(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int SpawnCreature(lua_State* L, WorldObject* obj)
{
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
float x = Eluna::CHECKVAL<float>(L, 3);
@@ -787,7 +787,7 @@ namespace LuaWorldObject
* @param uint32 repeats : how many times for the event to repeat, 0 is infinite
* @return int eventId : unique ID for the timed event used to cancel it or nil
*/
int RegisterEvent(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int RegisterEvent(lua_State* L, WorldObject* obj)
{
luaL_checktype(L, 2, LUA_TFUNCTION);
uint32 delay = Eluna::CHECKVAL<uint32>(L, 3);
@@ -808,7 +808,7 @@ namespace LuaWorldObject
*
* @param int eventId : event Id to remove
*/
int RemoveEventById(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int RemoveEventById(lua_State* L, WorldObject* obj)
{
int eventId = Eluna::CHECKVAL<int>(L, 2);
obj->elunaEvents->SetState(eventId, LUAEVENT_STATE_ABORT);
@@ -819,7 +819,7 @@ namespace LuaWorldObject
* Removes all timed events from a [WorldObject]
*
*/
int RemoveEvents(Eluna* /*E*/, lua_State* /*L*/, WorldObject* obj)
int RemoveEvents(lua_State* /*L*/, WorldObject* obj)
{
obj->elunaEvents->SetStates(LUAEVENT_STATE_ABORT);
return 0;
@@ -837,7 +837,7 @@ namespace LuaWorldObject
* @param float z
* @return bool isInLoS
*/
int IsWithinLoS(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int IsWithinLoS(lua_State* L, WorldObject* obj)
{
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
@@ -865,7 +865,7 @@ namespace LuaWorldObject
* @param uint32 music : entry of a music
* @param [Player] player = nil : [Player] to play the music to
*/
int PlayMusic(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int PlayMusic(lua_State* L, WorldObject* obj)
{
uint32 musicid = Eluna::CHECKVAL<uint32>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 3, false);
@@ -897,7 +897,7 @@ namespace LuaWorldObject
* @param uint32 sound : entry of a sound
* @param [Player] player = nil : [Player] to play the sound to
*/
int PlayDirectSound(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int PlayDirectSound(lua_State* L, WorldObject* obj)
{
uint32 soundId = Eluna::CHECKVAL<uint32>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 3, false);
@@ -923,7 +923,7 @@ namespace LuaWorldObject
* @param uint32 sound : entry of a sound
* @param [Player] player = nil : [Player] to play the sound to
*/
int PlayDistanceSound(Eluna* /*E*/, lua_State* L, WorldObject* obj)
int PlayDistanceSound(lua_State* L, WorldObject* obj)
{
uint32 soundId = Eluna::CHECKVAL<uint32>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 3, false);