aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorEugene Sandulenko2010-06-15 10:31:18 +0000
committerEugene Sandulenko2010-06-15 10:31:18 +0000
commitffc390e64c1adc8bd863ecd0bfe72ff7ecba6832 (patch)
treed20e4de81a37f6a9b02e9934435906e2e3e31233 /engines/agi
parent7034d071b6f44fb77f3379535f146a095357c5be (diff)
downloadscummvm-rg350-ffc390e64c1adc8bd863ecd0bfe72ff7ecba6832.tar.gz
scummvm-rg350-ffc390e64c1adc8bd863ecd0bfe72ff7ecba6832.tar.bz2
scummvm-rg350-ffc390e64c1adc8bd863ecd0bfe72ff7ecba6832.zip
AGI: Fix bug #1945716.
Bug #1945716: "AGI: Fan(Kings Quest 2 1/4) - Sprite not erased". Added a workaround, since it is design flaw of our rendering system. svn-id: r49742
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/op_cmd.cpp24
-rw-r--r--engines/agi/sprite.cpp32
-rw-r--r--engines/agi/view.cpp1
-rw-r--r--engines/agi/view.h1
4 files changed, 20 insertions, 38 deletions
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index fb95c1cee1..bb0799d92c 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -889,26 +889,12 @@ cmd(erase) {
}
g_sprites->blitUpdSprites();
- int x1, y1, x2, y2, w, h;
+ int x1, y1, x2, y2;
- w = MAX(vt.celData->width, vt.celData2->width);
- h = MAX(vt.celData->height, vt.celData2->height);
-
- if (vt.xPos < vt.xPos2) {
- x1 = vt.xPos;
- x2 = vt.xPos2 + w - 1;
- } else {
- x1 = vt.xPos2;
- x2 = vt.xPos + w - 1;
- }
-
- if (vt.yPos < vt.yPos2) {
- y1 = vt.yPos - h + 1;
- y2 = vt.yPos2;
- } else {
- y1 = vt.yPos2 - h + 1;
- y2 = vt.yPos;
- }
+ x1 = MIN((int)MIN(vt.xPos, vt.xPos2), MIN(vt.xPos + vt.celData->width, vt.xPos2 + vt.celData2->width));
+ x2 = MAX((int)MAX(vt.xPos, vt.xPos2), MAX(vt.xPos + vt.celData->width, vt.xPos2 + vt.celData2->width));
+ y1 = MIN((int)MIN(vt.yPos, vt.yPos2), MIN(vt.yPos - vt.celData->height, vt.yPos2 - vt.celData2->height));
+ y2 = MAX((int)MAX(vt.yPos, vt.yPos2), MAX(vt.yPos - vt.celData->height, vt.yPos2 - vt.celData2->height));
g_sprites->commitBlock(x1, y1, x2, y2);
}
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index 10184fcaa4..611dd16478 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -241,6 +241,14 @@ void SpritesMgr::objsRestoreArea(Sprite *s) {
q += xSize;
pos0 += _WIDTH;
}
+
+ // WORKAROUND
+ // When set.view command is called, current code cannot detect this situation while updating
+ // Thus we force removal of the old sprite
+ if (s->v->viewReplaced) {
+ commitBlock(xPos, yPos, xPos + xSize, yPos + ySize);
+ s->v->viewReplaced = false;
+ }
}
@@ -387,29 +395,15 @@ void SpritesMgr::commitSprites(SpriteList &l) {
SpriteList::iterator iter;
for (iter = l.begin(); iter != l.end(); ++iter) {
Sprite *s = *iter;
- int x1, y1, x2, y2, w, h;
+ int x1, y1, x2, y2;
- w = MAX(s->v->celData->width, s->v->celData2->width);
- h = MAX(s->v->celData->height, s->v->celData2->height);
+ x1 = MIN((int)MIN(s->v->xPos, s->v->xPos2), MIN(s->v->xPos + s->v->celData->width, s->v->xPos2 + s->v->celData2->width));
+ x2 = MAX((int)MAX(s->v->xPos, s->v->xPos2), MAX(s->v->xPos + s->v->celData->width, s->v->xPos2 + s->v->celData2->width));
+ y1 = MIN((int)MIN(s->v->yPos, s->v->yPos2), MIN(s->v->yPos - s->v->celData->height, s->v->yPos2 - s->v->celData2->height));
+ y2 = MAX((int)MAX(s->v->yPos, s->v->yPos2), MAX(s->v->yPos - s->v->celData->height, s->v->yPos2 - s->v->celData2->height));
s->v->celData2 = s->v->celData;
- if (s->v->xPos < s->v->xPos2) {
- x1 = s->v->xPos;
- x2 = s->v->xPos2 + w - 1;
- } else {
- x1 = s->v->xPos2;
- x2 = s->v->xPos + w - 1;
- }
-
- if (s->v->yPos < s->v->yPos2) {
- y1 = s->v->yPos - h + 1;
- y2 = s->v->yPos2;
- } else {
- y1 = s->v->yPos2 - h + 1;
- y2 = s->v->yPos;
- }
-
commitBlock(x1, y1, x2, y2);
if (s->v->stepTimeCount != s->v->stepTime)
diff --git a/engines/agi/view.cpp b/engines/agi/view.cpp
index a775b5f78b..b89ab3915c 100644
--- a/engines/agi/view.cpp
+++ b/engines/agi/view.cpp
@@ -297,6 +297,7 @@ void AgiEngine::setView(VtEntry *v, int n) {
v->viewData = &_game.views[n];
v->currentView = n;
v->numLoops = v->viewData->numLoops;
+ v->viewReplaced = true;
setLoop(v, v->currentLoop >= v->numLoops ? 0 : v->currentLoop);
}
diff --git a/engines/agi/view.h b/engines/agi/view.h
index f9017ec4ae..85f2d6eaf9 100644
--- a/engines/agi/view.h
+++ b/engines/agi/view.h
@@ -63,6 +63,7 @@ struct VtEntry {
int16 xPos;
int16 yPos;
uint8 currentView;
+ bool viewReplaced;
struct AgiView *viewData;
uint8 currentLoop;
uint8 numLoops;