SCI/newgui: finally changed floodfill to behave the same way as sierra sci. Fixes sq3 priority map

svn-id: r45005
This commit is contained in:
Martin Kiewitz 2009-10-13 08:03:09 +00:00
parent 19cacbdb3c
commit 3f914e67a0

View File

@ -570,8 +570,10 @@ void SciGuiPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority,
GuiPort *curPort = _gfx->GetPort();
Common::Stack<Common::Point> stack;
Common::Point p, p1;
byte screenMask = _screen->getDrawingMask(color, priority, control);
byte matchedMask;
int16 w, e, a_set, b_set;
byte screenMask = _screen->getDrawingMask(color, priority, control), matchMask;
p.x = x + curPort->left;
p.y = y + curPort->top;
stack.push(p);
@ -579,20 +581,23 @@ void SciGuiPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority,
byte searchColor = _screen->getVisual(p.x, p.y);
byte searchPriority = _screen->getPriority(p.x, p.y);
byte searchControl = _screen->getControl(p.x, p.y);
int16 w, e, a_set, b_set;
// It seems as if fills on visual screen, where color is not "initial" will not get done at all
// this fixes pictures in qfg1(ega)
if (screenMask & SCI_SCREEN_MASK_VISUAL && searchColor != 15)
screenMask ^= SCI_SCREEN_MASK_VISUAL;
// if in 1st point priority,control or color is already set to target, clear the flag
if (screenMask & SCI_SCREEN_MASK_VISUAL && searchColor == color)
screenMask ^= SCI_SCREEN_MASK_VISUAL;
if (screenMask & SCI_SCREEN_MASK_PRIORITY && searchPriority == priority)
screenMask ^= SCI_SCREEN_MASK_PRIORITY;
if (screenMask & SCI_SCREEN_MASK_CONTROL && searchControl == control)
screenMask ^= SCI_SCREEN_MASK_CONTROL;
if (screenMask == 0)// nothing to fill
return;
// This logic was taken directly from sierra sci, floodfill will get aborted on various occations
if (screenMask & SCI_SCREEN_MASK_VISUAL) {
if (_resMan->isVGA()) {
if ((color == 255) || (searchColor != 255))
return;
} else {
if ((color == 15) || (searchColor != 15))
return;
}
} else if (screenMask & SCI_SCREEN_MASK_PRIORITY) {
if ((priority == 0) || (searchPriority != 0))
return;
} else if (screenMask & SCI_SCREEN_MASK_CONTROL) {
if ((control == 0) || (searchControl != 0))
return;
}
// hard borders for filling
int l = curPort->rect.left + curPort->left;
@ -601,20 +606,20 @@ void SciGuiPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority,
int b = curPort->rect.bottom + curPort->top - 1;
while (stack.size()) {
p = stack.pop();
if ((matchMask = _screen->isFillMatch(p.x, p.y, screenMask, searchColor, searchPriority, searchControl)) == 0) // already filled
if ((matchedMask = _screen->isFillMatch(p.x, p.y, screenMask, searchColor, searchPriority, searchControl)) == 0) // already filled
continue;
_screen->putPixel(p.x, p.y, screenMask, color, priority, control);
w = p.x;
e = p.x;
// moving west and east pointers as long as there is a matching color to fill
while (w > l && (matchMask == _screen->isFillMatch(w - 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
_screen->putPixel(--w, p.y, matchMask, color, priority, control);
while (e < r && (matchMask == _screen->isFillMatch(e + 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
_screen->putPixel(++e, p.y, matchMask, color, priority, control);
while (w > l && (matchedMask == _screen->isFillMatch(w - 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
_screen->putPixel(--w, p.y, screenMask, color, priority, control);
while (e < r && (matchedMask == _screen->isFillMatch(e + 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
_screen->putPixel(++e, p.y, screenMask, color, priority, control);
// checking lines above and below for possible flood targets
a_set = b_set = 0;
while (w <= e) {
if (p.y > t && (matchMask == _screen->isFillMatch(w, p.y - 1, screenMask, searchColor, searchPriority, searchControl))) { // one line above
if (p.y > t && (matchedMask == _screen->isFillMatch(w, p.y - 1, screenMask, searchColor, searchPriority, searchControl))) { // one line above
if (a_set == 0) {
p1.x = w;
p1.y = p.y - 1;
@ -624,7 +629,7 @@ void SciGuiPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority,
} else
a_set = 0;
if (p.y < b && (matchMask == _screen->isFillMatch(w, p.y + 1, screenMask, searchColor, searchPriority, searchControl))) { // one line below
if (p.y < b && (matchedMask == _screen->isFillMatch(w, p.y + 1, screenMask, searchColor, searchPriority, searchControl))) { // one line below
if (b_set == 0) {
p1.x = w;
p1.y = p.y + 1;