diff options
author | Andrew Kurushin | 2005-04-19 11:07:06 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-04-19 11:07:06 +0000 |
commit | d9bb4aae1d6227f463dccd1ae2c65d71c8abcdf9 (patch) | |
tree | 92f659dce411a1e34c64ba79d3f4770cbc89bc2f | |
parent | c3bc118dc8fa39624c960f367c48d4f9bef48469 (diff) | |
download | scummvm-rg350-d9bb4aae1d6227f463dccd1ae2c65d71c8abcdf9.tar.gz scummvm-rg350-d9bb4aae1d6227f463dccd1ae2c65d71c8abcdf9.tar.bz2 scummvm-rg350-d9bb4aae1d6227f463dccd1ae2c65d71c8abcdf9.zip |
fixed speech lock
svn-id: r17689
-rw-r--r-- | saga/actor.cpp | 145 | ||||
-rw-r--r-- | saga/actor.h | 4 | ||||
-rw-r--r-- | saga/interface.cpp | 1 |
3 files changed, 81 insertions, 69 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index d2fc6352ed..55e1f1e241 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -450,11 +450,11 @@ void Actor::realLocation(Location &location, uint16 objectId, uint16 walkFlags) if (objectId != ID_NOTHING) { if (validActorId(objectId)) { actor = getActor(objectId); - location.add(actor->location); + location.addXY(actor->location); } else { if (validObjId(objectId)) { obj = getObj(objectId); - location.add(obj->location); + location.addXY(obj->location); } } @@ -694,92 +694,97 @@ void Actor::handleSpeech(int msec) { int talkspeed; ActorData *actor; - if (!isSpeaking()) return; + if (_activeSpeech.playing) { + _activeSpeech.playingTime -= msec; + stringLength = strlen(_activeSpeech.strings[0]); - stringLength = strlen(_activeSpeech.strings[0]); - - if (stringLength == 0) - error("Empty strings not allowed"); - - if (_vm->_script->_skipSpeeches) { - _activeSpeech.stringsCount = 0; - _vm->_sound->stopVoice(); - _vm->_script->wakeUpThreads(kWaitTypeSpeech); - return; - } - - if (!_activeSpeech.playing) { // just added - talkspeed = ConfMan.getInt("talkspeed"); - if (_activeSpeech.speechFlags & kSpeakSlow) { - if (_activeSpeech.slowModeCharIndex >= stringLength) - error("Wrong string index"); - - debug(0 , "Slow string!"); - _activeSpeech.playingTime = 10 * talkspeed; - // 10 - fix it - - } else { - sampleLength = _vm->_sndRes->getVoiceLength(_activeSpeech.sampleResourceId); //fixme - too fast - - if (sampleLength < 0) { - _activeSpeech.playingTime = stringLength * talkspeed; + removeFirst = false; + if (_activeSpeech.playingTime <= 0) { + if (_activeSpeech.speechFlags & kSpeakSlow) { + _activeSpeech.slowModeCharIndex++; + if (_activeSpeech.slowModeCharIndex >= stringLength) + removeFirst = true; } else { - _activeSpeech.playingTime = sampleLength; + removeFirst = true; + } + _activeSpeech.playing = false; + if (_activeSpeech.actorIds[0] != 0) { + actor = getActor(_activeSpeech.actorIds[0]); + if (!(_activeSpeech.speechFlags & kSpeakNoAnimate)) { + actor->currentAction = kActionWait; + } } } - if (_activeSpeech.sampleResourceId != -1) { - _vm->_sndRes->playVoice(_activeSpeech.sampleResourceId); - _activeSpeech.sampleResourceId++; + if (removeFirst) { + for (i = 1; i < _activeSpeech.stringsCount; i++) { + _activeSpeech.strings[i - 1] = _activeSpeech.strings[i]; + } + _activeSpeech.stringsCount--; } - if (_activeSpeech.actorIds[0] != 0) { - actor = getActor(_activeSpeech.actorIds[0]); - if (!(_activeSpeech.speechFlags & kSpeakNoAnimate)) { - 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); - } + if (_vm->_script->_skipSpeeches) { + _activeSpeech.stringsCount = 0; + _vm->_script->wakeUpThreads(kWaitTypeSpeech); + return; + } + + if (_activeSpeech.stringsCount == 0) { + _vm->_script->wakeUpThreadsDelayed(kWaitTypeSpeech, ticksToMSec(kScriptTimeTicksPerSecond / 3)); } - _activeSpeech.playing = true; + return; } + if (_vm->_script->_skipSpeeches) { + _activeSpeech.stringsCount = 0; + _vm->_script->wakeUpThreads(kWaitTypeSpeech); + } - _activeSpeech.playingTime -= msec; + if (_activeSpeech.stringsCount == 0) { + return; + } - removeFirst = false; - if (_activeSpeech.playingTime <= 0) { - if (_activeSpeech.speechFlags & kSpeakSlow) { - _activeSpeech.slowModeCharIndex++; - if (_activeSpeech.slowModeCharIndex >= stringLength) - removeFirst = true; + stringLength = strlen(_activeSpeech.strings[0]); + + talkspeed = ConfMan.getInt("talkspeed"); + if (_activeSpeech.speechFlags & kSpeakSlow) { + if (_activeSpeech.slowModeCharIndex >= stringLength) + error("Wrong string index"); + + debug(0 , "Slow string!"); + _activeSpeech.playingTime = 10 * talkspeed; + // 10 - fix it + + } else { + sampleLength = _vm->_sndRes->getVoiceLength(_activeSpeech.sampleResourceId); //fixme - too fast + + if (sampleLength < 0) { + _activeSpeech.playingTime = stringLength * talkspeed; } else { - removeFirst = true; - } - _activeSpeech.playing = false; - if (_activeSpeech.actorIds[0] != 0) { - actor = getActor(_activeSpeech.actorIds[0]); - if (!(_activeSpeech.speechFlags & kSpeakNoAnimate)) { - actor->currentAction = kActionWait; - } + _activeSpeech.playingTime = sampleLength; } } - if (removeFirst) { - for (i = 1; i < _activeSpeech.stringsCount; i++) { - _activeSpeech.strings[i - 1] = _activeSpeech.strings[i]; - } - _activeSpeech.stringsCount--; + if (_activeSpeech.sampleResourceId != -1) { + _vm->_sndRes->playVoice(_activeSpeech.sampleResourceId); + _activeSpeech.sampleResourceId++; } - if (!isSpeaking()) - _vm->_script->wakeUpThreadsDelayed(kWaitTypeSpeech, ticksToMSec(kScriptTimeTicksPerSecond / 3)); + if (_activeSpeech.actorIds[0] != 0) { + actor = getActor(_activeSpeech.actorIds[0]); + if (!(_activeSpeech.speechFlags & kSpeakNoAnimate)) { + 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; } void Actor::handleActions(int msec, bool setup) { @@ -1760,6 +1765,8 @@ void Actor::simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount, } void Actor::abortAllSpeeches() { + abortSpeech(); + if (_vm->_script->_abortEnabled) _vm->_script->_skipSpeeches = true; diff --git a/saga/actor.h b/saga/actor.h index d75f5a7271..93e3f2a803 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -160,6 +160,10 @@ struct Location { result.y = y - location.y; result.z = z - location.z; } + void addXY(const Location &location) { + x += location.x; + y += location.y; + } void add(const Location &location) { x += location.x; y += location.y; diff --git a/saga/interface.cpp b/saga/interface.cpp index 3d5f779593..deee66e960 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -158,6 +158,7 @@ int Interface::activate() { if (!_active) { _active = true; _vm->_script->_skipSpeeches = false; + _vm->_actor->_protagonist->targetObject = ID_NOTHING; _vm->_gfx->showCursor(true); unlockMode(); if (_panelMode == kPanelMain) |