Opened 12 years ago

Closed 12 years ago

Last modified 11 months ago

#8717 closed patch

FW: Fixes for German Amiga Version

Reported by: SF/thorfdbg Owned by: sev-
Priority: normal Component: Engine: Cine
Keywords: Cc:
Game: Future Wars

Description

The following patches fix the crashes for the german Amiga version of FutureWars (SVN version used) for bugs
1763053
1758503
in the bug database (not so) recently reported by myself:

a) Replace in cine/script.cpp o1_freePartRange by:

void o1_freePartRange() {
byte startIdx = getNextByte();
byte numIdx = getNextByte();

assert(startIdx + numIdx <= NUM_MAX_ANIMDATA);
g_sound->stopMusic();
debugC(5, kCineDebugScript, "Line: %d: freePartRange(%d,%d)", _currentLine, startIdx, numIdx);
freeAnimDataRange(startIdx, numIdx);
}

This will stop the sound engine when unloading its resources, fixes the first bug reported in 1763053.

b) Replace in cine/unpack.cpp delphineUnpack(), the termination condition of the while loop with:

} while (uc.datasize > 0 && uc.src >= src - 4);

This will stop unpacking your sofa if something's wrong with the packed data. Aparently, this seems to be the case for one of the files near the end at least for my version (or my disks are getting weary, but never mind, this extra condition doesn't hurt).
This fixes the second bug reported in 1763053.

c) in cine/sound.cpp replace PaulaSound::playMusic by:

void PaulaSound::playMusic() {
_mixer->stopHandle(_moduleHandle);
if (_moduleStream) {
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_moduleHandle, _moduleStream,
-1,255,0,false);
}
}

This will avoid deleting the sound channels because they will be needed afterwards again. This is part of the fix for 1758503.

d) in cine/sound.cpp replace PaulaSound::stopMusic() by:

void PaulaSound::stopMusic() {
_mixer->stopHandle(_moduleHandle);
_mixer->pauseAll(true);
for(int i = 0;i < NUM_CHANNELS;i++)
_soundChannelsTable[i].data = 0;
}

This will *really* stop the music, not just pretend to, and is part of the fix for both reports.

For saved games, please check the two bug reports in the database.

Greetings,
Thomas

Ticket imported from: #1773489. Ticket imported from: patches/822.

Change History (8)

comment:1 by cyxx, 12 years ago

Regarding b)
- if you really want to add checks to prevent memory overwrite/read, several checks must also be added to the helper functions.
- if the original data doesn't unpack properly, then scummvm shouldn't even try to do so, I think ; or invalid opcodes, decoding bitmap errors etc. are likely to occur. Better would be to have list a "bad known files" and add specific workarounds.

comment:2 by SF/thorfdbg, 12 years ago

Interestingly, the modification b) seems to be enough to fix my version, i.e. the source is fully decompressed at the time
it reaches the next chunk. No negative side effects seem to happen, i.e. the game proceeds as it should. (No damaged graphics or
sound). Still, it is unclear whether my disks are broken or the specific file comes "pre-broken".

So long,
Thomas

comment:3 by sev-, 12 years ago

Owner: set to sev-

comment:4 by fingolfin, 12 years ago

What is the status of this item?

comment:5 by sev-, 12 years ago

I committed as is. As of fix b), we anyway need code review and refactoring.

comment:6 by sev-, 12 years ago

Status: newclosed

comment:7 by cyxx, 12 years ago

modification a) caused a regression : no more music in the introduction of PC versions of FW and OS.
modification d) and c) introduced memory leaks.

I committed "alternative" changes to fix the sound issues.

comment:8 by digitall, 11 months ago

Component: Engine: Cine
Game: Future Wars
Note: See TracTickets for help on using tickets.