Browse Source

Introduce GetDunSize

pull/6842/head
obligaron 2 years ago committed by Anders Jenbo
parent
commit
dc85e7db43
  1. 4
      Source/levels/crypt.cpp
  2. 7
      Source/levels/gendung.cpp
  3. 4
      Source/levels/gendung.h
  4. 8
      Source/quests.cpp
  5. 2
      test/drlg_test.hpp

4
Source/levels/crypt.cpp

@ -689,7 +689,7 @@ void SetCryptRoom()
auto dunData = LoadFileInMem<uint16_t>("nlevels\\l5data\\uberroom.dun"); auto dunData = LoadFileInMem<uint16_t>("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); PlaceDunTiles(dunData.get(), position, 0);
} }
@ -700,7 +700,7 @@ void SetCornerRoom()
auto dunData = LoadFileInMem<uint16_t>("nlevels\\l5data\\cornerstone.dun"); auto dunData = LoadFileInMem<uint16_t>("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); PlaceDunTiles(dunData.get(), position, 0);
} }

7
Source/levels/gendung.cpp

@ -703,13 +703,18 @@ void DRLG_HoldThemeRooms()
} }
} }
WorldTileSize GetDunSize(const uint16_t *dunData)
{
return WorldTileSize(static_cast<WorldTileCoord>(SDL_SwapLE16(dunData[0])), static_cast<WorldTileCoord>(SDL_SwapLE16(dunData[1])));
}
void SetSetPieceRoom(WorldTilePosition position, int floorId) void SetSetPieceRoom(WorldTilePosition position, int floorId)
{ {
if (pSetPiece == nullptr) if (pSetPiece == nullptr)
return; return;
PlaceDunTiles(pSetPiece.get(), position, floorId); PlaceDunTiles(pSetPiece.get(), position, floorId);
SetPiece = { position, WorldTileSize(SDL_SwapLE16(pSetPiece[0]), SDL_SwapLE16(pSetPiece[1])) }; SetPiece = { position, GetDunSize(pSetPiece.get()) };
} }
void FreeQuestSetPieces() void FreeQuestSetPieces()

4
Source/levels/gendung.h

@ -358,6 +358,10 @@ std::optional<Point> PlaceMiniSet(const Miniset &miniset, int tries = 199, bool
void PlaceDunTiles(const uint16_t *dunData, Point position, int floorId = 0); 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_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, bool rndSize);
void DRLG_HoldThemeRooms(); 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 SetSetPieceRoom(WorldTilePosition position, int floorId);
void FreeQuestSetPieces(); void FreeQuestSetPieces();
void DRLG_LPass3(int lv); void DRLG_LPass3(int lv);

8
Source/quests.cpp

@ -147,7 +147,7 @@ void DrawWarLord(Point position)
{ {
auto dunData = LoadFileInMem<uint16_t>("levels\\l4data\\warlord2.dun"); auto dunData = LoadFileInMem<uint16_t>("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); PlaceDunTiles(dunData.get(), position, 6);
} }
@ -156,7 +156,7 @@ void DrawSChamber(quest_id q, Point position)
{ {
auto dunData = LoadFileInMem<uint16_t>("levels\\l2data\\bonestr1.dun"); auto dunData = LoadFileInMem<uint16_t>("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); PlaceDunTiles(dunData.get(), position, 3);
@ -170,7 +170,7 @@ void DrawLTBanner(Point position)
int width = SDL_SwapLE16(dunData[0]); int width = SDL_SwapLE16(dunData[0]);
int height = SDL_SwapLE16(dunData[1]); 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]; const uint16_t *tileLayer = &dunData[2];
@ -197,7 +197,7 @@ void DrawBlood(Point position)
{ {
auto dunData = LoadFileInMem<uint16_t>("levels\\l2data\\blood2.dun"); auto dunData = LoadFileInMem<uint16_t>("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); PlaceDunTiles(dunData.get(), position, 0);
} }

2
test/drlg_test.hpp

@ -48,7 +48,7 @@ void LoadExpectedLevelData(const char *fixture)
dunPath.append(fixture); dunPath.append(fixture);
DunData = LoadFileInMem<uint16_t>(dunPath.c_str()); DunData = LoadFileInMem<uint16_t>(dunPath.c_str());
ASSERT_NE(DunData, nullptr) << "Unable to load test fixture " << dunPath; 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) void TestInitGame(bool fullQuests = true, bool originalCathedral = true)

Loading…
Cancel
Save