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

View File

@@ -11,77 +11,77 @@ namespace LuaAura
{ {
int GetCaster(lua_State* L, Aura* aura) int GetCaster(lua_State* L, Aura* aura)
{ {
sEluna->Push(L, aura->GetCaster()); Eluna::Push(L, aura->GetCaster());
return 1; return 1;
} }
int GetCasterGUID(lua_State* L, Aura* aura) int GetCasterGUID(lua_State* L, Aura* aura)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, aura->GetCasterGuid()); Eluna::Push(L, aura->GetCasterGuid());
#else #else
sEluna->Push(L, aura->GetCasterGUID()); Eluna::Push(L, aura->GetCasterGUID());
#endif #endif
return 1; return 1;
} }
int GetCasterLevel(lua_State* L, Aura* aura) int GetCasterLevel(lua_State* L, Aura* aura)
{ {
sEluna->Push(L, aura->GetCaster()->getLevel()); Eluna::Push(L, aura->GetCaster()->getLevel());
return 1; return 1;
} }
int GetDuration(lua_State* L, Aura* aura) int GetDuration(lua_State* L, Aura* aura)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, aura->GetAuraDuration()); Eluna::Push(L, aura->GetAuraDuration());
#else #else
sEluna->Push(L, aura->GetDuration()); Eluna::Push(L, aura->GetDuration());
#endif #endif
return 1; return 1;
} }
int GetCharges(lua_State* L, Aura* aura) int GetCharges(lua_State* L, Aura* aura)
{ {
sEluna->Push(L, aura->GetStackAmount()); Eluna::Push(L, aura->GetStackAmount());
return 1; return 1;
} }
int GetAuraId(lua_State* L, Aura* aura) int GetAuraId(lua_State* L, Aura* aura)
{ {
sEluna->Push(L, aura->GetId()); Eluna::Push(L, aura->GetId());
return 1; return 1;
} }
int GetMaxDuration(lua_State* L, Aura* aura) int GetMaxDuration(lua_State* L, Aura* aura)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, aura->GetAuraMaxDuration()); Eluna::Push(L, aura->GetAuraMaxDuration());
#else #else
sEluna->Push(L, aura->GetMaxDuration()); Eluna::Push(L, aura->GetMaxDuration());
#endif #endif
return 1; return 1;
} }
int GetStackAmount(lua_State* L, Aura* aura) int GetStackAmount(lua_State* L, Aura* aura)
{ {
sEluna->Push(L, aura->GetStackAmount()); Eluna::Push(L, aura->GetStackAmount());
return 1; return 1;
} }
int GetOwner(lua_State* L, Aura* aura) int GetOwner(lua_State* L, Aura* aura)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, aura->GetTarget()); Eluna::Push(L, aura->GetTarget());
#else #else
sEluna->Push(L, aura->GetOwner()); Eluna::Push(L, aura->GetOwner());
#endif #endif
return 1; return 1;
} }
int SetDuration(lua_State* L, Aura* aura) int SetDuration(lua_State* L, Aura* aura)
{ {
int duration = sEluna->CHECKVAL<int>(L, 2); int duration = Eluna::CHECKVAL<int>(L, 2);
#ifdef MANGOS #ifdef MANGOS
aura->GetHolder()->SetAuraDuration(duration); aura->GetHolder()->SetAuraDuration(duration);
#else #else
@@ -92,7 +92,7 @@ namespace LuaAura
int SetMaxDuration(lua_State* L, Aura* aura) int SetMaxDuration(lua_State* L, Aura* aura)
{ {
int duration = sEluna->CHECKVAL<int>(L, 2); int duration = Eluna::CHECKVAL<int>(L, 2);
#ifdef MANGOS #ifdef MANGOS
aura->GetHolder()->SetAuraMaxDuration(duration); aura->GetHolder()->SetAuraMaxDuration(duration);
#else #else
@@ -103,8 +103,8 @@ namespace LuaAura
int SetStackAmount(lua_State* L, Aura* aura) int SetStackAmount(lua_State* L, Aura* aura)
{ {
int amount = sEluna->CHECKVAL<int>(L, 2); int amount = Eluna::CHECKVAL<int>(L, 2);
int duration = sEluna->CHECKVAL<int>(L, 2); int duration = Eluna::CHECKVAL<int>(L, 2);
#ifdef MANGOS #ifdef MANGOS
aura->GetHolder()->SetStackAmount(amount); aura->GetHolder()->SetStackAmount(amount);
#else #else
@@ -115,7 +115,7 @@ namespace LuaAura
int Remove(lua_State* L, Aura* aura) int Remove(lua_State* L, Aura* aura)
{ {
int duration = sEluna->CHECKVAL<int>(L, 2); int duration = Eluna::CHECKVAL<int>(L, 2);
#ifdef MANGOS #ifdef MANGOS
aura->GetHolder()->RemoveAura(aura->GetEffIndex()); aura->GetHolder()->RemoveAura(aura->GetEffIndex());
#else #else

View File

@@ -13,9 +13,9 @@ namespace LuaCorpse
int GetOwnerGUID(lua_State* L, Corpse* corpse) int GetOwnerGUID(lua_State* L, Corpse* corpse)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, corpse->GetOwnerGuid()); Eluna::Push(L, corpse->GetOwnerGuid());
#else #else
sEluna->Push(L, corpse->GetOwnerGUID()); Eluna::Push(L, corpse->GetOwnerGUID());
#endif #endif
return 1; return 1;
} }
@@ -23,14 +23,14 @@ namespace LuaCorpse
// GetGhostTime() // GetGhostTime()
int GetGhostTime(lua_State* L, Corpse* corpse) int GetGhostTime(lua_State* L, Corpse* corpse)
{ {
sEluna->Push(L, uint32(corpse->GetGhostTime())); Eluna::Push(L, uint32(corpse->GetGhostTime()));
return 1; return 1;
} }
// GetType() // GetType()
int GetType(lua_State* L, Corpse* corpse) int GetType(lua_State* L, Corpse* corpse)
{ {
sEluna->Push(L, corpse->GetType()); Eluna::Push(L, corpse->GetType());
return 1; return 1;
} }

View File

@@ -12,70 +12,70 @@ namespace LuaCreature
/* BOOLEAN */ /* BOOLEAN */
int IsReputationGainDisabled(lua_State* L, Creature* creature) int IsReputationGainDisabled(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsReputationGainDisabled()); Eluna::Push(L, creature->IsReputationGainDisabled());
return 1; return 1;
} }
int IsRegeneratingHealth(lua_State* L, Creature* creature) int IsRegeneratingHealth(lua_State* L, Creature* creature)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->IsRegeneratingHealth()); Eluna::Push(L, creature->IsRegeneratingHealth());
#else #else
sEluna->Push(L, creature->isRegeneratingHealth()); Eluna::Push(L, creature->isRegeneratingHealth());
#endif #endif
return 1; return 1;
} }
int HasInvolvedQuest(lua_State* L, Creature* creature) 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 #ifdef MANGOS
sEluna->Push(L, creature->HasInvolvedQuest(quest_id)); Eluna::Push(L, creature->HasInvolvedQuest(quest_id));
#else #else
sEluna->Push(L, creature->hasInvolvedQuest(quest_id)); Eluna::Push(L, creature->hasInvolvedQuest(quest_id));
#endif #endif
return 1; return 1;
} }
int IsTargetAcceptable(lua_State* L, Creature* creature) 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; return 1;
} }
int CanAssistTo(lua_State* L, Creature* creature) int CanAssistTo(lua_State* L, Creature* creature)
{ {
Unit* u = sEluna->CHECKOBJ<Unit>(L, 2); Unit* u = Eluna::CHECKOBJ<Unit>(L, 2);
Unit* enemy = sEluna->CHECKOBJ<Unit>(L, 3); Unit* enemy = Eluna::CHECKOBJ<Unit>(L, 3);
bool checkfaction = sEluna->CHECKVAL<bool>(L, 4, true); 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; return 1;
} }
int HasSearchedAssistance(lua_State* L, Creature* creature) int HasSearchedAssistance(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->HasSearchedAssistance()); Eluna::Push(L, creature->HasSearchedAssistance());
return 1; return 1;
} }
int IsTappedBy(lua_State* L, Creature* creature) 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; return 1;
} }
int HasLootRecipient(lua_State* L, Creature* creature) int HasLootRecipient(lua_State* L, Creature* creature)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->HasLootRecipient()); Eluna::Push(L, creature->HasLootRecipient());
#else #else
sEluna->Push(L, creature->hasLootRecipient()); Eluna::Push(L, creature->hasLootRecipient());
#endif #endif
return 1; return 1;
} }
@@ -84,222 +84,222 @@ namespace LuaCreature
{ {
#ifdef MANGOS #ifdef MANGOS
if (CreatureAI* ai = creature->AI()) if (CreatureAI* ai = creature->AI())
sEluna->Push(L, ai->IsCombatMovement()); Eluna::Push(L, ai->IsCombatMovement());
else else
sEluna->Push(L, false); Eluna::Push(L, false);
#else #else
sEluna->Push(L, !creature->HasReactState(REACT_PASSIVE)); Eluna::Push(L, !creature->HasReactState(REACT_PASSIVE));
#endif #endif
return 1; return 1;
} }
int CanSwim(lua_State* L, Creature* creature) int CanSwim(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->CanSwim()); Eluna::Push(L, creature->CanSwim());
return 1; return 1;
} }
int CanWalk(lua_State* L, Creature* creature) int CanWalk(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->CanWalk()); Eluna::Push(L, creature->CanWalk());
return 1; return 1;
} }
int IsInEvadeMode(lua_State* L, Creature* creature) int IsInEvadeMode(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsInEvadeMode()); Eluna::Push(L, creature->IsInEvadeMode());
return 1; return 1;
} }
int IsElite(lua_State* L, Creature* creature) int IsElite(lua_State* L, Creature* creature)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->IsElite()); Eluna::Push(L, creature->IsElite());
#else #else
sEluna->Push(L, creature->isElite()); Eluna::Push(L, creature->isElite());
#endif #endif
return 1; return 1;
} }
int IsGuard(lua_State* L, Creature* creature) int IsGuard(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsGuard()); Eluna::Push(L, creature->IsGuard());
return 1; return 1;
} }
int IsCivilian(lua_State* L, Creature* creature) int IsCivilian(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsCivilian()); Eluna::Push(L, creature->IsCivilian());
return 1; return 1;
} }
int IsRacialLeader(lua_State* L, Creature* creature) int IsRacialLeader(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsRacialLeader()); Eluna::Push(L, creature->IsRacialLeader());
return 1; return 1;
} }
int IsWorldBoss(lua_State* L, Creature* creature) int IsWorldBoss(lua_State* L, Creature* creature)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->IsWorldBoss()); Eluna::Push(L, creature->IsWorldBoss());
#else #else
sEluna->Push(L, creature->isWorldBoss()); Eluna::Push(L, creature->isWorldBoss());
#endif #endif
return 1; return 1;
} }
int HasCategoryCooldown(lua_State* L, Creature* creature) 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; return 1;
} }
int HasSpell(lua_State* L, Creature* creature) 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; return 1;
} }
int HasQuest(lua_State* L, Creature* creature) int HasQuest(lua_State* L, Creature* creature)
{ {
uint32 questId = sEluna->CHECKVAL<uint32>(L, 2); uint32 questId = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->HasQuest(questId)); Eluna::Push(L, creature->HasQuest(questId));
#else #else
sEluna->Push(L, creature->hasQuest(questId)); Eluna::Push(L, creature->hasQuest(questId));
#endif #endif
return 1; return 1;
} }
int HasSpellCooldown(lua_State* L, Creature* creature) 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; return 1;
} }
int CanFly(lua_State* L, Creature* creature) int CanFly(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->CanFly()); Eluna::Push(L, creature->CanFly());
return 1; return 1;
} }
/*int IsTrigger(lua_State* L, Creature* creature) /*int IsTrigger(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsTrigger()); Eluna::Push(L, creature->IsTrigger());
return 1; return 1;
}*/ }*/
/*int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature) /*int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->IsDamageEnoughForLootingAndReward()); Eluna::Push(L, creature->IsDamageEnoughForLootingAndReward());
return 1; return 1;
}*/ }*/
/*int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side /*int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side
{ {
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2); Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
bool force = sEluna->CHECKVAL<bool>(L, 3, true); bool force = Eluna::CHECKVAL<bool>(L, 3, true);
sEluna->Push(L, creature->CanStartAttack(target, force)); Eluna::Push(L, creature->CanStartAttack(target, force));
return 1; return 1;
}*/ }*/
/*int HasLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features /*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; return 1;
}*/ }*/
/* GETTERS */ /* GETTERS */
int GetRespawnDelay(lua_State* L, Creature* creature) int GetRespawnDelay(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetRespawnDelay()); Eluna::Push(L, creature->GetRespawnDelay());
return 1; return 1;
} }
int GetRespawnRadius(lua_State* L, Creature* creature) int GetRespawnRadius(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetRespawnRadius()); Eluna::Push(L, creature->GetRespawnRadius());
return 1; return 1;
} }
int GetDefaultMovementType(lua_State* L, Creature* creature) int GetDefaultMovementType(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetDefaultMovementType()); Eluna::Push(L, creature->GetDefaultMovementType());
return 1; return 1;
} }
int GetAggroRange(lua_State* L, Creature* creature) 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; return 1;
} }
int GetAttackDistance(lua_State* L, Creature* creature) 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; return 1;
} }
int GetLootRecipientGroup(lua_State* L, Creature* creature) int GetLootRecipientGroup(lua_State* L, Creature* creature)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->GetGroupLootRecipient()); Eluna::Push(L, creature->GetGroupLootRecipient());
#else #else
sEluna->Push(L, creature->GetLootRecipientGroup()); Eluna::Push(L, creature->GetLootRecipientGroup());
#endif #endif
return 1; return 1;
} }
int GetLootRecipient(lua_State* L, Creature* creature) int GetLootRecipient(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetLootRecipient()); Eluna::Push(L, creature->GetLootRecipient());
return 1; return 1;
} }
int GetScriptName(lua_State* L, Creature* creature) int GetScriptName(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetScriptName()); Eluna::Push(L, creature->GetScriptName());
return 1; return 1;
} }
int GetAIName(lua_State* L, Creature* creature) int GetAIName(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetAIName()); Eluna::Push(L, creature->GetAIName());
return 1; return 1;
} }
int GetScriptId(lua_State* L, Creature* creature) int GetScriptId(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetScriptId()); Eluna::Push(L, creature->GetScriptId());
return 1; return 1;
} }
int GetCreatureSpellCooldownDelay(lua_State* L, Creature* creature) 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; return 1;
} }
int GetCorpseDelay(lua_State* L, Creature* creature) int GetCorpseDelay(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetCorpseDelay()); Eluna::Push(L, creature->GetCorpseDelay());
return 1; return 1;
} }
@@ -312,20 +312,20 @@ namespace LuaCreature
creature->GetHomePosition(x, y, z, o); creature->GetHomePosition(x, y, z, o);
#endif #endif
sEluna->Push(L, x); Eluna::Push(L, x);
sEluna->Push(L, y); Eluna::Push(L, y);
sEluna->Push(L, z); Eluna::Push(L, z);
sEluna->Push(L, o); Eluna::Push(L, o);
return 4; return 4;
} }
int GetAITarget(lua_State* L, Creature* creature) int GetAITarget(lua_State* L, Creature* creature)
{ {
uint32 targetType = sEluna->CHECKVAL<uint32>(L, 2); uint32 targetType = Eluna::CHECKVAL<uint32>(L, 2);
bool playerOnly = sEluna->CHECKVAL<bool>(L, 3, false); bool playerOnly = Eluna::CHECKVAL<bool>(L, 3, false);
uint32 position = sEluna->CHECKVAL<uint32>(L, 4, 0); uint32 position = Eluna::CHECKVAL<uint32>(L, 4, 0);
float dist = sEluna->CHECKVAL<float>(L, 5, -1.0f); float dist = Eluna::CHECKVAL<float>(L, 5, -1.0f);
int32 aura = sEluna->CHECKVAL<int32>(L, 6, 0); int32 aura = Eluna::CHECKVAL<int32>(L, 6, 0);
ThreatList const& threatlist = creature->getThreatManager().getThreatList(); ThreatList const& threatlist = creature->getThreatManager().getThreatList();
if (position >= threatlist.size()) if (position >= threatlist.size())
@@ -361,20 +361,20 @@ namespace LuaCreature
{ {
std::list<Unit*>::const_iterator itr = targetList.begin(); std::list<Unit*>::const_iterator itr = targetList.begin();
std::advance(itr, position); std::advance(itr, position);
sEluna->Push(L, *itr); Eluna::Push(L, *itr);
} }
case SELECT_TARGET_FARTHEST: case SELECT_TARGET_FARTHEST:
case SELECT_TARGET_BOTTOMAGGRO: case SELECT_TARGET_BOTTOMAGGRO:
{ {
std::list<Unit*>::reverse_iterator ritr = targetList.rbegin(); std::list<Unit*>::reverse_iterator ritr = targetList.rbegin();
std::advance(ritr, position); std::advance(ritr, position);
sEluna->Push(L, *ritr); Eluna::Push(L, *ritr);
} }
case SELECT_TARGET_RANDOM: case SELECT_TARGET_RANDOM:
{ {
std::list<Unit*>::const_iterator itr = targetList.begin(); std::list<Unit*>::const_iterator itr = targetList.begin();
std::advance(itr, urand(position, targetList.size() - 1)); std::advance(itr, urand(position, targetList.size() - 1));
sEluna->Push(L, *itr); Eluna::Push(L, *itr);
} }
default: default:
luaL_argerror(L, 2, "SelectAggroTarget expected"); luaL_argerror(L, 2, "SelectAggroTarget expected");
@@ -397,8 +397,8 @@ namespace LuaCreature
if (!target) if (!target)
continue; continue;
++i; ++i;
sEluna->Push(L, i); Eluna::Push(L, i);
sEluna->Push(L, target); Eluna::Push(L, target);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
@@ -408,34 +408,34 @@ namespace LuaCreature
int GetAITargetsCount(lua_State* L, Creature* creature) int GetAITargetsCount(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->getThreatManager().getThreatList().size()); Eluna::Push(L, creature->getThreatManager().getThreatList().size());
return 1; return 1;
} }
int GetNPCFlags(lua_State* L, Creature* creature) 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; return 1;
} }
#ifndef CATA #ifndef CATA
int GetShieldBlockValue(lua_State* L, Creature* creature) int GetShieldBlockValue(lua_State* L, Creature* creature)
{ {
sEluna->Push(L, creature->GetShieldBlockValue()); Eluna::Push(L, creature->GetShieldBlockValue());
return 1; return 1;
} }
#endif #endif
/*int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features /*int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
{ {
sEluna->Push(L, creature->GetLootMode()); Eluna::Push(L, creature->GetLootMode());
return 1; return 1;
}*/ }*/
/* SETTERS */ /* SETTERS */
int SetNPCFlags(lua_State* L, Creature* creature) 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); creature->SetUInt32Value(UNIT_NPC_FLAGS, flags);
return 0; return 0;
@@ -443,7 +443,7 @@ namespace LuaCreature
int SetDeathState(lua_State* L, Creature* creature) int SetDeathState(lua_State* L, Creature* creature)
{ {
int32 state = sEluna->CHECKVAL<int32>(L, 2); int32 state = Eluna::CHECKVAL<int32>(L, 2);
#ifdef MANGOS #ifdef MANGOS
creature->SetDeathState((DeathState)state); creature->SetDeathState((DeathState)state);
@@ -455,7 +455,7 @@ namespace LuaCreature
int SetWalk(lua_State* L, Creature* creature) // TODO: Move same to Player ? 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); creature->SetWalk(enable);
return 0; return 0;
@@ -463,7 +463,7 @@ namespace LuaCreature
int SetAllowedCombat(lua_State* L, Creature* creature) int SetAllowedCombat(lua_State* L, Creature* creature)
{ {
bool allow = sEluna->CHECKVAL<bool>(L, 2); bool allow = Eluna::CHECKVAL<bool>(L, 2);
#ifdef MANGOS #ifdef MANGOS
if (CreatureAI* ai = creature->AI()) if (CreatureAI* ai = creature->AI())
@@ -476,7 +476,7 @@ namespace LuaCreature
int SetDisableReputationGain(lua_State* L, Creature* creature) 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); creature->SetDisableReputationGain(disable);
return 0; return 0;
@@ -490,7 +490,7 @@ namespace LuaCreature
int SetRespawnRadius(lua_State* L, Creature* creature) int SetRespawnRadius(lua_State* L, Creature* creature)
{ {
float dist = sEluna->CHECKVAL<float>(L, 2); float dist = Eluna::CHECKVAL<float>(L, 2);
creature->SetRespawnRadius(dist); creature->SetRespawnRadius(dist);
return 0; return 0;
@@ -498,7 +498,7 @@ namespace LuaCreature
int SetRespawnDelay(lua_State* L, Creature* creature) int SetRespawnDelay(lua_State* L, Creature* creature)
{ {
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2); uint32 delay = Eluna::CHECKVAL<uint32>(L, 2);
creature->SetRespawnDelay(delay); creature->SetRespawnDelay(delay);
return 0; return 0;
@@ -506,7 +506,7 @@ namespace LuaCreature
int SetDefaultMovementType(lua_State* L, Creature* creature) 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); creature->SetDefaultMovementType((MovementGeneratorType)type);
return 0; return 0;
@@ -514,7 +514,7 @@ namespace LuaCreature
int SetNoSearchAssistance(lua_State* L, Creature* creature) 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); creature->SetNoSearchAssistance(val);
return 0; return 0;
@@ -522,7 +522,7 @@ namespace LuaCreature
int SetNoCallAssistance(lua_State* L, Creature* creature) 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); creature->SetNoCallAssistance(val);
return 0; return 0;
@@ -530,7 +530,7 @@ namespace LuaCreature
int SetHover(lua_State* L, Creature* creature) 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 #ifdef MANGOS
creature->SetLevitate(enable); creature->SetLevitate(enable);
@@ -542,7 +542,7 @@ namespace LuaCreature
/*int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features /*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); creature->SetLootMode(lootMode);
return 0; return 0;
@@ -550,17 +550,17 @@ namespace LuaCreature
/*int SetDisableGravity(lua_State* L, Creature* creature) /*int SetDisableGravity(lua_State* L, Creature* creature)
{ {
bool disable = sEluna->CHECKVAL<bool>(L, 2, true); bool disable = Eluna::CHECKVAL<bool>(L, 2, true);
bool packetOnly = sEluna->CHECKVAL<bool>(L, 3, false); bool packetOnly = Eluna::CHECKVAL<bool>(L, 3, false);
sEluna->Push(L, creature->SetDisableGravity(disable, packetOnly)); Eluna::Push(L, creature->SetDisableGravity(disable, packetOnly));
return 1; return 1;
}*/ }*/
/* OTHER */ /* OTHER */
int DespawnOrUnsummon(lua_State* L, Creature* creature) 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 #ifdef MANGOS
creature->ForcedDespawn(msTimeToDespawn); creature->ForcedDespawn(msTimeToDespawn);
@@ -600,7 +600,7 @@ namespace LuaCreature
int CallForHelp(lua_State* L, Creature* creature) int CallForHelp(lua_State* L, Creature* creature)
{ {
float radius = sEluna->CHECKVAL<float>(L, 2); float radius = Eluna::CHECKVAL<float>(L, 2);
creature->CallForHelp(radius); creature->CallForHelp(radius);
return 0; return 0;
@@ -614,7 +614,7 @@ namespace LuaCreature
int AttackStart(lua_State* L, Creature* creature) 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); creature->AI()->AttackStart(target);
return 0; return 0;
@@ -629,9 +629,9 @@ namespace LuaCreature
int SelectVictim(lua_State* L, Creature* creature) int SelectVictim(lua_State* L, Creature* creature)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, creature->SelectHostileTarget()); Eluna::Push(L, creature->SelectHostileTarget());
#else #else
sEluna->Push(L, creature->SelectVictim()); Eluna::Push(L, creature->SelectVictim());
#endif #endif
return 1; return 1;
} }
@@ -644,7 +644,7 @@ namespace LuaCreature
/*int RemoveLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features /*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); creature->RemoveLootMode(lootMode);
return 0; return 0;
@@ -652,7 +652,7 @@ namespace LuaCreature
/*int AddLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features /*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); creature->AddLootMode(lootMode);
return 0; return 0;

View File

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

View File

@@ -7,62 +7,60 @@
#ifndef GLOBALMETHODS_H #ifndef GLOBALMETHODS_H
#define GLOBALMETHODS_H #define GLOBALMETHODS_H
extern bool StartEluna();
namespace LuaGlobalFunctions namespace LuaGlobalFunctions
{ {
/* GETTERS */ /* GETTERS */
int GetLuaEngine(lua_State* L) int GetLuaEngine(lua_State* L)
{ {
sEluna->Push(L, "ElunaEngine"); Eluna::Push(L, "ElunaEngine");
return 1; return 1;
} }
int GetCoreName(lua_State* L) int GetCoreName(lua_State* L)
{ {
sEluna->Push(L, CORE_NAME); Eluna::Push(L, CORE_NAME);
return 1; return 1;
} }
int GetCoreVersion(lua_State* L) int GetCoreVersion(lua_State* L)
{ {
sEluna->Push(L, CORE_VERSION); Eluna::Push(L, CORE_VERSION);
return 1; return 1;
} }
int GetCoreExpansion(lua_State* L) int GetCoreExpansion(lua_State* L)
{ {
#ifdef CLASSIC #ifdef CLASSIC
sEluna->Push(L, 0); Eluna::Push(L, 0);
#elif defined(TBC) #elif defined(TBC)
sEluna->Push(L, 1); Eluna::Push(L, 1);
#elif defined(WOTLK) #elif defined(WOTLK)
sEluna->Push(L, 2); Eluna::Push(L, 2);
#elif defined(CATA) #elif defined(CATA)
sEluna->Push(L, 3); Eluna::Push(L, 3);
#endif #endif
return 1; return 1;
} }
int GetQuest(lua_State* L) 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; return 1;
} }
int GetPlayerByGUID(lua_State* L) int GetPlayerByGUID(lua_State* L)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1); uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
sEluna->Push(L, sObjectAccessor->FindPlayer(ObjectGuid(guid))); Eluna::Push(L, sObjectAccessor->FindPlayer(ObjectGuid(guid)));
return 1; return 1;
} }
int GetPlayerByName(lua_State* L) int GetPlayerByName(lua_State* L)
{ {
const char* message = sEluna->CHECKVAL<const char*>(L, 1); const char* message = Eluna::CHECKVAL<const char*>(L, 1);
sEluna->Push(L, sObjectAccessor->FindPlayerByName(message)); Eluna::Push(L, sObjectAccessor->FindPlayerByName(message));
return 1; return 1;
} }
@@ -70,16 +68,16 @@ namespace LuaGlobalFunctions
{ {
time_t time = sWorld->GetGameTime(); time_t time = sWorld->GetGameTime();
if (time < 0) if (time < 0)
sEluna->Push(L, int32(time)); Eluna::Push(L, int32(time));
else else
sEluna->Push(L, uint32(time)); Eluna::Push(L, uint32(time));
return 1; return 1;
} }
int GetPlayersInWorld(lua_State* L) int GetPlayersInWorld(lua_State* L)
{ {
uint32 team = sEluna->CHECKVAL<uint32>(L, 1, TEAM_NEUTRAL); uint32 team = Eluna::CHECKVAL<uint32>(L, 1, TEAM_NEUTRAL);
bool onlyGM = sEluna->CHECKVAL<bool>(L, 2, false); bool onlyGM = Eluna::CHECKVAL<bool>(L, 2, false);
lua_newtable(L); lua_newtable(L);
int tbl = lua_gettop(L); int tbl = lua_gettop(L);
@@ -97,8 +95,8 @@ namespace LuaGlobalFunctions
#endif #endif
{ {
++i; ++i;
sEluna->Push(L, i); Eluna::Push(L, i);
sEluna->Push(L, player); Eluna::Push(L, player);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
} }
@@ -110,9 +108,9 @@ namespace LuaGlobalFunctions
int GetPlayersInMap(lua_State* L) int GetPlayersInMap(lua_State* L)
{ {
uint32 mapID = sEluna->CHECKVAL<uint32>(L, 1); uint32 mapID = Eluna::CHECKVAL<uint32>(L, 1);
uint32 instanceID = sEluna->CHECKVAL<uint32>(L, 2, 0); uint32 instanceID = Eluna::CHECKVAL<uint32>(L, 2, 0);
uint32 team = sEluna->CHECKVAL<uint32>(L, 3, TEAM_NEUTRAL); uint32 team = Eluna::CHECKVAL<uint32>(L, 3, TEAM_NEUTRAL);
Map* map = sMapMgr->FindMap(mapID, instanceID); Map* map = sMapMgr->FindMap(mapID, instanceID);
if (!map) if (!map)
@@ -135,8 +133,8 @@ namespace LuaGlobalFunctions
if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team)) if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team))
{ {
++i; ++i;
sEluna->Push(L, i); Eluna::Push(L, i);
sEluna->Push(L, player); Eluna::Push(L, player);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
} }
@@ -147,69 +145,69 @@ namespace LuaGlobalFunctions
int GetGuildByName(lua_State* L) int GetGuildByName(lua_State* L)
{ {
const char* name = sEluna->CHECKVAL<const char*>(L, 1); const char* name = Eluna::CHECKVAL<const char*>(L, 1);
sEluna->Push(L, sGuildMgr->GetGuildByName(name)); Eluna::Push(L, sGuildMgr->GetGuildByName(name));
return 1; return 1;
} }
int GetMapById(lua_State* L) int GetMapById(lua_State* L)
{ {
uint32 mapid = sEluna->CHECKVAL<uint32>(L, 1); uint32 mapid = Eluna::CHECKVAL<uint32>(L, 1);
uint32 instance = sEluna->CHECKVAL<uint32>(L, 2); uint32 instance = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, sMapMgr->FindMap(mapid, instance)); Eluna::Push(L, sMapMgr->FindMap(mapid, instance));
return 1; return 1;
} }
int GetGuildByLeaderGUID(lua_State* L) 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; return 1;
} }
int GetPlayerCount(lua_State* L) int GetPlayerCount(lua_State* L)
{ {
sEluna->Push(L, sWorld->GetActiveSessionCount()); Eluna::Push(L, sWorld->GetActiveSessionCount());
return 1; return 1;
} }
int GetPlayerGUID(lua_State* L) int GetPlayerGUID(lua_State* L)
{ {
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1); uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
sEluna->Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); Eluna::Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER));
return 1; return 1;
} }
int GetItemGUID(lua_State* L) int GetItemGUID(lua_State* L)
{ {
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1); uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
sEluna->Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM)); Eluna::Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM));
return 1; return 1;
} }
int GetObjectGUID(lua_State* L) int GetObjectGUID(lua_State* L)
{ {
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1); uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2); uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); Eluna::Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT));
return 1; return 1;
} }
int GetUnitGUID(lua_State* L) int GetUnitGUID(lua_State* L)
{ {
uint32 lowguid = sEluna->CHECKVAL<uint32>(L, 1); uint32 lowguid = Eluna::CHECKVAL<uint32>(L, 1);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2); uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT)); Eluna::Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT));
return 1; return 1;
} }
int GetGUIDLow(lua_State* L) 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; return 1;
} }
@@ -226,8 +224,8 @@ namespace LuaGlobalFunctions
LOCALE_esMX = 7, LOCALE_esMX = 7,
LOCALE_ruRU = 8 LOCALE_ruRU = 8
*/ */
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
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) if (loc_idx < 0 || loc_idx >= MAX_LOCALES)
return luaL_argerror(L, 2, "valid LocaleConstant expected"); return luaL_argerror(L, 2, "valid LocaleConstant expected");
@@ -247,28 +245,28 @@ namespace LuaGlobalFunctions
#endif #endif
"0:0:0:0|h[" << name << "]|h|r"; "0:0:0:0|h[" << name << "]|h|r";
sEluna->Push(L, oss.str()); Eluna::Push(L, oss.str());
return 1; return 1;
} }
int GetGUIDType(lua_State* L) int GetGUIDType(lua_State* L)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1); uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
sEluna->Push(L, GUID_HIPART(guid)); Eluna::Push(L, GUID_HIPART(guid));
return 1; return 1;
} }
int GetGUIDEntry(lua_State* L) int GetGUIDEntry(lua_State* L)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1); uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
sEluna->Push(L, GUID_ENPART(guid)); Eluna::Push(L, GUID_ENPART(guid));
return 1; return 1;
} }
int GetAreaName(lua_State* L) int GetAreaName(lua_State* L)
{ {
uint32 areaOrZoneId = sEluna->CHECKVAL<uint32>(L, 1); uint32 areaOrZoneId = Eluna::CHECKVAL<uint32>(L, 1);
int locale = sEluna->CHECKVAL<int>(L, 2, DEFAULT_LOCALE); int locale = Eluna::CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
if (locale < 0 || locale >= MAX_LOCALES) if (locale < 0 || locale >= MAX_LOCALES)
return luaL_argerror(L, 2, "Invalid locale specified"); return luaL_argerror(L, 2, "Invalid locale specified");
@@ -276,25 +274,26 @@ namespace LuaGlobalFunctions
if (!areaEntry) if (!areaEntry)
return luaL_argerror(L, 1, "Invalid Area or Zone ID"); 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; return 1;
} }
/* OTHER */ /* OTHER */
int RegisterPacketEvent(lua_State* L) 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); luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
if (functionRef > 0) if (functionRef > 0)
sEluna->Register(REGTYPE_PACKET, 0, ev, functionRef); sEluna->Register(REGTYPE_PACKET, entry, ev, functionRef);
return 0; return 0;
} }
int RegisterServerEvent(lua_State* L) 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); luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -305,7 +304,7 @@ namespace LuaGlobalFunctions
int RegisterPlayerEvent(lua_State* L) 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); luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -316,7 +315,7 @@ namespace LuaGlobalFunctions
int RegisterGuildEvent(lua_State* L) 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); luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -327,7 +326,7 @@ namespace LuaGlobalFunctions
int RegisterGroupEvent(lua_State* L) 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); luaL_checktype(L, 2, LUA_TFUNCTION);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -338,8 +337,8 @@ namespace LuaGlobalFunctions
int RegisterCreatureGossipEvent(lua_State* L) int RegisterCreatureGossipEvent(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -350,8 +349,8 @@ namespace LuaGlobalFunctions
int RegisterGameObjectGossipEvent(lua_State* L) int RegisterGameObjectGossipEvent(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -362,8 +361,8 @@ namespace LuaGlobalFunctions
int RegisterItemEvent(lua_State* L) int RegisterItemEvent(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -374,8 +373,8 @@ namespace LuaGlobalFunctions
int RegisterItemGossipEvent(lua_State* L) int RegisterItemGossipEvent(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -386,8 +385,8 @@ namespace LuaGlobalFunctions
int RegisterPlayerGossipEvent(lua_State* L) int RegisterPlayerGossipEvent(lua_State* L)
{ {
uint32 menu_id = sEluna->CHECKVAL<uint32>(L, 1); uint32 menu_id = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -398,8 +397,8 @@ namespace LuaGlobalFunctions
int RegisterCreatureEvent(lua_State* L) int RegisterCreatureEvent(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -410,8 +409,8 @@ namespace LuaGlobalFunctions
int RegisterGameObjectEvent(lua_State* L) int RegisterGameObjectEvent(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 ev = sEluna->CHECKVAL<uint32>(L, 2); uint32 ev = Eluna::CHECKVAL<uint32>(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION); luaL_checktype(L, 3, LUA_TFUNCTION);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
int functionRef = lua_ref(L, true); int functionRef = lua_ref(L, true);
@@ -422,20 +421,20 @@ namespace LuaGlobalFunctions
int ReloadEluna(lua_State* L) int ReloadEluna(lua_State* L)
{ {
sEluna->Push(L, StartEluna()); Eluna::ReloadEluna();
return 1; return 0;
} }
int SendWorldMessage(lua_State* L) 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); sWorld->SendServerMessage(SERVER_MSG_STRING, message);
return 0; return 0;
} }
int WorldDBQuery(lua_State* L) 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) if (!query)
return 1; return 1;
@@ -450,13 +449,13 @@ namespace LuaGlobalFunctions
if (!result) if (!result)
return 1; return 1;
sEluna->Push(L, result); Eluna::Push(L, result);
return 1; return 1;
} }
int WorldDBExecute(lua_State* L) 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) if (query)
WorldDatabase.Execute(query); WorldDatabase.Execute(query);
return 0; return 0;
@@ -464,7 +463,7 @@ namespace LuaGlobalFunctions
int CharDBQuery(lua_State* L) 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) if (!query)
return 1; return 1;
@@ -479,13 +478,13 @@ namespace LuaGlobalFunctions
if (!result) if (!result)
return 1; return 1;
sEluna->Push(L, result); Eluna::Push(L, result);
return 1; return 1;
} }
int CharDBExecute(lua_State* L) 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) if (query)
CharacterDatabase.Execute(query); CharacterDatabase.Execute(query);
return 0; return 0;
@@ -493,7 +492,7 @@ namespace LuaGlobalFunctions
int AuthDBQuery(lua_State* L) 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; QueryResult* result = NULL;
#ifdef MANGOS #ifdef MANGOS
@@ -506,13 +505,13 @@ namespace LuaGlobalFunctions
if (!result) if (!result)
return 0; return 0;
sEluna->Push(L, result); Eluna::Push(L, result);
return 1; return 1;
} }
int AuthDBExecute(lua_State* L) 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) if (query)
LoginDatabase.Execute(query); LoginDatabase.Execute(query);
return 0; return 0;
@@ -521,54 +520,54 @@ namespace LuaGlobalFunctions
int CreateLuaEvent(lua_State* L) int CreateLuaEvent(lua_State* L)
{ {
luaL_checktype(L, 1, LUA_TFUNCTION); luaL_checktype(L, 1, LUA_TFUNCTION);
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2); uint32 delay = Eluna::CHECKVAL<uint32>(L, 2);
uint32 repeats = sEluna->CHECKVAL<uint32>(L, 3); uint32 repeats = Eluna::CHECKVAL<uint32>(L, 3);
lua_pushvalue(L, 1); lua_pushvalue(L, 1);
int functionRef = lua_ref(L, true); 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) if (functionRef)
sEluna->Push(L, functionRef); Eluna::Push(L, functionRef);
return 1; return 1;
} }
int RemoveEventById(lua_State* L) int RemoveEventById(lua_State* L)
{ {
int eventId = sEluna->CHECKVAL<int>(L, 1); int eventId = Eluna::CHECKVAL<int>(L, 1);
bool all_Events = sEluna->CHECKVAL<bool>(L, 1, false); bool all_Events = Eluna::CHECKVAL<bool>(L, 1, false);
if (all_Events) if (all_Events)
sEluna->m_EventMgr.RemoveEvent(eventId); sEluna->m_EventMgr->RemoveEvent(eventId);
else else
sEluna->m_EventMgr.RemoveEvent(&sEluna->m_EventMgr.GlobalEvents, eventId); sEluna->m_EventMgr->RemoveEvent(&sEluna->m_EventMgr->GlobalEvents, eventId);
return 0; return 0;
} }
int RemoveEvents(lua_State* L) 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) if (all_Events)
sEluna->m_EventMgr.RemoveEvents(); sEluna->m_EventMgr->RemoveEvents();
else else
sEluna->m_EventMgr.GlobalEvents.KillAllEvents(true); sEluna->m_EventMgr->GlobalEvents.KillAllEvents(true);
return 0; return 0;
} }
int PerformIngameSpawn(lua_State* L) int PerformIngameSpawn(lua_State* L)
{ {
int spawntype = sEluna->CHECKVAL<int>(L, 1); int spawntype = Eluna::CHECKVAL<int>(L, 1);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2); uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
uint32 mapID = sEluna->CHECKVAL<uint32>(L, 3); uint32 mapID = Eluna::CHECKVAL<uint32>(L, 3);
uint32 instanceID = sEluna->CHECKVAL<uint32>(L, 4); uint32 instanceID = Eluna::CHECKVAL<uint32>(L, 4);
float x = sEluna->CHECKVAL<float>(L, 5); float x = Eluna::CHECKVAL<float>(L, 5);
float y = sEluna->CHECKVAL<float>(L, 6); float y = Eluna::CHECKVAL<float>(L, 6);
float z = sEluna->CHECKVAL<float>(L, 7); float z = Eluna::CHECKVAL<float>(L, 7);
float o = sEluna->CHECKVAL<float>(L, 8); float o = Eluna::CHECKVAL<float>(L, 8);
bool save = sEluna->CHECKVAL<bool>(L, 9, false); bool save = Eluna::CHECKVAL<bool>(L, 9, false);
uint32 durorresptime = sEluna->CHECKVAL<uint32>(L, 10, 0); uint32 durorresptime = Eluna::CHECKVAL<uint32>(L, 10, 0);
#if (!defined(TBC) && !defined(CLASSIC)) #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) if (!phase)
return 1; return 1;
#endif #endif
@@ -621,7 +620,7 @@ namespace LuaGlobalFunctions
if (durorresptime) if (durorresptime)
pCreature->ForcedDespawn(durorresptime); pCreature->ForcedDespawn(durorresptime);
sEluna->Push(L, pCreature); Eluna::Push(L, pCreature);
} }
else else
{ {
@@ -654,7 +653,7 @@ namespace LuaGlobalFunctions
if (pCreature->IsLinkingEventTrigger()) if (pCreature->IsLinkingEventTrigger())
map->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); map->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature);
sEluna->Push(L, pCreature); Eluna::Push(L, pCreature);
} }
return 1; return 1;
@@ -709,7 +708,7 @@ namespace LuaGlobalFunctions
sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID)); sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
sEluna->Push(L, pGameObj); Eluna::Push(L, pGameObj);
} }
else else
{ {
@@ -729,7 +728,7 @@ namespace LuaGlobalFunctions
map->Add(pGameObj); map->Add(pGameObj);
sEluna->Push(L, pGameObj); Eluna::Push(L, pGameObj);
} }
return 1; return 1;
} }
@@ -761,7 +760,7 @@ namespace LuaGlobalFunctions
} }
sObjectMgr->AddCreatureToGrid(db_lowguid, sObjectMgr->GetCreatureData(db_lowguid)); sObjectMgr->AddCreatureToGrid(db_lowguid, sObjectMgr->GetCreatureData(db_lowguid));
sEluna->Push(L, creature); Eluna::Push(L, creature);
} }
else else
{ {
@@ -774,7 +773,7 @@ namespace LuaGlobalFunctions
else else
creature->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN); creature->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN);
sEluna->Push(L, creature); Eluna::Push(L, creature);
} }
return 1; return 1;
@@ -817,7 +816,7 @@ namespace LuaGlobalFunctions
} }
else else
map->AddToMap(object); map->AddToMap(object);
sEluna->Push(L, object); Eluna::Push(L, object);
return 1; return 1;
} }
#endif #endif
@@ -827,22 +826,22 @@ namespace LuaGlobalFunctions
// CreatePacket(opcode, size) // CreatePacket(opcode, size)
int CreatePacket(lua_State* L) int CreatePacket(lua_State* L)
{ {
uint32 opcode = sEluna->CHECKVAL<uint32>(L, 1); uint32 opcode = Eluna::CHECKVAL<uint32>(L, 1);
uint32 size = sEluna->CHECKVAL<uint32>(L, 2); uint32 size = Eluna::CHECKVAL<uint32>(L, 2);
if (opcode >= NUM_MSG_TYPES) if (opcode >= NUM_MSG_TYPES)
return luaL_argerror(L, 1, "valid opcode expected"); 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; return 1;
} }
int AddVendorItem(lua_State* L) int AddVendorItem(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 item = sEluna->CHECKVAL<uint32>(L, 2); uint32 item = Eluna::CHECKVAL<uint32>(L, 2);
int maxcount = sEluna->CHECKVAL<int>(L, 3); int maxcount = Eluna::CHECKVAL<int>(L, 3);
uint32 incrtime = sEluna->CHECKVAL<uint32>(L, 4); uint32 incrtime = Eluna::CHECKVAL<uint32>(L, 4);
uint32 extendedcost = sEluna->CHECKVAL<uint32>(L, 5); uint32 extendedcost = Eluna::CHECKVAL<uint32>(L, 5);
#ifdef MANGOS #ifdef MANGOS
if (!sObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0)) if (!sObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0))
@@ -868,8 +867,8 @@ namespace LuaGlobalFunctions
int VendorRemoveItem(lua_State* L) int VendorRemoveItem(lua_State* L)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 1); uint32 entry = Eluna::CHECKVAL<uint32>(L, 1);
uint32 item = sEluna->CHECKVAL<uint32>(L, 2); uint32 item = Eluna::CHECKVAL<uint32>(L, 2);
if (!sObjectMgr->GetCreatureTemplate(entry)) if (!sObjectMgr->GetCreatureTemplate(entry))
return luaL_argerror(L, 1, "valid CreatureEntry expected"); return luaL_argerror(L, 1, "valid CreatureEntry expected");
@@ -883,7 +882,7 @@ namespace LuaGlobalFunctions
int VendorRemoveAllItems(lua_State* L) 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); VendorItemData const* items = sObjectMgr->GetNpcVendorItemList(entry);
if (!items || items->Empty()) if (!items || items->Empty())
@@ -901,18 +900,18 @@ namespace LuaGlobalFunctions
int Kick(lua_State* L) int Kick(lua_State* L)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 1); Player* player = Eluna::CHECKOBJ<Player>(L, 1);
player->GetSession()->KickPlayer(); player->GetSession()->KickPlayer();
return 0; return 0;
} }
int Ban(lua_State* L) int Ban(lua_State* L)
{ {
int banMode = sEluna->CHECKVAL<int>(L, 1); int banMode = Eluna::CHECKVAL<int>(L, 1);
const char* nameOrIP_cstr = sEluna->CHECKVAL<const char*>(L, 2); const char* nameOrIP_cstr = Eluna::CHECKVAL<const char*>(L, 2);
uint32 duration = sEluna->CHECKVAL<uint32>(L, 3); uint32 duration = Eluna::CHECKVAL<uint32>(L, 3);
const char* reason = sEluna->CHECKVAL<const char*>(L, 4); const char* reason = Eluna::CHECKVAL<const char*>(L, 4);
Player* whoBanned = sEluna->CHECKOBJ<Player>(L, 5); Player* whoBanned = Eluna::CHECKOBJ<Player>(L, 5);
std::string nameOrIP(nameOrIP_cstr); std::string nameOrIP(nameOrIP_cstr);
switch (banMode) switch (banMode)
@@ -958,12 +957,12 @@ namespace LuaGlobalFunctions
int SendMail(lua_State* L) int SendMail(lua_State* L)
{ {
int i = 0; int i = 0;
std::string subject = sEluna->CHECKVAL<std::string>(L, ++i); std::string subject = Eluna::CHECKVAL<std::string>(L, ++i);
std::string text = sEluna->CHECKVAL<std::string>(L, ++i); std::string text = Eluna::CHECKVAL<std::string>(L, ++i);
uint32 receiverGUIDLow = sEluna->CHECKVAL<uint32>(L, ++i); uint32 receiverGUIDLow = Eluna::CHECKVAL<uint32>(L, ++i);
uint32 senderGUIDLow = sEluna->CHECKVAL<uint32>(L, ++i, 0); uint32 senderGUIDLow = Eluna::CHECKVAL<uint32>(L, ++i, 0);
uint32 stationary = sEluna->CHECKVAL<uint32>(L, ++i, MAIL_STATIONERY_DEFAULT); uint32 stationary = Eluna::CHECKVAL<uint32>(L, ++i, MAIL_STATIONERY_DEFAULT);
uint32 delay = sEluna->CHECKVAL<uint32>(L, ++i, 0); uint32 delay = Eluna::CHECKVAL<uint32>(L, ++i, 0);
int argAmount = lua_gettop(L); int argAmount = lua_gettop(L);
MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary); MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary);
@@ -1018,53 +1017,53 @@ namespace LuaGlobalFunctions
// bit_and(a, b) // bit_and(a, b)
int bit_and(lua_State* L) int bit_and(lua_State* L)
{ {
uint32 a = sEluna->CHECKVAL<uint32>(L, 1); uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
uint32 b = sEluna->CHECKVAL<uint32>(L, 2); uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, a & b); Eluna::Push(L, a & b);
return 1; return 1;
} }
// bit_or(a, b) // bit_or(a, b)
int bit_or(lua_State* L) int bit_or(lua_State* L)
{ {
uint32 a = sEluna->CHECKVAL<uint32>(L, 1); uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
uint32 b = sEluna->CHECKVAL<uint32>(L, 2); uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, a | b); Eluna::Push(L, a | b);
return 1; return 1;
} }
// bit_lshift(a, b) // bit_lshift(a, b)
int bit_lshift(lua_State* L) int bit_lshift(lua_State* L)
{ {
uint32 a = sEluna->CHECKVAL<uint32>(L, 1); uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
uint32 b = sEluna->CHECKVAL<uint32>(L, 2); uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, a << b); Eluna::Push(L, a << b);
return 1; return 1;
} }
// bit_rshift(a, b) // bit_rshift(a, b)
int bit_rshift(lua_State* L) int bit_rshift(lua_State* L)
{ {
uint32 a = sEluna->CHECKVAL<uint32>(L, 1); uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
uint32 b = sEluna->CHECKVAL<uint32>(L, 2); uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, a >> b); Eluna::Push(L, a >> b);
return 1; return 1;
} }
// bit_xor(a, b) // bit_xor(a, b)
int bit_xor(lua_State* L) int bit_xor(lua_State* L)
{ {
uint32 a = sEluna->CHECKVAL<uint32>(L, 1); uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
uint32 b = sEluna->CHECKVAL<uint32>(L, 2); uint32 b = Eluna::CHECKVAL<uint32>(L, 2);
sEluna->Push(L, a ^ b); Eluna::Push(L, a ^ b);
return 1; return 1;
} }
// bit_not(a) // bit_not(a)
int bit_not(lua_State* L) int bit_not(lua_State* L)
{ {
uint32 a = sEluna->CHECKVAL<uint32>(L, 1); uint32 a = Eluna::CHECKVAL<uint32>(L, 1);
sEluna->Push(L, ~a); Eluna::Push(L, ~a);
return 1; return 1;
} }
@@ -1072,10 +1071,10 @@ namespace LuaGlobalFunctions
int AddTaxiPath(lua_State* L) int AddTaxiPath(lua_State* L)
{ {
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
uint32 mountA = sEluna->CHECKVAL<uint32>(L, 2); uint32 mountA = Eluna::CHECKVAL<uint32>(L, 2);
uint32 mountH = sEluna->CHECKVAL<uint32>(L, 3); uint32 mountH = Eluna::CHECKVAL<uint32>(L, 3);
uint32 price = sEluna->CHECKVAL<uint32>(L, 4, 0); uint32 price = Eluna::CHECKVAL<uint32>(L, 4, 0);
uint32 pathId = sEluna->CHECKVAL<uint32>(L, 5, 0); uint32 pathId = Eluna::CHECKVAL<uint32>(L, 5, 0);
lua_pushvalue(L, 1); lua_pushvalue(L, 1);
std::list<TaxiPathNodeEntry> nodes; std::list<TaxiPathNodeEntry> nodes;
@@ -1083,11 +1082,11 @@ namespace LuaGlobalFunctions
int start = lua_gettop(L); int start = lua_gettop(L);
int end = start; int end = start;
sEluna->Push(L); Eluna::Push(L);
while (lua_next(L, -2) != 0) while (lua_next(L, -2) != 0)
{ {
luaL_checktype(L, -1, LUA_TTABLE); luaL_checktype(L, -1, LUA_TTABLE);
sEluna->Push(L); Eluna::Push(L);
while (lua_next(L, -2) != 0) while (lua_next(L, -2) != 0)
{ {
lua_insert(L, end++); lua_insert(L, end++);
@@ -1104,18 +1103,18 @@ namespace LuaGlobalFunctions
while (end - start < 8) // fill optional args with 0 while (end - start < 8) // fill optional args with 0
{ {
sEluna->Push(L, 0); Eluna::Push(L, 0);
lua_insert(L, end++); lua_insert(L, end++);
} }
TaxiPathNodeEntry* entry = new TaxiPathNodeEntry(); TaxiPathNodeEntry* entry = new TaxiPathNodeEntry();
// mandatory // mandatory
entry->mapid = sEluna->CHECKVAL<uint32>(L, start); entry->mapid = Eluna::CHECKVAL<uint32>(L, start);
entry->x = sEluna->CHECKVAL<float>(L, start + 1); entry->x = Eluna::CHECKVAL<float>(L, start + 1);
entry->y = sEluna->CHECKVAL<float>(L, start + 2); entry->y = Eluna::CHECKVAL<float>(L, start + 2);
entry->z = sEluna->CHECKVAL<float>(L, start + 3); entry->z = Eluna::CHECKVAL<float>(L, start + 3);
// optional // optional
entry->actionFlag = sEluna->CHECKVAL<uint32>(L, start + 4); entry->actionFlag = Eluna::CHECKVAL<uint32>(L, start + 4);
entry->delay = sEluna->CHECKVAL<uint32>(L, start + 5); entry->delay = Eluna::CHECKVAL<uint32>(L, start + 5);
nodes.push_back(*entry); nodes.push_back(*entry);
@@ -1126,13 +1125,43 @@ namespace LuaGlobalFunctions
lua_pop(L, 1); 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; return 1;
} }
int AddCorpse(lua_State* L) int AddCorpse(lua_State* L)
{ {
Corpse* corpse = sEluna->CHECKOBJ<Corpse>(L, 1); Corpse* corpse = Eluna::CHECKOBJ<Corpse>(L, 1);
sObjectAccessor->AddCorpse(corpse); sObjectAccessor->AddCorpse(corpse);
return 0; return 0;
@@ -1140,17 +1169,17 @@ namespace LuaGlobalFunctions
int RemoveCorpse(lua_State* L) int RemoveCorpse(lua_State* L)
{ {
Corpse* corpse = sEluna->CHECKOBJ<Corpse>(L, 1); Corpse* corpse = Eluna::CHECKOBJ<Corpse>(L, 1);
sObjectAccessor->RemoveCorpse(corpse); sObjectAccessor->RemoveCorpse(corpse);
return 1; return 1;
} }
int ConvertCorpseForPlayer(lua_State* L) int ConvertCorpseForPlayer(lua_State* L)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 1); uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
bool insignia = sEluna->CHECKVAL<bool>(L, 2, false); 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; return 0;
} }
@@ -1162,31 +1191,31 @@ namespace LuaGlobalFunctions
int FindWeather(lua_State* L) int FindWeather(lua_State* L)
{ {
uint32 zoneId = sEluna->CHECKVAL<uint32>(L, 1); uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
#ifdef MANGOS #ifdef MANGOS
Weather* weather = sWorld->FindWeather(zoneId); Weather* weather = sWorld->FindWeather(zoneId);
#else #else
Weather* weather = WeatherMgr::FindWeather(zoneId); Weather* weather = WeatherMgr::FindWeather(zoneId);
#endif #endif
sEluna->Push(L, weather); Eluna::Push(L, weather);
return 1; return 1;
} }
int AddWeather(lua_State* L) int AddWeather(lua_State* L)
{ {
uint32 zoneId = sEluna->CHECKVAL<uint32>(L, 1); uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
#ifdef MANGOS #ifdef MANGOS
Weather* weather = sWorld->AddWeather(zoneId); Weather* weather = sWorld->AddWeather(zoneId);
#else #else
Weather* weather = WeatherMgr::AddWeather(zoneId); Weather* weather = WeatherMgr::AddWeather(zoneId);
#endif #endif
sEluna->Push(L, weather); Eluna::Push(L, weather);
return 1; return 1;
} }
int RemoveWeather(lua_State* L) int RemoveWeather(lua_State* L)
{ {
uint32 zoneId = sEluna->CHECKVAL<uint32>(L, 1); uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
#ifdef MANGOS #ifdef MANGOS
sWorld->RemoveWeather(zoneId); sWorld->RemoveWeather(zoneId);
#else #else
@@ -1197,7 +1226,7 @@ namespace LuaGlobalFunctions
int SendFineWeatherToPlayer(lua_State* L) int SendFineWeatherToPlayer(lua_State* L)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 1); Player* player = Eluna::CHECKOBJ<Player>(L, 1);
#ifdef MANGOS #ifdef MANGOS
Weather::SendFineWeatherUpdateToPlayer(player); Weather::SendFineWeatherUpdateToPlayer(player);
#else #else

View File

@@ -12,76 +12,76 @@ namespace LuaGroup
/* BOOLEAN */ /* BOOLEAN */
int IsLeader(lua_State* L, Group* group) int IsLeader(lua_State* L, Group* group)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2); uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
sEluna->Push(L, group->IsLeader(ObjectGuid(guid))); Eluna::Push(L, group->IsLeader(ObjectGuid(guid)));
return 1; return 1;
} }
int IsFull(lua_State* L, Group* group) int IsFull(lua_State* L, Group* group)
{ {
sEluna->Push(L, group->IsFull()); Eluna::Push(L, group->IsFull());
return 1; return 1;
} }
int isRaidGroup(lua_State* L, Group* group) int isRaidGroup(lua_State* L, Group* group)
{ {
sEluna->Push(L, group->isRaidGroup()); Eluna::Push(L, group->isRaidGroup());
return 1; return 1;
} }
int isBGGroup(lua_State* L, Group* group) int isBGGroup(lua_State* L, Group* group)
{ {
sEluna->Push(L, group->isBGGroup()); Eluna::Push(L, group->isBGGroup());
return 1; return 1;
} }
int IsMember(lua_State* L, Group* group) int IsMember(lua_State* L, Group* group)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
sEluna->Push(L, group->IsMember(player->GET_GUID())); Eluna::Push(L, group->IsMember(player->GET_GUID()));
return 1; return 1;
} }
int IsAssistant(lua_State* L, Group* group) 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; return 1;
} }
int SameSubGroup(lua_State* L, Group* group) int SameSubGroup(lua_State* L, Group* group)
{ {
Player* player1 = sEluna->CHECKOBJ<Player>(L, 2); Player* player1 = Eluna::CHECKOBJ<Player>(L, 2);
Player* player2 = sEluna->CHECKOBJ<Player>(L, 3); Player* player2 = Eluna::CHECKOBJ<Player>(L, 3);
sEluna->Push(L, group->SameSubGroup(player1, player2)); Eluna::Push(L, group->SameSubGroup(player1, player2));
return 1; return 1;
} }
int HasFreeSlotSubGroup(lua_State* L, Group* group) int HasFreeSlotSubGroup(lua_State* L, Group* group)
{ {
uint8 subGroup = sEluna->CHECKVAL<uint8>(L, 2); uint8 subGroup = Eluna::CHECKVAL<uint8>(L, 2);
sEluna->Push(L, group->HasFreeSlotSubGroup(subGroup)); Eluna::Push(L, group->HasFreeSlotSubGroup(subGroup));
return 1; return 1;
} }
int AddInvite(lua_State* L, Group* group) 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; return 1;
} }
/*int isLFGGroup(lua_State* L, Group* group) // TODO: Implementation /*int isLFGGroup(lua_State* L, Group* group) // TODO: Implementation
{ {
sEluna->Push(L, group->isLFGGroup()); Eluna::Push(L, group->isLFGGroup());
return 1; return 1;
}*/ }*/
/*int isBFGroup(lua_State* L, Group* group) // TODO: Implementation /*int isBFGroup(lua_State* L, Group* group) // TODO: Implementation
{ {
sEluna->Push(L, group->isBFGroup()); Eluna::Push(L, group->isBFGroup());
return 1; return 1;
}*/ }*/
@@ -104,8 +104,8 @@ namespace LuaGroup
continue; continue;
++i; ++i;
sEluna->Push(L, i); Eluna::Push(L, i);
sEluna->Push(L, member); Eluna::Push(L, member);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
@@ -116,9 +116,9 @@ namespace LuaGroup
int GetLeaderGUID(lua_State* L, Group* group) int GetLeaderGUID(lua_State* L, Group* group)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, group->GetLeaderGuid()); Eluna::Push(L, group->GetLeaderGuid());
#else #else
sEluna->Push(L, group->GetLeaderGUID()); Eluna::Push(L, group->GetLeaderGUID());
#endif #endif
return 1; return 1;
} }
@@ -126,9 +126,9 @@ namespace LuaGroup
int GetLeader(lua_State* L, Group* group) int GetLeader(lua_State* L, Group* group)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGuid())); Eluna::Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGuid()));
#else #else
sEluna->Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGUID())); Eluna::Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGUID()));
#endif #endif
return 1; return 1;
} }
@@ -136,42 +136,42 @@ namespace LuaGroup
int GetGUID(lua_State* L, Group* group) int GetGUID(lua_State* L, Group* group)
{ {
#ifdef CLASSIC #ifdef CLASSIC
sEluna->Push(L, group->GetId()); Eluna::Push(L, group->GetId());
#else #else
sEluna->Push(L, group->GET_GUID()); Eluna::Push(L, group->GET_GUID());
#endif #endif
return 1; return 1;
} }
int GetMemberGUID(lua_State* L, Group* group) 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 #ifdef MANGOS
sEluna->Push(L, group->GetMemberGuid(name)); Eluna::Push(L, group->GetMemberGuid(name));
#else #else
sEluna->Push(L, group->GetMemberGUID(name)); Eluna::Push(L, group->GetMemberGUID(name));
#endif #endif
return 1; return 1;
} }
int GetMembersCount(lua_State* L, Group* group) int GetMembersCount(lua_State* L, Group* group)
{ {
sEluna->Push(L, group->GetMembersCount()); Eluna::Push(L, group->GetMembersCount());
return 1; return 1;
} }
int GetMemberGroup(lua_State* L, Group* group) 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; return 1;
} }
/* OTHER */ /* OTHER */
int ChangeLeader(lua_State* L, Group* group) 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()); group->ChangeLeader(leader->GET_GUID());
return 0; return 0;
@@ -180,9 +180,9 @@ namespace LuaGroup
// SendPacket(packet, sendToPlayersInBattleground[, ignoreguid]) // SendPacket(packet, sendToPlayersInBattleground[, ignoreguid])
int SendPacket(lua_State* L, Group* group) int SendPacket(lua_State* L, Group* group)
{ {
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2); WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
bool ignorePlayersInBg = sEluna->CHECKVAL<bool>(L, 3); bool ignorePlayersInBg = Eluna::CHECKVAL<bool>(L, 3);
uint64 ignore = sEluna->CHECKVAL<uint64>(L, 4); uint64 ignore = Eluna::CHECKVAL<uint64>(L, 4);
group->BroadcastPacket(data, ignorePlayersInBg, -1, ObjectGuid(ignore)); group->BroadcastPacket(data, ignorePlayersInBg, -1, ObjectGuid(ignore));
return 0; return 0;
@@ -190,13 +190,13 @@ namespace LuaGroup
int RemoveMember(lua_State* L, Group* group) int RemoveMember(lua_State* L, Group* group)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint32 method = sEluna->CHECKVAL<uint32>(L, 3, 0); uint32 method = Eluna::CHECKVAL<uint32>(L, 3, 0);
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, group->RemoveMember(player->GET_GUID(), method)); Eluna::Push(L, group->RemoveMember(player->GET_GUID(), method));
#else #else
sEluna->Push(L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method)); Eluna::Push(L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method));
#endif #endif
return 1; return 1;
} }
@@ -215,8 +215,8 @@ namespace LuaGroup
int ChangeMembersGroup(lua_State* L, Group* group) int ChangeMembersGroup(lua_State* L, Group* group)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 groupID = sEluna->CHECKVAL<uint8>(L, 3); uint8 groupID = Eluna::CHECKVAL<uint8>(L, 3);
group->ChangeMembersGroup(player->GET_GUID(), groupID); group->ChangeMembersGroup(player->GET_GUID(), groupID);
return 0; return 0;
@@ -224,9 +224,9 @@ namespace LuaGroup
int SetTargetIcon(lua_State* L, Group* group) int SetTargetIcon(lua_State* L, Group* group)
{ {
uint8 icon = sEluna->CHECKVAL<uint8>(L, 2); uint8 icon = Eluna::CHECKVAL<uint8>(L, 2);
uint64 target = sEluna->CHECKVAL<uint64>(L, 3); uint64 target = Eluna::CHECKVAL<uint64>(L, 3);
uint64 setter = sEluna->CHECKVAL<uint64>(L, 4, 0); uint64 setter = Eluna::CHECKVAL<uint64>(L, 4, 0);
if (icon >= TARGETICONCOUNT) if (icon >= TARGETICONCOUNT)
return luaL_argerror(L, 2, "valid target icon expected"); return luaL_argerror(L, 2, "valid target icon expected");

View File

@@ -24,8 +24,8 @@ namespace LuaGuild
if (player->GetSession() && (player->GetGuildId() == guild->GetId())) if (player->GetSession() && (player->GetGuildId() == guild->GetId()))
{ {
++i; ++i;
sEluna->Push(L, i); Eluna::Push(L, i);
sEluna->Push(L, player); Eluna::Push(L, player);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
} }
@@ -37,16 +37,16 @@ namespace LuaGuild
int GetMemberCount(lua_State* L, Guild* guild) int GetMemberCount(lua_State* L, Guild* guild)
{ {
sEluna->Push(L, guild->GetMemberSize()); Eluna::Push(L, guild->GetMemberSize());
return 1; return 1;
} }
int GetLeader(lua_State* L, Guild* guild) int GetLeader(lua_State* L, Guild* guild)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGuid())); Eluna::Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGuid()));
#else #else
sEluna->Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGUID())); Eluna::Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGUID()));
#endif #endif
return 1; return 1;
} }
@@ -54,37 +54,37 @@ namespace LuaGuild
int GetLeaderGUID(lua_State* L, Guild* guild) int GetLeaderGUID(lua_State* L, Guild* guild)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, guild->GetLeaderGuid()); Eluna::Push(L, guild->GetLeaderGuid());
#else #else
sEluna->Push(L, guild->GetLeaderGUID()); Eluna::Push(L, guild->GetLeaderGUID());
#endif #endif
return 1; return 1;
} }
int GetId(lua_State* L, Guild* guild) int GetId(lua_State* L, Guild* guild)
{ {
sEluna->Push(L, guild->GetId()); Eluna::Push(L, guild->GetId());
return 1; return 1;
} }
int GetName(lua_State* L, Guild* guild) int GetName(lua_State* L, Guild* guild)
{ {
sEluna->Push(L, guild->GetName()); Eluna::Push(L, guild->GetName());
return 1; return 1;
} }
int GetMOTD(lua_State* L, Guild* guild) int GetMOTD(lua_State* L, Guild* guild)
{ {
sEluna->Push(L, guild->GetMOTD()); Eluna::Push(L, guild->GetMOTD());
return 1; return 1;
} }
int GetInfo(lua_State* L, Guild* guild) int GetInfo(lua_State* L, Guild* guild)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, guild->GetGINFO()); Eluna::Push(L, guild->GetGINFO());
#else #else
sEluna->Push(L, guild->GetInfo()); Eluna::Push(L, guild->GetInfo());
#endif #endif
return 1; return 1;
} }
@@ -93,7 +93,7 @@ namespace LuaGuild
#ifndef CATA #ifndef CATA
int SetLeader(lua_State* L, Guild* guild) int SetLeader(lua_State* L, Guild* guild)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#ifdef MANGOS #ifdef MANGOS
guild->SetLeader(player->GET_GUID()); guild->SetLeader(player->GET_GUID());
@@ -107,8 +107,8 @@ namespace LuaGuild
#ifndef CLASSIC #ifndef CLASSIC
int SetBankTabText(lua_State* L, Guild* guild) int SetBankTabText(lua_State* L, Guild* guild)
{ {
uint8 tabId = sEluna->CHECKVAL<uint8>(L, 2); uint8 tabId = Eluna::CHECKVAL<uint8>(L, 2);
const char* text = sEluna->CHECKVAL<const char*>(L, 3); const char* text = Eluna::CHECKVAL<const char*>(L, 3);
#ifdef MANGOS #ifdef MANGOS
guild->SetGuildBankTabText(tabId, text); guild->SetGuildBankTabText(tabId, text);
#else #else
@@ -122,7 +122,7 @@ namespace LuaGuild
// SendPacketToGuild(packet) // SendPacketToGuild(packet)
int SendPacket(lua_State* L, Guild* guild) int SendPacket(lua_State* L, Guild* guild)
{ {
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2); WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
guild->BroadcastPacket(data); guild->BroadcastPacket(data);
return 0; return 0;
@@ -131,8 +131,8 @@ namespace LuaGuild
// SendPacketToRankedInGuild(packet, rankId) // SendPacketToRankedInGuild(packet, rankId)
int SendPacketToRanked(lua_State* L, Guild* guild) int SendPacketToRanked(lua_State* L, Guild* guild)
{ {
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2); WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
uint8 ranked = sEluna->CHECKVAL<uint8>(L, 3); uint8 ranked = Eluna::CHECKVAL<uint8>(L, 3);
guild->BroadcastPacketToRank(data, ranked); guild->BroadcastPacketToRank(data, ranked);
return 0; return 0;
@@ -146,8 +146,8 @@ namespace LuaGuild
int AddMember(lua_State* L, Guild* guild) int AddMember(lua_State* L, Guild* guild)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 rankId = sEluna->CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE); uint8 rankId = Eluna::CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE);
guild->AddMember(player->GET_GUID(), rankId); guild->AddMember(player->GET_GUID(), rankId);
return 0; return 0;
@@ -155,8 +155,8 @@ namespace LuaGuild
int DeleteMember(lua_State* L, Guild* guild) int DeleteMember(lua_State* L, Guild* guild)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
bool isDisbanding = sEluna->CHECKVAL<bool>(L, 3, false); bool isDisbanding = Eluna::CHECKVAL<bool>(L, 3, false);
#ifdef MANGOS #ifdef MANGOS
guild->DelMember(player->GET_GUID(), isDisbanding); guild->DelMember(player->GET_GUID(), isDisbanding);
@@ -168,8 +168,8 @@ namespace LuaGuild
int ChangeMemberRank(lua_State* L, Guild* guild) int ChangeMemberRank(lua_State* L, Guild* guild)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 newRank = sEluna->CHECKVAL<uint8>(L, 3); uint8 newRank = Eluna::CHECKVAL<uint8>(L, 3);
guild->ChangeMemberRank(player->GET_GUID(), newRank); guild->ChangeMemberRank(player->GET_GUID(), newRank);
return 0; return 0;
@@ -179,8 +179,8 @@ namespace LuaGuild
// Move to Player methods // Move to Player methods
int WithdrawBankMoney(lua_State* L, Guild* guild) int WithdrawBankMoney(lua_State* L, Guild* guild)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint32 money = sEluna->CHECKVAL<uint32>(L, 3); uint32 money = Eluna::CHECKVAL<uint32>(L, 3);
#ifdef MANGOS #ifdef MANGOS
if (guild->GetGuildBankMoney() < money) if (guild->GetGuildBankMoney() < money)
return 0; return 0;
@@ -194,8 +194,8 @@ namespace LuaGuild
// Move to Player methods // Move to Player methods
int DepositBankMoney(lua_State* L, Guild* guild) int DepositBankMoney(lua_State* L, Guild* guild)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint32 money = sEluna->CHECKVAL<uint32>(L, 3); uint32 money = Eluna::CHECKVAL<uint32>(L, 3);
#ifdef MANGOS #ifdef MANGOS
guild->SetBankMoney(guild->GetGuildBankMoney() + money); guild->SetBankMoney(guild->GetGuildBankMoney() + money);

File diff suppressed because it is too large Load Diff

225
HookMgr.h
View File

@@ -7,67 +7,6 @@
#ifndef LUAHOOKS_H #ifndef LUAHOOKS_H
#define 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 enum RegisterTypes
{ {
REGTYPE_PACKET, REGTYPE_PACKET,
@@ -86,7 +25,7 @@ enum RegisterTypes
REGTYPE_COUNT 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 = 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_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 // 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) WORLD_EVENT_ON_SHUTDOWN = 15, // (event)
// Eluna // Eluna
ELUNA_EVENT_ON_RESTART = 16, // (event) ELUNA_EVENT_ON_LUA_STATE_CLOSE = 16, // (event)
// Map // Map
MAP_EVENT_ON_CREATE = 17, // (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_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 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 #endif

52
Includes.h Normal file
View 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

View File

@@ -12,134 +12,134 @@ namespace LuaItem
/* BOOLEAN */ /* BOOLEAN */
int IsSoulBound(lua_State* L, Item* item) int IsSoulBound(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsSoulBound()); Eluna::Push(L, item->IsSoulBound());
return 1; return 1;
} }
#if (!defined(TBC) && !defined(CLASSIC)) #if (!defined(TBC) && !defined(CLASSIC))
int IsBoundAccountWide(lua_State* L, Item* item) int IsBoundAccountWide(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsBoundAccountWide()); Eluna::Push(L, item->IsBoundAccountWide());
return 1; return 1;
} }
#endif #endif
int IsBoundByEnchant(lua_State* L, Item* item) int IsBoundByEnchant(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsBoundByEnchant()); Eluna::Push(L, item->IsBoundByEnchant());
return 1; return 1;
} }
int IsNotBoundToPlayer(lua_State* L, Item* item) 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; return 1;
} }
int IsLocked(lua_State* L, Item* item) int IsLocked(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsLocked()); Eluna::Push(L, item->IsLocked());
return 1; return 1;
} }
int IsBag(lua_State* L, Item* item) int IsBag(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsBag()); Eluna::Push(L, item->IsBag());
return 1; return 1;
} }
#ifndef CLASSIC #ifndef CLASSIC
int IsCurrencyToken(lua_State* L, Item* item) int IsCurrencyToken(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsCurrencyToken()); Eluna::Push(L, item->IsCurrencyToken());
return 1; return 1;
} }
#endif #endif
int IsNotEmptyBag(lua_State* L, Item* item) int IsNotEmptyBag(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsNotEmptyBag()); Eluna::Push(L, item->IsNotEmptyBag());
return 1; return 1;
} }
int IsBroken(lua_State* L, Item* item) int IsBroken(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsBroken()); Eluna::Push(L, item->IsBroken());
return 1; return 1;
} }
int CanBeTraded(lua_State* L, Item* item) int CanBeTraded(lua_State* L, Item* item)
{ {
#if (defined(TBC) || defined(CLASSIC)) #if (defined(TBC) || defined(CLASSIC))
sEluna->Push(L, item->CanBeTraded()); Eluna::Push(L, item->CanBeTraded());
#else #else
bool mail = sEluna->CHECKVAL<bool>(L, 2, false); bool mail = Eluna::CHECKVAL<bool>(L, 2, false);
sEluna->Push(L, item->CanBeTraded(mail)); Eluna::Push(L, item->CanBeTraded(mail));
#endif #endif
return 1; return 1;
} }
int IsInTrade(lua_State* L, Item* item) int IsInTrade(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsInTrade()); Eluna::Push(L, item->IsInTrade());
return 1; return 1;
} }
int IsInBag(lua_State* L, Item* item) int IsInBag(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsInBag()); Eluna::Push(L, item->IsInBag());
return 1; return 1;
} }
int IsEquipped(lua_State* L, Item* item) int IsEquipped(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsEquipped()); Eluna::Push(L, item->IsEquipped());
return 1; return 1;
} }
int HasQuest(lua_State* L, Item* item) int HasQuest(lua_State* L, Item* item)
{ {
uint32 quest = sEluna->CHECKVAL<uint32>(L, 2); uint32 quest = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, item->HasQuest(quest)); Eluna::Push(L, item->HasQuest(quest));
#else #else
sEluna->Push(L, item->hasQuest(quest)); Eluna::Push(L, item->hasQuest(quest));
#endif #endif
return 1; return 1;
} }
int IsPotion(lua_State* L, Item* item) int IsPotion(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsPotion()); Eluna::Push(L, item->IsPotion());
return 1; return 1;
} }
#ifndef CATA #ifndef CATA
int IsWeaponVellum(lua_State* L, Item* item) int IsWeaponVellum(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsWeaponVellum()); Eluna::Push(L, item->IsWeaponVellum());
return 1; return 1;
} }
int IsArmorVellum(lua_State* L, Item* item) int IsArmorVellum(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsArmorVellum()); Eluna::Push(L, item->IsArmorVellum());
return 1; return 1;
} }
#endif #endif
int IsConjuredConsumable(lua_State* L, Item* item) int IsConjuredConsumable(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->IsConjuredConsumable()); Eluna::Push(L, item->IsConjuredConsumable());
return 1; return 1;
} }
/* /*
int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
{ {
sEluna->Push(L, item->IsRefundExpired()); Eluna::Push(L, item->IsRefundExpired());
return 1; return 1;
} }
*/ */
@@ -157,7 +157,7 @@ namespace LuaItem
// LOCALE_esMX = 7, // LOCALE_esMX = 7,
// LOCALE_ruRU = 8 // 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) if (loc_idx < 0 || loc_idx >= MAX_LOCALES)
return luaL_argerror(L, 2, "valid LocaleConstant expected"); return luaL_argerror(L, 2, "valid LocaleConstant expected");
@@ -211,212 +211,212 @@ namespace LuaItem
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" << item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
(uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r"; (uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r";
sEluna->Push(L, oss.str()); Eluna::Push(L, oss.str());
return 1; return 1;
} }
int GetGUID(lua_State* L, Item* item) int GetGUID(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetGUIDLow()); Eluna::Push(L, item->GetGUIDLow());
return 1; return 1;
} }
int GetOwnerGUID(lua_State* L, Item* item) int GetOwnerGUID(lua_State* L, Item* item)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, item->GetOwnerGuid()); Eluna::Push(L, item->GetOwnerGuid());
#else #else
sEluna->Push(L, item->GetOwnerGUID()); Eluna::Push(L, item->GetOwnerGUID());
#endif #endif
return 1; return 1;
} }
int GetOwner(lua_State* L, Item* item) int GetOwner(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetOwner()); Eluna::Push(L, item->GetOwner());
return 1; return 1;
} }
int GetCount(lua_State* L, Item* item) int GetCount(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetCount()); Eluna::Push(L, item->GetCount());
return 1; return 1;
} }
int GetMaxStackCount(lua_State* L, Item* item) int GetMaxStackCount(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetMaxStackCount()); Eluna::Push(L, item->GetMaxStackCount());
return 1; return 1;
} }
int GetSlot(lua_State* L, Item* item) int GetSlot(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetSlot()); Eluna::Push(L, item->GetSlot());
return 1; return 1;
} }
int GetBagSlot(lua_State* L, Item* item) int GetBagSlot(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetBagSlot()); Eluna::Push(L, item->GetBagSlot());
return 1; return 1;
} }
int GetGUIDLow(lua_State* L, Item* item) int GetGUIDLow(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetGUIDLow()); Eluna::Push(L, item->GetGUIDLow());
return 1; return 1;
} }
int GetEnchantmentId(lua_State* L, Item* item) 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) if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); 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; return 1;
} }
int GetSpellId(lua_State* L, Item* item) 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) if (index >= MAX_ITEM_PROTO_SPELLS)
return luaL_argerror(L, 2, "valid SpellIndex expected"); 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; return 1;
} }
int GetSpellTrigger(lua_State* L, Item* item) 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) if (index >= MAX_ITEM_PROTO_SPELLS)
return luaL_argerror(L, 2, "valid SpellIndex expected"); 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; return 1;
} }
int GetClass(lua_State* L, Item* item) int GetClass(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->Class); Eluna::Push(L, item->GetTemplate()->Class);
return 1; return 1;
} }
int GetSubClass(lua_State* L, Item* item) int GetSubClass(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->SubClass); Eluna::Push(L, item->GetTemplate()->SubClass);
return 1; return 1;
} }
int GetName(lua_State* L, Item* item) int GetName(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->Name1); Eluna::Push(L, item->GetTemplate()->Name1);
return 1; return 1;
} }
int GetDisplayId(lua_State* L, Item* item) int GetDisplayId(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->DisplayInfoID); Eluna::Push(L, item->GetTemplate()->DisplayInfoID);
return 1; return 1;
} }
int GetQuality(lua_State* L, Item* item) int GetQuality(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->Quality); Eluna::Push(L, item->GetTemplate()->Quality);
return 1; return 1;
} }
int GetBuyCount(lua_State* L, Item* item) int GetBuyCount(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->BuyCount); Eluna::Push(L, item->GetTemplate()->BuyCount);
return 1; return 1;
} }
int GetBuyPrice(lua_State* L, Item* item) int GetBuyPrice(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->BuyPrice); Eluna::Push(L, item->GetTemplate()->BuyPrice);
return 1; return 1;
} }
int GetSellPrice(lua_State* L, Item* item) int GetSellPrice(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->SellPrice); Eluna::Push(L, item->GetTemplate()->SellPrice);
return 1; return 1;
} }
int GetInventoryType(lua_State* L, Item* item) int GetInventoryType(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->InventoryType); Eluna::Push(L, item->GetTemplate()->InventoryType);
return 1; return 1;
} }
int GetAllowableClass(lua_State* L, Item* item) int GetAllowableClass(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->AllowableClass); Eluna::Push(L, item->GetTemplate()->AllowableClass);
return 1; return 1;
} }
int GetAllowableRace(lua_State* L, Item* item) int GetAllowableRace(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->AllowableRace); Eluna::Push(L, item->GetTemplate()->AllowableRace);
return 1; return 1;
} }
int GetItemLevel(lua_State* L, Item* item) int GetItemLevel(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->ItemLevel); Eluna::Push(L, item->GetTemplate()->ItemLevel);
return 1; return 1;
} }
int GetRequiredLevel(lua_State* L, Item* item) int GetRequiredLevel(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->RequiredLevel); Eluna::Push(L, item->GetTemplate()->RequiredLevel);
return 1; return 1;
} }
#ifdef WOTLK #ifdef WOTLK
int GetStatsCount(lua_State* L, Item* item) int GetStatsCount(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->StatsCount); Eluna::Push(L, item->GetTemplate()->StatsCount);
return 1; return 1;
} }
#endif #endif
int GetRandomProperty(lua_State* L, Item* item) int GetRandomProperty(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->RandomProperty); Eluna::Push(L, item->GetTemplate()->RandomProperty);
return 1; return 1;
} }
#ifndef CLASSIC #ifndef CLASSIC
int GetRandomSuffix(lua_State* L, Item* item) int GetRandomSuffix(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->RandomSuffix); Eluna::Push(L, item->GetTemplate()->RandomSuffix);
return 1; return 1;
} }
#endif #endif
int GetItemSet(lua_State* L, Item* item) int GetItemSet(lua_State* L, Item* item)
{ {
sEluna->Push(L, item->GetTemplate()->ItemSet); Eluna::Push(L, item->GetTemplate()->ItemSet);
return 1; return 1;
} }
int GetBagSize(lua_State* L, Item* item) int GetBagSize(lua_State* L, Item* item)
{ {
if (Bag* bag = item->ToBag()) if (Bag* bag = item->ToBag())
sEluna->Push(L, bag->GetBagSize()); Eluna::Push(L, bag->GetBagSize());
else else
sEluna->Push(L, 0); Eluna::Push(L, 0);
return 1; return 1;
} }
/* SETTERS */ /* SETTERS */
int SetOwner(lua_State* L, Item* item) int SetOwner(lua_State* L, Item* item)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#ifdef MANGOS #ifdef MANGOS
item->SetOwnerGuid(player->GET_GUID()); item->SetOwnerGuid(player->GET_GUID());
#else #else
@@ -427,7 +427,7 @@ namespace LuaItem
int SetBinding(lua_State* L, Item* item) int SetBinding(lua_State* L, Item* item)
{ {
bool soulbound = sEluna->CHECKVAL<bool>(L, 2); bool soulbound = Eluna::CHECKVAL<bool>(L, 2);
item->SetBinding(soulbound); item->SetBinding(soulbound);
return 0; return 0;
@@ -435,7 +435,7 @@ namespace LuaItem
int SetCount(lua_State* L, Item* item) int SetCount(lua_State* L, Item* item)
{ {
uint32 count = sEluna->CHECKVAL<uint32>(L, 2); uint32 count = Eluna::CHECKVAL<uint32>(L, 2);
item->SetCount(count); item->SetCount(count);
return 0; return 0;
} }
@@ -445,25 +445,25 @@ namespace LuaItem
Player* owner = item->GetOwner(); Player* owner = item->GetOwner();
if (!owner) if (!owner)
{ {
sEluna->Push(L, false); Eluna::Push(L, false);
return 1; return 1;
} }
uint32 enchant = sEluna->CHECKVAL<uint32>(L, 2); uint32 enchant = Eluna::CHECKVAL<uint32>(L, 2);
if (!sSpellItemEnchantmentStore.LookupEntry(enchant)) if (!sSpellItemEnchantmentStore.LookupEntry(enchant))
{ {
sEluna->Push(L, false); Eluna::Push(L, false);
return 1; return 1;
} }
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(L, 3); EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 3);
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
owner->ApplyEnchantment(item, slot, false); owner->ApplyEnchantment(item, slot, false);
item->SetEnchantment(slot, enchant, 0, 0); item->SetEnchantment(slot, enchant, 0, 0);
owner->ApplyEnchantment(item, slot, true); owner->ApplyEnchantment(item, slot, true);
sEluna->Push(L, true); Eluna::Push(L, true);
return 1; return 1;
} }
@@ -473,23 +473,23 @@ namespace LuaItem
Player* owner = item->GetOwner(); Player* owner = item->GetOwner();
if (!owner) if (!owner)
{ {
sEluna->Push(L, false); Eluna::Push(L, false);
return 1; return 1;
} }
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(L, 2); EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 2);
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
if (!item->GetEnchantmentId(slot)) if (!item->GetEnchantmentId(slot))
{ {
sEluna->Push(L, false); Eluna::Push(L, false);
return 1; return 1;
} }
owner->ApplyEnchantment(item, slot, false); owner->ApplyEnchantment(item, slot, false);
item->ClearEnchantment(slot); item->ClearEnchantment(slot);
sEluna->Push(L, true); Eluna::Push(L, true);
return 1; return 1;
} }

