Eluna Removed mutex lock and forced only one map update thread to be used. Made returning more arguments than pushed to return the return amount of nils instead. Removed a few hooks

This commit is contained in:
Rochet2
2014-05-14 12:48:00 +03:00
committed by Foereaper
parent f166732b49
commit 94063c1b7d
15 changed files with 117 additions and 313 deletions

View File

@@ -324,15 +324,12 @@ namespace LuaCreature
uint32 targetType = sEluna->CHECKVAL<uint32>(L, 2);
bool playerOnly = sEluna->CHECKVAL<bool>(L, 3, false);
uint32 position = sEluna->CHECKVAL<uint32>(L, 4, 0);
float dist = sEluna->CHECKVAL<float>(L, 5, 0.0f);
float dist = sEluna->CHECKVAL<float>(L, 5, -1.0f);
int32 aura = sEluna->CHECKVAL<int32>(L, 6, 0);
ThreatList const& threatlist = creature->getThreatManager().getThreatList();
if (position >= threatlist.size())
{
sEluna->Push(L);
return 1;
}
std::list<Unit*> targetList;
for (ThreatList::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
@@ -352,10 +349,7 @@ namespace LuaCreature
}
if (position >= targetList.size())
{
sEluna->Push(L);
return 1;
}
if (targetType == SELECT_TARGET_NEAREST || targetType == SELECT_TARGET_FARTHEST)
targetList.sort(Eluna::ObjectDistanceOrderPred(creature));
@@ -368,7 +362,6 @@ namespace LuaCreature
std::list<Unit*>::const_iterator itr = targetList.begin();
std::advance(itr, position);
sEluna->Push(L, *itr);
return 1;
}
case SELECT_TARGET_FARTHEST:
case SELECT_TARGET_BOTTOMAGGRO:
@@ -376,20 +369,17 @@ namespace LuaCreature
std::list<Unit*>::reverse_iterator ritr = targetList.rbegin();
std::advance(ritr, position);
sEluna->Push(L, *ritr);
return 1;
}
case SELECT_TARGET_RANDOM:
{
std::list<Unit*>::const_iterator itr = targetList.begin();
std::advance(itr, urand(position, targetList.size() - 1));
sEluna->Push(L, *itr);
return 1;
}
default:
luaL_argerror(L, 2, "SelectAggroTarget expected");
}
sEluna->Push(L);
return 1;
}

View File

