From 5478f357b62062ffccfecb4c7b5fc607f0e7a518 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 10 Feb 2019 18:10:14 -0500 Subject: Corrected networking examples changed the api for interacting with sockets, sockets now have a callback, `socket:receive(function(stream) ... end)`, which they can use to decide what to do when called. Sockets also have a block:recv() function, which will block EVERYTHING until the socket receives data. This should probably not be used. --- src/client/main.cpp | 56 ++++-- src/server/main.cpp | 77 +++++++-- src/shared/lua_api/load_net.cpp | 356 ++++++++++++++++++++++++++++++--------- src/shared/lua_api/load_phys.cpp | 3 +- src/shared/lua_api/stream.hpp | 2 +- 5 files changed, 377 insertions(+), 117 deletions(-) (limited to 'src') diff --git a/src/client/main.cpp b/src/client/main.cpp index e8533d8..6e515ad 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -109,12 +109,6 @@ void UpdateElement(btRigidBody* TObject){ SColor background = SColor(255,100,101,140); //setbackgroundcolor(r,g,b) -int setbackgroundcolor(lua_State* L){ - long r,g,b; - popvector3i(L,&r,&g,&b); - background = SColor(255,r,g,b); - return 0; -} int main(int argc, char *argv[]){ printf("Brok[en]gine Client\n"); @@ -125,6 +119,7 @@ int main(int argc, char *argv[]){ //Create a new lua state, this gets shared everywhere //Set the path for lua putenv("LUA_PATH=?.lua"); + putenv("LUA_CPATH=../bin/?.dll"); lua_State *state = luaL_newstate(); L = state; printf("Created lua state at %p\n",L); @@ -156,11 +151,29 @@ int main(int argc, char *argv[]){ GlobalEventReceiver ger = GlobalEventReceiver(device); printf("Created event receiver\n"); device->setEventReceiver(&ger); - int iErr = luaL_dofile(state,"init.lua"); - if(iErr != 0){ - printf("Failed to open lua file:%s/init.lua\n",path); - lua_error(state); + + pusherrorfunc(L);//errfunc + switch(luaL_loadfile(state,"init.lua")){//errmsg or nothing + case 0: + break; //no error + case LUA_ERRSYNTAX: + printf("Syntax error, failed to load: %s\n%s","../data/init.lua",lua_tostring(L,-1)); + break; + case LUA_ERRMEM: + printf("Failed to allocate memroy\n"); + break; + case LUA_ERRFILE: + printf("Could not find file: %s\n","../data/init.lua"); + break; } + //errfunc,initfile() + printf("Loaded file\n"); + lua_pcall(state,0,0,-2); + //int iErr = luaL_dofile(state,"init.lua"); + //if(iErr != 0){ + //printf("Failed to open lua file:%s/init.lua\n",path); + //lua_error(state); + //} //Load some bullet physics stuff driver = device->getVideoDriver(); @@ -171,10 +184,9 @@ int main(int argc, char *argv[]){ printf("Everything registered, about to start running device!\n"); - lua_getglobal(L,"GAME"); - lua_pushcfunction(L,setbackgroundcolor); - lua_setfield(L,-2,"setbackgroundcolor"); - lua_pop(L,1); + lua_getglobal(state,"GAME");//{game} + lua_pop(state,1);// + printf("About to check if device run\n"); printf("Device is %p\n",device); while(device->run()){ @@ -197,7 +209,23 @@ int main(int argc, char *argv[]){ } smgr->drawAll(); + lua_getglobal(state,"GAME"); + lua_getfield(state,-1,"drawPostScene"); + if(!lua_isnil(state,-1)){ + lua_call(state,0,0); + lua_pop(state,1); + }else{ + lua_pop(state,2); + } guienv->drawAll(); + lua_getglobal(state,"GAME"); + lua_getfield(state,-1,"drawPostGui"); + if(!lua_isnil(state,-1)){ + lua_call(state,0,0); + lua_pop(state,1); + }else{ + lua_pop(state,2); + } driver->endScene(); }else{ device->yield(); diff --git a/src/server/main.cpp b/src/server/main.cpp index 2464899..b326e5f 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -23,9 +23,14 @@ extern "C" { #include #include +#include +#include + using namespace std; using namespace chrono; +bool game_active = true; + void dropRigidBody(btRigidBody* rb){ } @@ -40,43 +45,81 @@ void gameloop(){ //printf("done net\n"); } -int main (){ +int main (int argc, char *argv[]){ printf("Brok[en]gine Server\n"); - - putenv("LUA_PATH=../data/?.lua"); + game_active = true; + char *path; + if(argc == 2){ + path = argv[1]; + }else{ + path = (char*)"../data"; + } + size_t envstrsize = snprintf(NULL,0,"LUA_PATH=%s/?.lua",path); + char envstr[envstrsize]; + sprintf(envstr,"LUA_PATH=%s/?.lua",path); + putenv(envstr); + //printf("Put lua path\n"); L = luaL_newstate(); - - lua_newtable(L);//{} - lua_setglobal(L,"GAME");// + //printf("Created lua state\n"); + //lua_newtable(L);//{} + //lua_setglobal(L,"GAME");// + load_gamefuncs(L); + printf("Created global table\n"); phys_genesis(); + printf("Started phys\n"); luaL_openlibs(L); + printf("Opened standard libs\n"); loadLLibs(L); + printf("Opened aux libs\n"); loadNetLibs(L); + printf("Opened net libs\n"); load_physfuncs(L); - int iErr = luaL_dofile(L,"../data/init.lua"); - if(iErr != 0){ - printf("Failed to open lua file:../data/init.lua\n"); - lua_error(L); + printf("Opened phys libs\n"); + load_iofuncs(L); + printf("About to push error func\n"); + pusherrorfunc(L);//errfunc + printf("pushed error func\n"); + size_t init_file_path_len = snprintf(NULL,0,"%s/init.lua",path); + char init_file_path[init_file_path_len]; + sprintf(init_file_path,"%s/init.lua",path); + switch(luaL_loadfile(L,init_file_path)){ + case 0: + break; //no error + case LUA_ERRSYNTAX: + printf("Syntax error, failed to load: %s\n%s",init_file_path,lua_tostring(L,-1)); + break; + case LUA_ERRMEM: + printf("Failed to allocate memroy\n"); + break; + case LUA_ERRFILE: + printf("Could not find file: %s\n",init_file_path); + break; } + //errfunc,initfile() + printf("Loaded file\n"); + lua_pcall(L,0,0,-2); do{ - printf("Start of server gameloop\n"); + //printf("Start of server gameloop\n"); gameloop(); - printf("Gameloop\n"); - std::this_thread::yield(); - printf("Thread yeild\n"); + //printf("Gameloop\n"); + //std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + //printf("Thread yeild\n"); lua_getglobal(L,"GAME");//{} lua_getfield(L,-1,"tick");//{},function_tick() - printf("Found game tick\n"); if(!lua_isnil(L,-1)){ + //printf("Found game tick\n"); lua_call(L,0,0); lua_pop(L,1); }else{ + //printf("Did not find tick function\n"); lua_pop(L,2); } - printf("End of server gameloop\n"); - }while(true); + //printf("End of server gameloop\n"); + }while(game_active); phys_shutdown(); + printf("Goodbye\n"); return 0; } diff --git a/src/shared/lua_api/load_net.cpp b/src/shared/lua_api/load_net.cpp index 4b8475f..b6e95bc 100644 --- a/src/shared/lua_api/load_net.cpp +++ b/src/shared/lua_api/load_net.cpp @@ -7,9 +7,10 @@ The number values below are only for refrence. You should use net.PAIR, net.BUS, ect. @module net @usage - local s = net.newsocket() + --Server + local s = net.newsocket(net.REP) s:bind("tcp://127.0.0.1:8765") - s:receive("ping",function(stream) + s:receive(function(stream) local message = stream:readstring() s:send("pong",function(stream) stream:writestring(message .. " world!") @@ -17,11 +18,13 @@ ect. end) @usage - local c = net.newsocket() - c:receive("pong",function(stream) + --Client + local c = net.newsocket(net.REQ) + c:connect("tcp://127.0.0.1:8765") + c:receive(function(stream) print(stream:readstring()) end) - c:send("ping",function(stream) + c:send(function(stream) stream:writestring("Hello,") end) */ @@ -36,27 +39,29 @@ extern "C" { #include #include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "load_net.hpp" #include +#include #include "stream.hpp" /*** @@ -72,8 +77,18 @@ it just sent. */ /*** +Publish protocol. +The first half of the pub/sub protocol. @field PUB 3 +*/ + +/*** +Subscribe protocol +The second half of the pub/sub protocol. @field SUB 4 +*/ + +/*** @field PULL 5 @field PUSH 6 @field REQ 7 @@ -92,8 +107,6 @@ it just sent. #define RESPOND 9 #define SURVEY 10 -std::map netfuncs; - //Some defines for things that the library dosn't have @@ -277,49 +290,186 @@ int lstream_writestring(lua_State* L){ return 0; } -void gameloop_net(lua_State* L){ - //printf("Doing net of gameloop\n"); - for(std::map::iterator it = netfuncs.begin(); it != netfuncs.end(); ++it){ - //printf("In for socket %d\n"); - //char* buf = NULL; - //size_t size; - //int err = nng_recv(*(it->first), &buf, &size, NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC); - nng_msg *msgp; - int err = nng_recvmsg(*(it->first), &msgp, NNG_FLAG_NONBLOCK); +bool socket_can_receive(int type){ + switch(type){ + case PAIR: + case BUS: + case SUB: + case PULL: + case REQ: + case REP: + case RESPOND: + case SURVEY: + return true; + default: + return false; + } +} + +//socket:block_recv() +int block_recv(lua_State *L){//{socket} + lua_getfield(L,-1,"fd");//{socket},ud_socket + nng_socket *socket = (nng_socket*)lua_touserdata(L,-1); + lua_pop(L,2);// + nng_msg *msgp; + int err = nng_recvmsg(*socket,&msgp,0); + if(err){ + printf("Net error: %s\n\t\n",nng_strerror(err)); + lua_pushstring(L,"Error while receving message:");//Err + lua_pushstring(L,nng_strerror(err));//Err,msg + lua_concat(L,2);//Full_err + lua_error(L); + }else{ char* buf = (char*)nng_msg_body(msgp); size_t size = nng_msg_len(msgp); - //printf("Got bytes: %d EAGAIN:%d\n",bytes,EAGAIN); - if(err != 0 && err != NNG_EAGAIN){ - printf("Net error: %s\n\t err: %d\n\teagain:%d\n",nng_strerror(err),err,NNG_EAGAIN); - //lua_pushstring(L,"Failed to receive"); - //lua_error(L); - }else if(err == NNG_EAGAIN){ - //do nothing + struct stream* stream = stream_create(); + stream->length = size; + stream->data = buf; + //stream_print(stream); + lua_newtable(L);//{} + lua_pushlightuserdata(L,stream);//{},ud_stream + lua_setfield(L,-2,"data");//{data=stream} + luaL_getmetatable(L,"net.stream");//{data=stream},{net.stream} + lua_setmetatable(L,-2);//{stream} + } + return 1; +} + +void gameloop_net(lua_State* L){ + //printf("Doing net of gameloop,starting with %d args\n",lua_gettop(L)); + //printf("Got net\n"); + lua_getglobal(L,"net");//{net} + lua_getfield(L,-1,"sockets");//{net},{sockets} + lua_pushnil(L);//{net},{sockets},nil + //printf("Found sockets\n"); + while(lua_next(L,-2) != 0){ + //printf("Got first socket value\n"); + //{net},{sockets},{socket},true + //printf("%s - %s\n",lua_typename(L,lua_type(L,-2)),lua_typename(L,lua_type(L,-1))); + lua_getfield(L,-2,"fd");//{net},{sockets},{socket},true,fd + nng_socket *socket = (nng_socket*)lua_touserdata(L,-1); + lua_getfield(L,-3,"n");//{net},{sockets},{socket},true,fd,type + int stype = lua_tonumber(L,-1); + //printf("Got a socket of type %d\n",stype); + lua_pop(L,3);//{net},{sockets},{socket}//Keep key for next iteration of lua_next() + if(!socket_can_receive(stype)){ + //printf("Socket cannot receive, breaking!\n"); + continue; + } + //printf("About to push errorfunc\n"); + pusherrorfunc(L);//{net},{sockets},{socket},errfunc() + //printf("Done pushing errorfunc\n"); + lua_getfield(L,-2,"receive");//{net},{sockets},{socket},errfunc(),(socket.receive | nil) + //printf("Got field\n"); + if(lua_isnil(L,-1)){//Make sure we have a receive + //printf("Listen-able socket type %d has no .receive method\n",stype); + lua_pop(L,2); + continue; + } + //{net},{sockets},{socket},socket.receive + //printf("Right before recv\n"); + nng_msg *msgp; + //printf("About to recvmsg(), socket: %p, msgp: %p\n",socket,msgp); + int err = nng_recvmsg(*socket,&msgp,NNG_FLAG_NONBLOCK); + //size_t recvsize; + //char *buf; + //int err = nng_recv(*socket,&buf,&recvsize,NNG_FLAG_NONBLOCK); + //printf("Done with recvmsg() err: %d:\n",err); + if(err){ + switch(err){ + case NNG_EAGAIN: break; + case NNG_ESTATE: + if(stype == REQ) break; + default: + printf("Net error: %s\n\tSocket type:%d\n",nng_strerror(err),stype); + lua_pushstring(L,"Error while receving message:"); + lua_pushstring(L,nng_strerror(err)); + lua_concat(L,2); + lua_error(L); + } + lua_pop(L,2); }else{ - //find how long until the first null character + //printf("Actually receving message\n"); + char* buf = (char*)nng_msg_body(msgp); + //printf("Got message body\n"); + size_t size = nng_msg_len(msgp); + //size_t size = recvsize; + //printf("Got mesage body\n"); struct stream* stream = stream_create(); stream->length = size; stream->data = buf; - stream_print(stream); - int f = it->second; - if(f == -1){//not set yet - lua_pushstring(L,"Got message for a socket without a receiving function"); - lua_error(L); - } - lua_rawgeti(L,LUA_REGISTRYINDEX,f);//function(stream) - lua_newtable(L);//function(stream),{} - lua_pushlightuserdata(L,stream);//func,{},ud_stream - lua_setfield(L,-2,"data");//func,{data=stream} - luaL_getmetatable(L,"net.stream");//func,{data=stream} - lua_setmetatable(L,-2);//func,{stream} - lua_call(L,1,0);// + //stream_print(stream); + //printf("Created stream and everything\n"); + + lua_pushvalue(L,-4);//{net},{sockets},{socket},errfunc(),socket.receive(),{socket},{} + lua_newtable(L);//{net},{sockets},{socket},errfunc(),socket.receive(),{socket},{} + lua_pushlightuserdata(L,stream);//{net},{sockets},{socket},errfunc(),socket.receive(),{socket},{},ud_stream + lua_setfield(L,-2,"data");//{net},{sockets},{socket},errfunc(),socket.receive(),{socket},{data=stream} + luaL_getmetatable(L,"net.stream");//{net},{sockets},{socket},errfunc(),socket.receive(),{socket},{data=stream},{net.stream} + lua_setmetatable(L,-2);//{net},{sockets},{socket},errfunc(),socket.receive(),{socket},{stream} + //printf("About to call receive function\n"); + lua_pcall(L,2,0,-4);//{net},{sockets},{socket},errfunc() + lua_pop(L,1); + //printf("Finished calling receive function\n"); //printf("Finished calling gameloop, buf is %p, size is %zu\n",buf,size); nng_msg_free(msgp); - printf("called nn_freemsg\n"); + //nng_free(buf,size); + //printf("called nn_freemsg\n"); free(stream);//We manually set stream->data so free_stream would crash here - printf("Called free on stream\n"); + //printf("Called free on stream\n"); } + } + //printf("There are %d items left on the lua stack\n",lua_gettop(L)); + lua_pop(L,2); + //for(std::map::iterator it = netfuncs.begin(); it != netfuncs.end(); ++it){ + ////printf("In for socket %p\n",(void*)(it->first)); + ////char* buf = NULL; + ////size_t size; + ////int err = nng_recv(*(it->first), &buf, &size, NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC); + //nng_msg *msgp; + ////printf("About to recvmsg()\n"); + //int err = nng_recvmsg(*(it->first), &msgp, NNG_FLAG_NONBLOCK); + ////printf("Done recvmsg()\n"); + ////printf("Got bytes: %d EAGAIN:%d\n",bytes,EAGAIN); + //if(err != 0 && err != NNG_EAGAIN){ + //printf("Net error: %s\n\t err: %d\n\teagain:%d\n",nng_strerror(err),err,NNG_EAGAIN); + ////lua_pushstring(L,"Failed to receive"); + ////lua_error(L); + //}else if(err == NNG_EAGAIN){ + ////printf("EAGAIN\n"); + ////do nothing + //}else{ + //printf("Calling function with stream\n"); + //char* buf = (char*)nng_msg_body(msgp); + //printf("Got msg body\n"); + //size_t size = nng_msg_len(msgp); + //printf("Got msg size\n"); + ////find how long until the first null character + //struct stream* stream = stream_create(); + //stream->length = size; + //stream->data = buf; + //stream_print(stream); + //int f = it->second; + //if(f == -1){//not set yet + //lua_pushstring(L,"Got message for a socket without a receiving function"); + //lua_error(L); + //} + //lua_rawgeti(L,LUA_REGISTRYINDEX,f);//function(stream) + //lua_newtable(L);//function(stream),{} + //lua_pushlightuserdata(L,stream);//func,{},ud_stream + //lua_setfield(L,-2,"data");//func,{data=stream} + //luaL_getmetatable(L,"net.stream");//func,{data=stream} + //lua_setmetatable(L,-2);//func,{stream} + //lua_call(L,1,0);// + ////printf("Finished calling gameloop, buf is %p, size is %zu\n",buf,size); + //nng_msg_free(msgp); + //printf("called nn_freemsg\n"); + //free(stream);//We manually set stream->data so free_stream would crash here + //printf("Called free on stream\n"); + //} + //} + //printf("Done with net game loop\n"); } /*** @@ -348,7 +498,7 @@ int bindsocket(lua_State*L){ } lua_pushlightuserdata(L,fd);//{self},endpoint lua_setfield(L,-2,"endpoint");//{self} - + printf("Done binding socket\n"); return 0; } @@ -415,27 +565,51 @@ int send(lua_State* L){ */ //LUA: //socket:receive(function(stream)) -int netreceive(lua_State* L){ - int func = luaL_ref(L,LUA_REGISTRYINDEX);//{socket} - lua_getfield(L,-1,"fd");//{socket},fd - nng_socket *fd = (nng_socket*)lua_touserdata(L,-1);//{socket},fd - lua_pop(L,2);// - netfuncs[fd] = func;// - return 0; -} +//int netreceive(lua_State* L){ + //if(lua_type(L,-2) != LUA_TTABLE){ + //lua_pushstring(L,"Expected argument #1 to socket.receive to be socket"); + //lua_error(L); + //} + //printf("two\n"); + //if(lua_type(L,-1) != LUA_TFUNCTION){ + //lua_pushstring(L,"Expected argument #2 to socket.receive to be function"); + //lua_error(L); + //} + //lua_getfield(L,-1,"fd");//{socket},fd + //nng_socket *fd = (nng_socket*)lua_touserdata(L,-1);//{socket},fd + //lua_pop(L,1);//{socket} + //lua_getfield(L,-1,"n");//{socket},type + //int sockettype = lua_tonumber(L,-1); + //lua_pop(L,2);// + //switch(sockettype + //netfuncs[fd] = func;// + //nettypes[fd] = sockettype; + //return 0; +//} /*** @function socket:close() Closes the socket */ -//socket:close() -int netclose(lua_State* L){ - lua_getfield(L,-1,"fd"); - nng_socket *fd = (nng_socket*)lua_touserdata(L,-1); - lua_pop(L,2); +//socket:close() :: nil +int netclose(lua_State* L){//{socket} + lua_getfield(L,-1,"fd");//{socket},fd + nng_socket *fd = (nng_socket*)lua_touserdata(L,-1);//{socket},fd + lua_pop(L,1);//{socket} nng_close(*fd); - netfuncs.erase(fd); free(fd); + + lua_getglobal(L,"net");//{socket},{net} + lua_getfield(L,-1,"sockets");//{socket},{net},{sockets} + lua_pushvalue(L,-3);//{socket},{net},{sockets},{socket} + lua_pushnil(L);//{socket},{net},{sockets},{socket},nil + lua_settable(L,-3);//{socket},{net},{sockets} + lua_pop(L,2);//{socket} + + lua_pushboolean(L,1);//{socket},true + lua_setfield(L,-2,"closed");//{socket} + lua_pop(L,1); + return 0; } @@ -460,20 +634,20 @@ int socketFactory(lua_State*L){ int type = lua_tonumber(L,-1); lua_pop(L,1); - printf("Creating a socket with type: %d, NNG_PAIR:%d\n",type,PAIR); + printf("Creating a socket with type: %d, NNG_PAIR:%d, NNG_BUS:%d\n",type,PAIR,BUS); nng_socket *socket = (nng_socket*) malloc(sizeof(nng_socket)); int err; switch(type){ - case PAIR: err = nng_pair1_open(socket); break; - case BUS : err = nng_bus0_open(socket); break; - case PUB : err = nng_pub0_open(socket); break; - case SUB : err = nng_sub0_open(socket); break; - case PULL: err = nng_pull0_open(socket); break; - case PUSH: err = nng_push0_open(socket); break; - case REQ : err = nng_req0_open(socket); break; - case REP : err = nng_rep0_open(socket); break; - case SURVEY : err = nng_surveyor0_open(socket); break; - case RESPOND : err = nng_respondent0_open(socket); break; + case PAIR: err = nng_pair_open(socket); break; + case BUS : err = nng_bus_open(socket); break; + case PUB : err = nng_pub_open(socket); break; + case SUB : err = nng_sub_open(socket); break; + case PULL: err = nng_pull_open(socket); break; + case PUSH: err = nng_push_open(socket); break; + case REQ : err = nng_req_open(socket); break; + case REP : err = nng_rep_open(socket); break; + case SURVEY : err = nng_surveyor_open(socket); break; + case RESPOND : err = nng_respondent_open(socket); break; default: printf("Unknown socket type: %d",type); break; @@ -489,9 +663,20 @@ int socketFactory(lua_State*L){ lua_newtable(L);//{} lua_pushlightuserdata(L,socket);//{},c lua_setfield(L,-2,"fd");//{fd=c} + lua_pushnumber(L,type);//{fd=c},type + lua_setfield(L,-2,"n");//{fd=c,n=type} - luaL_getmetatable(L,"net.pair_socket");//{},{m_net.pair_socket} + printf("Metatable set\n"); + luaL_getmetatable(L,"net.pair_socket");//{fd=c,n=type},{m_net.pair_socket} lua_setmetatable(L,-2);//{socket} + + lua_getglobal(L,"net");//{socket},{net} + lua_getfield(L,-1,"sockets");//{socket},{net},{sockets} + lua_pushvalue(L,-3);//{socket},{net},{sockets},{socket} + lua_pushboolean(L,1);//{socket},{net},{sockets},{socket},true + lua_settable(L,-3);//{socket},{net},{sockets} + lua_pop(L,2);//{socket} + printf("Finished making the socket, returning\n"); return 1; } @@ -516,7 +701,8 @@ static const struct luaL_Reg pair_socket_m[] = { {"bind", bindsocket}, {"connect", connectsocket}, {"send",send}, - {"receive", netreceive}, + {"block_recv",block_recv}, + //{"receive", netreceive}, {"close",netclose}, {NULL,NULL} }; @@ -538,6 +724,8 @@ void loadNetLibs(lua_State* L){ //A table to hold all our net funcs lua_newtable(L);//{} + lua_newtable(L);//{},{} + lua_setfield(L,-2,"sockets");//{sockets = {}} //Push some enums //Protocols diff --git a/src/shared/lua_api/load_phys.cpp b/src/shared/lua_api/load_phys.cpp index 7580e99..db35f37 100644 --- a/src/shared/lua_api/load_phys.cpp +++ b/src/shared/lua_api/load_phys.cpp @@ -6,7 +6,8 @@ void load_physfuncs(lua_State* L){ lua_newtable(L);//{} - lua_setglobal(L,"phys"); + lua_setglobal(L,"phys");// + lua_getglobal(L,"phys"); set_const(L,BT_DISABLE_WORLD_GRAVITY); set_const(L,BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT); set_const(L,BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD); diff --git a/src/shared/lua_api/stream.hpp b/src/shared/lua_api/stream.hpp index 74a0e69..ff48945 100644 --- a/src/shared/lua_api/stream.hpp +++ b/src/shared/lua_api/stream.hpp @@ -1,5 +1,5 @@ #include -#include +#include //Char is not definitvely a byte, read the fucking standard #define byte char -- cgit v1.2.3-70-g09d2