From 86bc2ee9da463bf8bfc1566856119fbba7f4aa9b Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 6 Mar 2021 16:56:47 +0800 Subject: [PATCH] dlrg: Place constants in an anonymous namespace (#1114) --- Source/drlg_l1.cpp | 20 +++++++++++++------- Source/drlg_l2.cpp | 7 ++++++- Source/drlg_l3.cpp | 12 ++++++++---- Source/drlg_l4.cpp | 5 +++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 289560a31..19c4ae1fd 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -7,6 +7,16 @@ DEVILUTION_BEGIN_NAMESPACE +int UberRow; +int UberCol; +bool IsUberRoomOpened; +int UberLeverRow; +int UberLeverCol; +bool IsUberLeverActivated; +int UberDiabloMonsterIndex; + +namespace { + /** Represents a tile ID map of twice the size, repeating each tile of the original map in blocks of 4. */ BYTE L5dungeon[80][80]; BYTE L5dflags[DMAXX][DMAXY]; @@ -18,13 +28,7 @@ int HR1; int HR2; /** Specifies whether to generate a horizontal room at position 3 in the Cathedral. */ int HR3; -int UberRow; -int UberCol; -bool IsUberRoomOpened; -int UberLeverRow; -int UberLeverCol; -bool IsUberLeverActivated; -int UberDiabloMonsterIndex; + /** Specifies whether to generate a vertical room at position 1 in the Cathedral. */ BOOL VR1; /** Specifies whether to generate a vertical room at position 2 in the Cathedral. */ @@ -472,6 +476,8 @@ BYTE CornerstoneRoomPattern[32] = { 5, 5, 4, 2, 2, 2, 6, 1, 111, 172, 0, 1, 1, 1 */ BYTE L5ConvTbl[16] = { 22, 13, 1, 13, 2, 13, 13, 13, 4, 13, 1, 13, 2, 13, 16, 13 }; +} // namespace + void DRLG_InitL5Vals() { int i, j, pc; diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index db011f3b7..c478eeefb 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -10,12 +10,15 @@ DEVILUTION_BEGIN_NAMESPACE +BYTE predungeon[DMAXX][DMAXY]; + +namespace { + int nSx1; int nSy1; int nSx2; int nSy2; int nRoomCnt; -BYTE predungeon[DMAXX][DMAXY]; ROOMNODE RoomList[81]; HALLNODE *pHallList; @@ -1598,6 +1601,8 @@ int Patterns[100][10] = { { 0, 0, 0, 0, 255, 0, 0, 0, 0, 0 }, }; +} // namespace + static BOOL DRLG_L2PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir) { int sx, sy, sw, sh, xx, yy, i, ii, numt, bailcnt; diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index bb95003e1..fd74fb2f5 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -10,6 +10,8 @@ DEVILUTION_BEGIN_NAMESPACE +namespace { + /** This will be true if a lava pool has been generated for the level */ BOOLEAN lavapool; int lockoutcnt; @@ -832,6 +834,8 @@ const BYTE byte_48A9C8[] = { // clang-format on }; +} // namespace + static void InitL3Dungeon() { int i, j; @@ -2165,7 +2169,7 @@ static void DRLG_L3Wood() FenceDoorFix(); } -BOOL DRLG_L3Anvil() +static BOOL DRLG_L3Anvil() { int sx, sy, sw, sh, xx, yy, ii, trys; BOOL found; @@ -2226,7 +2230,7 @@ BOOL DRLG_L3Anvil() return FALSE; } -void FixL3Warp() +static void FixL3Warp() { int i, j; @@ -2246,7 +2250,7 @@ void FixL3Warp() } } -void FixL3HallofHeroes() +static void FixL3HallofHeroes() { int i, j; @@ -2273,7 +2277,7 @@ void FixL3HallofHeroes() } } -void DRLG_L3LockRec(int x, int y) +static void DRLG_L3LockRec(int x, int y) { if (!lockout[x][y]) { return; diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index aa1ba2ba0..2ecf08201 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -15,6 +15,9 @@ int diabquad3x; int diabquad3y; int diabquad4x; int diabquad4y; + +namespace { + BOOL hallok[20]; int l4holdx; int l4holdy; @@ -141,6 +144,8 @@ const BYTE L4BTYPES[140] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +} // namespace + static void DRLG_L4Shadows() { int x, y;