From ba66a9dc872d29449ac9348c50242e65dfc065ed Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sun, 27 Jun 2021 18:26:12 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20'dmaxx'=20and=20?= =?UTF-8?q?'dmaxy'=20globals=20with=20single=20'dmaxPosition'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/drlg_l1.cpp | 13 +++++-------- Source/drlg_l2.cpp | 3 +-- Source/drlg_l3.cpp | 6 ++---- Source/drlg_l4.cpp | 9 +++------ Source/gendung.cpp | 3 +-- Source/gendung.h | 6 ++---- Source/scrollrt.cpp | 14 +++++++------- Source/town.cpp | 3 +-- 8 files changed, 22 insertions(+), 35 deletions(-) diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 3ac6e6edc..62a54038b 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -2402,8 +2402,7 @@ void Pass3() void LoadL1Dungeon(const char *path, int vx, int vy) { dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; DRLG_InitTrans(); @@ -2458,8 +2457,7 @@ void LoadPreL1Dungeon(const char *path) } dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; auto dunData = LoadFileInMem(path); @@ -2495,8 +2493,7 @@ void CreateL5Dungeon(uint32_t rseed, lvl_entry entry) SetRndSeed(rseed); dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; UberRow = 0; UberCol = 0; @@ -2519,8 +2516,8 @@ void CreateL5Dungeon(uint32_t rseed, lvl_entry entry) DRLG_SetPC(); - for (int j = dminPosition.y; j < dmaxy; j++) { - for (int i = dminPosition.x; i < dmaxx; i++) { + for (int j = dminPosition.y; j < dmaxPosition.y; j++) { + for (int i = dminPosition.x; i < dmaxPosition.x; i++) { if (dPiece[i][j] == 290) { UberRow = i; UberCol = j; diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 22c455ff1..0a6ce237e 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -3173,8 +3173,7 @@ void CreateL2Dungeon(uint32_t rseed, lvl_entry entry) SetRndSeed(rseed); dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; DRLG_InitTrans(); DRLG_InitSetPC(); diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 2fc71bc13..347026adc 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -2482,8 +2482,7 @@ void CreateL3Dungeon(uint32_t rseed, lvl_entry entry) SetRndSeed(rseed); dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; DRLG_InitTrans(); DRLG_InitSetPC(); @@ -2518,8 +2517,7 @@ void CreateL3Dungeon(uint32_t rseed, lvl_entry entry) void LoadL3Dungeon(const char *path, int vx, int vy) { dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; InitDungeonFlags(); DRLG_InitTrans(); diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 9a577d815..9d02afd85 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1469,8 +1469,7 @@ void CreateL4Dungeon(uint32_t rseed, lvl_entry entry) SetRndSeed(rseed); dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; ViewPosition = { 40, 40 }; @@ -1485,8 +1484,7 @@ void CreateL4Dungeon(uint32_t rseed, lvl_entry entry) void LoadL4Dungeon(const char *path, int vx, int vy) { dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; DRLG_InitTrans(); InitDungeonFlags(); @@ -1507,8 +1505,7 @@ void LoadL4Dungeon(const char *path, int vx, int vy) void LoadPreL4Dungeon(const char *path) { dminPosition = { 16, 16 }; - dmaxx = 96; - dmaxy = 96; + dmaxPosition = { 96, 96 }; InitDungeonFlags(); diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 63a03c8ef..0017611a5 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -33,8 +33,7 @@ std::array nTransTable; std::array nMissileTable; std::array nTrapTable; Point dminPosition; -int dmaxx; -int dmaxy; +Point dmaxPosition; dungeon_type leveltype; BYTE currlevel; bool setlevel; diff --git a/Source/gendung.h b/Source/gendung.h index 63be65235..b329a6ed1 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -167,10 +167,8 @@ extern std::array nMissileTable; extern std::array nTrapTable; /** Specifies the minimum X,Y-coordinates of the map. */ extern Point dminPosition; -/** Specifies the maximum X-coordinate of the map. */ -extern int dmaxx; -/** Specifies the maximum Y-coordinate of the map. */ -extern int dmaxy; +/** Specifies the maximum X,Y-coordinates of the map. */ +extern Point dmaxPosition; /** Specifies the active dungeon type of the current game. */ extern dungeon_type leveltype; /** Specifies the active dungeon level of the current game. */ diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index efd3c3247..35abe6b6d 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1624,8 +1624,8 @@ void ScrollView() scroll = false; if (MousePosition.x < 20) { - if (dmaxy - 1 <= ViewPosition.y || dminPosition.x >= ViewPosition.x) { - if (dmaxy - 1 > ViewPosition.y) { + if (dmaxPosition.y - 1 <= ViewPosition.y || dminPosition.x >= ViewPosition.x) { + if (dmaxPosition.y - 1 > ViewPosition.y) { ViewPosition.y++; scroll = true; } @@ -1640,8 +1640,8 @@ void ScrollView() } } if (MousePosition.x > gnScreenWidth - 20) { - if (dmaxx - 1 <= ViewPosition.x || dminPosition.y >= ViewPosition.y) { - if (dmaxx - 1 > ViewPosition.x) { + if (dmaxPosition.x - 1 <= ViewPosition.x || dminPosition.y >= ViewPosition.y) { + if (dmaxPosition.x - 1 > ViewPosition.x) { ViewPosition.x++; scroll = true; } @@ -1672,12 +1672,12 @@ void ScrollView() } } if (MousePosition.y > gnScreenHeight - 20) { - if (dmaxy - 1 <= ViewPosition.y || dmaxx - 1 <= ViewPosition.x) { - if (dmaxy - 1 > ViewPosition.y) { + if (dmaxPosition.y - 1 <= ViewPosition.y || dmaxPosition.x - 1 <= ViewPosition.x) { + if (dmaxPosition.y - 1 > ViewPosition.y) { ViewPosition.y++; scroll = true; } - if (dmaxx - 1 > ViewPosition.x) { + if (dmaxPosition.x - 1 > ViewPosition.x) { ViewPosition.x++; scroll = true; } diff --git a/Source/town.cpp b/Source/town.cpp index ed566240a..f9687eafc 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -269,8 +269,7 @@ void TownOpenGrave() void CreateTown(lvl_entry entry) { dminPosition = { 10, 10 }; - dmaxx = 84; - dmaxy = 84; + dmaxPosition = { 84, 84 }; DRLG_InitTrans(); DRLG_Init_Globals();