From 0d2de2ba9c616862d7881f089382db772d034f89 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 27 Oct 2019 17:25:16 -0400 Subject: Various updates --- src/server/main.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/main.cpp b/src/server/main.cpp index c4c4d8e..8817329 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -1,6 +1,7 @@ #include #include +#include extern "C" { #include #include @@ -66,24 +67,34 @@ int main (int argc, char *argv[]){ putenv(envstr); //printf("Put lua path\n"); L = luaL_newstate(); + assert(lua_gettop(L) == 0); //printf("Created lua state\n"); //lua_newtable(L);//{} //lua_setglobal(L,"GAME");// + assert(lua_gettop(L) == 0); load_gamefuncs(L); + assert(lua_gettop(L) == 0); printf("Created global table\n"); + assert(lua_gettop(L) == 0); phys_genesis(); printf("Started phys\n"); + assert(lua_gettop(L) == 0); luaL_openlibs(L); printf("Opened standard libs\n"); + assert(lua_gettop(L) == 0); loadLLibs(L); printf("Opened aux libs\n"); + assert(lua_gettop(L) == 0); loadNetLibs(L); printf("Opened net libs\n"); + assert(lua_gettop(L) == 0); load_physfuncs(L); printf("Opened phys libs\n"); + assert(lua_gettop(L) == 0); load_iofuncs(L); printf("About to push error func\n"); + assert(lua_gettop(L) == 0); pusherrorfunc(L);//errfunc printf("pushed error func\n"); size_t init_file_path_len = snprintf(NULL,0,"%s/init.lua",path); @@ -104,14 +115,19 @@ int main (int argc, char *argv[]){ } //errfunc,initfile() printf("Loaded file\n"); - lua_pcall(L,0,0,-2); + lua_pcall(L,0,0,-2);//errfunc + lua_pop(L,1); + assert(lua_gettop(L) == 0); do{ + assert(lua_gettop(L) == 0); //printf("Start of server gameloop\n"); gameloop(); + assert(lua_gettop(L) == 0); //printf("Gameloop\n"); //std::this_thread::yield(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); //printf("Thread yeild\n"); + assert(lua_gettop(L) == 0); pusherrorfunc(L);//errfunc() lua_getglobal(L,"GAME");//errfunc(),{} lua_getfield(L,-1,"tick");//errfunc(),{},function_tick()? @@ -123,9 +139,12 @@ int main (int argc, char *argv[]){ //printf("Did not find tick function\n"); lua_pop(L,3); } + assert(lua_gettop(L) == 0); //printf("End of server gameloop\n"); }while(game_active); + assert(lua_gettop(L) == 0); phys_shutdown(); + assert(lua_gettop(L) == 0); printf("Goodbye\n"); return 0; -- cgit v1.2.3-70-g09d2