View File

@@ -6,83 +6,21 @@
#include <ace/Dirent.h> #include <ace/Dirent.h>
#include <ace/OS_NS_sys_stat.h> #include <ace/OS_NS_sys_stat.h>
#include "HookMgr.h"
#include "LuaEngine.h" #include "LuaEngine.h"
#include "Includes.h"
#ifdef MANGOS Eluna::ScriptPaths Eluna::scripts;
INSTANTIATE_SINGLETON_1(Eluna); Eluna* Eluna::GEluna = NULL;
#endif
extern void RegisterFunctions(lua_State* L); extern void RegisterFunctions(lua_State* L);
extern void AddElunaScripts();
// Start or restart eluna. Returns true if started void Eluna::Initialize()
bool StartEluna()
{ {
#ifndef ELUNA uint32 oldMSTime = getMSTime();
#ifndef MANGOS
{
ELUNA_LOG_ERROR("[Eluna]: LuaEngine is Disabled. (If you want to use it please enable in cmake)");
return false;
}
#endif
#endif
ELUNA_GUARD(); scripts.clear();
bool restart = false;
if (sEluna->L)
{
restart = true;
sHookMgr->OnEngineRestart();
ELUNA_LOG_INFO("[Eluna]: Stopping Lua Engine");
// 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"); std::string folderpath = sConfigMgr->GetStringDefault("Eluna.ScriptPath", "lua_scripts");
#if PLATFORM == PLATFORM_UNIX || PLATFORM == PLATFORM_APPLE #if PLATFORM == PLATFORM_UNIX || PLATFORM == PLATFORM_APPLE
if (folderpath[0] == '~') if (folderpath[0] == '~')
@@ -90,39 +28,92 @@ bool StartEluna()
folderpath.replace(0, 1, home); folderpath.replace(0, 1, home);
#endif #endif
ELUNA_LOG_INFO("[Eluna]: Searching scripts from `%s`", folderpath.c_str()); ELUNA_LOG_INFO("[Eluna]: Searching scripts from `%s`", folderpath.c_str());
sEluna->GetScripts(folderpath, scripts); GetScripts(folderpath, scripts);
sEluna->GetScripts(folderpath + "/extensions", scripts); GetScripts(folderpath + "/extensions", scripts);
sEluna->RunScripts(scripts);
/* ELUNA_LOG_INFO("[Eluna]: Loaded %u scripts in %u ms", uint32(scripts.size()), GetMSTimeDiffToNow(oldMSTime));
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();
}
}
{ // Create global eluna
HashMapHolder<GameObject>::ReadGuard g(HashMapHolder<GameObject>::GetLock()); new Eluna();
HashMapHolder<GameObject>::MapType& m = HashMapHolder<GameObject>::GetContainer(); }
for (HashMapHolder<GameObject>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{ void Eluna::Uninitialize()
if (itr->second->IsInWorld()) // must check? {
// if(sEluna->GameObjectEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna? delete GEluna;
itr->second->AIM_Initialize(); }
}
} void Eluna::ReloadEluna()
} {
*/ Uninitialize();
return true; 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 // 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()); ELUNA_LOG_ERROR("[Eluna]: Error loading file `%s`", it->c_str());
report(L); 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) 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); int top = lua_gettop(L);
luaL_checktype(L, top - params, LUA_TFUNCTION);
if (lua_type(L, top - params) == LUA_TFUNCTION) // is function
{
if (lua_pcall(L, params, res, 0)) if (lua_pcall(L, params, res, 0))
{
report(L); 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);
}
} }
void Eluna::Push(lua_State* L) void Eluna::Push(lua_State* L)
@@ -252,13 +222,13 @@ void Eluna::Push(lua_State* L, const uint64 l)
{ {
std::ostringstream ss; std::ostringstream ss;
ss << l; ss << l;
sEluna->Push(L, ss.str()); Push(L, ss.str());
} }
void Eluna::Push(lua_State* L, const int64 l) void Eluna::Push(lua_State* L, const int64 l)
{ {
std::ostringstream ss; std::ostringstream ss;
ss << l; ss << l;
sEluna->Push(L, ss.str()); Push(L, ss.str());
} }
void Eluna::Push(lua_State* L, const uint32 u) 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: case REGTYPE_PACKET:
if (evt < NUM_MSG_TYPES) if (evt < NUM_MSG_TYPES)
{ {
PacketEventBindings.Insert(evt, functionRef); PacketEventBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -566,7 +536,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
case REGTYPE_SERVER: case REGTYPE_SERVER:
if (evt < SERVER_EVENT_COUNT) if (evt < SERVER_EVENT_COUNT)
{ {
ServerEventBindings.Insert(evt, functionRef); ServerEventBindings->Insert(evt, functionRef);
return; return;
} }
break; break;
@@ -574,7 +544,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
case REGTYPE_PLAYER: case REGTYPE_PLAYER:
if (evt < PLAYER_EVENT_COUNT) if (evt < PLAYER_EVENT_COUNT)
{ {
PlayerEventBindings.Insert(evt, functionRef); PlayerEventBindings->Insert(evt, functionRef);
return; return;
} }
break; break;
@@ -582,7 +552,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
case REGTYPE_GUILD: case REGTYPE_GUILD:
if (evt < GUILD_EVENT_COUNT) if (evt < GUILD_EVENT_COUNT)
{ {
GuildEventBindings.Insert(evt, functionRef); GuildEventBindings->Insert(evt, functionRef);
return; return;
} }
break; break;
@@ -590,7 +560,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
case REGTYPE_GROUP: case REGTYPE_GROUP:
if (evt < GROUP_EVENT_COUNT) if (evt < GROUP_EVENT_COUNT)
{ {
GroupEventBindings.Insert(evt, functionRef); GroupEventBindings->Insert(evt, functionRef);
return; return;
} }
break; break;
@@ -598,7 +568,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
case REGTYPE_VEHICLE: case REGTYPE_VEHICLE:
if (evt < VEHICLE_EVENT_COUNT) if (evt < VEHICLE_EVENT_COUNT)
{ {
VehicleEventBindings.Insert(evt, functionRef); VehicleEventBindings->Insert(evt, functionRef);
return; return;
} }
break; break;
@@ -608,12 +578,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
{ {
if (!sObjectMgr->GetCreatureTemplate(id)) 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); luaL_error(L, "Couldn't find a creature with (ID: %d)!", id);
return; return;
} }
sEluna->CreatureEventBindings.Insert(id, evt, functionRef); CreatureEventBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -623,12 +593,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
{ {
if (!sObjectMgr->GetCreatureTemplate(id)) 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); luaL_error(L, "Couldn't find a creature with (ID: %d)!", id);
return; return;
} }
sEluna->CreatureGossipBindings.Insert(id, evt, functionRef); CreatureGossipBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -638,12 +608,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
{ {
if (!sObjectMgr->GetGameObjectTemplate(id)) 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); luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id);
return; return;
} }
sEluna->GameObjectEventBindings.Insert(id, evt, functionRef); GameObjectEventBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -653,12 +623,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
{ {
if (!sObjectMgr->GetGameObjectTemplate(id)) 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); luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id);
return; return;
} }
sEluna->GameObjectGossipBindings.Insert(id, evt, functionRef); GameObjectGossipBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -668,12 +638,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
{ {
if (!sObjectMgr->GetItemTemplate(id)) 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); luaL_error(L, "Couldn't find a item with (ID: %d)!", id);
return; return;
} }
sEluna->ItemEventBindings.Insert(id, evt, functionRef); ItemEventBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -683,12 +653,12 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
{ {
if (!sObjectMgr->GetItemTemplate(id)) 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); luaL_error(L, "Couldn't find a item with (ID: %d)!", id);
return; return;
} }
sEluna->ItemGossipBindings.Insert(id, evt, functionRef); ItemGossipBindings->Insert(id, evt, functionRef);
return; return;
} }
break; break;
@@ -696,32 +666,32 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
case REGTYPE_PLAYER_GOSSIP: case REGTYPE_PLAYER_GOSSIP:
if (evt < GOSSIP_EVENT_COUNT) if (evt < GOSSIP_EVENT_COUNT)
{ {
sEluna->playerGossipBindings.Insert(id, evt, functionRef); playerGossipBindings->Insert(id, evt, functionRef);
return; return;
} }
break; 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); 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 (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr)
{ {
for (ElunaBindingMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) 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(); itr->second.clear();
} }
Bindings.clear(); Bindings.clear();
} }
void Eluna::EventBind::Insert(int eventId, int funcRef) void EventBind::Insert(int eventId, int funcRef)
{ {
Bindings[eventId].push_back(funcRef); Bindings[eventId].push_back(funcRef);
} }
bool Eluna::EventBind::HasEvents(int eventId) const bool EventBind::HasEvents(int eventId) const
{ {
if (Bindings.empty()) if (Bindings.empty())
return false; return false;
@@ -730,61 +700,33 @@ bool Eluna::EventBind::HasEvents(int eventId) const
return true; return true;
} }
void Eluna::EventBind::BeginCall(int eventId) const void EntryBind::Clear()
{
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()
{ {
for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr) for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr)
{ {
for (ElunaBindingMap::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) 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(); itr->second.clear();
} }
Bindings.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]) if (Bindings[entryId][eventId])
{ {
luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // free the unused ref luaL_unref(E.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_error(E.L, "A function is already registered for entry (%d) event (%d)", entryId, eventId);
} }
else else
Bindings[entryId][eventId] = funcRef; Bindings[entryId][eventId] = funcRef;
} }
EventMgr::LuaEvent::LuaEvent(EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj): EventMgr::LuaEvent::LuaEvent(Eluna& _E, EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj):
events(_events), funcRef(_funcRef), delay(_delay), calls(_calls), obj(_obj) E(_E), events(_events), funcRef(_funcRef), delay(_delay), calls(_calls), obj(_obj)
{ {
if (_events) 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() EventMgr::LuaEvent::~LuaEvent()
@@ -792,79 +734,25 @@ EventMgr::LuaEvent::~LuaEvent()
if (events) if (events)
{ {
// Attempt to remove the pointer from LuaEvents // Attempt to remove the pointer from LuaEvents
EventMgr::EventMap::const_iterator it = sEluna->m_EventMgr.LuaEvents.find(events); // Get event set EventMgr::EventMap::const_iterator it = E.m_EventMgr->LuaEvents.find(events); // Get event set
if (it != sEluna->m_EventMgr.LuaEvents.end()) if (it != E.m_EventMgr->LuaEvents.end())
sEluna->m_EventMgr.LuaEvents[events].erase(this);// Remove pointer 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) bool EventMgr::LuaEvent::Execute(uint64 time, uint32 diff)
{ {
ELUNA_GUARD();
bool remove = (calls == 1); bool remove = (calls == 1);
if (!remove) if (!remove)
events->AddEvent(this, events->CalculateTime(delay)); // Reschedule before calling incase RemoveEvents used events->AddEvent(this, events->CalculateTime(delay)); // Reschedule before calling incase RemoveEvents used
sEluna->BeginCall(funcRef); lua_rawgeti(E.L, LUA_REGISTRYINDEX, funcRef);
sEluna->Push(sEluna->L, funcRef); Eluna::Push(E.L, funcRef);
sEluna->Push(sEluna->L, delay); Eluna::Push(E.L, delay);
sEluna->Push(sEluna->L, calls); Eluna::Push(E.L, calls);
if (!remove && calls) if (!remove && calls)
--calls; --calls;
sEluna->Push(sEluna->L, obj); Eluna::Push(E.L, obj);
sEluna->ExecuteCall(4, 0); Eluna::ExecuteCall(E.L, 4, 0);
return remove; // Destory (true) event if not run 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;
}

View File

@@ -14,61 +14,67 @@ extern "C"
#include "lauxlib.h" #include "lauxlib.h"
}; };
#include "HookMgr.h" // Base
#include "Common.h"
// Required #include "SharedDefines.h"
#include "AccountMgr.h" #include <ace/Singleton.h>
#include "AuctionHouseMgr.h" #include <ace/Atomic_Op.h>
#include "Cell.h" // enums
#include "CellImpl.h"
#include "Chat.h"
#include "Channel.h"
#ifdef MANGOS #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 "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 #else
#include "ScriptedCreature.h" #include "GameObjectAI.h"
#include "SpellInfo.h"
#include "WeatherMgr.h"
#endif #endif
#if (!defined(TBC) && !defined(CLASSIC)) #include "Group.h"
#include "Vehicle.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 #endif
#ifndef CLASSIC
#include "ArenaTeam.h"
#endif #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 #ifdef MANGOS
#undef sWorld #undef sWorld
@@ -138,6 +144,8 @@ typedef ThreatContainer::StorageType ThreatList;
#endif #endif
#endif #endif
class Eluna;
template<typename T> template<typename T>
struct ElunaRegister struct ElunaRegister
{ {
@@ -152,6 +160,7 @@ struct EventMgr
typedef std::set<LuaEvent*> EventSet; typedef std::set<LuaEvent*> EventSet;
typedef std::map<EventProcessor*, EventSet> EventMap; typedef std::map<EventProcessor*, EventSet> EventMap;
// typedef UNORDERED_MAP<uint64, EventProcessor> ProcessorMap; // typedef UNORDERED_MAP<uint64, EventProcessor> ProcessorMap;
Eluna& E;
EventMap LuaEvents; // LuaEvents[processor] = {LuaEvent, LuaEvent...} EventMap LuaEvents; // LuaEvents[processor] = {LuaEvent, LuaEvent...}
// ProcessorMap Processors; // Processors[guid] = processor // ProcessorMap Processors; // Processors[guid] = processor
@@ -159,13 +168,14 @@ struct EventMgr
struct LuaEvent : public BasicEvent 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(); ~LuaEvent();
// Should never execute on dead events // Should never execute on dead events
bool Execute(uint64 time, uint32 diff); bool Execute(uint64 time, uint32 diff);
Eluna& E;
EventProcessor* events; // Pointer to events (holds the timed event) EventProcessor* events; // Pointer to events (holds the timed event)
int funcRef; // Lua function reference ID, also used as event ID int funcRef; // Lua function reference ID, also used as event ID
uint32 delay; // Delay between event calls uint32 delay; // Delay between event calls
@@ -173,6 +183,15 @@ struct EventMgr
Object* obj; // Object to push Object* obj; // Object to push
}; };
EventMgr(Eluna& _E) : E(_E)
{
}
~EventMgr()
{
RemoveEvents();
}
// Should be run on world tick // Should be run on world tick
void Update(uint32 diff) void Update(uint32 diff)
{ {
@@ -243,7 +262,7 @@ struct EventMgr
{ {
if (!events || funcRef <= 0) // If funcRef <= 0, function reference failed if (!events || funcRef <= 0) // If funcRef <= 0, function reference failed
return 0; // on fail always return 0. funcRef can be negative. 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 return funcRef; // return the event ID
} }
@@ -308,36 +327,17 @@ struct EventMgr
if (RemoveEvent((it++)->first, eventId)) if (RemoveEvent((it++)->first, eventId))
break; // succesfully remove the event, stop loop. break; // succesfully remove the event, stop loop.
} }
~EventMgr()
{
RemoveEvents();
}
}; };
class Eluna struct EventBind
{ {
public:
friend class ScriptMgr;
// friend class ACE_Singleton<Eluna, ACE_Null_Mutex>;
lua_State* L;
EventMgr m_EventMgr;
// ACE_Recursive_Thread_Mutex lock;
Eluna()
{
L = NULL;
}
~Eluna()
{
}
struct EventBind
{
typedef std::vector<int> ElunaBindingMap; typedef std::vector<int> ElunaBindingMap;
typedef std::map<int, ElunaBindingMap> ElunaEntryMap; typedef std::map<int, ElunaBindingMap> ElunaEntryMap;
Eluna& E;
EventBind(Eluna& _E): E(_E)
{
}
~EventBind() ~EventBind()
{ {
@@ -361,21 +361,19 @@ public:
// Checks if there are events for ID // Checks if there are events for ID
bool HasEvents(int eventId) const; 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}; ElunaEntryMap Bindings; // Binding store Bindings[eventId] = {funcRef};
}; };
struct EntryBind struct EntryBind
{ {
typedef std::map<int, int> ElunaBindingMap; typedef std::map<int, int> ElunaBindingMap;
typedef UNORDERED_MAP<uint32, ElunaBindingMap> ElunaEntryMap; typedef UNORDERED_MAP<uint32, ElunaBindingMap> ElunaEntryMap;
Eluna& E;
EntryBind(Eluna& _E): E(_E)
{
}
~EntryBind() ~EntryBind()
{ {
@@ -420,57 +418,77 @@ public:
} }
ElunaEntryMap Bindings; // Binding store Bindings[entryId][eventId] = funcRef; ElunaEntryMap Bindings; // Binding store Bindings[entryId][eventId] = funcRef;
}; };
class Eluna
{
public:
friend class ScriptMgr;
typedef std::set<std::string> ScriptPaths;
static Eluna* GEluna;
lua_State* L;
int userdata_table;
EventMgr* m_EventMgr;
// Use templates for EventBind // Use templates for EventBind
EventBind PacketEventBindings; EventBind* ServerEventBindings;
EventBind ServerEventBindings; EventBind* PlayerEventBindings;
EventBind PlayerEventBindings; EventBind* GuildEventBindings;
EventBind GuildEventBindings; EventBind* GroupEventBindings;
EventBind GroupEventBindings; EventBind* VehicleEventBindings;
EventBind VehicleEventBindings;
EntryBind CreatureEventBindings; EntryBind* PacketEventBindings;
EntryBind CreatureGossipBindings; EntryBind* CreatureEventBindings;
EntryBind GameObjectEventBindings; EntryBind* CreatureGossipBindings;
EntryBind GameObjectGossipBindings; EntryBind* GameObjectEventBindings;
EntryBind ItemEventBindings; EntryBind* GameObjectGossipBindings;
EntryBind ItemGossipBindings; EntryBind* ItemEventBindings;
EntryBind playerGossipBindings; 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 report(lua_State*);
static void ExecuteCall(lua_State* L, int params, int res);
void Register(uint8 reg, uint32 id, uint32 evt, int func); 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); void RunScripts(ScriptPaths& scripts);
static void RemoveRef(const void* obj);
// Pushes // Pushes
void Push(lua_State*); // nil static void Push(lua_State*); // nil
void Push(lua_State*, const uint64); static void Push(lua_State*, const uint64);
void Push(lua_State*, const int64); static void Push(lua_State*, const int64);
void Push(lua_State*, const uint32); static void Push(lua_State*, const uint32);
void Push(lua_State*, const int32); static void Push(lua_State*, const int32);
void Push(lua_State*, const bool); static void Push(lua_State*, const bool);
void Push(lua_State*, const float); static void Push(lua_State*, const float);
void Push(lua_State*, const double); static void Push(lua_State*, const double);
void Push(lua_State*, const char*); static void Push(lua_State*, const char*);
void Push(lua_State*, const std::string); static void Push(lua_State*, const std::string);
template<typename T> void Push(lua_State* L, T const* ptr) template<typename T> static void Push(lua_State* L, T const* ptr)
{ {
ElunaTemplate<T>::push(L, ptr); ElunaTemplate<T>::push(L, ptr);
} }
void Push(lua_State* L, Object const* obj); static void Push(lua_State* L, Object const* obj);
void Push(lua_State* L, WorldObject const* obj); static void Push(lua_State* L, WorldObject const* obj);
void Push(lua_State* L, Unit const* unit); static void Push(lua_State* L, Unit const* unit);
void Push(lua_State* L, Pet const* pet); static void Push(lua_State* L, Pet const* pet);
void Push(lua_State* L, TempSummon const* summon); static void Push(lua_State* L, TempSummon const* summon);
// Checks // Checks
template<typename T> T CHECKVAL(lua_State* L, int narg); template<typename T> static T CHECKVAL(lua_State* L, int narg);
template<typename T> T CHECKVAL(lua_State* L, int narg, T def); template<typename T> static 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* CHECKOBJ(lua_State* L, int narg, bool error = true)
{ {
return ElunaTemplate<T>::check(L, narg, error); return ElunaTemplate<T>::check(L, narg, error);
} }
@@ -550,6 +568,167 @@ public:
WorldObjectInRangeCheck(WorldObjectInRangeCheck const&); 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<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error);
template<> Player* Eluna::CHECKOBJ<Player>(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<> GameObject* Eluna::CHECKOBJ<GameObject>(lua_State* L, int narg, bool error);
template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error); template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error);
#ifdef MANGOS #define sEluna Eluna::GEluna
#define sEluna (&MaNGOS::Singleton<Eluna>::Instance())
#else
#define sEluna ACE_Singleton<Eluna, ACE_Null_Mutex>::instance()
#endif
#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> template<typename T>
class ElunaTemplate class ElunaTemplate
@@ -679,7 +854,7 @@ public:
if (!manageMemory) if (!manageMemory)
{ {
lua_rawgeti(L, LUA_REGISTRYINDEX, sHookMgr->userdata_table); lua_rawgeti(L, LUA_REGISTRYINDEX, sEluna->userdata_table);
lua_pushfstring(L, "%p", obj); lua_pushfstring(L, "%p", obj);
lua_gettable(L, -2); lua_gettable(L, -2);
if (!lua_isnoneornil(L, -1) && luaL_checkudata(L, -1, tname)) if (!lua_isnoneornil(L, -1) && luaL_checkudata(L, -1, tname))
@@ -692,11 +867,11 @@ public:
} }
// Create new userdata // 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) if (!ptrHold)
{ {
ELUNA_LOG_ERROR("%s could not create new userdata", tname); ELUNA_LOG_ERROR("%s could not create new userdata", tname);
lua_remove(L, -1); lua_pop(L, manageMemory ? 1 : 2);
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
@@ -707,18 +882,17 @@ public:
if (!lua_istable(L, -1)) if (!lua_istable(L, -1))
{ {
ELUNA_LOG_ERROR("%s missing metatable", tname); ELUNA_LOG_ERROR("%s missing metatable", tname);
lua_pop(L, 2); lua_pop(L, manageMemory ? 2 : 3);
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
if (!manageMemory) if (!manageMemory)
{ {
lua_pushfstring(L, "%p", obj); lua_pushfstring(L, "%p", obj);
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_settable(L, -3); lua_settable(L, -4);
lua_remove(L, -2); lua_remove(L, -2);
} }
return 1; return 1;
@@ -741,7 +915,7 @@ public:
if (!manageMemory) if (!manageMemory)
{ {
// Check pointer validity // 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_pushfstring(L, "%p", *ptrHold);
lua_gettable(L, -2); lua_gettable(L, -2);
lua_remove(L, -2); lua_remove(L, -2);
@@ -767,7 +941,7 @@ public:
static int thunk(lua_State* L) 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) if (!obj)
return 0; return 0;
ElunaRegister<T>* l = static_cast<ElunaRegister<T>*>(lua_touserdata(L, lua_upvalueindex(1))); ElunaRegister<T>* l = static_cast<ElunaRegister<T>*>(lua_touserdata(L, lua_upvalueindex(1)));
@@ -785,7 +959,7 @@ public:
static int tostringT(lua_State* L) 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) if (obj)
{ {
lua_pushfstring(L, "%s: (%p)", tname, 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 #endif

View File

@@ -5,7 +5,9 @@
*/ */
// Eluna // Eluna
#include "HookMgr.h"
#include "LuaEngine.h" #include "LuaEngine.h"
#include "Includes.h"
// Methods // Methods
#include "GlobalMethods.h" #include "GlobalMethods.h"
#include "ObjectMethods.h" #include "ObjectMethods.h"
@@ -30,7 +32,7 @@
void RegisterGlobals(lua_State* L) void RegisterGlobals(lua_State* L)
{ {
// Hooks // 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, "RegisterServerEvent", &LuaGlobalFunctions::RegisterServerEvent); // RegisterServerEvent(event, function)
lua_register(L, "RegisterPlayerEvent", &LuaGlobalFunctions::RegisterPlayerEvent); // RegisterPlayerEvent(event, function) lua_register(L, "RegisterPlayerEvent", &LuaGlobalFunctions::RegisterPlayerEvent); // RegisterPlayerEvent(event, function)
lua_register(L, "RegisterGuildEvent", &LuaGlobalFunctions::RegisterGuildEvent); // RegisterGuildEvent(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 lua_register(L, "GetMapById", &LuaGlobalFunctions::GetMapById); // GetMapById(mapId, instance) - Returns map object of id specified. UNDOCUMENTED
// Other // 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, "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, "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) 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); 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. // 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"); ElunaTemplate<Object>::Register(L, "Object");

View File

@@ -13,7 +13,7 @@ namespace LuaMap
#ifndef CLASSIC #ifndef CLASSIC
int IsArena(lua_State* L, Map* map) int IsArena(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->IsBattleArena()); Eluna::Push(L, map->IsBattleArena());
return 1; return 1;
} }
#endif #endif
@@ -21,99 +21,99 @@ namespace LuaMap
int IsBattleground(lua_State* L, Map* map) int IsBattleground(lua_State* L, Map* map)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, map->IsBattleGround()); Eluna::Push(L, map->IsBattleGround());
#else #else
sEluna->Push(L, map->IsBattleground()); Eluna::Push(L, map->IsBattleground());
#endif #endif
return 1; return 1;
} }
int IsDungeon(lua_State* L, Map* map) int IsDungeon(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->IsDungeon()); Eluna::Push(L, map->IsDungeon());
return 1; return 1;
} }
int IsEmpty(lua_State* L, Map* map) int IsEmpty(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->isEmpty()); Eluna::Push(L, map->isEmpty());
return 1; return 1;
} }
#ifndef CLASSIC #ifndef CLASSIC
int IsHeroic(lua_State* L, Map* map) int IsHeroic(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->IsHeroic()); Eluna::Push(L, map->IsHeroic());
return 1; return 1;
} }
#endif #endif
int IsRaid(lua_State* L, Map* map) int IsRaid(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->IsRaid()); Eluna::Push(L, map->IsRaid());
return 1; return 1;
} }
/* GETTERS */ /* GETTERS */
int GetName(lua_State* L, Map* map) int GetName(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->GetMapName()); Eluna::Push(L, map->GetMapName());
return 1; return 1;
} }
int GetHeight(lua_State* L, Map* map) int GetHeight(lua_State* L, Map* map)
{ {
float x = sEluna->CHECKVAL<float>(L, 2); float x = Eluna::CHECKVAL<float>(L, 2);
float y = sEluna->CHECKVAL<float>(L, 3); float y = Eluna::CHECKVAL<float>(L, 3);
#if (defined(TBC) || defined(CLASSIC)) #if (defined(TBC) || defined(CLASSIC))
float z = map->GetHeight(x, y, MAX_HEIGHT); float z = map->GetHeight(x, y, MAX_HEIGHT);
#else #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); float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT);
#endif #endif
if (z != INVALID_HEIGHT) if (z != INVALID_HEIGHT)
sEluna->Push(L, z); Eluna::Push(L, z);
return 1; return 1;
} }
int GetDifficulty(lua_State* L, Map* map) int GetDifficulty(lua_State* L, Map* map)
{ {
#ifndef CLASSIC #ifndef CLASSIC
sEluna->Push(L, map->GetDifficulty()); Eluna::Push(L, map->GetDifficulty());
#else #else
sEluna->Push(L, (Difficulty)0); Eluna::Push(L, (Difficulty)0);
#endif #endif
return 1; return 1;
} }
int GetInstanceId(lua_State* L, Map* map) int GetInstanceId(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->GetInstanceId()); Eluna::Push(L, map->GetInstanceId());
return 1; return 1;
} }
int GetPlayerCount(lua_State* L, Map* map) int GetPlayerCount(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->GetPlayersCountExceptGMs()); Eluna::Push(L, map->GetPlayersCountExceptGMs());
return 1; return 1;
} }
int GetMapId(lua_State* L, Map* map) int GetMapId(lua_State* L, Map* map)
{ {
sEluna->Push(L, map->GetId()); Eluna::Push(L, map->GetId());
return 1; return 1;
} }
int GetAreaId(lua_State* L, Map* map) int GetAreaId(lua_State* L, Map* map)
{ {
float x = sEluna->CHECKVAL<float>(L, 2); float x = Eluna::CHECKVAL<float>(L, 2);
float y = sEluna->CHECKVAL<float>(L, 3); float y = Eluna::CHECKVAL<float>(L, 3);
float z = sEluna->CHECKVAL<float>(L, 4); float z = Eluna::CHECKVAL<float>(L, 4);
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, map->GetTerrain()->GetAreaId(x, y, z)); Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z));
#else #else
sEluna->Push(L, map->GetAreaId(x, y, z)); Eluna::Push(L, map->GetAreaId(x, y, z));
#endif #endif
return 1; return 1;
} }

