Skip to content

Commit

Permalink
Updates for VMaNGOS to multistate
Browse files Browse the repository at this point in the history
VMaNGOS doesn't use Boost libraries so must use std::filesystem when its VMaNGOS.
  • Loading branch information
Niam5 committed Feb 25, 2024
1 parent 890332a commit 75f101d
Show file tree
Hide file tree
Showing 21 changed files with 2,685 additions and 3,578 deletions.
4 changes: 2 additions & 2 deletions ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct ElunaCreatureAI : CreatureAI
void EnterCombat(Unit* target) override
{
#ifndef CMANGOS
if (!sEluna->EnterCombat(me, target))
if (!me->GetEluna()->EnterCombat(me, target))
ScriptedAI::EnterCombat(target);
#else
if (!me->GetEluna()->EnterCombat(me, target))
Expand Down Expand Up @@ -248,7 +248,7 @@ struct ElunaCreatureAI : CreatureAI
void JustRespawned() override
{
#ifndef CMANGOS
if (!sEluna->JustRespawned(me))
if (!me->GetEluna()->JustRespawned(me))
ScriptedAI::JustRespawned();
#else
if (!me->GetEluna()->JustRespawned(me))
Expand Down
17 changes: 11 additions & 6 deletions ElunaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
#include <filesystem>
#include <fstream>
#include <sstream>
#ifndef VMANGOS
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#else
namespace fs = std::filesystem;
#endif

#ifdef TRINITY
#include "MapManager.h"
Expand Down Expand Up @@ -96,18 +101,18 @@ void ElunaLoader::ReadFiles(std::string path)
lua_State* L = luaL_newstate();
luaL_openlibs(L);

boost::filesystem::path someDir(path);
boost::filesystem::directory_iterator end_iter;
fs::path someDir(path);
fs::directory_iterator end_iter;

if (boost::filesystem::exists(someDir) && boost::filesystem::is_directory(someDir))
if (fs::exists(someDir) && fs::is_directory(someDir))
{
lua_requirepath +=
path + "/?.lua;" +
path + "/?.ext;" +
path + "/?.dll;" +
path + "/?.so;";

for (boost::filesystem::directory_iterator dir_iter(someDir); dir_iter != end_iter; ++dir_iter)
for (fs::directory_iterator dir_iter(someDir); dir_iter != end_iter; ++dir_iter)
{
std::string fullpath = dir_iter->path().generic_string();
// Check if file is hidden
Expand All @@ -122,13 +127,13 @@ void ElunaLoader::ReadFiles(std::string path)
#endif

// load subfolder
if (boost::filesystem::is_directory(dir_iter->status()))
if (fs::is_directory(dir_iter->status()))
{
ReadFiles(fullpath);
continue;
}

if (boost::filesystem::is_regular_file(dir_iter->status()))
if (fs::is_regular_file(dir_iter->status()))
{
int32 mapId;

Expand Down
2 changes: 1 addition & 1 deletion LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

// Some dummy includes containing BOOST_VERSION:
// ObjectAccessor.h Config.h Log.h
#if !defined MANGOS
#if !defined(MANGOS) && !defined(VMANGOS)
#define USING_BOOST
#endif

Expand Down
84 changes: 24 additions & 60 deletions VMangos/AuraMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace LuaAura
*
* @return [Unit] caster
*/
int GetCaster(lua_State* L, Aura* aura)
int GetCaster(Eluna* E, Aura* aura)
{
Eluna::Push(L, aura->GetCaster());
E->Push(aura->GetCaster());
return 1;
}

Expand All @@ -37,13 +37,9 @@ namespace LuaAura
*
* @return string caster_guid : the GUID of the Unit as a decimal string
*/
int GetCasterGUID(lua_State* L, Aura* aura)
int GetCasterGUID(Eluna* E, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetCasterGUID());
#else
Eluna::Push(L, aura->GetCasterGuid());
#endif
E->Push(aura->GetCasterGuid());
return 1;
}

Expand All @@ -52,9 +48,9 @@ namespace LuaAura
*
* @return uint32 caster_level
*/
int GetCasterLevel(lua_State* L, Aura* aura)
int GetCasterLevel(Eluna* E, Aura* aura)
{
Eluna::Push(L, aura->GetCaster()->GetLevel());
E->Push(aura->GetCaster()->GetLevel());
return 1;
}

Expand All @@ -63,13 +59,9 @@ namespace LuaAura
*
* @return int32 duration : amount of time left in milliseconds
*/
int GetDuration(lua_State* L, Aura* aura)
int GetDuration(Eluna* E, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetDuration());
#else
Eluna::Push(L, aura->GetAuraDuration());
#endif
E->Push(aura->GetAuraDuration());
return 1;
}

Expand All @@ -78,9 +70,9 @@ namespace LuaAura
*
* @return uint32 aura_id
*/
int GetAuraId(lua_State* L, Aura* aura)
int GetAuraId(Eluna* E, Aura* aura)
{
Eluna::Push(L, aura->GetId());
E->Push(aura->GetId());
return 1;
}

Expand All @@ -92,13 +84,9 @@ namespace LuaAura
*
* @return int32 max_duration : the maximum duration of the Aura, in milliseconds
*/
int GetMaxDuration(lua_State* L, Aura* aura)
int GetMaxDuration(Eluna* E, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetMaxDuration());
#else
Eluna::Push(L, aura->GetAuraMaxDuration());
#endif
E->Push(aura->GetAuraMaxDuration());
return 1;
}

Expand All @@ -109,9 +97,9 @@ namespace LuaAura
*
* @return uint32 stack_amount
*/
int GetStackAmount(lua_State* L, Aura* aura)
int GetStackAmount(Eluna* E, Aura* aura)
{
Eluna::Push(L, aura->GetStackAmount());
E->Push(aura->GetStackAmount());
return 1;
}

Expand All @@ -120,13 +108,9 @@ namespace LuaAura
*
* @return [Unit] owner
*/
int GetOwner(lua_State* L, Aura* aura)
int GetOwner(Eluna* E, Aura* aura)
{
#if defined TRINITY || defined AZEROTHCORE
Eluna::Push(L, aura->GetOwner());
#else
Eluna::Push(L, aura->GetTarget());
#endif
E->Push(aura->GetTarget());
return 1;
}

Expand All @@ -135,19 +119,11 @@ namespace LuaAura
*
* @param int32 duration : the new duration of the Aura, in milliseconds
*/
int SetDuration(lua_State* L, Aura* aura)
int SetDuration(Eluna* E, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
#if defined TRINITY || defined AZEROTHCORE
aura->SetDuration(duration);
#else
int32 duration = Eluna::CHECKVAL<int32>(E->L, 2);
aura->GetHolder()->SetAuraDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
#else
aura->GetHolder()->SendAuraUpdate(false);
#endif
#endif
return 0;
}

Expand All @@ -159,19 +135,11 @@ namespace LuaAura
*
* @param int32 duration : the new maximum duration of the Aura, in milliseconds
*/
int SetMaxDuration(lua_State* L, Aura* aura)
int SetMaxDuration(Eluna* E, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
#if defined TRINITY || defined AZEROTHCORE
aura->SetMaxDuration(duration);
#else
int32 duration = Eluna::CHECKVAL<int32>(E->L, 2);
aura->GetHolder()->SetAuraMaxDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
#else
aura->GetHolder()->SendAuraUpdate(false);
#endif
#endif
return 0;
}

Expand All @@ -183,24 +151,20 @@ namespace LuaAura
*
* @param uint32 amount
*/
int SetStackAmount(lua_State* L, Aura* aura)
int SetStackAmount(Eluna* E, Aura* aura)
{
uint8 amount = Eluna::CHECKVAL<uint8>(L, 2);
uint8 amount = Eluna::CHECKVAL<uint8>(E->L, 2);
aura->GetHolder()->SetStackAmount(amount);
return 0;
}

/**
* Remove this [Aura] from the [Unit] it is applied to.
*/
int Remove(lua_State* L, Aura* aura)
int Remove(Eluna* E, Aura* aura)
{
#if defined TRINITY || defined AZEROTHCORE
aura->Remove();
#else
aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL);
#endif
Eluna::CHECKOBJ<ElunaObject>(L, 1)->Invalidate();
Eluna::CHECKOBJ<ElunaObject>(E->L, 1)->Invalidate();
return 0;
}

Expand Down
Loading

0 comments on commit 75f101d

Please sign in to comment.