@@ -24,36 +24,24 @@ namespace LuaGameObject
int IsSpawned(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
sEluna->Push(L, false);
else
sEluna->Push(L, go->isSpawned());
return 1;
}
int IsTransport(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
sEluna->Push(L, false);
else
sEluna->Push(L, go->IsTransport());
return 1;
}
int IsActive(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
sEluna->Push(L, false);
else
sEluna->Push(L, go->isActiveObject());
return 1;
}
/*int IsDestructible(lua_State* L, GameObject* go) // TODO: Implementation core side
{
if (!go || !go->IsInWorld())
sEluna->Push(L, false);
else
sEluna->Push(L, go->IsDestructibleBuilding());
return 1;
}*/
@@ -61,27 +49,18 @@ namespace LuaGameObject
/* GETTERS */
int GetDisplayId(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
sEluna->Push(L, go->GetDisplayId());
return 1;
}
int GetGoState(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
sEluna->Push(L, go->GetGoState());
return 1;
}
int GetLootState(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
sEluna->Push(L, go->getLootState());
return 1;
}
@@ -89,9 +68,6 @@ namespace LuaGameObject
/* SETTERS */
int SetGoState(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
uint32 state = sEluna->CHECKVAL<uint32>(L, 2, 0);
if (state == 0)
@@ -106,9 +82,6 @@ namespace LuaGameObject
int SetLootState(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
uint32 state = sEluna->CHECKVAL<uint32>(L, 2, 0);
if (state == 0)
@@ -132,11 +105,8 @@ namespace LuaGameObject
int RemoveFromWorld(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
bool del = sEluna->CHECKVAL<bool>(L, 2, false);
if (del)
bool deldb = sEluna->CHECKVAL<bool>(L, 2, false);
if (deldb)
go->DeleteFromDB();
go->RemoveFromWorld();
return 0;
@@ -153,8 +123,6 @@ namespace LuaGameObject
functionRef = sEluna->m_EventMgr.AddEvent(&go->m_Events, functionRef, delay, repeats, go);
if (functionRef)
sEluna->Push(L, functionRef);
else
sEluna->Push(L);
return 1;
}
@@ -173,9 +141,6 @@ namespace LuaGameObject
int UseDoorOrButton(lua_State* L, GameObject* go)
{
if (!go || !go->IsInWorld())
return 0;
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2, 0);
go->UseDoorOrButton(delay);

View File

@@ -40,8 +40,6 @@ namespace LuaGlobalFunctions
sEluna->Push(L, 2);
#elif defined(CATA)
sEluna->Push(L, 3);
#else
sEluna->Push(L);
#endif
return 1;
}
@@ -118,7 +116,7 @@ namespace LuaGlobalFunctions
Map* map = sMapMgr->FindMap(mapID, instanceID);
if (!map)
return 0;
return 1;
lua_newtable(L);
int tbl = lua_gettop(L);
@@ -439,7 +437,7 @@ namespace LuaGlobalFunctions
{
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
if (!query)
return 0;
return 1;
QueryResult* result = NULL;
#ifdef MANGOS
@@ -450,7 +448,7 @@ namespace LuaGlobalFunctions
result = new QueryResult(res);
#endif
if (!result)
return 0;
return 1;
sEluna->Push(L, result);
return 1;
@@ -459,6 +457,7 @@ namespace LuaGlobalFunctions
int WorldDBExecute(lua_State* L)
{
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
if (query)
WorldDatabase.Execute(query);
return 0;
}
@@ -466,6 +465,8 @@ namespace LuaGlobalFunctions
int CharDBQuery(lua_State* L)
{
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
if (!query)
return 1;
QueryResult* result = NULL;
#ifdef MANGOS
@@ -476,7 +477,7 @@ namespace LuaGlobalFunctions
result = new QueryResult(res);
#endif
if (!result)
return 0;
return 1;
sEluna->Push(L, result);
return 1;
@@ -485,6 +486,7 @@ namespace LuaGlobalFunctions
int CharDBExecute(lua_State* L)
{
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
if (query)
CharacterDatabase.Execute(query);
return 0;
}
@@ -511,6 +513,7 @@ namespace LuaGlobalFunctions
int AuthDBExecute(lua_State* L)
{
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
if (query)
LoginDatabase.Execute(query);
return 0;
}
@@ -526,8 +529,6 @@ namespace LuaGlobalFunctions
functionRef = sEluna->m_EventMgr.AddEvent(&sEluna->m_EventMgr.GlobalEvents, functionRef, delay, repeats);
if (functionRef)
sEluna->Push(L, functionRef);
else
sEluna->Push(L);
return 1;
}
@@ -569,13 +570,13 @@ namespace LuaGlobalFunctions
#if (!defined(TBC) && !defined(CLASSIC))
uint32 phase = sEluna->CHECKVAL<uint32>(L, 11, PHASEMASK_NORMAL);
if (!phase)
return 0;
return 1;
#endif
#ifdef MANGOS
Map* map = sMapMgr->FindMap(mapID, instanceID);
if (!map)
return 0;
return 1;
if (spawntype == 1) // spawn creature
{
@@ -583,7 +584,7 @@ namespace LuaGlobalFunctions
{
CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(entry);
if (!cinfo)
return 0;
return 1;
#if (defined(TBC) || defined(CLASSIC))
CreatureCreatePos pos(map, x, y, z, o);
@@ -594,12 +595,12 @@ namespace LuaGlobalFunctions
// used guids from specially reserved range (can be 0 if no free values)
uint32 lowguid = sObjectMgr->GenerateStaticCreatureLowGuid();
if (!lowguid)
return 0;
return 1;
if (!pCreature->Create(lowguid, pos, cinfo))
{
delete pCreature;
return 0;
return 1;
}
#ifdef TBC
@@ -626,7 +627,7 @@ namespace LuaGlobalFunctions
{
CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(entry);
if (!cinfo)
return 0;
return 1;
TemporarySummon* pCreature = new TemporarySummon(ObjectGuid(uint64(0)));
#if (defined(TBC) || defined(CLASSIC))
@@ -638,7 +639,7 @@ namespace LuaGlobalFunctions
if (!pCreature->Create(map->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, TEAM_NONE))
{
delete pCreature;
return NULL;
return 1;
}
pCreature->SetRespawnCoord(pos);
@@ -665,12 +666,12 @@ namespace LuaGlobalFunctions
{
const GameObjectInfo* gInfo = ObjectMgr::GetGameObjectInfo(entry);
if (!gInfo)
return 0;
return 1;
// used guids from specially reserved range (can be 0 if no free values)
uint32 db_lowGUID = sObjectMgr->GenerateStaticGameObjectLowGuid();
if (!db_lowGUID)
return 0;
return 1;
GameObject* pGameObj = new GameObject;
#if (defined(TBC) || defined(CLASSIC))
@@ -680,7 +681,7 @@ namespace LuaGlobalFunctions
#endif
{
delete pGameObj;
return 0;
return 1;
}
if (durorresptime)
@@ -699,7 +700,7 @@ namespace LuaGlobalFunctions
if (!pGameObj->LoadFromDB(db_lowGUID, map))
{
delete pGameObj;
return false;
return 1;
}
// DEBUG_LOG(GetMangosString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o);
@@ -721,7 +722,7 @@ namespace LuaGlobalFunctions
#endif
{
delete pGameObj;
return NULL;
return 1;
}
pGameObj->SetRespawnTime(durorresptime / IN_MILLISECONDS);
@@ -735,7 +736,7 @@ namespace LuaGlobalFunctions
#else
Map* map = sMapMgr->FindMap(mapID, instanceID);
if (!map)
return 0;
return 1;
Position pos = { x, y, z, o };
@@ -747,7 +748,7 @@ namespace LuaGlobalFunctions
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, x, y, z, o))
{
delete creature;
return 0;
return 1;
}
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
@@ -756,7 +757,7 @@ namespace LuaGlobalFunctions
if (!creature->LoadCreatureFromDB(db_lowguid, map))
{
delete creature;
return 0;
return 1;
}
sObjectMgr->AddCreatureToGrid(db_lowguid, sObjectMgr->GetCreatureData(db_lowguid));
@@ -766,7 +767,7 @@ namespace LuaGlobalFunctions
{
TempSummon* creature = map->SummonCreature(entry, pos, NULL, durorresptime);
if (!creature)
return 0;
return 1;
if (durorresptime)
creature->SetTempSummonType(TEMPSUMMON_TIMED_OR_DEAD_DESPAWN);
@@ -783,10 +784,10 @@ namespace LuaGlobalFunctions
{
const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(entry);
if (!objectInfo)
return 0;
return 1;
if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
return 0;
return 1;
GameObject* object = new GameObject;
uint32 lowguid = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
@@ -794,7 +795,7 @@ namespace LuaGlobalFunctions
if (!object->Create(lowguid, objectInfo->entry, map, phase, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{
delete object;
return 0;
return 1;
}
if (durorresptime)
@@ -809,7 +810,7 @@ namespace LuaGlobalFunctions
if (!object->LoadGameObjectFromDB(lowguid, map))
{
delete object;
return false;
return 1;
}
sObjectMgr->AddGameobjectToGrid(lowguid, sObjectMgr->GetGOData(lowguid));
@@ -820,7 +821,7 @@ namespace LuaGlobalFunctions
return 1;
}
#endif
return 0;
return 1;
}
// CreatePacket(opcode, size)

View File

@@ -257,17 +257,6 @@ public:
sEluna->ServerEventBindings.EndCall();
}
void OnMotdChange(std::string& newMotd) override
{
if (!sEluna->ServerEventBindings.HasEvents(WORLD_EVENT_ON_MOTD_CHANGE))
return;
ELUNA_GUARD();
sEluna->ServerEventBindings.BeginCall(WORLD_EVENT_ON_MOTD_CHANGE);
sEluna->Push(sEluna->L, newMotd);
sEluna->ServerEventBindings.ExecuteCall();
sEluna->ServerEventBindings.EndCall();
}
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) override
{
if (!sEluna->ServerEventBindings.HasEvents(WORLD_EVENT_ON_SHUTDOWN_INIT))
@@ -592,41 +581,6 @@ void HookMgr::OnQuestAbandon(Player* pPlayer, uint32 questId)
sEluna->PlayerEventBindings.EndCall();
}
void HookMgr::OnGmTicketCreate(Player* pPlayer, std::string& ticketText)
{
if (!sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GM_TICKET_CREATE))
return;
ELUNA_GUARD();
sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GM_TICKET_CREATE);
sEluna->Push(sEluna->L, pPlayer);
sEluna->Push(sEluna->L, ticketText);
sEluna->PlayerEventBindings.ExecuteCall();
sEluna->PlayerEventBindings.EndCall();
}
void HookMgr::OnGmTicketUpdate(Player* pPlayer, std::string& ticketText)
{
if (!sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GM_TICKET_UPDATE))
return;
ELUNA_GUARD();
sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GM_TICKET_UPDATE);
sEluna->Push(sEluna->L, pPlayer);
sEluna->Push(sEluna->L, ticketText);
sEluna->PlayerEventBindings.ExecuteCall();
sEluna->PlayerEventBindings.EndCall();
}
void HookMgr::OnGmTicketDelete(Player* pPlayer)
{
if (!sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GM_TICKET_DELETE))
return;
ELUNA_GUARD();
sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GM_TICKET_DELETE);
sEluna->Push(sEluna->L, pPlayer);
sEluna->PlayerEventBindings.ExecuteCall();
sEluna->PlayerEventBindings.EndCall();
}
void HookMgr::OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot)
{
if (!sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_EQUIP))
@@ -1565,21 +1519,6 @@ bool HookMgr::OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* p
return true;
}
bool HookMgr::OnQuestSelect(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
{
int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_QUEST_SELECT);
if (!bind)
return false;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_QUEST_SELECT);
sEluna->Push(sEluna->L, pPlayer);
sEluna->Push(sEluna->L, pCreature);
sEluna->Push(sEluna->L, pQuest);
sEluna->ExecuteCall(4, 0);
return true;
}
bool HookMgr::OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
{
int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_QUEST_COMPLETE);
@@ -1892,7 +1831,7 @@ struct ElunaCreatureAI : ScriptedAI
// Enables use of MoveInLineOfSight
bool IsVisible(Unit* who) const override
{
return me->IsWithinLOSInMap(who);
return true
}
#endif