View File

@@ -12,90 +12,90 @@ namespace LuaObject
/* BOOLEAN */ /* BOOLEAN */
int HasFlag(lua_State* L, Object* obj) int HasFlag(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3); uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
sEluna->Push(L, obj->HasFlag(index, flag)); Eluna::Push(L, obj->HasFlag(index, flag));
return 1; return 1;
} }
int IsInWorld(lua_State* L, Object* obj) int IsInWorld(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->IsInWorld()); Eluna::Push(L, obj->IsInWorld());
return 1; return 1;
} }
/* GETTERS */ /* GETTERS */
int GetInt32Value(lua_State* L, Object* obj) int GetInt32Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
sEluna->Push(L, obj->GetInt32Value(index)); Eluna::Push(L, obj->GetInt32Value(index));
return 1; return 1;
} }
int GetUInt32Value(lua_State* L, Object* obj) int GetUInt32Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
sEluna->Push(L, obj->GetUInt32Value(index)); Eluna::Push(L, obj->GetUInt32Value(index));
return 1; return 1;
} }
int GetFloatValue(lua_State* L, Object* obj) int GetFloatValue(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
sEluna->Push(L, obj->GetFloatValue(index)); Eluna::Push(L, obj->GetFloatValue(index));
return 1; return 1;
} }
int GetByteValue(lua_State* L, Object* obj) int GetByteValue(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3); uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
sEluna->Push(L, obj->GetByteValue(index, offset)); Eluna::Push(L, obj->GetByteValue(index, offset));
return 1; return 1;
} }
int GetUInt16Value(lua_State* L, Object* obj) int GetUInt16Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3); uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
sEluna->Push(L, obj->GetUInt16Value(index, offset)); Eluna::Push(L, obj->GetUInt16Value(index, offset));
return 1; return 1;
} }
int GetScale(lua_State* L, Object* obj) int GetScale(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->GetObjectScale()); Eluna::Push(L, obj->GetObjectScale());
return 1; return 1;
} }
int GetEntry(lua_State* L, Object* obj) int GetEntry(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->GetEntry()); Eluna::Push(L, obj->GetEntry());
return 1; return 1;
} }
int GetGUID(lua_State* L, Object* obj) int GetGUID(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->GET_GUID()); Eluna::Push(L, obj->GET_GUID());
return 1; return 1;
} }
int GetGUIDLow(lua_State* L, Object* obj) int GetGUIDLow(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->GetGUIDLow()); Eluna::Push(L, obj->GetGUIDLow());
return 1; return 1;
} }
int GetTypeId(lua_State* L, Object* obj) int GetTypeId(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->GetTypeId()); Eluna::Push(L, obj->GetTypeId());
return 1; return 1;
} }
int GetUInt64Value(lua_State* L, Object* obj) int GetUInt64Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
obj->GetUInt64Value(index); obj->GetUInt64Value(index);
return 0; return 0;
} }
@@ -103,8 +103,8 @@ namespace LuaObject
/* SETTERS */ /* SETTERS */
int SetFlag(lua_State* L, Object* obj) int SetFlag(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3); uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
obj->SetFlag(index, flag); obj->SetFlag(index, flag);
return 0; return 0;
@@ -112,24 +112,24 @@ namespace LuaObject
int SetInt32Value(lua_State* L, Object* obj) int SetInt32Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
int32 value = sEluna->CHECKVAL<int32>(L, 3); int32 value = Eluna::CHECKVAL<int32>(L, 3);
obj->SetInt32Value(index, value); obj->SetInt32Value(index, value);
return 0; return 0;
} }
int SetUInt32Value(lua_State* L, Object* obj) int SetUInt32Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint32 value = sEluna->CHECKVAL<uint32>(L, 3); uint32 value = Eluna::CHECKVAL<uint32>(L, 3);
obj->SetUInt32Value(index, value); obj->SetUInt32Value(index, value);
return 0; return 0;
} }
int SetFloatValue(lua_State* L, Object* obj) int SetFloatValue(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
float value = sEluna->CHECKVAL<float>(L, 3); float value = Eluna::CHECKVAL<float>(L, 3);
obj->SetFloatValue(index, value); obj->SetFloatValue(index, value);
return 0; return 0;
@@ -137,34 +137,34 @@ namespace LuaObject
int SetByteValue(lua_State* L, Object* obj) int SetByteValue(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3); uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
uint8 value = sEluna->CHECKVAL<uint8>(L, 4); uint8 value = Eluna::CHECKVAL<uint8>(L, 4);
obj->SetByteValue(index, offset, value); obj->SetByteValue(index, offset, value);
return 0; return 0;
} }
int SetUInt16Value(lua_State* L, Object* obj) int SetUInt16Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3); uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
uint16 value = sEluna->CHECKVAL<uint16>(L, 4); uint16 value = Eluna::CHECKVAL<uint16>(L, 4);
obj->SetUInt16Value(index, offset, value); obj->SetUInt16Value(index, offset, value);
return 0; return 0;
} }
int SetInt16Value(lua_State* L, Object* obj) int SetInt16Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3); uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
int16 value = sEluna->CHECKVAL<int16>(L, 4); int16 value = Eluna::CHECKVAL<int16>(L, 4);
obj->SetInt16Value(index, offset, value); obj->SetInt16Value(index, offset, value);
return 0; return 0;
} }
int SetScale(lua_State* L, Object* obj) int SetScale(lua_State* L, Object* obj)
{ {
float size = sEluna->CHECKVAL<float>(L, 2); float size = Eluna::CHECKVAL<float>(L, 2);
obj->SetObjectScale(size); obj->SetObjectScale(size);
return 0; return 0;
@@ -172,8 +172,8 @@ namespace LuaObject
int SetUInt64Value(lua_State* L, Object* obj) int SetUInt64Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint64 value = sEluna->CHECKVAL<uint64>(L, 3); uint64 value = Eluna::CHECKVAL<uint64>(L, 3);
obj->SetUInt64Value(index, value); obj->SetUInt64Value(index, value);
return 0; return 0;
} }
@@ -181,8 +181,8 @@ namespace LuaObject
/* OTHER */ /* OTHER */
int RemoveFlag(lua_State* L, Object* obj) int RemoveFlag(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3); uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
obj->RemoveFlag(index, flag); obj->RemoveFlag(index, flag);
return 0; return 0;
@@ -190,39 +190,39 @@ namespace LuaObject
int UpdateUInt32Value(lua_State* L, Object* obj) int UpdateUInt32Value(lua_State* L, Object* obj)
{ {
uint16 index = sEluna->CHECKVAL<uint16>(L, 2); uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
uint32 value = sEluna->CHECKVAL<uint32>(L, 3); uint32 value = Eluna::CHECKVAL<uint32>(L, 3);
obj->UpdateUInt32Value(index, value); obj->UpdateUInt32Value(index, value);
return 0; return 0;
} }
int ToCorpse(lua_State* L, Object* obj) int ToCorpse(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->ToCorpse()); Eluna::Push(L, obj->ToCorpse());
return 1; return 1;
} }
int ToGameObject(lua_State* L, Object* obj) int ToGameObject(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->ToGameObject()); Eluna::Push(L, obj->ToGameObject());
return 1; return 1;
} }
int ToUnit(lua_State* L, Object* obj) int ToUnit(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->ToUnit()); Eluna::Push(L, obj->ToUnit());
return 1; return 1;
} }
int ToCreature(lua_State* L, Object* obj) int ToCreature(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->ToCreature()); Eluna::Push(L, obj->ToCreature());
return 1; return 1;
} }
int ToPlayer(lua_State* L, Object* obj) int ToPlayer(lua_State* L, Object* obj)
{ {
sEluna->Push(L, obj->ToPlayer()); Eluna::Push(L, obj->ToPlayer());
return 1; return 1;
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -17,13 +17,13 @@ namespace LuaQuery
/* BOOLEAN */ /* BOOLEAN */
int IsNull(lua_State* L, QueryResult* result) int IsNull(lua_State* L, QueryResult* result)
{ {
uint32 col = sEluna->CHECKVAL<uint32>(L, 2); uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS #ifdef MANGOS
if (col < RESULT->GetFieldCount()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].IsNULL()); Eluna::Push(L, RESULT->Fetch()[col].IsNULL());
#else #else
if (col < RESULT->GetFieldCount()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].IsNull()); Eluna::Push(L, RESULT->Fetch()[col].IsNull());
#endif #endif
return 1; return 1;
} }
@@ -31,119 +31,119 @@ namespace LuaQuery
/* GETTERS */ /* GETTERS */
int GetColumnCount(lua_State* L, QueryResult* result) int GetColumnCount(lua_State* L, QueryResult* result)
{ {
sEluna->Push(L, RESULT->GetFieldCount()); Eluna::Push(L, RESULT->GetFieldCount());
return 1; return 1;
} }
int GetRowCount(lua_State* L, QueryResult* result) int GetRowCount(lua_State* L, QueryResult* result)
{ {
if (RESULT->GetRowCount() > (uint32)-1) if (RESULT->GetRowCount() > (uint32)-1)
sEluna->Push(L, (uint32)-1); Eluna::Push(L, (uint32)-1);
else else
sEluna->Push(L, RESULT->GetRowCount()); Eluna::Push(L, RESULT->GetRowCount());
return 1; return 1;
} }
int GetBool(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetBool()); Eluna::Push(L, RESULT->Fetch()[col].GetBool());
return 1; return 1;
} }
int GetUInt8(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt8()); Eluna::Push(L, RESULT->Fetch()[col].GetUInt8());
return 1; return 1;
} }
int GetUInt16(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt16()); Eluna::Push(L, RESULT->Fetch()[col].GetUInt16());
return 1; return 1;
} }
int GetUInt32(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt32()); Eluna::Push(L, RESULT->Fetch()[col].GetUInt32());
return 1; return 1;
} }
int GetUInt64(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetUInt64()); Eluna::Push(L, RESULT->Fetch()[col].GetUInt64());
return 1; return 1;
} }
int GetInt8(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt8()); Eluna::Push(L, RESULT->Fetch()[col].GetInt8());
return 1; return 1;
} }
int GetInt16(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt16()); Eluna::Push(L, RESULT->Fetch()[col].GetInt16());
return 1; return 1;
} }
int GetInt32(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt32()); Eluna::Push(L, RESULT->Fetch()[col].GetInt32());
return 1; return 1;
} }
int GetInt64(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetInt64()); Eluna::Push(L, RESULT->Fetch()[col].GetInt64());
return 1; return 1;
} }
int GetFloat(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetFloat()); Eluna::Push(L, RESULT->Fetch()[col].GetFloat());
return 1; return 1;
} }
int GetDouble(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetDouble()); Eluna::Push(L, RESULT->Fetch()[col].GetDouble());
return 1; return 1;
} }
int GetString(lua_State* L, QueryResult* result) 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()) if (col < RESULT->GetFieldCount())
sEluna->Push(L, RESULT->Fetch()[col].GetString()); Eluna::Push(L, RESULT->Fetch()[col].GetString());
return 1; return 1;
} }
/* OTHER */ /* OTHER */
int NextRow(lua_State* L, QueryResult* result) int NextRow(lua_State* L, QueryResult* result)
{ {
sEluna->Push(L, RESULT->NextRow()); Eluna::Push(L, RESULT->NextRow());
return 1; return 1;
} }
}; };

