diff options
author | Willem Jan Palenstijn | 2013-04-18 23:34:29 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:39:44 +0200 |
commit | 01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6 (patch) | |
tree | 544b07f3aa41abe7907bcd2040cdad11ebc324bb /engines/toon | |
parent | 9cf2c83e5e5a35816ab153bf8443dac691829ea8 (diff) | |
parent | a41d72a44a660c72fdadbc3a8ef580e5e03cb890 (diff) | |
download | scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.tar.gz scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.tar.bz2 scummvm-rg350-01f3f3a8dd0ad2891939d03b0ce47cbf36ea9bc6.zip |
Merge branch 'master'
Diffstat (limited to 'engines/toon')
-rw-r--r-- | engines/toon/anim.cpp | 16 | ||||
-rw-r--r-- | engines/toon/anim.h | 1 | ||||
-rw-r--r-- | engines/toon/audio.cpp | 7 | ||||
-rw-r--r-- | engines/toon/character.cpp | 10 | ||||
-rw-r--r-- | engines/toon/detection.cpp | 21 | ||||
-rw-r--r-- | engines/toon/drew.cpp | 1 | ||||
-rw-r--r-- | engines/toon/font.cpp | 14 | ||||
-rw-r--r-- | engines/toon/hotspot.cpp | 1 | ||||
-rw-r--r-- | engines/toon/movie.cpp | 3 | ||||
-rw-r--r-- | engines/toon/path.cpp | 124 | ||||
-rw-r--r-- | engines/toon/path.h | 17 | ||||
-rw-r--r-- | engines/toon/picture.cpp | 13 | ||||
-rw-r--r-- | engines/toon/picture.h | 2 | ||||
-rw-r--r-- | engines/toon/resource.cpp | 2 | ||||
-rw-r--r-- | engines/toon/script.cpp | 1 | ||||
-rw-r--r-- | engines/toon/script.h | 1 | ||||
-rw-r--r-- | engines/toon/script_func.cpp | 10 | ||||
-rw-r--r-- | engines/toon/tools.cpp | 2 | ||||
-rw-r--r-- | engines/toon/toon.cpp | 31 |
19 files changed, 165 insertions, 112 deletions
diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp index 23bd0f6487..a529001af5 100644 --- a/engines/toon/anim.cpp +++ b/engines/toon/anim.cpp @@ -271,6 +271,18 @@ void Animation::applyPalette(int32 offset, int32 srcOffset, int32 numEntries) { _vm->setPaletteEntries(_palette + srcOffset, offset, numEntries); } +Common::Rect Animation::getFrameRect(int32 frame) { + debugC(4, kDebugAnim, "getFrameRect(%d)", frame); + if ((frame < 0) || (frame >= _numFrames)) { + return Common::Rect(); + } + + if (_frames[frame]._ref != -1) + frame = _frames[frame]._ref; + + return Common::Rect(_frames[frame]._x1, _frames[frame]._y1, _frames[frame]._x2, _frames[frame]._y2); +} + int32 Animation::getFrameWidth(int32 frame) { debugC(4, kDebugAnim, "getFrameWidth(%d)", frame); if ((frame < 0) || (frame >= _numFrames)) @@ -681,7 +693,7 @@ AnimationManager::AnimationManager(ToonEngine *vm) : _vm(vm) { bool AnimationManager::hasInstance(AnimationInstance* instance) { for (uint32 i = 0; i < _instances.size(); i++) { - if(_instances[i] == instance) + if (_instances[i] == instance) return true; } return false; @@ -697,7 +709,7 @@ void AnimationManager::addInstance(AnimationInstance *instance) { // if the instance already exists, we skip the add for (uint32 i = 0; i < _instances.size(); i++) { - if(_instances[i] == instance) + if (_instances[i] == instance) return; } diff --git a/engines/toon/anim.h b/engines/toon/anim.h index 13c501b910..4b95b6cf40 100644 --- a/engines/toon/anim.h +++ b/engines/toon/anim.h @@ -68,6 +68,7 @@ public: void drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask, int32 scale); void drawStrip(int32 offset = 0); void applyPalette(int32 offset, int32 srcOffset, int32 numEntries); + Common::Rect getFrameRect(int32 frame); int32 getFrameWidth(int32 frame); int32 getFrameHeight(int32 frame); int32 getWidth() const; diff --git a/engines/toon/audio.cpp b/engines/toon/audio.cpp index 0bf3316209..5b2d06b74d 100644 --- a/engines/toon/audio.cpp +++ b/engines/toon/audio.cpp @@ -65,7 +65,7 @@ void AudioManager::muteMusic(bool muted) { } void AudioManager::muteVoice(bool muted) { - if(voiceStillPlaying() && _channels[2]) { + if (voiceStillPlaying() && _channels[2]) { _channels[2]->setVolume(muted ? 0 : 255); } _voiceMuted = muted; @@ -272,7 +272,7 @@ AudioStreamInstance::~AudioStreamInstance() { int AudioStreamInstance::readBuffer(int16 *buffer, const int numSamples) { debugC(5, kDebugAudio, "readBuffer(buffer, %d)", numSamples); - if(_stopped) + if (_stopped) return 0; handleFade(numSamples); @@ -598,7 +598,7 @@ void AudioManager::updateAmbientSFX() for (int32 i = 0; i < 4; i++) { AudioAmbientSFX* ambient = &_ambientSFXs[i]; if (ambient->_enabled && (ambient->_channel < 0 || !(_channels[ambient->_channel] && _channels[ambient->_channel]->isPlaying()))) { - if(ambient->_mode == 1) { + if (ambient->_mode == 1) { if (_vm->randRange(0, 32767) < ambient->_delay) { ambient->_channel = playSFX(ambient->_id, ambient->_volume, false); } @@ -613,4 +613,3 @@ void AudioManager::updateAmbientSFX() } } // End of namespace Toon - diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 06c6e21d21..7d9a31c170 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -596,7 +596,8 @@ int32 Character::getId() { void Character::save(Common::WriteStream *stream) { debugC(1, kDebugCharacter, "save(stream)"); - stream->writeSint32LE(_flags); + // we have to save visibility too, put in flags to not invalidate old savegames. + stream->writeSint32LE(_flags | ((_visible == false) ? 0x100 : 0)); stream->writeSint32LE(_x); stream->writeSint32LE(_y); stream->writeSint32LE(_z); @@ -633,6 +634,12 @@ void Character::load(Common::ReadStream *stream) { if (_sceneAnimationId > -1) { setAnimationInstance(_vm->getSceneAnimation(_sceneAnimationId)->_animInstance); } + + // "not visible" flag. + if (_flags & 0x100) { + _flags &= ~0x100; + setVisible(false); + } } void Character::setAnimScript(int32 animScriptId) { @@ -1102,4 +1109,3 @@ void Character::updateIdle() { } } } // End of namespace Toon - diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp index 810a37720a..2afcb589b7 100644 --- a/engines/toon/detection.cpp +++ b/engines/toon/detection.cpp @@ -35,8 +35,6 @@ static const PlainGameDescriptor toonGames[] = { namespace Toon { -using Common::GUIO_NONE; - static const ADGameDescription gameDescriptions[] = { { "toon", "", @@ -46,7 +44,7 @@ static const ADGameDescription gameDescriptions[] = { {"study.svl", 0, "281efa3f33f6712c0f641a605f4d40fd", 2511090}, AD_LISTEND }, - Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, { "toon", "", @@ -56,7 +54,7 @@ static const ADGameDescription gameDescriptions[] = { {"study.svl", 0, "df056b94ea83f1ed92a539cf636053ab", 2542668}, AD_LISTEND }, - Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, { "toon", "", @@ -66,7 +64,7 @@ static const ADGameDescription gameDescriptions[] = { {"study.svl", 0, "72fe96a9e10967d3138e918295babc42", 2910283}, AD_LISTEND }, - Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, { "toon", "", @@ -76,7 +74,7 @@ static const ADGameDescription gameDescriptions[] = { {"study.svl", 0, "b6b1ee2d9d94d53d305856039ab7bde7", 2634620}, AD_LISTEND }, - Common::ES_ESP, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE + Common::ES_ESP, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, { "toon", "", @@ -86,7 +84,7 @@ static const ADGameDescription gameDescriptions[] = { {"generic.svl", 0, "5eb99850ada22f0b8cf6392262d4dd07", 9404599}, AD_LISTEND }, - Common::DE_DEU, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE + Common::DE_DEU, Common::kPlatformPC, ADGF_DEMO, GUIO1(GUIO_NONE) }, { "toon", "", @@ -95,7 +93,7 @@ static const ADGameDescription gameDescriptions[] = { {"generic.svl", 0, "5c42724bb93b360dca7044d6b7ef26e5", 7739319}, AD_LISTEND }, - Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE + Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, GUIO1(GUIO_NONE) }, AD_TABLE_END_MARKER @@ -224,12 +222,7 @@ SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int s SaveStateDescriptor desc(slot, saveName); - Graphics::Surface *thumbnail = new Graphics::Surface(); - assert(thumbnail); - if (!Graphics::loadThumbnail(*file, *thumbnail)) { - delete thumbnail; - thumbnail = 0; - } + Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); desc.setThumbnail(thumbnail); desc.setDeletableFlag(true); diff --git a/engines/toon/drew.cpp b/engines/toon/drew.cpp index 89438fb35c..df5cfcfa03 100644 --- a/engines/toon/drew.cpp +++ b/engines/toon/drew.cpp @@ -129,4 +129,3 @@ void CharacterDrew::resetScale() setPosition(_x, _y); } } // End of namespace Toon - diff --git a/engines/toon/font.cpp b/engines/toon/font.cpp index 4c491ae2b3..63304c905f 100644 --- a/engines/toon/font.cpp +++ b/engines/toon/font.cpp @@ -21,6 +21,7 @@ */ #include "common/debug.h" +#include "common/rect.h" #include "toon/font.h" @@ -80,7 +81,7 @@ void FontRenderer::renderText(int32 x, int32 y, Common::String origText, int32 m x -= xx / 2; } - _vm->addDirtyRect(x, y, x + xx + 2, y + yy); + _vm->addDirtyRect(x, y, x + xx, y + yy); int32 curX = x; int32 curY = y; @@ -110,6 +111,7 @@ void FontRenderer::computeSize(Common::String origText, int32 *retX, int32 *retY int32 lineHeight = 0; int32 totalHeight = 0; int32 totalWidth = 0; + int32 lastLineHeight = 0; const byte *text = (const byte *)origText.c_str(); while (*text) { @@ -122,17 +124,25 @@ void FontRenderer::computeSize(Common::String origText, int32 *retX, int32 *retY totalHeight += lineHeight; lineHeight = 0; lineWidth = 0; + lastLineHeight = 0; } else { curChar = textToFont(curChar); int32 charWidth = _currentFont->getFrameWidth(curChar) - 1; int32 charHeight = _currentFont->getFrameHeight(curChar); lineWidth += charWidth; lineHeight = MAX(lineHeight, charHeight); + + // The character may be offset, so the height doesn't + // really tell how far it will stick out. For now, + // assume we only need to take the lower bound into + // consideration. + Common::Rect charRect = _currentFont->getFrameRect(curChar); + lastLineHeight = MAX<int32>(lastLineHeight, charRect.bottom); } text++; } - totalHeight += lineHeight; + totalHeight += lastLineHeight; totalWidth = MAX(totalWidth, lineWidth); *retX = totalWidth; diff --git a/engines/toon/hotspot.cpp b/engines/toon/hotspot.cpp index 62458ad800..ee81b87417 100644 --- a/engines/toon/hotspot.cpp +++ b/engines/toon/hotspot.cpp @@ -149,4 +149,3 @@ HotspotData *Hotspots::Get(int32 id) { } } // End of namespace Toon - diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index 2318eaaac7..7637f4e62f 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -94,7 +94,7 @@ void Movie::play(Common::String video, int32 flags) { _vm->getAudioManager()->setMusicVolume(0); _decoder->loadFile(video.c_str()); playVideo(isFirstIntroVideo); - _vm->flushPalette(false); + _vm->flushPalette(true); if (flags & 1) _vm->getAudioManager()->setMusicVolume(_vm->getAudioManager()->isMusicMuted() ? 0 : 255); _decoder->close(); @@ -103,7 +103,6 @@ void Movie::play(Common::String video, int32 flags) { bool Movie::playVideo(bool isFirstIntroVideo) { debugC(1, kDebugMovie, "playVideo(isFirstIntroVideo: %d)", isFirstIntroVideo); - while (!_vm->shouldQuit() && !_decoder->endOfVideo()) { if (_decoder->needsUpdate()) { const Graphics::Surface *frame = _decoder->decodeNextFrame(); diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index dde7be07d0..60ca007930 100644 --- a/engines/toon/path.cpp +++ b/engines/toon/path.cpp @@ -28,54 +28,69 @@ namespace Toon { PathFindingHeap::PathFindingHeap() { _count = 0; - _alloc = 0; + _size = 0; _data = NULL; } PathFindingHeap::~PathFindingHeap() { - delete[] _data; + free(_data); } -int32 PathFindingHeap::init(int32 size) { +void PathFindingHeap::init(int32 size) { debugC(1, kDebugPath, "init(%d)", size); + _size = size; - delete[] _data; - _data = new HeapDataGrid[size * 2]; - memset(_data, 0, sizeof(HeapDataGrid) * size * 2); + free(_data); + _data = (HeapDataGrid *)malloc(sizeof(HeapDataGrid) * _size); + memset(_data, 0, sizeof(HeapDataGrid) * _size); _count = 0; - _alloc = size; - return size; } -int32 PathFindingHeap::unload() { - delete[] _data; +void PathFindingHeap::unload() { + _count = 0; + _size = 0; + free(_data); _data = NULL; - return 0; } -int32 PathFindingHeap::clear() { - //debugC(1, kDebugPath, "clear()"); +void PathFindingHeap::clear() { + debugC(1, kDebugPath, "clear()"); _count = 0; - memset(_data, 0, sizeof(HeapDataGrid) * _alloc * 2); - return 1; + memset(_data, 0, sizeof(HeapDataGrid) * _size); } -int32 PathFindingHeap::push(int32 x, int32 y, int32 weight) { - //debugC(6, kDebugPath, "push(%d, %d, %d)", x, y, weight); +void PathFindingHeap::push(int32 x, int32 y, int32 weight) { + debugC(2, kDebugPath, "push(%d, %d, %d)", x, y, weight); + + if (_count == _size) { + // Increase size by 50% + int newSize = _size + (_size >> 1) + 1; + HeapDataGrid *newData; + + newData = (HeapDataGrid *)realloc(_data, sizeof(HeapDataGrid) * newSize); + if (newData == NULL) { + warning("Aborting attempt to push onto PathFindingHeap at maximum size: %d", _count); + return; + } + + memset(newData + _size, 0, sizeof(HeapDataGrid) * (newSize - _size)); + _data = newData; + _size = newSize; + } - _count++; _data[_count]._x = x; _data[_count]._y = y; _data[_count]._weight = weight; + _count++; - int32 lMax = _count; + int32 lMax = _count-1; int32 lT = 0; while (1) { - lT = lMax / 2; - if (lT < 1) + if (lMax <= 0) break; + lT = (lMax-1) / 2; if (_data[lT]._weight > _data[lMax]._weight) { HeapDataGrid temp; @@ -87,31 +102,31 @@ int32 PathFindingHeap::push(int32 x, int32 y, int32 weight) { break; } } - return 1; } -int32 PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) { - //debugC(6, kDebugPath, "pop(x, y, weight)"); +void PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) { + debugC(2, kDebugPath, "pop(x, y, weight)"); - if (!_count) - return 0; + if (!_count) { + warning("Attempt to pop empty PathFindingHeap!"); + return; + } - *x = _data[1]._x; - *y = _data[1]._y; - *weight = _data[1]._weight; + *x = _data[0]._x; + *y = _data[0]._y; + *weight = _data[0]._weight; - _data[1] = _data[_count]; - _count--; + _data[0] = _data[--_count]; if (!_count) - return 0; + return; - int32 lMin = 1; - int32 lT = 1; + int32 lMin = 0; + int32 lT = 0; while (1) { - lT = lMin << 1; - if (lT <= _count) { - if (lT < _count) { + lT = (lMin << 1) + 1; + if (lT < _count) { + if (lT < _count-1) { if (_data[lT + 1]._weight < _data[lT]._weight) lT++; } @@ -129,7 +144,6 @@ int32 PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) { break; } } - return 0; } PathFinding::PathFinding(ToonEngine *vm) : _vm(vm) { @@ -164,7 +178,7 @@ bool PathFinding::isLikelyWalkable(int32 x, int32 y) { } bool PathFinding::isWalkable(int32 x, int32 y) { - //debugC(6, kDebugPath, "isWalkable(%d, %d)", x, y); + debugC(2, kDebugPath, "isWalkable(%d, %d)", x, y); bool maskWalk = (_currentMask->getData(x, y) & 0x1f) > 0; @@ -299,7 +313,7 @@ int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { _heap->push(curX, curY, abs(destx - x) + abs(desty - y)); int wei = 0; - while (_heap->_count) { + while (_heap->getCount()) { wei = 0; _heap->pop(&curX, &curY, &curWeight); int curNode = curX + curY * _width; @@ -342,8 +356,15 @@ next: curX = destx; curY = desty; - int32 retPathX[4096]; - int32 retPathY[4096]; + int32 *retPathX = (int32 *)malloc(4096 * sizeof(int32)); + int32 *retPathY = (int32 *)malloc(4096 * sizeof(int32)); + if (!retPathX || !retPathY) { + free(retPathX); + free(retPathY); + + error("[PathFinding::findPath] Cannot allocate pathfinding buffers"); + } + int32 numpath = 0; retPathX[numpath] = curX; @@ -377,8 +398,12 @@ next: } } - if (bestX < 0 || bestY < 0) + if (bestX < 0 || bestY < 0) { + free(retPathX); + free(retPathY); + return 0; + } retPathX[numpath] = bestX; retPathY[numpath] = bestY; @@ -389,6 +414,10 @@ next: memcpy(_tempPathX, retPathX, sizeof(int32) * numpath); memcpy(_tempPathY, retPathY, sizeof(int32) * numpath); + + free(retPathX); + free(retPathY); + return true; } @@ -396,6 +425,9 @@ next: curY = bestY; } + free(retPathX); + free(retPathY); + return false; } @@ -406,11 +438,7 @@ void PathFinding::init(Picture *mask) { _height = mask->getHeight(); _currentMask = mask; _heap->unload(); - // In order to reduce memory fragmentation on small devices, we use the maximum - // possible size here which is TOON_BACKBUFFER_WIDTH. Even though this is - // 1280 as opposed to the possible 640, it actually helps memory allocation on - // those devices. - _heap->init(TOON_BACKBUFFER_WIDTH * _height); // should really be _width + _heap->init(500); delete[] _gridTemp; _gridTemp = new int32[_width*_height]; } diff --git a/engines/toon/path.h b/engines/toon/path.h index 329127c9ce..2de58064f0 100644 --- a/engines/toon/path.h +++ b/engines/toon/path.h @@ -38,17 +38,18 @@ public: PathFindingHeap(); ~PathFindingHeap(); - int32 _alloc; - int32 _count; - - int32 push(int32 x, int32 y, int32 weight); - int32 pop(int32 *x, int32 *y, int32 *weight); - int32 init(int32 size); - int32 clear(); - int32 unload(); + void push(int32 x, int32 y, int32 weight); + void pop(int32 *x, int32 *y, int32 *weight); + void init(int32 size); + void clear(); + void unload(); + int32 getCount() { return _count; } private: HeapDataGrid *_data; + + int32 _size; + int32 _count; }; class PathFinding { diff --git a/engines/toon/picture.cpp b/engines/toon/picture.cpp index 0257964fb5..6367165d6f 100644 --- a/engines/toon/picture.cpp +++ b/engines/toon/picture.cpp @@ -29,16 +29,14 @@ namespace Toon { -bool Picture::loadPicture(Common::String file, bool totalPalette /*= false*/) { - debugC(1, kDebugPicture, "loadPicture(%s, %d)", file.c_str(), (totalPalette) ? 1 : 0); +bool Picture::loadPicture(Common::String file) { + debugC(1, kDebugPicture, "loadPicture(%s)", file.c_str()); uint32 size = 0; uint8 *fileData = _vm->resources()->getFileData(file, &size); if (!fileData) return false; - _useFullPalette = totalPalette; - uint32 compId = READ_BE_UINT32(fileData); switch (compId) { @@ -57,6 +55,8 @@ bool Picture::loadPicture(Common::String file, bool totalPalette /*= false*/) { // do we have a palette ? _paletteEntries = (dstsize & 0x7ff) / 3; + _useFullPalette = (_paletteEntries == 256); + // _useFullPalette = true; if (_paletteEntries) { _palette = new uint8[_paletteEntries * 3]; memcpy(_palette, _data + dstsize - (dstsize & 0x7ff), _paletteEntries * 3); @@ -70,7 +70,8 @@ bool Picture::loadPicture(Common::String file, bool totalPalette /*= false*/) { uint32 decSize = READ_LE_UINT32(fileData + 10); _data = new uint8[decSize + 100]; _paletteEntries = READ_LE_UINT16(fileData + 14) / 3; - + _useFullPalette = (_paletteEntries == 256); + if (_paletteEntries) { _palette = new uint8[_paletteEntries * 3]; memcpy(_palette, fileData + 16, _paletteEntries * 3); @@ -322,7 +323,7 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable int32 rx = bx >> 16; int32 ry = by >> 16; - if( rx >= 0 && rx < _width-1 && ry >= 0 && ry < _height) { // sanity check: some lines in the game + if ( rx >= 0 && rx < _width-1 && ry >= 0 && ry < _height) { // sanity check: some lines in the game // were drawing outside the screen causing corruption if (!walkable) { _data[_width * ry + rx] &= 0xe0; diff --git a/engines/toon/picture.h b/engines/toon/picture.h index 23edbc91da..ee0e006702 100644 --- a/engines/toon/picture.h +++ b/engines/toon/picture.h @@ -38,7 +38,7 @@ class Picture { public: Picture(ToonEngine *vm); ~Picture(); - bool loadPicture(Common::String file, bool totalPalette = false); + bool loadPicture(Common::String file); void setupPalette(); void draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy); void drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int32 dx, int32 dy, Common::Array<Common::Rect>& rectArray); diff --git a/engines/toon/resource.cpp b/engines/toon/resource.cpp index cef916c7de..384a363d7d 100644 --- a/engines/toon/resource.cpp +++ b/engines/toon/resource.cpp @@ -41,7 +41,7 @@ Resources::~Resources() { delete temp; } - while(!_pakFiles.empty()) { + while (!_pakFiles.empty()) { PakFile *temp = _pakFiles.back(); _pakFiles.pop_back(); delete temp; diff --git a/engines/toon/script.cpp b/engines/toon/script.cpp index eed781295a..69ae727bb5 100644 --- a/engines/toon/script.cpp +++ b/engines/toon/script.cpp @@ -502,4 +502,3 @@ void EMCInterpreter::loadState(EMCState *script, Common::ReadStream *stream) { } } // End of namespace Toon - diff --git a/engines/toon/script.h b/engines/toon/script.h index 9dd00dca80..8ef085f383 100644 --- a/engines/toon/script.h +++ b/engines/toon/script.h @@ -148,4 +148,3 @@ private: } // End of namespace Toon #endif - diff --git a/engines/toon/script_func.cpp b/engines/toon/script_func.cpp index 005a299502..e9b7534198 100644 --- a/engines/toon/script_func.cpp +++ b/engines/toon/script_func.cpp @@ -223,7 +223,7 @@ ScriptFunc::ScriptFunc(ToonEngine *vm) { } ScriptFunc::~ScriptFunc(void) { - while(!_opcodes.empty()) { + while (!_opcodes.empty()) { const OpcodeV2 *temp = _opcodes.back(); _opcodes.pop_back(); delete temp; @@ -655,13 +655,15 @@ int32 ScriptFunc::sys_Cmd_Set_Flux_Facing_Point(EMCState *state) { int32 fx = stackPos(0); int32 fy = stackPos(1); _vm->getFlux()->setFacing(_vm->getFlux()->getFacingFromDirection(fx - _vm->getFlux()->getX(), fy - _vm->getFlux()->getY())); - _vm->getFlux()->playStandingAnim(); + if (_vm->getFlux()->getFlag() == 0) // don't reset the animation unless Flux is in idle mode + _vm->getFlux()->playStandingAnim(); return 1; } int32 ScriptFunc::sys_Cmd_Set_Flux_Facing(EMCState *state) { _vm->getFlux()->forceFacing(stackPos(0)); - _vm->getFlux()->playStandingAnim(); + if (_vm->getFlux()->getFlag() == 0) // don't reset the animation unless Flux is in idle mode + _vm->getFlux()->playStandingAnim(); return 0; } @@ -990,7 +992,7 @@ int32 ScriptFunc::sys_Cmd_Set_Scene_Animation_Active_Flag(EMCState *state) { if (sceneAnim->_active) { sceneAnim->_animInstance->setVisible(activeFlag > 0); - if(activeFlag) { + if (activeFlag) { _vm->getAnimationManager()->addInstance(sceneAnim->_animInstance); } } diff --git a/engines/toon/tools.cpp b/engines/toon/tools.cpp index c2ee8acf8a..added39940 100644 --- a/engines/toon/tools.cpp +++ b/engines/toon/tools.cpp @@ -383,7 +383,7 @@ int32 RncDecoder::unpackM1(const void *input, uint16 inputSize, void *output) { uint16 b; if (_inputByteLeft <= 2) b = 0; - else if(_inputByteLeft == 3) + else if (_inputByteLeft == 3) b = *(_srcPtr + 2); else b = READ_LE_UINT16(_srcPtr + 2); diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index cb41db1967..b3ab591ba7 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -191,11 +191,11 @@ void ToonEngine::parseInput() { _audioManager->stopCurrentVoice(); } if (event.kbd.keycode == Common::KEYCODE_F5 && !hasModifier) { - if(canSaveGameStateCurrently()) + if (canSaveGameStateCurrently()) saveGame(-1, Common::String()); } if (event.kbd.keycode == Common::KEYCODE_F6 && !hasModifier) { - if(canLoadGameStateCurrently()) + if (canLoadGameStateCurrently()) loadGame(-1); } if (event.kbd.ascii == 't' && !hasModifier) { @@ -509,7 +509,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) { Common::Rect rect = _oldDirtyRects[i]; rect.translate(-state()->_currentScrollValue, 0); offX = 0; - if(rect.right <= 0) + if (rect.right <= 0) continue; if (rect.left < 0) { offX = -rect.left; @@ -614,7 +614,7 @@ struct MainMenuEntry { bool ToonEngine::showMainmenu(bool &loadedGame) { Picture *mainmenuPicture = new Picture(this); - mainmenuPicture->loadPicture("TITLESCR.CPS", true); + mainmenuPicture->loadPicture("TITLESCR.CPS"); mainmenuPicture->setupPalette(); flushPalette(false); @@ -663,7 +663,7 @@ bool ToonEngine::showMainmenu(bool &loadedGame) { while (!clickRelease) { - if(_dirtyAll) { + if (_dirtyAll) { mainmenuPicture->draw(*_mainSurface, 0, 0, 0, 0); addDirtyRect(0, 0, TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT); } else { @@ -690,6 +690,11 @@ bool ToonEngine::showMainmenu(bool &loadedGame) { } } + if (_needPaletteFlush) { + flushPalette(false); + _needPaletteFlush = false; + } + parseInput(); copyToVirtualScreen(true); _system->delayMillis(17); @@ -931,7 +936,7 @@ ToonEngine::~ToonEngine() { delete _animationManager; delete _moviePlayer; - if(_mainSurface) { + if (_mainSurface) { _mainSurface->free(); delete _mainSurface; } @@ -1498,7 +1503,7 @@ void ToonEngine::clickEvent() { if (leftButton) createMouseItem(104); else - characterTalk(518); + characterTalk(1104); } } if (_currentHotspotItem == -4) { @@ -1547,7 +1552,7 @@ void ToonEngine::clickEvent() { return; } } else { - if (!_drew->walkTo(_mouseX, _mouseY)) { + if (!_drew->walkTo(_mouseX + _gameState->_currentScrollValue, _mouseY)) { // walk was canceled ? return; } @@ -2600,7 +2605,7 @@ int32 ToonEngine::showInventory() { delete _inventoryPicture; _inventoryPicture = new Picture(this); fadeOut(5); - _inventoryPicture->loadPicture("SACK128.CPS", true); + _inventoryPicture->loadPicture("SACK128.CPS"); _inventoryPicture->setupPalette(); dirtyAllScreen(); @@ -2695,7 +2700,7 @@ int32 ToonEngine::showInventory() { } renderInventory(); - + _system->delayMillis(10); } _gameState->_currentScrollValue = oldScrollValue; @@ -2786,7 +2791,7 @@ void ToonEngine::showCutaway(Common::String cutawayPicture) { if (cutawayPicture == "") { cutawayPicture = Common::String(_gameState->_locations[_gameState->_currentScene]._cutaway) + ".CPS"; } - _currentCutaway->loadPicture(cutawayPicture, false); + _currentCutaway->loadPicture(cutawayPicture); _currentCutaway->setupPalette(); _oldScrollValue = _gameState->_currentScrollValue; _gameState->_currentScrollValue = 0; @@ -3418,7 +3423,7 @@ void ToonEngine::viewInventoryItem(Common::String str, int32 lineId, int32 itemD fadeOut(5); Picture *pic = new Picture(this); - pic->loadPicture(str, false); + pic->loadPicture(str); pic->setupPalette(); dirtyAllScreen(); flushPalette(); @@ -4672,7 +4677,7 @@ void ToonEngine::makeLineWalkable(int32 x, int32 y, int32 x2, int32 y2) { } void ToonEngine::playRoomMusic() { - if(_gameState->_inConversation) { + if (_gameState->_inConversation) { const char* music = getSpecialConversationMusic(_gameState->_currentConversationId); if (music) { _audioManager->playMusic(_gameState->_locations[_gameState->_currentScene]._name, music); |