View File

@@ -104,7 +104,7 @@ enum ServerEvents
// World // Not implemented on mangos
WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open)
WORLD_EVENT_ON_CONFIG_LOAD = 9, // (event, reload)
WORLD_EVENT_ON_MOTD_CHANGE = 10, // (event, newMOTD)
// UNUSED = 10, // (event)
WORLD_EVENT_ON_SHUTDOWN_INIT = 11, // (event, code, mask)
WORLD_EVENT_ON_SHUTDOWN_CANCEL = 12, // (event)
WORLD_EVENT_ON_UPDATE = 13, // (event, diff)
@@ -183,10 +183,10 @@ enum PlayerEvents
PLAYER_EVENT_ON_REPOP = 35, // (event, player)
PLAYER_EVENT_ON_RESURRECT = 36, // (event, player)
PLAYER_EVENT_ON_LOOT_MONEY = 37, // (event, player, amount)
PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId) // Not on TC
PLAYER_EVENT_ON_GM_TICKET_CREATE = 39, // (event, player, ticketText) // Not on TC
PLAYER_EVENT_ON_GM_TICKET_UPDATE = 40, // (event, player, ticketText) // Not on TC
PLAYER_EVENT_ON_GM_TICKET_DELETE = 41, // (event, player) // Not on TC
PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId)
// UNUSED = 39, // (event, player)
// UNUSED = 40, // (event, player)
// UNUSED = 41, // (event, player)
PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - Can return false
PLAYER_EVENT_COUNT
@@ -267,12 +267,12 @@ enum CreatureEvents
CREATURE_EVENT_ON_REACH_HOME = 24, // (event, creature)
// UNUSED = 25, // (event, creature)
CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay)
CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit)
CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit) // Doesnt actually check LOS
// UNUSED = 28, // (event, creature)
// UNUSED = 29, // (event, creature)
CREATURE_EVENT_ON_DUMMY_EFFECT = 30, // (event, caster, spellid, effindex, creature)
CREATURE_EVENT_ON_QUEST_ACCEPT = 31, // (event, player, creature, quest)
CREATURE_EVENT_ON_QUEST_SELECT = 32, // (event, player, creature, quest)
// UNUSED = 32, // (event, creature)
CREATURE_EVENT_ON_QUEST_COMPLETE = 33, // (event, player, creature, quest)
CREATURE_EVENT_ON_QUEST_REWARD = 34, // (event, player, creature, quest, opt)
CREATURE_EVENT_ON_DIALOG_STATUS = 35, // (event, player, creature)
@@ -339,9 +339,6 @@ public:
void OnRepop(Player* pPlayer);
void OnResurrect(Player* pPlayer);
void OnQuestAbandon(Player* pPlayer, uint32 questId);
void OnGmTicketCreate(Player* pPlayer, std::string& ticketText);
void OnGmTicketUpdate(Player* pPlayer, std::string& ticketText);
void OnGmTicketDelete(Player* pPlayer);
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
void OnEngineRestart();
bool OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel);
@@ -360,7 +357,6 @@ public:
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action);
bool OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code);
bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
bool OnQuestSelect(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
bool OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
bool OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature);

