| 1796 | } |
| 1797 | |
| 1798 | void Core::onStateChange(color_ostream &out, state_change_event event) |
| 1799 | { |
| 1800 | using df::global::gametype; |
| 1801 | static md5wrapper md5w; |
| 1802 | static std::string ostype; |
| 1803 | |
| 1804 | if (!ostype.size()) |
| 1805 | { |
| 1806 | ostype = "unknown OS"; |
| 1807 | if (vinfo) { |
| 1808 | switch (vinfo->getOS()) |
| 1809 | { |
| 1810 | case OS_WINDOWS: |
| 1811 | ostype = "Windows"; |
| 1812 | break; |
| 1813 | case OS_APPLE: |
| 1814 | ostype = "OS X"; |
| 1815 | break; |
| 1816 | case OS_LINUX: |
| 1817 | ostype = "Linux"; |
| 1818 | break; |
| 1819 | default: |
| 1820 | break; |
| 1821 | } |
| 1822 | } |
| 1823 | } |
| 1824 | |
| 1825 | switch (event) |
| 1826 | { |
| 1827 | case SC_CORE_INITIALIZED: |
| 1828 | { |
| 1829 | loadModScriptPaths(out); |
| 1830 | Lua::CallLuaModuleFunction(con, "helpdb", "refresh"); |
| 1831 | Lua::CallLuaModuleFunction(con, "script-manager", "reload"); |
| 1832 | break; |
| 1833 | } |
| 1834 | case SC_WORLD_LOADED: |
| 1835 | { |
| 1836 | perf_counters.reset(); |
| 1837 | unpaused_ms = 0; |
| 1838 | Persistence::Internal::load(out); |
| 1839 | plug_mgr->doLoadWorldData(out); |
| 1840 | loadModScriptPaths(out); |
| 1841 | auto L = DFHack::Core::getInstance().getLuaState(); |
| 1842 | Lua::StackUnwinder top(L); |
| 1843 | Lua::CallLuaModuleFunction(con, "script-manager", "reload", std::make_tuple(true)); |
| 1844 | if (world && world->cur_savegame.save_dir.size()) |
| 1845 | { |
| 1846 | std::string save_dir = "save/" + world->cur_savegame.save_dir; |
| 1847 | std::string evtlogpath = save_dir + "/events-dfhack.log"; |
| 1848 | std::ofstream evtlog; |
| 1849 | evtlog.open(evtlogpath, std::ios_base::app); // append |
| 1850 | if (evtlog.fail()) |
| 1851 | { |
| 1852 | if (DFHack::Filesystem::isdir(save_dir)) |
| 1853 | out.printerr("Could not append to {}\n", evtlogpath); |
| 1854 | } |
| 1855 | else |
nothing calls this directly
no test coverage detected