View File

@@ -12,11 +12,11 @@ namespace LuaQuest
/* BOOLEAN */ /* BOOLEAN */
int HasFlag(lua_State* L, Quest* quest) int HasFlag(lua_State* L, Quest* quest)
{ {
uint32 flag = sEluna->CHECKVAL<uint32>(L, 2); uint32 flag = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, quest->HasQuestFlag((QuestFlags)flag)); Eluna::Push(L, quest->HasQuestFlag((QuestFlags)flag));
#else #else
sEluna->Push(L, quest->HasFlag(flag)); Eluna::Push(L, quest->HasFlag(flag));
#endif #endif
return 1; return 1;
} }
@@ -24,73 +24,73 @@ namespace LuaQuest
#ifndef CLASSIC #ifndef CLASSIC
int IsDaily(lua_State* L, Quest* quest) int IsDaily(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->IsDaily()); Eluna::Push(L, quest->IsDaily());
return 1; return 1;
} }
#endif #endif
int IsRepeatable(lua_State* L, Quest* quest) int IsRepeatable(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->IsRepeatable()); Eluna::Push(L, quest->IsRepeatable());
return 1; return 1;
} }
/* GETTERS */ /* GETTERS */
int GetId(lua_State* L, Quest* quest) int GetId(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetQuestId()); Eluna::Push(L, quest->GetQuestId());
return 1; return 1;
} }
int GetLevel(lua_State* L, Quest* quest) int GetLevel(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetQuestLevel()); Eluna::Push(L, quest->GetQuestLevel());
return 1; return 1;
} }
int GetMinLevel(lua_State* L, Quest* quest) int GetMinLevel(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetMinLevel()); Eluna::Push(L, quest->GetMinLevel());
return 1; return 1;
} }
int GetNextQuestId(lua_State* L, Quest* quest) int GetNextQuestId(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetNextQuestId()); Eluna::Push(L, quest->GetNextQuestId());
return 1; return 1;
} }
int GetPrevQuestId(lua_State* L, Quest* quest) int GetPrevQuestId(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetPrevQuestId()); Eluna::Push(L, quest->GetPrevQuestId());
return 1; return 1;
} }
int GetNextQuestInChain(lua_State* L, Quest* quest) int GetNextQuestInChain(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetNextQuestInChain()); Eluna::Push(L, quest->GetNextQuestInChain());
return 1; return 1;
} }
int GetFlags(lua_State* L, Quest* quest) int GetFlags(lua_State* L, Quest* quest)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, quest->GetQuestFlags()); Eluna::Push(L, quest->GetQuestFlags());
#else #else
sEluna->Push(L, quest->GetFlags()); Eluna::Push(L, quest->GetFlags());
#endif #endif
return 1; return 1;
} }
int GetType(lua_State* L, Quest* quest) int GetType(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetType()); Eluna::Push(L, quest->GetType());
return 1; return 1;
} }
/*int GetMaxLevel(lua_State* L, Quest* quest) /*int GetMaxLevel(lua_State* L, Quest* quest)
{ {
sEluna->Push(L, quest->GetMaxLevel()); Eluna::Push(L, quest->GetMaxLevel());
return 1; return 1;
}*/ }*/
}; };

