diff --git a/src/world/renderer.cc b/src/world/renderer.cc index 13a6963..39b7519 100644 --- a/src/world/renderer.cc +++ b/src/world/renderer.cc @@ -50,8 +50,22 @@ void renderer_base::draw (const s_int16 & x, const s_int16 & y, const render_inf // draw all pieces of the shadow for (std::list::const_iterator area = shdw->Area.begin(); area != shdw->Area.end(); area++) { + // Make sure the area falls withing the object + s_int16 area_x = area->x(); + u_int16 area_length = area->length(); + if(area_x + area_length < obj.x() + obj.Shape->x()) + continue; + if(area_x < obj.x() + obj.Shape->x()) { + area_length -= obj.x() + obj.Shape->x() - area_x; + area_x = obj.x() + obj.Shape->x(); + } + if(area_x > obj.x() + obj.Shape->x() + obj.Shape->length()) + continue; + if(area_x + area_length > obj.x() + obj.Shape->x() + obj.Shape->length()) + area_length = obj.x() + obj.Shape->x() + obj.Shape->length() - area_x; + // relocate area to mapview position - gfx::drawing_area part (x + area->x(), y + area->y() - (obj.z() + obj.Shape->height()), area->length(), area->height()); + gfx::drawing_area part (x + area_x, y + area->y() - (obj.z() + obj.Shape->height()), area_length, area->height()); // clip with mapview ... just in case part.assign_drawing_area (&da); // render shadow