Skip to content

Commit

Permalink
Work done so far on adapting the Lua interpreter to the trunk.
Browse files Browse the repository at this point in the history
I will keep the two Lua interpreters separate because of alot of method renames which will result in alot of syntax errors in old scripts.

MODIFIED: 
Added some callback support for function pointers required by the engine.
Cleaned and divided the lua interpreter's files into folders.
  • Loading branch information
Paroxysm authored and Paroxysm committed Dec 20, 2010
1 parent 6ddac9c commit 49f2033
Show file tree
Hide file tree
Showing 36 changed files with 172 additions and 292 deletions.
66 changes: 66 additions & 0 deletions src/arcemu-shared/CallBack.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,72 @@ class CallbackFP {
CallbackFP* Create();
};

class CallBackFunctionP0 : public CallbackBase
{
typedef void(*cbfunction)();
cbfunction cb;
public:
CallBackFunctionP0(cbfunction fn) : cb(fn) {}
void operator()() { return (cb)(); }
void execute() { return operator()(); }
};

template<typename P1>
class CallBackFunctionP1 : public CallbackBase
{
typedef void(*cbfunction)(P1);
cbfunction cb;
P1 _p1;
public:
CallBackFunctionP1(cbfunction fn, P1 p1)
{
cb = fn;
_p1 = p1;
}
void operator()() { return (cb)(_p1); }
void execute() { return operator()(); }
};

template<typename P1, typename P2>
class CallBackFunctionP2 : public CallbackBase
{
typedef void(*cbfunction)(P1,P2);
cbfunction cb;
P1 _p1;
P2 _p2;
public:
CallBackFunctionP2(cbfunction fn, P1 p1, P2 p2) : cb(fn), _p1(p1), _p2(p2) {}
void operator()() { return (cb)(_p1,_p2); }
void execute() { return operator()(); }
};
template<typename P1, typename P2, typename P3>
class CallBackFunctionP3 : public CallbackBase
{
typedef void(*cbfunction)(P1,P2, P3);
cbfunction cb;
P1 _p1;
P2 _p2;
P3 _p3;
public:
CallBackFunctionP3(cbfunction fn, P1 p1, P2 p2, P3 p3) : cb(fn), _p1(p1), _p2(p2), _p3(p3) {};
void operator()() { return (cb)(_p1,_p2,_p3); }
void execute() { return operator()(); }
};
template<typename P1, typename P2, typename P3, typename P4>
class CallBackFunctionP4 : public CallbackBase
{
typedef void(*cbfunction)(P1,P2, P3, P4);
cbfunction cb;
P1 _p1;
P2 _p2;
P3 _p3;
P4 _p4;
public:
CallBackFunctionP4(cbfunction fn, P1 p1, P2 p2, P3 p3, P4 p4) : cb(fn), _p1(p1), _p2(p2), _p3(p3), _p4(p4) {};
void operator()() { return (cb)(_p1, _p2, _p3, _p4); }
void execute() { return operator()(); }
};