View File

@@ -12,41 +12,41 @@ namespace LuaSpell
/* BOOLEAN */ /* BOOLEAN */
int IsAutoRepeat(lua_State* L, Spell* spell) int IsAutoRepeat(lua_State* L, Spell* spell)
{ {
sEluna->Push(L, spell->IsAutoRepeat()); Eluna::Push(L, spell->IsAutoRepeat());
return 1; return 1;
} }
/* GETTERS */ /* GETTERS */
int GetCaster(lua_State* L, Spell* spell) int GetCaster(lua_State* L, Spell* spell)
{ {
sEluna->Push(L, spell->GetCaster()); Eluna::Push(L, spell->GetCaster());
return 1; return 1;
} }
int GetCastTime(lua_State* L, Spell* spell) int GetCastTime(lua_State* L, Spell* spell)
{ {
sEluna->Push(L, spell->GetCastTime()); Eluna::Push(L, spell->GetCastTime());
return 1; return 1;
} }
int GetId(lua_State* L, Spell* spell) int GetId(lua_State* L, Spell* spell)
{ {
sEluna->Push(L, spell->m_spellInfo->Id); Eluna::Push(L, spell->m_spellInfo->Id);
return 1; return 1;
} }
int GetPowerCost(lua_State* L, Spell* spell) int GetPowerCost(lua_State* L, Spell* spell)
{ {
sEluna->Push(L, spell->GetPowerCost()); Eluna::Push(L, spell->GetPowerCost());
return 1; return 1;
} }
int GetDuration(lua_State* L, Spell* spell) int GetDuration(lua_State* L, Spell* spell)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, GetSpellDuration(spell->m_spellInfo)); Eluna::Push(L, GetSpellDuration(spell->m_spellInfo));
#else #else
sEluna->Push(L, spell->GetSpellInfo()->GetDuration()); Eluna::Push(L, spell->GetSpellInfo()->GetDuration());
#endif #endif
return 1; return 1;
} }
@@ -64,9 +64,9 @@ namespace LuaSpell
float x, y, z; float x, y, z;
spell->m_targets.GetDstPos()->GetPosition(x, y, z); spell->m_targets.GetDstPos()->GetPosition(x, y, z);
#endif #endif
sEluna->Push(L, x); Eluna::Push(L, x);
sEluna->Push(L, y); Eluna::Push(L, y);
sEluna->Push(L, z); Eluna::Push(L, z);
return 3; return 3;
} }
@@ -74,24 +74,24 @@ namespace LuaSpell
{ {
#ifdef MANGOS #ifdef MANGOS
if (GameObject* target = spell->m_targets.getGOTarget()) if (GameObject* target = spell->m_targets.getGOTarget())
sEluna->Push(sEluna->L, target); Eluna::Push(L, target);
else if (Item* target = spell->m_targets.getItemTarget()) 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())) 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()) else if (Unit* target = spell->m_targets.getUnitTarget())
sEluna->Push(sEluna->L, target); Eluna::Push(L, target);
#else #else
if (GameObject* target = spell->m_targets.GetGOTarget()) if (GameObject* target = spell->m_targets.GetGOTarget())
sEluna->Push(L, target); Eluna::Push(L, target);
else if (Item* target = spell->m_targets.GetItemTarget()) else if (Item* target = spell->m_targets.GetItemTarget())
sEluna->Push(L, target); Eluna::Push(L, target);
else if (Corpse* target = spell->m_targets.GetCorpseTarget()) else if (Corpse* target = spell->m_targets.GetCorpseTarget())
sEluna->Push(L, target); Eluna::Push(L, target);
else if (Unit* target = spell->m_targets.GetUnitTarget()) else if (Unit* target = spell->m_targets.GetUnitTarget())
sEluna->Push(L, target); Eluna::Push(L, target);
else if (WorldObject* target = spell->m_targets.GetObjectTarget()) else if (WorldObject* target = spell->m_targets.GetObjectTarget())
sEluna->Push(L, target); Eluna::Push(L, target);
#endif #endif
return 1; return 1;
} }
@@ -99,7 +99,7 @@ namespace LuaSpell
/* SETTERS */ /* SETTERS */
int SetAutoRepeat(lua_State* L, Spell* spell) int SetAutoRepeat(lua_State* L, Spell* spell)
{ {
bool repeat = sEluna->CHECKVAL<bool>(L, 2); bool repeat = Eluna::CHECKVAL<bool>(L, 2);
spell->SetAutoRepeat(repeat); spell->SetAutoRepeat(repeat);
return 0; return 0;
} }
@@ -107,7 +107,7 @@ namespace LuaSpell
/* OTHER */ /* OTHER */
int Cast(lua_State* L, Spell* spell) int Cast(lua_State* L, Spell* spell)
{ {
bool skipCheck = sEluna->CHECKVAL<bool>(L, 2); bool skipCheck = Eluna::CHECKVAL<bool>(L, 2);
spell->cast(skipCheck); spell->cast(skipCheck);
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -14,11 +14,11 @@ namespace LuaVehicle
/* BOOLEAN */ /* BOOLEAN */
int IsOnBoard(lua_State* L, Vehicle* vehicle) int IsOnBoard(lua_State* L, Vehicle* vehicle)
{ {
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2); Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, vehicle->HasOnBoard(passenger)); Eluna::Push(L, vehicle->HasOnBoard(passenger));
#else #else
sEluna->Push(L, passenger->IsOnVehicle(vehicle->GetBase())); Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
#endif #endif
return 1; return 1;
} }
@@ -27,9 +27,9 @@ namespace LuaVehicle
int GetOwner(lua_State* L, Vehicle* vehicle) int GetOwner(lua_State* L, Vehicle* vehicle)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, vehicle->GetOwner()); Eluna::Push(L, vehicle->GetOwner());
#else #else
sEluna->Push(L, vehicle->GetBase()); Eluna::Push(L, vehicle->GetBase());
#endif #endif
return 1; return 1;
} }
@@ -37,25 +37,25 @@ namespace LuaVehicle
int GetEntry(lua_State* L, Vehicle* vehicle) int GetEntry(lua_State* L, Vehicle* vehicle)
{ {
#ifdef MANGOS #ifdef MANGOS
sEluna->Push(L, vehicle->GetVehicleEntry()->m_ID); Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID);
#else #else
sEluna->Push(L, vehicle->GetVehicleInfo()->m_ID); Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID);
#endif #endif
return 1; return 1;
} }
int GetPassenger(lua_State* L, Vehicle* vehicle) int GetPassenger(lua_State* L, Vehicle* vehicle)
{ {
int8 seatId = sEluna->CHECKVAL<int8>(L, 2); int8 seatId = Eluna::CHECKVAL<int8>(L, 2);
sEluna->Push(L, vehicle->GetPassenger(seatId)); Eluna::Push(L, vehicle->GetPassenger(seatId));
return 1; return 1;
} }
/* OTHER */ /* OTHER */
int AddPassenger(lua_State* L, Vehicle* vehicle) int AddPassenger(lua_State* L, Vehicle* vehicle)
{ {
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2); Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
int8 seatId = sEluna->CHECKVAL<int8>(L, 3); int8 seatId = Eluna::CHECKVAL<int8>(L, 3);
#ifdef MANGOS #ifdef MANGOS
if (vehicle->CanBoard(passenger)) if (vehicle->CanBoard(passenger))
vehicle->Board(passenger, seatId); vehicle->Board(passenger, seatId);
@@ -67,7 +67,7 @@ namespace LuaVehicle
int RemovePassenger(lua_State* L, Vehicle* vehicle) int RemovePassenger(lua_State* L, Vehicle* vehicle)
{ {
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2); Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
#ifdef MANGOS #ifdef MANGOS
vehicle->UnBoard(passenger, false); vehicle->UnBoard(passenger, false);
#else #else

View File

@@ -12,15 +12,15 @@ namespace LuaWeather
/* GETTERS */ /* GETTERS */
int GetZoneId(lua_State* L, Weather* weather) int GetZoneId(lua_State* L, Weather* weather)
{ {
sEluna->Push(L, weather->GetZone()); Eluna::Push(L, weather->GetZone());
return 1; return 1;
} }
/* SETTERS */ /* SETTERS */
int SetWeather(lua_State* L, Weather* weather) int SetWeather(lua_State* L, Weather* weather)
{ {
uint32 weatherType = sEluna->CHECKVAL<uint32>(L, 2); uint32 weatherType = Eluna::CHECKVAL<uint32>(L, 2);
float grade = sEluna->CHECKVAL<float>(L, 3); float grade = Eluna::CHECKVAL<float>(L, 3);
weather->SetWeather((WeatherType)weatherType, grade); weather->SetWeather((WeatherType)weatherType, grade);
return 0; return 0;
@@ -28,7 +28,7 @@ namespace LuaWeather
int SendWeatherUpdateToPlayer(lua_State* L, Weather* weather) int SendWeatherUpdateToPlayer(lua_State* L, Weather* weather)
{ {
Player* player = sEluna->CHECKOBJ<Player>(L, 2); Player* player = Eluna::CHECKOBJ<Player>(L, 2);
weather->SendWeatherUpdateToPlayer(player); weather->SendWeatherUpdateToPlayer(player);
return 0; return 0;
@@ -37,13 +37,13 @@ namespace LuaWeather
/* OTHER */ /* OTHER */
int Regenerate(lua_State* L, Weather* weather) int Regenerate(lua_State* L, Weather* weather)
{ {
sEluna->Push(L, weather->ReGenerate()); Eluna::Push(L, weather->ReGenerate());
return 1; return 1;
} }
int UpdateWeather(lua_State* L, Weather* weather) int UpdateWeather(lua_State* L, Weather* weather)
{ {
sEluna->Push(L, weather->UpdateWeather()); Eluna::Push(L, weather->UpdateWeather());
return 1; return 1;
} }
}; };

View File

@@ -12,84 +12,84 @@ namespace LuaWorldObject
/* GETTERS */ /* GETTERS */
int GetName(lua_State* L, WorldObject* obj) int GetName(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetName()); Eluna::Push(L, obj->GetName());
return 1; return 1;
} }
int GetMap(lua_State* L, WorldObject* obj) int GetMap(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetMap()); Eluna::Push(L, obj->GetMap());
return 1; return 1;
} }
#if (!defined(TBC) && !defined(CLASSIC)) #if (!defined(TBC) && !defined(CLASSIC))
int GetPhaseMask(lua_State* L, WorldObject* obj) int GetPhaseMask(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetPhaseMask()); Eluna::Push(L, obj->GetPhaseMask());
return 1; return 1;
} }
#endif #endif
int GetInstanceId(lua_State* L, WorldObject* obj) int GetInstanceId(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetInstanceId()); Eluna::Push(L, obj->GetInstanceId());
return 1; return 1;
} }
int GetAreaId(lua_State* L, WorldObject* obj) int GetAreaId(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetAreaId()); Eluna::Push(L, obj->GetAreaId());
return 1; return 1;
} }
int GetZoneId(lua_State* L, WorldObject* obj) int GetZoneId(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetZoneId()); Eluna::Push(L, obj->GetZoneId());
return 1; return 1;
} }
int GetMapId(lua_State* L, WorldObject* obj) int GetMapId(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetMapId()); Eluna::Push(L, obj->GetMapId());
return 1; return 1;
} }
int GetX(lua_State* L, WorldObject* obj) int GetX(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetPositionX()); Eluna::Push(L, obj->GetPositionX());
return 1; return 1;
} }
int GetY(lua_State* L, WorldObject* obj) int GetY(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetPositionY()); Eluna::Push(L, obj->GetPositionY());
return 1; return 1;
} }
int GetZ(lua_State* L, WorldObject* obj) int GetZ(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetPositionZ()); Eluna::Push(L, obj->GetPositionZ());
return 1; return 1;
} }
int GetO(lua_State* L, WorldObject* obj) int GetO(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetOrientation()); Eluna::Push(L, obj->GetOrientation());
return 1; return 1;
} }
int GetLocation(lua_State* L, WorldObject* obj) int GetLocation(lua_State* L, WorldObject* obj)
{ {
sEluna->Push(L, obj->GetPositionX()); Eluna::Push(L, obj->GetPositionX());
sEluna->Push(L, obj->GetPositionY()); Eluna::Push(L, obj->GetPositionY());
sEluna->Push(L, obj->GetPositionZ()); Eluna::Push(L, obj->GetPositionZ());
sEluna->Push(L, obj->GetOrientation()); Eluna::Push(L, obj->GetOrientation());
return 4; return 4;
} }
int GetNearestPlayer(lua_State* L, WorldObject* obj) 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; Unit* target = NULL;
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER); Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER);
@@ -101,14 +101,14 @@ namespace LuaWorldObject
obj->VisitNearbyObject(range, searcher); obj->VisitNearbyObject(range, searcher);
#endif #endif
sEluna->Push(L, target); Eluna::Push(L, target);
return 1; return 1;
} }
int GetNearestGameObject(lua_State* L, WorldObject* obj) int GetNearestGameObject(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);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0); uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
GameObject* target = NULL; GameObject* target = NULL;
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry); Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry);
@@ -120,14 +120,14 @@ namespace LuaWorldObject
obj->VisitNearbyObject(range, searcher); obj->VisitNearbyObject(range, searcher);
#endif #endif
sEluna->Push(L, target); Eluna::Push(L, target);
return 1; return 1;
} }
int GetNearestCreature(lua_State* L, WorldObject* obj) int GetNearestCreature(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);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0); uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
Creature* target = NULL; Creature* target = NULL;
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry); Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry);
@@ -139,13 +139,13 @@ namespace LuaWorldObject
obj->VisitNearbyObject(range, searcher); obj->VisitNearbyObject(range, searcher);
#endif #endif
sEluna->Push(L, target); Eluna::Push(L, target);
return 1; return 1;
} }
int GetPlayersInRange(lua_State* L, WorldObject* obj) 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; std::list<Player*> list;
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER); 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) for (std::list<Player*>::const_iterator it = list.begin(); it != list.end(); ++it)
{ {
sEluna->Push(L, ++i); Eluna::Push(L, ++i);
sEluna->Push(L, *it); Eluna::Push(L, *it);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
@@ -174,8 +174,8 @@ namespace LuaWorldObject
int GetCreaturesInRange(lua_State* L, WorldObject* obj) int GetCreaturesInRange(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);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0); uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
std::list<Creature*> list; std::list<Creature*> list;
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry); 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) for (std::list<Creature*>::const_iterator it = list.begin(); it != list.end(); ++it)
{ {
sEluna->Push(L, ++i); Eluna::Push(L, ++i);
sEluna->Push(L, *it); Eluna::Push(L, *it);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
@@ -204,8 +204,8 @@ namespace LuaWorldObject
int GetGameObjectsInRange(lua_State* L, WorldObject* obj) int GetGameObjectsInRange(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);
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0); uint32 entry = Eluna::CHECKVAL<uint32>(L, 3, 0);
std::list<GameObject*> list; std::list<GameObject*> list;
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry); 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) for (std::list<GameObject*>::const_iterator it = list.begin(); it != list.end(); ++it)
{ {
sEluna->Push(L, ++i); Eluna::Push(L, ++i);
sEluna->Push(L, *it); Eluna::Push(L, *it);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
@@ -234,11 +234,11 @@ namespace LuaWorldObject
int GetNearObject(lua_State* L, WorldObject* obj) int GetNearObject(lua_State* L, WorldObject* obj)
{ {
bool nearest = sEluna->CHECKVAL<bool>(L, 2, true); bool nearest = Eluna::CHECKVAL<bool>(L, 2, true);
float range = sEluna->CHECKVAL<float>(L, 3, SIZE_OF_GRIDS); float range = Eluna::CHECKVAL<float>(L, 3, SIZE_OF_GRIDS);
uint16 type = sEluna->CHECKVAL<uint16>(L, 4, 0); // TypeMask uint16 type = Eluna::CHECKVAL<uint16>(L, 4, 0); // TypeMask
uint32 entry = sEluna->CHECKVAL<uint32>(L, 5, 0); uint32 entry = Eluna::CHECKVAL<uint32>(L, 5, 0);
uint32 hostile = sEluna->CHECKVAL<uint32>(L, 6, 0); // 0 none, 1 hostile, 2 friendly uint32 hostile = Eluna::CHECKVAL<uint32>(L, 6, 0); // 0 none, 1 hostile, 2 friendly
float x, y, z; float x, y, z;
obj->GetPosition(x, y, z); obj->GetPosition(x, y, z);
@@ -254,7 +254,7 @@ namespace LuaWorldObject
obj->VisitNearbyObject(range, searcher); obj->VisitNearbyObject(range, searcher);
#endif #endif
sEluna->Push(L, target); Eluna::Push(L, target);
return 1; return 1;
} }
else else
@@ -274,8 +274,8 @@ namespace LuaWorldObject
for (std::list<WorldObject*>::const_iterator it = list.begin(); it != list.end(); ++it) for (std::list<WorldObject*>::const_iterator it = list.begin(); it != list.end(); ++it)
{ {
sEluna->Push(L, ++i); Eluna::Push(L, ++i);
sEluna->Push(L, *it); Eluna::Push(L, *it);
lua_settable(L, tbl); lua_settable(L, tbl);
} }
@@ -288,31 +288,31 @@ namespace LuaWorldObject
int GetWorldObject(lua_State* L, WorldObject* obj) int GetWorldObject(lua_State* L, WorldObject* obj)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2); uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
#ifdef MANGOS #ifdef MANGOS
switch (GUID_HIPART(guid)) 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_TRANSPORT:
case HIGHGUID_MO_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)) #if (!defined(TBC) && !defined(CLASSIC))
case HIGHGUID_VEHICLE: case HIGHGUID_VEHICLE:
#endif #endif
case HIGHGUID_UNIT: 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 #else
switch (GUID_HIPART(guid)) 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_TRANSPORT:
case HIGHGUID_MO_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_VEHICLE:
case HIGHGUID_UNIT: sEluna->Push(L, sObjectAccessor->GetCreature(*obj, ObjectGuid(guid))); break; case HIGHGUID_UNIT: Eluna::Push(L, sObjectAccessor->GetCreature(*obj, ObjectGuid(guid))); break;
case HIGHGUID_PET: sEluna->Push(L, sObjectAccessor->GetPet(*obj, ObjectGuid(guid))); break; case HIGHGUID_PET: Eluna::Push(L, sObjectAccessor->GetPet(*obj, ObjectGuid(guid))); break;
} }
#endif #endif
return 1; return 1;
@@ -320,44 +320,44 @@ namespace LuaWorldObject
int GetDistance(lua_State* L, WorldObject* obj) 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()) if (target && target->IsInWorld())
sEluna->Push(L, obj->GetDistance(target)); Eluna::Push(L, obj->GetDistance(target));
else else
{ {
float X = sEluna->CHECKVAL<float>(L, 2); float X = Eluna::CHECKVAL<float>(L, 2);
float Y = sEluna->CHECKVAL<float>(L, 3); float Y = Eluna::CHECKVAL<float>(L, 3);
float Z = sEluna->CHECKVAL<float>(L, 4); float Z = Eluna::CHECKVAL<float>(L, 4);
sEluna->Push(L, obj->GetDistance(X, Y, Z)); Eluna::Push(L, obj->GetDistance(X, Y, Z));
} }
return 1; return 1;
} }
int GetRelativePoint(lua_State* L, WorldObject* obj) int GetRelativePoint(lua_State* L, WorldObject* obj)
{ {
float dist = sEluna->CHECKVAL<float>(L, 2); float dist = Eluna::CHECKVAL<float>(L, 2);
float rad = sEluna->CHECKVAL<float>(L, 3); float rad = Eluna::CHECKVAL<float>(L, 3);
float x, y, z; float x, y, z;
obj->GetClosePoint(x, y, z, 0.0f, dist, rad); obj->GetClosePoint(x, y, z, 0.0f, dist, rad);
sEluna->Push(L, x); Eluna::Push(L, x);
sEluna->Push(L, y); Eluna::Push(L, y);
sEluna->Push(L, z); Eluna::Push(L, z);
return 3; return 3;
} }
int GetAngle(lua_State* L, WorldObject* obj) 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()) if (target && target->IsInWorld())
sEluna->Push(L, obj->GetAngle(target)); Eluna::Push(L, obj->GetAngle(target));
else else
{ {
float x = sEluna->CHECKVAL<float>(L, 2); float x = Eluna::CHECKVAL<float>(L, 2);
float y = sEluna->CHECKVAL<float>(L, 3); float y = Eluna::CHECKVAL<float>(L, 3);
sEluna->Push(L, obj->GetAngle(x, y)); Eluna::Push(L, obj->GetAngle(x, y));
} }
return 1; return 1;
} }
@@ -365,36 +365,36 @@ namespace LuaWorldObject
/* OTHER */ /* OTHER */
int SendPacket(lua_State* L, WorldObject* obj) 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); obj->SendMessageToSet(data, true);
return 0; return 0;
} }
int SummonGameObject(lua_State* L, WorldObject* obj) int SummonGameObject(lua_State* L, WorldObject* obj)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2); uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
float x = sEluna->CHECKVAL<float>(L, 3); float x = Eluna::CHECKVAL<float>(L, 3);
float y = sEluna->CHECKVAL<float>(L, 4); float y = Eluna::CHECKVAL<float>(L, 4);
float z = sEluna->CHECKVAL<float>(L, 5); float z = Eluna::CHECKVAL<float>(L, 5);
float o = sEluna->CHECKVAL<float>(L, 6); float o = Eluna::CHECKVAL<float>(L, 6);
uint32 respawnDelay = sEluna->CHECKVAL<uint32>(L, 7, 30); uint32 respawnDelay = Eluna::CHECKVAL<uint32>(L, 7, 30);
#ifdef MANGOS #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 #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 #endif
return 1; return 1;
} }
int SpawnCreature(lua_State* L, WorldObject* obj) int SpawnCreature(lua_State* L, WorldObject* obj)
{ {
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2); uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
float x = sEluna->CHECKVAL<float>(L, 3); float x = Eluna::CHECKVAL<float>(L, 3);
float y = sEluna->CHECKVAL<float>(L, 4); float y = Eluna::CHECKVAL<float>(L, 4);
float z = sEluna->CHECKVAL<float>(L, 5); float z = Eluna::CHECKVAL<float>(L, 5);
float o = sEluna->CHECKVAL<float>(L, 6); float o = Eluna::CHECKVAL<float>(L, 6);
uint32 spawnType = sEluna->CHECKVAL<uint32>(L, 7, 8); uint32 spawnType = Eluna::CHECKVAL<uint32>(L, 7, 8);
uint32 despawnTimer = sEluna->CHECKVAL<uint32>(L, 8, 0); uint32 despawnTimer = Eluna::CHECKVAL<uint32>(L, 8, 0);
TempSummonType type; TempSummonType type;
switch (spawnType) switch (spawnType)
@@ -423,7 +423,7 @@ namespace LuaWorldObject
default: default:
return luaL_argerror(L, 7, "valid SpawnType expected"); 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; return 1;
} }
}; };

