From e171d21fc5fa8e0b918593ca57860835012085a1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 3 Jun 2016 15:52:48 +0200 Subject: GRAPHICS: Fix FloodFill --- graphics/surface.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'graphics') diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 8e5a22aec6..2fe6a73010 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -524,23 +524,32 @@ void FloodFill::addSeed(int x, int y) { if (!_visited[y * _w + x]) { _visited[y * _w + x] = 1; void *p = _surface->getBasePtr(x, y); + bool changed = false; if (_surface->format.bytesPerPixel == 1) { - if (*((byte *)p) == _oldColor) + if (*((byte *)p) == _oldColor) { *((byte *)p) = _fillColor; + changed = true; + } } else if (_surface->format.bytesPerPixel == 2) { - if (READ_UINT16(p) == _oldColor) + if (READ_UINT16(p) == _oldColor) { WRITE_UINT16(p, _fillColor); + changed = true; + } } else if (_surface->format.bytesPerPixel == 4) { - if (READ_UINT32(p) == _oldColor) + if (READ_UINT32(p) == _oldColor) { WRITE_UINT32(p, _fillColor); + changed = true; + } } else { error("Unsupported bpp in FloodFill"); } - Common::Point *pt = new Common::Point(x, y); + if (changed) { + Common::Point *pt = new Common::Point(x, y); - _queue.push_back(pt); + _queue.push_back(pt); + } } } } -- cgit v1.2.3