From 054460a170d60d6b74114882e15af22b284f3066 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 3 Sep 2004 19:54:58 +0000 Subject: Fix for bug #1021538 (COMI: Graphic glitches in ship-to-ship fight) svn-id: r14876 --- scumm/actor.cpp | 39 +++++++++++++++++++++++++++++---------- scumm/actor.h | 4 +++- scumm/script_v8.cpp | 15 +-------------- 3 files changed, 33 insertions(+), 25 deletions(-) (limited to 'scumm') diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 5dcaa334df..54c847099c 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -986,11 +986,13 @@ void ScummEngine::processUpperActors() { } } -void Actor::drawActorCostume() { - if (!needRedraw) - return; - - needRedraw = false; +void Actor::drawActorCostume(bool hitTestMode) { + if (!hitTestMode) { + if (!needRedraw) + return; + + needRedraw = false; + } setupActorScale(); @@ -1055,9 +1057,9 @@ void Actor::drawActorCostume() { } - bcr->_draw_top = top = 0x7fffffff; + bcr->_draw_top = 0x7fffffff; + bcr->_draw_bottom = 0; - bcr->_draw_bottom = bottom = 0; bcr->_skipLimb = (skipLimb != 0); // If the actor is partially hidden, redraw it next frame. @@ -1066,9 +1068,26 @@ void Actor::drawActorCostume() { needRedraw = (_vm->_version <= 6); } - // Record the vertical extent of the drawn actor - top = bcr->_draw_top; - bottom = bcr->_draw_bottom; + if (!hitTestMode) { + // Record the vertical extent of the drawn actor + top = bcr->_draw_top; + bottom = bcr->_draw_bottom; + } +} + +bool Actor::actorHitTest(int x, int y) { + AkosRenderer *ar = (AkosRenderer *)_vm->_costumeRenderer; + + ar->_actorHitX = x; + ar->_actorHitY = y; + ar->_actorHitMode = true; + ar->_actorHitResult = false; + + drawActorCostume(true); + + ar->_actorHitMode = false; + + return ar->_actorHitResult; } void Actor::animateCostume() { diff --git a/scumm/actor.h b/scumm/actor.h index 40c4f5cd6b..58bf6505cd 100644 --- a/scumm/actor.h +++ b/scumm/actor.h @@ -156,12 +156,14 @@ public: void turnToDirection(int newdir); void walkActor(); void walkActorOld(); - void drawActorCostume(); + void drawActorCostume(bool hitTestMode = false); void animateCostume(); void setActorCostume(int c); void animateLimb(int limb, int f); + bool actorHitTest(int x, int y); + byte *getActorName(); void startWalkActor(int x, int y, int dir); void stopActorMoving(); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index ae7e7507ce..5f924163e6 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1402,20 +1402,7 @@ void ScummEngine_v8::o8_kernelGetFunctions() { case 0xD9: { // actorHit - used, for example, to detect ship collision // during ship-to-ship combat. Actor *a = derefActor(args[1], "actorHit"); - AkosRenderer *ar = (AkosRenderer *) _costumeRenderer; - bool old_need_redraw = a->needRedraw; - - ar->_actorHitX = args[2]; - ar->_actorHitY = args[3] + _screenTop; - ar->_actorHitMode = true; - ar->_actorHitResult = false; - - a->needRedraw = true; - a->drawActorCostume(); - a->needRedraw = old_need_redraw; - - ar->_actorHitMode = false; - push(ar->_actorHitResult); + push(a->actorHitTest(args[2], args[3] + _screenTop)); break; } case 0xDA: // lipSyncWidth -- cgit v1.2.3