diff --git a/Source/levels/crypt.cpp b/Source/levels/crypt.cpp index 136dbd1fd..80415f5dc 100644 --- a/Source/levels/crypt.cpp +++ b/Source/levels/crypt.cpp @@ -689,7 +689,7 @@ void SetCryptRoom() auto dunData = LoadFileInMem("nlevels\\l5data\\uberroom.dun"); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(dunData[0]), SDL_SwapLE16(dunData[1])) }; + SetPiece = { position, GetDunSize(dunData.get()) }; PlaceDunTiles(dunData.get(), position, 0); } @@ -700,7 +700,7 @@ void SetCornerRoom() auto dunData = LoadFileInMem("nlevels\\l5data\\cornerstone.dun"); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(dunData[0]), SDL_SwapLE16(dunData[1])) }; + SetPiece = { position, GetDunSize(dunData.get()) }; PlaceDunTiles(dunData.get(), position, 0); } diff --git a/Source/levels/gendung.cpp b/Source/levels/gendung.cpp index 6ed8e1c60..341de6ff5 100644 --- a/Source/levels/gendung.cpp +++ b/Source/levels/gendung.cpp @@ -703,13 +703,18 @@ void DRLG_HoldThemeRooms() } } +WorldTileSize GetDunSize(const uint16_t *dunData) +{ + return WorldTileSize(static_cast(SDL_SwapLE16(dunData[0])), static_cast(SDL_SwapLE16(dunData[1]))); +} + void SetSetPieceRoom(WorldTilePosition position, int floorId) { if (pSetPiece == nullptr) return; PlaceDunTiles(pSetPiece.get(), position, floorId); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(pSetPiece[0]), SDL_SwapLE16(pSetPiece[1])) }; + SetPiece = { position, GetDunSize(pSetPiece.get()) }; } void FreeQuestSetPieces() diff --git a/Source/levels/gendung.h b/Source/levels/gendung.h index 452692098..c5476edb7 100644 --- a/Source/levels/gendung.h +++ b/Source/levels/gendung.h @@ -358,6 +358,10 @@ std::optional PlaceMiniSet(const Miniset &miniset, int tries = 199, bool void PlaceDunTiles(const uint16_t *dunData, Point position, int floorId = 0); void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, bool rndSize); void DRLG_HoldThemeRooms(); +/** + * @brief Returns ths size in tiles of the specified ".dun" Data + */ +WorldTileSize GetDunSize(const uint16_t *dunData); void SetSetPieceRoom(WorldTilePosition position, int floorId); void FreeQuestSetPieces(); void DRLG_LPass3(int lv); diff --git a/Source/quests.cpp b/Source/quests.cpp index b2ee1824d..063ceb2e0 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -147,7 +147,7 @@ void DrawWarLord(Point position) { auto dunData = LoadFileInMem("levels\\l4data\\warlord2.dun"); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(dunData[0]), SDL_SwapLE16(dunData[1])) }; + SetPiece = { position, GetDunSize(dunData.get()) }; PlaceDunTiles(dunData.get(), position, 6); } @@ -156,7 +156,7 @@ void DrawSChamber(quest_id q, Point position) { auto dunData = LoadFileInMem("levels\\l2data\\bonestr1.dun"); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(dunData[0]), SDL_SwapLE16(dunData[1])) }; + SetPiece = { position, GetDunSize(dunData.get()) }; PlaceDunTiles(dunData.get(), position, 3); @@ -170,7 +170,7 @@ void DrawLTBanner(Point position) int width = SDL_SwapLE16(dunData[0]); int height = SDL_SwapLE16(dunData[1]); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(dunData[0]), SDL_SwapLE16(dunData[1])) }; + SetPiece = { position, GetDunSize(dunData.get()) }; const uint16_t *tileLayer = &dunData[2]; @@ -197,7 +197,7 @@ void DrawBlood(Point position) { auto dunData = LoadFileInMem("levels\\l2data\\blood2.dun"); - SetPiece = { position, WorldTileSize(SDL_SwapLE16(dunData[0]), SDL_SwapLE16(dunData[1])) }; + SetPiece = { position, GetDunSize(dunData.get()) }; PlaceDunTiles(dunData.get(), position, 0); } diff --git a/test/drlg_test.hpp b/test/drlg_test.hpp index 1612c8667..9906116c4 100644 --- a/test/drlg_test.hpp +++ b/test/drlg_test.hpp @@ -48,7 +48,7 @@ void LoadExpectedLevelData(const char *fixture) dunPath.append(fixture); DunData = LoadFileInMem(dunPath.c_str()); ASSERT_NE(DunData, nullptr) << "Unable to load test fixture " << dunPath; - ASSERT_EQ(Size(DMAXX, DMAXY), Size(SDL_SwapLE16(DunData[0]), SDL_SwapLE16(DunData[1]))); + ASSERT_EQ(WorldTileSize(DMAXX, DMAXY), GetDunSize(DunData.get())); } void TestInitGame(bool fullQuests = true, bool originalCathedral = true)