From ef25a513437196a3ea9ee45e6e03565eb86067d2 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Thu, 28 Jun 2018 16:05:26 -0600 Subject: Simplified makefile Made makefile much simpiler, added option to build dynamically with DEBUG=true --- src/shared/lua_api/common.c | 205 ----------------------------------- src/shared/lua_api/common.cpp | 205 +++++++++++++++++++++++++++++++++++ src/shared/lua_api/common.h | 20 ---- src/shared/lua_api/common.hpp | 20 ++++ src/shared/lua_api/load_net.cpp | 2 +- src/shared/lua_api/phys/bphysbox.cpp | 2 +- src/shared/lua_api/phys/bphysbox.hpp | 1 - 7 files changed, 227 insertions(+), 228 deletions(-) delete mode 100644 src/shared/lua_api/common.c create mode 100644 src/shared/lua_api/common.cpp delete mode 100644 src/shared/lua_api/common.h create mode 100644 src/shared/lua_api/common.hpp (limited to 'src/shared/lua_api') diff --git a/src/shared/lua_api/common.c b/src/shared/lua_api/common.c deleted file mode 100644 index 2eeee11..0000000 --- a/src/shared/lua_api/common.c +++ /dev/null @@ -1,205 +0,0 @@ - -extern "C" { - #include - #include - #include -} - -#include "common.h" - -//Expose things to the lua state -void loadLLibs(lua_State* L){ - - lua_pushcfunction(L,luaopen_base); - lua_pushliteral(L,""); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_table); - lua_pushliteral(L,LUA_TABLIBNAME); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_string); - lua_pushliteral(L,LUA_STRLIBNAME); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_math); - lua_pushliteral(L,LUA_MATHLIBNAME); - lua_call(L,1,0); - - lua_pushcfunction(L,luaopen_string); - lua_pushliteral(L,LUA_STRLIBNAME); - lua_call(L,1,0); - - /* - lua_pushcfunction(L,luaopen_string); - lua_pushliteral(L,LUA_STRLIBNAME); - lua_call(L,1,0); - */ -} - - -int pushvector3i(lua_State* L,long a,long b,long c){ - lua_newtable(L);//{} - - lua_pushinteger(L,1);//{},1 - lua_pushinteger(L,a);//{},1,a - lua_settable(L,-3);//{} - - lua_pushinteger(L,2);//{},2 - lua_pushinteger(L,b);//{},2,b - lua_settable(L,-3);//{} - - lua_pushinteger(L,3);//{},3 - lua_pushinteger(L,c);//{},3,c - lua_settable(L,-3);//{} - - return 1; -} -int pushvector3d(lua_State* L,double a,double b,double c){ - lua_newtable(L);//{} - - lua_pushinteger(L,1);//{},1 - lua_pushnumber(L,a);//{},1,a - lua_settable(L,-3);//{} - - lua_pushinteger(L,2);//{},2 - lua_pushnumber(L,b);//{},2,b - lua_settable(L,-3);//{} - - lua_pushinteger(L,3);//{},3 - lua_pushnumber(L,c);//{},3,c - lua_settable(L,-3);//{} - - return 1; -} -int pushvector2i(lua_State* L, long a, long b){ - lua_newtable(L); - - lua_pushinteger(L,1); - lua_pushinteger(L,a); - lua_settable(L,-3); - - lua_pushinteger(L,2); - lua_pushinteger(L,b); - lua_settable(L,-3); - - return 1; -} - -int popvector4i(lua_State* L,long* a,long* b,long* c, long* d){ - lua_pushinteger(L,1);//{v4},1 - lua_gettable(L,-2);//{v4},v4[1] - *a = lua_tointeger(L,-1);//{v4},v4[1] - lua_pop(L,1);//{v4} - - lua_pushinteger(L,2);//{v4},2 - lua_gettable(L,-2);//{v4},v4[2] - *b = lua_tointeger(L,-1);//{v4},v4[2] - lua_pop(L,1);//{v4} - - lua_pushinteger(L,3);//{v4},3 - lua_gettable(L,-2);//{v4},v4[3] - *c = lua_tointeger(L,-1);//{v4},v4[3] - lua_pop(L,1);//{v4} - - lua_pushinteger(L,4);//{v4},3 - lua_gettable(L,-2);//{v4},v4[3] - *d = lua_tointeger(L,-1);//{v4},v4[3] - lua_pop(L,1);//{v4} - - lua_pop(L,1);// - return 0; -} - -int popvector3i(lua_State* L,long* a,long* b,long* c){//{v3} - lua_pushinteger(L,1);//{v3},1 - lua_gettable(L,-2);//{v3},v3[1] - *a = lua_tointeger(L,-1);//{v3},v3[1] - lua_pop(L,1);//{v3} - - lua_pushinteger(L,2);//{v3},2 - lua_gettable(L,-2);//{v3},v3[2] - *b = lua_tointeger(L,-1);//{v3},v3[2] - lua_pop(L,1);//{v3} - - lua_pushinteger(L,3);//{v3},3 - lua_gettable(L,-2);//{v3},v3[3] - *c = lua_tointeger(L,-1);//{v3},v3[3] - lua_pop(L,1);//{v3} - - lua_pop(L,1);// - return 0; -} - - - -int popvector3d(lua_State* L,double* a,double* b,double* c){ - lua_pushinteger(L,1); - lua_gettable(L,-2); - *a = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,2); - lua_gettable(L,-2); - *b = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,3); - lua_gettable(L,-2); - *c = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pop(L,1); - return 0; -} - -int popvector4d(lua_State* L, double *a, double *b, double *c, double *d){ - lua_pushinteger(L,1);//{a,b,c,d},1 - lua_gettable(L,-2);//{a,b,c,d},a - *a = lua_tonumber(L,-1);//{a,b,c,d},a - lua_pop(L,1);//{a,b,c,d} - - lua_pushinteger(L,2); - lua_gettable(L,-2); - *b = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,3); - lua_gettable(L,-2); - *c = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,4); - lua_gettable(L,-2); - *d = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pop(L,1); - return 0; -} - -//{{sx,sy},{ex,ey}} -int poprecti(lua_State* L, long *sx, long *sy, long *ex, long *ey){ - lua_pushnumber(L,1); - lua_gettable(L,-2); - popvector2i(L,sx,sy); - lua_pushnumber(L,2); - lua_gettable(L,-2); - popvector2i(L,ex,ey); - lua_pop(L,1); - return 0; -} - -int popvector2i(lua_State* L, long* a, long* b){ - lua_pushinteger(L,1); - lua_gettable(L,-2); - *a = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L,2); - lua_gettable(L,-2); - *b = lua_tonumber(L,-1); - lua_pop(L,2); - - return 0; -} diff --git a/src/shared/lua_api/common.cpp b/src/shared/lua_api/common.cpp new file mode 100644 index 0000000..68bf203 --- /dev/null +++ b/src/shared/lua_api/common.cpp @@ -0,0 +1,205 @@ + +extern "C" { + #include + #include + #include +} + +#include "common.hpp" + +//Expose things to the lua state +void loadLLibs(lua_State* L){ + + lua_pushcfunction(L,luaopen_base); + lua_pushliteral(L,""); + lua_call(L,1,0); + + lua_pushcfunction(L,luaopen_table); + lua_pushliteral(L,LUA_TABLIBNAME); + lua_call(L,1,0); + + lua_pushcfunction(L,luaopen_string); + lua_pushliteral(L,LUA_STRLIBNAME); + lua_call(L,1,0); + + lua_pushcfunction(L,luaopen_math); + lua_pushliteral(L,LUA_MATHLIBNAME); + lua_call(L,1,0); + + lua_pushcfunction(L,luaopen_string); + lua_pushliteral(L,LUA_STRLIBNAME); + lua_call(L,1,0); + + /* + lua_pushcfunction(L,luaopen_string); + lua_pushliteral(L,LUA_STRLIBNAME); + lua_call(L,1,0); + */ +} + + +int pushvector3i(lua_State* L,long a,long b,long c){ + lua_newtable(L);//{} + + lua_pushinteger(L,1);//{},1 + lua_pushinteger(L,a);//{},1,a + lua_settable(L,-3);//{} + + lua_pushinteger(L,2);//{},2 + lua_pushinteger(L,b);//{},2,b + lua_settable(L,-3);//{} + + lua_pushinteger(L,3);//{},3 + lua_pushinteger(L,c);//{},3,c + lua_settable(L,-3);//{} + + return 1; +} +int pushvector3d(lua_State* L,double a,double b,double c){ + lua_newtable(L);//{} + + lua_pushinteger(L,1);//{},1 + lua_pushnumber(L,a);//{},1,a + lua_settable(L,-3);//{} + + lua_pushinteger(L,2);//{},2 + lua_pushnumber(L,b);//{},2,b + lua_settable(L,-3);//{} + + lua_pushinteger(L,3);//{},3 + lua_pushnumber(L,c);//{},3,c + lua_settable(L,-3);//{} + + return 1; +} +int pushvector2i(lua_State* L, long a, long b){ + lua_newtable(L); + + lua_pushinteger(L,1); + lua_pushinteger(L,a); + lua_settable(L,-3); + + lua_pushinteger(L,2); + lua_pushinteger(L,b); + lua_settable(L,-3); + + return 1; +} + +int popvector4i(lua_State* L,long* a,long* b,long* c, long* d){ + lua_pushinteger(L,1);//{v4},1 + lua_gettable(L,-2);//{v4},v4[1] + *a = lua_tointeger(L,-1);//{v4},v4[1] + lua_pop(L,1);//{v4} + + lua_pushinteger(L,2);//{v4},2 + lua_gettable(L,-2);//{v4},v4[2] + *b = lua_tointeger(L,-1);//{v4},v4[2] + lua_pop(L,1);//{v4} + + lua_pushinteger(L,3);//{v4},3 + lua_gettable(L,-2);//{v4},v4[3] + *c = lua_tointeger(L,-1);//{v4},v4[3] + lua_pop(L,1);//{v4} + + lua_pushinteger(L,4);//{v4},3 + lua_gettable(L,-2);//{v4},v4[3] + *d = lua_tointeger(L,-1);//{v4},v4[3] + lua_pop(L,1);//{v4} + + lua_pop(L,1);// + return 0; +} + +int popvector3i(lua_State* L,long* a,long* b,long* c){//{v3} + lua_pushinteger(L,1);//{v3},1 + lua_gettable(L,-2);//{v3},v3[1] + *a = lua_tointeger(L,-1);//{v3},v3[1] + lua_pop(L,1);//{v3} + + lua_pushinteger(L,2);//{v3},2 + lua_gettable(L,-2);//{v3},v3[2] + *b = lua_tointeger(L,-1);//{v3},v3[2] + lua_pop(L,1);//{v3} + + lua_pushinteger(L,3);//{v3},3 + lua_gettable(L,-2);//{v3},v3[3] + *c = lua_tointeger(L,-1);//{v3},v3[3] + lua_pop(L,1);//{v3} + + lua_pop(L,1);// + return 0; +} + + + +int popvector3d(lua_State* L,double* a,double* b,double* c){ + lua_pushinteger(L,1); + lua_gettable(L,-2); + *a = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushinteger(L,2); + lua_gettable(L,-2); + *b = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushinteger(L,3); + lua_gettable(L,-2); + *c = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pop(L,1); + return 0; +} + +int popvector4d(lua_State* L, double *a, double *b, double *c, double *d){ + lua_pushinteger(L,1);//{a,b,c,d},1 + lua_gettable(L,-2);//{a,b,c,d},a + *a = lua_tonumber(L,-1);//{a,b,c,d},a + lua_pop(L,1);//{a,b,c,d} + + lua_pushinteger(L,2); + lua_gettable(L,-2); + *b = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushinteger(L,3); + lua_gettable(L,-2); + *c = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushinteger(L,4); + lua_gettable(L,-2); + *d = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pop(L,1); + return 0; +} + +//{{sx,sy},{ex,ey}} +int poprecti(lua_State* L, long *sx, long *sy, long *ex, long *ey){ + lua_pushnumber(L,1); + lua_gettable(L,-2); + popvector2i(L,sx,sy); + lua_pushnumber(L,2); + lua_gettable(L,-2); + popvector2i(L,ex,ey); + lua_pop(L,1); + return 0; +} + +int popvector2i(lua_State* L, long* a, long* b){ + lua_pushinteger(L,1); + lua_gettable(L,-2); + *a = lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushinteger(L,2); + lua_gettable(L,-2); + *b = lua_tonumber(L,-1); + lua_pop(L,2); + + return 0; +} diff --git a/src/shared/lua_api/common.h b/src/shared/lua_api/common.h deleted file mode 100644 index 6086065..0000000 --- a/src/shared/lua_api/common.h +++ /dev/null @@ -1,20 +0,0 @@ - -extern "C" { - #include - #include - #include -} - -void loadLLibs(lua_State*); - -int pushvector3i(lua_State*,long,long,long); -int pushvector3d(lua_State*,double,double,double); -int pushvector2i(lua_State*,long,long); - -int popvector4i(lua_State*,long*,long*,long*,long*); -int popvector4d(lua_State*,double*,double*,double*,double*); -int popvector3i(lua_State*,long*,long*,long*); -int popvector3d(lua_State*,double*,double*,double*); -int popvector2i(lua_State*,long*,long*); - -int poprecti(lua_State* L,long*,long*,long*,long*); diff --git a/src/shared/lua_api/common.hpp b/src/shared/lua_api/common.hpp new file mode 100644 index 0000000..6086065 --- /dev/null +++ b/src/shared/lua_api/common.hpp @@ -0,0 +1,20 @@ + +extern "C" { + #include + #include + #include +} + +void loadLLibs(lua_State*); + +int pushvector3i(lua_State*,long,long,long); +int pushvector3d(lua_State*,double,double,double); +int pushvector2i(lua_State*,long,long); + +int popvector4i(lua_State*,long*,long*,long*,long*); +int popvector4d(lua_State*,double*,double*,double*,double*); +int popvector3i(lua_State*,long*,long*,long*); +int popvector3d(lua_State*,double*,double*,double*); +int popvector2i(lua_State*,long*,long*); + +int poprecti(lua_State* L,long*,long*,long*,long*); diff --git a/src/shared/lua_api/load_net.cpp b/src/shared/lua_api/load_net.cpp index 5280d42..740d997 100644 --- a/src/shared/lua_api/load_net.cpp +++ b/src/shared/lua_api/load_net.cpp @@ -20,7 +20,7 @@ extern "C" { #include "load_net.hpp" -#include "../util/hashmap.h" +#include #include "stream.hpp" std::map> netfuncs; diff --git a/src/shared/lua_api/phys/bphysbox.cpp b/src/shared/lua_api/phys/bphysbox.cpp index 0fe9f72..728b6d1 100644 --- a/src/shared/lua_api/phys/bphysbox.cpp +++ b/src/shared/lua_api/phys/bphysbox.cpp @@ -9,7 +9,7 @@ extern "C" { } #include #include "bphysbox.hpp" -#include "../common.h" +#include extern btDiscreteDynamicsWorld* World; extern std::list Objects; diff --git a/src/shared/lua_api/phys/bphysbox.hpp b/src/shared/lua_api/phys/bphysbox.hpp index 96b58a7..1471381 100644 --- a/src/shared/lua_api/phys/bphysbox.hpp +++ b/src/shared/lua_api/phys/bphysbox.hpp @@ -8,7 +8,6 @@ extern "C" { #include } #include -#include "../common.h" void bphysbox_register(lua_State* L); void makenewbphysbox(lua_State* L); -- cgit v1.2.3-70-g09d2