diff options
| author | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
| commit | 0d2de2ba9c616862d7881f089382db772d034f89 (patch) | |
| tree | 5fc58b63c593e2ac17f3353b50318c299f643390 /src/server | |
| parent | c9db55cdc2f69c3dc7aefabe0cc828a64e377024 (diff) | |
| download | brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.gz brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.bz2 brokengine-0d2de2ba9c616862d7881f089382db772d034f89.zip | |
Various updates
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/main.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
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 <stdio.h> #include <stdlib.h> +#include <assert.h> extern "C" { #include <lua.h> #include <lauxlib.h> @@ -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; |
