aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2005-04-16 16:55:35 +0000
committerAndrew Kurushin2005-04-16 16:55:35 +0000
commitbffeb58d06f89fc49d64c349d3d8cfa4f65a0664 (patch)
treebb7c509d7f845d024b422d2d5aebe8bbad2d21a3 /saga
parent7b9a3b1fa73a2433201ac1c9d63952b5e9076158 (diff)
downloadscummvm-rg350-bffeb58d06f89fc49d64c349d3d8cfa4f65a0664.tar.gz
scummvm-rg350-bffeb58d06f89fc49d64c349d3d8cfa4f65a0664.tar.bz2
scummvm-rg350-bffeb58d06f89fc49d64c349d3d8cfa4f65a0664.zip
fixed: sprite hittest, speech draws in screen bounds
svn-id: r17635
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp22
-rw-r--r--saga/script.h2
-rw-r--r--saga/sfuncs.cpp4
-rw-r--r--saga/sprite.cpp23
4 files changed, 13 insertions, 38 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index c7fd31ada0..0e7b5eb16b 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -739,6 +739,12 @@ void Actor::handleSpeech(int msec) {
actor->currentAction = kActionSpeak;
actor->actionCycle = _vm->_rnd.getRandomNumber(63);
}
+ for (i = 0; i < _activeSpeech.actorsCount; i++) {
+ actor = getActor(_activeSpeech.actorIds[i]);
+ _activeSpeech.speechCoords[i] = actor->screenPosition;
+ _activeSpeech.speechCoords[i].y -= ACTOR_DIALOGUE_HEIGHT;
+ _activeSpeech.speechCoords[i].y = MAX(_activeSpeech.speechCoords[i].y, (int16)10);
+ }
}
_activeSpeech.playing = true;
return;
@@ -770,15 +776,6 @@ void Actor::handleSpeech(int msec) {
_activeSpeech.strings[i - 1] = _activeSpeech.strings[i];
}
_activeSpeech.stringsCount--;
- if (_activeSpeech.stringsCount > 0 && _activeSpeech.actorIds[0] != 0) {
- // Update actor speech position for the next string.
- // Note that we only need to do this for the first
- // actor since simultaneous speech is never more than
- // one string at a time.
- actor = getActor(_activeSpeech.actorIds[0]);
- _activeSpeech.speechCoords[0] = actor->screenPosition;
- _activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
- }
}
if (!isSpeaking())
@@ -1280,7 +1277,7 @@ int Actor::drawActors() {
}
// draw speeches
- if (isSpeaking() && !_vm->_script->_skipSpeeches) {
+ if (isSpeaking() && _activeSpeech.playing && !_vm->_script->_skipSpeeches) {
int i;
int textDrawFlags;
char oneChar[2];
@@ -1699,12 +1696,11 @@ void Actor::actorSpeech(uint16 actorId, const char **strings, int stringsCount,
for (i = 0; i < stringsCount; i++) {
_activeSpeech.strings[i] = strings[i];
}
+
_activeSpeech.stringsCount = stringsCount;
_activeSpeech.speechFlags = speechFlags;
_activeSpeech.actorsCount = 1;
_activeSpeech.actorIds[0] = actorId;
- _activeSpeech.speechCoords[0] = actor->screenPosition;
- _activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
_activeSpeech.speechColor[0] = actor->speechColor;
_activeSpeech.outlineColor[0] = kITEColorBlack;
_activeSpeech.sampleResourceId = sampleResourceId;
@@ -1746,8 +1742,6 @@ void Actor::simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount,
actor = getActor(actorIds[i]);
_activeSpeech.actorIds[i] = actorIds[i];
- _activeSpeech.speechCoords[i] = actor->screenPosition;
- _activeSpeech.speechCoords[i].y -= ACTOR_DIALOGUE_HEIGHT;
_activeSpeech.speechColor[i] = actor->speechColor;
_activeSpeech.outlineColor[i] = 0; // disable outline
}
diff --git a/saga/script.h b/saga/script.h
index 24577db51e..ccb81ab1a4 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -512,7 +512,7 @@ private:
void sfResumeBgdAnim(SCRIPTFUNC_PARAMS);
void SF_throwActor(SCRIPTFUNC_PARAMS);
void sfWaitWalk(SCRIPTFUNC_PARAMS);
- void SF_sceneID(SCRIPTFUNC_PARAMS);
+ void sfScriptSceneID(SCRIPTFUNC_PARAMS);
void SF_changeActorScene(SCRIPTFUNC_PARAMS);
void SF_climb(SCRIPTFUNC_PARAMS);
void sfSetDoorState(SCRIPTFUNC_PARAMS);
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 82efff070f..68b21b082d 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -104,7 +104,7 @@ void Script::setupScriptFuncList(void) {
OPCODE(sfResumeBgdAnim),
OPCODE(SF_throwActor),
OPCODE(sfWaitWalk),
- OPCODE(SF_sceneID),
+ OPCODE(sfScriptSceneID),
OPCODE(SF_changeActorScene),
OPCODE(SF_climb),
OPCODE(sfSetDoorState),
@@ -1346,7 +1346,7 @@ void Script::sfWaitWalk(SCRIPTFUNC_PARAMS) {
}
// Script function #54 (0x36)
-void Script::SF_sceneID(SCRIPTFUNC_PARAMS) {
+void Script::sfScriptSceneID(SCRIPTFUNC_PARAMS) {
thread->_returnValue = _vm->_scene->currentSceneNumber();
}
diff --git a/saga/sprite.cpp b/saga/sprite.cpp
index 23f6a8e66c..46a55d73d7 100644
--- a/saga/sprite.cpp
+++ b/saga/sprite.cpp
@@ -241,8 +241,6 @@ bool Sprite::hitTest(SpriteList &spriteList, int spriteNumber, const Point &scre
const byte *spriteBuffer;
int i, j;
const byte *srcRowPointer;
- int clipWidth;
- int clipHeight;
int width;
int height;
int xAlign;
@@ -255,27 +253,10 @@ bool Sprite::hitTest(SpriteList &spriteList, int spriteNumber, const Point &scre
spritePointer.x = screenCoord.x + xAlign;
spritePointer.y = screenCoord.y + yAlign;
- if (spritePointer.x < 0) {
- return false;
- }
- if (spritePointer.y < 0) {
- return false;
- }
-
- clipWidth = width;
- if (width > (_vm->getDisplayWidth() - spritePointer.x)) {
- clipWidth = (_vm->getDisplayWidth() - spritePointer.x);
- }
-
- clipHeight = height;
- if (height > (_vm->getDisplayHeight() - spritePointer.y)) {
- clipHeight = (_vm->getDisplayHeight() - spritePointer.y);
- }
-
- if ((testPoint.y < spritePointer.y) || (testPoint.y >= spritePointer.y + clipHeight)) {
+ if ((testPoint.y < spritePointer.y) || (testPoint.y >= spritePointer.y + height)) {
return false;
}
- if ((testPoint.x < spritePointer.x) || (testPoint.x >= spritePointer.x + clipWidth)) {
+ if ((testPoint.x < spritePointer.x) || (testPoint.x >= spritePointer.x + width)) {
return false;
}
i = testPoint.y - spritePointer.y;