svn-id: r24963
This commit is contained in:
Travis Howell 2007-01-01 05:44:34 +00:00
parent afcfc95e8a
commit cbe3cb850c
3 changed files with 28 additions and 34 deletions

View File

@ -836,7 +836,10 @@ int AGOSEngine::go() {
loadGamePcFile();
addTimeEvent(0, 1);
openGameFile();
if (getFileName(GAME_GMEFILE) != NULL) {
openGameFile();
}
if (getGameType() == GType_FF) {
loadIconData();

View File

@ -466,25 +466,22 @@ uint fileReadItemID(Common::SeekableReadStream *in) {
}
void AGOSEngine::openGameFile() {
if (getFileName(GAME_GMEFILE) != NULL) {
_gameFile = new File();
_gameFile->open(getFileName(GAME_GMEFILE));
_gameFile = new File();
_gameFile->open(getFileName(GAME_GMEFILE));
if (_gameFile->isOpen() == false)
error("openGameFile: Can't load game file '%s'", getFileName(GAME_GMEFILE));
if (!_gameFile->isOpen())
error("openGameFile: Can't load game file '%s'", getFileName(GAME_GMEFILE));
uint32 size = _gameFile->readUint32LE();
uint32 size = _gameFile->readUint32LE();
_gameOffsetsPtr = (uint32 *)malloc(size);
if (_gameOffsetsPtr == NULL)
error("openGameFile: Out of memory, game offsets");
_gameOffsetsPtr = (uint32 *)malloc(size);
if (_gameOffsetsPtr == NULL)
error("openGameFile: Out of memory, game offsets");
readGameFile(_gameOffsetsPtr, 0, size);
#if defined(SCUMM_BIG_ENDIAN)
for (uint r = 0; r < size / 4; r++)
_gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]);
#endif
}
_gameFile->seek(0, SEEK_SET);
for (uint r = 0; r < size / 4; r++)
_gameOffsetsPtr[r] = _gameFile->readUint32LE();
}
void AGOSEngine::readGameFile(void *dst, uint32 offs, uint32 size) {

View File

@ -51,8 +51,8 @@ protected:
bool _freeOffsets;
public:
BaseSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigendian = false);
BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigendian = false);
BaseSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigEndian = false);
BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigEndian = false);
virtual ~BaseSound();
virtual void playSound(uint sound, Audio::SoundHandle *handle, byte flags) = 0;
#if defined(USE_MAD) || defined(USE_VORBIS) || defined(USE_FLAC)
@ -62,23 +62,23 @@ public:
class WavSound : public BaseSound {
public:
WavSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
WavSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigEndian = false) : BaseSound(mixer, file, base, bigEndian) {};
WavSound(Audio::Mixer *mixer, File *file, uint32 *offsets) : BaseSound(mixer, file, offsets) {};
void playSound(uint sound, Audio::SoundHandle *handle, byte flags);
};
class VocSound : public BaseSound {
public:
VocSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
VocSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigEndian = false) : BaseSound(mixer, file, base, bigEndian) {};
void playSound(uint sound, Audio::SoundHandle *handle, byte flags);
};
class RawSound : public BaseSound {
public:
RawSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
RawSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigEndian = false) : BaseSound(mixer, file, base, bigEndian) {};
void playSound(uint sound, Audio::SoundHandle *handle, byte flags);
};
BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 base, bool bigendian) {
BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 base, bool bigEndian) {
_mixer = mixer;
_file = file;
@ -86,7 +86,7 @@ BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 base, bool bigendia
uint32 size;
_file->seek(base + sizeof(uint32), SEEK_SET);
if (bigendian)
if (bigEndian)
size = _file->readUint32BE();
else
size = _file->readUint32LE();
@ -102,24 +102,18 @@ BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 base, bool bigendia
_file->seek(base, SEEK_SET);
if (_file->read(_offsets, size) != size)
error("BaseSound: Can't read offsets");
for (uint i = 0; i < res; i++) {
#if defined(SCUMM_BIG_ENDIAN)
if (!(bigendian))
_offsets[i] = FROM_LE_32(_offsets[i]);
#endif
if (bigendian)
_offsets[i] = TO_BE_32(_offsets[i]);
_offsets[i] += base;
if (bigEndian)
_offsets[i] = base + _file->readUint32BE();
else
_offsets[i] = base + _file->readUint32LE();
}
// only needed for mp3
_offsets[res] = _file->size();
}
BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigendian) {
BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigEndian) {
_mixer = mixer;
_file = file;
_offsets = offsets;