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

Method parseBuildings

plugins/rendermax/renderer_light.cpp:1096–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094 return 0;
1095}
1096int lightingEngineViewscreen::parseBuildings(lua_State* L)
1097{
1098 auto engine= (lightingEngineViewscreen*)lua_touserdata(L, 1);
1099 engine->buildingDefs.clear();
1100 Lua::StackUnwinder unwinder(L);
1101 lua_getfield(L,2,"buildings");
1102 if(!lua_istable(L,-1))
1103 {
1104 luaL_error(L,"Buildings table not found.");
1105 return 0;
1106 }
1107 lua_pushnil(L);
1108 while (lua_next(L, -2) != 0) {
1109 int type=lua_tonumber(L,-2);
1110 if(!lua_istable(L,-1))
1111 {
1112 luaL_error(L,"Broken building definitions.");
1113 }
1114 //os->print("Processing type:%d\n",type);
1115 lua_pushnil(L);
1116 while (lua_next(L, -2) != 0) {
1117 int subtype=lua_tonumber(L,-2);
1118 //os->print("\tProcessing subtype:%d\n",index);
1119 lua_pushnil(L);
1120 while (lua_next(L, -2) != 0) {
1121 int custom=lua_tonumber(L,-2);
1122 //os->print("\tProcessing custom:%d\n",index);
1123 buildingLightDef current;
1124 current.light=lua_parseMatDef(L);
1125 engine->buildingDefs[std::make_tuple(type,subtype,custom)]=current;
1126 GETLUAFLAG(current.poweredOnly,"poweredOnly");
1127 GETLUAFLAG(current.useMaterial,"useMaterial");
1128
1129 lua_getfield(L,-1,"size");
1130 current.size=luaL_optnumber(L,-1,1);
1131 lua_pop(L,1);
1132
1133 lua_getfield(L,-1,"thickness");
1134 current.thickness=luaL_optnumber(L,-1,1);
1135 lua_pop(L,1);
1136
1137 lua_pop(L, 1);
1138 }
1139
1140 lua_pop(L, 1);
1141 }
1142 lua_pop(L, 1);
1143 }
1144 lua_pop(L,1);
1145 return 0;
1146}
1147void lightingEngineViewscreen::defaultSettings()
1148{
1149 matAmbience=matLightDef(rgbf(0.85f,0.85f,0.85f));

Callers

nothing calls this directly

Calls 8

lua_touserdataFunction · 0.85
lua_getfieldFunction · 0.85
luaL_errorFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_parseMatDefFunction · 0.85
luaL_optnumberFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected