MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / Init

Method Init

LuaSTGPlus/AppFrame.cpp:1232–1458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1230}
1231
1232bool AppFrame::Init()LNOEXCEPT
1233{
1234 LASSERT(m_iStatus == AppStatus::NotInitialized);
1235
1236 LINFO("开始初始化 版本: %s", LVERSION);
1237 m_iStatus = AppStatus::Initializing;
1238
1239 Scope tSplashWindowExit([this]() {
1240 m_SplashWindow.HideSplashWindow();
1241 });
1242
1243 //////////////////////////////////////// Lua初始化部分
1244 LINFO("开始初始化Lua虚拟机 版本: %m", LVERSION_LUA);
1245 L = lua_open();
1246 if (!L)
1247 {
1248 LERROR("无法初始化Lua虚拟机");
1249 return false;
1250 }
1251 if (0 != luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_ON))
1252 LWARNING("无法启动JIT模式");
1253
1254 lua_gc(L, LUA_GCSTOP, 0); // 初始化时关闭GC
1255
1256 luaL_openlibs(L); // 内建库
1257 luaopen_lfs(L); // 文件系统库
1258 luaopen_cjson(L); // CJSON库
1259 ColorWrapper::Register(L); // 颜色对象
1260 RandomizerWrapper::Register(L); // 随机数发生器
1261 BentLaserDataWrapper::Register(L); // 曲线激光
1262 BuiltInFunctionWrapper::Register(L); // 内建函数库
1263
1264 lua_gc(L, LUA_GCRESTART, -1); // 重启GC
1265
1266 // 为对象池分配空间
1267 LINFO("初始化对象池 上限=%u", LGOBJ_MAXCNT);
1268 try
1269 {
1270 m_GameObjectPool = make_unique<GameObjectPool>(L);
1271 }
1272 catch (const bad_alloc&)
1273 {
1274 LERROR("无法为对象池分配足够内存");
1275 return false;
1276 }
1277
1278 // 设置命令行参数
1279 regex tDebuggerPattern("\\/debugger:(\\d+)");
1280 lua_getglobal(L, "lstg"); // t
1281 lua_newtable(L); // t t
1282 for (int i = 0, c = 1; i < __argc; ++i)
1283 {
1284 cmatch tMatch;
1285 if (regex_match(__argv[i], tMatch, tDebuggerPattern))
1286 {
1287#if (defined LDEVVERSION) || (defined LDEBUG)
1288 // 创建调试器
1289 if (!m_DebuggerClient)

Callers 1

WinMainFunction · 0.80

Calls 7

luaopen_lfsFunction · 0.85
luaopen_cjsonFunction · 0.85
HideSplashWindowMethod · 0.80
LoadFileMethod · 0.80
GetRendererMethod · 0.80
GetSoundSysMethod · 0.80
CreateRenderTargetMethod · 0.80

Tested by

no test coverage detected