View File

@@ -12,21 +12,21 @@ namespace LuaPacket
// GetOpcode() // GetOpcode()
int GetOpcode(lua_State* L, WorldPacket* packet) int GetOpcode(lua_State* L, WorldPacket* packet)
{ {
sEluna->Push(L, packet->GetOpcode()); Eluna::Push(L, packet->GetOpcode());
return 1; return 1;
} }
// GetSize() // GetSize()
int GetSize(lua_State* L, WorldPacket* packet) int GetSize(lua_State* L, WorldPacket* packet)
{ {
sEluna->Push(L, packet->size()); Eluna::Push(L, packet->size());
return 1; return 1;
} }
// SetOpcode(opcode) // SetOpcode(opcode)
int SetOpcode(lua_State* L, WorldPacket* packet) 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) if (opcode >= NUM_MSG_TYPES)
return luaL_argerror(L, 2, "valid opcode expected"); return luaL_argerror(L, 2, "valid opcode expected");
packet->SetOpcode((Opcodes)opcode); packet->SetOpcode((Opcodes)opcode);
@@ -38,7 +38,7 @@ namespace LuaPacket
{ {
int8 byte; int8 byte;
(*packet) >> byte; (*packet) >> byte;
sEluna->Push(L, byte); Eluna::Push(L, byte);
return 1; return 1;
} }
@@ -47,7 +47,7 @@ namespace LuaPacket
{ {
uint8 byte; uint8 byte;
(*packet) >> byte; (*packet) >> byte;
sEluna->Push(L, byte); Eluna::Push(L, byte);
return 1; return 1;
} }
@@ -56,7 +56,7 @@ namespace LuaPacket
{ {
int16 _short; int16 _short;
(*packet) >> _short; (*packet) >> _short;
sEluna->Push(L, _short); Eluna::Push(L, _short);
return 1; return 1;
} }
@@ -65,7 +65,7 @@ namespace LuaPacket
{ {
uint16 _ushort; uint16 _ushort;
(*packet) >> _ushort; (*packet) >> _ushort;
sEluna->Push(L, _ushort); Eluna::Push(L, _ushort);
return 1; return 1;
} }
@@ -74,7 +74,7 @@ namespace LuaPacket
{ {
int32 _long; int32 _long;
(*packet) >> _long; (*packet) >> _long;
sEluna->Push(L, _long); Eluna::Push(L, _long);
return 1; return 1;
} }
@@ -83,7 +83,7 @@ namespace LuaPacket
{ {
uint32 _ulong; uint32 _ulong;
(*packet) >> _ulong; (*packet) >> _ulong;
sEluna->Push(L, _ulong); Eluna::Push(L, _ulong);
return 1; return 1;
} }
@@ -92,7 +92,7 @@ namespace LuaPacket
{ {
float _val; float _val;
(*packet) >> _val; (*packet) >> _val;
sEluna->Push(L, _val); Eluna::Push(L, _val);
return 1; return 1;
} }
@@ -101,7 +101,7 @@ namespace LuaPacket
{ {
double _val; double _val;
(*packet) >> _val; (*packet) >> _val;
sEluna->Push(L, _val); Eluna::Push(L, _val);
return 1; return 1;
} }
@@ -110,7 +110,7 @@ namespace LuaPacket
{ {
uint64 guid; uint64 guid;
(*packet) >> guid; (*packet) >> guid;
sEluna->Push(L, guid); Eluna::Push(L, guid);
return 1; return 1;
} }
@@ -119,14 +119,14 @@ namespace LuaPacket
{ {
std::string _val; std::string _val;
(*packet) >> _val; (*packet) >> _val;
sEluna->Push(L, _val); Eluna::Push(L, _val);
return 1; return 1;
} }
// WriteGUID(guid) // WriteGUID(guid)
int WriteGUID(lua_State* L, WorldPacket* packet) int WriteGUID(lua_State* L, WorldPacket* packet)
{ {
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2); uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
(*packet) << guid; (*packet) << guid;
return 0; return 0;
} }
@@ -134,7 +134,7 @@ namespace LuaPacket
// WriteString(string) // WriteString(string)
int WriteString(lua_State* L, WorldPacket* packet) 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; (*packet) << _val;
return 0; return 0;
} }
@@ -142,7 +142,7 @@ namespace LuaPacket
// WriteBye(byte) // WriteBye(byte)
int WriteByte(lua_State* L, WorldPacket* packet) int WriteByte(lua_State* L, WorldPacket* packet)
{ {
int8 byte = sEluna->CHECKVAL<int8>(L, 2); int8 byte = Eluna::CHECKVAL<int8>(L, 2);
(*packet) << byte; (*packet) << byte;
return 0; return 0;
} }
@@ -150,7 +150,7 @@ namespace LuaPacket
// WriteUByte(byte) // WriteUByte(byte)
int WriteUByte(lua_State* L, WorldPacket* packet) int WriteUByte(lua_State* L, WorldPacket* packet)
{ {
uint8 byte = sEluna->CHECKVAL<uint8>(L, 2); uint8 byte = Eluna::CHECKVAL<uint8>(L, 2);
(*packet) << byte; (*packet) << byte;
return 0; return 0;
} }
@@ -158,7 +158,7 @@ namespace LuaPacket
// WriteUShort(short) // WriteUShort(short)
int WriteUShort(lua_State* L, WorldPacket* packet) int WriteUShort(lua_State* L, WorldPacket* packet)
{ {
uint16 _ushort = sEluna->CHECKVAL<uint16>(L, 2); uint16 _ushort = Eluna::CHECKVAL<uint16>(L, 2);
(*packet) << _ushort; (*packet) << _ushort;
return 0; return 0;
} }
@@ -166,7 +166,7 @@ namespace LuaPacket
// WriteShort(short) // WriteShort(short)
int WriteShort(lua_State* L, WorldPacket* packet) int WriteShort(lua_State* L, WorldPacket* packet)
{ {
int16 _short = sEluna->CHECKVAL<int16>(L, 2); int16 _short = Eluna::CHECKVAL<int16>(L, 2);
(*packet) << _short; (*packet) << _short;
return 0; return 0;
} }
@@ -174,7 +174,7 @@ namespace LuaPacket
// WriteLong(long) // WriteLong(long)
int WriteLong(lua_State* L, WorldPacket* packet) int WriteLong(lua_State* L, WorldPacket* packet)
{ {
int32 _long = sEluna->CHECKVAL<int32>(L, 2); int32 _long = Eluna::CHECKVAL<int32>(L, 2);
(*packet) << _long; (*packet) << _long;
return 0; return 0;
} }
@@ -182,7 +182,7 @@ namespace LuaPacket
// WriteULong(long) // WriteULong(long)
int WriteULong(lua_State* L, WorldPacket* packet) int WriteULong(lua_State* L, WorldPacket* packet)
{ {
uint32 _ulong = sEluna->CHECKVAL<uint32>(L, 2); uint32 _ulong = Eluna::CHECKVAL<uint32>(L, 2);
(*packet) << _ulong; (*packet) << _ulong;
return 0; return 0;
} }
@@ -190,7 +190,7 @@ namespace LuaPacket
// WriteFloat(float) // WriteFloat(float)
int WriteFloat(lua_State* L, WorldPacket* packet) int WriteFloat(lua_State* L, WorldPacket* packet)
{ {
float _val = sEluna->CHECKVAL<float>(L, 2); float _val = Eluna::CHECKVAL<float>(L, 2);
(*packet) << _val; (*packet) << _val;
return 0; return 0;
} }
@@ -198,7 +198,7 @@ namespace LuaPacket
// WriteDouble(double) // WriteDouble(double)
int WriteDouble(lua_State* L, WorldPacket* packet) int WriteDouble(lua_State* L, WorldPacket* packet)
{ {
double _val = sEluna->CHECKVAL<double>(L, 2); double _val = Eluna::CHECKVAL<double>(L, 2);
(*packet) << _val; (*packet) << _val;
return 0; return 0;
} }