MCPcopy Create free account
hub / github.com/DFHack/dfhack / loadSettings

Method loadSettings

plugins/rendermax/renderer_light.cpp:1166–1239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1164 dayColors.push_back(rgbf(0,0,0));
1165}
1166void lightingEngineViewscreen::loadSettings()
1167{
1168 std::string rawFolder;
1169 if(df::global::world->cur_savegame.save_dir!="")
1170 {
1171 rawFolder= "save/" + (df::global::world->cur_savegame.save_dir) + "/";
1172 }
1173 else
1174 {
1175 rawFolder= "dfhack-config/";
1176 }
1177 const std::string settingsfile=rawFolder+"rendermax.lua";
1178
1179 color_ostream_proxy out(Core::getInstance().getConsole());
1180
1181 lua_State* s=DFHack::Lua::Core::State;
1182 lua_newtable(s);
1183 int env=lua_gettop(s);
1184 try{
1185 int ret=luaL_loadfile(s,settingsfile.c_str());
1186 if(ret==LUA_ERRFILE)
1187 {
1188 out.printerr("File not found:{}\n",settingsfile);
1189 lua_pop(s,1);
1190 }
1191 else if(ret==LUA_ERRSYNTAX)
1192 {
1193 out.printerr("Syntax error:\n\t{}\n",lua_tostring(s,-1));
1194 }
1195 else
1196 {
1197 lua_pushvalue(s,env);
1198
1199 if(Lua::SafeCall(out,s,1,0))
1200 {
1201 lua_pushcfunction(s, parseMaterials);
1202 lua_pushlightuserdata(s, this);
1203 lua_pushvalue(s,env);
1204 Lua::SafeCall(out,s,2,0);
1205 out.print("{} materials loaded\n",matDefs.size());
1206
1207 lua_pushcfunction(s, parseSpecial);
1208 lua_pushlightuserdata(s, this);
1209 lua_pushvalue(s,env);
1210 Lua::SafeCall(out,s,2,0);
1211 out.print("{} day light colors loaded\n",dayColors.size());
1212
1213 lua_pushcfunction(s, parseBuildings);
1214 lua_pushlightuserdata(s, this);
1215 lua_pushvalue(s,env);
1216 Lua::SafeCall(out,s,2,0);
1217 out.print("{} buildings loaded\n",buildingDefs.size());
1218
1219 lua_pushcfunction(s, parseCreatures);
1220 lua_pushlightuserdata(s, this);
1221 lua_pushvalue(s,env);
1222 Lua::SafeCall(out,s,2,0);
1223 out.print("{} creatures loaded\n",creatureDefs.size());

Callers 1

enable_hooksFunction · 0.80

Calls 8

lua_gettopFunction · 0.85
lua_pushvalueFunction · 0.85
SafeCallFunction · 0.85
lua_pushlightuserdataFunction · 0.85
c_strMethod · 0.80
printMethod · 0.45
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected