//static void Faction::Init() { lua_State *L = luaL_newstate(); LUA_DEBUG_START(L); pi_lua_open_standard_base(L); LuaConstants::Register(L); LUA_DEBUG_CHECK(L, 0); RegisterFactionsAPI(L); LUA_DEBUG_CHECK(L, 0); pi_lua_dofile_recursive(L, "factions"); LUA_DEBUG_END(L, 0); lua_close(L); printf("Number of factions added: " SIZET_FMT "\n", s_factions.size()); StarSystem::ShrinkCache(); // clear the star system cache of anything we used for faction generation }
void FactionsDatabase::Init() { lua_State *L = luaL_newstate(); LUA_DEBUG_START(L); pi_lua_open_standard_base(L); LuaConstants::Register(L); LUA_DEBUG_CHECK(L, 0); RegisterFactionsAPI(L); LUA_DEBUG_CHECK(L, 0); pi_lua_dofile_recursive(L, "factions"); LUA_DEBUG_END(L, 0); lua_close(L); Output("Number of factions added: " SIZET_FMT "\n", m_factions.size()); ClearHomeSectors(); Pi::FlushCaches(); // clear caches of anything we used for faction generation while (!m_missingFactionsMap.empty()) { const std::string& factionName = m_missingFactionsMap.begin()->first; std::list<CustomSystem*>& csl = m_missingFactionsMap.begin()->second; while (!csl.empty()) { CustomSystem* cs = csl.front(); // FIXME: How to signal missing faction? fprintf(stderr, "Custom system %s referenced unknown faction %s\n", cs->name.c_str(), factionName.c_str()); csl.pop_front(); } m_missingFactionsMap.erase(m_missingFactionsMap.begin()); } m_initialized = true; SetHomeSectors(); }