template < class Class >
class CallbackP0 : public CallbackBase
{
Expand Down
59 changes: 0 additions & 59 deletions src/scripts/src/LuaEngine/lua/Makefile.am

This file was deleted.

29 changes: 0 additions & 29 deletions src/scripts/src/luabridge/LUAFunctions.h

This file was deleted.

42 changes: 21 additions & 21 deletions src/scripts/src/luabridge/Makefile.am.nocompile
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ lua/lvm.h \
lua/lzio.c \
lua/lzio.h \
lua/print.c \
lua_defs.h \
LUAEngine.cpp \
LUAEngine.h \
aura_functions.h \
gameobject_functions.h \
global_functions.h \
instance_functions.h \
item_functions.h \
lua_hooks.h \
lua_instance.h \
object_functions.h \
packet_functions.h \
player_functions.h \
quest_functions.h \
register_functions.h \
spell_functions.h \
sql_functions.h \
taxi_functions.h \
unit_functions.h \
creature_functions.h \
GlobalFunctions.h
interpreter/lua_defs.h \
interpreter/lua_instance.h \
interpreter/LUAEngine.cpp \
interpreter/LUAEngine.h \
object_functions/aura_functions.h \
object_functions/gameobject_functions.h \
object_functions/global_functions.h \
object_functions/instance_functions.h \
object_functions/item_functions.h \
object_functions/lua_hooks.h \
object_functions/object_functions.h \
object_functions/packet_functions.h \
object_functions/player_functions.h \
object_functions/quest_functions.h \
object_functions/register_functions.h \
object_functions/spell_functions.h \
object_functions/sql_functions.h \
object_functions/taxi_functions.h \
object_functions/unit_functions.h \
object_functions/creature_functions.h \
object_functions/GlobalFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void lua_engine::EndLuaFunctionCall(int res)
void lua_engine::startupEngine()
{
Log.Notice("LuaEngineMgr", "Spawning Lua Engine...");
#ifdef WIN32
/*#ifdef WIN32
Log.Color(TGREEN);
printf(" \_\_ \_\_ \_\_ \_\_\_\_\_\_ \n");
//Log.Color(TGREEN);
Expand All @@ -268,12 +268,13 @@ void lua_engine::startupEngine()
Log.Color(TNORMAL);
#else
Log.Color(TGREEN);
printf("~~~LuaHypArc~~~");
#endif
Log.Line("");
Log.Notice("LuaEngineMgr", "LuaHypArc Lua Engine %s: Loaded", ARCH);
Log.Color(TNORMAL);
Log.Line("");
Log.Line("");*/
Log.Notice("LuaEngineMgr","~~~LuaHypArc~~~");
Log.Notice("LuaEngineMgr", "LuaHypArc Lua Engine %s: Loaded", ARCH);

//Initialize our compiler.
LUA_COMPILER = new LUA_INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ GossipMenu * Menu;
#include "StdAfx.h"
#include "lua_instance.h"
#include "lua_defs.h"
#include "lua_bridge/luabridge.hpp"
#include "../luabridge_src/luabridge.hpp"

extern "C"
{ // we're C++, and LUA is C, so the compiler needs to know to use C function names.
#include "lua/lua.h"
#include "lua/lauxlib.h"
#include "lua/lualib.h"
#include "../lua/lua.h"
#include "../lua/lauxlib.h"
#include "../lua/lualib.h"
};

#if defined WIN32
Expand Down Expand Up @@ -169,22 +169,22 @@ namespace lua_engine
// We can no longer insert double pointers so we are safe here.
#define RegisterHook(evt, _func) m_scriptMgr->register_hook( (ServerHookEvents)(evt), (_func) );

#include "register_functions.h"
#include "gameobject_functions.h"
#include "unit_functions.h"
#include "item_functions.h"
#include "packet_functions.h"
#include "taxi_functions.h"
#include "spell_functions.h"
#include "global_functions.h"
#include "sql_functions.h"
#include "aura_functions.h"
#include "lua_hooks.h"
#include "instance_functions.h"
#include "quest_functions.h"
#include "object_functions.h"
#include "player_functions.h"
#include "creature_functions.h"
#include "../object_functions/register_functions.h"
#include "../object_functions/gameobject_functions.h"
#include "../object_functions/unit_functions.h"
#include "../object_functions/item_functions.h"
#include "../object_functions/packet_functions.h"
#include "../object_functions/taxi_functions.h"
#include "../object_functions/spell_functions.h"
#include "../object_functions/global_functions.h"
#include "../object_functions/sql_functions.h"
#include "../object_functions/aura_functions.h"
#include "../object_functions/lua_hooks.h"
#include "../object_functions/instance_functions.h"
#include "../object_functions/quest_functions.h"
#include "../object_functions/object_functions.h"
#include "../object_functions/player_functions.h"
#include "../object_functions/creature_functions.h"



Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include "StdAfx.h"
extern "C"
{ // we're C++, and LUA is C, so the compiler needs to know to use C function names.
#include "lua/lua.h"
#include "lua/lauxlib.h"
#include "lua/lualib.h"
#include "../lua/lua.h"
#include "../lua/lauxlib.h"
#include "../lua/lualib.h"
};

enum QuestEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "lua_defs.h"
extern "C"
{ // we're C++, and LUA is C, so the compiler needs to know to use C function names.
#include "lua/lua.h"
#include "lua/lauxlib.h"
#include "lua/lualib.h"
#include "../lua/lua.h"
#include "../lua/lauxlib.h"
#include "../lua/lualib.h"
};

typedef struct _LUA_INSTANCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C"
#include "../lua/lauxlib.h"
#include "../lua/lualib.h"
};
#include "../lua_defs.h"
#include "../interpreter/lua_defs.h"

/*#ifndef USE_OTHER_SHARED_PTR
# include "shared_ptr.hpp"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ ARCEMU_FORCEINLINE static int engineversion()

ARCEMU_FORCEINLINE static void logcolor(int color)
{
Log.Color(color);
//Log.Color(color);
}
ARCEMU_FORCEINLINE static QueryResult* WorldDBQuery(const char * query)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace lua_engine
#define bind(name) .method(#name, &Creature::name)
m .class_<Creature>("Creature")
bind(IsVehicle)
bind(isGuard)
bind(isNeutralGuard)
//bind(isGuard)
//bind(isNeutralGuard)
.method("RemoveFromWorld", (void (Creature::*)(bool) )&Creature::RemoveFromWorld)
bind(HasItems)
bind(GetProto)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace lua_engine
.method("GetPositionZ", &Object::GetPositionZ)
.method("GetOrientation", &Object::GetOrientation)
.method("GetO", &Object::GetOrientation)
.method("SetO", &Object::SetOrientation)
.method("SetOrientation", &Object::SetOrientation)
//.method("SetO", &Object::SetOrientation)
// .method("SetOrientation", &Object::SetOrientation)
.method("GetSpawnX", &Object::GetSpawnX)
.method("GetSpawnY", &Object::GetSpawnY)
.method("GetSpawnZ", &Object::GetSpawnZ)
Expand Down Expand Up @@ -60,7 +60,7 @@ namespace lua_engine
.method("HasFlag", &Object::HasFlag)
.method("IsInRange", &Object::isInRange)
.method("IsInFront", &Object::isInFront)
.method("SetInFront", &Object::setInFront)
//.method("SetInFront", &Object::setInFront)
.method("IsBehind", &Object::isInBack)
.method("IsInArc", &Object::isInArc)
.method("calcAngle", &Object::calcAngle)
Expand All @@ -72,11 +72,11 @@ namespace lua_engine

//creatable and destroyable in the lua environment.
m .class_<GossipMenu>("GossipMenu", true)
.constructor< void(*)(Creature *, uint32) > ()
.constructor< void(*)(uint64, uint32) > ()
.method("AddItem", ( void(GossipMenu::*)(uint8,const char*, int32, int8) )&GossipMenu::AddItem)
.method("AddMenuItem", &GossipMenu::AddMenuItem)
.method("SendToPlr", &GossipMenu::SendTo)
.method("SendToAllPlayers", &GossipMenu::SendToAllPlayers)
//.method("SendToAllPlayers", &GossipMenu::SendToAllPlayers)
.method("SetTextID", &GossipMenu::SetTextID);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ namespace lua_engine
.method("AddPathNode", &TaxiPath::AddPathNode)
.method("GetNodeCount", &TaxiPath::GetNodeCount)
//.method("GetPathNode", &TaxiPath::GetPathNode)
.method("GetPrice", &TaxiPath::GetPrice)
.method("SetPrice", &TaxiPath::SetPrice);
.method("GetPrice", &TaxiPath::GetPrice);
//.method("SetPrice", &TaxiPath::SetPrice);

m .class_<TaxiMgr>("sTaxiMgr")
.method("GetTaxiNode", &TaxiMgr::GetTaxiNode)
Expand Down
Loading

0 comments on commit 49f2033

Please sign in to comment.