From ee759bd3f0c4bcf8e1d753da00157c4baf513591 Mon Sep 17 00:00:00 2001 From: xiyoo0812 Date: Thu, 25 Apr 2024 23:44:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/quanta/src/execute.cpp | 81 ---------------------------- core/quanta/src/mainlib.cpp | 105 ------------------------------------ core/quanta/src/mainlib.h | 24 --------- 3 files changed, 210 deletions(-) delete mode 100644 core/quanta/src/execute.cpp delete mode 100644 core/quanta/src/mainlib.cpp delete mode 100644 core/quanta/src/mainlib.h diff --git a/core/quanta/src/execute.cpp b/core/quanta/src/execute.cpp deleted file mode 100644 index 540aec56..00000000 --- a/core/quanta/src/execute.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include "mainlib.h" - -int main(int argc, const char* argv[]) -{ - init_quanta(argv[1], argv[2]); - while (true) { - if(run_quanta() != 0) break; - } - return 0; -} - -#ifdef WIN32 -#pragma once -#include -#include -#include -#pragma comment(lib,"DbgHelp.lib") - -class CMiniDump -{ -public: - CMiniDump(void); - virtual ~CMiniDump(void); - -protected: - static BOOL GetModulePath(LPTSTR lpBuf, DWORD dwBufSize); - static LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* ExceptionInfo); -}; - - -CMiniDump::CMiniDump(void) -{ - SetUnhandledExceptionFilter(&CMiniDump::MyUnhandledExceptionFilter); -} - - -CMiniDump::~CMiniDump(void) -{ -} - -LONG WINAPI CMiniDump::MyUnhandledExceptionFilter(EXCEPTION_POINTERS* ExceptionInfo) -{ - TCHAR sModulePath[MAX_PATH] = { 0 }; - GetModulePath(sModulePath, MAX_PATH); - - TCHAR sFileName[MAX_PATH] = { 0 }; - SYSTEMTIME systime = { 0 }; - GetLocalTime(&systime); - _stprintf_s(sFileName, _T("%04d%02d%02d-%02d%02d%02d.dmp"), - systime.wYear, systime.wMonth, systime.wDay, systime.wHour, systime.wMinute, systime.wSecond); - - _tcscat_s(sModulePath, sFileName); - HANDLE lhDumpFile = CreateFile(sModulePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - MINIDUMP_EXCEPTION_INFORMATION loExceptionInfo; - loExceptionInfo.ExceptionPointers = ExceptionInfo; - loExceptionInfo.ThreadId = GetCurrentThreadId(); - loExceptionInfo.ClientPointers = FALSE; - MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), lhDumpFile, MiniDumpNormal, &loExceptionInfo, NULL, NULL); - CloseHandle(lhDumpFile); - - return EXCEPTION_EXECUTE_HANDLER; -} - -BOOL CMiniDump::GetModulePath(LPTSTR lpBuf, DWORD dwBufSize) -{ - TCHAR sModuleName[MAX_PATH] = { 0 }; - GetModuleFileName(NULL, sModuleName, MAX_PATH); - TCHAR* pChar = _tcsrchr(sModuleName, _T('\\')); - if (NULL != pChar) - { - size_t iPos = pChar - sModuleName; - sModuleName[iPos + 1] = _T('\0'); - _tcscpy_s(lpBuf, dwBufSize, sModuleName); - return TRUE; - } - return FALSE; -} - -CMiniDump g_minidump; -#endif \ No newline at end of file diff --git a/core/quanta/src/mainlib.cpp b/core/quanta/src/mainlib.cpp deleted file mode 100644 index 4068585b..00000000 --- a/core/quanta/src/mainlib.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include "mainlib.h" -#include "quanta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int luaopen_lssl(lua_State* L); -int luaopen_lbson(lua_State* L); -int luaopen_ljson(lua_State* L); -int luaopen_luapb(lua_State* L); -int luaopen_lualog(lua_State* L); -int luaopen_luabus(lua_State* L); -int luaopen_lcodec(lua_State* L); -int luaopen_lstdfs(lua_State* L); -int luaopen_ltimer(lua_State* L); -int luaopen_lsqlite(lua_State* L); -int luaopen_lworker(lua_State* L); - -#ifdef __cplusplus -} -#endif - -#ifdef WIN32 -#define tzset _tzset -#endif - -#define QUANTA_ARGS_NUM 2 - -static void luaL_open_worldlibs(lua_State* L) { - luaopen_lssl(L); - luaopen_lbson(L); - luaopen_ljson(L); - luaopen_luapb(L); - luaopen_lualog(L); - luaopen_luabus(L); - luaopen_lcodec(L); - luaopen_lstdfs(L); - luaopen_ltimer(L); - luaopen_lsqlite(L); - luaopen_lworker(L); -} - -quanta_app* q_app = nullptr; - -QUANTA_API int init_quanta(const char* zfile, const char* fconf) { - setlocale(LC_ALL, ""); -#if !(defined(__ORBIS__) || defined(__PROSPERO__)) - tzset(); - system("echo quanta engine init."); -#endif - if (!q_app) { - q_app = new quanta_app(); - //初始化lua扩展 - luaL_open_worldlibs(q_app->L()); - //设置静态库模式 - q_app->set_env("QUANTA_STATIC", "1", 0); - //加载zip文件 - if (!q_app->initzip(zfile)) { - return -1; - } - const char* args[QUANTA_ARGS_NUM]{ "world", fconf}; - //初始化 - q_app->setup(QUANTA_ARGS_NUM, args); - q_app->init(); - } - return 0; -} - -static char buff[1024]; -QUANTA_API const char* call_quanta(const char* func) { - if (q_app) { - auto luakit = q_app->state(); - if (luakit) { - std::string value; - luakit::lua_table quanta = luakit->get("quanta"); - if (quanta.call(func, nullptr, std::tie(value))) { - memset(buff, 0, 1024); - strcpy(buff, value.c_str()); - return buff; - } - } - } - return ""; -} - -QUANTA_API void stop_quanta() { - if (q_app) { - delete q_app; - q_app = nullptr; - } -} - -QUANTA_API int run_quanta() { - if (q_app) {; - if (!q_app->step()) { - delete q_app; - q_app = nullptr; - return -1; - } - return 0; - } - return -2; -} diff --git a/core/quanta/src/mainlib.h b/core/quanta/src/mainlib.h deleted file mode 100644 index 63aaed8c..00000000 --- a/core/quanta/src/mainlib.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#ifdef _MSC_VER -#ifdef QUANTA_EXPORT -#define QUANTA_API _declspec(dllexport) -#else -#define QUANTA_API _declspec(dllimport) -#endif -#else -#define QUANTA_API extern -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -QUANTA_API int run_quanta(); -QUANTA_API void stop_quanta(); -QUANTA_API int init_quanta(const char* zfile, const char* fconf); -QUANTA_API const char* call_quanta(const char* func); - -#ifdef __cplusplus -} -#endif