From eef9f7b57b493cfb7712fd47cb961d16e8ce878d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 9 Oct 2010 11:11:26 +0000 Subject: TOON: Ran astyle over the toon engine (+ some manual corrections). svn-id: r53098 --- engines/toon/anim.cpp | 4 +- engines/toon/anim.h | 4 +- engines/toon/audio.cpp | 2 +- engines/toon/character.cpp | 40 +++---- engines/toon/conversation.cpp | 6 +- engines/toon/conversation.h | 4 +- engines/toon/detection.cpp | 79 +++++++----- engines/toon/drew.cpp | 2 +- engines/toon/flux.cpp | 3 +- engines/toon/font.cpp | 4 +- engines/toon/hotspot.cpp | 6 +- engines/toon/path.cpp | 5 +- engines/toon/path.h | 2 +- engines/toon/picture.cpp | 6 +- engines/toon/picture.h | 2 +- engines/toon/resource.h | 4 +- engines/toon/script.cpp | 20 ++-- engines/toon/script.h | 4 +- engines/toon/script_func.cpp | 17 ++- engines/toon/state.cpp | 20 ++-- engines/toon/toon.cpp | 272 ++++++++++++++++++++---------------------- engines/toon/toon.h | 6 +- 22 files changed, 256 insertions(+), 256 deletions(-) diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp index c5b1ca14a9..4626071b6a 100644 --- a/engines/toon/anim.cpp +++ b/engines/toon/anim.cpp @@ -680,8 +680,8 @@ void AnimationManager::render() { changed = false; for (uint32 i = 0; i < _instances.size() - 1; i++) { if ((_instances[i]->getLayerZ() > _instances[i + 1]->getLayerZ()) || - ((_instances[i]->getLayerZ() == _instances[i + 1]->getLayerZ()) && - (_instances[i]->getId() < _instances[i+1]->getId()))) { + ((_instances[i]->getLayerZ() == _instances[i + 1]->getLayerZ()) && + (_instances[i]->getId() < _instances[i+1]->getId()))) { AnimationInstance *instance = _instances[i]; _instances[i] = _instances[i + 1]; _instances[i + 1] = instance; diff --git a/engines/toon/anim.h b/engines/toon/anim.h index 2672365ee6..7bf633220c 100644 --- a/engines/toon/anim.h +++ b/engines/toon/anim.h @@ -176,8 +176,8 @@ public: int32 _id; bool _active; - void load(ToonEngine* vm,Common::ReadStream *stream); - void save(ToonEngine* vm,Common::WriteStream *stream); + void load(ToonEngine *vm, Common::ReadStream *stream); + void save(ToonEngine *vm, Common::WriteStream *stream); }; class SceneAnimationScript { diff --git a/engines/toon/audio.cpp b/engines/toon/audio.cpp index 7b8737719d..228e583832 100644 --- a/engines/toon/audio.cpp +++ b/engines/toon/audio.cpp @@ -332,7 +332,7 @@ void AudioStreamInstance::decodeADPCM(uint8 *comp, int16 *dest, int32 packetSize _lastADPCMval2 = v19; } -void AudioStreamInstance::play(bool fade, Audio::Mixer::SoundType soundType ) { +void AudioStreamInstance::play(bool fade, Audio::Mixer::SoundType soundType) { debugC(1, kDebugAudio, "play(%d)", (fade) ? 1 : 0); Audio::SoundHandle soundHandle; diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 6c006ae8f8..2de846bfe5 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -55,7 +55,7 @@ Character::Character(ToonEngine *vm) : _vm(vm) { _currentPathNodeCount = 0; _currentPathNode = 0; _visible = true; - _speed = 150; // 150 = nominal drew speed + _speed = 150; // 150 = nominal drew speed _lastWalkTime = 0; _numPixelToWalk = 0; _nextIdleTime = _vm->getSystem()->getMillis() + (_vm->randRange(0, 600) + 300) * _vm->getTickLength(); @@ -75,7 +75,7 @@ void Character::setFacing(int32 facing) { void Character::setPosition(int32 x, int32 y) { debugC(5, kDebugCharacter, "setPosition(%d, %d)", x, y); - + _x = x; _y = y; if (_animationInstance) @@ -86,7 +86,7 @@ void Character::setPosition(int32 x, int32 y) { bool Character::walkTo(int32 newPosX, int32 newPosY) { debugC(1, kDebugCharacter, "walkTo(%d, %d)", newPosX, newPosY); - if (!_visible) + if (!_visible) return true; if (_x == newPosX && _y == newPosY) @@ -95,13 +95,13 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) { _vm->getPathFinding()->resetBlockingRects(); if (_id == 1) { - int32 sizeX = MAX(5,40 * _vm->getDrew()->getScale() / 1024); - int32 sizeY = MAX(2,20 * _vm->getDrew()->getScale() / 1024); - _vm->getPathFinding()->addBlockingEllipse(_vm->getDrew()->getFinalX(),_vm->getDrew()->getFinalY(),sizeX,sizeY ); + int32 sizeX = MAX(5, 40 * _vm->getDrew()->getScale() / 1024); + int32 sizeY = MAX(2, 20 * _vm->getDrew()->getScale() / 1024); + _vm->getPathFinding()->addBlockingEllipse(_vm->getDrew()->getFinalX(), _vm->getDrew()->getFinalY(), sizeX, sizeY); } _vm->getPathFinding()->findClosestWalkingPoint(newPosX, newPosY, &_finalX, &_finalY, _x, _y); - if (_x == _finalX && _y == _finalY) + if (_x == _finalX && _y == _finalY) return true; @@ -131,19 +131,19 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) { setFacing(getFacingFromDirection(dx, dy)); playWalkAnim(0, 0); } - + // in 1/1000 pixels _numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024; _lastWalkTime = _vm->getSystem()->getMillis(); - while(_numPixelToWalk >= 1000 && _currentPathNode < _currentPathNodeCount) { + while (_numPixelToWalk >= 1000 && _currentPathNode < _currentPathNodeCount) { _x = _currentPathX[_currentPathNode]; _y = _currentPathY[_currentPathNode]; _currentPathNode += 1; _numPixelToWalk -= 1000; } setPosition(_x, _y); - + _vm->doFrame(); } playStandingAnim(); @@ -256,7 +256,7 @@ void Character::stopSpecialAnim() { if (_animFlags & 0x40) { playStandingAnim(); } - + #if 0 _animationInstance->setFrame(0); playStandingAnim(); @@ -279,7 +279,7 @@ void Character::update(int32 timeIncrement) { _numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024; _lastWalkTime = _vm->getSystem()->getMillis(); - while(_numPixelToWalk > 1000 && _currentPathNode < _currentPathNodeCount) { + while (_numPixelToWalk > 1000 && _currentPathNode < _currentPathNodeCount) { _x = _currentPathX[_currentPathNode]; _y = _currentPathY[_currentPathNode]; _currentPathNode += 1; @@ -357,7 +357,7 @@ void Character::update(int32 timeIncrement) { } if ((_animFlags & 3) == 2) { - if (_vm->getCurrentLineToSay() != _lineToSayId || !_vm->getAudioManager()->voiceStillPlaying() ) // || (_flags & 8)) && _vm->getAudioManager()->voiceStillPlaying() ) + if (_vm->getCurrentLineToSay() != _lineToSayId || !_vm->getAudioManager()->voiceStillPlaying()) // || (_flags & 8)) && _vm->getAudioManager()->voiceStillPlaying()) _animFlags |= 1; // Strangerke - Commented (not used) @@ -564,12 +564,12 @@ void Character::load(Common::ReadStream *stream) { _finalY = stream->readSint32LE(); _scale = stream->readSint32LE(); _id = stream->readSint32LE(); - + _animScriptId = stream->readSint32LE(); _animFlags = stream->readSint32LE(); _animSpecialDefaultId = stream->readSint32LE(); _sceneAnimationId = stream->readSint32LE(); - + if (_sceneAnimationId > -1) { setAnimationInstance(_vm->getSceneAnimation(_sceneAnimationId)->_animInstance); } @@ -986,7 +986,7 @@ int32 Character::getSceneAnimationId() { return _sceneAnimationId; } -void Character::setDefaultSpecialAnimationId( int32 defaultAnimationId ) { +void Character::setDefaultSpecialAnimationId(int32 defaultAnimationId) { _animSpecialDefaultId = defaultAnimationId; } @@ -1003,16 +1003,16 @@ void Character::updateIdle() { // only flux and drew if (_id > 1) - return; + return; if (_vm->state()->_mouseHidden) - _nextIdleTime = _vm->getOldMilli() + (300 + _vm->randRange(0,600)) * _vm->getTickLength(); + _nextIdleTime = _vm->getOldMilli() + (300 + _vm->randRange(0, 600)) * _vm->getTickLength(); if (_vm->getOldMilli() > _nextIdleTime) { - if ( ((_flags & 1) == 0) || ((_flags & 2) != 0) ) { + if (((_flags & 1) == 0) || ((_flags & 2) != 0)) { if (!_vm->state()->_inCloseUp && !_vm->state()->_inCutaway && _animSpecialId == -1) { if (!_vm->state()->_mouseHidden) { - _nextIdleTime = _vm->getOldMilli() + (300 + _vm->randRange(0,600)) * _vm->getTickLength(); + _nextIdleTime = _vm->getOldMilli() + (300 + _vm->randRange(0, 600)) * _vm->getTickLength(); playAnim(getRandomIdleAnim(), 0, 0x40); _flags |= 0x4; } diff --git a/engines/toon/conversation.cpp b/engines/toon/conversation.cpp index 1bb8dcb9fe..4678ccc1c8 100644 --- a/engines/toon/conversation.cpp +++ b/engines/toon/conversation.cpp @@ -27,16 +27,16 @@ namespace Toon { -void Conversation::save(Common::WriteStream *stream, int16* conversationDataBase) { +void Conversation::save(Common::WriteStream *stream, int16 *conversationDataBase) { stream->writeSint32BE(_enable); for (int32 i = 0; i < 10; i++) { stream->writeSint32BE(state[i]._data2); stream->writeSint16BE(state[i]._data3); - stream->writeSint32BE((int16*)state[i]._data4 - conversationDataBase); + stream->writeSint32BE((int16 *)state[i]._data4 - conversationDataBase); } } -void Conversation::load(Common::ReadStream *stream, int16* conversationDataBase) { +void Conversation::load(Common::ReadStream *stream, int16 *conversationDataBase) { _enable = stream->readSint32BE(); for (int32 i = 0; i < 10; i++) { state[i]._data2 = stream->readSint32BE(); diff --git a/engines/toon/conversation.h b/engines/toon/conversation.h index 03a3aeaa70..784c681055 100644 --- a/engines/toon/conversation.h +++ b/engines/toon/conversation.h @@ -41,8 +41,8 @@ public: void *_data4; // 10 } state[10]; - void save(Common::WriteStream *stream, int16* conversationDataBase); - void load(Common::ReadStream *stream, int16* conversationDataBase); + void save(Common::WriteStream *stream, int16 *conversationDataBase); + void load(Common::ReadStream *stream, int16 *conversationDataBase); }; } // End of namespace Toon diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp index 4a4f836c8b..4c5996edd8 100644 --- a/engines/toon/detection.cpp +++ b/engines/toon/detection.cpp @@ -41,39 +41,54 @@ namespace Toon { using Common::GUIO_NONE; static const ADGameDescription gameDescriptions[] = { - { "toon", "", { - {"local.pak", 0, "3290209ef9bc92692108dd2f45df0736", 3237611}, - {"arcaddbl.svl", 0, "c418478cd2833c7c983799f948af41ac", 7844688}, - {"study.svl", 0, "281efa3f33f6712c0f641a605f4d40fd", 2511090}, - AD_LISTEND}, + { + "toon", "", + { + {"local.pak", 0, "3290209ef9bc92692108dd2f45df0736", 3237611}, + {"arcaddbl.svl", 0, "c418478cd2833c7c983799f948af41ac", 7844688}, + {"study.svl", 0, "281efa3f33f6712c0f641a605f4d40fd", 2511090}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE }, - { "toon", "", { - {"local.pak", 0, "517132c3575b38806d1e7b6f59848072", 3224044}, - {"arcaddbl.svl", 0, "ff74008827b62fbef1f46f104c438e44", 9699256}, - {"study.svl", 0, "df056b94ea83f1ed92a539cf636053ab", 2542668}, - AD_LISTEND}, + { + "toon", "", + { + {"local.pak", 0, "517132c3575b38806d1e7b6f59848072", 3224044}, + {"arcaddbl.svl", 0, "ff74008827b62fbef1f46f104c438e44", 9699256}, + {"study.svl", 0, "df056b94ea83f1ed92a539cf636053ab", 2542668}, + AD_LISTEND + }, Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE }, - { "toon", "", { - {"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841}, - {"arcaddbl.svl", 0, "7a0d74f4d66d1c722b946abbeb0834ef", 9122249}, - {"study.svl", 0, "72fe96a9e10967d3138e918295babc42", 2910283}, - AD_LISTEND}, + { + "toon", "", + { + {"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841}, + {"arcaddbl.svl", 0, "7a0d74f4d66d1c722b946abbeb0834ef", 9122249}, + {"study.svl", 0, "72fe96a9e10967d3138e918295babc42", 2910283}, + AD_LISTEND + }, Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE }, - { "toon", "", { - {"local.pak", 0, "e8645168a247e2abdbfc2f9fa9d1c0fa", 3232222}, - {"arcaddbl.svl", 0, "7893ac4cc78d51356baa058bbee7aa28", 8275016}, - {"study.svl", 0, "b6b1ee2d9d94d53d305856039ab7bde7", 2634620}, - AD_LISTEND}, + { + "toon", "", + { + {"local.pak", 0, "e8645168a247e2abdbfc2f9fa9d1c0fa", 3232222}, + {"arcaddbl.svl", 0, "7893ac4cc78d51356baa058bbee7aa28", 8275016}, + {"study.svl", 0, "b6b1ee2d9d94d53d305856039ab7bde7", 2634620}, + AD_LISTEND + }, Common::ES_ESP, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE }, - { "toon", "", { - {"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841}, - {"wacexdbl.emc", 0, "cfbc2156a31b294b038204888407ebc8", 6974}, - {"generic.svl", 0, "5eb99850ada22f0b8cf6392262d4dd07", 9404599}, - AD_LISTEND}, + { + "toon", "", + { + {"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841}, + {"wacexdbl.emc", 0, "cfbc2156a31b294b038204888407ebc8", 6974}, + {"generic.svl", 0, "5eb99850ada22f0b8cf6392262d4dd07", 9404599}, + AD_LISTEND + }, Common::DE_DEU, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE }, @@ -135,12 +150,12 @@ public: bool ToonMetaEngine::hasFeature(MetaEngineFeature f) const { return - (f == kSupportsListSaves) || -// (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave) || - (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail) || - (f == kSavesSupportCreationDate); + (f == kSupportsListSaves) || +// (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate); } int ToonMetaEngine::getMaximumSaveSlot() const { return 99; } @@ -152,7 +167,7 @@ SaveStateList ToonMetaEngine::listSaves(const char *target) const { pattern += ".???"; filenames = saveFileMan->listSavefiles(pattern); - sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) SaveStateList saveList; int slotNum = 0; diff --git a/engines/toon/drew.cpp b/engines/toon/drew.cpp index b079bfc9a0..5d60e5bdbd 100644 --- a/engines/toon/drew.cpp +++ b/engines/toon/drew.cpp @@ -22,7 +22,7 @@ * $Id$ * */ - + #include "toon/drew.h" namespace Toon { diff --git a/engines/toon/flux.cpp b/engines/toon/flux.cpp index 4d451b2ff1..0d5ee06d2f 100644 --- a/engines/toon/flux.cpp +++ b/engines/toon/flux.cpp @@ -52,8 +52,7 @@ void CharacterFlux::playStandingAnim() { void CharacterFlux::setVisible(bool visible) { if (_vm->state()->_currentChapter == 2) { Character::setVisible(false); - } - else { + } else { Character::setVisible(visible); } } diff --git a/engines/toon/font.cpp b/engines/toon/font.cpp index e70acab706..be5a306d8c 100644 --- a/engines/toon/font.cpp +++ b/engines/toon/font.cpp @@ -132,7 +132,7 @@ void FontRenderer::setFontColorByCharacter(int32 characterId) { debugC(5, kDebugFont, "setFontColorByCharacter(%d)", characterId); // unfortunately this table was hardcoded in the original executable - static const byte colorsByCharacters[] = { + static const byte colorsByCharacters[] = { 0xe0, 0xdc, 0xc8, 0xd6, 0xc1, 0xc8, 0xe9, 0xde, 0xc8, 0xeb, 0xe8, 0xc8, 0xd1, 0xcf, 0xc8, 0xd8, 0xd5, 0xc8, 0xfb, 0xfa, 0xc8, 0xd9, 0xd7, 0xc8, 0xe8, 0xe4, 0xc8, 0xe9, 0xfa, 0xc8, 0xeb, 0xe4, 0xc8, 0xeb, 0xe4, 0xc8, @@ -247,7 +247,7 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, Common::String origText // adapt x if (x - 30 - maxWidth / 2 < 0) x = maxWidth / 2 + 30; - + if (x + 30 + (maxWidth / 2) > 640) x = 640 - (maxWidth / 2) - 30; diff --git a/engines/toon/hotspot.cpp b/engines/toon/hotspot.cpp index d29e4f55a6..3ddda1450b 100644 --- a/engines/toon/hotspot.cpp +++ b/engines/toon/hotspot.cpp @@ -42,7 +42,7 @@ void Hotspots::load(Common::ReadStream *Stream) { for (int32 i = 0; i < _numItems; i++) { for (int32 a = 0; a < 256; a++) - _items[i].setData(a,Stream->readSint16BE()); + _items[i].setData(a, Stream->readSint16BE()); } } @@ -104,7 +104,7 @@ bool Hotspots::LoadRif(Common::String rifName, Common::String additionalRifName) uint32 size = 0; uint8 *rifData = _vm->resources()->getFileData(rifName, &size); - if (!rifData) + if (!rifData) return false; uint32 size2 = 0; @@ -121,7 +121,7 @@ bool Hotspots::LoadRif(Common::String rifName, Common::String additionalRifName) _numItems = (rifsize + rifsize2) / 512; - if (_items) + if (_items) delete[] _items; _items = new HotspotData[_numItems]; diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index bbd6a7bf2f..be0358f588 100644 --- a/engines/toon/path.cpp +++ b/engines/toon/path.cpp @@ -144,8 +144,7 @@ bool PathFinding::isWalkable(int32 x, int32 y) { if (_blockingRects[i][4] == 0) { if (x >= _blockingRects[i][0] && x <= _blockingRects[i][2] && y >= _blockingRects[i][1] && y < _blockingRects[i][3]) return false; - } - else { + } else { int32 dx = abs(_blockingRects[i][0] - x); int32 dy = abs(_blockingRects[i][1] - y); if ((dx << 8) / _blockingRects[i][2] < (1 << 8) && (dy << 8) / _blockingRects[i][3] < (1 << 8)) { @@ -200,7 +199,7 @@ int PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { _gridPathCount = 0; return true; } - + memset(_gridTemp , 0, _width * _height * sizeof(int32)); _heap->clear(); int32 curX = x; diff --git a/engines/toon/path.h b/engines/toon/path.h index 4846206008..d8ef2eac02 100644 --- a/engines/toon/path.h +++ b/engines/toon/path.h @@ -63,7 +63,7 @@ public: void resetBlockingRects(); void addBlockingRect(int32 x1, int32 y1, int32 x2, int32 y2); - void addBlockingEllipse(int32 x1, int32 y1, int32 w, int32 h); + void addBlockingEllipse(int32 x1, int32 y1, int32 w, int32 h); int32 getPathNodeCount() const; int32 getPathNodeX(int32 nodeId) const; diff --git a/engines/toon/picture.cpp b/engines/toon/picture.cpp index c14d91b1e8..52dc6cedb2 100644 --- a/engines/toon/picture.cpp +++ b/engines/toon/picture.cpp @@ -220,7 +220,7 @@ uint8 Picture::getData(int32 x, int32 y) { } // use original work from johndoe -void Picture::floodFillNotWalkableOnMask( int32 x, int32 y ) { +void Picture::floodFillNotWalkableOnMask(int32 x, int32 y) { debugC(1, kDebugPicture, "floodFillNotWalkableOnMask(%d, %d)", x, y); // Stack-based floodFill algorithm based on @@ -254,7 +254,7 @@ void Picture::floodFillNotWalkableOnMask( int32 x, int32 y ) { } } -void Picture::drawLineOnMask( int32 x, int32 y, int32 x2, int32 y2, bool walkable ) { +void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable) { debugC(1, kDebugPicture, "drawLineOnMask(%d, %d, %d, %d, %d)", x, y, x2, y2, (walkable) ? 1 : 0); static int32 lastX = 0; @@ -291,7 +291,7 @@ void Picture::drawLineOnMask( int32 x, int32 y, int32 x2, int32 y2, bool walkabl _data[_width * (by >> 16) + (bx >> 16)] = v; _data[_width * (by >> 16) + (bx >> 16)+1] = v; } - + bx += cdx; by += cdy; i--; diff --git a/engines/toon/picture.h b/engines/toon/picture.h index 917c66cb93..5065843b3c 100644 --- a/engines/toon/picture.h +++ b/engines/toon/picture.h @@ -45,7 +45,7 @@ public: void draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy); void drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy); void drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable); - void floodFillNotWalkableOnMask( int32 x, int32 y ); + void floodFillNotWalkableOnMask(int32 x, int32 y); uint8 getData(int32 x, int32 y); uint8 *getDataPtr() { return _data; } int32 getWidth() const { return _width; } diff --git a/engines/toon/resource.h b/engines/toon/resource.h index f1d472cdd6..3a080fe894 100644 --- a/engines/toon/resource.h +++ b/engines/toon/resource.h @@ -42,7 +42,7 @@ public: uint8 *getFileData(Common::String fileName, uint32 *fileSize); Common::String getPackName() { return _packName; } Common::SeekableReadStream *createReadStream(Common::String fileName); - void close(); + void close(); protected: struct File { @@ -68,7 +68,7 @@ class Resources { public: Resources(ToonEngine *vm); void openPackage(Common::String file, bool preloadEntirePackage); - void closePackage(Common::String fileName); + void closePackage(Common::String fileName); Common::SeekableReadStream *openFile(Common::String file); uint8 *getFileData(Common::String fileName, uint32 *fileSize); diff --git a/engines/toon/script.cpp b/engines/toon/script.cpp index 5598e8e10c..efd100db61 100644 --- a/engines/toon/script.cpp +++ b/engines/toon/script.cpp @@ -214,8 +214,8 @@ bool EMCInterpreter::run(EMCState *script) { error("Unknown script opcode: %d in file '%s' at offset 0x%.08X", opcode, script->dataPtr->filename, instOffset); } else { static bool EMCDebug = false; - if (EMCDebug ) - debugC(5, 0, "[0x%.08X] EMCInterpreter::%s([%d/%u])", instOffset*2, _opcodes[opcode].desc, _parameter, (uint)_parameter); + if (EMCDebug) + debugC(5, 0, "[0x%.08X] EMCInterpreter::%s([%d/%u])", instOffset * 2, _opcodes[opcode].desc, _parameter, (uint)_parameter); //debug(0, "[0x%.08X] EMCInterpreter::%s([%d/%u])", instOffset, _opcodes[opcode].desc, _parameter, (uint)_parameter); (this->*(_opcodes[opcode].proc))(script); @@ -457,16 +457,15 @@ void EMCInterpreter::op_setRetAndJmp(EMCState *script) { } } -void EMCInterpreter::saveState(EMCState* script, Common::WriteStream * stream) { +void EMCInterpreter::saveState(EMCState *script, Common::WriteStream *stream) { stream->writeSint16LE(script->bp); stream->writeSint16LE(script->sp); if (!script->ip) { stream->writeSint16LE(-1); - } - else { + } else { stream->writeSint16LE(script->ip - script->dataPtr->data); } - + for (int32 i = 0; i < EMCState::kStackSize; i++) { stream->writeSint16LE(script->stack[i]); } @@ -478,18 +477,17 @@ void EMCInterpreter::saveState(EMCState* script, Common::WriteStream * stream) { stream->writeSint16LE(script->retValue); stream->writeByte(script->running); } -void EMCInterpreter::loadState(EMCState* script, Common::ReadStream* stream) { +void EMCInterpreter::loadState(EMCState *script, Common::ReadStream *stream) { script->bp = stream->readSint16LE(); script->sp = stream->readSint16LE(); int16 scriptIp = stream->readSint16LE(); - if(scriptIp == -1) { + if (scriptIp == -1) { script->ip = 0; - } - else { + } else { script->ip = scriptIp + script->dataPtr->data; } - + for (int32 i = 0; i < EMCState::kStackSize; i++) { script->stack[i] = stream->readSint16LE(); } diff --git a/engines/toon/script.h b/engines/toon/script.h index 941b892179..47e04e8c82 100644 --- a/engines/toon/script.h +++ b/engines/toon/script.h @@ -104,8 +104,8 @@ public: void init(EMCState *scriptState, const EMCData *data); bool start(EMCState *script, int function); - void saveState(EMCState* script, Common::WriteStream * stream); - void loadState(EMCState* script, Common::ReadStream* stream); + void saveState(EMCState *script, Common::WriteStream *stream); + void loadState(EMCState *script, Common::ReadStream *stream); bool isValid(EMCState *script); diff --git a/engines/toon/script_func.cpp b/engines/toon/script_func.cpp index e2842e0e6b..724f120755 100644 --- a/engines/toon/script_func.cpp +++ b/engines/toon/script_func.cpp @@ -388,7 +388,7 @@ int32 ScriptFunc::sys_Cmd_Set_Initial_Location(EMCState *state) { } int32 ScriptFunc::sys_Cmd_Make_Line_Non_Walkable(EMCState *state) { - _vm->makeLineNonWalkable(stackPos(0),stackPos(1),stackPos(2),stackPos(3)); + _vm->makeLineNonWalkable(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); // we have to store some info for savegame _vm->getSaveBufferStream()->writeSint16BE(2); // 2 = sys_Cmd_Make_Line_Non_Walkable @@ -400,7 +400,7 @@ int32 ScriptFunc::sys_Cmd_Make_Line_Non_Walkable(EMCState *state) { } int32 ScriptFunc::sys_Cmd_Make_Line_Walkable(EMCState *state) { - _vm->makeLineWalkable(stackPos(0),stackPos(1),stackPos(2),stackPos(3)); + _vm->makeLineWalkable(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); // we have to store some info for savegame _vm->getSaveBufferStream()->writeSint16BE(3); // 3 = sys_Cmd_Make_Line_Walkable @@ -784,7 +784,7 @@ int32 ScriptFunc::sys_Cmd_Get_Mouse_Y(EMCState *state) { } int32 ScriptFunc::sys_Cmd_Fade_Palette(EMCState *state) { - debugC(0,0xfff, "fadePalette %d %d", stackPos(0),stackPos(1)); + debugC(0, 0xfff, "fadePalette %d %d", stackPos(0), stackPos(1)); return 0; } @@ -829,8 +829,8 @@ int32 ScriptFunc::sys_Cmd_Draw_Scene_Anim_WSA_Frame_To_Back(EMCState *state) { // we have to store some info for savegame _vm->getSaveBufferStream()->writeSint16BE(1); // 1 = Draw_Scene_Anim_WSA_Frame_To_Back _vm->getSaveBufferStream()->writeSint16BE(frame); - _vm->getSaveBufferStream()->writeSint16BE(strlen(sceneAnim->_animInstance->getAnimation()->_name)+1); - _vm->getSaveBufferStream()->write(sceneAnim->_animInstance->getAnimation()->_name, strlen(sceneAnim->_animInstance->getAnimation()->_name)+1); + _vm->getSaveBufferStream()->writeSint16BE(strlen(sceneAnim->_animInstance->getAnimation()->_name) + 1); + _vm->getSaveBufferStream()->write(sceneAnim->_animInstance->getAnimation()->_name, strlen(sceneAnim->_animInstance->getAnimation()->_name) + 1); _vm->getSaveBufferStream()->writeSint16BE(sceneAnim->_animInstance->getX()); _vm->getSaveBufferStream()->writeSint16BE(sceneAnim->_animInstance->getY()); _vm->getSaveBufferStream()->writeSint16BE(sceneAnim->_animInstance->getZ()); @@ -905,7 +905,6 @@ int32 ScriptFunc::sys_Cmd_Init_Scene_Anim(EMCState *state) { _vm->getAnimationManager()->addInstance(sceneAnim->_animInstance); - debugC(0, 0xfff, "Init Anim %s %d %d %d %d %d %d %d %d %d %d %d %d %d\n", GetText(12, state), stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9), stackPos(10), stackPos(11), stackPos(12)); @@ -979,7 +978,7 @@ int32 ScriptFunc::sys_Cmd_Draw_Scene_Anim_WSA_Frame(EMCState *state) { else if (animId == 20 || animId == 15 || animId == 21 || animId == 16 || animId == 17 || animId == 18) _vm->pauseSceneAnimationScript(_vm->getCurrentUpdatingSceneAnimation(), 1); } - + if (_vm->state()->_currentScene == 29) { if (animId == 16 || animId == 26 || animId == 36) _vm->pauseSceneAnimationScript(_vm->getCurrentUpdatingSceneAnimation(), 2); @@ -1004,7 +1003,7 @@ int32 ScriptFunc::sys_Cmd_Run_Actor_Default_Script(EMCState *state) { int32 ScriptFunc::sys_Cmd_Set_Location_Data(EMCState *state) { // initial setup of locations int32 locationId = stackPos(0); - debugC(0,0, "setlocationdata(%d) %s %x %s %s %d %d", locationId, GetText(1,state), stackPos(2), GetText(3,state), GetText(4,state), stackPos(5),stackPos(6)); + debugC(0, 0, "setlocationdata(%d) %s %x %s %s %d %d", locationId, GetText(1, state), stackPos(2), GetText(3, state), GetText(4, state), stackPos(5), stackPos(6)); strcpy(_vm->state()->_locations[locationId]._name, GetText(1, state)); strcpy(_vm->state()->_locations[locationId]._music, GetText(3, state)); strcpy(_vm->state()->_locations[locationId]._cutaway, GetText(4, state)); @@ -1092,7 +1091,7 @@ int32 ScriptFunc::sys_Cmd_Say_Line(EMCState *state) { } int32 ScriptFunc::sys_Cmd_Knight_Puzzle_Get_Coord(EMCState *state) { - static uint16 knightCoords[] = { + static const uint16 knightCoords[] = { 0x327, 0x0fa, 0x354, 0x0f8, 0x383, 0x0f4, 0x3a4, 0x0f0, 0x3d3, 0x0ed, 0x3fd, 0x0ef, 0x2fe, 0x12d, 0x2fe, 0x12d, 0x310, 0x109, 0x349, 0x103, 0x378, 0x103, 0x3a4, 0x102, 0x3d5, 0x102, 0x403, 0x103, 0x2fe, 0x12d, diff --git a/engines/toon/state.cpp b/engines/toon/state.cpp index c7c6582cc6..71674688d5 100644 --- a/engines/toon/state.cpp +++ b/engines/toon/state.cpp @@ -29,26 +29,26 @@ namespace Toon { void Location::save(Common::WriteStream *stream) { - stream->write(_cutaway,64); - stream->write(_music,64); - stream->write(_name,64); + stream->write(_cutaway, 64); + stream->write(_music, 64); + stream->write(_name, 64); stream->writeSint16BE(_numRifBoxes); stream->writeSint16BE(_numSceneAnimations); stream->writeSByte(_visited); - for (int32 i = 0; i < _numRifBoxes*2; i++) { + for (int32 i = 0; i < _numRifBoxes * 2; i++) { stream->writeSint16BE(_rifBoxesFlags[i]); } } void Location::load(Common::ReadStream *stream) { - stream->read(_cutaway,64); - stream->read(_music,64); - stream->read(_name,64); + stream->read(_cutaway, 64); + stream->read(_music, 64); + stream->read(_name, 64); _numRifBoxes = stream->readSint16BE(); _numSceneAnimations = stream->readSint16BE(); _visited = stream->readSByte(); - for (int32 i = 0; i < _numRifBoxes*2; i++) { + for (int32 i = 0; i < _numRifBoxes * 2; i++) { _rifBoxesFlags[i] = stream->readSint16BE(); } } @@ -135,7 +135,7 @@ bool State::hasItemInInventory(int32 item) { return false; } -void State::save(Common::WriteStream * stream) { +void State::save(Common::WriteStream *stream) { for (int32 i = 0; i < 256; i++) { _locations[i].save(stream); @@ -191,7 +191,7 @@ void State::save(Common::WriteStream * stream) { stream->writeSint32BE(_timerDelay[1]); } -void State::load(Common::ReadStream* stream) { +void State::load(Common::ReadStream *stream) { for (int32 i = 0; i < 256; i++) { _locations[i].load(stream); } diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 4227c363bc..afabba920f 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -89,7 +89,7 @@ void ToonEngine::init() { _saveBufferStream = new Common::MemoryWriteStreamDynamic(); _firstFrame = false; - + const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "misc"); @@ -182,11 +182,10 @@ void ToonEngine::parseInput() { if (saveGame(slotNum)) { // ok char buf[256]; - snprintf(buf, 256, "Saved game in slot #%d ",slotNum); + snprintf(buf, 256, "Saved game in slot #%d ", slotNum); GUI::TimedMessageDialog dialog(buf, 1000); dialog.runModal(); - } - else { + } else { char buf[256]; snprintf(buf, 256, "Could not quick save into slot #%d", slotNum); GUI::MessageDialog dialog2(buf, "OK", 0); @@ -206,8 +205,7 @@ void ToonEngine::parseInput() { snprintf(buf, 256, "Savegame #%d quick loaded", slotNum); GUI::TimedMessageDialog dialog(buf, 1000); dialog.runModal(); - } - else { + } else { char buf[256]; snprintf(buf, 256, "Could not quick load the savegame #%d", slotNum); GUI::MessageDialog dialog(buf, "OK", 0); @@ -257,7 +255,7 @@ void ToonEngine::updateTimers() { if (_gameState->_timerEnabled[i]) { if (_gameState->_timerDelay[i] > -1 && getOldMilli() > _gameState->_timerTimeout[i]) { if (i == 0) { - + EMCState *status = &_scriptState[_currentScriptRegion]; _script->init(status, &_scriptData); @@ -275,7 +273,7 @@ void ToonEngine::updateTimers() { _currentScriptRegion--; _gameState->_timerTimeout[i] = getOldMilli() + _gameState->_timerDelay[i] * getTickLength(); - + return; } @@ -291,7 +289,7 @@ void ToonEngine::updateScrolling(bool force, int32 timeIncrement) { if (_drew->getFacing() <= 4) lastScrollOffset = 200; else - lastScrollOffset = 440; + lastScrollOffset = 440; } if (_gameState->_inCutaway || _gameState->_inInventory || _gameState->_inCloseUp) @@ -302,7 +300,7 @@ void ToonEngine::updateScrolling(bool force, int32 timeIncrement) { if ((_gameState->_locations[_gameState->_currentScene]._flags & 0x80) == 0) { if (desiredScrollValue < 0) desiredScrollValue = 0; - if (desiredScrollValue >= _currentPicture->getWidth() - 640) + if (desiredScrollValue >= _currentPicture->getWidth() - 640) desiredScrollValue = _currentPicture->getWidth() - 640; if (force) { @@ -327,14 +325,14 @@ void ToonEngine::updateScrolling(bool force, int32 timeIncrement) { void ToonEngine::update(int32 timeIncrement) { // to make sure we're updating the game at 5fps at least - if (timeIncrement > 200) + if (timeIncrement > 200) timeIncrement = 200; updateAnimationSceneScripts(timeIncrement); updateCharacters(timeIncrement); updateTimer(timeIncrement); updateTimers(); - updateScrolling(false,timeIncrement); + updateScrolling(false, timeIncrement); _animationManager->update(timeIncrement); _cursorAnimationInstance->update(timeIncrement); @@ -346,7 +344,7 @@ void ToonEngine::update(int32 timeIncrement) { void ToonEngine::updateTimer(int32 timeIncrement) { if (_gameState->_gameTimer > 0) { - debugC(0, 0xfff,"updateTimer(%d)", timeIncrement); + debugC(0, 0xfff, "updateTimer(%d)", timeIncrement); _gameState->_gameTimer -= timeIncrement; if (_gameState->_gameTimer < 0) _gameState->_gameTimer = 0; @@ -371,10 +369,10 @@ void ToonEngine::render() { #if 0 char test[256]; if (_mouseX > 0 && _mouseX < 640 && _mouseY > 0 && _mouseY < 400) { - sprintf(test, "%d %d / mask %d layer %d z %d", _mouseX, _mouseY, getMask()->getData(_mouseX,_mouseY), getLayerAtPoint(_mouseX,_mouseY), getZAtPoint(_mouseX,_mouseY)); + sprintf(test, "%d %d / mask %d layer %d z %d", _mouseX, _mouseY, getMask()->getData(_mouseX, _mouseY), getLayerAtPoint(_mouseX, _mouseY), getZAtPoint(_mouseX, _mouseY)); - int32 c = *(uint8*)_mainSurface->getBasePtr(_mouseX,_mouseY); - sprintf(test, "%d %d / color id %d %d,%d,%d", _mouseX, _mouseY, c, _finalPalette[c*3+0],_finalPalette[c*3+1],_finalPalette[c*3+2]); + int32 c = *(uint8 *)_mainSurface->getBasePtr(_mouseX, _mouseY); + sprintf(test, "%d %d / color id %d %d,%d,%d", _mouseX, _mouseY, c, _finalPalette[c*3+0], _finalPalette[c*3+1], _finalPalette[c*3+2]); _fontRenderer->setFont(_fontToon); _fontRenderer->renderText(40, 150, Common::String(test), 0); @@ -397,7 +395,7 @@ void ToonEngine::copyToVirtualScreen(bool updateScreen) { _cursorAnimationInstance->render(); } _system->copyRectToScreen((byte *)_mainSurface->pixels + state()->_currentScrollValue, 1280, 0, 0, 640, 400); - if (updateScreen) + if (updateScreen) _system->updateScreen(); } @@ -411,7 +409,7 @@ void ToonEngine::doFrame() { int32 currentTimer = _system->getMillis(); // Strangerke - Commented (not used) // int32 elapsedTime = currentTimer - _oldTimer; - + update(currentTimer - _oldTimer); _oldTimer = currentTimer; _oldTimer2 = currentTimer; @@ -470,7 +468,7 @@ struct MainMenuEntry { int activeFrame; }; -bool ToonEngine::showMainmenu(bool& loadedGame) { +bool ToonEngine::showMainmenu(bool &loadedGame) { Picture *mainmenuPicture = new Picture(this); mainmenuPicture->loadPicture("TITLESCR.CPS", true); mainmenuPicture->setupPalette(); @@ -529,7 +527,7 @@ bool ToonEngine::showMainmenu(bool& loadedGame) { entries[entryNr].animation->drawFrame(*_mainSurface, frameNr, 0, 0); } } - + parseInput(); copyToVirtualScreen(true); _system->delayMillis(17); @@ -576,7 +574,7 @@ bool ToonEngine::showMainmenu(bool& loadedGame) { musicPlaying = false; } - + switch (clickingOn) { case MAINMENUHOTSPOT_START: @@ -624,7 +622,7 @@ Common::Error ToonEngine::run() { // show mainmenu bool loadedGame = false; - if(!showMainmenu(loadedGame)) { + if (!showMainmenu(loadedGame)) { return Common::kNoError; } @@ -683,10 +681,10 @@ ToonEngine::ToonEngine(OSystem *syst, const ADGameDescription *gameDescription) _gameVariant = 3; break; default: - // 0 - english + // 0 - english _gameVariant = 0; break; - } + } } ToonEngine::~ToonEngine() { @@ -756,14 +754,14 @@ void ToonEngine::updateAnimationSceneScripts(int32 timeElapsed) { do { if (_sceneAnimationScripts[_lastProcessedSceneScript]._lastTimer <= _system->getMillis() && - !_sceneAnimationScripts[_lastProcessedSceneScript]._frozen) { + !_sceneAnimationScripts[_lastProcessedSceneScript]._frozen) { _animationSceneScriptRunFlag = true; while (_animationSceneScriptRunFlag && _sceneAnimationScripts[_lastProcessedSceneScript]._lastTimer <= _system->getMillis() && !shouldQuit()) { if (!_script->run(&_sceneAnimationScripts[_lastProcessedSceneScript]._state)) _animationSceneScriptRunFlag = false; - if (_sceneAnimationScripts[_lastProcessedSceneScript]._frozen) + if (_sceneAnimationScripts[_lastProcessedSceneScript]._frozen) break; } @@ -813,7 +811,7 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) { do { _gameState->_currentChapter++; flag >>= 1; - } while((flag & 1) == 0); + } while ((flag & 1) == 0); } for (int32 i = 0; i < 8; i++) { @@ -823,7 +821,7 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) { _drew->setVisible(true); // hide flux in chapter 2 - if ( _gameState->_currentChapter == 1) { + if (_gameState->_currentChapter == 1) { _flux->playStandingAnim(); _flux->setVisible(true); } else { @@ -841,7 +839,7 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) { _gameState->_currentScrollValue = 0; _gameState->_currentScrollLock = false; _gameState->_inCloseUp = false; - + if (_gameState->_mouseState >= 0) addItemToInventory(_gameState->_mouseState); @@ -976,7 +974,7 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) { if (!forGameLoad) { - + _script->start(&_scriptState[0], 0); while (_script->run(&_scriptState[0])) @@ -1084,10 +1082,10 @@ void ToonEngine::loadCursor() { void ToonEngine::setCursor(int32 type, bool inventory, int32 offsetX, int32 offsetY) { - static int32 offsets[] = { - 0, 1, 1, 6, 7, 1, 8, 10, 18, 10, - 28, 8, 36, 10, 46, 10, 56, 10, 66, 10, - 76, 10, 86, 10, 96, 10, 106, 10, 116, 10, + static const int32 offsets[] = { + 0, 1, 1, 6, 7, 1, 8, 10, 18, 10, + 28, 8, 36, 10, 46, 10, 56, 10, 66, 10, + 76, 10, 86, 10, 96, 10, 106, 10, 116, 10, 126, 10 }; @@ -1245,8 +1243,7 @@ void ToonEngine::clickEvent() { // walk was canceled ? return; } - } - else { + } else { if (!_drew->walkTo(_mouseX, _mouseY)) { // walk was canceled ? return; @@ -1275,7 +1272,7 @@ void ToonEngine::clickEvent() { break; case 6: createMouseItem(argument); - currentHot->setData(7,-1); + currentHot->setData(7, -1); break; case 7: // switch to CloseUp @@ -1313,7 +1310,7 @@ void ToonEngine::clickEvent() { int32 val = _scriptState[_currentScriptRegion].regs[4]; currentHot->setData(4, currentHot->getData(4) & val); } - + } void ToonEngine::selectHotspot() { @@ -1447,14 +1444,13 @@ void ToonEngine::exitScene() { delete _characters[i]; _characters[i] = 0; } - } - else { + } else { _characters[i]->stopSpecialAnim(); } } for (int32 i = 0; i < 2; i++) { - _gameState->_timerEnabled[i] = false; + _gameState->_timerEnabled[i] = false; } // put back our item if inventory if needed @@ -1641,7 +1637,7 @@ void ToonEngine::sayLines(int numLines, int dialogId) { if (currentLine < 1000) currentLine = _roomTexts->getNext(currentLine); else - currentLine = _genericTexts->getNext(currentLine-1000) + 1000; + currentLine = _genericTexts->getNext(currentLine - 1000) + 1000; } #if 0 @@ -1664,7 +1660,7 @@ int32 ToonEngine::simpleCharacterTalk(int32 dialogid) { myLine = _genericTexts->getText(dialogid - 1000); myId = dialogid - 1000; } - debugC(0, 0xfff, "Talker = %d will say '%s' \n", READ_LE_UINT16(c-2), myLine); + debugC(0, 0xfff, "Talker = %d will say '%s' \n", READ_LE_UINT16(c - 2), myLine); #endif if (_audioManager->voiceStillPlaying()) @@ -1689,17 +1685,17 @@ void ToonEngine::playTalkAnimOnCharacter(int32 animID, int32 characterId, bool t if (talker) { // character talks } - } else + } else #endif if (characterId == 0) { _drew->playAnim(animID, 0, (talker ? 8 : 0) + 2); } else if (characterId == 1) { // stop flux if he is walking - if(_flux->getFlag() & 1) { + if (_flux->getFlag() & 1) { _flux->stopWalk(); } _flux->playAnim(animID, 0, (talker ? 8 : 0) + 2); - _flux->setFlag( _flux->getFlag() | 1 ); + _flux->setFlag(_flux->getFlag() | 1); } else { Character *character = getCharacterById(characterId); if (character) { @@ -1714,7 +1710,7 @@ void ToonEngine::playTalkAnimOnCharacter(int32 animID, int32 characterId, bool t } int32 ToonEngine::characterTalk(int32 dialogid, bool blocking) { - if(blocking == false && _audioManager->voiceStillPlaying()) { + if (blocking == false && _audioManager->voiceStillPlaying()) { // someone is already talking, and this voice is not important // skip it return 0; @@ -1890,7 +1886,7 @@ void ToonEngine::haveAConversation(int32 convId) { a++; } } - if(shouldQuit()) return; + if (shouldQuit()) return; _gameState->_showConversationIcons = false; _gameState->_mouseHidden = 1; @@ -2226,12 +2222,12 @@ int ToonEngine::runConversationCommand(int16 **command) { break; // case 105: - if ( getConversationFlag( _gameState->_currentScene, v4)) { - result = *(int16*)(*command + 4); + if (getConversationFlag(_gameState->_currentScene, v4)) { + result = *(int16 *)(*command + 4); *command = (int16 *)((char *)_conversationData + result); *command = (int16 *)((char *)_conversationData + result - 4); } else { - int16* newPtr = *command + 1; + int16 *newPtr = *command + 1; *command = newPtr; } break; @@ -2324,9 +2320,9 @@ int32 ToonEngine::showInventory() { for (int32 i = 0; i < _gameState->_numInventoryItems; i++) { int32 x = 57 * (i % 7) + 114; int32 y = ((9 * (i % 7)) & 0xf) + 56 * (i / 7) + 80; - if (_mouseX >= (_gameState->_currentScrollValue + x - 6) && - _mouseX <= (_gameState->_currentScrollValue + x + 44 + 7) && - _mouseY >= y - 6 && _mouseY <= y + 50) { + if (_mouseX >= (_gameState->_currentScrollValue + x - 6) && + _mouseX <= (_gameState->_currentScrollValue + x + 44 + 7) && + _mouseY >= y - 6 && _mouseY <= y + 50) { foundObj = i; break; } @@ -2380,7 +2376,7 @@ int32 ToonEngine::showInventory() { } renderInventory(); - + } _gameState->_currentScrollValue = oldScrollValue; @@ -2390,8 +2386,7 @@ int32 ToonEngine::showInventory() { if (_gameState->_inCloseUp) { _gameState->_inCloseUp = false; flipScreens(); - } - else if (_gameState->_inCutaway) { + } else if (_gameState->_inCutaway) { _currentCutaway->setupPalette(); setupGeneralPalette(); } else { @@ -2515,7 +2510,7 @@ void ToonEngine::rearrangeInventory() { } void ToonEngine::newGame() { - + if (_isDemo) { addItemToInventory(59); addItemToInventory(67); @@ -2637,8 +2632,7 @@ bool ToonEngine::saveGame(int32 slot) { savegameId = dialog->runModal(plugin, ConfMan.getActiveDomainName()); savegameDescription = dialog->getResultString(); delete dialog; - } - else { + } else { savegameId = slot; savegameDescription = Common::String::printf("Quick save #%d", slot); } @@ -2654,13 +2648,13 @@ bool ToonEngine::saveGame(int32 slot) { // save savegame header saveFile->writeSint32BE(TOON_SAVEGAME_VERSION); - + if (savegameDescription == "") { savegameDescription = "Untitled savegame"; } - saveFile->writeSint16BE(savegameDescription.size()+1); - saveFile->write(savegameDescription.c_str(), savegameDescription.size()+1); + saveFile->writeSint16BE(savegameDescription.size() + 1); + saveFile->write(savegameDescription.c_str(), savegameDescription.size() + 1); Graphics::saveThumbnail(*saveFile); @@ -2673,7 +2667,7 @@ bool ToonEngine::saveGame(int32 slot) { saveFile->writeUint32BE(saveDate); saveFile->writeUint16BE(saveTime); - + // save global state _gameState->save(saveFile); _gameState->saveConversations(saveFile); @@ -2712,8 +2706,8 @@ bool ToonEngine::saveGame(int32 slot) { // save "command buffer" saveFile->writeSint16BE(_saveBufferStream->pos()); if (_saveBufferStream->pos() > 0) { - saveFile->write(_saveBufferStream->getData(), _saveBufferStream->pos()); - saveFile->writeSint16BE(0); + saveFile->write(_saveBufferStream->getData(), _saveBufferStream->pos()); + saveFile->writeSint16BE(0); } delete saveFile; @@ -2731,8 +2725,7 @@ bool ToonEngine::loadGame(int32 slot) { dialog->setSaveMode(false); savegameId = dialog->runModal(plugin, ConfMan.getActiveDomainName()); delete dialog; - } - else { + } else { savegameId = slot; } if (savegameId < 0) @@ -2800,13 +2793,13 @@ bool ToonEngine::loadGame(int32 slot) { // we have to fix up our pointers... for (int32 a = 0; a < 10; a++) { if (_gameState->_conversationState[i].state[a]._data4) - _gameState->_conversationState[i].state[a]._data4 = (int16*)_gameState->_conversationState[i].state[a]._data4 + diff; + _gameState->_conversationState[i].state[a]._data4 = (int16 *)_gameState->_conversationState[i].state[a]._data4 + diff; } } } */ - _gameState->_conversationData = _conversationData; + _gameState->_conversationData = _conversationData; _firstFrame = true; // read characters info @@ -2817,7 +2810,7 @@ bool ToonEngine::loadGame(int32 slot) { if (!_characters[c]) { _characters[c] = new Character(this); - } + } _characters[c]->load(loadFile); //_characters[c]->setVisible(true); _characters[c]->update(0); @@ -2826,60 +2819,60 @@ bool ToonEngine::loadGame(int32 slot) { // load "command buffer" int32 size = loadFile->readSint16BE(); if (size) { - uint8* buf = new uint8[size+2]; - loadFile->read(buf, size+2); + uint8 *buf = new uint8[size+2]; + loadFile->read(buf, size + 2); - Common::MemoryReadStream rStr(buf, size+2); + Common::MemoryReadStream rStr(buf, size + 2); while (1) { int16 command = rStr.readSint16BE(); if (!command) break; switch (command) { - case 1: { - int16 frame = rStr.readSint16BE(); - int16 animLen = rStr.readSint16BE(); - char animName[32]; - rStr.read(animName,animLen); - int16 x = rStr.readSint16BE(); - int16 y = rStr.readSint16BE(); -// int16 z = rStr.readSint16BE(); -// int16 layerZ = rStr.readSint16BE(); - rStr.readSint16BE(); - rStr.readSint16BE(); - - Animation* anim = new Animation(this); - anim->loadAnimation(animName); - anim->drawFrameOnPicture(frame,x,y); - delete anim; - break; - } - case 2: { - int16 x = rStr.readSint16BE(); - int16 y = rStr.readSint16BE(); - int16 x1 = rStr.readSint16BE(); - int16 y1 = rStr.readSint16BE(); - makeLineNonWalkable(x,y,x1,y1); - break; - } - case 3: { - int16 x = rStr.readSint16BE(); - int16 y = rStr.readSint16BE(); - int16 x1 = rStr.readSint16BE(); - int16 y1 = rStr.readSint16BE(); - makeLineWalkable(x,y,x1,y1); - break; - } - case 4: { - int16 x = rStr.readSint16BE(); - int16 y = rStr.readSint16BE(); - getMask()->floodFillNotWalkableOnMask(x,y); - break; - } - default: - break; + case 1: { + int16 frame = rStr.readSint16BE(); + int16 animLen = rStr.readSint16BE(); + char animName[32]; + rStr.read(animName, animLen); + int16 x = rStr.readSint16BE(); + int16 y = rStr.readSint16BE(); +// int16 z = rStr.readSint16BE(); +// int16 layerZ = rStr.readSint16BE(); + rStr.readSint16BE(); + rStr.readSint16BE(); + + Animation *anim = new Animation(this); + anim->loadAnimation(animName); + anim->drawFrameOnPicture(frame, x, y); + delete anim; + break; + } + case 2: { + int16 x = rStr.readSint16BE(); + int16 y = rStr.readSint16BE(); + int16 x1 = rStr.readSint16BE(); + int16 y1 = rStr.readSint16BE(); + makeLineNonWalkable(x, y, x1, y1); + break; + } + case 3: { + int16 x = rStr.readSint16BE(); + int16 y = rStr.readSint16BE(); + int16 x1 = rStr.readSint16BE(); + int16 y1 = rStr.readSint16BE(); + makeLineWalkable(x, y, x1, y1); + break; + } + case 4: { + int16 x = rStr.readSint16BE(); + int16 y = rStr.readSint16BE(); + getMask()->floodFillNotWalkableOnMask(x, y); + break; + } + default: + break; } } - _saveBufferStream->write(buf,size); + _saveBufferStream->write(buf, size); delete loadFile; } return true; @@ -2934,7 +2927,7 @@ void ToonEngine::initCharacter(int32 characterId, int32 animScriptId, int32 scen // Strangerke - Commented (not used) // if (_characters[characterIndex]) - //delete current char +// delete current char _characters[characterIndex] = new Character(this); _characters[characterIndex]->setId(characterId); @@ -2984,7 +2977,7 @@ void ToonEngine::viewInventoryItem(Common::String str, int32 lineId, int32 itemD storePalette(); fadeOut(5); - Picture* pic = new Picture(this); + Picture *pic = new Picture(this); pic->loadPicture(str, false); pic->setupPalette(); flushPalette(); @@ -3024,14 +3017,14 @@ void ToonEngine::viewInventoryItem(Common::String str, int32 lineId, int32 itemD _firstFrame = false; fadeIn(5); } - + copyToVirtualScreen(); } fadeOut(5); restorePalette(); _firstFrame = true; - _gameState->_currentScrollValue= oldScrollValue; + _gameState->_currentScrollValue = oldScrollValue; delete pic; } @@ -4204,40 +4197,38 @@ char **ToonEngine::loadTextsVariante(Common::File &in) { return res; } -void ToonEngine::makeLineNonWalkable( int32 x, int32 y, int32 x2, int32 y2 ) { - _currentMask->drawLineOnMask(x,y,x2,y2,false); +void ToonEngine::makeLineNonWalkable(int32 x, int32 y, int32 x2, int32 y2) { + _currentMask->drawLineOnMask(x, y, x2, y2, false); } -void ToonEngine::makeLineWalkable( int32 x, int32 y, int32 x2, int32 y2 ) { - _currentMask->drawLineOnMask(x,y,x2,y2,true); +void ToonEngine::makeLineWalkable(int32 x, int32 y, int32 x2, int32 y2) { + _currentMask->drawLineOnMask(x, y, x2, y2, true); } -void SceneAnimation::save(ToonEngine* vm, Common::WriteStream *stream) { +void SceneAnimation::save(ToonEngine *vm, Common::WriteStream *stream) { stream->writeByte(_active); stream->writeSint32BE(_id); - if (!_active) + if (!_active) return; if (_animInstance) { stream->writeByte(1); _animInstance->save(stream); - } - else { + } else { stream->writeByte(0); } if (!_animation) { stream->writeByte(0); - } - else { - stream->writeByte(strlen(_animation->_name)+1); - stream->write(_animation->_name, strlen(_animation->_name)+1); + } else { + stream->writeByte(strlen(_animation->_name) + 1); + stream->write(_animation->_name, strlen(_animation->_name) + 1); } } -void SceneAnimation::load(ToonEngine* vm,Common::ReadStream *stream) { - - _active = stream->readByte(); +void SceneAnimation::load(ToonEngine *vm, Common::ReadStream *stream) { + + _active = stream->readByte(); _id = stream->readSint32BE(); @@ -4256,21 +4247,20 @@ void SceneAnimation::load(ToonEngine* vm,Common::ReadStream *stream) { int8 strSize = stream->readByte(); if (!strSize) { _animation = 0; - if(_animInstance) + if (_animInstance) _animInstance->setAnimation(0); - } - else { + } else { stream->read(animationName, strSize); animationName[strSize] = 0; _animation = new Animation(vm); _animation->loadAnimation(animationName); - if(_animInstance) + if (_animInstance) _animInstance->setAnimation(_animation, false); printf("load animation instance %d / %s / visible %d \n", _id, _animation->_name, _animInstance->getVisible()); } -} +} } // End of namespace Toon diff --git a/engines/toon/toon.h b/engines/toon/toon.h index 9b3adb608e..c8efbaab13 100644 --- a/engines/toon/toon.h +++ b/engines/toon/toon.h @@ -53,7 +53,7 @@ enum ToonGameType { enum ToonDebugChannels { kDebugAnim = 1 << 0, - kDebugCharacter = 1 << 1, + kDebugCharacter = 1 << 1, kDebugAudio = 1 << 2, kDebugHotspot = 1 << 3, kDebugFont = 1 << 4, @@ -91,7 +91,7 @@ public: char **_specialInfoLine; virtual Common::Error run(); - virtual bool showMainmenu(bool& loadedGame); + virtual bool showMainmenu(bool &loadedGame); virtual void init(); bool loadToonDat(); char **loadTextsVariante(Common::File &in); @@ -367,7 +367,7 @@ protected: AudioManager *_audioManager; - Common::MemoryWriteStreamDynamic* _saveBufferStream; + Common::MemoryWriteStreamDynamic *_saveBufferStream; int16 *_conversationData; -- cgit v1.2.3