mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna
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:
@@ -11,77 +11,77 @@ namespace LuaAura
|
||||
{
|
||||
int GetCaster(lua_State* L, Aura* aura)
|
||||
{
|
||||
sEluna->Push(L, aura->GetCaster());
|
||||
Eluna::Push(L, aura->GetCaster());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCasterGUID(lua_State* L, Aura* aura)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, aura->GetCasterGuid());
|
||||
Eluna::Push(L, aura->GetCasterGuid());
|
||||
#else
|
||||
sEluna->Push(L, aura->GetCasterGUID());
|
||||
Eluna::Push(L, aura->GetCasterGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCasterLevel(lua_State* L, Aura* aura)
|
||||
{
|
||||
sEluna->Push(L, aura->GetCaster()->getLevel());
|
||||
Eluna::Push(L, aura->GetCaster()->getLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, aura->GetAuraDuration());
|
||||
Eluna::Push(L, aura->GetAuraDuration());
|
||||
#else
|
||||
sEluna->Push(L, aura->GetDuration());
|
||||
Eluna::Push(L, aura->GetDuration());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCharges(lua_State* L, Aura* aura)
|
||||
{
|
||||
sEluna->Push(L, aura->GetStackAmount());
|
||||
Eluna::Push(L, aura->GetStackAmount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAuraId(lua_State* L, Aura* aura)
|
||||
{
|
||||
sEluna->Push(L, aura->GetId());
|
||||
Eluna::Push(L, aura->GetId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMaxDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, aura->GetAuraMaxDuration());
|
||||
Eluna::Push(L, aura->GetAuraMaxDuration());
|
||||
#else
|
||||
sEluna->Push(L, aura->GetMaxDuration());
|
||||
Eluna::Push(L, aura->GetMaxDuration());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetStackAmount(lua_State* L, Aura* aura)
|
||||
{
|
||||
sEluna->Push(L, aura->GetStackAmount());
|
||||
Eluna::Push(L, aura->GetStackAmount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetOwner(lua_State* L, Aura* aura)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, aura->GetTarget());
|
||||
Eluna::Push(L, aura->GetTarget());
|
||||
#else
|
||||
sEluna->Push(L, aura->GetOwner());
|
||||
Eluna::Push(L, aura->GetOwner());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SetDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
int duration = Eluna::CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->SetAuraDuration(duration);
|
||||
#else
|
||||
@@ -92,7 +92,7 @@ namespace LuaAura
|
||||
|
||||
int SetMaxDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
int duration = Eluna::CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->SetAuraMaxDuration(duration);
|
||||
#else
|
||||
@@ -103,8 +103,8 @@ namespace LuaAura
|
||||
|
||||
int SetStackAmount(lua_State* L, Aura* aura)
|
||||
{
|
||||
int amount = sEluna->CHECKVAL<int>(L, 2);
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
int amount = Eluna::CHECKVAL<int>(L, 2);
|
||||
int duration = Eluna::CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->SetStackAmount(amount);
|
||||
#else
|
||||
@@ -115,7 +115,7 @@ namespace LuaAura
|
||||
|
||||
int Remove(lua_State* L, Aura* aura)
|
||||
{
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
int duration = Eluna::CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->RemoveAura(aura->GetEffIndex());
|
||||
#else
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace LuaCorpse
|
||||
int GetOwnerGUID(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, corpse->GetOwnerGuid());
|
||||
Eluna::Push(L, corpse->GetOwnerGuid());
|
||||
#else
|
||||
sEluna->Push(L, corpse->GetOwnerGUID());
|
||||
Eluna::Push(L, corpse->GetOwnerGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -23,14 +23,14 @@ namespace LuaCorpse
|
||||
// GetGhostTime()
|
||||
int GetGhostTime(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
sEluna->Push(L, uint32(corpse->GetGhostTime()));
|
||||
Eluna::Push(L, uint32(corpse->GetGhostTime()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// GetType()
|
||||
int GetType(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
sEluna->Push(L, corpse->GetType());
|
||||
Eluna::Push(L, corpse->GetType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,70 +12,70 @@ namespace LuaCreature
|
||||
/* BOOLEAN */
|
||||
int IsReputationGainDisabled(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsReputationGainDisabled());
|
||||
Eluna::Push(L, creature->IsReputationGainDisabled());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsRegeneratingHealth(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->IsRegeneratingHealth());
|
||||
Eluna::Push(L, creature->IsRegeneratingHealth());
|
||||
#else
|
||||
sEluna->Push(L, creature->isRegeneratingHealth());
|
||||
Eluna::Push(L, creature->isRegeneratingHealth());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasInvolvedQuest(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 quest_id = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 quest_id = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->HasInvolvedQuest(quest_id));
|
||||
Eluna::Push(L, creature->HasInvolvedQuest(quest_id));
|
||||
#else
|
||||
sEluna->Push(L, creature->hasInvolvedQuest(quest_id));
|
||||
Eluna::Push(L, creature->hasInvolvedQuest(quest_id));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsTargetAcceptable(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->isTargetableForAttack(target));
|
||||
Eluna::Push(L, creature->isTargetableForAttack(target));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanAssistTo(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* u = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* enemy = sEluna->CHECKOBJ<Unit>(L, 3);
|
||||
bool checkfaction = sEluna->CHECKVAL<bool>(L, 4, true);
|
||||
Unit* u = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
Unit* enemy = Eluna::CHECKOBJ<Unit>(L, 3);
|
||||
bool checkfaction = Eluna::CHECKVAL<bool>(L, 4, true);
|
||||
|
||||
sEluna->Push(L, creature->CanAssistTo(u, enemy, checkfaction));
|
||||
Eluna::Push(L, creature->CanAssistTo(u, enemy, checkfaction));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasSearchedAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->HasSearchedAssistance());
|
||||
Eluna::Push(L, creature->HasSearchedAssistance());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsTappedBy(lua_State* L, Creature* creature)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->isTappedBy(player));
|
||||
Eluna::Push(L, creature->isTappedBy(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasLootRecipient(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->HasLootRecipient());
|
||||
Eluna::Push(L, creature->HasLootRecipient());
|
||||
#else
|
||||
sEluna->Push(L, creature->hasLootRecipient());
|
||||
Eluna::Push(L, creature->hasLootRecipient());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -84,222 +84,222 @@ namespace LuaCreature
|
||||
{
|
||||
#ifdef MANGOS
|
||||
if (CreatureAI* ai = creature->AI())
|
||||
sEluna->Push(L, ai->IsCombatMovement());
|
||||
Eluna::Push(L, ai->IsCombatMovement());
|
||||
else
|
||||
sEluna->Push(L, false);
|
||||
Eluna::Push(L, false);
|
||||
#else
|
||||
sEluna->Push(L, !creature->HasReactState(REACT_PASSIVE));
|
||||
Eluna::Push(L, !creature->HasReactState(REACT_PASSIVE));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanSwim(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->CanSwim());
|
||||
Eluna::Push(L, creature->CanSwim());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanWalk(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->CanWalk());
|
||||
Eluna::Push(L, creature->CanWalk());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsInEvadeMode(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsInEvadeMode());
|
||||
Eluna::Push(L, creature->IsInEvadeMode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsElite(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->IsElite());
|
||||
Eluna::Push(L, creature->IsElite());
|
||||
#else
|
||||
sEluna->Push(L, creature->isElite());
|
||||
Eluna::Push(L, creature->isElite());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsGuard(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsGuard());
|
||||
Eluna::Push(L, creature->IsGuard());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsCivilian(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsCivilian());
|
||||
Eluna::Push(L, creature->IsCivilian());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsRacialLeader(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsRacialLeader());
|
||||
Eluna::Push(L, creature->IsRacialLeader());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsWorldBoss(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->IsWorldBoss());
|
||||
Eluna::Push(L, creature->IsWorldBoss());
|
||||
#else
|
||||
sEluna->Push(L, creature->isWorldBoss());
|
||||
Eluna::Push(L, creature->isWorldBoss());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasCategoryCooldown(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 spell = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 spell = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasCategoryCooldown(spell));
|
||||
Eluna::Push(L, creature->HasCategoryCooldown(spell));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasSpell(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 id = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 id = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasSpell(id));
|
||||
Eluna::Push(L, creature->HasSpell(id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasQuest(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 questId = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 questId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->HasQuest(questId));
|
||||
Eluna::Push(L, creature->HasQuest(questId));
|
||||
#else
|
||||
sEluna->Push(L, creature->hasQuest(questId));
|
||||
Eluna::Push(L, creature->hasQuest(questId));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasSpellCooldown(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 spellId = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 spellId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasSpellCooldown(spellId));
|
||||
Eluna::Push(L, creature->HasSpellCooldown(spellId));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanFly(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->CanFly());
|
||||
Eluna::Push(L, creature->CanFly());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int IsTrigger(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsTrigger());
|
||||
Eluna::Push(L, creature->IsTrigger());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsDamageEnoughForLootingAndReward());
|
||||
Eluna::Push(L, creature->IsDamageEnoughForLootingAndReward());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
bool force = sEluna->CHECKVAL<bool>(L, 3, true);
|
||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
bool force = Eluna::CHECKVAL<bool>(L, 3, true);
|
||||
|
||||
sEluna->Push(L, creature->CanStartAttack(target, force));
|
||||
Eluna::Push(L, creature->CanStartAttack(target, force));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int HasLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint16 lootMode = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasLootMode(lootMode));
|
||||
Eluna::Push(L, creature->HasLootMode(lootMode));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* GETTERS */
|
||||
int GetRespawnDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetRespawnDelay());
|
||||
Eluna::Push(L, creature->GetRespawnDelay());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRespawnRadius(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetRespawnRadius());
|
||||
Eluna::Push(L, creature->GetRespawnRadius());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDefaultMovementType(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetDefaultMovementType());
|
||||
Eluna::Push(L, creature->GetDefaultMovementType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAggroRange(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->GetAttackDistance(target));
|
||||
Eluna::Push(L, creature->GetAttackDistance(target));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAttackDistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->GetAttackDistance(target));
|
||||
Eluna::Push(L, creature->GetAttackDistance(target));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLootRecipientGroup(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->GetGroupLootRecipient());
|
||||
Eluna::Push(L, creature->GetGroupLootRecipient());
|
||||
#else
|
||||
sEluna->Push(L, creature->GetLootRecipientGroup());
|
||||
Eluna::Push(L, creature->GetLootRecipientGroup());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLootRecipient(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetLootRecipient());
|
||||
Eluna::Push(L, creature->GetLootRecipient());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetScriptName(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetScriptName());
|
||||
Eluna::Push(L, creature->GetScriptName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAIName(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetAIName());
|
||||
Eluna::Push(L, creature->GetAIName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetScriptId(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetScriptId());
|
||||
Eluna::Push(L, creature->GetScriptId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCreatureSpellCooldownDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 spell = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 spell = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->GetCreatureSpellCooldownDelay(spell));
|
||||
Eluna::Push(L, creature->GetCreatureSpellCooldownDelay(spell));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCorpseDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetCorpseDelay());
|
||||
Eluna::Push(L, creature->GetCorpseDelay());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -312,20 +312,20 @@ namespace LuaCreature
|
||||
creature->GetHomePosition(x, y, z, o);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, x);
|
||||
sEluna->Push(L, y);
|
||||
sEluna->Push(L, z);
|
||||
sEluna->Push(L, o);
|
||||
Eluna::Push(L, x);
|
||||
Eluna::Push(L, y);
|
||||
Eluna::Push(L, z);
|
||||
Eluna::Push(L, o);
|
||||
return 4;
|
||||
}
|
||||
|
||||
int GetAITarget(lua_State* L, Creature* creature)
|
||||
{
|
||||
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, -1.0f);
|
||||
int32 aura = sEluna->CHECKVAL<int32>(L, 6, 0);
|
||||
uint32 targetType = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
bool playerOnly = Eluna::CHECKVAL<bool>(L, 3, false);
|
||||
uint32 position = Eluna::CHECKVAL<uint32>(L, 4, 0);
|
||||
float dist = Eluna::CHECKVAL<float>(L, 5, -1.0f);
|
||||
int32 aura = Eluna::CHECKVAL<int32>(L, 6, 0);
|
||||
|
||||
ThreatList const& threatlist = creature->getThreatManager().getThreatList();
|
||||
if (position >= threatlist.size())
|
||||
@@ -361,20 +361,20 @@ namespace LuaCreature
|
||||
{
|
||||
std::list<Unit*>::const_iterator itr = targetList.begin();
|
||||
std::advance(itr, position);
|
||||
sEluna->Push(L, *itr);
|
||||
Eluna::Push(L, *itr);
|
||||
}
|
||||
case SELECT_TARGET_FARTHEST:
|
||||
case SELECT_TARGET_BOTTOMAGGRO:
|
||||
{
|
||||
std::list<Unit*>::reverse_iterator ritr = targetList.rbegin();
|
||||
std::advance(ritr, position);
|
||||
sEluna->Push(L, *ritr);
|
||||
Eluna::Push(L, *ritr);
|
||||
}
|
||||
case SELECT_TARGET_RANDOM:
|
||||
{
|
||||
std::list<Unit*>::const_iterator itr = targetList.begin();
|
||||
std::advance(itr, urand(position, targetList.size() - 1));
|
||||
sEluna->Push(L, *itr);
|
||||
Eluna::Push(L, *itr);
|
||||
}
|
||||
default:
|
||||
luaL_argerror(L, 2, "SelectAggroTarget expected");
|
||||
@@ -397,8 +397,8 @@ namespace LuaCreature
|
||||
if (!target)
|
||||
continue;
|
||||
++i;
|
||||
sEluna->Push(L, i);
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, i);
|
||||
Eluna::Push(L, target);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
|
||||
@@ -408,34 +408,34 @@ namespace LuaCreature
|
||||
|
||||
int GetAITargetsCount(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->getThreatManager().getThreatList().size());
|
||||
Eluna::Push(L, creature->getThreatManager().getThreatList().size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNPCFlags(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetUInt32Value(UNIT_NPC_FLAGS));
|
||||
Eluna::Push(L, creature->GetUInt32Value(UNIT_NPC_FLAGS));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CATA
|
||||
int GetShieldBlockValue(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetShieldBlockValue());
|
||||
Eluna::Push(L, creature->GetShieldBlockValue());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
sEluna->Push(L, creature->GetLootMode());
|
||||
Eluna::Push(L, creature->GetLootMode());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* SETTERS */
|
||||
int SetNPCFlags(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 flags = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 flags = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
creature->SetUInt32Value(UNIT_NPC_FLAGS, flags);
|
||||
return 0;
|
||||
@@ -443,7 +443,7 @@ namespace LuaCreature
|
||||
|
||||
int SetDeathState(lua_State* L, Creature* creature)
|
||||
{
|
||||
int32 state = sEluna->CHECKVAL<int32>(L, 2);
|
||||
int32 state = Eluna::CHECKVAL<int32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->SetDeathState((DeathState)state);
|
||||
@@ -455,7 +455,7 @@ namespace LuaCreature
|
||||
|
||||
int SetWalk(lua_State* L, Creature* creature) // TODO: Move same to Player ?
|
||||
{
|
||||
bool enable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetWalk(enable);
|
||||
return 0;
|
||||
@@ -463,7 +463,7 @@ namespace LuaCreature
|
||||
|
||||
int SetAllowedCombat(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool allow = sEluna->CHECKVAL<bool>(L, 2);
|
||||
bool allow = Eluna::CHECKVAL<bool>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
if (CreatureAI* ai = creature->AI())
|
||||
@@ -476,7 +476,7 @@ namespace LuaCreature
|
||||
|
||||
int SetDisableReputationGain(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool disable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool disable = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetDisableReputationGain(disable);
|
||||
return 0;
|
||||
@@ -490,7 +490,7 @@ namespace LuaCreature
|
||||
|
||||
int SetRespawnRadius(lua_State* L, Creature* creature)
|
||||
{
|
||||
float dist = sEluna->CHECKVAL<float>(L, 2);
|
||||
float dist = Eluna::CHECKVAL<float>(L, 2);
|
||||
|
||||
creature->SetRespawnRadius(dist);
|
||||
return 0;
|
||||
@@ -498,7 +498,7 @@ namespace LuaCreature
|
||||
|
||||
int SetRespawnDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 delay = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
creature->SetRespawnDelay(delay);
|
||||
return 0;
|
||||
@@ -506,7 +506,7 @@ namespace LuaCreature
|
||||
|
||||
int SetDefaultMovementType(lua_State* L, Creature* creature)
|
||||
{
|
||||
int32 type = sEluna->CHECKVAL<int32>(L, 2);
|
||||
int32 type = Eluna::CHECKVAL<int32>(L, 2);
|
||||
|
||||
creature->SetDefaultMovementType((MovementGeneratorType)type);
|
||||
return 0;
|
||||
@@ -514,7 +514,7 @@ namespace LuaCreature
|
||||
|
||||
int SetNoSearchAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool val = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool val = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetNoSearchAssistance(val);
|
||||
return 0;
|
||||
@@ -522,7 +522,7 @@ namespace LuaCreature
|
||||
|
||||
int SetNoCallAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool val = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool val = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetNoCallAssistance(val);
|
||||
return 0;
|
||||
@@ -530,7 +530,7 @@ namespace LuaCreature
|
||||
|
||||
int SetHover(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool enable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->SetLevitate(enable);
|
||||
@@ -542,7 +542,7 @@ namespace LuaCreature
|
||||
|
||||
/*int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint16 lootMode = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
|
||||
creature->SetLootMode(lootMode);
|
||||
return 0;
|
||||
@@ -550,17 +550,17 @@ namespace LuaCreature
|
||||
|
||||
/*int SetDisableGravity(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool disable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool packetOnly = sEluna->CHECKVAL<bool>(L, 3, false);
|
||||
bool disable = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
bool packetOnly = Eluna::CHECKVAL<bool>(L, 3, false);
|
||||
|
||||
sEluna->Push(L, creature->SetDisableGravity(disable, packetOnly));
|
||||
Eluna::Push(L, creature->SetDisableGravity(disable, packetOnly));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* OTHER */
|
||||
int DespawnOrUnsummon(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 msTimeToDespawn = sEluna->CHECKVAL<uint32>(L, 2, 0);
|
||||
uint32 msTimeToDespawn = Eluna::CHECKVAL<uint32>(L, 2, 0);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->ForcedDespawn(msTimeToDespawn);
|
||||
@@ -600,7 +600,7 @@ namespace LuaCreature
|
||||
|
||||
int CallForHelp(lua_State* L, Creature* creature)
|
||||
{
|
||||
float radius = sEluna->CHECKVAL<float>(L, 2);
|
||||
float radius = Eluna::CHECKVAL<float>(L, 2);
|
||||
|
||||
creature->CallForHelp(radius);
|
||||
return 0;
|
||||
@@ -614,7 +614,7 @@ namespace LuaCreature
|
||||
|
||||
int AttackStart(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
creature->AI()->AttackStart(target);
|
||||
return 0;
|
||||
@@ -629,9 +629,9 @@ namespace LuaCreature
|
||||
int SelectVictim(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->SelectHostileTarget());
|
||||
Eluna::Push(L, creature->SelectHostileTarget());
|
||||
#else
|
||||
sEluna->Push(L, creature->SelectVictim());
|
||||
Eluna::Push(L, creature->SelectVictim());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -644,7 +644,7 @@ namespace LuaCreature
|
||||
|
||||
/*int RemoveLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint16 lootMode = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
|
||||
creature->RemoveLootMode(lootMode);
|
||||
return 0;
|
||||
@@ -652,7 +652,7 @@ namespace LuaCreature
|
||||
|
||||
/*int AddLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint16 lootMode = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
|
||||
creature->AddLootMode(lootMode);
|
||||
return 0;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
393
GlobalMethods.h
393
GlobalMethods.h
@@ -7,62 +7,60 @@
|
||||
#ifndef GLOBALMETHODS_H
|
||||
#define GLOBALMETHODS_H
|
||||
|
||||
extern bool StartEluna();
|
||||
|
||||
namespace LuaGlobalFunctions
|
||||
{
|
||||
/* GETTERS */
|
||||
int GetLuaEngine(lua_State* L)
|
||||
{
|
||||
sEluna->Push(L, "ElunaEngine");
|
||||
Eluna::Push(L, "ElunaEngine");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCoreName(lua_State* L)
|
||||
{
|
||||
sEluna->Push(L, CORE_NAME);
|
||||
Eluna::Push(L, CORE_NAME);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCoreVersion(lua_State* L)
|
||||
{
|
||||
sEluna->Push(L, CORE_VERSION);
|
||||
Eluna::Push(L, CORE_VERSION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCoreExpansion(lua_State* L)
|
||||
{
|
||||
#ifdef CLASSIC
|
||||
sEluna->Push(L, 0);
|
||||
Eluna::Push(L, 0);
|
||||
#elif defined(TBC)
|
||||
sEluna->Push(L, 1);
|
||||
Eluna::Push(L, 1);
|
||||
#elif defined(WOTLK)
|
||||
sEluna->Push(L, 2);
|
||||
Eluna::Push(L, 2);
|
||||
#elif defined(CATA)
|
||||
sEluna->Push(L, 3);
|
||||
Eluna::Push(L, 3);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetQuest(lua_State* L)
|
||||
{
|
||||
uint32 questId = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 questId = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
|
||||
sEluna->Push(L, sObjectMgr->GetQuestTemplate(questId));
|
||||
Eluna::Push(L, sObjectMgr->GetQuestTemplate(questId));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayerByGUID(lua_State* L)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1);
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(ObjectGuid(guid)));
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
|
||||
Eluna::Push(L, sObjectAccessor->FindPlayer(ObjectGuid(guid)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayerByName(lua_State* L)
|
||||
{
|
||||
const char* message = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayerByName(message));
|
||||
const char* message = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
Eluna::Push(L, sObjectAccessor->FindPlayerByName(message));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -70,16 +68,16 @@ namespace LuaGlobalFunctions
|
||||
{
|
||||
time_t time = sWorld->GetGameTime();
|
||||
if (time < 0)
|
||||
sEluna->Push(L, int32(time));
|
||||
Eluna::Push(L, int32(time));
|
||||
else
|
||||
sEluna->Push(L, uint32(time));
|
||||
Eluna::Push(L, uint32(time));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayersInWorld(lua_State* L)
|
||||
{
|
||||
uint32 team = sEluna->CHECKVAL<uint32>(L, 1, TEAM_NEUTRAL);
|
||||
bool onlyGM = sEluna->CHECKVAL<bool>(L, 2, false);
|
||||
uint32 team = Eluna::CHECKVAL<uint32>(L, 1, TEAM_NEUTRAL);
|
||||
bool onlyGM = Eluna::CHECKVAL<bool>(L, 2, false);
|
||||
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
@@ -97,8 +95,8 @@ namespace LuaGlobalFunctions
|
||||
#endif
|
||||
{
|
||||
++i;
|
||||
sEluna->Push(L, i);
|
||||
sEluna->Push(L, player);
|
||||
Eluna::Push(L, i);
|
||||
Eluna::Push(L, player);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
}
|
||||
@@ -110,9 +108,9 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int GetPlayersInMap(lua_State* L)
|
||||
{
|
||||
uint32 mapID = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 instanceID = sEluna->CHECKVAL<uint32>(L, 2, 0);
|
||||
uint32 team = sEluna->CHECKVAL<uint32>(L, 3, TEAM_NEUTRAL);
|
||||
uint32 mapID = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 instanceID = Eluna::CHECKVAL<uint32>(L, 2, 0);
|
||||
uint32 team = Eluna::CHECKVAL<uint32>(L, 3, TEAM_NEUTRAL);
|
||||
|
||||
Map* map = sMapMgr->FindMap(mapID, instanceID);
|
||||
if (!map)
|
||||
@@ -135,8 +133,8 @@ namespace LuaGlobalFunctions
|
||||
if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team))
|
||||
{
|
||||
++i;
|
||||
sEluna->Push(L, i);
|
||||
sEluna->Push(L, player);
|
||||
Eluna::Push(L, i);
|
||||
Eluna::Push(L, player);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
}
|
||||
@@ -147,69 +145,69 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int GetGuildByName(lua_State* L)
|
||||
{
|
||||
const char* name = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
sEluna->Push(L, sGuildMgr->GetGuildByName(name));
|
||||
const char* name = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
Eluna::Push(L, sGuildMgr->GetGuildByName(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMapById(lua_State* L)
|
||||
{
|
||||
uint32 mapid = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 instance = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 mapid = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 instance = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, sMapMgr->FindMap(mapid, instance));
|
||||
Eluna::Push(L, sMapMgr->FindMap(mapid, instance));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGuildByLeaderGUID(lua_State* L)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1);
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
|
||||
|
||||
sEluna->Push(L, sGuildMgr->GetGuildByLeader(ObjectGuid(guid)));
|
||||
Eluna::Push(L, sGuildMgr->GetGuildByLeader(ObjectGuid(guid)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayerCount(lua_State* L)
|
||||
{
|
||||
sEluna->Push(L, sWorld->GetActiveSessionCount());
|
||||
Eluna::Push(L, sWorld->GetActiveSessionCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayerGUID(lua_State* L)
|
||||
{
|
||||
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
sEluna->Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER));
|
||||
uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
Eluna::Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetItemGUID(lua_State* L)
|
||||
{
|
||||
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
sEluna->Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM));
|
||||
uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
Eluna::Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetObjectGUID(lua_State* L)
|
||||
{
|
||||
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT));
|
||||
uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUnitGUID(lua_State* L)
|
||||
{
|
||||
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT));
|
||||
uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUIDLow(lua_State* L)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1);
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
|
||||
|
||||
sEluna->Push(L, GUID_LOPART(guid));
|
||||
Eluna::Push(L, GUID_LOPART(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -226,8 +224,8 @@ namespace LuaGlobalFunctions
|
||||
LOCALE_esMX = 7,
|
||||
LOCALE_ruRU = 8
|
||||
*/
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
int loc_idx = sEluna->CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
int loc_idx = Eluna::CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
|
||||
if (loc_idx < 0 || loc_idx >= MAX_LOCALES)
|
||||
return luaL_argerror(L, 2, "valid LocaleConstant expected");
|
||||
|
||||
@@ -247,28 +245,28 @@ namespace LuaGlobalFunctions
|
||||
#endif
|
||||
"0:0:0:0|h[" << name << "]|h|r";
|
||||
|
||||
sEluna->Push(L, oss.str());
|
||||
Eluna::Push(L, oss.str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUIDType(lua_State* L)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1);
|
||||
sEluna->Push(L, GUID_HIPART(guid));
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
|
||||
Eluna::Push(L, GUID_HIPART(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUIDEntry(lua_State* L)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1);
|
||||
sEluna->Push(L, GUID_ENPART(guid));
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
|
||||
Eluna::Push(L, GUID_ENPART(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAreaName(lua_State* L)
|
||||
{
|
||||
uint32 areaOrZoneId = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
int locale = sEluna->CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
|
||||
uint32 areaOrZoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
int locale = Eluna::CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
|
||||
if (locale < 0 || locale >= MAX_LOCALES)
|
||||
return luaL_argerror(L, 2, "Invalid locale specified");
|
||||
|
||||
@@ -276,25 +274,26 @@ namespace LuaGlobalFunctions
|
||||
if (!areaEntry)
|
||||
return luaL_argerror(L, 1, "Invalid Area or Zone ID");
|
||||
|
||||
sEluna->Push(L, areaEntry->area_name[locale]);
|
||||
Eluna::Push(L, areaEntry->area_name[locale]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int RegisterPacketEvent(lua_State* L)
|
||||
{
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 2);
|
||||
int functionRef = lua_ref(L, true);
|
||||
if (functionRef > 0)
|
||||
sEluna->Register(REGTYPE_PACKET, 0, ev, functionRef);
|
||||
sEluna->Register(REGTYPE_PACKET, entry, ev, functionRef);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RegisterServerEvent(lua_State* L)
|
||||
{
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 2);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -305,7 +304,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterPlayerEvent(lua_State* L)
|
||||
{
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 2);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -316,7 +315,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterGuildEvent(lua_State* L)
|
||||
{
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 2);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -327,7 +326,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterGroupEvent(lua_State* L)
|
||||
{
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 2);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -338,8 +337,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterCreatureGossipEvent(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -350,8 +349,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterGameObjectGossipEvent(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -362,8 +361,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterItemEvent(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -374,8 +373,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterItemGossipEvent(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -386,8 +385,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterPlayerGossipEvent(lua_State* L)
|
||||
{
|
||||
uint32 menu_id = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 menu_id = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -398,8 +397,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterCreatureEvent(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -410,8 +409,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RegisterGameObjectEvent(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, 3);
|
||||
int functionRef = lua_ref(L, true);
|
||||
@@ -422,20 +421,20 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int ReloadEluna(lua_State* L)
|
||||
{
|
||||
sEluna->Push(L, StartEluna());
|
||||
return 1;
|
||||
Eluna::ReloadEluna();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SendWorldMessage(lua_State* L)
|
||||
{
|
||||
const char* message = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* message = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
sWorld->SendServerMessage(SERVER_MSG_STRING, message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WorldDBQuery(lua_State* L)
|
||||
{
|
||||
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
if (!query)
|
||||
return 1;
|
||||
|
||||
@@ -450,13 +449,13 @@ namespace LuaGlobalFunctions
|
||||
if (!result)
|
||||
return 1;
|
||||
|
||||
sEluna->Push(L, result);
|
||||
Eluna::Push(L, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int WorldDBExecute(lua_State* L)
|
||||
{
|
||||
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
if (query)
|
||||
WorldDatabase.Execute(query);
|
||||
return 0;
|
||||
@@ -464,7 +463,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int CharDBQuery(lua_State* L)
|
||||
{
|
||||
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
if (!query)
|
||||
return 1;
|
||||
|
||||
@@ -479,13 +478,13 @@ namespace LuaGlobalFunctions
|
||||
if (!result)
|
||||
return 1;
|
||||
|
||||
sEluna->Push(L, result);
|
||||
Eluna::Push(L, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CharDBExecute(lua_State* L)
|
||||
{
|
||||
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
if (query)
|
||||
CharacterDatabase.Execute(query);
|
||||
return 0;
|
||||
@@ -493,7 +492,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int AuthDBQuery(lua_State* L)
|
||||
{
|
||||
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
QueryResult* result = NULL;
|
||||
#ifdef MANGOS
|
||||
@@ -506,13 +505,13 @@ namespace LuaGlobalFunctions
|
||||
if (!result)
|
||||
return 0;
|
||||
|
||||
sEluna->Push(L, result);
|
||||
Eluna::Push(L, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AuthDBExecute(lua_State* L)
|
||||
{
|
||||
const char* query = sEluna->CHECKVAL<const char*>(L, 1);
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
if (query)
|
||||
LoginDatabase.Execute(query);
|
||||
return 0;
|
||||
@@ -521,54 +520,54 @@ namespace LuaGlobalFunctions
|
||||
int CreateLuaEvent(lua_State* L)
|
||||
{
|
||||
luaL_checktype(L, 1, LUA_TFUNCTION);
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 repeats = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint32 delay = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
uint32 repeats = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
lua_pushvalue(L, 1);
|
||||
int functionRef = lua_ref(L, true);
|
||||
functionRef = sEluna->m_EventMgr.AddEvent(&sEluna->m_EventMgr.GlobalEvents, functionRef, delay, repeats);
|
||||
functionRef = sEluna->m_EventMgr->AddEvent(&sEluna->m_EventMgr->GlobalEvents, functionRef, delay, repeats);
|
||||
if (functionRef)
|
||||
sEluna->Push(L, functionRef);
|
||||
Eluna::Push(L, functionRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RemoveEventById(lua_State* L)
|
||||
{
|
||||
int eventId = sEluna->CHECKVAL<int>(L, 1);
|
||||
bool all_Events = sEluna->CHECKVAL<bool>(L, 1, false);
|
||||
int eventId = Eluna::CHECKVAL<int>(L, 1);
|
||||
bool all_Events = Eluna::CHECKVAL<bool>(L, 1, false);
|
||||
|
||||
if (all_Events)
|
||||
sEluna->m_EventMgr.RemoveEvent(eventId);
|
||||
sEluna->m_EventMgr->RemoveEvent(eventId);
|
||||
else
|
||||
sEluna->m_EventMgr.RemoveEvent(&sEluna->m_EventMgr.GlobalEvents, eventId);
|
||||
sEluna->m_EventMgr->RemoveEvent(&sEluna->m_EventMgr->GlobalEvents, eventId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RemoveEvents(lua_State* L)
|
||||
{
|
||||
bool all_Events = sEluna->CHECKVAL<bool>(L, 1, false);
|
||||
bool all_Events = Eluna::CHECKVAL<bool>(L, 1, false);
|
||||
|
||||
if (all_Events)
|
||||
sEluna->m_EventMgr.RemoveEvents();
|
||||
sEluna->m_EventMgr->RemoveEvents();
|
||||
else
|
||||
sEluna->m_EventMgr.GlobalEvents.KillAllEvents(true);
|
||||
sEluna->m_EventMgr->GlobalEvents.KillAllEvents(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PerformIngameSpawn(lua_State* L)
|
||||
{
|
||||
int spawntype = sEluna->CHECKVAL<int>(L, 1);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 mapID = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint32 instanceID = sEluna->CHECKVAL<uint32>(L, 4);
|
||||
float x = sEluna->CHECKVAL<float>(L, 5);
|
||||
float y = sEluna->CHECKVAL<float>(L, 6);
|
||||
float z = sEluna->CHECKVAL<float>(L, 7);
|
||||
float o = sEluna->CHECKVAL<float>(L, 8);
|
||||
bool save = sEluna->CHECKVAL<bool>(L, 9, false);
|
||||
uint32 durorresptime = sEluna->CHECKVAL<uint32>(L, 10, 0);
|
||||
int spawntype = Eluna::CHECKVAL<int>(L, 1);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
uint32 mapID = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
uint32 instanceID = Eluna::CHECKVAL<uint32>(L, 4);
|
||||
float x = Eluna::CHECKVAL<float>(L, 5);
|
||||
float y = Eluna::CHECKVAL<float>(L, 6);
|
||||
float z = Eluna::CHECKVAL<float>(L, 7);
|
||||
float o = Eluna::CHECKVAL<float>(L, 8);
|
||||
bool save = Eluna::CHECKVAL<bool>(L, 9, false);
|
||||
uint32 durorresptime = Eluna::CHECKVAL<uint32>(L, 10, 0);
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
uint32 phase = sEluna->CHECKVAL<uint32>(L, 11, PHASEMASK_NORMAL);
|
||||
uint32 phase = Eluna::CHECKVAL<uint32>(L, 11, PHASEMASK_NORMAL);
|
||||
if (!phase)
|
||||
return 1;
|
||||
#endif
|
||||
@@ -621,7 +620,7 @@ namespace LuaGlobalFunctions
|
||||
if (durorresptime)
|
||||
pCreature->ForcedDespawn(durorresptime);
|
||||
|
||||
sEluna->Push(L, pCreature);
|
||||
Eluna::Push(L, pCreature);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -654,7 +653,7 @@ namespace LuaGlobalFunctions
|
||||
if (pCreature->IsLinkingEventTrigger())
|
||||
map->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature);
|
||||
|
||||
sEluna->Push(L, pCreature);
|
||||
Eluna::Push(L, pCreature);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -709,7 +708,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
|
||||
|
||||
sEluna->Push(L, pGameObj);
|
||||
Eluna::Push(L, pGameObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -729,7 +728,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
map->Add(pGameObj);
|
||||
|
||||
sEluna->Push(L, pGameObj);
|
||||
Eluna::Push(L, pGameObj);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -761,7 +760,7 @@ namespace LuaGlobalFunctions
|
||||
}
|
||||
|
||||
sObjectMgr->AddCreatureToGrid(db_lowguid, sObjectMgr->GetCreatureData(db_lowguid));
|
||||
sEluna->Push(L, creature);
|
||||
Eluna::Push(L, creature);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -774,7 +773,7 @@ namespace LuaGlobalFunctions
|
||||
else
|
||||
creature->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN);
|
||||
|
||||
sEluna->Push(L, creature);
|
||||
Eluna::Push(L, creature);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -817,7 +816,7 @@ namespace LuaGlobalFunctions
|
||||
}
|
||||
else
|
||||
map->AddToMap(object);
|
||||
sEluna->Push(L, object);
|
||||
Eluna::Push(L, object);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@@ -827,22 +826,22 @@ namespace LuaGlobalFunctions
|
||||
// CreatePacket(opcode, size)
|
||||
int CreatePacket(lua_State* L)
|
||||
{
|
||||
uint32 opcode = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 size = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 opcode = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 size = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (opcode >= NUM_MSG_TYPES)
|
||||
return luaL_argerror(L, 1, "valid opcode expected");
|
||||
|
||||
sEluna->Push(L, new WorldPacket((Opcodes)opcode, size));
|
||||
Eluna::Push(L, new WorldPacket((Opcodes)opcode, size));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AddVendorItem(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 item = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
int maxcount = sEluna->CHECKVAL<int>(L, 3);
|
||||
uint32 incrtime = sEluna->CHECKVAL<uint32>(L, 4);
|
||||
uint32 extendedcost = sEluna->CHECKVAL<uint32>(L, 5);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 item = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
int maxcount = Eluna::CHECKVAL<int>(L, 3);
|
||||
uint32 incrtime = Eluna::CHECKVAL<uint32>(L, 4);
|
||||
uint32 extendedcost = Eluna::CHECKVAL<uint32>(L, 5);
|
||||
|
||||
#ifdef MANGOS
|
||||
if (!sObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0))
|
||||
@@ -868,8 +867,8 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int VendorRemoveItem(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 item = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 item = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (!sObjectMgr->GetCreatureTemplate(entry))
|
||||
return luaL_argerror(L, 1, "valid CreatureEntry expected");
|
||||
|
||||
@@ -883,7 +882,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int VendorRemoveAllItems(lua_State* L)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
|
||||
VendorItemData const* items = sObjectMgr->GetNpcVendorItemList(entry);
|
||||
if (!items || items->Empty())
|
||||
@@ -901,18 +900,18 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int Kick(lua_State* L)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 1);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 1);
|
||||
player->GetSession()->KickPlayer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Ban(lua_State* L)
|
||||
{
|
||||
int banMode = sEluna->CHECKVAL<int>(L, 1);
|
||||
const char* nameOrIP_cstr = sEluna->CHECKVAL<const char*>(L, 2);
|
||||
uint32 duration = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
const char* reason = sEluna->CHECKVAL<const char*>(L, 4);
|
||||
Player* whoBanned = sEluna->CHECKOBJ<Player>(L, 5);
|
||||
int banMode = Eluna::CHECKVAL<int>(L, 1);
|
||||
const char* nameOrIP_cstr = Eluna::CHECKVAL<const char*>(L, 2);
|
||||
uint32 duration = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
const char* reason = Eluna::CHECKVAL<const char*>(L, 4);
|
||||
Player* whoBanned = Eluna::CHECKOBJ<Player>(L, 5);
|
||||
std::string nameOrIP(nameOrIP_cstr);
|
||||
|
||||
switch (banMode)
|
||||
@@ -958,12 +957,12 @@ namespace LuaGlobalFunctions
|
||||
int SendMail(lua_State* L)
|
||||
{
|
||||
int i = 0;
|
||||
std::string subject = sEluna->CHECKVAL<std::string>(L, ++i);
|
||||
std::string text = sEluna->CHECKVAL<std::string>(L, ++i);
|
||||
uint32 receiverGUIDLow = sEluna->CHECKVAL<uint32>(L, ++i);
|
||||
uint32 senderGUIDLow = sEluna->CHECKVAL<uint32>(L, ++i, 0);
|
||||
uint32 stationary = sEluna->CHECKVAL<uint32>(L, ++i, MAIL_STATIONERY_DEFAULT);
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(L, ++i, 0);
|
||||
std::string subject = Eluna::CHECKVAL<std::string>(L, ++i);
|
||||
std::string text = Eluna::CHECKVAL<std::string>(L, ++i);
|
||||
uint32 receiverGUIDLow = Eluna::CHECKVAL<uint32>(L, ++i);
|
||||
uint32 senderGUIDLow = Eluna::CHECKVAL<uint32>(L, ++i, 0);
|
||||
uint32 stationary = Eluna::CHECKVAL<uint32>(L, ++i, MAIL_STATIONERY_DEFAULT);
|
||||
uint32 delay = Eluna::CHECKVAL<uint32>(L, ++i, 0);
|
||||
int argAmount = lua_gettop(L);
|
||||
|
||||
MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary);
|
||||
@@ -1018,53 +1017,53 @@ namespace LuaGlobalFunctions
|
||||
// bit_and(a, b)
|
||||
int bit_and(lua_State* L)
|
||||
{
|
||||
uint32 a = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, a & b);
|
||||
uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, a & b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// bit_or(a, b)
|
||||
int bit_or(lua_State* L)
|
||||
{
|
||||
uint32 a = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, a | b);
|
||||
uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, a | b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// bit_lshift(a, b)
|
||||
int bit_lshift(lua_State* L)
|
||||
{
|
||||
uint32 a = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, a << b);
|
||||
uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, a << b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// bit_rshift(a, b)
|
||||
int bit_rshift(lua_State* L)
|
||||
{
|
||||
uint32 a = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, a >> b);
|
||||
uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, a >> b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// bit_xor(a, b)
|
||||
int bit_xor(lua_State* L)
|
||||
{
|
||||
uint32 a = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
sEluna->Push(L, a ^ b);
|
||||
uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, a ^ b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// bit_not(a)
|
||||
int bit_not(lua_State* L)
|
||||
{
|
||||
uint32 a = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
sEluna->Push(L, ~a);
|
||||
uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
Eluna::Push(L, ~a);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1072,10 +1071,10 @@ namespace LuaGlobalFunctions
|
||||
int AddTaxiPath(lua_State* L)
|
||||
{
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
uint32 mountA = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 mountH = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint32 price = sEluna->CHECKVAL<uint32>(L, 4, 0);
|
||||
uint32 pathId = sEluna->CHECKVAL<uint32>(L, 5, 0);
|
||||
uint32 mountA = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
uint32 mountH = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
uint32 price = Eluna::CHECKVAL<uint32>(L, 4, 0);
|
||||
uint32 pathId = Eluna::CHECKVAL<uint32>(L, 5, 0);
|
||||
lua_pushvalue(L, 1);
|
||||
|
||||
std::list<TaxiPathNodeEntry> nodes;
|
||||
@@ -1083,11 +1082,11 @@ namespace LuaGlobalFunctions
|
||||
int start = lua_gettop(L);
|
||||
int end = start;
|
||||
|
||||
sEluna->Push(L);
|
||||
Eluna::Push(L);
|
||||
while (lua_next(L, -2) != 0)
|
||||
{
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
sEluna->Push(L);
|
||||
Eluna::Push(L);
|
||||
while (lua_next(L, -2) != 0)
|
||||
{
|
||||
lua_insert(L, end++);
|
||||
@@ -1104,18 +1103,18 @@ namespace LuaGlobalFunctions
|
||||
|
||||
while (end - start < 8) // fill optional args with 0
|
||||
{
|
||||
sEluna->Push(L, 0);
|
||||
Eluna::Push(L, 0);
|
||||
lua_insert(L, end++);
|
||||
}
|
||||
TaxiPathNodeEntry* entry = new TaxiPathNodeEntry();
|
||||
// mandatory
|
||||
entry->mapid = sEluna->CHECKVAL<uint32>(L, start);
|
||||
entry->x = sEluna->CHECKVAL<float>(L, start + 1);
|
||||
entry->y = sEluna->CHECKVAL<float>(L, start + 2);
|
||||
entry->z = sEluna->CHECKVAL<float>(L, start + 3);
|
||||
entry->mapid = Eluna::CHECKVAL<uint32>(L, start);
|
||||
entry->x = Eluna::CHECKVAL<float>(L, start + 1);
|
||||
entry->y = Eluna::CHECKVAL<float>(L, start + 2);
|
||||
entry->z = Eluna::CHECKVAL<float>(L, start + 3);
|
||||
// optional
|
||||
entry->actionFlag = sEluna->CHECKVAL<uint32>(L, start + 4);
|
||||
entry->delay = sEluna->CHECKVAL<uint32>(L, start + 5);
|
||||
entry->actionFlag = Eluna::CHECKVAL<uint32>(L, start + 4);
|
||||
entry->delay = Eluna::CHECKVAL<uint32>(L, start + 5);
|
||||
|
||||
nodes.push_back(*entry);
|
||||
|
||||
@@ -1126,13 +1125,43 @@ namespace LuaGlobalFunctions
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
sEluna->Push(L, LuaTaxiMgr::AddPath(nodes, mountA, mountH, price, pathId));
|
||||
if (nodes.size() < 2)
|
||||
return 1;
|
||||
if (!pathId)
|
||||
pathId = sTaxiPathNodesByPath.size();
|
||||
if (sTaxiPathNodesByPath.size() <= pathId)
|
||||
sTaxiPathNodesByPath.resize(pathId + 1);
|
||||
sTaxiPathNodesByPath[pathId].clear();
|
||||
sTaxiPathNodesByPath[pathId].resize(nodes.size());
|
||||
static uint32 nodeId = 500;
|
||||
uint32 startNode = nodeId;
|
||||
uint32 index = 0;
|
||||
for (std::list<TaxiPathNodeEntry>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
|
||||
{
|
||||
TaxiPathNodeEntry entry = *it;
|
||||
entry.path = pathId;
|
||||
TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
|
||||
nodeEntry->ID = index;
|
||||
nodeEntry->map_id = entry.mapid;
|
||||
nodeEntry->MountCreatureID[0] = mountH;
|
||||
nodeEntry->MountCreatureID[1] = mountA;
|
||||
nodeEntry->x = entry.x;
|
||||
nodeEntry->y = entry.y;
|
||||
nodeEntry->z = entry.z;
|
||||
sTaxiNodesStore.SetEntry(nodeId, nodeEntry);
|
||||
entry.index = nodeId++;
|
||||
sTaxiPathNodesByPath[pathId].set(index++, TaxiPathNodePtr(new TaxiPathNodeEntry(entry)));
|
||||
}
|
||||
if (startNode >= nodeId)
|
||||
return 1;
|
||||
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
|
||||
Eluna::Push(L, pathId);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AddCorpse(lua_State* L)
|
||||
{
|
||||
Corpse* corpse = sEluna->CHECKOBJ<Corpse>(L, 1);
|
||||
Corpse* corpse = Eluna::CHECKOBJ<Corpse>(L, 1);
|
||||
|
||||
sObjectAccessor->AddCorpse(corpse);
|
||||
return 0;
|
||||
@@ -1140,17 +1169,17 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int RemoveCorpse(lua_State* L)
|
||||
{
|
||||
Corpse* corpse = sEluna->CHECKOBJ<Corpse>(L, 1);
|
||||
Corpse* corpse = Eluna::CHECKOBJ<Corpse>(L, 1);
|
||||
sObjectAccessor->RemoveCorpse(corpse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ConvertCorpseForPlayer(lua_State* L)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1);
|
||||
bool insignia = sEluna->CHECKVAL<bool>(L, 2, false);
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
|
||||
bool insignia = Eluna::CHECKVAL<bool>(L, 2, false);
|
||||
|
||||
sEluna->Push(L, sObjectAccessor->ConvertCorpseForPlayer(ObjectGuid(guid), insignia));
|
||||
Eluna::Push(L, sObjectAccessor->ConvertCorpseForPlayer(ObjectGuid(guid), insignia));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1162,31 +1191,31 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int FindWeather(lua_State* L)
|
||||
{
|
||||
uint32 zoneId = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
#ifdef MANGOS
|
||||
Weather* weather = sWorld->FindWeather(zoneId);
|
||||
#else
|
||||
Weather* weather = WeatherMgr::FindWeather(zoneId);
|
||||
#endif
|
||||
sEluna->Push(L, weather);
|
||||
Eluna::Push(L, weather);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AddWeather(lua_State* L)
|
||||
{
|
||||
uint32 zoneId = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
#ifdef MANGOS
|
||||
Weather* weather = sWorld->AddWeather(zoneId);
|
||||
#else
|
||||
Weather* weather = WeatherMgr::AddWeather(zoneId);
|
||||
#endif
|
||||
sEluna->Push(L, weather);
|
||||
Eluna::Push(L, weather);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RemoveWeather(lua_State* L)
|
||||
{
|
||||
uint32 zoneId = sEluna->CHECKVAL<uint32>(L, 1);
|
||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
||||
#ifdef MANGOS
|
||||
sWorld->RemoveWeather(zoneId);
|
||||
#else
|
||||
@@ -1197,7 +1226,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int SendFineWeatherToPlayer(lua_State* L)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 1);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 1);
|
||||
#ifdef MANGOS
|
||||
Weather::SendFineWeatherUpdateToPlayer(player);
|
||||
#else
|
||||
|
||||
@@ -12,76 +12,76 @@ namespace LuaGroup
|
||||
/* BOOLEAN */
|
||||
int IsLeader(lua_State* L, Group* group)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2);
|
||||
sEluna->Push(L, group->IsLeader(ObjectGuid(guid)));
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
|
||||
Eluna::Push(L, group->IsLeader(ObjectGuid(guid)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsFull(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->IsFull());
|
||||
Eluna::Push(L, group->IsFull());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int isRaidGroup(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->isRaidGroup());
|
||||
Eluna::Push(L, group->isRaidGroup());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int isBGGroup(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->isBGGroup());
|
||||
Eluna::Push(L, group->isBGGroup());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsMember(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
sEluna->Push(L, group->IsMember(player->GET_GUID()));
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
Eluna::Push(L, group->IsMember(player->GET_GUID()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsAssistant(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, group->IsAssistant(player->GET_GUID()));
|
||||
Eluna::Push(L, group->IsAssistant(player->GET_GUID()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SameSubGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player1 = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player2 = sEluna->CHECKOBJ<Player>(L, 3);
|
||||
sEluna->Push(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;
|
||||
}
|
||||
|
||||
int HasFreeSlotSubGroup(lua_State* L, Group* group)
|
||||
{
|
||||
uint8 subGroup = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
sEluna->Push(L, group->HasFreeSlotSubGroup(subGroup));
|
||||
uint8 subGroup = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
Eluna::Push(L, group->HasFreeSlotSubGroup(subGroup));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AddInvite(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, group->AddInvite(player));
|
||||
Eluna::Push(L, group->AddInvite(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int isLFGGroup(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
sEluna->Push(L, group->isLFGGroup());
|
||||
Eluna::Push(L, group->isLFGGroup());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int isBFGroup(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
sEluna->Push(L, group->isBFGroup());
|
||||
Eluna::Push(L, group->isBFGroup());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
@@ -104,8 +104,8 @@ namespace LuaGroup
|
||||
continue;
|
||||
|
||||
++i;
|
||||
sEluna->Push(L, i);
|
||||
sEluna->Push(L, member);
|
||||
Eluna::Push(L, i);
|
||||
Eluna::Push(L, member);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace LuaGroup
|
||||
int GetLeaderGUID(lua_State* L, Group* group)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, group->GetLeaderGuid());
|
||||
Eluna::Push(L, group->GetLeaderGuid());
|
||||
#else
|
||||
sEluna->Push(L, group->GetLeaderGUID());
|
||||
Eluna::Push(L, group->GetLeaderGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -126,9 +126,9 @@ namespace LuaGroup
|
||||
int GetLeader(lua_State* L, Group* group)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGuid()));
|
||||
Eluna::Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGuid()));
|
||||
#else
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGUID()));
|
||||
Eluna::Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGUID()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -136,42 +136,42 @@ namespace LuaGroup
|
||||
int GetGUID(lua_State* L, Group* group)
|
||||
{
|
||||
#ifdef CLASSIC
|
||||
sEluna->Push(L, group->GetId());
|
||||
Eluna::Push(L, group->GetId());
|
||||
#else
|
||||
sEluna->Push(L, group->GET_GUID());
|
||||
Eluna::Push(L, group->GET_GUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMemberGUID(lua_State* L, Group* group)
|
||||
{
|
||||
const char* name = sEluna->CHECKVAL<const char*>(L, 2);
|
||||
const char* name = Eluna::CHECKVAL<const char*>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, group->GetMemberGuid(name));
|
||||
Eluna::Push(L, group->GetMemberGuid(name));
|
||||
#else
|
||||
sEluna->Push(L, group->GetMemberGUID(name));
|
||||
Eluna::Push(L, group->GetMemberGUID(name));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMembersCount(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->GetMembersCount());
|
||||
Eluna::Push(L, group->GetMembersCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMemberGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, group->GetMemberGroup(player->GET_GUID()));
|
||||
Eluna::Push(L, group->GetMemberGroup(player->GET_GUID()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int ChangeLeader(lua_State* L, Group* group)
|
||||
{
|
||||
Player* leader = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* leader = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
group->ChangeLeader(leader->GET_GUID());
|
||||
return 0;
|
||||
@@ -180,9 +180,9 @@ namespace LuaGroup
|
||||
// SendPacket(packet, sendToPlayersInBattleground[, ignoreguid])
|
||||
int SendPacket(lua_State* L, Group* group)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
bool ignorePlayersInBg = sEluna->CHECKVAL<bool>(L, 3);
|
||||
uint64 ignore = sEluna->CHECKVAL<uint64>(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;
|
||||
@@ -190,13 +190,13 @@ namespace LuaGroup
|
||||
|
||||
int RemoveMember(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint32 method = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint32 method = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, group->RemoveMember(player->GET_GUID(), method));
|
||||
Eluna::Push(L, group->RemoveMember(player->GET_GUID(), method));
|
||||
#else
|
||||
sEluna->Push(L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method));
|
||||
Eluna::Push(L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -215,8 +215,8 @@ namespace LuaGroup
|
||||
|
||||
int ChangeMembersGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint8 groupID = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint8 groupID = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
|
||||
group->ChangeMembersGroup(player->GET_GUID(), groupID);
|
||||
return 0;
|
||||
@@ -224,9 +224,9 @@ namespace LuaGroup
|
||||
|
||||
int SetTargetIcon(lua_State* L, Group* group)
|
||||
{
|
||||
uint8 icon = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
uint64 target = sEluna->CHECKVAL<uint64>(L, 3);
|
||||
uint64 setter = sEluna->CHECKVAL<uint64>(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(L, 2, "valid target icon expected");
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace LuaGuild
|
||||
if (player->GetSession() && (player->GetGuildId() == guild->GetId()))
|
||||
{
|
||||
++i;
|
||||
sEluna->Push(L, i);
|
||||
sEluna->Push(L, player);
|
||||
Eluna::Push(L, i);
|
||||
Eluna::Push(L, player);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
}
|
||||
@@ -37,16 +37,16 @@ namespace LuaGuild
|
||||
|
||||
int GetMemberCount(lua_State* L, Guild* guild)
|
||||
{
|
||||
sEluna->Push(L, guild->GetMemberSize());
|
||||
Eluna::Push(L, guild->GetMemberSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLeader(lua_State* L, Guild* guild)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGuid()));
|
||||
Eluna::Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGuid()));
|
||||
#else
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGUID()));
|
||||
Eluna::Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGUID()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -54,37 +54,37 @@ namespace LuaGuild
|
||||
int GetLeaderGUID(lua_State* L, Guild* guild)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, guild->GetLeaderGuid());
|
||||
Eluna::Push(L, guild->GetLeaderGuid());
|
||||
#else
|
||||
sEluna->Push(L, guild->GetLeaderGUID());
|
||||
Eluna::Push(L, guild->GetLeaderGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetId(lua_State* L, Guild* guild)
|
||||
{
|
||||
sEluna->Push(L, guild->GetId());
|
||||
Eluna::Push(L, guild->GetId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetName(lua_State* L, Guild* guild)
|
||||
{
|
||||
sEluna->Push(L, guild->GetName());
|
||||
Eluna::Push(L, guild->GetName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMOTD(lua_State* L, Guild* guild)
|
||||
{
|
||||
sEluna->Push(L, guild->GetMOTD());
|
||||
Eluna::Push(L, guild->GetMOTD());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInfo(lua_State* L, Guild* guild)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, guild->GetGINFO());
|
||||
Eluna::Push(L, guild->GetGINFO());
|
||||
#else
|
||||
sEluna->Push(L, guild->GetInfo());
|
||||
Eluna::Push(L, guild->GetInfo());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace LuaGuild
|
||||
#ifndef CATA
|
||||
int SetLeader(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
guild->SetLeader(player->GET_GUID());
|
||||
@@ -107,8 +107,8 @@ namespace LuaGuild
|
||||
#ifndef CLASSIC
|
||||
int SetBankTabText(lua_State* L, Guild* guild)
|
||||
{
|
||||
uint8 tabId = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
const char* text = sEluna->CHECKVAL<const char*>(L, 3);
|
||||
uint8 tabId = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
const char* text = Eluna::CHECKVAL<const char*>(L, 3);
|
||||
#ifdef MANGOS
|
||||
guild->SetGuildBankTabText(tabId, text);
|
||||
#else
|
||||
@@ -122,7 +122,7 @@ namespace LuaGuild
|
||||
// SendPacketToGuild(packet)
|
||||
int SendPacket(lua_State* L, Guild* guild)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
|
||||
|
||||
guild->BroadcastPacket(data);
|
||||
return 0;
|
||||
@@ -131,8 +131,8 @@ namespace LuaGuild
|
||||
// SendPacketToRankedInGuild(packet, rankId)
|
||||
int SendPacketToRanked(lua_State* L, Guild* guild)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
uint8 ranked = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
|
||||
uint8 ranked = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
|
||||
guild->BroadcastPacketToRank(data, ranked);
|
||||
return 0;
|
||||
@@ -146,8 +146,8 @@ namespace LuaGuild
|
||||
|
||||
int AddMember(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint8 rankId = sEluna->CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint8 rankId = Eluna::CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE);
|
||||
|
||||
guild->AddMember(player->GET_GUID(), rankId);
|
||||
return 0;
|
||||
@@ -155,8 +155,8 @@ namespace LuaGuild
|
||||
|
||||
int DeleteMember(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
bool isDisbanding = sEluna->CHECKVAL<bool>(L, 3, false);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
bool isDisbanding = Eluna::CHECKVAL<bool>(L, 3, false);
|
||||
|
||||
#ifdef MANGOS
|
||||
guild->DelMember(player->GET_GUID(), isDisbanding);
|
||||
@@ -168,8 +168,8 @@ namespace LuaGuild
|
||||
|
||||
int ChangeMemberRank(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint8 newRank = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint8 newRank = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
|
||||
guild->ChangeMemberRank(player->GET_GUID(), newRank);
|
||||
return 0;
|
||||
@@ -179,8 +179,8 @@ namespace LuaGuild
|
||||
// Move to Player methods
|
||||
int WithdrawBankMoney(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint32 money = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint32 money = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
#ifdef MANGOS
|
||||
if (guild->GetGuildBankMoney() < money)
|
||||
return 0;
|
||||
@@ -194,8 +194,8 @@ namespace LuaGuild
|
||||
// Move to Player methods
|
||||
int DepositBankMoney(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint32 money = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint32 money = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
#ifdef MANGOS
|
||||
guild->SetBankMoney(guild->GetGuildBankMoney() + money);
|
||||
|
||||
2691
HookMgr.cpp
2691
HookMgr.cpp
File diff suppressed because it is too large
Load Diff
225
HookMgr.h
225
HookMgr.h
@@ -7,67 +7,6 @@
|
||||
#ifndef LUAHOOKS_H
|
||||
#define LUAHOOKS_H
|
||||
|
||||
// Base
|
||||
#include "Common.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
// enums
|
||||
#ifdef MANGOS
|
||||
#include "Player.h"
|
||||
#else
|
||||
#include "GameObjectAI.h"
|
||||
#endif
|
||||
#include "Group.h"
|
||||
#include "Item.h"
|
||||
#include "Weather.h"
|
||||
|
||||
#ifdef MANGOS
|
||||
typedef SpellEffectIndex SpellEffIndex;
|
||||
typedef SpellEntry SpellInfo;
|
||||
typedef ItemPrototype ItemTemplate;
|
||||
#define GetTemplate GetProto
|
||||
#ifdef CLASSIC
|
||||
typedef int Difficulty;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct AreaTriggerEntry;
|
||||
#ifdef MANGOS
|
||||
class ReactorAI;
|
||||
typedef ReactorAI ScriptedAI;
|
||||
#else
|
||||
#undef UNORDERED_MAP
|
||||
#define UNORDERED_MAP std::unordered_map
|
||||
struct ScriptedAI;
|
||||
#endif
|
||||
class AuctionHouseObject;
|
||||
class Channel;
|
||||
class Creature;
|
||||
class CreatureAI;
|
||||
class GameObject;
|
||||
class Guild;
|
||||
class Group;
|
||||
class Item;
|
||||
class Player;
|
||||
class Quest;
|
||||
class Spell;
|
||||
class SpellCastTargets;
|
||||
class Transport;
|
||||
class Unit;
|
||||
class Weather;
|
||||
class WorldPacket;
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
#ifdef TRINITY
|
||||
class Vehicle;
|
||||
#else
|
||||
class VehicleInfo;
|
||||
typedef VehicleInfo Vehicle;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum RegisterTypes
|
||||
{
|
||||
REGTYPE_PACKET,
|
||||
@@ -86,7 +25,7 @@ enum RegisterTypes
|
||||
REGTYPE_COUNT
|
||||
};
|
||||
|
||||
// RegisterPacketEvent(Opcode, function)
|
||||
// RegisterPacketEvent(Opcode, event, function)
|
||||
// SERVER_EVENT_ON_PACKET_RECEIVE = 5, // (event, packet, player) - Player only if accessible. Can return false or a new packet
|
||||
// SERVER_EVENT_ON_PACKET_RECEIVE_UNKNOWN = 6, // Not Implemented
|
||||
// SERVER_EVENT_ON_PACKET_SEND = 7, // (event, packet, player) - Player only if accessible. Can return false or a new packet
|
||||
@@ -114,7 +53,7 @@ enum ServerEvents
|
||||
WORLD_EVENT_ON_SHUTDOWN = 15, // (event)
|
||||
|
||||
// Eluna
|
||||
ELUNA_EVENT_ON_RESTART = 16, // (event)
|
||||
ELUNA_EVENT_ON_LUA_STATE_CLOSE = 16, // (event)
|
||||
|
||||
// Map
|
||||
MAP_EVENT_ON_CREATE = 17, // (event, map)
|
||||
@@ -319,164 +258,4 @@ enum GossipEvents
|
||||
GOSSIP_EVENT_ON_SELECT = 2, // (event, player, object, sender, intid, code, menu_id) - Object is the Creature/GameObject/Item/Player, menu_id is only for player gossip
|
||||
GOSSIP_EVENT_COUNT
|
||||
};
|
||||
|
||||
class HookMgr
|
||||
{
|
||||
public:
|
||||
int userdata_table;
|
||||
void RemoveRef(const void* obj) const;
|
||||
|
||||
CreatureAI* GetAI(Creature* creature);
|
||||
|
||||
#ifndef MANGOS
|
||||
GameObjectAI* GetAI(GameObject* gameObject);
|
||||
#endif
|
||||
|
||||
/* Custom */
|
||||
bool OnCommand(Player* player, const char* text);
|
||||
void OnWorldUpdate(uint32 diff);
|
||||
void OnLootItem(Player* pPlayer, Item* pItem, uint32 count, uint64 guid);
|
||||
void OnLootMoney(Player* pPlayer, uint32 amount);
|
||||
void OnFirstLogin(Player* pPlayer);
|
||||
void OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot);
|
||||
void OnRepop(Player* pPlayer);
|
||||
void OnResurrect(Player* pPlayer);
|
||||
void OnQuestAbandon(Player* pPlayer, uint32 questId);
|
||||
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);
|
||||
|
||||
/* Item */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
|
||||
bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest);
|
||||
bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
|
||||
bool OnExpire(Player* pPlayer, ItemTemplate const* pProto);
|
||||
bool OnRemove(Player* pPlayer, Item* item);
|
||||
void HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, std::string code);
|
||||
|
||||
/* Creature */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Creature* pTarget);
|
||||
bool OnGossipHello(Player* pPlayer, Creature* pCreature);
|
||||
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 OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
|
||||
bool OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
|
||||
uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature);
|
||||
void OnSummoned(Creature* creature, Unit* summoner);
|
||||
|
||||
/* GameObject */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, GameObject* pTarget);
|
||||
bool OnGossipHello(Player* pPlayer, GameObject* pGameObject);
|
||||
bool OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action);
|
||||
bool OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code);
|
||||
bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
bool OnQuestComplete(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
uint32 GetDialogStatus(Player* pPlayer, GameObject* pGameObject);
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
void OnDestroyed(GameObject* pGameObject, Player* pPlayer);
|
||||
void OnDamaged(GameObject* pGameObject, Player* pPlayer);
|
||||
#endif
|
||||
#endif
|
||||
void OnLootStateChanged(GameObject* pGameObject, uint32 state);
|
||||
void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state);
|
||||
void UpdateAI(GameObject* pGameObject, uint32 diff);
|
||||
void OnSpawn(GameObject* gameobject);
|
||||
|
||||
/* Packet */
|
||||
bool OnPacketSend(WorldSession* session, WorldPacket& packet);
|
||||
bool OnPacketReceive(WorldSession* session, WorldPacket& packet);
|
||||
|
||||
/* Player */
|
||||
void OnPlayerEnterCombat(Player* pPlayer, Unit* pEnemy);
|
||||
void OnPlayerLeaveCombat(Player* pPlayer);
|
||||
void OnPVPKill(Player* pKiller, Player* pKilled);
|
||||
void OnCreatureKill(Player* pKiller, Creature* pKilled);
|
||||
void OnPlayerKilledByCreature(Creature* pKiller, Player* pKilled);
|
||||
void OnLevelChanged(Player* pPlayer, uint8 oldLevel);
|
||||
void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints);
|
||||
void OnTalentsReset(Player* pPlayer, bool noCost);
|
||||
void OnMoneyChanged(Player* pPlayer, int32& amount);
|
||||
void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim);
|
||||
void OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental);
|
||||
void OnDuelRequest(Player* pTarget, Player* pChallenger);
|
||||
void OnDuelStart(Player* pStarter, Player* pChallenger);
|
||||
void OnDuelEnd(Player* pWinner, Player* pLoser, DuelCompleteType type);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver);
|
||||
void OnEmote(Player* pPlayer, uint32 emote);
|
||||
void OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, uint64 guid);
|
||||
void OnSpellCast(Player* pPlayer, Spell* pSpell, bool skipCheck);
|
||||
void OnLogin(Player* pPlayer);
|
||||
void OnLogout(Player* pPlayer);
|
||||
void OnCreate(Player* pPlayer);
|
||||
void OnDelete(uint32 guid);
|
||||
void OnSave(Player* pPlayer);
|
||||
void OnBindToInstance(Player* pPlayer, Difficulty difficulty, uint32 mapid, bool permanent);
|
||||
void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea);
|
||||
void OnMapChanged(Player* pPlayer);
|
||||
void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, std::string code);
|
||||
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
/* Vehicle */
|
||||
void OnInstall(Vehicle* vehicle);
|
||||
void OnUninstall(Vehicle* vehicle);
|
||||
void OnInstallAccessory(Vehicle* vehicle, Creature* accessory);
|
||||
void OnAddPassenger(Vehicle* vehicle, Unit* passenger, int8 seatId);
|
||||
void OnRemovePassenger(Vehicle* vehicle, Unit* passenger);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* AreaTrigger */
|
||||
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger);
|
||||
|
||||
/* Weather */
|
||||
void OnChange(Weather* weather, WeatherState state, float grade);
|
||||
|
||||
/* Auction House */
|
||||
void OnAdd(AuctionHouseObject* auctionHouse);
|
||||
void OnRemove(AuctionHouseObject* auctionHouse);
|
||||
void OnSuccessful(AuctionHouseObject* auctionHouse);
|
||||
void OnExpire(AuctionHouseObject* auctionHouse);
|
||||
|
||||
/* Guild */
|
||||
void OnAddMember(Guild* guild, Player* player, uint32 plRank);
|
||||
void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding);
|
||||
void OnMOTDChanged(Guild* guild, const std::string& newMotd);
|
||||
void OnInfoChanged(Guild* guild, const std::string& newInfo);
|
||||
void OnCreate(Guild* guild, Player* leader, const std::string& name);
|
||||
void OnDisband(Guild* guild);
|
||||
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair);
|
||||
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
|
||||
void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId);
|
||||
void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank);
|
||||
void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId);
|
||||
|
||||
/* Group */
|
||||
void OnAddMember(Group* group, uint64 guid);
|
||||
void OnInviteMember(Group* group, uint64 guid);
|
||||
void OnRemoveMember(Group* group, uint64 guid, uint8 method);
|
||||
void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid);
|
||||
void OnDisband(Group* group);
|
||||
void OnCreate(Group* group, uint64 leaderGuid, GroupType groupType);
|
||||
|
||||
/* Map */
|
||||
void OnCreate(Map* map);
|
||||
void OnDestroy(Map* map);
|
||||
void OnPlayerEnter(Map* map, Player* player);
|
||||
void OnPlayerLeave(Map* map, Player* player);
|
||||
void OnUpdate(Map* map, uint32 diff);
|
||||
};
|
||||
#ifdef MANGOS
|
||||
#define sHookMgr (&MaNGOS::Singleton<HookMgr>::Instance())
|
||||
#else
|
||||
#define sHookMgr ACE_Singleton<HookMgr, ACE_Null_Mutex>::instance()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
52
Includes.h
Normal file
52
Includes.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
// Required
|
||||
#include "AccountMgr.h"
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "Chat.h"
|
||||
#include "Channel.h"
|
||||
#include "Config.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Language.h"
|
||||
#include "Mail.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "Pet.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "revision.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#ifdef MANGOS
|
||||
#include "ReactorAI.h"
|
||||
#include "revision_nr.h"
|
||||
#else
|
||||
#include "ScriptedCreature.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "WeatherMgr.h"
|
||||
#endif
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
#include "Vehicle.h"
|
||||
#endif
|
||||
#ifndef CLASSIC
|
||||
#include "ArenaTeam.h"
|
||||
#endif
|
||||
144
ItemMethods.h
144
ItemMethods.h
@@ -12,134 +12,134 @@ namespace LuaItem
|
||||
/* BOOLEAN */
|
||||
int IsSoulBound(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsSoulBound());
|
||||
Eluna::Push(L, item->IsSoulBound());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
int IsBoundAccountWide(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBoundAccountWide());
|
||||
Eluna::Push(L, item->IsBoundAccountWide());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int IsBoundByEnchant(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBoundByEnchant());
|
||||
Eluna::Push(L, item->IsBoundByEnchant());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsNotBoundToPlayer(lua_State* L, Item* item)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, item->IsBindedNotWith(player));
|
||||
Eluna::Push(L, item->IsBindedNotWith(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsLocked(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsLocked());
|
||||
Eluna::Push(L, item->IsLocked());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsBag(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBag());
|
||||
Eluna::Push(L, item->IsBag());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
int IsCurrencyToken(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsCurrencyToken());
|
||||
Eluna::Push(L, item->IsCurrencyToken());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int IsNotEmptyBag(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsNotEmptyBag());
|
||||
Eluna::Push(L, item->IsNotEmptyBag());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsBroken(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBroken());
|
||||
Eluna::Push(L, item->IsBroken());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanBeTraded(lua_State* L, Item* item)
|
||||
{
|
||||
#if (defined(TBC) || defined(CLASSIC))
|
||||
sEluna->Push(L, item->CanBeTraded());
|
||||
Eluna::Push(L, item->CanBeTraded());
|
||||
#else
|
||||
bool mail = sEluna->CHECKVAL<bool>(L, 2, false);
|
||||
sEluna->Push(L, item->CanBeTraded(mail));
|
||||
bool mail = Eluna::CHECKVAL<bool>(L, 2, false);
|
||||
Eluna::Push(L, item->CanBeTraded(mail));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsInTrade(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsInTrade());
|
||||
Eluna::Push(L, item->IsInTrade());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsInBag(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsInBag());
|
||||
Eluna::Push(L, item->IsInBag());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsEquipped(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsEquipped());
|
||||
Eluna::Push(L, item->IsEquipped());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasQuest(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 quest = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 quest = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, item->HasQuest(quest));
|
||||
Eluna::Push(L, item->HasQuest(quest));
|
||||
#else
|
||||
sEluna->Push(L, item->hasQuest(quest));
|
||||
Eluna::Push(L, item->hasQuest(quest));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsPotion(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsPotion());
|
||||
Eluna::Push(L, item->IsPotion());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CATA
|
||||
int IsWeaponVellum(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsWeaponVellum());
|
||||
Eluna::Push(L, item->IsWeaponVellum());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsArmorVellum(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsArmorVellum());
|
||||
Eluna::Push(L, item->IsArmorVellum());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int IsConjuredConsumable(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsConjuredConsumable());
|
||||
Eluna::Push(L, item->IsConjuredConsumable());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
|
||||
{
|
||||
sEluna->Push(L, item->IsRefundExpired());
|
||||
Eluna::Push(L, item->IsRefundExpired());
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
@@ -157,7 +157,7 @@ namespace LuaItem
|
||||
// LOCALE_esMX = 7,
|
||||
// LOCALE_ruRU = 8
|
||||
|
||||
int loc_idx = sEluna->CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
|
||||
int loc_idx = Eluna::CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
|
||||
if (loc_idx < 0 || loc_idx >= MAX_LOCALES)
|
||||
return luaL_argerror(L, 2, "valid LocaleConstant expected");
|
||||
|
||||
@@ -211,212 +211,212 @@ namespace LuaItem
|
||||
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
|
||||
(uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r";
|
||||
|
||||
sEluna->Push(L, oss.str());
|
||||
Eluna::Push(L, oss.str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUID(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetGUIDLow());
|
||||
Eluna::Push(L, item->GetGUIDLow());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetOwnerGUID(lua_State* L, Item* item)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, item->GetOwnerGuid());
|
||||
Eluna::Push(L, item->GetOwnerGuid());
|
||||
#else
|
||||
sEluna->Push(L, item->GetOwnerGUID());
|
||||
Eluna::Push(L, item->GetOwnerGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetOwner(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetOwner());
|
||||
Eluna::Push(L, item->GetOwner());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetCount());
|
||||
Eluna::Push(L, item->GetCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMaxStackCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetMaxStackCount());
|
||||
Eluna::Push(L, item->GetMaxStackCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSlot(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetSlot());
|
||||
Eluna::Push(L, item->GetSlot());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBagSlot(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetBagSlot());
|
||||
Eluna::Push(L, item->GetBagSlot());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUIDLow(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetGUIDLow());
|
||||
Eluna::Push(L, item->GetGUIDLow());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetEnchantmentId(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 enchant_slot = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 enchant_slot = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
|
||||
|
||||
sEluna->Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot)));
|
||||
Eluna::Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSpellId(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 index = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (index >= MAX_ITEM_PROTO_SPELLS)
|
||||
return luaL_argerror(L, 2, "valid SpellIndex expected");
|
||||
|
||||
sEluna->Push(L, item->GetTemplate()->Spells[index].SpellId);
|
||||
Eluna::Push(L, item->GetTemplate()->Spells[index].SpellId);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSpellTrigger(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 index = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (index >= MAX_ITEM_PROTO_SPELLS)
|
||||
return luaL_argerror(L, 2, "valid SpellIndex expected");
|
||||
|
||||
sEluna->Push(L, item->GetTemplate()->Spells[index].SpellTrigger);
|
||||
Eluna::Push(L, item->GetTemplate()->Spells[index].SpellTrigger);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetClass(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->Class);
|
||||
Eluna::Push(L, item->GetTemplate()->Class);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSubClass(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->SubClass);
|
||||
Eluna::Push(L, item->GetTemplate()->SubClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetName(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->Name1);
|
||||
Eluna::Push(L, item->GetTemplate()->Name1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDisplayId(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->DisplayInfoID);
|
||||
Eluna::Push(L, item->GetTemplate()->DisplayInfoID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetQuality(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->Quality);
|
||||
Eluna::Push(L, item->GetTemplate()->Quality);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBuyCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->BuyCount);
|
||||
Eluna::Push(L, item->GetTemplate()->BuyCount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBuyPrice(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->BuyPrice);
|
||||
Eluna::Push(L, item->GetTemplate()->BuyPrice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSellPrice(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->SellPrice);
|
||||
Eluna::Push(L, item->GetTemplate()->SellPrice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInventoryType(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->InventoryType);
|
||||
Eluna::Push(L, item->GetTemplate()->InventoryType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAllowableClass(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->AllowableClass);
|
||||
Eluna::Push(L, item->GetTemplate()->AllowableClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAllowableRace(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->AllowableRace);
|
||||
Eluna::Push(L, item->GetTemplate()->AllowableRace);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetItemLevel(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->ItemLevel);
|
||||
Eluna::Push(L, item->GetTemplate()->ItemLevel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRequiredLevel(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->RequiredLevel);
|
||||
Eluna::Push(L, item->GetTemplate()->RequiredLevel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WOTLK
|
||||
int GetStatsCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->StatsCount);
|
||||
Eluna::Push(L, item->GetTemplate()->StatsCount);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int GetRandomProperty(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->RandomProperty);
|
||||
Eluna::Push(L, item->GetTemplate()->RandomProperty);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
int GetRandomSuffix(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->RandomSuffix);
|
||||
Eluna::Push(L, item->GetTemplate()->RandomSuffix);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int GetItemSet(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->ItemSet);
|
||||
Eluna::Push(L, item->GetTemplate()->ItemSet);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBagSize(lua_State* L, Item* item)
|
||||
{
|
||||
if (Bag* bag = item->ToBag())
|
||||
sEluna->Push(L, bag->GetBagSize());
|
||||
Eluna::Push(L, bag->GetBagSize());
|
||||
else
|
||||
sEluna->Push(L, 0);
|
||||
Eluna::Push(L, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetOwner(lua_State* L, Item* item)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
#ifdef MANGOS
|
||||
item->SetOwnerGuid(player->GET_GUID());
|
||||
#else
|
||||
@@ -427,7 +427,7 @@ namespace LuaItem
|
||||
|
||||
int SetBinding(lua_State* L, Item* item)
|
||||
{
|
||||
bool soulbound = sEluna->CHECKVAL<bool>(L, 2);
|
||||
bool soulbound = Eluna::CHECKVAL<bool>(L, 2);
|
||||
|
||||
item->SetBinding(soulbound);
|
||||
return 0;
|
||||
@@ -435,7 +435,7 @@ namespace LuaItem
|
||||
|
||||
int SetCount(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 count = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 count = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
item->SetCount(count);
|
||||
return 0;
|
||||
}
|
||||
@@ -445,25 +445,25 @@ namespace LuaItem
|
||||
Player* owner = item->GetOwner();
|
||||
if (!owner)
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 enchant = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 enchant = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (!sSpellItemEnchantmentStore.LookupEntry(enchant))
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(L, 3);
|
||||
EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 3);
|
||||
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
|
||||
|
||||
owner->ApplyEnchantment(item, slot, false);
|
||||
item->SetEnchantment(slot, enchant, 0, 0);
|
||||
owner->ApplyEnchantment(item, slot, true);
|
||||
sEluna->Push(L, true);
|
||||
Eluna::Push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -473,23 +473,23 @@ namespace LuaItem
|
||||
Player* owner = item->GetOwner();
|
||||
if (!owner)
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(L, 2);
|
||||
EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
|
||||
|
||||
if (!item->GetEnchantmentId(slot))
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
owner->ApplyEnchantment(item, slot, false);
|
||||
item->ClearEnchantment(slot);
|
||||
sEluna->Push(L, true);
|
||||
Eluna::Push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
420
LuaEngine.cpp
420
LuaEngine.cpp
@@ -6,83 +6,21 @@
|
||||
|
||||
#include <ace/Dirent.h>
|
||||
#include <ace/OS_NS_sys_stat.h>
|
||||
#include "HookMgr.h"
|
||||
#include "LuaEngine.h"
|
||||
#include "Includes.h"
|
||||
|
||||
#ifdef MANGOS
|
||||
INSTANTIATE_SINGLETON_1(Eluna);
|
||||
#endif
|
||||
Eluna::ScriptPaths Eluna::scripts;
|
||||
Eluna* Eluna::GEluna = NULL;
|
||||
|
||||
extern void RegisterFunctions(lua_State* L);
|
||||
extern void AddElunaScripts();
|
||||
|
||||
// Start or restart eluna. Returns true if started
|
||||
bool StartEluna()
|
||||
void Eluna::Initialize()
|
||||
{
|
||||
#ifndef ELUNA
|
||||
#ifndef MANGOS
|
||||
{
|
||||
ELUNA_LOG_ERROR("[Eluna]: LuaEngine is Disabled. (If you want to use it please enable in cmake)");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
ELUNA_GUARD();
|
||||
bool restart = false;
|
||||
if (sEluna->L)
|
||||
{
|
||||
restart = true;
|
||||
sHookMgr->OnEngineRestart();
|
||||
ELUNA_LOG_INFO("[Eluna]: Stopping Lua Engine");
|
||||
scripts.clear();
|
||||
|
||||
// Unregisters and stops all timed events
|
||||
sEluna->m_EventMgr.RemoveEvents();
|
||||
|
||||
// Remove bindings
|
||||
sEluna->PacketEventBindings.Clear();
|
||||
sEluna->ServerEventBindings.Clear();
|
||||
sEluna->PlayerEventBindings.Clear();
|
||||
sEluna->GuildEventBindings.Clear();
|
||||
sEluna->GroupEventBindings.Clear();
|
||||
|
||||
sEluna->CreatureEventBindings.Clear();
|
||||
sEluna->CreatureGossipBindings.Clear();
|
||||
sEluna->GameObjectEventBindings.Clear();
|
||||
sEluna->GameObjectGossipBindings.Clear();
|
||||
sEluna->ItemEventBindings.Clear();
|
||||
sEluna->ItemGossipBindings.Clear();
|
||||
sEluna->playerGossipBindings.Clear();
|
||||
sEluna->VehicleEventBindings.Clear();
|
||||
|
||||
lua_close(sEluna->L);
|
||||
}
|
||||
else
|
||||
AddElunaScripts();
|
||||
|
||||
#ifdef MANGOS
|
||||
// Check config file for eluna is enabled or disabled
|
||||
if (!sWorld->getConfig(CONFIG_BOOL_ELUNA_ENABLED))
|
||||
{
|
||||
ELUNA_LOG_ERROR("[Eluna]: LuaEngine is Disabled. (If you want to use it please set config in 'mangosd.conf')");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
ELUNA_LOG_INFO("[Eluna]: Starting Lua Engine");
|
||||
|
||||
sEluna->L = luaL_newstate();
|
||||
luaL_openlibs(sEluna->L);
|
||||
RegisterFunctions(sEluna->L);
|
||||
|
||||
// Create hidden table with weak values
|
||||
lua_newtable(sEluna->L);
|
||||
lua_newtable(sEluna->L);
|
||||
lua_pushstring(sEluna->L, "v");
|
||||
lua_setfield(sEluna->L, -2, "__mode");
|
||||
lua_setmetatable(sEluna->L, -2);
|
||||
sHookMgr->userdata_table = luaL_ref(sEluna->L, LUA_REGISTRYINDEX);
|
||||
|
||||
ScriptPaths scripts;
|
||||
std::string folderpath = sConfigMgr->GetStringDefault("Eluna.ScriptPath", "lua_scripts");
|
||||
#if PLATFORM == PLATFORM_UNIX || PLATFORM == PLATFORM_APPLE
|
||||
if (folderpath[0] == '~')
|
||||
@@ -90,39 +28,92 @@ bool StartEluna()
|
||||
folderpath.replace(0, 1, home);
|
||||
#endif
|
||||
ELUNA_LOG_INFO("[Eluna]: Searching scripts from `%s`", folderpath.c_str());
|
||||
sEluna->GetScripts(folderpath, scripts);
|
||||
sEluna->GetScripts(folderpath + "/extensions", scripts);
|
||||
sEluna->RunScripts(scripts);
|
||||
GetScripts(folderpath, scripts);
|
||||
GetScripts(folderpath + "/extensions", scripts);
|
||||
|
||||
/*
|
||||
if (restart)
|
||||
{
|
||||
//! Iterate over every supported source type (creature and gameobject)
|
||||
//! Not entirely sure how this will affect units in non-loaded grids.
|
||||
{
|
||||
HashMapHolder<Creature>::ReadGuard g(HashMapHolder<Creature>::GetLock());
|
||||
HashMapHolder<Creature>::MapType& m = HashMapHolder<Creature>::GetContainer();
|
||||
for (HashMapHolder<Creature>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (itr->second->IsInWorld()) // must check?
|
||||
// if(sEluna->CreatureEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna?
|
||||
itr->second->AIM_Initialize();
|
||||
}
|
||||
}
|
||||
ELUNA_LOG_INFO("[Eluna]: Loaded %u scripts in %u ms", uint32(scripts.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
{
|
||||
HashMapHolder<GameObject>::ReadGuard g(HashMapHolder<GameObject>::GetLock());
|
||||
HashMapHolder<GameObject>::MapType& m = HashMapHolder<GameObject>::GetContainer();
|
||||
for (HashMapHolder<GameObject>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (itr->second->IsInWorld()) // must check?
|
||||
// if(sEluna->GameObjectEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna?
|
||||
itr->second->AIM_Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
// Create global eluna
|
||||
new Eluna();
|
||||
}
|
||||
|
||||
void Eluna::Uninitialize()
|
||||
{
|
||||
delete GEluna;
|
||||
}
|
||||
|
||||
void Eluna::ReloadEluna()
|
||||
{
|
||||
Uninitialize();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
Eluna::Eluna():
|
||||
L(luaL_newstate()),
|
||||
|
||||
m_EventMgr(new EventMgr(*this)),
|
||||
|
||||
ServerEventBindings(new EventBind(*this)),
|
||||
PlayerEventBindings(new EventBind(*this)),
|
||||
GuildEventBindings(new EventBind(*this)),
|
||||
GroupEventBindings(new EventBind(*this)),
|
||||
VehicleEventBindings(new EventBind(*this)),
|
||||
|
||||
PacketEventBindings(new EntryBind(*this)),
|
||||
CreatureEventBindings(new EntryBind(*this)),
|
||||
CreatureGossipBindings(new EntryBind(*this)),
|
||||
GameObjectEventBindings(new EntryBind(*this)),
|
||||
GameObjectGossipBindings(new EntryBind(*this)),
|
||||
ItemEventBindings(new EntryBind(*this)),
|
||||
ItemGossipBindings(new EntryBind(*this)),
|
||||
playerGossipBindings(new EntryBind(*this))
|
||||
{
|
||||
// open base lua
|
||||
luaL_openlibs(L);
|
||||
RegisterFunctions(L);
|
||||
|
||||
// Create hidden table with weak values
|
||||
lua_newtable(L);
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "v");
|
||||
lua_setfield(L, -2, "__mode");
|
||||
lua_setmetatable(L, -2);
|
||||
userdata_table = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
|
||||
// Replace this with map insert if making multithread version
|
||||
ASSERT(!Eluna::GEluna);
|
||||
Eluna::GEluna = this;
|
||||
|
||||
// run scripts
|
||||
RunScripts(scripts);
|
||||
}
|
||||
|
||||
Eluna::~Eluna()
|
||||
{
|
||||
OnLuaStateClose();
|
||||
|
||||
// Replace this with map remove if making multithread version
|
||||
Eluna::GEluna = NULL;
|
||||
|
||||
delete m_EventMgr;
|
||||
|
||||
delete ServerEventBindings;
|
||||
delete PlayerEventBindings;
|
||||
delete GuildEventBindings;
|
||||
delete GroupEventBindings;
|
||||
delete VehicleEventBindings;
|
||||
|
||||
delete PacketEventBindings;
|
||||
delete CreatureEventBindings;
|
||||
delete CreatureGossipBindings;
|
||||
delete GameObjectEventBindings;
|
||||
delete GameObjectGossipBindings;
|
||||
delete ItemEventBindings;
|
||||
delete ItemGossipBindings;
|
||||
delete playerGossipBindings;
|
||||
|
||||
// Must close lua state after deleting stores and mgr
|
||||
lua_close(L);
|
||||
}
|
||||
|
||||
// Finds lua script files from given path (including subdirectories) and pushes them to scripts
|
||||
@@ -187,7 +178,21 @@ void Eluna::RunScripts(ScriptPaths& scripts)
|
||||
ELUNA_LOG_ERROR("[Eluna]: Error loading file `%s`", it->c_str());
|
||||
report(L);
|
||||
}
|
||||
ELUNA_LOG_INFO("[Eluna]: Loaded %u Lua scripts", count);
|
||||
ELUNA_LOG_DEBUG("[Eluna]: Loaded %u Lua scripts", count);
|
||||
}
|
||||
|
||||
void Eluna::RemoveRef(const void* obj)
|
||||
{
|
||||
lua_rawgeti(sEluna->L, LUA_REGISTRYINDEX, sEluna->userdata_table);
|
||||
lua_pushfstring(sEluna->L, "%p", obj);
|
||||
lua_gettable(sEluna->L, -2);
|
||||
if (!lua_isnoneornil(sEluna->L, -1))
|
||||
{
|
||||
lua_pushfstring(sEluna->L, "%p", obj);
|
||||
lua_pushnil(sEluna->L);
|
||||
lua_settable(sEluna->L, -4);
|
||||
}
|
||||
lua_pop(sEluna->L, 2);
|
||||
}
|
||||
|
||||
void Eluna::report(lua_State* L)
|
||||
@@ -201,47 +206,12 @@ void Eluna::report(lua_State* L)
|
||||
}
|
||||
}
|
||||
|
||||
void Eluna::BeginCall(int fReference)
|
||||
void Eluna::ExecuteCall(lua_State* L, int params, int res)
|
||||
{
|
||||
lua_settop(L, 0); // stack should be empty
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (fReference));
|
||||
}
|
||||
|
||||
bool Eluna::ExecuteCall(int params, int res)
|
||||
{
|
||||
bool ret = true;
|
||||
int top = lua_gettop(L);
|
||||
|
||||
if (lua_type(L, top - params) == LUA_TFUNCTION) // is function
|
||||
{
|
||||
if (lua_pcall(L, params, res, 0))
|
||||
{
|
||||
report(L);
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = false;
|
||||
if (params > 0)
|
||||
{
|
||||
for (int i = top; i >= (top - params); i--)
|
||||
{
|
||||
if (!lua_isnone(L, i))
|
||||
lua_remove(L, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Eluna::EndCall(int res)
|
||||
{
|
||||
for (int i = res; i > 0; i--)
|
||||
{
|
||||
if (!lua_isnone(L, res))
|
||||
lua_remove(L, res);
|
||||
}
|
||||
luaL_checktype(L, top - params, LUA_TFUNCTION);
|
||||
if (lua_pcall(L, params, res, 0))
|
||||
report(L);
|
||||
}
|
||||
|
||||
void Eluna::Push(lua_State* L)
|
||||
@@ -252,13 +222,13 @@ void Eluna::Push(lua_State* L, const uint64 l)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << l;
|
||||
sEluna->Push(L, ss.str());
|
||||
Push(L, ss.str());
|
||||
}
|
||||
void Eluna::Push(lua_State* L, const int64 l)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << l;
|
||||
sEluna->Push(L, ss.str());
|
||||
Push(L, ss.str());
|
||||
}
|
||||
void Eluna::Push(lua_State* L, const uint32 u)
|
||||
{
|
||||
@@ -558,7 +528,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_PACKET:
|
||||
if (evt < NUM_MSG_TYPES)
|
||||
{
|
||||
PacketEventBindings.Insert(evt, functionRef);
|
||||
PacketEventBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -566,7 +536,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_SERVER:
|
||||
if (evt < SERVER_EVENT_COUNT)
|
||||
{
|
||||
ServerEventBindings.Insert(evt, functionRef);
|
||||
ServerEventBindings->Insert(evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -574,7 +544,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_PLAYER:
|
||||
if (evt < PLAYER_EVENT_COUNT)
|
||||
{
|
||||
PlayerEventBindings.Insert(evt, functionRef);
|
||||
PlayerEventBindings->Insert(evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -582,7 +552,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_GUILD:
|
||||
if (evt < GUILD_EVENT_COUNT)
|
||||
{
|
||||
GuildEventBindings.Insert(evt, functionRef);
|
||||
GuildEventBindings->Insert(evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -590,7 +560,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_GROUP:
|
||||
if (evt < GROUP_EVENT_COUNT)
|
||||
{
|
||||
GroupEventBindings.Insert(evt, functionRef);
|
||||
GroupEventBindings->Insert(evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -598,7 +568,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_VEHICLE:
|
||||
if (evt < VEHICLE_EVENT_COUNT)
|
||||
{
|
||||
VehicleEventBindings.Insert(evt, functionRef);
|
||||
VehicleEventBindings->Insert(evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -608,12 +578,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
{
|
||||
if (!sObjectMgr->GetCreatureTemplate(id))
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Couldn't find a creature with (ID: %d)!", id);
|
||||
return;
|
||||
}
|
||||
|
||||
sEluna->CreatureEventBindings.Insert(id, evt, functionRef);
|
||||
CreatureEventBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -623,12 +593,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
{
|
||||
if (!sObjectMgr->GetCreatureTemplate(id))
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Couldn't find a creature with (ID: %d)!", id);
|
||||
return;
|
||||
}
|
||||
|
||||
sEluna->CreatureGossipBindings.Insert(id, evt, functionRef);
|
||||
CreatureGossipBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -638,12 +608,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
{
|
||||
if (!sObjectMgr->GetGameObjectTemplate(id))
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id);
|
||||
return;
|
||||
}
|
||||
|
||||
sEluna->GameObjectEventBindings.Insert(id, evt, functionRef);
|
||||
GameObjectEventBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -653,12 +623,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
{
|
||||
if (!sObjectMgr->GetGameObjectTemplate(id))
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id);
|
||||
return;
|
||||
}
|
||||
|
||||
sEluna->GameObjectGossipBindings.Insert(id, evt, functionRef);
|
||||
GameObjectGossipBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -668,12 +638,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
{
|
||||
if (!sObjectMgr->GetItemTemplate(id))
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Couldn't find a item with (ID: %d)!", id);
|
||||
return;
|
||||
}
|
||||
|
||||
sEluna->ItemEventBindings.Insert(id, evt, functionRef);
|
||||
ItemEventBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -683,12 +653,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
{
|
||||
if (!sObjectMgr->GetItemTemplate(id))
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Couldn't find a item with (ID: %d)!", id);
|
||||
return;
|
||||
}
|
||||
|
||||
sEluna->ItemGossipBindings.Insert(id, evt, functionRef);
|
||||
ItemGossipBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -696,32 +666,32 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
|
||||
case REGTYPE_PLAYER_GOSSIP:
|
||||
if (evt < GOSSIP_EVENT_COUNT)
|
||||
{
|
||||
sEluna->playerGossipBindings.Insert(id, evt, functionRef);
|
||||
playerGossipBindings->Insert(id, evt, functionRef);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
|
||||
luaL_error(L, "Unknown event type (regtype %d, id %d, event %d)", regtype, id, evt);
|
||||
}
|
||||
|
||||
void Eluna::EventBind::Clear()
|
||||
void EventBind::Clear()
|
||||
{
|
||||
for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr)
|
||||
{
|
||||
for (ElunaBindingMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it));
|
||||
luaL_unref(E.L, LUA_REGISTRYINDEX, (*it));
|
||||
itr->second.clear();
|
||||
}
|
||||
Bindings.clear();
|
||||
}
|
||||
|
||||
void Eluna::EventBind::Insert(int eventId, int funcRef)
|
||||
void EventBind::Insert(int eventId, int funcRef)
|
||||
{
|
||||
Bindings[eventId].push_back(funcRef);
|
||||
}
|
||||
|
||||
bool Eluna::EventBind::HasEvents(int eventId) const
|
||||
bool EventBind::HasEvents(int eventId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return false;
|
||||
@@ -730,61 +700,33 @@ bool Eluna::EventBind::HasEvents(int eventId) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void Eluna::EventBind::BeginCall(int eventId) const
|
||||
{
|
||||
lua_settop(sEluna->L, 0); // stack should be empty
|
||||
sEluna->Push(sEluna->L, eventId);
|
||||
}
|
||||
|
||||
void Eluna::EventBind::ExecuteCall()
|
||||
{
|
||||
int eventId = sEluna->CHECKVAL<int>(sEluna->L, 1);
|
||||
int params = lua_gettop(sEluna->L);
|
||||
for (ElunaBindingMap::const_iterator it = Bindings[eventId].begin(); it != Bindings[eventId].end(); ++it)
|
||||
{
|
||||
lua_rawgeti(sEluna->L, LUA_REGISTRYINDEX, (*it)); // Fetch function
|
||||
for (int i = 1; i <= params; ++i) // Copy original pushed params
|
||||
lua_pushvalue(sEluna->L, i);
|
||||
sEluna->ExecuteCall(params, LUA_MULTRET); // Do call and leave results to stack
|
||||
}
|
||||
for (int i = params; i > 0; --i) // Remove original pushed params
|
||||
if (!lua_isnone(sEluna->L, i))
|
||||
lua_remove(sEluna->L, i);
|
||||
// Results in stack, otherwise stack clean
|
||||
}
|
||||
|
||||
void Eluna::EventBind::EndCall() const
|
||||
{
|
||||
lua_settop(sEluna->L, 0); // stack should be empty
|
||||
};
|
||||
|
||||
void Eluna::EntryBind::Clear()
|
||||
void EntryBind::Clear()
|
||||
{
|
||||
for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr)
|
||||
{
|
||||
for (ElunaBindingMap::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, it->second);
|
||||
luaL_unref(E.L, LUA_REGISTRYINDEX, it->second);
|
||||
itr->second.clear();
|
||||
}
|
||||
Bindings.clear();
|
||||
}
|
||||
|
||||
void Eluna::EntryBind::Insert(uint32 entryId, int eventId, int funcRef)
|
||||
void EntryBind::Insert(uint32 entryId, int eventId, int funcRef)
|
||||
{
|
||||
if (Bindings[entryId][eventId])
|
||||
{
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // free the unused ref
|
||||
luaL_error(sEluna->L, "A function is already registered for entry (%d) event (%d)", entryId, eventId);
|
||||
luaL_unref(E.L, LUA_REGISTRYINDEX, funcRef); // free the unused ref
|
||||
luaL_error(E.L, "A function is already registered for entry (%d) event (%d)", entryId, eventId);
|
||||
}
|
||||
else
|
||||
Bindings[entryId][eventId] = funcRef;
|
||||
}
|
||||
|
||||
EventMgr::LuaEvent::LuaEvent(EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj):
|
||||
events(_events), funcRef(_funcRef), delay(_delay), calls(_calls), obj(_obj)
|
||||
EventMgr::LuaEvent::LuaEvent(Eluna& _E, EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj):
|
||||
E(_E), events(_events), funcRef(_funcRef), delay(_delay), calls(_calls), obj(_obj)
|
||||
{
|
||||
if (_events)
|
||||
sEluna->m_EventMgr.LuaEvents[_events].insert(this); // Able to access the event if we have the processor
|
||||
E.m_EventMgr->LuaEvents[_events].insert(this); // Able to access the event if we have the processor
|
||||
}
|
||||
|
||||
EventMgr::LuaEvent::~LuaEvent()
|
||||
@@ -792,79 +734,25 @@ EventMgr::LuaEvent::~LuaEvent()
|
||||
if (events)
|
||||
{
|
||||
// Attempt to remove the pointer from LuaEvents
|
||||
EventMgr::EventMap::const_iterator it = sEluna->m_EventMgr.LuaEvents.find(events); // Get event set
|
||||
if (it != sEluna->m_EventMgr.LuaEvents.end())
|
||||
sEluna->m_EventMgr.LuaEvents[events].erase(this);// Remove pointer
|
||||
EventMgr::EventMap::const_iterator it = E.m_EventMgr->LuaEvents.find(events); // Get event set
|
||||
if (it != E.m_EventMgr->LuaEvents.end())
|
||||
E.m_EventMgr->LuaEvents[events].erase(this);// Remove pointer
|
||||
}
|
||||
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // Free lua function ref
|
||||
luaL_unref(E.L, LUA_REGISTRYINDEX, funcRef); // Free lua function ref
|
||||
}
|
||||
|
||||
bool EventMgr::LuaEvent::Execute(uint64 time, uint32 diff)
|
||||
{
|
||||
ELUNA_GUARD();
|
||||
bool remove = (calls == 1);
|
||||
if (!remove)
|
||||
events->AddEvent(this, events->CalculateTime(delay)); // Reschedule before calling incase RemoveEvents used
|
||||
sEluna->BeginCall(funcRef);
|
||||
sEluna->Push(sEluna->L, funcRef);
|
||||
sEluna->Push(sEluna->L, delay);
|
||||
sEluna->Push(sEluna->L, calls);
|
||||
lua_rawgeti(E.L, LUA_REGISTRYINDEX, funcRef);
|
||||
Eluna::Push(E.L, funcRef);
|
||||
Eluna::Push(E.L, delay);
|
||||
Eluna::Push(E.L, calls);
|
||||
if (!remove && calls)
|
||||
--calls;
|
||||
sEluna->Push(sEluna->L, obj);
|
||||
sEluna->ExecuteCall(4, 0);
|
||||
Eluna::Push(E.L, obj);
|
||||
Eluna::ExecuteCall(E.L, 4, 0);
|
||||
return remove; // Destory (true) event if not run
|
||||
}
|
||||
|
||||
// Lua taxi helper functions
|
||||
uint32 LuaTaxiMgr::nodeId = 500;
|
||||
void LuaTaxiMgr::StartTaxi(Player* player, uint32 pathid)
|
||||
{
|
||||
if (pathid >= sTaxiPathNodesByPath.size())
|
||||
return;
|
||||
|
||||
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid];
|
||||
if (path.size() < 2)
|
||||
return;
|
||||
|
||||
std::vector<uint32> nodes;
|
||||
nodes.resize(2);
|
||||
nodes[0] = path[0].index;
|
||||
nodes[1] = path[path.size() - 1].index;
|
||||
|
||||
player->ActivateTaxiPathTo(nodes);
|
||||
}
|
||||
|
||||
uint32 LuaTaxiMgr::AddPath(std::list<TaxiPathNodeEntry> nodes, uint32 mountA, uint32 mountH, uint32 price, uint32 pathId)
|
||||
{
|
||||
if (nodes.size() < 2)
|
||||
return 0;
|
||||
if (!pathId)
|
||||
pathId = sTaxiPathNodesByPath.size();
|
||||
if (sTaxiPathNodesByPath.size() <= pathId)
|
||||
sTaxiPathNodesByPath.resize(pathId + 1);
|
||||
sTaxiPathNodesByPath[pathId].clear();
|
||||
sTaxiPathNodesByPath[pathId].resize(nodes.size());
|
||||
uint32 startNode = nodeId;
|
||||
uint32 index = 0;
|
||||
for (std::list<TaxiPathNodeEntry>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
|
||||
{
|
||||
TaxiPathNodeEntry entry = *it;
|
||||
entry.path = pathId;
|
||||
TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
|
||||
nodeEntry->ID = index;
|
||||
nodeEntry->map_id = entry.mapid;
|
||||
nodeEntry->MountCreatureID[0] = mountH;
|
||||
nodeEntry->MountCreatureID[1] = mountA;
|
||||
nodeEntry->x = entry.x;
|
||||
nodeEntry->y = entry.y;
|
||||
nodeEntry->z = entry.z;
|
||||
sTaxiNodesStore.SetEntry(nodeId, nodeEntry);
|
||||
entry.index = nodeId++;
|
||||
sTaxiPathNodesByPath[pathId].set(index++, TaxiPathNodePtr(new TaxiPathNodeEntry(entry)));
|
||||
}
|
||||
if (startNode >= nodeId)
|
||||
return 0;
|
||||
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
|
||||
return pathId;
|
||||
}
|
||||
|
||||
586
LuaEngine.h
586
LuaEngine.h
@@ -14,61 +14,67 @@ extern "C"
|
||||
#include "lauxlib.h"
|
||||
};
|
||||
|
||||
#include "HookMgr.h"
|
||||
|
||||
// Required
|
||||
#include "AccountMgr.h"
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "Chat.h"
|
||||
#include "Channel.h"
|
||||
// Base
|
||||
#include "Common.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
// enums
|
||||
#ifdef MANGOS
|
||||
#include "Config/Config.h"
|
||||
#else
|
||||
#include "Config.h"
|
||||
#endif
|
||||
#include "DBCStores.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Language.h"
|
||||
#include "Mail.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "Pet.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "revision.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#ifdef MANGOS
|
||||
#include "ReactorAI.h"
|
||||
#include "revision_nr.h"
|
||||
#else
|
||||
#include "ScriptedCreature.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "WeatherMgr.h"
|
||||
#include "GameObjectAI.h"
|
||||
#endif
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
#include "Vehicle.h"
|
||||
#include "Group.h"
|
||||
#include "Item.h"
|
||||
#include "Weather.h"
|
||||
#include "World.h"
|
||||
|
||||
#ifdef MANGOS
|
||||
typedef SpellEffectIndex SpellEffIndex;
|
||||
typedef SpellEntry SpellInfo;
|
||||
typedef ItemPrototype ItemTemplate;
|
||||
#define GetTemplate GetProto
|
||||
#ifdef CLASSIC
|
||||
typedef int Difficulty;
|
||||
#endif
|
||||
#ifndef CLASSIC
|
||||
#include "ArenaTeam.h"
|
||||
#endif
|
||||
|
||||
typedef std::set<std::string> ScriptPaths;
|
||||
struct AreaTriggerEntry;
|
||||
#ifdef MANGOS
|
||||
class ReactorAI;
|
||||
typedef ReactorAI ScriptedAI;
|
||||
#else
|
||||
#undef UNORDERED_MAP
|
||||
#define UNORDERED_MAP std::unordered_map
|
||||
struct ScriptedAI;
|
||||
#endif
|
||||
class AuctionHouseObject;
|
||||
class Channel;
|
||||
class Creature;
|
||||
class CreatureAI;
|
||||
class GameObject;
|
||||
class Guild;
|
||||
class Group;
|
||||
class Item;
|
||||
class Player;
|
||||
class Quest;
|
||||
class Spell;
|
||||
class SpellCastTargets;
|
||||
class Transport;
|
||||
class Unit;
|
||||
class Weather;
|
||||
class WorldPacket;
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
#ifdef TRINITY
|
||||
class Vehicle;
|
||||
#else
|
||||
class VehicleInfo;
|
||||
typedef VehicleInfo Vehicle;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MANGOS
|
||||
#undef sWorld
|
||||
@@ -138,6 +144,8 @@ typedef ThreatContainer::StorageType ThreatList;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class Eluna;
|
||||
|
||||
template<typename T>
|
||||
struct ElunaRegister
|
||||
{
|
||||
@@ -152,6 +160,7 @@ struct EventMgr
|
||||
typedef std::set<LuaEvent*> EventSet;
|
||||
typedef std::map<EventProcessor*, EventSet> EventMap;
|
||||
// typedef UNORDERED_MAP<uint64, EventProcessor> ProcessorMap;
|
||||
Eluna& E;
|
||||
|
||||
EventMap LuaEvents; // LuaEvents[processor] = {LuaEvent, LuaEvent...}
|
||||
// ProcessorMap Processors; // Processors[guid] = processor
|
||||
@@ -159,13 +168,14 @@ struct EventMgr
|
||||
|
||||
struct LuaEvent : public BasicEvent
|
||||
{
|
||||
LuaEvent(EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj);
|
||||
LuaEvent(Eluna& _E, EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj);
|
||||
|
||||
~LuaEvent();
|
||||
|
||||
// Should never execute on dead events
|
||||
bool Execute(uint64 time, uint32 diff);
|
||||
|
||||
Eluna& E;
|
||||
EventProcessor* events; // Pointer to events (holds the timed event)
|
||||
int funcRef; // Lua function reference ID, also used as event ID
|
||||
uint32 delay; // Delay between event calls
|
||||
@@ -173,6 +183,15 @@ struct EventMgr
|
||||
Object* obj; // Object to push
|
||||
};
|
||||
|
||||
EventMgr(Eluna& _E) : E(_E)
|
||||
{
|
||||
}
|
||||
|
||||
~EventMgr()
|
||||
{
|
||||
RemoveEvents();
|
||||
}
|
||||
|
||||
// Should be run on world tick
|
||||
void Update(uint32 diff)
|
||||
{
|
||||
@@ -243,7 +262,7 @@ struct EventMgr
|
||||
{
|
||||
if (!events || funcRef <= 0) // If funcRef <= 0, function reference failed
|
||||
return 0; // on fail always return 0. funcRef can be negative.
|
||||
events->AddEvent(new LuaEvent(events, funcRef, delay, calls, obj), events->CalculateTime(delay));
|
||||
events->AddEvent(new LuaEvent(E, events, funcRef, delay, calls, obj), events->CalculateTime(delay));
|
||||
return funcRef; // return the event ID
|
||||
}
|
||||
|
||||
@@ -308,169 +327,168 @@ struct EventMgr
|
||||
if (RemoveEvent((it++)->first, eventId))
|
||||
break; // succesfully remove the event, stop loop.
|
||||
}
|
||||
};
|
||||
|
||||
~EventMgr()
|
||||
struct EventBind
|
||||
{
|
||||
typedef std::vector<int> ElunaBindingMap;
|
||||
typedef std::map<int, ElunaBindingMap> ElunaEntryMap;
|
||||
Eluna& E;
|
||||
|
||||
EventBind(Eluna& _E): E(_E)
|
||||
{
|
||||
RemoveEvents();
|
||||
}
|
||||
|
||||
~EventBind()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear(); // unregisters all registered functions and clears all registered events from the bind std::maps (reset)
|
||||
void Insert(int eventId, int funcRef); // Inserts a new registered event
|
||||
|
||||
// Gets the binding std::map containing all registered events with the function refs for the entry
|
||||
ElunaBindingMap* GetBindMap(int eventId)
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return NULL;
|
||||
ElunaEntryMap::iterator itr = Bindings.find(eventId);
|
||||
if (itr == Bindings.end())
|
||||
return NULL;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
// Checks if there are events for ID
|
||||
bool HasEvents(int eventId) const;
|
||||
|
||||
ElunaEntryMap Bindings; // Binding store Bindings[eventId] = {funcRef};
|
||||
};
|
||||
|
||||
struct EntryBind
|
||||
{
|
||||
typedef std::map<int, int> ElunaBindingMap;
|
||||
typedef UNORDERED_MAP<uint32, ElunaBindingMap> ElunaEntryMap;
|
||||
Eluna& E;
|
||||
|
||||
EntryBind(Eluna& _E): E(_E)
|
||||
{
|
||||
}
|
||||
|
||||
~EntryBind()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear(); // unregisters all registered functions and clears all registered events from the bind std::maps (reset)
|
||||
void Insert(uint32 entryId, int eventId, int funcRef); // Inserts a new registered event
|
||||
|
||||
// Gets the function ref of an entry for an event
|
||||
int GetBind(uint32 entryId, int eventId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return 0;
|
||||
ElunaEntryMap::const_iterator itr = Bindings.find(entryId);
|
||||
if (itr == Bindings.end() || itr->second.empty())
|
||||
return 0;
|
||||
ElunaBindingMap::const_iterator itr2 = itr->second.find(eventId);
|
||||
if (itr2 == itr->second.end())
|
||||
return 0;
|
||||
return itr2->second;
|
||||
}
|
||||
|
||||
// Gets the binding std::map containing all registered events with the function refs for the entry
|
||||
const ElunaBindingMap* GetBindMap(uint32 entryId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return NULL;
|
||||
ElunaEntryMap::const_iterator itr = Bindings.find(entryId);
|
||||
if (itr == Bindings.end())
|
||||
return NULL;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
// Returns true if the entry has registered binds
|
||||
bool HasBinds(uint32 entryId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return false;
|
||||
return Bindings.find(entryId) != Bindings.end();
|
||||
}
|
||||
|
||||
ElunaEntryMap Bindings; // Binding store Bindings[entryId][eventId] = funcRef;
|
||||
};
|
||||
|
||||
class Eluna
|
||||
{
|
||||
public:
|
||||
friend class ScriptMgr;
|
||||
// friend class ACE_Singleton<Eluna, ACE_Null_Mutex>;
|
||||
typedef std::set<std::string> ScriptPaths;
|
||||
|
||||
static Eluna* GEluna;
|
||||
|
||||
lua_State* L;
|
||||
EventMgr m_EventMgr;
|
||||
// ACE_Recursive_Thread_Mutex lock;
|
||||
int userdata_table;
|
||||
|
||||
Eluna()
|
||||
{
|
||||
L = NULL;
|
||||
}
|
||||
|
||||
~Eluna()
|
||||
{
|
||||
}
|
||||
|
||||
struct EventBind
|
||||
{
|
||||
typedef std::vector<int> ElunaBindingMap;
|
||||
typedef std::map<int, ElunaBindingMap> ElunaEntryMap;
|
||||
|
||||
~EventBind()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear(); // unregisters all registered functions and clears all registered events from the bind std::maps (reset)
|
||||
void Insert(int eventId, int funcRef); // Inserts a new registered event
|
||||
|
||||
// Gets the binding std::map containing all registered events with the function refs for the entry
|
||||
ElunaBindingMap* GetBindMap(int eventId)
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return NULL;
|
||||
ElunaEntryMap::iterator itr = Bindings.find(eventId);
|
||||
if (itr == Bindings.end())
|
||||
return NULL;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
// Checks if there are events for ID
|
||||
bool HasEvents(int eventId) const;
|
||||
// Cleans stack and pushes eventId
|
||||
void BeginCall(int eventId) const;
|
||||
// Loops through all registered events for the eventId at stack index 1
|
||||
// Copies the whole stack as arguments for the called function. Before Executing, push all params to stack!
|
||||
// Leaves return values from all functions in order to the stack.
|
||||
void ExecuteCall();
|
||||
void EndCall() const;
|
||||
|
||||
ElunaEntryMap Bindings; // Binding store Bindings[eventId] = {funcRef};
|
||||
};
|
||||
|
||||
struct EntryBind
|
||||
{
|
||||
typedef std::map<int, int> ElunaBindingMap;
|
||||
typedef UNORDERED_MAP<uint32, ElunaBindingMap> ElunaEntryMap;
|
||||
|
||||
~EntryBind()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear(); // unregisters all registered functions and clears all registered events from the bind std::maps (reset)
|
||||
void Insert(uint32 entryId, int eventId, int funcRef); // Inserts a new registered event
|
||||
|
||||
// Gets the function ref of an entry for an event
|
||||
int GetBind(uint32 entryId, int eventId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return 0;
|
||||
ElunaEntryMap::const_iterator itr = Bindings.find(entryId);
|
||||
if (itr == Bindings.end() || itr->second.empty())
|
||||
return 0;
|
||||
ElunaBindingMap::const_iterator itr2 = itr->second.find(eventId);
|
||||
if (itr2 == itr->second.end())
|
||||
return 0;
|
||||
return itr2->second;
|
||||
}
|
||||
|
||||
// Gets the binding std::map containing all registered events with the function refs for the entry
|
||||
const ElunaBindingMap* GetBindMap(uint32 entryId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return NULL;
|
||||
ElunaEntryMap::const_iterator itr = Bindings.find(entryId);
|
||||
if (itr == Bindings.end())
|
||||
return NULL;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
// Returns true if the entry has registered binds
|
||||
bool HasBinds(uint32 entryId) const
|
||||
{
|
||||
if (Bindings.empty())
|
||||
return false;
|
||||
return Bindings.find(entryId) != Bindings.end();
|
||||
}
|
||||
|
||||
ElunaEntryMap Bindings; // Binding store Bindings[entryId][eventId] = funcRef;
|
||||
};
|
||||
EventMgr* m_EventMgr;
|
||||
|
||||
// Use templates for EventBind
|
||||
EventBind PacketEventBindings;
|
||||
EventBind ServerEventBindings;
|
||||
EventBind PlayerEventBindings;
|
||||
EventBind GuildEventBindings;
|
||||
EventBind GroupEventBindings;
|
||||
EventBind VehicleEventBindings;
|
||||
EventBind* ServerEventBindings;
|
||||
EventBind* PlayerEventBindings;
|
||||
EventBind* GuildEventBindings;
|
||||
EventBind* GroupEventBindings;
|
||||
EventBind* VehicleEventBindings;
|
||||
|
||||
EntryBind CreatureEventBindings;
|
||||
EntryBind CreatureGossipBindings;
|
||||
EntryBind GameObjectEventBindings;
|
||||
EntryBind GameObjectGossipBindings;
|
||||
EntryBind ItemEventBindings;
|
||||
EntryBind ItemGossipBindings;
|
||||
EntryBind playerGossipBindings;
|
||||
EntryBind* PacketEventBindings;
|
||||
EntryBind* CreatureEventBindings;
|
||||
EntryBind* CreatureGossipBindings;
|
||||
EntryBind* GameObjectEventBindings;
|
||||
EntryBind* GameObjectGossipBindings;
|
||||
EntryBind* ItemEventBindings;
|
||||
EntryBind* ItemGossipBindings;
|
||||
EntryBind* playerGossipBindings;
|
||||
|
||||
Eluna();
|
||||
~Eluna();
|
||||
|
||||
static ScriptPaths scripts;
|
||||
static void Initialize();
|
||||
static void Uninitialize();
|
||||
static void ReloadEluna();
|
||||
void static GetScripts(std::string path, ScriptPaths& scripts);
|
||||
|
||||
static void report(lua_State*);
|
||||
static void ExecuteCall(lua_State* L, int params, int res);
|
||||
void Register(uint8 reg, uint32 id, uint32 evt, int func);
|
||||
void BeginCall(int fReference);
|
||||
bool ExecuteCall(int params, int res);
|
||||
void EndCall(int res);
|
||||
void GetScripts(std::string path, ScriptPaths& scripts);
|
||||
void RunScripts(ScriptPaths& scripts);
|
||||
static void RemoveRef(const void* obj);
|
||||
|
||||
// Pushes
|
||||
void Push(lua_State*); // nil
|
||||
void Push(lua_State*, const uint64);
|
||||
void Push(lua_State*, const int64);
|
||||
void Push(lua_State*, const uint32);
|
||||
void Push(lua_State*, const int32);
|
||||
void Push(lua_State*, const bool);
|
||||
void Push(lua_State*, const float);
|
||||
void Push(lua_State*, const double);
|
||||
void Push(lua_State*, const char*);
|
||||
void Push(lua_State*, const std::string);
|
||||
template<typename T> void Push(lua_State* L, T const* ptr)
|
||||
static void Push(lua_State*); // nil
|
||||
static void Push(lua_State*, const uint64);
|
||||
static void Push(lua_State*, const int64);
|
||||
static void Push(lua_State*, const uint32);
|
||||
static void Push(lua_State*, const int32);
|
||||
static void Push(lua_State*, const bool);
|
||||
static void Push(lua_State*, const float);
|
||||
static void Push(lua_State*, const double);
|
||||
static void Push(lua_State*, const char*);
|
||||
static void Push(lua_State*, const std::string);
|
||||
template<typename T> static void Push(lua_State* L, T const* ptr)
|
||||
{
|
||||
ElunaTemplate<T>::push(L, ptr);
|
||||
}
|
||||
void Push(lua_State* L, Object const* obj);
|
||||
void Push(lua_State* L, WorldObject const* obj);
|
||||
void Push(lua_State* L, Unit const* unit);
|
||||
void Push(lua_State* L, Pet const* pet);
|
||||
void Push(lua_State* L, TempSummon const* summon);
|
||||
static void Push(lua_State* L, Object const* obj);
|
||||
static void Push(lua_State* L, WorldObject const* obj);
|
||||
static void Push(lua_State* L, Unit const* unit);
|
||||
static void Push(lua_State* L, Pet const* pet);
|
||||
static void Push(lua_State* L, TempSummon const* summon);
|
||||
|
||||
// Checks
|
||||
template<typename T> T CHECKVAL(lua_State* L, int narg);
|
||||
template<typename T> T CHECKVAL(lua_State* L, int narg, T def);
|
||||
template<typename T> T* CHECKOBJ(lua_State* L, int narg, bool error = true)
|
||||
template<typename T> static T CHECKVAL(lua_State* L, int narg);
|
||||
template<typename T> static T CHECKVAL(lua_State* L, int narg, T def);
|
||||
template<typename T> static T* CHECKOBJ(lua_State* L, int narg, bool error = true)
|
||||
{
|
||||
return ElunaTemplate<T>::check(L, narg, error);
|
||||
}
|
||||
@@ -550,6 +568,167 @@ public:
|
||||
|
||||
WorldObjectInRangeCheck(WorldObjectInRangeCheck const&);
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature);
|
||||
#ifndef MANGOS
|
||||
GameObjectAI* GetAI(GameObject* gameObject);
|
||||
#endif
|
||||
|
||||
/* Custom */
|
||||
bool OnCommand(Player* player, const char* text);
|
||||
void OnWorldUpdate(uint32 diff);
|
||||
void OnLootItem(Player* pPlayer, Item* pItem, uint32 count, uint64 guid);
|
||||
void OnLootMoney(Player* pPlayer, uint32 amount);
|
||||
void OnFirstLogin(Player* pPlayer);
|
||||
void OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot);
|
||||
void OnRepop(Player* pPlayer);
|
||||
void OnResurrect(Player* pPlayer);
|
||||
void OnQuestAbandon(Player* pPlayer, uint32 questId);
|
||||
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
|
||||
void OnLuaStateClose();
|
||||
bool OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel);
|
||||
|
||||
/* Item */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
|
||||
bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest);
|
||||
bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
|
||||
bool OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
|
||||
bool OnItemGossip(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
|
||||
bool OnExpire(Player* pPlayer, ItemTemplate const* pProto);
|
||||
bool OnRemove(Player* pPlayer, Item* item);
|
||||
void HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, std::string code);
|
||||
|
||||
/* Creature */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Creature* pTarget);
|
||||
bool OnGossipHello(Player* pPlayer, Creature* pCreature);
|
||||
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 OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
|
||||
bool OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
|
||||
uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature);
|
||||
void OnSummoned(Creature* creature, Unit* summoner);
|
||||
|
||||
/* GameObject */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, GameObject* pTarget);
|
||||
bool OnGossipHello(Player* pPlayer, GameObject* pGameObject);
|
||||
bool OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action);
|
||||
bool OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code);
|
||||
bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
bool OnQuestComplete(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
uint32 GetDialogStatus(Player* pPlayer, GameObject* pGameObject);
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
void OnDestroyed(GameObject* pGameObject, Player* pPlayer);
|
||||
void OnDamaged(GameObject* pGameObject, Player* pPlayer);
|
||||
#endif
|
||||
#endif
|
||||
void OnLootStateChanged(GameObject* pGameObject, uint32 state);
|
||||
void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state);
|
||||
void UpdateAI(GameObject* pGameObject, uint32 diff);
|
||||
void OnSpawn(GameObject* gameobject);
|
||||
|
||||
/* Packet */
|
||||
bool OnPacketSend(WorldSession* session, WorldPacket& packet);
|
||||
void OnPacketSendAny(Player* player, WorldPacket& packet, bool& result);
|
||||
void OnPacketSendOne(Player* player, WorldPacket& packet, bool& result);
|
||||
bool OnPacketReceive(WorldSession* session, WorldPacket& packet);
|
||||
void OnPacketReceiveAny(Player* player, WorldPacket& packet, bool& result);
|
||||
void OnPacketReceiveOne(Player* player, WorldPacket& packet, bool& result);
|
||||
|
||||
/* Player */
|
||||
void OnPlayerEnterCombat(Player* pPlayer, Unit* pEnemy);
|
||||
void OnPlayerLeaveCombat(Player* pPlayer);
|
||||
void OnPVPKill(Player* pKiller, Player* pKilled);
|
||||
void OnCreatureKill(Player* pKiller, Creature* pKilled);
|
||||
void OnPlayerKilledByCreature(Creature* pKiller, Player* pKilled);
|
||||
void OnLevelChanged(Player* pPlayer, uint8 oldLevel);
|
||||
void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints);
|
||||
void OnTalentsReset(Player* pPlayer, bool noCost);
|
||||
void OnMoneyChanged(Player* pPlayer, int32& amount);
|
||||
void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim);
|
||||
void OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental);
|
||||
void OnDuelRequest(Player* pTarget, Player* pChallenger);
|
||||
void OnDuelStart(Player* pStarter, Player* pChallenger);
|
||||
void OnDuelEnd(Player* pWinner, Player* pLoser, DuelCompleteType type);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel);
|
||||
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver);
|
||||
void OnEmote(Player* pPlayer, uint32 emote);
|
||||
void OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, uint64 guid);
|
||||
void OnSpellCast(Player* pPlayer, Spell* pSpell, bool skipCheck);
|
||||
void OnLogin(Player* pPlayer);
|
||||
void OnLogout(Player* pPlayer);
|
||||
void OnCreate(Player* pPlayer);
|
||||
void OnDelete(uint32 guid);
|
||||
void OnSave(Player* pPlayer);
|
||||
void OnBindToInstance(Player* pPlayer, Difficulty difficulty, uint32 mapid, bool permanent);
|
||||
void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea);
|
||||
void OnMapChanged(Player* pPlayer);
|
||||
void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, std::string code);
|
||||
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
/* Vehicle */
|
||||
void OnInstall(Vehicle* vehicle);
|
||||
void OnUninstall(Vehicle* vehicle);
|
||||
void OnInstallAccessory(Vehicle* vehicle, Creature* accessory);
|
||||
void OnAddPassenger(Vehicle* vehicle, Unit* passenger, int8 seatId);
|
||||
void OnRemovePassenger(Vehicle* vehicle, Unit* passenger);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* AreaTrigger */
|
||||
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger);
|
||||
|
||||
/* Weather */
|
||||
void OnChange(Weather* weather, WeatherState state, float grade);
|
||||
|
||||
/* Auction House */
|
||||
void OnAdd(AuctionHouseObject* auctionHouse);
|
||||
void OnRemove(AuctionHouseObject* auctionHouse);
|
||||
void OnSuccessful(AuctionHouseObject* auctionHouse);
|
||||
void OnExpire(AuctionHouseObject* auctionHouse);
|
||||
|
||||
/* Guild */
|
||||
void OnAddMember(Guild* guild, Player* player, uint32 plRank);
|
||||
void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding);
|
||||
void OnMOTDChanged(Guild* guild, const std::string& newMotd);
|
||||
void OnInfoChanged(Guild* guild, const std::string& newInfo);
|
||||
void OnCreate(Guild* guild, Player* leader, const std::string& name);
|
||||
void OnDisband(Guild* guild);
|
||||
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair);
|
||||
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
|
||||
void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId);
|
||||
void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank);
|
||||
void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId);
|
||||
|
||||
/* Group */
|
||||
void OnAddMember(Group* group, uint64 guid);
|
||||
void OnInviteMember(Group* group, uint64 guid);
|
||||
void OnRemoveMember(Group* group, uint64 guid, uint8 method);
|
||||
void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid);
|
||||
void OnDisband(Group* group);
|
||||
void OnCreate(Group* group, uint64 leaderGuid, GroupType groupType);
|
||||
|
||||
/* Map */
|
||||
void OnCreate(Map* map);
|
||||
void OnDestroy(Map* map);
|
||||
void OnPlayerEnter(Map* map, Player* player);
|
||||
void OnPlayerLeave(Map* map, Player* player);
|
||||
void OnUpdate(Map* map, uint32 diff);
|
||||
|
||||
/* World */
|
||||
void OnOpenStateChange(bool open);
|
||||
void OnConfigLoad(bool reload);
|
||||
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask);
|
||||
void OnShutdownCancel();
|
||||
void OnUpdate(uint32 diff);
|
||||
void OnStartup();
|
||||
void OnShutdown();
|
||||
};
|
||||
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error);
|
||||
template<> Player* Eluna::CHECKOBJ<Player>(lua_State* L, int narg, bool error);
|
||||
@@ -557,13 +736,9 @@ template<> Creature* Eluna::CHECKOBJ<Creature>(lua_State* L, int narg, bool erro
|
||||
template<> GameObject* Eluna::CHECKOBJ<GameObject>(lua_State* L, int narg, bool error);
|
||||
template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error);
|
||||
|
||||
#ifdef MANGOS
|
||||
#define sEluna (&MaNGOS::Singleton<Eluna>::Instance())
|
||||
#else
|
||||
#define sEluna ACE_Singleton<Eluna, ACE_Null_Mutex>::instance()
|
||||
#endif
|
||||
#define sEluna Eluna::GEluna
|
||||
|
||||
#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);
|
||||
|
||||
template<typename T>
|
||||
class ElunaTemplate
|
||||
@@ -679,7 +854,7 @@ public:
|
||||
|
||||
if (!manageMemory)
|
||||
{
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, sHookMgr->userdata_table);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, sEluna->userdata_table);
|
||||
lua_pushfstring(L, "%p", obj);
|
||||
lua_gettable(L, -2);
|
||||
if (!lua_isnoneornil(L, -1) && luaL_checkudata(L, -1, tname))
|
||||
@@ -692,11 +867,11 @@ public:
|
||||
}
|
||||
|
||||
// Create new userdata
|
||||
T const** ptrHold = (T const**)lua_newuserdata(L, sizeof(T const**));
|
||||
T const** ptrHold = static_cast<T const**>(lua_newuserdata(L, sizeof(T const*)));
|
||||
if (!ptrHold)
|
||||
{
|
||||
ELUNA_LOG_ERROR("%s could not create new userdata", tname);
|
||||
lua_remove(L, -1);
|
||||
lua_pop(L, manageMemory ? 1 : 2);
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
@@ -707,18 +882,17 @@ public:
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
ELUNA_LOG_ERROR("%s missing metatable", tname);
|
||||
lua_pop(L, 2);
|
||||
lua_pop(L, manageMemory ? 2 : 3);
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
|
||||
if (!manageMemory)
|
||||
{
|
||||
lua_pushfstring(L, "%p", obj);
|
||||
lua_pushvalue(L, -2);
|
||||
lua_settable(L, -3);
|
||||
lua_settable(L, -4);
|
||||
lua_remove(L, -2);
|
||||
}
|
||||
return 1;
|
||||
@@ -741,7 +915,7 @@ public:
|
||||
if (!manageMemory)
|
||||
{
|
||||
// Check pointer validity
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, sHookMgr->userdata_table);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, sEluna->userdata_table);
|
||||
lua_pushfstring(L, "%p", *ptrHold);
|
||||
lua_gettable(L, -2);
|
||||
lua_remove(L, -2);
|
||||
@@ -767,7 +941,7 @@ public:
|
||||
|
||||
static int thunk(lua_State* L)
|
||||
{
|
||||
T* obj = sEluna->CHECKOBJ<T>(L, 1); // get self
|
||||
T* obj = Eluna::CHECKOBJ<T>(L, 1); // get self
|
||||
if (!obj)
|
||||
return 0;
|
||||
ElunaRegister<T>* l = static_cast<ElunaRegister<T>*>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
@@ -785,7 +959,7 @@ public:
|
||||
|
||||
static int tostringT(lua_State* L)
|
||||
{
|
||||
T* obj = sEluna->CHECKOBJ<T>(L, 1); // get self
|
||||
T* obj = Eluna::CHECKOBJ<T>(L, 1); // get self
|
||||
if (obj)
|
||||
{
|
||||
lua_pushfstring(L, "%s: (%p)", tname, obj);
|
||||
@@ -798,12 +972,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LuaTaxiMgr
|
||||
{
|
||||
private:
|
||||
static uint32 nodeId;
|
||||
public:
|
||||
static void StartTaxi(Player* player, uint32 pathid);
|
||||
static uint32 AddPath(std::list<TaxiPathNodeEntry> nodes, uint32 mountA, uint32 mountH, uint32 price = 0, uint32 pathId = 0);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
*/
|
||||
|
||||
// Eluna
|
||||
#include "HookMgr.h"
|
||||
#include "LuaEngine.h"
|
||||
#include "Includes.h"
|
||||
// Methods
|
||||
#include "GlobalMethods.h"
|
||||
#include "ObjectMethods.h"
|
||||
@@ -30,7 +32,7 @@
|
||||
void RegisterGlobals(lua_State* L)
|
||||
{
|
||||
// Hooks
|
||||
lua_register(L, "RegisterPacketEvent", &LuaGlobalFunctions::RegisterPacketEvent); // RegisterPacketEvent(opcodeID, function)
|
||||
lua_register(L, "RegisterPacketEvent", &LuaGlobalFunctions::RegisterPacketEvent); // RegisterPacketEvent(opcodeID, event, function)
|
||||
lua_register(L, "RegisterServerEvent", &LuaGlobalFunctions::RegisterServerEvent); // RegisterServerEvent(event, function)
|
||||
lua_register(L, "RegisterPlayerEvent", &LuaGlobalFunctions::RegisterPlayerEvent); // RegisterPlayerEvent(event, function)
|
||||
lua_register(L, "RegisterGuildEvent", &LuaGlobalFunctions::RegisterGuildEvent); // RegisterGuildEvent(event, function)
|
||||
@@ -75,7 +77,7 @@ void RegisterGlobals(lua_State* L)
|
||||
lua_register(L, "GetMapById", &LuaGlobalFunctions::GetMapById); // GetMapById(mapId, instance) - Returns map object of id specified. UNDOCUMENTED
|
||||
|
||||
// Other
|
||||
// lua_register(L, "ReloadEluna", &LuaGlobalFunctions::ReloadEluna); // ReloadEluna() - Reload's Eluna engine. Returns true if reload succesful.
|
||||
lua_register(L, "ReloadEluna", &LuaGlobalFunctions::ReloadEluna); // ReloadEluna() - Reload's Eluna engine.
|
||||
lua_register(L, "SendWorldMessage", &LuaGlobalFunctions::SendWorldMessage); // SendWorldMessage(msg) - Sends a broadcast message to everyone
|
||||
lua_register(L, "WorldDBQuery", &LuaGlobalFunctions::WorldDBQuery); // WorldDBQuery(sql) - Executes given SQL query to world database instantly and returns a QueryResult object
|
||||
lua_register(L, "WorldDBExecute", &LuaGlobalFunctions::WorldDBExecute); // WorldDBExecute(sql) - Executes given SQL query to world database (not instant)
|
||||
@@ -1193,7 +1195,7 @@ void RegisterFunctions(lua_State* L)
|
||||
{
|
||||
RegisterGlobals(L);
|
||||
|
||||
// You should add sHookMgr->RemoveRef(this); to all destructors for objects that are NOT mem managed (gc) by lua.
|
||||
// You should add Eluna::RemoveRef(this); to all destructors for objects that are NOT mem managed (gc) by lua.
|
||||
// Exceptions being Quest type static data structs that will never be destructed (during runtime), though they can have it as well.
|
||||
|
||||
ElunaTemplate<Object>::Register(L, "Object");
|
||||
|
||||
44
MapMethods.h
44
MapMethods.h
@@ -13,7 +13,7 @@ namespace LuaMap
|
||||
#ifndef CLASSIC
|
||||
int IsArena(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->IsBattleArena());
|
||||
Eluna::Push(L, map->IsBattleArena());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@@ -21,99 +21,99 @@ namespace LuaMap
|
||||
int IsBattleground(lua_State* L, Map* map)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, map->IsBattleGround());
|
||||
Eluna::Push(L, map->IsBattleGround());
|
||||
#else
|
||||
sEluna->Push(L, map->IsBattleground());
|
||||
Eluna::Push(L, map->IsBattleground());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsDungeon(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->IsDungeon());
|
||||
Eluna::Push(L, map->IsDungeon());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsEmpty(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->isEmpty());
|
||||
Eluna::Push(L, map->isEmpty());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
int IsHeroic(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->IsHeroic());
|
||||
Eluna::Push(L, map->IsHeroic());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int IsRaid(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->IsRaid());
|
||||
Eluna::Push(L, map->IsRaid());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetName(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->GetMapName());
|
||||
Eluna::Push(L, map->GetMapName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetHeight(lua_State* L, Map* map)
|
||||
{
|
||||
float x = sEluna->CHECKVAL<float>(L, 2);
|
||||
float y = sEluna->CHECKVAL<float>(L, 3);
|
||||
float x = Eluna::CHECKVAL<float>(L, 2);
|
||||
float y = Eluna::CHECKVAL<float>(L, 3);
|
||||
#if (defined(TBC) || defined(CLASSIC))
|
||||
float z = map->GetHeight(x, y, MAX_HEIGHT);
|
||||
#else
|
||||
uint32 phasemask = sEluna->CHECKVAL<uint32>(L, 4, 1);
|
||||
uint32 phasemask = Eluna::CHECKVAL<uint32>(L, 4, 1);
|
||||
float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT);
|
||||
#endif
|
||||
if (z != INVALID_HEIGHT)
|
||||
sEluna->Push(L, z);
|
||||
Eluna::Push(L, z);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDifficulty(lua_State* L, Map* map)
|
||||
{
|
||||
#ifndef CLASSIC
|
||||
sEluna->Push(L, map->GetDifficulty());
|
||||
Eluna::Push(L, map->GetDifficulty());
|
||||
#else
|
||||
sEluna->Push(L, (Difficulty)0);
|
||||
Eluna::Push(L, (Difficulty)0);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInstanceId(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->GetInstanceId());
|
||||
Eluna::Push(L, map->GetInstanceId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayerCount(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->GetPlayersCountExceptGMs());
|
||||
Eluna::Push(L, map->GetPlayersCountExceptGMs());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMapId(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->GetId());
|
||||
Eluna::Push(L, map->GetId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAreaId(lua_State* L, Map* map)
|
||||
{
|
||||
float x = sEluna->CHECKVAL<float>(L, 2);
|
||||
float y = sEluna->CHECKVAL<float>(L, 3);
|
||||
float z = sEluna->CHECKVAL<float>(L, 4);
|
||||
float x = Eluna::CHECKVAL<float>(L, 2);
|
||||
float y = Eluna::CHECKVAL<float>(L, 3);
|
||||
float z = Eluna::CHECKVAL<float>(L, 4);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, map->GetTerrain()->GetAreaId(x, y, z));
|
||||
Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z));
|
||||
#else
|
||||
sEluna->Push(L, map->GetAreaId(x, y, z));
|
||||
Eluna::Push(L, map->GetAreaId(x, y, z));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
102
ObjectMethods.h
102
ObjectMethods.h
@@ -12,90 +12,90 @@ namespace LuaObject
|
||||
/* BOOLEAN */
|
||||
int HasFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
sEluna->Push(L, obj->HasFlag(index, flag));
|
||||
Eluna::Push(L, obj->HasFlag(index, flag));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsInWorld(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->IsInWorld());
|
||||
Eluna::Push(L, obj->IsInWorld());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
sEluna->Push(L, obj->GetInt32Value(index));
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetInt32Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
sEluna->Push(L, obj->GetUInt32Value(index));
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetUInt32Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetFloatValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
sEluna->Push(L, obj->GetFloatValue(index));
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetFloatValue(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetByteValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
sEluna->Push(L, obj->GetByteValue(index, offset));
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
Eluna::Push(L, obj->GetByteValue(index, offset));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
sEluna->Push(L, obj->GetUInt16Value(index, offset));
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
Eluna::Push(L, obj->GetUInt16Value(index, offset));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetScale(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetObjectScale());
|
||||
Eluna::Push(L, obj->GetObjectScale());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetEntry(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetEntry());
|
||||
Eluna::Push(L, obj->GetEntry());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUID(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GET_GUID());
|
||||
Eluna::Push(L, obj->GET_GUID());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUIDLow(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetGUIDLow());
|
||||
Eluna::Push(L, obj->GetGUIDLow());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetTypeId(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetTypeId());
|
||||
Eluna::Push(L, obj->GetTypeId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt64Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
obj->GetUInt64Value(index);
|
||||
return 0;
|
||||
}
|
||||
@@ -103,8 +103,8 @@ namespace LuaObject
|
||||
/* SETTERS */
|
||||
int SetFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
obj->SetFlag(index, flag);
|
||||
return 0;
|
||||
@@ -112,24 +112,24 @@ namespace LuaObject
|
||||
|
||||
int SetInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
int32 value = sEluna->CHECKVAL<int32>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
int32 value = Eluna::CHECKVAL<int32>(L, 3);
|
||||
obj->SetInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
obj->SetUInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetFloatValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
float value = sEluna->CHECKVAL<float>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
float value = Eluna::CHECKVAL<float>(L, 3);
|
||||
|
||||
obj->SetFloatValue(index, value);
|
||||
return 0;
|
||||
@@ -137,34 +137,34 @@ namespace LuaObject
|
||||
|
||||
int SetByteValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
uint8 value = sEluna->CHECKVAL<uint8>(L, 4);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
uint8 value = Eluna::CHECKVAL<uint8>(L, 4);
|
||||
obj->SetByteValue(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetUInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
uint16 value = sEluna->CHECKVAL<uint16>(L, 4);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
uint16 value = Eluna::CHECKVAL<uint16>(L, 4);
|
||||
obj->SetUInt16Value(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
int16 value = sEluna->CHECKVAL<int16>(L, 4);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
int16 value = Eluna::CHECKVAL<int16>(L, 4);
|
||||
obj->SetInt16Value(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetScale(lua_State* L, Object* obj)
|
||||
{
|
||||
float size = sEluna->CHECKVAL<float>(L, 2);
|
||||
float size = Eluna::CHECKVAL<float>(L, 2);
|
||||
|
||||
obj->SetObjectScale(size);
|
||||
return 0;
|
||||
@@ -172,8 +172,8 @@ namespace LuaObject
|
||||
|
||||
int SetUInt64Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint64 value = sEluna->CHECKVAL<uint64>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint64 value = Eluna::CHECKVAL<uint64>(L, 3);
|
||||
obj->SetUInt64Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
@@ -181,8 +181,8 @@ namespace LuaObject
|
||||
/* OTHER */
|
||||
int RemoveFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
obj->RemoveFlag(index, flag);
|
||||
return 0;
|
||||
@@ -190,39 +190,39 @@ namespace LuaObject
|
||||
|
||||
int UpdateUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
obj->UpdateUInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ToCorpse(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToCorpse());
|
||||
Eluna::Push(L, obj->ToCorpse());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ToGameObject(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToGameObject());
|
||||
Eluna::Push(L, obj->ToGameObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ToUnit(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToUnit());
|
||||
Eluna::Push(L, obj->ToUnit());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ToCreature(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToCreature());
|
||||
Eluna::Push(L, obj->ToCreature());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ToPlayer(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToPlayer());
|
||||
Eluna::Push(L, obj->ToPlayer());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
812
PlayerMethods.h
812
PlayerMethods.h
File diff suppressed because it is too large
Load Diff
@@ -17,13 +17,13 @@ namespace LuaQuery
|
||||
/* BOOLEAN */
|
||||
int IsNull(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
#ifdef MANGOS
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].IsNULL());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].IsNULL());
|
||||
#else
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].IsNull());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].IsNull());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -31,119 +31,119 @@ namespace LuaQuery
|
||||
/* GETTERS */
|
||||
int GetColumnCount(lua_State* L, QueryResult* result)
|
||||
{
|
||||
sEluna->Push(L, RESULT->GetFieldCount());
|
||||
Eluna::Push(L, RESULT->GetFieldCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRowCount(lua_State* L, QueryResult* result)
|
||||
{
|
||||
if (RESULT->GetRowCount() > (uint32)-1)
|
||||
sEluna->Push(L, (uint32)-1);
|
||||
Eluna::Push(L, (uint32)-1);
|
||||
else
|
||||
sEluna->Push(L, RESULT->GetRowCount());
|
||||
Eluna::Push(L, RESULT->GetRowCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBool(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetBool());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetBool());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt8(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetUInt8());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetUInt8());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt16(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetUInt16());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetUInt16());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt32(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetUInt32());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetUInt32());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt64(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetUInt64());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetUInt64());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInt8(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetInt8());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetInt8());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInt16(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetInt16());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetInt16());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInt32(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetInt32());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetInt32());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInt64(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetInt64());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetInt64());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetFloat(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetFloat());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetFloat());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDouble(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetDouble());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetDouble());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetString(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (col < RESULT->GetFieldCount())
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetString());
|
||||
Eluna::Push(L, RESULT->Fetch()[col].GetString());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int NextRow(lua_State* L, QueryResult* result)
|
||||
{
|
||||
sEluna->Push(L, RESULT->NextRow());
|
||||
Eluna::Push(L, RESULT->NextRow());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace LuaQuest
|
||||
/* BOOLEAN */
|
||||
int HasFlag(lua_State* L, Quest* quest)
|
||||
{
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, quest->HasQuestFlag((QuestFlags)flag));
|
||||
Eluna::Push(L, quest->HasQuestFlag((QuestFlags)flag));
|
||||
#else
|
||||
sEluna->Push(L, quest->HasFlag(flag));
|
||||
Eluna::Push(L, quest->HasFlag(flag));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -24,73 +24,73 @@ namespace LuaQuest
|
||||
#ifndef CLASSIC
|
||||
int IsDaily(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->IsDaily());
|
||||
Eluna::Push(L, quest->IsDaily());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int IsRepeatable(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->IsRepeatable());
|
||||
Eluna::Push(L, quest->IsRepeatable());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetId(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetQuestId());
|
||||
Eluna::Push(L, quest->GetQuestId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetQuestLevel());
|
||||
Eluna::Push(L, quest->GetQuestLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMinLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetMinLevel());
|
||||
Eluna::Push(L, quest->GetMinLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNextQuestId(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetNextQuestId());
|
||||
Eluna::Push(L, quest->GetNextQuestId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPrevQuestId(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetPrevQuestId());
|
||||
Eluna::Push(L, quest->GetPrevQuestId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNextQuestInChain(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetNextQuestInChain());
|
||||
Eluna::Push(L, quest->GetNextQuestInChain());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetFlags(lua_State* L, Quest* quest)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, quest->GetQuestFlags());
|
||||
Eluna::Push(L, quest->GetQuestFlags());
|
||||
#else
|
||||
sEluna->Push(L, quest->GetFlags());
|
||||
Eluna::Push(L, quest->GetFlags());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetType(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetType());
|
||||
Eluna::Push(L, quest->GetType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int GetMaxLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetMaxLevel());
|
||||
Eluna::Push(L, quest->GetMaxLevel());
|
||||
return 1;
|
||||
}*/
|
||||
};
|
||||
|
||||
@@ -12,41 +12,41 @@ namespace LuaSpell
|
||||
/* BOOLEAN */
|
||||
int IsAutoRepeat(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->IsAutoRepeat());
|
||||
Eluna::Push(L, spell->IsAutoRepeat());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetCaster(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->GetCaster());
|
||||
Eluna::Push(L, spell->GetCaster());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCastTime(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->GetCastTime());
|
||||
Eluna::Push(L, spell->GetCastTime());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetId(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->m_spellInfo->Id);
|
||||
Eluna::Push(L, spell->m_spellInfo->Id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPowerCost(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->GetPowerCost());
|
||||
Eluna::Push(L, spell->GetPowerCost());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDuration(lua_State* L, Spell* spell)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, GetSpellDuration(spell->m_spellInfo));
|
||||
Eluna::Push(L, GetSpellDuration(spell->m_spellInfo));
|
||||
#else
|
||||
sEluna->Push(L, spell->GetSpellInfo()->GetDuration());
|
||||
Eluna::Push(L, spell->GetSpellInfo()->GetDuration());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -64,9 +64,9 @@ namespace LuaSpell
|
||||
float x, y, z;
|
||||
spell->m_targets.GetDstPos()->GetPosition(x, y, z);
|
||||
#endif
|
||||
sEluna->Push(L, x);
|
||||
sEluna->Push(L, y);
|
||||
sEluna->Push(L, z);
|
||||
Eluna::Push(L, x);
|
||||
Eluna::Push(L, y);
|
||||
Eluna::Push(L, z);
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -74,24 +74,24 @@ namespace LuaSpell
|
||||
{
|
||||
#ifdef MANGOS
|
||||
if (GameObject* target = spell->m_targets.getGOTarget())
|
||||
sEluna->Push(sEluna->L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (Item* target = spell->m_targets.getItemTarget())
|
||||
sEluna->Push(sEluna->L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (Corpse* target = spell->GetCaster()->GetMap()->GetCorpse(spell->m_targets.getCorpseTargetGuid()))
|
||||
sEluna->Push(sEluna->L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (Unit* target = spell->m_targets.getUnitTarget())
|
||||
sEluna->Push(sEluna->L, target);
|
||||
Eluna::Push(L, target);
|
||||
#else
|
||||
if (GameObject* target = spell->m_targets.GetGOTarget())
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (Item* target = spell->m_targets.GetItemTarget())
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (Corpse* target = spell->m_targets.GetCorpseTarget())
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (Unit* target = spell->m_targets.GetUnitTarget())
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
else if (WorldObject* target = spell->m_targets.GetObjectTarget())
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace LuaSpell
|
||||
/* SETTERS */
|
||||
int SetAutoRepeat(lua_State* L, Spell* spell)
|
||||
{
|
||||
bool repeat = sEluna->CHECKVAL<bool>(L, 2);
|
||||
bool repeat = Eluna::CHECKVAL<bool>(L, 2);
|
||||
spell->SetAutoRepeat(repeat);
|
||||
return 0;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace LuaSpell
|
||||
/* OTHER */
|
||||
int Cast(lua_State* L, Spell* spell)
|
||||
{
|
||||
bool skipCheck = sEluna->CHECKVAL<bool>(L, 2);
|
||||
bool skipCheck = Eluna::CHECKVAL<bool>(L, 2);
|
||||
spell->cast(skipCheck);
|
||||
return 0;
|
||||
}
|
||||
|
||||
534
UnitMethods.h
534
UnitMethods.h
File diff suppressed because it is too large
Load Diff
@@ -14,11 +14,11 @@ namespace LuaVehicle
|
||||
/* BOOLEAN */
|
||||
int IsOnBoard(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, vehicle->HasOnBoard(passenger));
|
||||
Eluna::Push(L, vehicle->HasOnBoard(passenger));
|
||||
#else
|
||||
sEluna->Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
|
||||
Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -27,9 +27,9 @@ namespace LuaVehicle
|
||||
int GetOwner(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, vehicle->GetOwner());
|
||||
Eluna::Push(L, vehicle->GetOwner());
|
||||
#else
|
||||
sEluna->Push(L, vehicle->GetBase());
|
||||
Eluna::Push(L, vehicle->GetBase());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -37,25 +37,25 @@ namespace LuaVehicle
|
||||
int GetEntry(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, vehicle->GetVehicleEntry()->m_ID);
|
||||
Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID);
|
||||
#else
|
||||
sEluna->Push(L, vehicle->GetVehicleInfo()->m_ID);
|
||||
Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
int8 seatId = sEluna->CHECKVAL<int8>(L, 2);
|
||||
sEluna->Push(L, vehicle->GetPassenger(seatId));
|
||||
int8 seatId = Eluna::CHECKVAL<int8>(L, 2);
|
||||
Eluna::Push(L, vehicle->GetPassenger(seatId));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int AddPassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
int8 seatId = sEluna->CHECKVAL<int8>(L, 3);
|
||||
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
int8 seatId = Eluna::CHECKVAL<int8>(L, 3);
|
||||
#ifdef MANGOS
|
||||
if (vehicle->CanBoard(passenger))
|
||||
vehicle->Board(passenger, seatId);
|
||||
@@ -67,7 +67,7 @@ namespace LuaVehicle
|
||||
|
||||
int RemovePassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
#ifdef MANGOS
|
||||
vehicle->UnBoard(passenger, false);
|
||||
#else
|
||||
|
||||
@@ -12,15 +12,15 @@ namespace LuaWeather
|
||||
/* GETTERS */
|
||||
int GetZoneId(lua_State* L, Weather* weather)
|
||||
{
|
||||
sEluna->Push(L, weather->GetZone());
|
||||
Eluna::Push(L, weather->GetZone());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetWeather(lua_State* L, Weather* weather)
|
||||
{
|
||||
uint32 weatherType = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
float grade = sEluna->CHECKVAL<float>(L, 3);
|
||||
uint32 weatherType = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
float grade = Eluna::CHECKVAL<float>(L, 3);
|
||||
|
||||
weather->SetWeather((WeatherType)weatherType, grade);
|
||||
return 0;
|
||||
@@ -28,7 +28,7 @@ namespace LuaWeather
|
||||
|
||||
int SendWeatherUpdateToPlayer(lua_State* L, Weather* weather)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
weather->SendWeatherUpdateToPlayer(player);
|
||||
return 0;
|
||||
@@ -37,13 +37,13 @@ namespace LuaWeather
|
||||
/* OTHER */
|
||||
int Regenerate(lua_State* L, Weather* weather)
|
||||
{
|
||||
sEluna->Push(L, weather->ReGenerate());
|
||||
Eluna::Push(L, weather->ReGenerate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int UpdateWeather(lua_State* L, Weather* weather)
|
||||
{
|
||||
sEluna->Push(L, weather->UpdateWeather());
|
||||
Eluna::Push(L, weather->UpdateWeather());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,84 +12,84 @@ namespace LuaWorldObject
|
||||
/* GETTERS */
|
||||
int GetName(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetName());
|
||||
Eluna::Push(L, obj->GetName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMap(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetMap());
|
||||
Eluna::Push(L, obj->GetMap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
int GetPhaseMask(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetPhaseMask());
|
||||
Eluna::Push(L, obj->GetPhaseMask());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int GetInstanceId(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetInstanceId());
|
||||
Eluna::Push(L, obj->GetInstanceId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAreaId(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetAreaId());
|
||||
Eluna::Push(L, obj->GetAreaId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetZoneId(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetZoneId());
|
||||
Eluna::Push(L, obj->GetZoneId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMapId(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetMapId());
|
||||
Eluna::Push(L, obj->GetMapId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetX(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetPositionX());
|
||||
Eluna::Push(L, obj->GetPositionX());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetY(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetPositionY());
|
||||
Eluna::Push(L, obj->GetPositionY());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetZ(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetPositionZ());
|
||||
Eluna::Push(L, obj->GetPositionZ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetO(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetOrientation());
|
||||
Eluna::Push(L, obj->GetOrientation());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLocation(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetPositionX());
|
||||
sEluna->Push(L, obj->GetPositionY());
|
||||
sEluna->Push(L, obj->GetPositionZ());
|
||||
sEluna->Push(L, obj->GetOrientation());
|
||||
Eluna::Push(L, obj->GetPositionX());
|
||||
Eluna::Push(L, obj->GetPositionY());
|
||||
Eluna::Push(L, obj->GetPositionZ());
|
||||
Eluna::Push(L, obj->GetOrientation());
|
||||
return 4;
|
||||
}
|
||||
|
||||
int GetNearestPlayer(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
|
||||
Unit* target = NULL;
|
||||
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER);
|
||||
@@ -101,14 +101,14 @@ namespace LuaWorldObject
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNearestGameObject(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
GameObject* target = NULL;
|
||||
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry);
|
||||
@@ -120,14 +120,14 @@ namespace LuaWorldObject
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNearestCreature(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
Creature* target = NULL;
|
||||
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry);
|
||||
@@ -139,13 +139,13 @@ namespace LuaWorldObject
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayersInRange(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
|
||||
std::list<Player*> list;
|
||||
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER);
|
||||
@@ -163,8 +163,8 @@ namespace LuaWorldObject
|
||||
|
||||
for (std::list<Player*>::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
sEluna->Push(L, ++i);
|
||||
sEluna->Push(L, *it);
|
||||
Eluna::Push(L, ++i);
|
||||
Eluna::Push(L, *it);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace LuaWorldObject
|
||||
|
||||
int GetCreaturesInRange(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
std::list<Creature*> list;
|
||||
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry);
|
||||
@@ -193,8 +193,8 @@ namespace LuaWorldObject
|
||||
|
||||
for (std::list<Creature*>::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
sEluna->Push(L, ++i);
|
||||
sEluna->Push(L, *it);
|
||||
Eluna::Push(L, ++i);
|
||||
Eluna::Push(L, *it);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ namespace LuaWorldObject
|
||||
|
||||
int GetGameObjectsInRange(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
float range = Eluna::CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
std::list<GameObject*> list;
|
||||
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry);
|
||||
@@ -223,8 +223,8 @@ namespace LuaWorldObject
|
||||
|
||||
for (std::list<GameObject*>::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
sEluna->Push(L, ++i);
|
||||
sEluna->Push(L, *it);
|
||||
Eluna::Push(L, ++i);
|
||||
Eluna::Push(L, *it);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
|
||||
@@ -234,11 +234,11 @@ namespace LuaWorldObject
|
||||
|
||||
int GetNearObject(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
bool nearest = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
float range = sEluna->CHECKVAL<float>(L, 3, SIZE_OF_GRIDS);
|
||||
uint16 type = sEluna->CHECKVAL<uint16>(L, 4, 0); // TypeMask
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 5, 0);
|
||||
uint32 hostile = sEluna->CHECKVAL<uint32>(L, 6, 0); // 0 none, 1 hostile, 2 friendly
|
||||
bool nearest = Eluna::CHECKVAL<bool>(L, 2, true);
|
||||
float range = Eluna::CHECKVAL<float>(L, 3, SIZE_OF_GRIDS);
|
||||
uint16 type = Eluna::CHECKVAL<uint16>(L, 4, 0); // TypeMask
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 5, 0);
|
||||
uint32 hostile = Eluna::CHECKVAL<uint32>(L, 6, 0); // 0 none, 1 hostile, 2 friendly
|
||||
|
||||
float x, y, z;
|
||||
obj->GetPosition(x, y, z);
|
||||
@@ -254,7 +254,7 @@ namespace LuaWorldObject
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
Eluna::Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -274,8 +274,8 @@ namespace LuaWorldObject
|
||||
|
||||
for (std::list<WorldObject*>::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
sEluna->Push(L, ++i);
|
||||
sEluna->Push(L, *it);
|
||||
Eluna::Push(L, ++i);
|
||||
Eluna::Push(L, *it);
|
||||
lua_settable(L, tbl);
|
||||
}
|
||||
|
||||
@@ -288,31 +288,31 @@ namespace LuaWorldObject
|
||||
|
||||
int GetWorldObject(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2);
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
switch (GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER: sEluna->Push(L, obj->GetMap()->GetPlayer(ObjectGuid(guid))); break;
|
||||
case HIGHGUID_PLAYER: Eluna::Push(L, obj->GetMap()->GetPlayer(ObjectGuid(guid))); break;
|
||||
case HIGHGUID_TRANSPORT:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
case HIGHGUID_GAMEOBJECT: sEluna->Push(L, obj->GetMap()->GetGameObject(ObjectGuid(guid))); break;
|
||||
case HIGHGUID_GAMEOBJECT: Eluna::Push(L, obj->GetMap()->GetGameObject(ObjectGuid(guid))); break;
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
case HIGHGUID_VEHICLE:
|
||||
#endif
|
||||
case HIGHGUID_UNIT:
|
||||
case HIGHGUID_PET: sEluna->Push(L, obj->GetMap()->GetAnyTypeCreature(ObjectGuid(guid))); break;
|
||||
case HIGHGUID_PET: Eluna::Push(L, obj->GetMap()->GetAnyTypeCreature(ObjectGuid(guid))); break;
|
||||
}
|
||||
#else
|
||||
switch (GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER: sEluna->Push(L, sObjectAccessor->GetPlayer(*obj, ObjectGuid(guid))); break;
|
||||
case HIGHGUID_PLAYER: Eluna::Push(L, sObjectAccessor->GetPlayer(*obj, ObjectGuid(guid))); break;
|
||||
case HIGHGUID_TRANSPORT:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
case HIGHGUID_GAMEOBJECT: sEluna->Push(L, sObjectAccessor->GetGameObject(*obj, ObjectGuid(guid))); break;
|
||||
case HIGHGUID_GAMEOBJECT: Eluna::Push(L, sObjectAccessor->GetGameObject(*obj, ObjectGuid(guid))); break;
|
||||
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;
|
||||
case HIGHGUID_UNIT: Eluna::Push(L, sObjectAccessor->GetCreature(*obj, ObjectGuid(guid))); break;
|
||||
case HIGHGUID_PET: Eluna::Push(L, sObjectAccessor->GetPet(*obj, ObjectGuid(guid))); break;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
@@ -320,44 +320,44 @@ namespace LuaWorldObject
|
||||
|
||||
int GetDistance(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
WorldObject* target = sEluna->CHECKOBJ<WorldObject>(L, 2, false);
|
||||
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
|
||||
if (target && target->IsInWorld())
|
||||
sEluna->Push(L, obj->GetDistance(target));
|
||||
Eluna::Push(L, obj->GetDistance(target));
|
||||
else
|
||||
{
|
||||
float X = sEluna->CHECKVAL<float>(L, 2);
|
||||
float Y = sEluna->CHECKVAL<float>(L, 3);
|
||||
float Z = sEluna->CHECKVAL<float>(L, 4);
|
||||
sEluna->Push(L, obj->GetDistance(X, Y, Z));
|
||||
float X = Eluna::CHECKVAL<float>(L, 2);
|
||||
float Y = Eluna::CHECKVAL<float>(L, 3);
|
||||
float Z = Eluna::CHECKVAL<float>(L, 4);
|
||||
Eluna::Push(L, obj->GetDistance(X, Y, Z));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRelativePoint(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float dist = sEluna->CHECKVAL<float>(L, 2);
|
||||
float rad = sEluna->CHECKVAL<float>(L, 3);
|
||||
float dist = Eluna::CHECKVAL<float>(L, 2);
|
||||
float rad = Eluna::CHECKVAL<float>(L, 3);
|
||||
|
||||
float x, y, z;
|
||||
obj->GetClosePoint(x, y, z, 0.0f, dist, rad);
|
||||
|
||||
sEluna->Push(L, x);
|
||||
sEluna->Push(L, y);
|
||||
sEluna->Push(L, z);
|
||||
Eluna::Push(L, x);
|
||||
Eluna::Push(L, y);
|
||||
Eluna::Push(L, z);
|
||||
return 3;
|
||||
}
|
||||
|
||||
int GetAngle(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
WorldObject* target = sEluna->CHECKOBJ<WorldObject>(L, 2, false);
|
||||
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
|
||||
|
||||
if (target && target->IsInWorld())
|
||||
sEluna->Push(L, obj->GetAngle(target));
|
||||
Eluna::Push(L, obj->GetAngle(target));
|
||||
else
|
||||
{
|
||||
float x = sEluna->CHECKVAL<float>(L, 2);
|
||||
float y = sEluna->CHECKVAL<float>(L, 3);
|
||||
sEluna->Push(L, obj->GetAngle(x, y));
|
||||
float x = Eluna::CHECKVAL<float>(L, 2);
|
||||
float y = Eluna::CHECKVAL<float>(L, 3);
|
||||
Eluna::Push(L, obj->GetAngle(x, y));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -365,36 +365,36 @@ namespace LuaWorldObject
|
||||
/* OTHER */
|
||||
int SendPacket(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
|
||||
obj->SendMessageToSet(data, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SummonGameObject(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
float x = sEluna->CHECKVAL<float>(L, 3);
|
||||
float y = sEluna->CHECKVAL<float>(L, 4);
|
||||
float z = sEluna->CHECKVAL<float>(L, 5);
|
||||
float o = sEluna->CHECKVAL<float>(L, 6);
|
||||
uint32 respawnDelay = sEluna->CHECKVAL<uint32>(L, 7, 30);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
float x = Eluna::CHECKVAL<float>(L, 3);
|
||||
float y = Eluna::CHECKVAL<float>(L, 4);
|
||||
float z = Eluna::CHECKVAL<float>(L, 5);
|
||||
float o = Eluna::CHECKVAL<float>(L, 6);
|
||||
uint32 respawnDelay = Eluna::CHECKVAL<uint32>(L, 7, 30);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, obj->SummonGameObject(entry, x, y, z, o, respawnDelay));
|
||||
Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, respawnDelay));
|
||||
#else
|
||||
sEluna->Push(L, obj->SummonGameObject(entry, x, y, z, o, 0, 0, 0, 0, respawnDelay));
|
||||
Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, 0, 0, 0, 0, respawnDelay));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SpawnCreature(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
float x = sEluna->CHECKVAL<float>(L, 3);
|
||||
float y = sEluna->CHECKVAL<float>(L, 4);
|
||||
float z = sEluna->CHECKVAL<float>(L, 5);
|
||||
float o = sEluna->CHECKVAL<float>(L, 6);
|
||||
uint32 spawnType = sEluna->CHECKVAL<uint32>(L, 7, 8);
|
||||
uint32 despawnTimer = sEluna->CHECKVAL<uint32>(L, 8, 0);
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
float x = Eluna::CHECKVAL<float>(L, 3);
|
||||
float y = Eluna::CHECKVAL<float>(L, 4);
|
||||
float z = Eluna::CHECKVAL<float>(L, 5);
|
||||
float o = Eluna::CHECKVAL<float>(L, 6);
|
||||
uint32 spawnType = Eluna::CHECKVAL<uint32>(L, 7, 8);
|
||||
uint32 despawnTimer = Eluna::CHECKVAL<uint32>(L, 8, 0);
|
||||
|
||||
TempSummonType type;
|
||||
switch (spawnType)
|
||||
@@ -423,7 +423,7 @@ namespace LuaWorldObject
|
||||
default:
|
||||
return luaL_argerror(L, 7, "valid SpawnType expected");
|
||||
}
|
||||
sEluna->Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer));
|
||||
Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer));
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,21 +12,21 @@ namespace LuaPacket
|
||||
// GetOpcode()
|
||||
int GetOpcode(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
sEluna->Push(L, packet->GetOpcode());
|
||||
Eluna::Push(L, packet->GetOpcode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// GetSize()
|
||||
int GetSize(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
sEluna->Push(L, packet->size());
|
||||
Eluna::Push(L, packet->size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// SetOpcode(opcode)
|
||||
int SetOpcode(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint32 opcode = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 opcode = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (opcode >= NUM_MSG_TYPES)
|
||||
return luaL_argerror(L, 2, "valid opcode expected");
|
||||
packet->SetOpcode((Opcodes)opcode);
|
||||
@@ -38,7 +38,7 @@ namespace LuaPacket
|
||||
{
|
||||
int8 byte;
|
||||
(*packet) >> byte;
|
||||
sEluna->Push(L, byte);
|
||||
Eluna::Push(L, byte);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace LuaPacket
|
||||
{
|
||||
uint8 byte;
|
||||
(*packet) >> byte;
|
||||
sEluna->Push(L, byte);
|
||||
Eluna::Push(L, byte);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace LuaPacket
|
||||
{
|
||||
int16 _short;
|
||||
(*packet) >> _short;
|
||||
sEluna->Push(L, _short);
|
||||
Eluna::Push(L, _short);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace LuaPacket
|
||||
{
|
||||
uint16 _ushort;
|
||||
(*packet) >> _ushort;
|
||||
sEluna->Push(L, _ushort);
|
||||
Eluna::Push(L, _ushort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace LuaPacket
|
||||
{
|
||||
int32 _long;
|
||||
(*packet) >> _long;
|
||||
sEluna->Push(L, _long);
|
||||
Eluna::Push(L, _long);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace LuaPacket
|
||||
{
|
||||
uint32 _ulong;
|
||||
(*packet) >> _ulong;
|
||||
sEluna->Push(L, _ulong);
|
||||
Eluna::Push(L, _ulong);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace LuaPacket
|
||||
{
|
||||
float _val;
|
||||
(*packet) >> _val;
|
||||
sEluna->Push(L, _val);
|
||||
Eluna::Push(L, _val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace LuaPacket
|
||||
{
|
||||
double _val;
|
||||
(*packet) >> _val;
|
||||
sEluna->Push(L, _val);
|
||||
Eluna::Push(L, _val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace LuaPacket
|
||||
{
|
||||
uint64 guid;
|
||||
(*packet) >> guid;
|
||||
sEluna->Push(L, guid);
|
||||
Eluna::Push(L, guid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -119,14 +119,14 @@ namespace LuaPacket
|
||||
{
|
||||
std::string _val;
|
||||
(*packet) >> _val;
|
||||
sEluna->Push(L, _val);
|
||||
Eluna::Push(L, _val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WriteGUID(guid)
|
||||
int WriteGUID(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2);
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
|
||||
(*packet) << guid;
|
||||
return 0;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ namespace LuaPacket
|
||||
// WriteString(string)
|
||||
int WriteString(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
std::string _val = sEluna->CHECKVAL<std::string>(L, 2);
|
||||
std::string _val = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ namespace LuaPacket
|
||||
// WriteBye(byte)
|
||||
int WriteByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int8 byte = sEluna->CHECKVAL<int8>(L, 2);
|
||||
int8 byte = Eluna::CHECKVAL<int8>(L, 2);
|
||||
(*packet) << byte;
|
||||
return 0;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace LuaPacket
|
||||
// WriteUByte(byte)
|
||||
int WriteUByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint8 byte = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
uint8 byte = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
(*packet) << byte;
|
||||
return 0;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ namespace LuaPacket
|
||||
// WriteUShort(short)
|
||||
int WriteUShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint16 _ushort = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint16 _ushort = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
(*packet) << _ushort;
|
||||
return 0;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace LuaPacket
|
||||
// WriteShort(short)
|
||||
int WriteShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int16 _short = sEluna->CHECKVAL<int16>(L, 2);
|
||||
int16 _short = Eluna::CHECKVAL<int16>(L, 2);
|
||||
(*packet) << _short;
|
||||
return 0;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace LuaPacket
|
||||
// WriteLong(long)
|
||||
int WriteLong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int32 _long = sEluna->CHECKVAL<int32>(L, 2);
|
||||
int32 _long = Eluna::CHECKVAL<int32>(L, 2);
|
||||
(*packet) << _long;
|
||||
return 0;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ namespace LuaPacket
|
||||
// WriteULong(long)
|
||||
int WriteULong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint32 _ulong = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
uint32 _ulong = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
(*packet) << _ulong;
|
||||
return 0;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ namespace LuaPacket
|
||||
// WriteFloat(float)
|
||||
int WriteFloat(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
float _val = sEluna->CHECKVAL<float>(L, 2);
|
||||
float _val = Eluna::CHECKVAL<float>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ namespace LuaPacket
|
||||
// WriteDouble(double)
|
||||
int WriteDouble(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
double _val = sEluna->CHECKVAL<double>(L, 2);
|
||||
double _val = Eluna::CHECKVAL<double>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user