View File

@@ -136,12 +136,13 @@ namespace LuaItem
return 1;
}
/*
int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
{
/*sEluna->Push(L, item->IsRefundExpired());
return 1;*/
return 0; // Temp till supported
sEluna->Push(L, item->IsRefundExpired());
return 1;
}
*/
/* GETTERS */
int GetItemLink(lua_State* L, Item* item)
@@ -271,7 +272,7 @@ namespace LuaItem
uint32 enchant_slot = sEluna->CHECKVAL<uint32>(L, 2);
if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return 0;
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
sEluna->Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot)));
return 1;

View File

@@ -122,6 +122,8 @@ enum SelectAggroTarget
#define Opcodes OpcodesList
#endif
#else
#undef UNORDERED_MAP
#define UNORDERED_MAP std::unordered_map
#ifndef CATA
typedef uint64 ObjectGuid;
#endif
@@ -268,7 +270,18 @@ public:
ElunaRegister<T>* l = static_cast<ElunaRegister<T>*>(lua_touserdata(L, lua_upvalueindex(1)));
if (!obj)
return 0;
return l->mfunc(L, obj);
int args = lua_gettop(L);
int expected = l->mfunc(L, obj);
args = lua_gettop(L) - args;
if (args <= 0 || args > expected)
{
if (args < 0 || args > expected) // Assert instead?
ELUNA_LOG_ERROR("[Eluna]: %s returned unexpected amount of arguments %i out of %i. Report to devs", l->name, args, expected);
return expected;
}
for (; args < expected; ++args)
lua_pushnil(L);
return expected;
}
static int tostringT(lua_State* L)
@@ -455,11 +468,11 @@ class Eluna
{
public:
friend class ScriptMgr;
friend class ACE_Singleton<Eluna, ACE_Null_Mutex>;
// friend class ACE_Singleton<Eluna, ACE_Null_Mutex>;
lua_State* L;
EventMgr m_EventMgr;
ACE_Recursive_Thread_Mutex lock;
// ACE_Recursive_Thread_Mutex lock;
Eluna()
{
@@ -511,7 +524,7 @@ public:
struct EntryBind
{
typedef std::map<int, int> ElunaBindingMap;
typedef std::map<uint32, ElunaBindingMap> ElunaEntryMap;
typedef UNORDERED_MAP<uint32, ElunaBindingMap> ElunaEntryMap;
~EntryBind()
{
@@ -697,46 +710,7 @@ template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error);
#define sEluna ACE_Singleton<Eluna, ACE_Null_Mutex>::instance()
#endif
/*
class FakeLock
{
public:
static bool locked;
FakeLock()
{
if (locked)
printf("ELUNA_GUARD CREATE\n");
locked = true;
}
~FakeLock()
{
if (!locked)
printf("ELUNA_GUARD DELETE\n");
locked = false;
}
};
class FakeRecursiveLock
{
public:
static uint32 locked;
FakeRecursiveLock()
{
++locked;
if (locked > 1)
printf("GUARD LOCK %u\n", locked);
}
~FakeRecursiveLock()
{
if (!locked)
printf("GUARD FAULTY\n");
else if (locked > 1)
printf("GUARD RELE %u\n", locked);
--locked;
}
};
*/
#define ELUNA_GUARD() \
ACE_Guard< ACE_Recursive_Thread_Mutex > ELUNA_GUARD_OBJECT(sEluna->lock);
#define ELUNA_GUARD() // ACE_Guard< ACE_Recursive_Thread_Mutex > ELUNA_GUARD_OBJECT(sEluna->lock);
class LuaTaxiMgr
{

View File

@@ -956,9 +956,6 @@ ElunaRegister<Quest> QuestMethods[] =
#endif
{ "IsRepeatable", &LuaQuest::IsRepeatable }, // :IsRepeatable() - Returns true or false if the quest is repeatable
// Setters
{ "SetFlag", &LuaQuest::SetFlag }, // :SetFlag(flag) - Sets the flag of the quest by the specified flag
{ NULL, NULL },
};

View File

@@ -71,8 +71,7 @@ namespace LuaMap
uint32 phasemask = sEluna->CHECKVAL<uint32>(L, 4, 1);
float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT);
#endif
if (z == INVALID_HEIGHT)
return 0;
if (z != INVALID_HEIGHT)
sEluna->Push(L, z);
return 1;
}

View File

@@ -21,9 +21,8 @@ namespace LuaPlayer
{
uint32 talentId = sEluna->CHECKVAL<uint32>(L, 2);
uint8 spec = sEluna->CHECKVAL<uint8>(L, 3);
if (spec >= MAX_TALENT_SPECS)
sEluna->Push(L, false);
else
if (spec < MAX_TALENT_SPECS)
return 1;
sEluna->Push(L, player->HasTalent(talentId, spec));
return 1;
}
@@ -87,8 +86,6 @@ namespace LuaPlayer
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
if (titleInfo)
sEluna->Push(L, player->HasTitle(titleInfo));
else
sEluna->Push(L, false);
return 1;
}
#endif
@@ -724,7 +721,7 @@ namespace LuaPlayer
int GetGuildName(lua_State* L, Player* player)
{
if (!player->GetGuildId())
return 0;
return 1;
sEluna->Push(L, sGuildMgr->GetGuildNameById(player->GetGuildId()));
return 1;
}
@@ -808,7 +805,7 @@ namespace LuaPlayer
{
uint8 slot = sEluna->CHECKVAL<uint8>(L, 2);
if (slot >= EQUIPMENT_SLOT_END)
return 0;
return 1;
Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
sEluna->Push(L, item);
@@ -953,8 +950,6 @@ namespace LuaPlayer
std::string accName;
if (sAccountMgr->GetName(player->GetSession()->GetAccountId(), accName))
sEluna->Push(L, accName);
else
return 0;
return 1;
}
@@ -1474,9 +1469,8 @@ namespace LuaPlayer
int SendListInventory(lua_State* L, Player* player)
{
WorldObject* obj = sEluna->CHECKOBJ<WorldObject>(L, 2);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
player->GetSession()->SendListInventory(obj->GET_GUID()), entry;
player->GetSession()->SendListInventory(obj->GET_GUID());
return 0;
}
@@ -1802,20 +1796,20 @@ namespace LuaPlayer
uint32 slot = sEluna->CHECKVAL<uint32>(L, 3);
if (slot >= INVENTORY_SLOT_BAG_END)
return 0;
return 1;
if (!item)
{
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
item = Item::CreateItem(entry, 1, player);
if (!item)
return 0;
return 1;
InventoryResult result = player->CanEquipItem(slot, dest, item, false);
if (result != EQUIP_ERR_OK)
{
delete item;
return 0;
return 1;
}
player->ItemAddedQuestCheck(entry, 1);
#if (!defined(TBC) && !defined(CLASSIC))
@@ -1826,7 +1820,7 @@ namespace LuaPlayer
{
InventoryResult result = player->CanEquipItem(slot, dest, item, false);
if (result != EQUIP_ERR_OK)
return 0;
return 1;
player->RemoveItem(item->GetBagSlot(), item->GetSlot(), true);
}
@@ -1905,7 +1899,7 @@ namespace LuaPlayer
};
static const uint32 skillsSize = sizeof(skillsArray) / sizeof(*skillsArray);
for (int i = 0; i < skillsSize; ++i)
for (uint32 i = 0; i < skillsSize; ++i)
{
if (player->HasSkill(skillsArray[i]))
player->UpdateSkill(skillsArray[i], step);

View File

@@ -18,12 +18,11 @@ namespace LuaQuery
int IsNull(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, true);
else
#ifdef MANGOS
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].IsNULL());
#else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].IsNull());
#endif
return 1;
@@ -32,33 +31,23 @@ namespace LuaQuery
/* GETTERS */
int GetColumnCount(lua_State* L, QueryResult* result)
{
if (!result)
sEluna->Push(L, 0);
else
sEluna->Push(L, RESULT->GetFieldCount());
return 1;
}
int GetRowCount(lua_State* L, QueryResult* result)
{
if (!result)
sEluna->Push(L, 0);
else
{
if (RESULT->GetRowCount() > (uint32)-1)
sEluna->Push(L, (uint32)-1);
else
sEluna->Push(L, RESULT->GetRowCount());
}
return 1;
}
int GetBool(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, false);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetBool());
return 1;
}
@@ -66,9 +55,7 @@ namespace LuaQuery
int GetUInt8(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt8());
return 1;
}
@@ -76,9 +63,7 @@ namespace LuaQuery
int GetUInt16(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt16());
return 1;
}
@@ -86,9 +71,7 @@ namespace LuaQuery
int GetUInt32(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt32());
return 1;
}
@@ -96,9 +79,7 @@ namespace LuaQuery
int GetUInt64(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt64());
return 1;
}
@@ -106,9 +87,7 @@ namespace LuaQuery
int GetInt8(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt8());
return 1;
}
@@ -116,9 +95,7 @@ namespace LuaQuery
int GetInt16(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt16());
return 1;
}
@@ -126,9 +103,7 @@ namespace LuaQuery
int GetInt32(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt32());
return 1;
}
@@ -136,9 +111,7 @@ namespace LuaQuery
int GetInt64(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt64());
return 1;
}
@@ -146,9 +119,7 @@ namespace LuaQuery
int GetFloat(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0.0f);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetFloat());
return 1;
}
@@ -156,9 +127,7 @@ namespace LuaQuery
int GetDouble(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, 0.0);
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetDouble());
return 1;
}
@@ -166,9 +135,7 @@ namespace LuaQuery
int GetString(lua_State* L, QueryResult* result)
{
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
if (!result || col >= RESULT->GetFieldCount())
sEluna->Push(L, "");
else
if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetString());
return 1;
}
@@ -176,9 +143,6 @@ namespace LuaQuery
/* OTHER */
int NextRow(lua_State* L, QueryResult* result)
{
if (!result)
sEluna->Push(L, false);
else
sEluna->Push(L, RESULT->NextRow());
return 1;
}

