diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index c5569f6629f..65aae1debfa 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -1006,7 +1006,7 @@ void EventManager::commandMoveParty(CommandType cmdType) { } case kDMElementTypeDoor: { byte doorState = curSquare.getDoorState(); - isMovementBlocked = (doorState != k0_doorState_OPEN) && (doorState != k1_doorState_FOURTH) && (doorState != k5_doorState_DESTROYED); + isMovementBlocked = (doorState != kDMDoorStateOpen) && (doorState != kDMDoorStateOneFourth) && (doorState != kDMDoorStateDestroyed); } break; case kDMElementTypeFakeWall: { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 1cd00ea183c..f1d5fe22e49 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1076,8 +1076,8 @@ void DisplayMan::drawFloorOrnament(uint16 floorOrnOrdinal, ViewFloor viewFloorIn drawFloorOrnament(_vm->indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex); } -void DisplayMan::drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) { - if (doorState == k0_doorState_OPEN) +void DisplayMan::drawDoor(uint16 doorThingIndex, DoorState doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) { + if (doorState == kDMDoorStateOpen) return; DoorFrames *doorFramesTemp = doorFrames; @@ -1096,18 +1096,18 @@ void DisplayMan::drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNa if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_party._event73Count_ThievesEye) drawDoorOrnament(_vm->indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR); - if (doorState == k4_doorState_CLOSED) + if (doorState == kDMDoorStateClosed) drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed); - else if (doorState == k5_doorState_DESTROYED) { + else if (doorState == kDMDoorStateDestroyed) { drawDoorOrnament(_vm->indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex); drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed); } else { - doorState--; + int16 idx = doorState - 1; if (door->opensVertically()) - drawDoorBitmap(&doorFramesTemp->_vertical[doorState]); + drawDoorBitmap(&doorFramesTemp->_vertical[idx]); else { - drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]); - drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]); + drawDoorBitmap(&doorFramesTemp->_leftHorizontal[idx]); + drawDoorBitmap(&doorFramesTemp->_rightHorizontal[idx]); } } } @@ -1272,7 +1272,7 @@ void DisplayMan::drawSquareD3L(Direction dir, int16 posX, int16 posY) { drawFloorOrnament(squareAspect[kDMSquareAspectFloorOrn], kDMViewFloorD3L); drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[kDMSquareAspectFirstGroupOrObject]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); drawWallSetBitmap(_bitmapWallSetDoorFrameLeftD3L, doorFrameLeftD3L); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD3LCR, getBitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; @@ -1356,7 +1356,7 @@ void DisplayMan::drawSquareD3R(Direction dir, int16 posX, int16 posY) { drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R); drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], - squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD3LCR, + (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD3LCR, getBitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R); break;; case kDMElementTypePit: @@ -1433,7 +1433,7 @@ void DisplayMan::drawSquareD3C(Direction dir, int16 posX, int16 posY) { if (((Door *)_vm->_dungeonMan->_thingData[kDMThingTypeDoor])[squareAspect[kDMSquareAspectDoorThingIndex]].hasButton()) drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD3LCR, getBitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; @@ -1513,7 +1513,7 @@ void DisplayMan::drawSquareD2L(Direction dir, int16 posX, int16 posY) { drawFloorOrnament(squareAspect[kDMSquareAspectFloorOrn], kDMViewFloorD2L); drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[kDMSquareAspectFirstGroupOrObject]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2L); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD2LCR, + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD2LCR, getBitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; @@ -1600,7 +1600,7 @@ void DisplayMan::drawSquareD2R(Direction dir, int16 posX, int16 posY) { drawFloorOrnament(squareAspect[kDMSquareAspectFloorOrn], kDMViewFloorD2R); drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[kDMSquareAspectFirstGroupOrObject]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2R); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD2LCR, getBitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R); order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; break; @@ -1683,7 +1683,7 @@ void DisplayMan::drawSquareD2C(Direction dir, int16 posX, int16 posY) { if (((Door *)_vm->_dungeonMan->_thingData[kDMThingTypeDoor])[squareAspect[kDMSquareAspectDoorThingIndex]].hasButton()) drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD2LCR, getBitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; @@ -1768,7 +1768,7 @@ void DisplayMan::drawSquareD1L(Direction dir, int16 posX, int16 posY) { drawFloorOrnament(squareAspect[kDMSquareAspectFloorOrn], kDMViewFloorD1L); drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[kDMSquareAspectFirstGroupOrObject]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1L); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD1LCR, getBitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L); order = k0x0039_CellOrder_DoorPass2_FrontRight; break; @@ -1852,7 +1852,7 @@ void DisplayMan::drawSquareD1R(Direction dir, int16 posX, int16 posY) { drawFloorOrnament(squareAspect[kDMSquareAspectFloorOrn], kDMViewFloorD1R); drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[kDMSquareAspectFirstGroupOrObject]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1R); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD1LCR, getBitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R); order = k0x0049_CellOrder_DoorPass2_FrontLeft; break; @@ -1937,7 +1937,7 @@ void DisplayMan::drawSquareD1C(Direction dir, int16 posX, int16 posY) { if (((Door *)_vm->_dungeonMan->_thingData[kDMThingTypeDoor])[squareAspect[kDMSquareAspectDoorThingIndex]].hasButton()) drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C); - drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], squareAspect[kDMSquareAspectDoorState], + drawDoor(squareAspect[kDMSquareAspectDoorThingIndex], (DoorState)squareAspect[kDMSquareAspectDoorState], _doorNativeBitmapIndexFrontD1LCR, getBitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index effe91d1641..63dab05f1f4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -49,12 +49,14 @@ enum ViewFloor { kDMViewFloorD1R = 8 // @ C8_VIEW_FLOOR_D1R }; -#define k0_doorState_OPEN 0 // @ C0_DOOR_STATE_OPEN -#define k1_doorState_FOURTH 1 // @ C1_DOOR_STATE_CLOSED_ONE_FOURTH -#define k2_doorState_HALF 2 // @ k2_DoorStateAspect_CLOSED_HALF -#define k3_doorState_FOURTH 3 // @ C3_DOOR_STATE_CLOSED_THREE_FOURTH -#define k4_doorState_CLOSED 4 // @ C4_DOOR_STATE_CLOSED -#define k5_doorState_DESTROYED 5 // @ C5_DOOR_STATE_DESTROYED +enum DoorState { + kDMDoorStateOpen = 0, // @ C0_DOOR_STATE_OPEN + kDMDoorStateOneFourth = 1, // @ C1_DOOR_STATE_CLOSED_ONE_FOURTH + kDMDoorStateHalf = 2, // @ k2_DoorStateAspect_CLOSED_HALF + kDMDoorStateThreeFourth = 3, // @ C3_DOOR_STATE_CLOSED_THREE_FOURTH + kDMDoorStateClosed = 4, // @ C4_DOOR_STATE_CLOSED + kDMDoorStateDestroyed = 5 // @ C5_DOOR_STATE_DESTROYED +}; #define k0_ViewDoorOrnament_D3LCR 0 // @ C0_VIEW_DOOR_ORNAMENT_D3LCR #define k1_ViewDoorOrnament_D2LCR 1 // @ C1_VIEW_DOOR_ORNAMENT_D2LCR @@ -722,7 +724,7 @@ public: void copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal void drawFloorOrnament(uint16 floorOrnOrdinal, ViewFloor viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament - void drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount, + void drawDoor(uint16 doorThingIndex, DoorState doorState, int16 *doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor void drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament void drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 2bd3bc53517..0d61489ae79 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -357,7 +357,7 @@ bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 atta if (attack >= _vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._defense) { byte *curSquare = &_vm->_dungeonMan->_currMapData[mapX][mapY]; - if (Square(*curSquare).getDoorState() == k4_doorState_CLOSED) { + if (Square(*curSquare).getDoorState() == kDMDoorStateClosed) { if (ticks) { TimelineEvent newEvent; _vm->setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + ticks); @@ -367,7 +367,7 @@ bool GroupMan::groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 atta newEvent._Bu._location._mapY = mapY; _vm->_timeline->addEventGetEventIndex(&newEvent); } else { - ((Square *)curSquare)->setDoorState(k5_doorState_DESTROYED); + ((Square *)curSquare)->setDoorState(kDMDoorStateDestroyed); } return true; } @@ -1106,7 +1106,7 @@ bool GroupMan::isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 if (curSquareType == kDMElementTypeDoor) { Teleporter *curTeleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY); - if (((Square(curSquare).getDoorState()) > (((Door *)curTeleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(curSquare).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + if (((Square(curSquare).getDoorState()) > (((Door *)curTeleporter)->opensVertically() ? CreatureInfo::getHeight(creatureInfo->_attributes) : 1)) && ((Square(curSquare).getDoorState()) != kDMDoorStateDestroyed) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { _groupMovementBlockedByDoor = true; return false; } @@ -1237,7 +1237,7 @@ bool GroupMan::isViewPartyBlocked(uint16 mapX, uint16 mapY) { if (curSquareType == kDMElementTypeDoor) { Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY); int16 curDoorState = Square(curSquare).getDoorState(); - return ((curDoorState == k3_doorState_FOURTH) || (curDoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); + return ((curDoorState == kDMDoorStateThreeFourth) || (curDoorState == kDMDoorStateClosed)) && !getFlag(_vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); } return (curSquareType == kDMElementTypeWall) || ((curSquareType == kDMElementTypeFakeWall) && !getFlag(curSquare, kDMSquareMaskFakeWallOpen)); } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 7bc6d599508..faf61393cee 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1105,7 +1105,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) { case kDMActionKick: case kDMActionSwing: case kDMActionChop: - if ((Square(targetSquare).getType() == kDMElementTypeDoor) && (Square(targetSquare).getDoorState() == k4_doorState_CLOSED)) { + if ((Square(targetSquare).getType() == kDMElementTypeDoor) && (Square(targetSquare).getDoorState() == kDMDoorStateClosed)) { _vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMSoundModePlayIfPrioritized); actionDisabledTicks = 6; _vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, _vm->_championMan->getStrength(champIndex, kDMSlotActionHand), false, 2); diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index ab521446f88..bd4cd6c69bb 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -116,13 +116,13 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in byte curSquare = _vm->_dungeonMan->_currMapData[projectileTargetMapX][projectileTargetMapY]; int16 curDoorState = Square(curSquare).getDoorState(); Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(projectileTargetMapX, projectileTargetMapY); - if ((curDoorState != k5_doorState_DESTROYED) && (projectileAssociatedThing == Thing::_explOpenDoor)) { + if ((curDoorState != kDMDoorStateDestroyed) && (projectileAssociatedThing == Thing::_explOpenDoor)) { if (curDoor->hasButton()) _vm->_moveSens->addEvent(k10_TMEventTypeDoor, projectileTargetMapX, projectileTargetMapY, kDMCellNorthWest, kDMSensorEffectToggle, _vm->_gameTime + 1); break; } - if ((curDoorState == k5_doorState_DESTROYED) || (curDoorState <= k1_doorState_FOURTH)) + if ((curDoorState == kDMDoorStateDestroyed) || (curDoorState <= kDMDoorStateOneFourth)) return false; DoorInfo curDoorInfo = _vm->_dungeonMan->_currMapDoorInfo[curDoor->getType()]; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 7a032f12d73..e0b6484f27e 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -383,8 +383,8 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) { uint16 mapX = event->_Bu._location._mapX; uint16 mapY = event->_Bu._location._mapY; Square *curSquare = (Square *)&_vm->_dungeonMan->_currMapData[mapX][mapY]; - int16 doorState = Square(*curSquare).getDoorState(); - if (doorState == k5_doorState_DESTROYED) + DoorState doorState = (DoorState)(*curSquare).getDoorState(); + if (doorState == kDMDoorStateDestroyed) return; event->_mapTime++; @@ -393,9 +393,9 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) { Door *curDoor = (Door *)_vm->_dungeonMan->getSquareFirstThingData(mapX, mapY); bool verticalDoorFl = curDoor->opensVertically(); if ((_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) - && (mapY == _vm->_dungeonMan->_partyMapY) && (doorState != k0_doorState_OPEN)) { + && (mapY == _vm->_dungeonMan->_partyMapY) && (doorState != kDMDoorStateOpen)) { if (_vm->_championMan->_partyChampionCount > 0) { - curSquare->setDoorState(k0_doorState_OPEN); + curSquare->setDoorState(kDMDoorStateOpen); // Strangerke // Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso @@ -415,7 +415,8 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) { if (_vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(groupThing), mapX, mapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) _vm->_groupMan->processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0); - doorState = (doorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (doorState - 1); + int16 nextState = doorState - 1; + doorState = (doorState == kDMDoorStateOpen) ? kDMDoorStateOpen : (DoorState) nextState; curSquare->setDoorState(doorState); _vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, kDMSoundModePlayIfPrioritized); event->_mapTime++; @@ -424,20 +425,22 @@ void Timeline::processEventDoorAnimation(TimelineEvent *event) { } } } - if ((sensorEffect == kDMSensorEffectSet) && (doorState == k0_doorState_OPEN)) + if ((sensorEffect == kDMSensorEffectSet) && (doorState == kDMDoorStateOpen)) return; - if ((sensorEffect == kDMSensorEffectClear) && (doorState == k4_doorState_CLOSED)) + if ((sensorEffect == kDMSensorEffectClear) && (doorState == kDMDoorStateClosed)) return; - doorState += (sensorEffect == kDMSensorEffectSet) ? -1 : 1; + int16 nextDoorEffect = doorState + 1; + int16 prevDoorEffect = doorState - 1; + doorState = (DoorState) ((sensorEffect == kDMSensorEffectSet) ? prevDoorEffect : nextDoorEffect); curSquare->setDoorState(doorState); _vm->_sound->requestPlay(k02_soundDOOR_RATTLE, mapX, mapY, kDMSoundModePlayIfPrioritized); if (sensorEffect == kDMSensorEffectSet) { - if (doorState == k0_doorState_OPEN) + if (doorState == kDMDoorStateOpen) return; - } else if (doorState == k4_doorState_CLOSED) + } else if (doorState == kDMDoorStateClosed) return; addEventGetEventIndex(event); @@ -469,18 +472,18 @@ void Timeline::processEventSquareFakewall(TimelineEvent *event) { void Timeline::processEventDoorDestruction(TimelineEvent *event) { Square *square = (Square *)&_vm->_dungeonMan->_currMapData[event->_Bu._location._mapX][event->_Bu._location._mapY]; - square->setDoorState(k5_doorState_DESTROYED); + square->setDoorState(kDMDoorStateDestroyed); } void Timeline::processEventSquareDoor(TimelineEvent *event) { int16 doorState = Square(_vm->_dungeonMan->_currMapData[event->_Bu._location._mapX][event->_Bu._location._mapY]).getDoorState(); - if (doorState == k5_doorState_DESTROYED) + if (doorState == kDMDoorStateDestroyed) return; if (event->_Cu.A._effect == kDMSensorEffectToggle) - event->_Cu.A._effect = (doorState == k0_doorState_OPEN) ? kDMSensorEffectClear : kDMSensorEffectSet; + event->_Cu.A._effect = (doorState == kDMDoorStateOpen) ? kDMSensorEffectClear : kDMSensorEffectSet; else if (event->_Cu.A._effect == kDMSensorEffectSet) { - if ((doorState == k0_doorState_OPEN) || (doorState == k4_doorState_CLOSED)) + if ((doorState == kDMDoorStateOpen) || (doorState == kDMDoorStateClosed)) return; } event->_type = k1_TMEventTypeDoorAnimation;