diff options
author | johndoe123 | 2012-11-19 22:24:03 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:38 +0200 |
commit | b2934eb166ba5b442a93969ad8b4dfbbc6ef3314 (patch) | |
tree | b2ffdaa149da1a7e1a989a6617b19849b3184923 /engines/neverhood | |
parent | cc015e3d24d15dc0c3532063927fd40e2329f43e (diff) | |
download | scummvm-rg350-b2934eb166ba5b442a93969ad8b4dfbbc6ef3314.tar.gz scummvm-rg350-b2934eb166ba5b442a93969ad8b4dfbbc6ef3314.tar.bz2 scummvm-rg350-b2934eb166ba5b442a93969ad8b4dfbbc6ef3314.zip |
NEVERHOOD: Fix Klaymen "grow" animation after drinking the potion
- Remove static sprite 0x50C027A8 Scene2803/Scene2803Small because the resource doesn't exist!
- Remove some old comments
- Fix resource extData handling which fixes some crashes
- Enable reusing deleted sound/music slots in SoundMan (was disabled for debugging)
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/blbarchive.cpp | 3 | ||||
-rw-r--r-- | engines/neverhood/entity.cpp | 9 | ||||
-rw-r--r-- | engines/neverhood/entity.h | 4 | ||||
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 13 | ||||
-rw-r--r-- | engines/neverhood/klayman.cpp | 25 | ||||
-rw-r--r-- | engines/neverhood/klayman.h | 4 | ||||
-rw-r--r-- | engines/neverhood/module2800.cpp | 94 | ||||
-rw-r--r-- | engines/neverhood/resource.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/resourceman.cpp | 8 | ||||
-rw-r--r-- | engines/neverhood/resourceman.h | 5 | ||||
-rw-r--r-- | engines/neverhood/sound.cpp | 10 | ||||
-rw-r--r-- | engines/neverhood/sprite.cpp | 1 |
12 files changed, 81 insertions, 97 deletions
diff --git a/engines/neverhood/blbarchive.cpp b/engines/neverhood/blbarchive.cpp index 02fad55000..748d04c7ca 100644 --- a/engines/neverhood/blbarchive.cpp +++ b/engines/neverhood/blbarchive.cpp @@ -91,7 +91,6 @@ void BlbArchive::open(const Common::String &filename) { BlbArchiveEntry &entry = _entries[i]; entry.type = _fd.readByte(); entry.comprType = _fd.readByte(); - //entry.extDataOfs = _fd.readUint16LE(); entry.extData = NULL; extDataOffsets[i] = _fd.readUint16LE(); entry.timeStamp = _fd.readUint32LE(); @@ -132,7 +131,7 @@ void BlbArchive::load(BlbArchiveEntry *entry, byte *buffer, uint32 size) { break; case 3: // DCL-compressed if (!Common::decompressDCL(&_fd, buffer, entry->diskSize, entry->size)) - error("BlbArchive::load() Error during decompression of %=8X", entry->fileHash); + error("BlbArchive::load() Error during decompression of %08X", entry->fileHash); break; default: error("BlbArchive::load() Unknown compression type %d", entry->comprType); diff --git a/engines/neverhood/entity.cpp b/engines/neverhood/entity.cpp index 29524f8639..c7f1659399 100644 --- a/engines/neverhood/entity.cpp +++ b/engines/neverhood/entity.cpp @@ -46,11 +46,6 @@ Entity *MessageParam::asEntity() const { return _entity; } -// TODO: Disable heavy debug stuff in release mode - -#define SetUpdateHandler(handler) _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler); debug(2, "SetUpdateHandler(" #handler ")"); _updateHandlerCbName = #handler -#define SetMessageHandler(handler) _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam ¶m, Entity *sender)> (handler); debug(2, "SetMessageHandler(" #handler ")"); _messageHandlerCbName = #handler - Entity::Entity(NeverhoodEngine *vm, int priority) : _vm(vm), _updateHandlerCb(NULL), _messageHandlerCb(NULL), _priority(priority), _soundResources(NULL) { } @@ -63,13 +58,13 @@ void Entity::draw() { } void Entity::handleUpdate() { - debug(2, "handleUpdate() -> [%s]", _updateHandlerCbName.c_str()); + debug(5, "handleUpdate() -> [%s]", _updateHandlerCbName.c_str()); if (_updateHandlerCb) (this->*_updateHandlerCb)(); } uint32 Entity::receiveMessage(int messageNum, const MessageParam ¶m, Entity *sender) { - debug(2, "receiveMessage(%04X) -> [%s]", messageNum, _messageHandlerCbName.c_str()); + debug(5, "receiveMessage(%04X) -> [%s]", messageNum, _messageHandlerCbName.c_str()); return _messageHandlerCb ? (this->*_messageHandlerCb)(messageNum, param, sender) : 0; } diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h index 89a1a42eb4..fb8941ae43 100644 --- a/engines/neverhood/entity.h +++ b/engines/neverhood/entity.h @@ -61,12 +61,12 @@ protected: #define SetUpdateHandler(handler) \ _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler); \ - debug(2, "SetUpdateHandler(" #handler ")"); \ + debug(5, "SetUpdateHandler(" #handler ")"); \ _updateHandlerCbName = #handler #define SetMessageHandler(handler) \ _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam ¶m, Entity *sender)> (handler); \ - debug(2, "SetMessageHandler(" #handler ")"); \ + debug(5, "SetMessageHandler(" #handler ")"); \ _messageHandlerCbName = #handler const uint kMaxSoundResources = 16; diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index e6f38f020c..5cb9198898 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -358,6 +358,8 @@ void GameModule::startup() { setSubVar(VA_CURR_WATER_PIPES_LEVEL, 2, 2); setSubVar(VA_CURR_WATER_PIPES_LEVEL, 3, 0); setSubVar(VA_CURR_WATER_PIPES_LEVEL, 4, 4); + setGlobalVar(V_KLAYMAN_SMALL, 1); + setGlobalVar(V_SHRINK_LIGHTS_ON, 0); // <<<DEBUG #if 0 @@ -369,13 +371,13 @@ void GameModule::startup() { */ _vm->gameState().which = 0; - _vm->gameState().sceneNum = 28; - createModule(2700, -1); + _vm->gameState().sceneNum = 2; + createModule(2800, -1); #endif #if 1 - _vm->gameState().sceneNum = 4; - _vm->gameState().which = 1; - createModule(1000, -1); + _vm->gameState().sceneNum = 5; + _vm->gameState().which = 0; + createModule(2800, -1); #endif #if 0 _vm->gameState().sceneNum = 0; @@ -416,7 +418,6 @@ void GameModule::startup() { createModule(2700, -1); #endif #if 0 - setGlobalVar(V_KLAYMAN_SMALL, 1); // DEBUG Make Klayman small _vm->gameState().sceneNum = 2; createModule(2800, -1); #endif diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index 9673adc6f8..39d38c322a 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -2212,16 +2212,16 @@ uint32 Klayman::hmJumpToGrab(int messageNum, const MessageParam ¶m, Entity * return messageResult; } -void Klayman::sub421230() {//stGrow +void Klayman::stFinishGrow() { _status2 = 2; _acceptInput = false; - startAnimationByHash(0x38445000, 0, -1); + startAnimation(0x38445000, 0, -1); SetUpdateHandler(&Klayman::update); SetSpriteUpdate(NULL); - SetMessageHandler(&Klayman::handleMessage41F1D0); + SetMessageHandler(&Klayman::hmFinishGrow); } -uint32 Klayman::handleMessage41F1D0(int messageNum, const MessageParam ¶m, Entity *sender) { +uint32 Klayman::hmFinishGrow(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { case 0x100D: @@ -5728,7 +5728,7 @@ uint32 KmScene2803::xHandleMessage(int messageNum, const MessageParam ¶m) { break; case 0x4804: if (param.asInteger() == 3) - GotoState(&Klayman::sub421230); + GotoState(&Klayman::stFinishGrow); break; case 0x480D: GotoState(&Klayman::stPullCord); @@ -5882,11 +5882,11 @@ uint32 KmScene2805::xHandleMessage(int messageNum, const MessageParam ¶m) { KmScene2806::KmScene2806(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, bool flag, NRect *clipRects, uint clipRectsCount) : Klayman(vm, parentScene, x, y, 1000, 1000) { - // Empty - - _surface->setClipRects(clipRects, clipRectsCount); if (flag) { + NDimensions dimensions = _animResource.loadSpriteDimensions(0x2838C010); + delete _surface; + createSurface(1000, dimensions.width, dimensions.height); loadSound(3, 0x58E0C341); loadSound(4, 0x40A00342); loadSound(5, 0xD0A1C348); @@ -5895,6 +5895,7 @@ KmScene2806::KmScene2806(NeverhoodEngine *vm, Entity *parentScene, int16 x, int1 } _dataResource.load(0x98182003); + _surface->setClipRects(clipRects, clipRectsCount); } @@ -5943,9 +5944,10 @@ KmScene2809::KmScene2809(NeverhoodEngine *vm, Entity *parentScene, int16 x, int1 bool flag, NRect *clipRects, uint clipRectsCount) : Klayman(vm, parentScene, x, y, 1000, 1000) { - _surface->setClipRects(clipRects, clipRectsCount); - if (flag) { + NDimensions dimensions = _animResource.loadSpriteDimensions(0x2838C010); + delete _surface; + createSurface(1000, dimensions.width, dimensions.height); loadSound(3, 0x58E0C341); loadSound(4, 0x40A00342); loadSound(5, 0xD0A1C348); @@ -5954,6 +5956,7 @@ KmScene2809::KmScene2809(NeverhoodEngine *vm, Entity *parentScene, int16 x, int1 } _dataResource.load(0x1830009A); + _surface->setClipRects(clipRects, clipRectsCount); } @@ -6070,7 +6073,7 @@ uint32 KmScene2810::xHandleMessage(int messageNum, const MessageParam ¶m) { break; case 0x4804: if (param.asInteger() == 3) - GotoState(&Klayman::sub421230); + GotoState(&Klayman::stFinishGrow); break; case NM_KLAYMAN_PICKUP: GotoState(&Klayman::stPickUpGeneric); diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h index 443bb97b2b..3b08108e3a 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -319,8 +319,8 @@ public: void stTurnToBackSmall(); uint32 hmWalkFrontBackSmall(int messageNum, const MessageParam ¶m, Entity *sender); - void sub421230();//stGrow?? - uint32 handleMessage41F1D0(int messageNum, const MessageParam ¶m, Entity *sender); + void stFinishGrow(); + uint32 hmFinishGrow(int messageNum, const MessageParam ¶m, Entity *sender); void stJumpToRingVenusFlyTrap(); uint32 hmJumpToRingVenusFlyTrap(int messageNum, const MessageParam ¶m, Entity *sender); diff --git a/engines/neverhood/module2800.cpp b/engines/neverhood/module2800.cpp index 6500ae0955..fb437fd86f 100644 --- a/engines/neverhood/module2800.cpp +++ b/engines/neverhood/module2800.cpp @@ -661,9 +661,6 @@ uint32 Scene2802::handleMessage(int messageNum, const MessageParam ¶m, Entit if (prevTuneStatus != _currTuneStatus) changeTuneStatus(prevTuneStatus, _currTuneStatus); break; - case 0x000D: - // DEBUG message - break; } return 0; } @@ -1035,7 +1032,6 @@ void Scene2803::toggleBackground() { } void Scene2803::changeBackground() { - // TODO? g_screen->resetDirtyRects(); if (getGlobalVar(V_SHRINK_LIGHTS_ON)) { _asLightCord->setFileHashes(0x8FAD5932, 0x276E1A3D); _background->load(0x412A423E); @@ -1050,16 +1046,14 @@ void Scene2803::changeBackground() { _mouseCursor->updateCursor(); _sprite8->loadSprite(0x3C42022F); _sprite9->loadSprite(0x341A0237); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) == 0) { + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) == 0) _asTestTubeOne->loadSprite(0x66121222); - } else + else sendMessage(_asTestTubeOne, 0x2000, 0); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1) == 3) { + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1) == 3) _asTestTubeTwo->loadSprite(0x64330236); - } - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2) == 3) { + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2) == 3) _asTestTubeThree->loadSprite(0x2E4A22A2); - } _sprite10->setVisible(true); } else { _asLightCord->setFileHashes(0xAFAD591A, 0x276E321D); @@ -1075,16 +1069,12 @@ void Scene2803::changeBackground() { _mouseCursor->updateCursor(); _sprite8->loadSprite(0x108012C1); _sprite9->loadSprite(0x708072E0); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) == 0) { - _asTestTubeOne->loadSprite(0x50C027A8); - } else + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) != 0) sendMessage(_asTestTubeOne, 0x2000, 1); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1) == 3) { + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1) == 3) _asTestTubeTwo->loadSprite(0xD48077A0); - } - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2) == 3) { + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2) == 3) _asTestTubeThree->loadSprite(0x30022689); - } _sprite10->setVisible(false); } updatePaletteArea(); @@ -1144,18 +1134,14 @@ Scene2803Small::Scene2803Small(NeverhoodEngine *vm, Module *parentModule, int wh _sprite5 = insertStaticSprite(0x34422912, 1100); _sprite6 = insertStaticSprite(0x3C42022F, 1100); _sprite7 = insertStaticSprite(0x341A0237, 1100); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) == 0) insertStaticSprite(0x66121222, 100); else insertSprite<AnimatedSprite>(kScene2803SmallFileHashes1[getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0)], 100, 529, 326); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1) == 3) insertStaticSprite(0x64330236, 100); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2) == 3) insertStaticSprite(0x2E4A22A2, 100); - } else { setBackground(0x29800A01); setPalette(0x29800A01); @@ -1169,19 +1155,12 @@ Scene2803Small::Scene2803Small(NeverhoodEngine *vm, Module *parentModule, int wh _sprite6 = insertStaticSprite(0x108012C1, 1100); _sprite7 = insertStaticSprite(0x708072E0, 1100); insertStaticSprite(0x90582EA4, 100); - - setSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0, 1);//DEBUG, FIXME crashes when not done?! - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) == 0) - insertStaticSprite(0x50C027A8, 100); - else + if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0) != 0) insertSprite<AnimatedSprite>(kScene2803SmallFileHashes2[getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0)], 100, 529, 326); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1) == 3) insertStaticSprite(0xD48077A0, 100); - if (getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2) == 3) insertStaticSprite(0x30022689, 100); - } _sprite6->setVisible(false); @@ -1992,6 +1971,8 @@ Scene2806::Scene2806(NeverhoodEngine *vm, Module *parentModule, int which) Sprite *tempSprite; + which = 3; + SetMessageHandler(&Scene2806::handleMessage); SetUpdateHandler(&Scene2806::update); @@ -2023,7 +2004,7 @@ Scene2806::Scene2806(NeverhoodEngine *vm, Module *parentModule, int which) _clipRects[2].x1 = tempSprite->getDrawRect().x; _clipRects[2].y2 = tempSprite->getDrawRect().y2(); _clipRects[3].y1 = tempSprite->getDrawRect().y2(); - _clipRects[1].x2 = tempSprite->getDrawRect().x2(); + _clipRects[1].x2 = tempSprite->getDrawRect().x; tempSprite = insertStaticSprite(0x72875F42, 1100); _clipRects[3].x1 = tempSprite->getDrawRect().x; @@ -2038,6 +2019,9 @@ Scene2806::Scene2806(NeverhoodEngine *vm, Module *parentModule, int which) _clipRects[2].x2 = 640; _clipRects[3].x2 = 640; + for (uint i = 0; i < 4; i++) + debug("clipRect[%d] (%d, %d, %d, %d)", i, _clipRects[i].x1, _clipRects[i].y1, _clipRects[i].x2, _clipRects[i].y2); + if (which < 0) { insertKlayman<KmScene2806>(441, 423, false, _clipRects, 4); setMessageList(0x004AF098); @@ -2288,25 +2272,21 @@ uint32 AsScene2808TestTube::handleMessage(int messageNum, const MessageParam &pa } void AsScene2808TestTube::fill() { - - - if ((int)_fillLevel < _testTubeSetNum * 3 + 3) - return; - - if (_testTubeSetNum == 0) { - playSound(_fillLevel); - setVisible(true); - startAnimation(kClass490FileHashes[_testTubeIndex], kClass490FrameIndices1[_fillLevel], kClass490FrameIndices1[_fillLevel + 1]); - _newStickFrameIndex = kClass490FrameIndices1[_fillLevel + 1]; - } else { - playSound(3 + _fillLevel); - setVisible(true); - startAnimation(kClass490FileHashes[_testTubeIndex], kClass490FrameIndices2[_fillLevel], kClass490FrameIndices2[_fillLevel + 1]); - _newStickFrameIndex = kClass490FrameIndices2[_fillLevel + 1]; + if ((int)_fillLevel < _testTubeSetNum * 3 + 3) { + if (_testTubeSetNum == 0) { + playSound(_fillLevel); + setVisible(true); + startAnimation(kClass490FileHashes[_testTubeIndex], kClass490FrameIndices1[_fillLevel], kClass490FrameIndices1[_fillLevel + 1]); + _newStickFrameIndex = kClass490FrameIndices1[_fillLevel + 1]; + } else { + playSound(3 + _fillLevel); + setVisible(true); + startAnimation(kClass490FileHashes[_testTubeIndex], kClass490FrameIndices2[_fillLevel], kClass490FrameIndices2[_fillLevel + 1]); + _newStickFrameIndex = kClass490FrameIndices2[_fillLevel + 1]; + } + _ssDispenser->startCountdown(_fillLevel); + _fillLevel++; } - _ssDispenser->startCountdown(_fillLevel); - _fillLevel++; - } void AsScene2808TestTube::flush() { @@ -2446,13 +2426,12 @@ void AsScene2808LightEffect::update() { Scene2808::Scene2808(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule, true), _countdown(0), _testTubeSetNum(which), _leaveResult(0), _isFlowing(false) { - Sprite *tempSprite; + Sprite *asHandle; - if (which == 0) { + if (which == 0) _vm->gameModule()->initTestTubes1Puzzle(); - } else { + else _vm->gameModule()->initTestTubes2Puzzle(); - } SetMessageHandler(&Scene2808::handleMessage); SetUpdateHandler(&Scene2808::update); @@ -2460,8 +2439,8 @@ Scene2808::Scene2808(NeverhoodEngine *vm, Module *parentModule, int which) setBackground(kScene2808FileHashes1[which]); setPalette(kScene2808FileHashes1[which]); - tempSprite = insertSprite<AsScene2808Handle>(this, which); - _vm->_collisionMan->addSprite(tempSprite); + asHandle = insertSprite<AsScene2808Handle>(this, which); + _vm->_collisionMan->addSprite(asHandle); _asFlow = insertSprite<AsScene2808Flow>(this, which); insertSprite<AsScene2808LightEffect>(which); @@ -2513,9 +2492,14 @@ uint32 Scene2808::handleMessage(int messageNum, const MessageParam ¶m, Entit void Scene2808::update() { // DEBUG>>> Show correct values + #if 1 debug("---------------"); - debug("%03d %03d %03d", getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0), getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1), getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2)); + if (_testTubeSetNum == 0) + debug("%03d %03d %03d", getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 0), getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 1), getSubVar(VA_GOOD_TEST_TUBES_LEVEL_1, 2)); + else + debug("%03d %03d %03d", getSubVar(VA_GOOD_TEST_TUBES_LEVEL_2, 0), getSubVar(VA_GOOD_TEST_TUBES_LEVEL_2, 1), getSubVar(VA_GOOD_TEST_TUBES_LEVEL_2, 2)); debug("%03d %03d %03d", _asTestTubes[0]->getFillLevel(), _asTestTubes[1]->getFillLevel(), _asTestTubes[2]->getFillLevel()); + #endif // DEBUG<<< Scene::update(); diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp index 64f106128b..7f897a415f 100644 --- a/engines/neverhood/resource.cpp +++ b/engines/neverhood/resource.cpp @@ -162,7 +162,7 @@ bool AnimResource::load(uint32 fileHash) { _vm->_res->loadResource(_resourceHandle); resourceData = _resourceHandle.data(); - + animListCount = READ_LE_UINT16(resourceData); animInfoStartOfs = READ_LE_UINT16(resourceData + 2); spriteDataOfs = READ_LE_UINT32(resourceData + 4); diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp index 3b67b26a06..c30e272eab 100644 --- a/engines/neverhood/resourceman.cpp +++ b/engines/neverhood/resourceman.cpp @@ -66,8 +66,10 @@ ResourceFileEntry *ResourceMan::findEntrySimple(uint32 fileHash) { return p != _entries.end() ? &(*p)._value : NULL; } -ResourceFileEntry *ResourceMan::findEntry(uint32 fileHash) { +ResourceFileEntry *ResourceMan::findEntry(uint32 fileHash, ResourceFileEntry **firstEntry) { ResourceFileEntry *entry = findEntrySimple(fileHash); + if (firstEntry) + *firstEntry = entry; for (; entry && entry->archiveEntry->comprType == 0x65; fileHash = entry->archiveEntry->diskSize) entry = findEntrySimple(fileHash); return entry; @@ -79,7 +81,9 @@ Common::SeekableReadStream *ResourceMan::createStream(uint32 fileHash) { } void ResourceMan::queryResource(uint32 fileHash, ResourceHandle &resourceHandle) { - resourceHandle._resourceFileEntry = findEntry(fileHash); + ResourceFileEntry *firstEntry; + resourceHandle._resourceFileEntry = findEntry(fileHash, &firstEntry); + resourceHandle._extData = firstEntry ? firstEntry->archiveEntry->extData : NULL; } void ResourceMan::loadResource(ResourceHandle &resourceHandle) { diff --git a/engines/neverhood/resourceman.h b/engines/neverhood/resourceman.h index 515849efbf..e83de240ed 100644 --- a/engines/neverhood/resourceman.h +++ b/engines/neverhood/resourceman.h @@ -59,10 +59,11 @@ public: byte type() const { return isValid() ? _resourceFileEntry->archiveEntry->type : 0; }; const byte *data() const { return _data; } uint32 size() const { return isValid() ? _resourceFileEntry->archiveEntry->size : 0; }; - const byte *extData() const { return isValid() ? _resourceFileEntry->archiveEntry->extData : NULL; }; + const byte *extData() const { return _extData; }; uint32 fileHash() const { return isValid() ? _resourceFileEntry->archiveEntry->fileHash : 0; }; protected: ResourceFileEntry *_resourceFileEntry; + const byte *_extData; const byte *_data; }; @@ -72,7 +73,7 @@ public: ~ResourceMan(); void addArchive(const Common::String &filename); ResourceFileEntry *findEntrySimple(uint32 fileHash); - ResourceFileEntry *findEntry(uint32 fileHash); + ResourceFileEntry *findEntry(uint32 fileHash, ResourceFileEntry **firstEntry = NULL); Common::SeekableReadStream *createStream(uint32 fileHash); const ResourceFileEntry& getEntry(uint index) { return _entries[index]; } uint getEntryCount() { return _entries.size(); } diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp index f0961f42e9..3cbcf96354 100644 --- a/engines/neverhood/sound.cpp +++ b/engines/neverhood/sound.cpp @@ -436,26 +436,22 @@ SoundItem *SoundMan::getSoundItemByHash(uint32 soundFileHash) { } int16 SoundMan::addMusicItem(MusicItem *musicItem) { -#if 0 for (uint i = 0; i < _musicItems.size(); ++i) if (!_musicItems[i]) { _musicItems[i] = musicItem; return i; } -#endif int16 musicIndex = _musicItems.size(); _musicItems.push_back(musicItem); return musicIndex; } int16 SoundMan::addSoundItem(SoundItem *soundItem) { -#if 0 for (uint i = 0; i < _soundItems.size(); ++i) if (!_soundItems[i]) { _soundItems[i] = soundItem; return i; } -#endif int16 soundIndex = _soundItems.size(); _soundItems.push_back(soundItem); return soundIndex; @@ -550,7 +546,7 @@ void AudioResourceMan::removeSound(int16 soundIndex) { void AudioResourceMan::loadSound(int16 soundIndex) { AudioResourceManSoundItem *soundItem = _soundItems[soundIndex]; - if (!soundItem->_data) { + if (!soundItem->_data && soundItem->_resourceHandle.isValid()) { // TODO Check if it's a sound resource _vm->_res->loadResource(soundItem->_resourceHandle); soundItem->_data = soundItem->_resourceHandle.data(); @@ -580,6 +576,7 @@ void AudioResourceMan::setSoundPan(int16 soundIndex, int16 pan) { } void AudioResourceMan::playSound(int16 soundIndex, bool looping) { + AudioResourceManSoundItem *soundItem = _soundItems[soundIndex]; if (!soundItem->_data) loadSound(soundIndex); @@ -587,8 +584,9 @@ void AudioResourceMan::playSound(int16 soundIndex, bool looping) { if (!soundItem->_data) return; - Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundItem->_data, soundItem->_resourceHandle.size(), DisposeAfterUse::NO); const byte *shiftValue = soundItem->_resourceHandle.extData(); + + Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundItem->_data, soundItem->_resourceHandle.size(), DisposeAfterUse::NO); NeverhoodAudioStream *audioStream = new NeverhoodAudioStream(22050, *shiftValue, false, DisposeAfterUse::YES, stream); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &soundItem->_soundHandle, diff --git a/engines/neverhood/sprite.cpp b/engines/neverhood/sprite.cpp index c7676ce0b4..241912286c 100644 --- a/engines/neverhood/sprite.cpp +++ b/engines/neverhood/sprite.cpp @@ -477,7 +477,6 @@ void AnimatedSprite::gotoNextState() { if (_nextStateCb) { _currStateCb = _nextStateCb; _nextStateCb = NULL; - //debug("Fire _nextStateCb '%s'", _nextStateCbName.c_str()); (this->*_currStateCb)(); } else { _currStateCb = NULL; |