Skip to content

Commit

Permalink
Removal of luaState from most helper functions (#459)
Browse files Browse the repository at this point in the history
* Removal of luaState from most helper functions

We can get the luaState from the Eluna object, so no need to do this in all wrappers

Some more Mangos header file cleanup. Probably more to do, but will have to be tested when Mangos can be updated
  • Loading branch information
Foereaper authored Mar 3, 2024
1 parent 96e31de commit a1832a8
Show file tree
Hide file tree
Showing 82 changed files with 3,565 additions and 3,545 deletions.
8 changes: 4 additions & 4 deletions CMangos/AuraMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace LuaAura
*/
int SetDuration(Eluna* E, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(E->L, 2);
int32 duration = E->CHECKVAL<int32>(2);
aura->GetHolder()->SetAuraDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
Expand All @@ -141,7 +141,7 @@ namespace LuaAura
*/
int SetMaxDuration(Eluna* E, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(E->L, 2);
int32 duration = E->CHECKVAL<int32>(2);
aura->GetHolder()->SetAuraMaxDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
Expand All @@ -161,7 +161,7 @@ namespace LuaAura
*/
int SetStackAmount(Eluna* E, Aura* aura)
{
uint8 amount = Eluna::CHECKVAL<uint8>(E->L, 2);
uint8 amount = E->CHECKVAL<uint8>(2);
#ifndef CATA
aura->GetHolder()->SetStackAmount(amount, aura->GetTarget());
#else
Expand All @@ -176,7 +176,7 @@ namespace LuaAura
int Remove(Eluna* E, Aura* aura)
{
aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL);
Eluna::CHECKOBJ<ElunaObject>(E->L, 1)->Invalidate();
E->CHECKOBJ<ElunaObject>(1)->Invalidate();
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions CMangos/BattleGroundMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace LuaBattleGround
*/
int GetAlivePlayersCountByTeam(Eluna* E, BattleGround* bg)
{
uint32 team = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 team = E->CHECKVAL<uint32>(2);

E->Push(bg->GetAlivePlayersCountByTeam((Team)team));
return 1;
Expand All @@ -58,7 +58,7 @@ namespace LuaBattleGround
*/
int GetBonusHonorFromKillCount(Eluna* E, BattleGround* bg)
{
uint32 kills = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 kills = E->CHECKVAL<uint32>(2);

E->Push(bg->GetBonusHonorFromKill(kills));
return 1;
Expand Down Expand Up @@ -94,7 +94,7 @@ namespace LuaBattleGround
*/
int GetFreeSlotsForTeam(Eluna* E, BattleGround* bg)
{
uint32 team = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 team = E->CHECKVAL<uint32>(2);

E->Push(bg->GetFreeSlotsForTeam((Team)team));
return 1;
Expand Down
92 changes: 46 additions & 46 deletions CMangos/CreatureMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace LuaCreature
*/
int CanCompleteQuest(Eluna* E, Creature* creature)
{
uint32 quest_id = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 quest_id = E->CHECKVAL<uint32>(2);

E->Push(creature->HasInvolvedQuest(quest_id));
return 1;
Expand All @@ -64,7 +64,7 @@ namespace LuaCreature
*/
int IsTargetableForAttack(Eluna* E, Creature* creature)
{
bool mustBeDead = Eluna::CHECKVAL<bool>(E->L, 2, false);
bool mustBeDead = E->CHECKVAL<bool>(2, false);

#ifndef CATA
E->Push(creature->IsTargetableForAttack(mustBeDead));
Expand All @@ -85,9 +85,9 @@ namespace LuaCreature
*/
int CanAssistTo(Eluna* E, Creature* creature)
{
Unit* u = Eluna::CHECKOBJ<Unit>(E->L, 2);
Unit* enemy = Eluna::CHECKOBJ<Unit>(E->L, 3);
bool checkfaction = Eluna::CHECKVAL<bool>(E->L, 4, true);
Unit* u = E->CHECKOBJ<Unit>(2);
Unit* enemy = E->CHECKOBJ<Unit>(3);
bool checkfaction = E->CHECKVAL<bool>(4, true);

E->Push(creature->CanAssistTo(u, enemy, checkfaction));
return 1;
Expand All @@ -113,7 +113,7 @@ namespace LuaCreature
*/
int IsTappedBy(Eluna* E, Creature* creature)
{
Player* player = Eluna::CHECKOBJ<Player>(E->L, 2);
Player* player = E->CHECKOBJ<Player>(2);

E->Push(creature->IsTappedBy(player));
return 1;
Expand Down Expand Up @@ -248,7 +248,7 @@ namespace LuaCreature
*/
int HasCategoryCooldown(Eluna* E, Creature* creature)
{
uint32 spell = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 spell = E->CHECKVAL<uint32>(2);

E->Push(creature->HasCategoryCooldown(spell));
return 1;
Expand All @@ -263,7 +263,7 @@ namespace LuaCreature
*/
int HasSpell(Eluna* E, Creature* creature)
{
uint32 id = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 id = E->CHECKVAL<uint32>(2);

E->Push(creature->HasSpell(id));
return 1;
Expand All @@ -278,7 +278,7 @@ namespace LuaCreature
*/
int HasQuest(Eluna* E, Creature* creature)
{
uint32 questId = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 questId = E->CHECKVAL<uint32>(2);

E->Push(creature->HasQuest(questId));
return 1;
Expand All @@ -293,7 +293,7 @@ namespace LuaCreature
*/
int HasSpellCooldown(Eluna* E, Creature* creature)
{
uint32 spellId = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 spellId = E->CHECKVAL<uint32>(2);

E->Push(creature->HasSpellCooldown(spellId));
return 1;
Expand Down Expand Up @@ -367,7 +367,7 @@ namespace LuaCreature
*/
int GetAggroRange(Eluna* E, Creature* creature)
{
Unit* target = Eluna::CHECKOBJ<Unit>(E->L, 2);
Unit* target = E->CHECKOBJ<Unit>(2);

float AttackDist = creature->GetAttackDistance(target);
float ThreatRadius = sWorld.getConfig(CONFIG_FLOAT_THREAT_RADIUS);
Expand All @@ -386,7 +386,7 @@ namespace LuaCreature
*/
int GetAttackDistance(Eluna* E, Creature* creature)
{
Unit* target = Eluna::CHECKOBJ<Unit>(E->L, 2);
Unit* target = E->CHECKOBJ<Unit>(2);

E->Push(creature->GetAttackDistance(target));
return 1;
Expand Down Expand Up @@ -466,7 +466,7 @@ namespace LuaCreature
*/
int GetCreatureSpellCooldownDelay(Eluna* E, Creature* creature)
{
uint32 spell = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 spell = E->CHECKVAL<uint32>(2);

E->Push(creature->GetCreatureSpellCooldownDelay(spell));
return 1;
Expand Down Expand Up @@ -515,10 +515,10 @@ namespace LuaCreature
*/
int SetHomePosition(Eluna* E, Creature* creature)
{
float x = Eluna::CHECKVAL<float>(E->L, 2);
float y = Eluna::CHECKVAL<float>(E->L, 3);
float z = Eluna::CHECKVAL<float>(E->L, 4);
float o = Eluna::CHECKVAL<float>(E->L, 5);
float x = E->CHECKVAL<float>(2);
float y = E->CHECKVAL<float>(3);
float z = E->CHECKVAL<float>(4);
float o = E->CHECKVAL<float>(5);

creature->SetRespawnCoord(x, y, z, o);
return 0;
Expand Down Expand Up @@ -561,11 +561,11 @@ namespace LuaCreature
*/
int GetAITarget(Eluna* E, Creature* creature)
{
uint32 targetType = Eluna::CHECKVAL<uint32>(E->L, 2);
bool playerOnly = Eluna::CHECKVAL<bool>(E->L, 3, false);
uint32 position = Eluna::CHECKVAL<uint32>(E->L, 4, 0);
float dist = Eluna::CHECKVAL<float>(E->L, 5, 0.0f);
int32 aura = Eluna::CHECKVAL<int32>(E->L, 6, 0);
uint32 targetType = E->CHECKVAL<uint32>(2);
bool playerOnly = E->CHECKVAL<bool>(3, false);
uint32 position = E->CHECKVAL<uint32>(4, 0);
float dist = E->CHECKVAL<float>(5, 0.0f);
int32 aura = E->CHECKVAL<int32>(6, 0);

ThreatList const& threatlist = creature->getThreatManager().getThreatList();

Expand Down Expand Up @@ -736,7 +736,7 @@ namespace LuaCreature
*/
int SetNPCFlags(Eluna* E, Creature* creature)
{
uint32 flags = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 flags = E->CHECKVAL<uint32>(2);

creature->SetUInt32Value(UNIT_NPC_FLAGS, flags);
return 0;
Expand All @@ -749,7 +749,7 @@ namespace LuaCreature
*/
int SetDisableGravity(Eluna* E, Creature* creature)
{
bool disable = Eluna::CHECKVAL<bool>(E->L, 2);
bool disable = E->CHECKVAL<bool>(2);

creature->SetLevitate(disable);
return 0;
Expand All @@ -762,7 +762,7 @@ namespace LuaCreature
*/
int SetDeathState(Eluna* E, Creature* creature)
{
int32 state = Eluna::CHECKVAL<int32>(E->L, 2);
int32 state = E->CHECKVAL<int32>(2);

creature->SetDeathState((DeathState)state);
return 0;
Expand All @@ -775,7 +775,7 @@ namespace LuaCreature
*/
int SetWalk(Eluna* E, Creature* creature) // TODO: Move same to Player ?
{
bool enable = Eluna::CHECKVAL<bool>(E->L, 2, true);
bool enable = E->CHECKVAL<bool>(2, true);

creature->SetWalk(enable);
return 0;
Expand All @@ -790,9 +790,9 @@ namespace LuaCreature
*/
int SetEquipmentSlots(Eluna* E, Creature* creature)
{
uint32 main_hand = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 off_hand = Eluna::CHECKVAL<uint32>(E->L, 3);
uint32 ranged = Eluna::CHECKVAL<uint32>(E->L, 4);
uint32 main_hand = E->CHECKVAL<uint32>(2);
uint32 off_hand = E->CHECKVAL<uint32>(3);
uint32 ranged = E->CHECKVAL<uint32>(4);

creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, main_hand);
creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, off_hand);
Expand All @@ -807,7 +807,7 @@ namespace LuaCreature
*/
int SetAggroEnabled(Eluna* E, Creature* creature)
{
bool allow = Eluna::CHECKVAL<bool>(E->L, 2, true);
bool allow = E->CHECKVAL<bool>(2, true);

if (allow)
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
Expand All @@ -823,7 +823,7 @@ namespace LuaCreature
*/
int SetDisableReputationGain(Eluna* E, Creature* creature)
{
bool disable = Eluna::CHECKVAL<bool>(E->L, 2, true);
bool disable = E->CHECKVAL<bool>(2, true);

creature->SetNoReputation(disable);
return 0;
Expand All @@ -849,7 +849,7 @@ namespace LuaCreature
*/
int SetWanderRadius(Eluna* E, Creature* creature)
{
float dist = Eluna::CHECKVAL<float>(E->L, 2);
float dist = E->CHECKVAL<float>(2);

creature->SetRespawnRadius(dist);
return 0;
Expand All @@ -862,7 +862,7 @@ namespace LuaCreature
*/
int SetRespawnDelay(Eluna* E, Creature* creature)
{
uint32 delay = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 delay = E->CHECKVAL<uint32>(2);

creature->SetRespawnDelay(delay);
return 0;
Expand All @@ -875,7 +875,7 @@ namespace LuaCreature
*/
int SetDefaultMovementType(Eluna* E, Creature* creature)
{
int32 type = Eluna::CHECKVAL<int32>(E->L, 2);
int32 type = E->CHECKVAL<int32>(2);

creature->SetDefaultMovementType((MovementGeneratorType)type);
return 0;
Expand All @@ -888,7 +888,7 @@ namespace LuaCreature
*/
int SetNoSearchAssistance(Eluna* E, Creature* creature)
{
bool val = Eluna::CHECKVAL<bool>(E->L, 2, true);
bool val = E->CHECKVAL<bool>(2, true);

creature->SetNoSearchAssistance(val);
return 0;
Expand All @@ -901,7 +901,7 @@ namespace LuaCreature
*/
int SetNoCallAssistance(Eluna* E, Creature* creature)
{
bool val = Eluna::CHECKVAL<bool>(E->L, 2, true);
bool val = E->CHECKVAL<bool>(2, true);

creature->SetNoCallAssistance(val);
return 0;
Expand All @@ -914,7 +914,7 @@ namespace LuaCreature
*/
int SetHover(Eluna* E, Creature* creature)
{
bool enable = Eluna::CHECKVAL<bool>(E->L, 2, true);
bool enable = E->CHECKVAL<bool>(2, true);

// Copy paste from Aura::HandleAuraHover
// TODO: implement core side properly
Expand All @@ -936,7 +936,7 @@ namespace LuaCreature
*/
int DespawnOrUnsummon(Eluna* E, Creature* creature)
{
uint32 msTimeToDespawn = Eluna::CHECKVAL<uint32>(E->L, 2, 0);
uint32 msTimeToDespawn = E->CHECKVAL<uint32>(2, 0);

creature->ForcedDespawn(msTimeToDespawn);
return 0;
Expand Down Expand Up @@ -985,7 +985,7 @@ namespace LuaCreature
*/
int CallForHelp(Eluna* E, Creature* creature)
{
float radius = Eluna::CHECKVAL<float>(E->L, 2);
float radius = E->CHECKVAL<float>(2);

creature->CallForHelp(radius);
return 0;
Expand All @@ -1007,7 +1007,7 @@ namespace LuaCreature
*/
int AttackStart(Eluna* E, Creature* creature)
{
Unit* target = Eluna::CHECKOBJ<Unit>(E->L, 2);
Unit* target = E->CHECKOBJ<Unit>(2);

creature->AI()->AttackStart(target);
return 0;
Expand Down Expand Up @@ -1041,8 +1041,8 @@ namespace LuaCreature
*/
int UpdateEntry(Eluna* E, Creature* creature)
{
uint32 entry = Eluna::CHECKVAL<uint32>(E->L, 2);
uint32 dataGuidLow = Eluna::CHECKVAL<uint32>(E->L, 3, 0);
uint32 entry = E->CHECKVAL<uint32>(2);
uint32 dataGuidLow = E->CHECKVAL<uint32>(3, 0);

#ifndef CATA
creature->UpdateEntry(entry, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL);
Expand Down Expand Up @@ -1140,11 +1140,11 @@ namespace LuaCreature
*/
int AddThreat(Eluna* E, Creature* creature)
{
Unit* victim = Eluna::CHECKOBJ<Unit>(E->L, 2);
float threat = Eluna::CHECKVAL<float>(E->L, 3, true);
uint32 spell = Eluna::CHECKVAL<uint32>(E->L, 4, 0);
Unit* victim = E->CHECKOBJ<Unit>(2);
float threat = E->CHECKVAL<float>(3, true);
uint32 spell = E->CHECKVAL<uint32>(4, 0);

uint32 schoolMask = Eluna::CHECKVAL<uint32>(E->L, 5, 0);
uint32 schoolMask = E->CHECKVAL<uint32>(5, 0);
SpellEntry const* spellEntry = GetSpellStore()->LookupEntry<SpellEntry>(spell);
creature->AddThreat(victim, threat, false, (SpellSchoolMask)schoolMask, spellEntry);

Expand Down
Loading

0 comments on commit a1832a8

Please sign in to comment.