@@ -168,22 +168,22 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
168
168
EmergeManager *emerge = getServer (L)->getEmergeManager ();
169
169
ManualMapVoxelManipulator *vm = o->vm ;
170
170
171
- v3s16 p1 = lua_istable (L, 2 ) ? read_v3s16 (L, 2 ) : vm->m_area .MinEdge ;
172
- v3s16 p2 = lua_istable (L, 3 ) ? read_v3s16 (L, 3 ) : vm->m_area .MaxEdge ;
173
- sortBoxVerticies (p1, p2);
174
- if (!vm->m_area .contains (VoxelArea (p1, p2)))
171
+ v3s16 yblock = v3s16 (0 , 1 , 0 ) * MAP_BLOCKSIZE;
172
+ v3s16 fpmin = vm->m_area .MinEdge ;
173
+ v3s16 fpmax = vm->m_area .MaxEdge ;
174
+ v3s16 pmin = lua_istable (L, 2 ) ? read_v3s16 (L, 2 ) : fpmin + yblock;
175
+ v3s16 pmax = lua_istable (L, 3 ) ? read_v3s16 (L, 3 ) : fpmax - yblock;
176
+
177
+ sortBoxVerticies (pmin, pmax);
178
+ if (!vm->m_area .contains (VoxelArea (pmin, pmax)))
175
179
throw LuaError (" Specified voxel area out of VoxelManipulator bounds" );
176
180
177
181
Mapgen mg;
178
182
mg.vm = vm;
179
183
mg.ndef = ndef;
180
184
mg.water_level = emerge->params .water_level ;
181
185
182
- // Mapgen::calcLighting assumes the coordinates of
183
- // the central chunk; correct for this
184
- mg.calcLighting (
185
- p1 + v3s16 (1 , 1 , 1 ) * MAP_BLOCKSIZE,
186
- p2 - v3s16 (1 , 1 , 1 ) * MAP_BLOCKSIZE);
186
+ mg.calcLighting (pmin, pmax, fpmin, fpmax);
187
187
188
188
return 0 ;
189
189
}
@@ -205,19 +205,18 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
205
205
206
206
ManualMapVoxelManipulator *vm = o->vm ;
207
207
208
- v3s16 p1 = lua_istable (L, 3 ) ? read_v3s16 (L, 3 ) : vm->m_area .MinEdge ;
209
- v3s16 p2 = lua_istable (L, 4 ) ? read_v3s16 (L, 4 ) : vm->m_area .MaxEdge ;
210
- sortBoxVerticies (p1, p2);
211
- if (!vm->m_area .contains (VoxelArea (p1, p2)))
208
+ v3s16 yblock = v3s16 (0 , 1 , 0 ) * MAP_BLOCKSIZE;
209
+ v3s16 pmin = lua_istable (L, 3 ) ? read_v3s16 (L, 3 ) : vm->m_area .MinEdge + yblock;
210
+ v3s16 pmax = lua_istable (L, 4 ) ? read_v3s16 (L, 4 ) : vm->m_area .MaxEdge - yblock;
211
+
212
+ sortBoxVerticies (pmin, pmax);
213
+ if (!vm->m_area .contains (VoxelArea (pmin, pmax)))
212
214
throw LuaError (" Specified voxel area out of VoxelManipulator bounds" );
213
215
214
216
Mapgen mg;
215
217
mg.vm = vm;
216
218
217
- mg.setLighting (
218
- p1 + v3s16 (0 , 1 , 0 ) * MAP_BLOCKSIZE,
219
- p2 - v3s16 (0 , 1 , 0 ) * MAP_BLOCKSIZE,
220
- light);
219
+ mg.setLighting (light, pmin, pmax);
221
220
222
221
return 0 ;
223
222
}
0 commit comments