diff options
-rw-r--r-- | engines/dm/dungeonman.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index da7d2dafa0..684e81d1f1 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -377,13 +377,13 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) { _g282_dungeonColumCount = 0; _g281_dungeonMapsFirstColumnIndex = nullptr; - _g282_dungeonColumCount = 0; _g280_dungeonColumnsCumulativeSquareThingCount = nullptr; _g283_squareFirstThings = nullptr; _g260_dungeonTextData = nullptr; for (uint16 i = 0; i < 16; ++i) _g284_thingData[i] = nullptr; + _g279_dungeonMapData = nullptr; _g308_partyDir = (Direction)0; _g306_partyMapX = 0; @@ -540,7 +540,6 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { if (_vm->_g298_newGame) f455_decompressDungeonFile(); - Common::ReadStream *dunDataStream = nullptr; if (file) { // if loading a save dunDataStream = file; @@ -627,37 +626,38 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { for (uint16 i = 0; i < columCount; ++i) _g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE(); - - // load sqaure first things + // load square first things if (!_vm->_g523_restartGameRequest) { delete[] _g283_squareFirstThings; _g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount]; } + for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) _g283_squareFirstThings[i].set(dunDataStream->readUint16BE()); - if (_vm->_g298_newGame) + + if (_vm->_g298_newGame) { for (uint16 i = 0; i < 300; ++i) _g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; - + } // load text data if (!_vm->_g523_restartGameRequest) { delete[] _g260_dungeonTextData; _g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount]; } + for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i) _g260_dungeonTextData[i] = dunDataStream->readUint16BE(); - if (_vm->_g298_newGame) _vm->_timeline->_g369_eventMaxCount = 100; // load things for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) { uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType]; - if (_vm->_g298_newGame) { + if (_vm->_g298_newGame) _g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]); - } + uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType]; if (thingStoreWordCount == 0) @@ -689,9 +689,9 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { if (_vm->_g298_newGame) { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; - for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { + + for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); - } } } @@ -704,7 +704,6 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i) _g276_dungeonRawMapData[i] = dunDataStream->readByte(); - if (!_vm->_g523_restartGameRequest) { uint8 mapCount = _g278_dungeonFileHeader._mapCount; delete[] _g279_dungeonMapData; @@ -727,7 +726,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { } void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { - static DoorInfo g254_doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo + static const DoorInfo doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo /* { Attributes, Defense } */ DoorInfo(3, 110), /* Door type 0 Portcullis */ DoorInfo(0, 42), /* Door type 1 Wooden door */ @@ -736,15 +735,15 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { if (_g272_currMapIndex == mapIndex) return; + _g272_currMapIndex = mapIndex; _g271_currMapData = _g279_dungeonMapData[mapIndex]; _g269_currMap = _g277_dungeonMaps + mapIndex; _g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1; _g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1; - _g275_currMapDoorInfo[0] = g254_doorInfo[_g269_currMap->_doorSet0]; - _g275_currMapDoorInfo[1] = g254_doorInfo[_g269_currMap->_doorSet1]; - _g270_currMapColCumulativeSquareFirstThingCount - = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; + _g275_currMapDoorInfo[0] = doorInfo[_g269_currMap->_doorSet0]; + _g275_currMapDoorInfo[1] = doorInfo[_g269_currMap->_doorSet1]; + _g270_currMapColCumulativeSquareFirstThingCount = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; } void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { |