Fix for Bug [788531] Indy3VGA - Access violation with PC Speaker "travel" music

Checked for OOB channel clear command. The "travel" music
in question seems to try to clear channel 4 when there are
only channels 0-3. Now we check and bail if OOB.

Perhaps this isn't quite the correct thing to do. Would
channel 4 be significant, as in perhaps "clear ALL channels"?
Hoenicke should answer this one.

svn-id: r9700
This commit is contained in:
Jamieson Christian 2003-08-15 07:10:30 +00:00
parent 3ddb50711e
commit c0730f6cb9

View File

@ -589,10 +589,15 @@ void Player_V2::execute_cmd(ChannelInfo *channel) {
break;
case 0xfd: // clear other channel
value = READ_LE_UINT16 (script_ptr);
debug(9, "clear channel %d", value/50);
value = READ_LE_UINT16 (script_ptr) / sizeof (ChannelInfo);
debug(9, "clear channel %d", value);
script_ptr += 2;
channel = &_channels[value / sizeof(ChannelInfo)];
// In Indy3, when traveling to Venice a command is
// issued to clear channel 4, which is OOB. So, we
// check first.
if (value >= ARRAYSIZE (_channels))
break;
channel = &_channels[value];
// fall through
case 0xfa: // clear current channel