diff options
Diffstat (limited to 'engines/bladerunner')
-rw-r--r-- | engines/bladerunner/actor_dialogue_queue.cpp | 4 | ||||
-rw-r--r-- | engines/bladerunner/actor_dialogue_queue.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/ambient_sounds.cpp | 114 | ||||
-rw-r--r-- | engines/bladerunner/savefile.cpp | 4 | ||||
-rw-r--r-- | engines/bladerunner/scene_objects.cpp | 1 | ||||
-rw-r--r-- | engines/bladerunner/ui/kia_shapes.h | 2 |
6 files changed, 72 insertions, 55 deletions
diff --git a/engines/bladerunner/actor_dialogue_queue.cpp b/engines/bladerunner/actor_dialogue_queue.cpp index 48fcf8a6ab..320dd53478 100644 --- a/engines/bladerunner/actor_dialogue_queue.cpp +++ b/engines/bladerunner/actor_dialogue_queue.cpp @@ -186,10 +186,10 @@ void ActorDialogueQueue::save(SaveFileWriteStream &f) { void ActorDialogueQueue::load(SaveFileReadStream &f) { _entries.clear(); - int count = f.readInt(); + uint count = f.readInt(); assert(count <= kMaxEntries); _entries.resize(count); - for (int i = 0; i < count; ++i) { + for (uint i = 0; i < count; ++i) { Entry &e = _entries[i]; e.isNotPause = f.readBool(); e.isPause = f.readBool(); diff --git a/engines/bladerunner/actor_dialogue_queue.h b/engines/bladerunner/actor_dialogue_queue.h index 832bcc9dab..e45663275a 100644 --- a/engines/bladerunner/actor_dialogue_queue.h +++ b/engines/bladerunner/actor_dialogue_queue.h @@ -32,7 +32,7 @@ class SaveFileReadStream; class SaveFileWriteStream; class ActorDialogueQueue { - static const int kMaxEntries = 25; + static const uint kMaxEntries = 25; struct Entry { bool isNotPause; diff --git a/engines/bladerunner/ambient_sounds.cpp b/engines/bladerunner/ambient_sounds.cpp index 81b6174ab9..a9cd82fe2e 100644 --- a/engines/bladerunner/ambient_sounds.cpp +++ b/engines/bladerunner/ambient_sounds.cpp @@ -355,70 +355,88 @@ void AmbientSounds::save(SaveFileWriteStream &f) { for (int i = 0; i != kNonLoopingSounds; ++i) { // 73 bytes per non-looping sound - NonLoopingSound &s = _nonLoopingSounds[i]; - f.writeBool(s.isActive); - f.writeStringSz(s.name, 13); - f.writeSint32LE(s.hash); - f.writeInt(s.audioPlayerTrack); - f.writeInt(s.timeMin); - f.writeInt(s.timeMax); - f.writeUint32LE(s.nextPlayTime); - f.writeInt(s.volumeMin); - f.writeInt(s.volumeMax); - f.writeInt(s.volume); - f.writeInt(s.panStartMin); - f.writeInt(s.panStartMax); - f.writeInt(s.panEndMin); - f.writeInt(s.panEndMax); - f.writeInt(s.priority); + NonLoopingSound &track = _nonLoopingSounds[i]; + f.writeBool(track.isActive); + f.writeStringSz(track.name, 13); + f.writeSint32LE(track.hash); + f.writeInt(-1); // track.audioPlayerTrack is not used after load + f.writeInt(track.timeMin); + f.writeInt(track.timeMax); + f.writeInt(0); // track.nextPlayTime is not used after load + f.writeInt(track.volumeMin); + f.writeInt(track.volumeMax); + f.writeInt(track.volume); + f.writeInt(track.panStartMin); + f.writeInt(track.panStartMax); + f.writeInt(track.panEndMin); + f.writeInt(track.panEndMax); + f.writeInt(track.priority); f.padBytes(4); // field_45 } for (int i = 0; i != kLoopingSounds; ++i) { // 33 bytes per looping sound - LoopingSound &s = _loopingSounds[i]; - f.writeBool(s.isActive); - f.writeStringSz(s.name, 13); - f.writeSint32LE(s.hash); - f.writeInt(s.audioPlayerTrack); - f.writeInt(s.volume); - f.writeInt(s.pan); + LoopingSound &track = _loopingSounds[i]; + f.writeBool(track.isActive); + f.writeStringSz(track.name, 13); + f.writeSint32LE(track.hash); + f.writeInt(-1); // track.audioPlayerTrack is not used after load + f.writeInt(track.volume); + f.writeInt(track.pan); } } void AmbientSounds::load(SaveFileReadStream &f) { + removeAllLoopingSounds(0); + removeAllNonLoopingSounds(true); + f.skip(4); // TODO: _isDisabled + uint32 now = g_system->getMillis(); + for (int i = 0; i != kNonLoopingSounds; ++i) { - // 73 bytes per non-looping sound - NonLoopingSound &s = _nonLoopingSounds[i]; - s.isActive = f.readBool(); - s.name = f.readStringSz(13); - s.hash = f.readSint32LE(); - s.audioPlayerTrack = f.readInt(); - s.timeMin = f.readInt(); - s.timeMax = f.readInt(); - s.nextPlayTime = f.readUint32LE(); - s.volumeMin = f.readInt(); - s.volumeMax = f.readInt(); - s.volume = f.readInt(); - s.panStartMin = f.readInt(); - s.panStartMax = f.readInt(); - s.panEndMin = f.readInt(); - s.panEndMax = f.readInt(); - s.priority = f.readInt(); + NonLoopingSound &track = _nonLoopingSounds[i]; + track.isActive = f.readBool(); + track.name = f.readStringSz(13); + track.hash = f.readSint32LE(); + f.skip(4); // track.audioPlayerTrack is not used after load + track.audioPlayerTrack = -1; + track.timeMin = f.readInt(); + track.timeMax = f.readInt(); + f.skip(4); // track.nextPlayTime is not used after load + track.nextPlayTime = now + _vm->_rnd.getRandomNumberRng(track.timeMin, track.timeMax); + track.volumeMin = f.readInt(); + track.volumeMax = f.readInt(); + track.volume = f.readInt(); + track.panStartMin = f.readInt(); + track.panStartMax = f.readInt(); + track.panEndMin = f.readInt(); + track.panEndMax = f.readInt(); + track.priority = f.readInt(); f.skip(4); // field_45 } for (int i = 0; i != kLoopingSounds; ++i) { - // 33 bytes per looping sound - LoopingSound &s = _loopingSounds[i]; - s.isActive = f.readBool(); - s.name = f.readStringSz(13); - s.hash = f.readSint32LE(); - s.audioPlayerTrack = f.readInt(); - s.volume = f.readInt(); - s.pan = f.readInt(); + LoopingSound &track = _loopingSounds[i]; + track.isActive = f.readBool(); + track.name = f.readStringSz(13); + track.hash = f.readSint32LE(); + f.skip(4); // track.audioPlayerTrack is not used after load + track.audioPlayerTrack = -1; + track.volume = f.readInt(); + track.pan = f.readInt(); + } + + for (int i = 0; i != kLoopingSounds; ++i) { + LoopingSound &track = _loopingSounds[i]; + if (track.isActive) { + track.audioPlayerTrack = _vm->_audioPlayer->playAud(track.name, 1, track.pan, track.pan, 99, kAudioPlayerLoop | kAudioPlayerOverrideVolume); + if (track.audioPlayerTrack == -1) { + removeLoopingSoundByIndex(i, 0); + } else { + _vm->_audioPlayer->adjustVolume(track.audioPlayerTrack, _ambientVolume * track.volume / 100, 2, false); + } + } } } diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp index b0fb1e7fd6..143d947646 100644 --- a/engines/bladerunner/savefile.cpp +++ b/engines/bladerunner/savefile.cpp @@ -58,13 +58,13 @@ bool SaveFile::readHeader(Common::SeekableReadStream &in, SaveFileHeader &header header._thumbnail = nullptr; if (!skipThumbnail) { - header._thumbnail = new Graphics::Surface(); + header._thumbnail = new Graphics::Surface(); // freed by ScummVM's smartptr int32 pos = s.pos(); s.skip(4); //skip size; - void *thumbnailData = new byte[kThumbnailSize]; + void *thumbnailData = new byte[kThumbnailSize]; // freed by ScummVM's smartptr s.read(thumbnailData, kThumbnailSize); // TODO: cleanup - remove magic constants diff --git a/engines/bladerunner/scene_objects.cpp b/engines/bladerunner/scene_objects.cpp index 51538cd6fc..5eace21736 100644 --- a/engines/bladerunner/scene_objects.cpp +++ b/engines/bladerunner/scene_objects.cpp @@ -353,7 +353,6 @@ void SceneObjects::load(SaveFileReadStream &f) { _sceneObjects[i].id = f.readInt(); _sceneObjects[i].type = (SceneObjectType)f.readInt(); _sceneObjects[i].boundingBox = f.readBoundingBox(true); - debug("screenRectangle[%i]: %08x", i, f.pos()); _sceneObjects[i].screenRectangle = f.readRect(); _sceneObjects[i].distanceToCamera = f.readFloat(); _sceneObjects[i].isPresent = f.readBool(); diff --git a/engines/bladerunner/ui/kia_shapes.h b/engines/bladerunner/ui/kia_shapes.h index 0f36754626..af1898f408 100644 --- a/engines/bladerunner/ui/kia_shapes.h +++ b/engines/bladerunner/ui/kia_shapes.h @@ -32,7 +32,7 @@ namespace BladeRunner { class BladeRunnerEngine; class KIAShapes { - static const int kShapeCount = 132; + static const uint kShapeCount = 132; BladeRunnerEngine *_vm; const Shape *_shapes[kShapeCount]; |