diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 4be51e157..6077c0c08 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -290,7 +290,7 @@ void CheckCursMove() int fy = myPlayer.position.offset2.deltaY / 256; fx -= (myPlayer.position.offset2.deltaX + myPlayer.position.velocity.deltaX) / 256; fy -= (myPlayer.position.offset2.deltaY + myPlayer.position.velocity.deltaY) / 256; - if (ScrollInfo._sdir != SDIR_NONE) { + if (ScrollInfo._sdir != ScrollDirection::None) { sx -= fx; sy -= fy; } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 87164b478..98feb56e0 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -912,7 +912,7 @@ void DiabloInitScreen() SetCursorPos(MousePosition); ScrollInfo.tile = { 0, 0 }; ScrollInfo.offset = { 0, 0 }; - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; ClrDiabloMsg(); } diff --git a/Source/gendung.h b/Source/gendung.h index 7f0b5dec4..a81352196 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -90,7 +90,7 @@ struct ScrollStruct { /** @brief Pixel offset of camera. */ Displacement offset; /** @brief Move direction of camera. */ - _scroll_direction _sdir; + ScrollDirection _sdir; }; struct THEME_LOC { diff --git a/Source/player.cpp b/Source/player.cpp index acb50df8e..a835f647d 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -158,7 +158,7 @@ struct DirectionSettings { Displacement tileAdd; Displacement offset; Displacement map; - _scroll_direction scrollDir; + ScrollDirection scrollDir; PLR_MODE walkMode; void (*walkModeHandler)(int, const DirectionSettings &); }; @@ -295,29 +295,29 @@ _sfx_id herosounds[enum_size::value][enum_size::value] = constexpr std::array WalkSettings { { // clang-format off - { Direction::South, { 1, 1 }, { 0, -32 }, { 0, 0 }, SDIR_S, PM_WALK2, WalkDownwards }, - { Direction::SouthWest, { 0, 1 }, { 32, -16 }, { 0, 0 }, SDIR_SW, PM_WALK2, WalkDownwards }, - { Direction::West, { -1, 1 }, { 32, -16 }, { 0, 1 }, SDIR_W, PM_WALK3, WalkSides }, - { Direction::NorthWest, { -1, 0 }, { 0, 0 }, { 0, 0 }, SDIR_NW, PM_WALK, WalkUpwards }, - { Direction::North, { -1, -1 }, { 0, 0 }, { 0, 0 }, SDIR_N, PM_WALK, WalkUpwards }, - { Direction::NorthEast, { 0, -1 }, { 0, 0 }, { 0, 0 }, SDIR_NE, PM_WALK, WalkUpwards }, - { Direction::East, { 1, -1 }, { -32, -16 }, { 1, 0 }, SDIR_E, PM_WALK3, WalkSides }, - { Direction::SouthEast, { 1, 0 }, { -32, -16 }, { 0, 0 }, SDIR_SE, PM_WALK2, WalkDownwards } + { Direction::South, { 1, 1 }, { 0, -32 }, { 0, 0 }, ScrollDirection::South, PM_WALK2, WalkDownwards }, + { Direction::SouthWest, { 0, 1 }, { 32, -16 }, { 0, 0 }, ScrollDirection::SouthWest, PM_WALK2, WalkDownwards }, + { Direction::West, { -1, 1 }, { 32, -16 }, { 0, 1 }, ScrollDirection::West, PM_WALK3, WalkSides }, + { Direction::NorthWest, { -1, 0 }, { 0, 0 }, { 0, 0 }, ScrollDirection::NorthWest, PM_WALK, WalkUpwards }, + { Direction::North, { -1, -1 }, { 0, 0 }, { 0, 0 }, ScrollDirection::North, PM_WALK, WalkUpwards }, + { Direction::NorthEast, { 0, -1 }, { 0, 0 }, { 0, 0 }, ScrollDirection::NorthEast, PM_WALK, WalkUpwards }, + { Direction::East, { 1, -1 }, { -32, -16 }, { 1, 0 }, ScrollDirection::East, PM_WALK3, WalkSides }, + { Direction::SouthEast, { 1, 0 }, { -32, -16 }, { 0, 0 }, ScrollDirection::SouthEast, PM_WALK2, WalkDownwards } // clang-format on } }; -void ScrollViewPort(const Player &player, _scroll_direction dir) +void ScrollViewPort(const Player &player, ScrollDirection dir) { ScrollInfo.tile = Point { 0, 0 } + (player.position.tile - ViewPosition); if (zoomflag) { if (abs(ScrollInfo.tile.x) >= 3 || abs(ScrollInfo.tile.y) >= 3) { - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; } else { ScrollInfo._sdir = dir; } } else if (abs(ScrollInfo.tile.x) >= 2 || abs(ScrollInfo.tile.y) >= 2) { - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; } else { ScrollInfo._sdir = dir; } @@ -429,7 +429,7 @@ void StartWalkStand(int pnum) if (pnum == MyPlayerId) { ScrollInfo.offset = { 0, 0 }; - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; ViewPosition = player.position.tile; } } @@ -455,7 +455,7 @@ void ChangeOffset(int pnum) px -= player.position.offset2.deltaX >> 8; py -= player.position.offset2.deltaY >> 8; - if (pnum == MyPlayerId && ScrollInfo._sdir != SDIR_NONE) { + if (pnum == MyPlayerId && ScrollInfo._sdir != ScrollDirection::None) { ScrollInfo.offset += { px, py }; } @@ -743,7 +743,7 @@ bool DoWalk(int pnum, int variant) } //Update the "camera" tile position - if (pnum == MyPlayerId && ScrollInfo._sdir != SDIR_NONE) { + if (pnum == MyPlayerId && ScrollInfo._sdir != ScrollDirection::None) { ViewPosition = Point { 0, 0 } + (player.position.tile - ScrollInfo.tile); } @@ -2793,7 +2793,7 @@ void InitPlayer(Player &player, bool firstTime) deathdelay = 0; MyPlayerIsDead = false; ScrollInfo.offset = { 0, 0 }; - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; } } @@ -2849,7 +2849,7 @@ void FixPlayerLocation(int pnum, Direction bDir) player._pdir = bDir; if (pnum == MyPlayerId) { ScrollInfo.offset = { 0, 0 }; - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; ViewPosition = player.position.tile; } ChangeLightXY(player._plid, player.position.tile); diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 288025916..4d0fd522c 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1135,46 +1135,46 @@ void DrawGame(const Surface &fullOut, Point position) // Draw areas moving in and out of the screen switch (ScrollInfo._sdir) { - case SDIR_N: + case ScrollDirection::North: sy -= TILE_HEIGHT; position += Direction::North; rows += 2; break; - case SDIR_NE: + case ScrollDirection::NorthEast: sy -= TILE_HEIGHT; position += Direction::North; columns++; rows += 2; break; - case SDIR_E: + case ScrollDirection::East: columns++; break; - case SDIR_SE: + case ScrollDirection::SouthEast: columns++; rows++; break; - case SDIR_S: + case ScrollDirection::South: rows += 2; break; - case SDIR_SW: + case ScrollDirection::SouthWest: sx -= TILE_WIDTH; position += Direction::West; columns++; rows++; break; - case SDIR_W: + case ScrollDirection::West: sx -= TILE_WIDTH; position += Direction::West; columns++; break; - case SDIR_NW: + case ScrollDirection::NorthWest: sx -= TILE_WIDTH / 2; sy -= TILE_HEIGHT / 2; position += Direction::NorthWest; columns++; rows++; break; - case SDIR_NONE: + case ScrollDirection::None: break; } @@ -1627,7 +1627,7 @@ void ScrollView() } if (scroll) - ScrollInfo._sdir = SDIR_NONE; + ScrollInfo._sdir = ScrollDirection::None; } #endif diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 8b5f917e8..478b697d3 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -13,16 +13,16 @@ namespace devilution { -enum _scroll_direction : uint8_t { - SDIR_NONE, - SDIR_N, - SDIR_NE, - SDIR_E, - SDIR_SE, - SDIR_S, - SDIR_SW, - SDIR_W, - SDIR_NW, +enum class ScrollDirection : uint8_t { + None, + North, + NorthEast, + East, + SouthEast, + South, + SouthWest, + West, + NorthWest, }; // Defined in SourceX/controls/plctrls.cpp