修复 线程isdebug
This commit is contained in:
parent
237dc618fc
commit
509b5416ab
|
@ -182,20 +182,21 @@ static int LUA_StateThread(void* data)
|
|||
|
||||
size_t coresize = info->coresize;
|
||||
const char* ggecore = info->ggecore;
|
||||
|
||||
int haserror = 1;
|
||||
SDL_LockMutex(mutex);
|
||||
if (luaL_loadbuffer(L, ggecore,coresize,"ggelua.lua")== LUA_OK){
|
||||
lua_pushstring(L,info->entry);
|
||||
lua_pushboolean(L,1);//是否虚拟机
|
||||
|
||||
if (lua_pcall(L, 2, 0, 0)== LUA_OK){
|
||||
if (lua_getglobal(L, "main") == LUA_TFUNCTION) {//loop
|
||||
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
|
||||
printf("%s\n", lua_tostring(L, -1));
|
||||
}
|
||||
haserror = 0;
|
||||
if (lua_getglobal(L, "main") == LUA_TFUNCTION)//loop
|
||||
haserror = lua_pcall(L, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (haserror) {
|
||||
printf("%s\n", lua_tostring(L, -1));
|
||||
}
|
||||
SDL_DestroyMutex(mutex);
|
||||
lua_close(L);
|
||||
SDL_free(info);
|
||||
|
@ -204,12 +205,14 @@ static int LUA_StateThread(void* data)
|
|||
//主要用于服务端创建
|
||||
static int LUA_NewState(lua_State *L)
|
||||
{
|
||||
|
||||
if (lua_getfield(L, LUA_REGISTRYINDEX, "ggecore")== LUA_TSTRING)
|
||||
{
|
||||
THREADINFO* info = (THREADINFO*)SDL_malloc(sizeof(THREADINFO));
|
||||
info->entry = luaL_checkstring(L, 1);
|
||||
info->ggecore = lua_tolstring(L, -1, &info->coresize);
|
||||
|
||||
info->isdebug = lua_getfield(L, LUA_REGISTRYINDEX, "ggepack") != LUA_TSTRING;
|
||||
lua_pop(L, 1);
|
||||
SDL_Thread* t = SDL_CreateThread(LUA_StateThread, NULL, (void*)info);
|
||||
lua_pushboolean(L, t != NULL);
|
||||
if (!t)
|
||||
|
|
Loading…
Reference in New Issue