diff options
Diffstat (limited to 'engines/gob/game_v2.cpp')
-rw-r--r-- | engines/gob/game_v2.cpp | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index e02ac9f7f5..025c86b73a 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -53,9 +53,6 @@ void Game_v2::playTot(int16 skipPlay) { int16 _captureCounter; int16 breakFrom; int16 nestLevel; - char needTextFree; - char needFreeResTable; - char *curPtr; int32 variablesCount; char *filePtr; char *savedIP; @@ -105,9 +102,6 @@ void Game_v2::playTot(int16 skipPlay) { _extTable = 0; _extHandle = -1; - needFreeResTable = 1; - needTextFree = 1; - _totToLoad[0] = 0; if (_curTotFile[0] == 0 && _totFileData == 0) @@ -133,45 +127,44 @@ void Game_v2::playTot(int16 skipPlay) { filePtr = (char *)_totFileData + 0x30; + _totTextData = 0; if (READ_LE_UINT32(filePtr) != (uint32)-1) { - curPtr = _totFileData; + _totTextData = new TotTextTable; if (READ_LE_UINT32(filePtr) == 0) - _totTextData = (TotTextTable *) loadLocTexts(); + _totTextData->dataPtr = loadLocTexts(); else - _totTextData = - (TotTextTable *) (curPtr + - READ_LE_UINT32((char *)_totFileData + 0x30)); + _totTextData->dataPtr = (_totFileData + READ_LE_UINT32((char *)_totFileData + 0x30)); - if (_totTextData != 0) { - _totTextData->itemsCount = (int16)READ_LE_UINT16(&_totTextData->itemsCount); + _totTextData->items = 0; + if (_totTextData->dataPtr != 0) { + Common::MemoryReadStream totTextData((byte *) _totTextData->dataPtr, 4294967295U); + _totTextData->itemsCount = totTextData.readSint16LE(); + _totTextData->items = new TotTextItem[_totTextData->itemsCount]; for (i = 0; i < _totTextData->itemsCount; ++i) { - _totTextData->items[i].offset = (int16)READ_LE_UINT16(&_totTextData->items[i].offset); - _totTextData->items[i].size = (int16)READ_LE_UINT16(&_totTextData->items[i].size); + _totTextData->items[i].offset = totTextData.readSint16LE(); + _totTextData->items[i].size = totTextData.readSint16LE(); } } - - needTextFree = 0; } filePtr = (char *)_totFileData + 0x34; + _totResourceTable = 0; if (READ_LE_UINT32(filePtr) != (uint32)-1) { - curPtr = _totFileData; + _totResourceTable = new TotResTable; + _totResourceTable->dataPtr = _totFileData + READ_LE_UINT32((char *)_totFileData + 0x34); + Common::MemoryReadStream totResTable((byte *) _totResourceTable->dataPtr, 4294967295U); - _totResourceTable = - (TotResTable *)(curPtr + - READ_LE_UINT32((char *)_totFileData + 0x34)); - - _totResourceTable->itemsCount = (int16)READ_LE_UINT16(&_totResourceTable->itemsCount); + _totResourceTable->itemsCount = totResTable.readSint16LE(); + _totResourceTable->unknown = totResTable.readByte(); + _totResourceTable->items = new TotResItem[_totResourceTable->itemsCount]; for (i = 0; i < _totResourceTable->itemsCount; ++i) { - _totResourceTable->items[i].offset = (int32)READ_LE_UINT32(&_totResourceTable->items[i].offset); - _totResourceTable->items[i].size = (int16)READ_LE_UINT16(&_totResourceTable->items[i].size); - _totResourceTable->items[i].width = (int16)READ_LE_UINT16(&_totResourceTable->items[i].width); - _totResourceTable->items[i].height = (int16)READ_LE_UINT16(&_totResourceTable->items[i].height); + _totResourceTable->items[i].offset = totResTable.readSint32LE(); + _totResourceTable->items[i].size = totResTable.readSint16LE(); + _totResourceTable->items[i].width = totResTable.readSint16LE(); + _totResourceTable->items[i].height = totResTable.readSint16LE(); } - - needFreeResTable = 0; } loadImFile(); @@ -204,12 +197,17 @@ void Game_v2::playTot(int16 skipPlay) { delete[] _totFileData; _totFileData = 0; - if (needTextFree) - delete[] _totTextData; + if (_totTextData) { + if (_totTextData->items) + delete[] _totTextData->items; + delete _totTextData; + } _totTextData = 0; - if (needFreeResTable) - delete[] _totResourceTable; + if (_totResourceTable) { + delete[] _totResourceTable->items; + delete _totResourceTable; + } _totResourceTable = 0; delete[] _imFileData; |