From 0d4e7925511c1aa763569cce269df73e63cd1de7 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 24 May 2021 00:30:56 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Change=20'SetMapMonsters'?= =?UTF-8?q?=20to=20take=20a=20'Point'=20instead=20of=202=20separate=20ints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/drlg_l1.cpp | 2 +- Source/drlg_l2.cpp | 2 +- Source/drlg_l3.cpp | 2 +- Source/drlg_l4.cpp | 2 +- Source/monster.cpp | 24 ++++++++++++------------ Source/monster.h | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index ae8eadf5f..46009ef2d 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1246,7 +1246,7 @@ void LoadL1Dungeon(const char *path, int vx, int vy) if (currlevel < 17) DRLG_InitL1Vals(); - SetMapMonsters(dunData.get(), 0, 0); + SetMapMonsters(dunData.get(), { 0, 0 }); SetMapObjects(dunData.get(), 0, 0); } diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index ca15df234..756800f42 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -3308,7 +3308,7 @@ void LoadL2Dungeon(const char *path, int vx, int vy) ViewX = vx; ViewY = vy; - SetMapMonsters(dunData.get(), 0, 0); + SetMapMonsters(dunData.get(), { 0, 0 }); SetMapObjects(dunData.get(), 0, 0); } diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 13f671fb3..987880c48 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -2657,7 +2657,7 @@ void LoadL3Dungeon(const char *path, int vx, int vy) ViewX = vx; ViewY = vy; - SetMapMonsters(dunData.get(), 0, 0); + SetMapMonsters(dunData.get(), { 0, 0 }); SetMapObjects(dunData.get(), 0, 0); for (int j = 0; j < MAXDUNY; j++) { diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 7d2d8b42c..532c76868 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1758,7 +1758,7 @@ void LoadL4Dungeon(const char *path, int vx, int vy) DRLG_L4Pass3(); DRLG_Init_Globals(); - SetMapMonsters(dunData.get(), 0, 0); + SetMapMonsters(dunData.get(), { 0, 0 }); SetMapObjects(dunData.get(), 0, 0); } diff --git a/Source/monster.cpp b/Source/monster.cpp index 92d68a539..20b8419a4 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -946,23 +946,23 @@ void PlaceQuestMonsters() if (QuestStatus(Q_LTBANNER)) { auto dunData = LoadFileInMem("Levels\\L1Data\\Banner1.DUN"); - SetMapMonsters(dunData.get(), 2 * setpc_x, 2 * setpc_y); + SetMapMonsters(dunData.get(), Point { setpc_x, setpc_y } * 2); } if (QuestStatus(Q_BLOOD)) { auto dunData = LoadFileInMem("Levels\\L2Data\\Blood2.DUN"); - SetMapMonsters(dunData.get(), 2 * setpc_x, 2 * setpc_y); + SetMapMonsters(dunData.get(), Point { setpc_x, setpc_y } * 2); } if (QuestStatus(Q_BLIND)) { auto dunData = LoadFileInMem("Levels\\L2Data\\Blind2.DUN"); - SetMapMonsters(dunData.get(), 2 * setpc_x, 2 * setpc_y); + SetMapMonsters(dunData.get(), Point { setpc_x, setpc_y } * 2); } if (QuestStatus(Q_ANVIL)) { auto dunData = LoadFileInMem("Levels\\L3Data\\Anvil.DUN"); - SetMapMonsters(dunData.get(), 2 * setpc_x + 2, 2 * setpc_y + 2); + SetMapMonsters(dunData.get(), Point { setpc_x + 2, setpc_y + 2 } * 2); } if (QuestStatus(Q_WARLORD)) { auto dunData = LoadFileInMem("Levels\\L4Data\\Warlord.DUN"); - SetMapMonsters(dunData.get(), 2 * setpc_x, 2 * setpc_y); + SetMapMonsters(dunData.get(), Point { setpc_x, setpc_y } * 2); AddMonsterType(UniqMonst[UMT_WARLORD].mtype, PLACE_SCATTER); } if (QuestStatus(Q_VEIL)) { @@ -979,7 +979,7 @@ void PlaceQuestMonsters() PlaceUniqueMonst(UMT_RED_VEX, 0, 0); PlaceUniqueMonst(UMT_BLACKJADE, 0, 0); auto dunData = LoadFileInMem("Levels\\L4Data\\Vile1.DUN"); - SetMapMonsters(dunData.get(), 2 * setpc_x, 2 * setpc_y); + SetMapMonsters(dunData.get(), Point { setpc_x, setpc_y } * 2); } if (currlevel == 24) { @@ -1083,19 +1083,19 @@ void LoadDiabMonsts() { { auto dunData = LoadFileInMem("Levels\\L4Data\\diab1.DUN"); - SetMapMonsters(dunData.get(), 2 * diabquad1x, 2 * diabquad1y); + SetMapMonsters(dunData.get(), Point { diabquad1x, diabquad1y } * 2); } { auto dunData = LoadFileInMem("Levels\\L4Data\\diab2a.DUN"); - SetMapMonsters(dunData.get(), 2 * diabquad2x, 2 * diabquad2y); + SetMapMonsters(dunData.get(), Point { diabquad2x, diabquad2y } * 2); } { auto dunData = LoadFileInMem("Levels\\L4Data\\diab3a.DUN"); - SetMapMonsters(dunData.get(), 2 * diabquad3x, 2 * diabquad3y); + SetMapMonsters(dunData.get(), Point { diabquad3x, diabquad3y } * 2); } { auto dunData = LoadFileInMem("Levels\\L4Data\\diab4a.DUN"); - SetMapMonsters(dunData.get(), 2 * diabquad4x, 2 * diabquad4y); + SetMapMonsters(dunData.get(), Point { diabquad4x, diabquad4y } * 2); } } @@ -1175,7 +1175,7 @@ void InitMonsters() } } -void SetMapMonsters(const uint16_t *dunData, int startx, int starty) +void SetMapMonsters(const uint16_t *dunData, Point startPosition) { AddMonsterType(MT_GOLEM, PLACE_SPECIAL); AddMonster(1, 0, DIR_S, 0, false); @@ -1207,7 +1207,7 @@ void SetMapMonsters(const uint16_t *dunData, int startx, int starty) uint8_t monsterId = SDL_SwapLE16(monsterLayer[j * width + i]); if (monsterId != 0) { int mtype = AddMonsterType(MonstConvTbl[monsterId - 1], PLACE_SPECIAL); - PlaceMonster(nummonsters++, mtype, i + startx + 16, j + starty + 16); + PlaceMonster(nummonsters++, mtype, i + startPosition.x + 16, j + startPosition.y + 16); } } } diff --git a/Source/monster.h b/Source/monster.h index b2788628b..aa7183552 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -211,7 +211,7 @@ void ClrAllMonsters(); void monster_some_crypt(); void PlaceGroup(int mtype, int num, int leaderf, int leader); void InitMonsters(); -void SetMapMonsters(const uint16_t *dunData, int startx, int starty); +void SetMapMonsters(const uint16_t *dunData, Point startPosition); void DeleteMonster(int i); int AddMonster(int x, int y, Direction dir, int mtype, bool InMap); void monster_43C785(int i);