From 006690789af69432fd9bec6cee8b76dbf62cb3f7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 24 May 2014 13:53:42 +0200 Subject: TUCKER: Add a check to error out when the index isn't found for a given location number --- engines/tucker/resource.cpp | 109 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 5f06334720..dd9d426cde 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -662,15 +662,13 @@ void TuckerEngine::loadData4() { t.findNextToken(kDataTokenDw); _gameDebug = t.getNextInteger() != 0; _displayGameHints = t.getNextInteger() != 0; - // forces game hints feature -// _displayGameHints = true; _locationObjectsCount = 0; if (t.findIndex(_locationNum)) { while (t.findNextToken(kDataTokenDw)) { int i = t.getNextInteger(); - if (i < 0) { + if (i < 0) break; - } + assert(_locationObjectsCount < kLocationObjectsTableSize); LocationObject *d = &_locationObjectsTable[_locationObjectsCount++]; d->_xPos = i; @@ -851,60 +849,63 @@ void TuckerEngine::unloadSprC02_01() { void TuckerEngine::loadFx() { loadFile("fx.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); - t.findIndex(_locationNum); - t.findNextToken(kDataTokenDw); - _locationSoundsCount = t.getNextInteger(); - _currentFxSet = 0; - for (int i = 0; i < _locationSoundsCount; ++i) { - LocationSound *s = &_locationSoundsTable[i]; - s->_offset = 0; - s->_num = t.getNextInteger(); - s->_volume = t.getNextInteger(); - s->_type = t.getNextInteger(); - switch (s->_type) { - case 5: - _currentFxSet = 1; - _currentFxIndex = i; - _currentFxVolume = s->_volume; - _currentFxDist = t.getNextInteger(); - _currentFxScale = t.getNextInteger(); - break; - case 6: - case 7: - case 8: - s->_startFxSpriteState = t.getNextInteger(); - s->_startFxSpriteNum = t.getNextInteger(); - s->_updateType = t.getNextInteger(); - if (s->_type == 7) { - s->_flagNum = t.getNextInteger(); - s->_flagValueStartFx = t.getNextInteger(); - s->_stopFxSpriteState = t.getNextInteger(); - s->_stopFxSpriteNum = t.getNextInteger(); - s->_flagValueStopFx = t.getNextInteger(); + if (t.findIndex(_locationNum)) { + t.findNextToken(kDataTokenDw); + _locationSoundsCount = t.getNextInteger(); + _currentFxSet = 0; + for (int i = 0; i < _locationSoundsCount; ++i) { + LocationSound *s = &_locationSoundsTable[i]; + s->_offset = 0; + s->_num = t.getNextInteger(); + s->_volume = t.getNextInteger(); + s->_type = t.getNextInteger(); + switch (s->_type) { + case 5: + _currentFxSet = 1; + _currentFxIndex = i; + _currentFxVolume = s->_volume; + _currentFxDist = t.getNextInteger(); + _currentFxScale = t.getNextInteger(); + break; + case 6: + case 7: + case 8: + s->_startFxSpriteState = t.getNextInteger(); + s->_startFxSpriteNum = t.getNextInteger(); + s->_updateType = t.getNextInteger(); + if (s->_type == 7) { + s->_flagNum = t.getNextInteger(); + s->_flagValueStartFx = t.getNextInteger(); + s->_stopFxSpriteState = t.getNextInteger(); + s->_stopFxSpriteNum = t.getNextInteger(); + s->_flagValueStopFx = t.getNextInteger(); + } + break; + } + if (s->_type == 8) { + s->_type = 6; } - break; - } - if (s->_type == 8) { - s->_type = 6; } - } - t.findNextToken(kDataTokenDw); - int count = t.getNextInteger(); - _locationMusicsCount = 0; - for (int i = 0; i < count; ++i) { - int flagNum = t.getNextInteger(); - int flagValue = t.getNextInteger(); - if (flagValue == _flagsTable[flagNum]) { - LocationMusic *m = &_locationMusicsTable[_locationMusicsCount++]; - m->_offset = 0; - m->_num = t.getNextInteger(); - m->_volume = t.getNextInteger(); - m->_flag = t.getNextInteger(); - } else { - for (int j = 0; j < 3; ++j) { - t.getNextInteger(); + t.findNextToken(kDataTokenDw); + int count = t.getNextInteger(); + _locationMusicsCount = 0; + for (int i = 0; i < count; ++i) { + int flagNum = t.getNextInteger(); + int flagValue = t.getNextInteger(); + if (flagValue == _flagsTable[flagNum]) { + LocationMusic *m = &_locationMusicsTable[_locationMusicsCount++]; + m->_offset = 0; + m->_num = t.getNextInteger(); + m->_volume = t.getNextInteger(); + m->_flag = t.getNextInteger(); + } else { + for (int j = 0; j < 3; ++j) { + t.getNextInteger(); + } } } + } else { + error("loadFx() - Index not found for location %d", _locationNum); } } -- cgit v1.2.3