Fix access to .he3/.he4 files

svn-id: r22118
This commit is contained in:
Max Horn 2006-04-23 21:56:09 +00:00
parent 1a7b4a7d7c
commit e0a5a2b89e
3 changed files with 11 additions and 7 deletions

View File

@ -159,7 +159,7 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
fi.file = new Common::File;
if (_fileName.empty()) { // We are running for the first time
_fileName = _vm->generateFilename(3);
_fileName = _vm->generateFilename(-3);
}
@ -1282,7 +1282,7 @@ int MacResExtractor::extractResource(int id, byte **buf) {
int size;
if (_fileName.empty()) { // We are running for the first time
_fileName = _vm->generateFilename(3);
_fileName = _vm->generateFilename(-3);
// Some programs write it as .bin. Try that too
if (!in.exists(_fileName)) {
@ -1637,6 +1637,8 @@ void ScummEngine_v70he::readRoomsOffsets() {
void ScummEngine_v70he::readGlobalObjects() {
int num = _fileHandle->readUint16LE();
assert(num == _numGlobalObjects);
assert(_objectStateTable);
assert(_objectOwnerTable);
_fileHandle->read(_objectStateTable, num);
_fileHandle->read(_objectOwnerTable, num);

View File

@ -282,7 +282,7 @@ void SoundHE::setOverrideFreq(int freq) {
void SoundHE::setupHEMusicFile() {
int i, total_size;
Common::File musicFile;
Common::String buf(_vm->generateFilename(4));
Common::String buf(_vm->generateFilename(-4));
if (musicFile.open(buf) == true) {
musicFile.seek(4, SEEK_SET);
@ -475,7 +475,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
if (soundID > _vm->_numSounds) {
int music_offs;
Common::File musicFile;
Common::String buf(_vm->generateFilename(4));
Common::String buf(_vm->generateFilename(-4));
if (musicFile.open(buf) == false) {
warning("playHESound: Can't open music file %s", buf.c_str());
@ -634,6 +634,7 @@ void SoundHE::startHETalkSound(uint32 offset) {
if (ConfMan.getBool("speech_mute"))
return;
assert(_sfxFile);
if (!_sfxFile->isOpen()) {
error("startHETalkSound: Speech file is not open");
return;

View File

@ -760,7 +760,7 @@ const MD5Table *findInMD5Table(const char *md5) {
}
Common::String ScummEngine::generateFilename(const int room) const {
const int diskNumber = room ? res.roomno[rtRoom][room] : 0;
const int diskNumber = (room > 0) ? res.roomno[rtRoom][room] : 0;
char buf[128];
if (_game.version == 4) {
@ -784,8 +784,9 @@ Common::String ScummEngine::generateFilename(const int room) const {
case kGenHEMac:
case kGenHEMacNoParens:
case kGenHEPC:
// FIXME: Not sure if the following HE section is quite correct...
if (_game.heversion >= 98) {
if (room < 0) {
id = '0' - room;
} else if (_game.heversion >= 98) {
int disk = 0;
if (_heV7DiskOffsets)
disk = _heV7DiskOffsets[room];