From 44a1421c393632978d59c0698a93ae22243b97e9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 10 Jun 2020 20:39:54 -0400 Subject: Various progress for 1klutz Added convext shape casts, still a little broken, but it might be just broken bullet side. --- src/server/lua_api/load_game.hpp | 26 ++-- src/server/lua_api/load_io.cpp | 126 ++++++++-------- src/server/lua_api/load_io.hpp | 26 ++-- src/server/lua_api/phys/sbphysmodel.cpp | 252 ++++++++++++++++---------------- 4 files changed, 215 insertions(+), 215 deletions(-) (limited to 'src/server') diff --git a/src/server/lua_api/load_game.hpp b/src/server/lua_api/load_game.hpp index 7937b15..23b9e81 100644 --- a/src/server/lua_api/load_game.hpp +++ b/src/server/lua_api/load_game.hpp @@ -1,13 +1,13 @@ -#ifndef __H_loadgame -#define __H_loadgame -#include -#include -#include -extern "C" { - #include - #include - #include -} - -void load_gamefuncs(lua_State* L); -#endif +#ifndef __H_loadgame +#define __H_loadgame +#include +#include +#include +extern "C" { + #include + #include + #include +} + +void load_gamefuncs(lua_State* L); +#endif diff --git a/src/server/lua_api/load_io.cpp b/src/server/lua_api/load_io.cpp index af471b1..278d7a7 100644 --- a/src/server/lua_api/load_io.cpp +++ b/src/server/lua_api/load_io.cpp @@ -1,63 +1,63 @@ - -extern "C" { - #include - #include - #include -} -#include -//STL -#include -#include -#include - -#define epath "../data" -#define epathlen sizeof(epath) - -/*Add an io.dir(path) function, which lists all the files in (path)*/ -int dirpath(lua_State *L){ - if(!lua_isstring(L,-1)){ - lua_pushstring(L,"io.dir() requires a string as argument #1"); - lua_error(L); - } - size_t pathstrlen; - const char *pathstr = lua_tolstring(L,-1,&pathstrlen); - //printf("got pathstr: %s\n",pathstr); - //char tpathstr[pathstrlen + epathlen + 1 + 1]; //+1 for null, +1 for / - //memcpy(tpathstr,epath,epathlen); - //tpathstr[epathlen] = '/'; - //memcpy(tpathstr+epathlen,pathstr,pathstrlen); - //tpathstr[pathstrlen + epathlen + 1] = '\0'; - //printf("tpathstr is: \"%s\"\n",tpathstr); - //lua_pop(L,1); - DIR *dir; - struct dirent *ent; - const char *tpathstr = pathstr; - dir = opendir(tpathstr); - if(dir == NULL){ - perror("Cannot open"); - lua_pushstring(L,"Failed to open directory: "); - lua_pushstring(L,tpathstr); - lua_concat(L,2); - lua_error(L); - } - int i = 1; - ent = readdir(dir); - lua_newtable(L); - while( (ent = readdir(dir)) != NULL){ - lua_pushinteger(L,i); - lua_pushstring(L,ent->d_name); - lua_settable(L,-3); - i++; - } - closedir(dir); - return 1; -} - - -void load_iofuncs(lua_State* L){ - lua_getglobal(L,"io"); - - lua_pushcfunction(L,dirpath); - lua_setfield(L,-2,"dir"); - lua_pop(L,1); -} + +extern "C" { + #include + #include + #include +} +#include +//STL +#include +#include +#include + +#define epath "../data" +#define epathlen sizeof(epath) + +/*Add an io.dir(path) function, which lists all the files in (path)*/ +int dirpath(lua_State *L){ + if(!lua_isstring(L,-1)){ + lua_pushstring(L,"io.dir() requires a string as argument #1"); + lua_error(L); + } + size_t pathstrlen; + const char *pathstr = lua_tolstring(L,-1,&pathstrlen); + //printf("got pathstr: %s\n",pathstr); + //char tpathstr[pathstrlen + epathlen + 1 + 1]; //+1 for null, +1 for / + //memcpy(tpathstr,epath,epathlen); + //tpathstr[epathlen] = '/'; + //memcpy(tpathstr+epathlen,pathstr,pathstrlen); + //tpathstr[pathstrlen + epathlen + 1] = '\0'; + //printf("tpathstr is: \"%s\"\n",tpathstr); + //lua_pop(L,1); + DIR *dir; + struct dirent *ent; + const char *tpathstr = pathstr; + dir = opendir(tpathstr); + if(dir == NULL){ + perror("Cannot open"); + lua_pushstring(L,"Failed to open directory: "); + lua_pushstring(L,tpathstr); + lua_concat(L,2); + lua_error(L); + } + int i = 1; + ent = readdir(dir); + lua_newtable(L); + while( (ent = readdir(dir)) != NULL){ + lua_pushinteger(L,i); + lua_pushstring(L,ent->d_name); + lua_settable(L,-3); + i++; + } + closedir(dir); + return 1; +} + + +void load_iofuncs(lua_State* L){ + lua_getglobal(L,"io"); + + lua_pushcfunction(L,dirpath); + lua_setfield(L,-2,"dir"); + lua_pop(L,1); +} diff --git a/src/server/lua_api/load_io.hpp b/src/server/lua_api/load_io.hpp index 19f7a77..e4e29b1 100644 --- a/src/server/lua_api/load_io.hpp +++ b/src/server/lua_api/load_io.hpp @@ -1,13 +1,13 @@ -#ifndef __H_loadio -#define __H_loadio -#include -#include -#include -extern "C" { - #include - #include - #include -} - -void load_iofuncs(lua_State* L); -#endif +#ifndef __H_loadio +#define __H_loadio +#include +#include +#include +extern "C" { + #include + #include + #include +} + +void load_iofuncs(lua_State* L); +#endif diff --git a/src/server/lua_api/phys/sbphysmodel.cpp b/src/server/lua_api/phys/sbphysmodel.cpp index 4d81b2c..0371b93 100644 --- a/src/server/lua_api/phys/sbphysmodel.cpp +++ b/src/server/lua_api/phys/sbphysmodel.cpp @@ -1,126 +1,126 @@ -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//extern "C" { - //#include - //#include - //#include -//} -//#include -//#include -//#include "../gameparts.hpp" -//#include "cbphysbox.hpp" -//#include "cbphysmodel.hpp" -//#include -//#include -//#include -//#include - - -//using namespace irr; -//using namespace scene; -//using namespace core; -//using namespace video; - -//extern IrrlichtDevice* device; - -//extern btDiscreteDynamicsWorld* World; -//extern std::list Objects; - -////newbphysmodel("graphicfile","physicfile",mass,[,{position}][,{lookat}]) -//static int newbphysmodel(lua_State* L){ - //printf("Creating bphysmodel\n"); - //int nargs = lua_gettop(L); - //double lx,ly,lz; - //double x,y,z; - //if(nargs > 4){ - ////"graphicsfile","physicsfile",{position},{lookat} - //popvector3d(L,&lx,&ly,&lz); - //}else{ - //lx = 1; ly = 1; lz = 1; - //} - - //if(nargs > 3){ - ////"graphicsfile","physicsfile",{position} - //popvector3d(L,&x,&y,&z); - //}else{ - //x = 0; y = 0; z = 0; - //} - ////"graphicsfile","physicsfile",mass - - //double mass = lua_tonumber(L,-1); - //const char *ppath = lua_tostring(L,-2); - //const char *gpath = lua_tostring(L,-3); - //lua_pop(L,3);// - - //ISceneManager *smgr = device->getSceneManager(); - - //printf("bphysnode, creating the scene node\n"); - - ////Create the scene node - //IMesh *gmesh = smgr->getMesh(gpath); - //ISceneNode *node = smgr->addMeshSceneNode(gmesh,0,-1,vector3df(x,y,z)); - - //printf("bphysnode, createing the physics body\n"); - ////Create the physics body - //lua_pushstring(L,ppath); - //lua_pushnumber(L,mass); - //pushvector3d(L,x,y,z); - //pushvector3d(L,lx,ly,lz); - //printf("About to makebphysmodel\n"); - //makebphysmodel(L); - //printf("done makebphysmodel\n"); - - //btRigidBody *rb = (btRigidBody*)lua_touserdata(L,-1); - ////Create the lua representation - //lua_newtable(L);// - - //lua_pushlightuserdata(L,rb); - //lua_setfield(L,-2,"collider");//{rb=ud_rb} - - //lua_pushstring(L,"rigidbody"); - //lua_setfield(L,-2,"type");//{rb=ud_rb, type="rigidbody"} - - //lua_pushlightuserdata(L,node); - //lua_setfield(L,-2,"node");//{rb=ud_rb, node=ud_node, type="rigidbody"} - - //luaL_getmetatable(L,"phys.physmodel"); - //lua_setmetatable(L,-2); - - //lua_getglobal(L,"phys");//{rb},{phys} - //lua_getfield(L,-1,"colliders");//{rb},{phys},{colliders} - //lua_pushlightuserdata(L,rb);//{rb},{phys},{colliders},ud_rb - //lua_pushvalue(L,-4);//{rb},{phys},{colliders},ud_rb,{rb} - //lua_settable(L,-3);//{rb},{phys},{colliders} - //lua_pop(L,2);//{rb} - //printf("finished creating the lua representation\n"); - - //return 1; -//} - -//static const luaL_reg bphysmodel_f[] = { - //{"newphysmodel", newbphysmodel}, - //{0,0}, -//}; - -//static const luaL_reg bphysmodel_m[] = { - //{0, 0}, -//}; - -//int cbphysmodel_register(lua_State* L){ - ////printf("bphysmodel registered\n"); - - //luaL_newmetatable(L, "phys.physmodel");//{} - //luaL_register(L,NULL,bcollider_m); - //luaL_register(L,NULL,bphysmodel_m); - //luaL_register(L,NULL,igeneric_m); //Inherit all the things to do with scene nodes - - //lua_getglobal(L,"phys"); - //luaL_register(L,NULL,bphysmodel_f); - - //return 1; -//} +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//extern "C" { + //#include + //#include + //#include +//} +//#include +//#include +//#include "../gameparts.hpp" +//#include "cbphysbox.hpp" +//#include "cbphysmodel.hpp" +//#include +//#include +//#include +//#include + + +//using namespace irr; +//using namespace scene; +//using namespace core; +//using namespace video; + +//extern IrrlichtDevice* device; + +//extern btDiscreteDynamicsWorld* World; +//extern std::list Objects; + +////newbphysmodel("graphicfile","physicfile",mass,[,{position}][,{lookat}]) +//static int newbphysmodel(lua_State* L){ + //printf("Creating bphysmodel\n"); + //int nargs = lua_gettop(L); + //double lx,ly,lz; + //double x,y,z; + //if(nargs > 4){ + ////"graphicsfile","physicsfile",{position},{lookat} + //popvector3d(L,&lx,&ly,&lz); + //}else{ + //lx = 1; ly = 1; lz = 1; + //} + + //if(nargs > 3){ + ////"graphicsfile","physicsfile",{position} + //popvector3d(L,&x,&y,&z); + //}else{ + //x = 0; y = 0; z = 0; + //} + ////"graphicsfile","physicsfile",mass + + //double mass = lua_tonumber(L,-1); + //const char *ppath = lua_tostring(L,-2); + //const char *gpath = lua_tostring(L,-3); + //lua_pop(L,3);// + + //ISceneManager *smgr = device->getSceneManager(); + + //printf("bphysnode, creating the scene node\n"); + + ////Create the scene node + //IMesh *gmesh = smgr->getMesh(gpath); + //ISceneNode *node = smgr->addMeshSceneNode(gmesh,0,-1,vector3df(x,y,z)); + + //printf("bphysnode, createing the physics body\n"); + ////Create the physics body + //lua_pushstring(L,ppath); + //lua_pushnumber(L,mass); + //pushvector3d(L,x,y,z); + //pushvector3d(L,lx,ly,lz); + //printf("About to makebphysmodel\n"); + //makebphysmodel(L); + //printf("done makebphysmodel\n"); + + //btRigidBody *rb = (btRigidBody*)lua_touserdata(L,-1); + ////Create the lua representation + //lua_newtable(L);// + + //lua_pushlightuserdata(L,rb); + //lua_setfield(L,-2,"collider");//{rb=ud_rb} + + //lua_pushstring(L,"rigidbody"); + //lua_setfield(L,-2,"type");//{rb=ud_rb, type="rigidbody"} + + //lua_pushlightuserdata(L,node); + //lua_setfield(L,-2,"node");//{rb=ud_rb, node=ud_node, type="rigidbody"} + + //luaL_getmetatable(L,"phys.physmodel"); + //lua_setmetatable(L,-2); + + //lua_getglobal(L,"phys");//{rb},{phys} + //lua_getfield(L,-1,"colliders");//{rb},{phys},{colliders} + //lua_pushlightuserdata(L,rb);//{rb},{phys},{colliders},ud_rb + //lua_pushvalue(L,-4);//{rb},{phys},{colliders},ud_rb,{rb} + //lua_settable(L,-3);//{rb},{phys},{colliders} + //lua_pop(L,2);//{rb} + //printf("finished creating the lua representation\n"); + + //return 1; +//} + +//static const luaL_reg bphysmodel_f[] = { + //{"newphysmodel", newbphysmodel}, + //{0,0}, +//}; + +//static const luaL_reg bphysmodel_m[] = { + //{0, 0}, +//}; + +//int cbphysmodel_register(lua_State* L){ + ////printf("bphysmodel registered\n"); + + //luaL_newmetatable(L, "phys.physmodel");//{} + //luaL_register(L,NULL,bcollider_m); + //luaL_register(L,NULL,bphysmodel_m); + //luaL_register(L,NULL,igeneric_m); //Inherit all the things to do with scene nodes + + //lua_getglobal(L,"phys"); + //luaL_register(L,NULL,bphysmodel_f); + + //return 1; +//} -- cgit v1.2.3-70-g09d2