View File

@@ -93,13 +93,5 @@ namespace LuaQuest
sEluna->Push(L, quest->GetMaxLevel());
return 1;
}*/
/* SETTERS */
int SetFlag(lua_State* L, Quest* quest)
{
uint32 flag = sEluna->CHECKVAL<uint32>(L, 2);
quest->SetSpecialFlag((QuestSpecialFlags)flag);
return 0;
}
};
#endif

View File

@@ -55,12 +55,12 @@ namespace LuaSpell
{
#ifdef MANGOS
if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
return 0;
return 3;
float x, y, z;
spell->m_targets.getDestination(x, y, z);
#else
if (!spell->m_targets.HasDst())
return 0;
return 3;
float x, y, z;
spell->m_targets.GetDstPos()->GetPosition(x, y, z);
#endif
@@ -81,8 +81,6 @@ namespace LuaSpell
sEluna->Push(sEluna->L, target);
else if (Unit* target = spell->m_targets.getUnitTarget())
sEluna->Push(sEluna->L, target);
else
sEluna->Push(sEluna->L);
#else
if (GameObject* target = spell->m_targets.GetGOTarget())
sEluna->Push(L, target);
@@ -94,8 +92,6 @@ namespace LuaSpell
sEluna->Push(L, target);
else if (WorldObject* target = spell->m_targets.GetObjectTarget())
sEluna->Push(L, target);
else
sEluna->Push(L);
#endif
return 1;
}

