GRIM: Don't reset all the components when stopping the talking chore. Fix #253

This commit is contained in:
Giulio Camuffo
2011-07-08 17:41:13 +02:00
parent b73f136ad1
commit 1db7e0de31
3 changed files with 35 additions and 1 deletions
+4 -1
View File
@@ -948,7 +948,10 @@ void Actor::shutUp() {
_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
_lipSync = NULL;
} else if (_mumbleChore >= 0 && _mumbleCostume->isChoring(_mumbleChore, false) >= 0) {
_mumbleCostume->stopChore(_mumbleChore);
// Not using stopChore here, because it calls reset() on the components and
// so hides the model components, which is a problem when talking to Sal's head.
// https://github.com/residual/residual/issues/253
_mumbleCostume->cleanupChore(_mumbleChore);
}
if (_sayLineText) {
+28
View File
@@ -632,6 +632,7 @@ public:
void setupTexture();
void reset();
void resetColormap();
void cleanup();
void saveState(SaveGame *state);
void restoreState(SaveGame *state);
~MaterialComponent() { }
@@ -1010,6 +1011,10 @@ void MaterialComponent::resetColormap() {
init();
}
void MaterialComponent::cleanup() {
_num = 0;
}
void MaterialComponent::saveState(SaveGame *state) {
state->writeLESint32(_num);
}
@@ -1529,6 +1534,18 @@ void Costume::Chore::fade(Costume::Chore::FadeMode mode, int msecs) {
_fadeLength = msecs;
}
void Costume::Chore::cleanup() {
_playing = false;
_hasPlayed = false;
_fadeMode = None;
for (int i = 0; i < _numTracks; i++) {
Component *comp = _owner->_components[_tracks[i].compID];
if (comp)
comp->cleanup();
}
}
Costume::Component *Costume::loadComponent (tag32 tag, Costume::Component *parent, int parentID, const char *name, Costume::Component *prevComponent) {
if (FROM_BE_32(tag) == MKTAG('M','M','D','L'))
return new MainModelComponent(parent, parentID, name, prevComponent, tag);
@@ -1698,6 +1715,17 @@ void Costume::fadeChoreOut(int chore, int msecs) {
_playingChores.push_back(&_chores[chore]);
}
void Costume::cleanupChore(int chore) {
if (chore >= _numChores) {
if (chore < 0 || chore >= _numChores) {
if (gDebugLevel == DEBUG_CHORES || gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
warning("Requested chore number %d is outside the range of chores (0-%d)", chore, _numChores);
return;
}
}
_chores[chore].cleanup();
}
int Costume::isChoring(const char *name, bool excludeLooping) {
for (int i = 0; i < _numChores; i++) {
if (!strcmp(_chores[i]._name, name) && _chores[i]._playing && !(excludeLooping && _chores[i]._looping))
+3
View File
@@ -55,6 +55,7 @@ public:
void stopChore(int num);
void fadeChoreIn(int chore, int msecs);
void fadeChoreOut(int chore, int msecs);
void cleanupChore(int chore);
Model::HierNode *getModelNodes();
Model *getModel();
void setColormap(const Common::String &map);
@@ -97,6 +98,7 @@ public:
virtual void setupTexture() { }
virtual void draw() { }
virtual void reset() { }
virtual void cleanup() { }
virtual void resetColormap() { }
virtual void saveState(SaveGame *) { }
virtual void restoreState(SaveGame *) { }
@@ -165,6 +167,7 @@ private:
void update();
void setLastFrame();
void fade(FadeMode mode, int msecs);
void cleanup();
private:
Costume *_owner;