View File

@@ -503,7 +503,7 @@ namespace LuaUnit
uint32 stat = sEluna->CHECKVAL<uint32>(L, 2);
if (stat >= MAX_STATS)
return 0;
return 1;
sEluna->Push(L, unit->GetStat((Stats)stat));
return 1;
@@ -514,7 +514,7 @@ namespace LuaUnit
uint32 spellschool = sEluna->CHECKVAL<uint32>(L, 2);
if (spellschool >= MAX_SPELL_SCHOOL)
return 0;
return 1;
sEluna->Push(L, unit->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + spellschool));
return 1;
@@ -1260,12 +1260,12 @@ namespace LuaUnit
return 0;
}
static void PrepareMove(Unit* unit)
{
unit->GetMotionMaster()->MovementExpired(); // Chase
unit->StopMoving(); // Some
unit->GetMotionMaster()->Clear(); // all
}
// static void PrepareMove(Unit* unit)
// {
// unit->GetMotionMaster()->MovementExpired(); // Chase
// unit->StopMoving(); // Some
// unit->GetMotionMaster()->Clear(); // all
// }
int MoveStop(lua_State* L, Unit* unit)
{
@@ -1479,11 +1479,11 @@ namespace LuaUnit
Unit* target = sEluna->CHECKOBJ<Unit>(L, 3);
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
return 0;
return 1;
#ifdef MANGOS
if (!IsSpellAppliesAura(spellInfo) && !IsSpellHaveEffect(spellInfo, SPELL_EFFECT_PERSISTENT_AREA_AURA))
return 0;
return 1;
SpellAuraHolder* holder = CreateSpellAuraHolder(spellInfo, target, unit);
@@ -1559,8 +1559,6 @@ namespace LuaUnit
functionRef = sEluna->m_EventMgr.AddEvent(&unit->m_Events, functionRef, delay, repeats, unit);
if (functionRef)
sEluna->Push(L, functionRef);
else
sEluna->Push(L);
return 1;
}
@@ -1675,13 +1673,13 @@ namespace LuaUnit
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(61);
if (!properties)
return 0;
return 1;
Position pos;
pos.Relocate(x,y,z,o);
TempSummon* summon = unit->GetMap()->SummonCreature(entry, pos, properties, desp, unit);
if (!summon)
return 0;
return 1;
if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
((Guardian*)summon)->InitStatsForLevel(unit->getLevel());

View File

@@ -283,7 +283,7 @@ namespace LuaWorldObject
return 1;
}
return 0;
return 1;
}
int GetWorldObject(lua_State* L, WorldObject* obj)
@@ -302,7 +302,6 @@ namespace LuaWorldObject
#endif
case HIGHGUID_UNIT:
case HIGHGUID_PET: sEluna->Push(L, obj->GetMap()->GetAnyTypeCreature(ObjectGuid(guid))); break;
default: return 0;
}
#else
switch (GUID_HIPART(guid))
@@ -314,7 +313,6 @@ namespace LuaWorldObject
case HIGHGUID_VEHICLE:
case HIGHGUID_UNIT: sEluna->Push(L, sObjectAccessor->GetCreature(*obj, ObjectGuid(guid))); break;
case HIGHGUID_PET: sEluna->Push(L, sObjectAccessor->GetPet(*obj, ObjectGuid(guid))); break;
default: return 0;
}
#endif
return 1;