Browse Source

Clean up level initialization

pull/4717/head
Anders Jenbo 4 years ago
parent
commit
6fa681e567
  1. 138
      Source/drlg_l1.cpp
  2. 92
      Source/drlg_l2.cpp
  3. 88
      Source/drlg_l3.cpp
  4. 75
      Source/drlg_l4.cpp
  5. 28
      Source/gendung.cpp
  6. 3
      Source/gendung.h
  7. 1
      Source/setmaps.cpp
  8. 88
      Source/town.cpp

138
Source/drlg_l1.cpp

@ -804,11 +804,6 @@ void LoadQuestSetPieces()
}
}
void FreeQuestSetPieces()
{
pSetPiece = nullptr;
}
void InitDungeonPieces()
{
for (int j = 0; j < MAXDUNY; j++) {
@ -1497,16 +1492,6 @@ Point SelectChamber()
}
}
void SetSetPieceRoom()
{
if (pSetPiece == nullptr)
return;
Point position = SelectChamber();
PlaceDunTiles(pSetPiece.get(), position, Tile::Floor);
SetPiece = { position, { SDL_SwapLE16(pSetPiece[0]), SDL_SwapLE16(pSetPiece[1]) } };
}
void SetCryptRoom()
{
Point position = SelectChamber();
@ -1586,8 +1571,8 @@ void FillChambers()
} else if (currlevel == 21) {
SetCornerRoom();
}
} else {
SetSetPieceRoom();
} else if (pSetPiece != nullptr) {
SetSetPieceRoom(SelectChamber(), Tile::Floor);
}
}
@ -1910,6 +1895,8 @@ void GenerateLevel(lvl_entry entry)
break;
}
LoadQuestSetPieces();
while (true) {
DRLG_InitTrans();
@ -1928,6 +1915,8 @@ void GenerateLevel(lvl_entry entry)
break;
}
FreeQuestSetPieces();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
if (dungeon[i][j] == Tile::EntranceStairs) {
@ -2005,117 +1994,80 @@ void GenerateLevel(lvl_entry entry)
FillFloor();
}
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
memcpy(pdungeon, dungeon, sizeof(pdungeon));
DRLG_Init_Globals();
DRLG_CheckQuests(SetPiece.position);
}
void Pass3()
{
DRLG_LPass3(22 - 1);
if (leveltype == DTYPE_CRYPT)
InitCryptPieces();
else
InitDungeonPieces();
}
} // namespace
void LoadL1Dungeon(const char *path, int vx, int vy)
void CreateL5Dungeon(uint32_t rseed, lvl_entry entry)
{
dminPosition = { 16, 16 };
dmaxPosition = { 96, 96 };
DRLG_InitTrans();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 22;
Protected[i][j] = false;
}
}
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, Tile::Floor);
SetRndSeed(rseed);
FillFloor();
UberRow = 0;
UberCol = 0;
ViewPosition = { vx, vy };
GenerateLevel(entry);
Pass3();
DRLG_Init_Globals();
if (leveltype != DTYPE_CRYPT)
InitDungeonPieces();
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
if (leveltype == DTYPE_CRYPT) {
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;
}
if (dPiece[i][j] == 317) {
CornerStone.position = { i, j };
}
}
}
}
}
void LoadPreL1Dungeon(const char *path)
{
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 22;
Protected[i][j] = false;
}
}
dminPosition = { 16, 16 };
dmaxPosition = { 96, 96 };
memset(dungeon, 22, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, Tile::Floor);
FillFloor();
if (leveltype == DTYPE_CATHEDRAL)
FillFloor();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
memcpy(pdungeon, dungeon, sizeof(pdungeon));
}
void CreateL5Dungeon(uint32_t rseed, lvl_entry entry)
void LoadL1Dungeon(const char *path, int vx, int vy)
{
SetRndSeed(rseed);
ViewPosition = { vx, vy };
dminPosition = { 16, 16 };
dmaxPosition = { 96, 96 };
DRLG_Init_Globals();
UberRow = 0;
UberCol = 0;
IsUberRoomOpened = false;
IsUberLeverActivated = false;
UberDiabloMonsterIndex = 0;
memset(dungeon, 22, sizeof(dungeon));
DRLG_InitTrans();
DRLG_InitSetPC();
LoadQuestSetPieces();
GenerateLevel(entry);
Pass3();
FreeQuestSetPieces();
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, Tile::Floor);
if (leveltype == DTYPE_CRYPT) {
InitCryptPieces();
} else {
InitDungeonPieces();
}
if (leveltype == DTYPE_CATHEDRAL)
FillFloor();
DRLG_SetPC();
Pass3();
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;
}
if (dPiece[i][j] == 317) {
CornerStone.position = { i, j };
}
}
}
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
}
} // namespace devilution

92
Source/drlg_l2.cpp

@ -1613,11 +1613,6 @@ void LoadQuestSetPieces()
}
}
void FreeQuestSetPieces()
{
pSetPiece = nullptr;
}
void InitDungeonPieces()
{
for (int j = 0; j < MAXDUNY; j++) {
@ -2713,6 +2708,8 @@ bool PlaceStairs(lvl_entry entry)
void GenerateLevel(lvl_entry entry)
{
LoadQuestSetPieces();
while (true) {
nRoomCnt = 0;
InitDungeonFlags();
@ -2721,16 +2718,15 @@ void GenerateLevel(lvl_entry entry)
continue;
}
FixTilesPatterns();
if (pSetPiece != nullptr) {
PlaceDunTiles(pSetPiece.get(), SetPieceRoom.position, 3);
SetPiece = { SetPieceRoom.position, { SDL_SwapLE16(pSetPiece[0]), SDL_SwapLE16(pSetPiece[1]) } };
}
SetSetPieceRoom(SetPieceRoom.position, 3);
FloodTransparencyValues(3);
FixTransparency();
if (PlaceStairs(entry))
break;
}
FreeQuestSetPieces();
FixLockout();
FixDoors();
FixDirtTiles();
@ -2847,88 +2843,54 @@ void GenerateLevel(lvl_entry entry)
Substitution();
ApplyShadowsPatterns();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
memcpy(pdungeon, dungeon, sizeof(pdungeon));
DRLG_Init_Globals();
DRLG_CheckQuests(SetPieceRoom.position);
}
void LoadDungeonData(const uint16_t *dunData)
{
InitDungeonFlags();
DRLG_InitTrans();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 12;
}
}
PlaceDunTiles(dunData, { 0, 0 }, 3);
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) { // NOLINT(modernize-loop-convert)
if (dungeon[i][j] == 0) {
dungeon[i][j] = 12;
}
}
}
}
void Pass3()
{
DRLG_LPass3(12 - 1);
InitDungeonPieces();
}
} // namespace
void LoadL2Dungeon(const char *path, int vx, int vy)
void CreateL2Dungeon(uint32_t rseed, lvl_entry entry)
{
auto dunData = LoadFileInMem<uint16_t>(path);
LoadDungeonData(dunData.get());
Pass3();
DRLG_Init_Globals();
InitDungeonPieces();
SetRndSeed(rseed);
ViewPosition = { vx, vy };
GenerateLevel(entry);
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
Pass3();
}
void LoadPreL2Dungeon(const char *path)
{
memset(dungeon, 12, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
LoadDungeonData(dunData.get());
PlaceDunTiles(dunData.get(), { 0, 0 }, 3);
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
memcpy(pdungeon, dungeon, sizeof(pdungeon));
}
void CreateL2Dungeon(uint32_t rseed, lvl_entry entry)
void LoadL2Dungeon(const char *path, int vx, int vy)
{
SetRndSeed(rseed);
ViewPosition = { vx, vy };
dminPosition = { 16, 16 };
dmaxPosition = { 96, 96 };
DRLG_Init_Globals();
memset(dungeon, 12, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, 3);
DRLG_InitTrans();
DRLG_InitSetPC();
LoadQuestSetPieces();
GenerateLevel(entry);
Pass3();
FreeQuestSetPieces();
InitDungeonPieces();
DRLG_SetPC();
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
}
} // namespace devilution

88
Source/drlg_l3.cpp

@ -1831,11 +1831,16 @@ void Fence()
FenceDoorFix();
}
void LoadQuestSetPieces()
{
if (Quests[Q_ANVIL].IsAvailable())
pSetPiece = LoadFileInMem<uint16_t>("Levels\\L3Data\\Anvil.DUN");
}
bool PlaceAnvil()
{
auto dunData = LoadFileInMem<uint16_t>("Levels\\L3Data\\Anvil.DUN");
int width = SDL_SwapLE16(dunData[0]);
int height = SDL_SwapLE16(dunData[1]);
int width = SDL_SwapLE16(pSetPiece[0]);
int height = SDL_SwapLE16(pSetPiece[1]);
int sx = GenerateRnd(DMAXX - width - 2);
int sy = GenerateRnd(DMAXY - height - 2);
@ -1866,6 +1871,7 @@ bool PlaceAnvil()
break;
}
PlaceDunTiles(pSetPiece.get(), { sx + 1, sy + 1 }, 7);
SetPiece = { { sx, sy }, { width + 2, height + 2 } };
for (int yy = 0; yy < SetPiece.size.width; yy++) {
@ -1874,8 +1880,6 @@ bool PlaceAnvil()
}
}
PlaceDunTiles(dunData.get(), { sx + 1, sy + 1 }, 7);
// Hack to avoid rivers entering the island, reversed later
dungeon[SetPiece.position.x + 7][SetPiece.position.y + 5] = 2;
dungeon[SetPiece.position.x + 8][SetPiece.position.y + 5] = 2;
@ -2030,6 +2034,8 @@ bool PlaceStairs(lvl_entry entry)
void GenerateLevel(lvl_entry entry)
{
LoadQuestSetPieces();
while (true) {
InitDungeonFlags();
int x1 = GenerateRnd(20) + 10;
@ -2064,6 +2070,8 @@ void GenerateLevel(lvl_entry entry)
break;
}
FreeQuestSetPieces();
if (leveltype == DTYPE_NEST) {
PlaceMiniSetRandom(L6ISLE1, 70);
PlaceMiniSetRandom(L6ISLE2, 70);
@ -2175,13 +2183,7 @@ void GenerateLevel(lvl_entry entry)
PlaceMiniSetRandom1x1(10, 110, 25);
}
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
DRLG_Init_Globals();
memcpy(pdungeon, dungeon, sizeof(pdungeon));
}
void Pass3()
@ -2232,74 +2234,38 @@ void CreateL3Dungeon(uint32_t rseed, lvl_entry entry)
{
SetRndSeed(rseed);
dminPosition = { 16, 16 };
dmaxPosition = { 96, 96 };
DRLG_InitTrans();
DRLG_InitSetPC();
GenerateLevel(entry);
Pass3();
PlaceLights();
DRLG_SetPC();
}
void LoadL3Dungeon(const char *path, int vx, int vy)
void LoadPreL3Dungeon(const char *path)
{
dminPosition = { 16, 16 };
dmaxPosition = { 96, 96 };
InitDungeonFlags();
DRLG_InitTrans();
memset(dungeon, 8, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, 7);
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) { // NOLINT(modernize-loop-convert)
if (dungeon[i][j] == 0) {
dungeon[i][j] = 8;
}
}
}
Pass3();
DRLG_Init_Globals();
memcpy(pdungeon, dungeon, sizeof(pdungeon));
}
void LoadL3Dungeon(const char *path, int vx, int vy)
{
ViewPosition = { vx, vy };
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
for (int j = 0; j < MAXDUNY; j++) {
for (int i = 0; i < MAXDUNX; i++) {
if (dPiece[i][j] >= 56 && dPiece[i][j] <= 147) {
DoLighting({ i, j }, 7, -1);
} else if (dPiece[i][j] >= 154 && dPiece[i][j] <= 161) {
DoLighting({ i, j }, 7, -1);
} else if (IsAnyOf(dPiece[i][j], 150, 152)) {
DoLighting({ i, j }, 7, -1);
}
}
}
}
DRLG_Init_Globals();
void LoadPreL3Dungeon(const char *path)
{
InitDungeonFlags();
DRLG_InitTrans();
memset(dungeon, 8, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, 7);
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) { // NOLINT(modernize-loop-convert)
if (dungeon[i][j] == 0) {
dungeon[i][j] = 8;
}
}
}
Pass3();
PlaceLights();
memcpy(pdungeon, dungeon, sizeof(pdungeon));
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
}
} // namespace devilution

75
Source/drlg_l4.cpp

@ -168,11 +168,6 @@ void LoadQuestSetPieces()
}
}
void FreeQuestSetPieces()
{
pSetPiece = nullptr;
}
void InitDungeonFlags()
{
memset(dung, 0, sizeof(dung));
@ -312,16 +307,6 @@ void FirstRoom()
GenerateRoom(x, y, w, h, GenerateRnd(2));
}
void SetSetPieceRoom(Point position)
{
if (pSetPiece == nullptr)
return;
SetPiece = { position, { SDL_SwapLE16(pSetPiece[0]), SDL_SwapLE16(pSetPiece[1]) } };
PlaceDunTiles(pSetPiece.get(), position, 6);
}
void MakeDungeon()
{
for (int j = 0; j < 20; j++) {
@ -1211,6 +1196,8 @@ bool PlaceStairs(lvl_entry entry)
void GenerateLevel(lvl_entry entry)
{
LoadQuestSetPieces();
while (true) {
DRLG_InitTrans();
@ -1238,7 +1225,7 @@ void GenerateLevel(lvl_entry entry)
AddWall();
FloodTransparencyValues(6);
FixTransparency();
SetSetPieceRoom(SetPieceRoom.position);
SetSetPieceRoom(SetPieceRoom.position, 6);
if (currlevel == 16) {
LoadDiabQuads(true);
}
@ -1246,6 +1233,8 @@ void GenerateLevel(lvl_entry entry)
break;
}
FreeQuestSetPieces();
GeneralFix();
if (currlevel != 16) {
@ -1255,15 +1244,8 @@ void GenerateLevel(lvl_entry entry)
ApplyShadowsPatterns();
FixCornerTiles();
Substitution();
DRLG_Init_Globals();
if (Quests[Q_WARLORD].IsAvailable()) {
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
}
memcpy(pdungeon, dungeon, sizeof(pdungeon));
DRLG_CheckQuests(SetPieceRoom.position);
@ -1281,11 +1263,6 @@ void GenerateLevel(lvl_entry entry)
}
}
if (currlevel == 16) {
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
LoadDiabQuads(false);
}
}
@ -1301,48 +1278,36 @@ void CreateL4Dungeon(uint32_t rseed, lvl_entry entry)
{
SetRndSeed(rseed);
dminPosition = Point(0, 0).megaToWorld();
dmaxPosition = Point(40, 40).megaToWorld();
ViewPosition = { 40, 40 };
DRLG_InitSetPC();
LoadQuestSetPieces();
GenerateLevel(entry);
Pass3();
FreeQuestSetPieces();
DRLG_SetPC();
}
void LoadL4Dungeon(const char *path, int vx, int vy)
void LoadPreL4Dungeon(const char *path)
{
dminPosition = Point(0, 0).megaToWorld();
dmaxPosition = Point(40, 40).megaToWorld();
DRLG_InitTrans();
InitDungeonFlags();
memset(dungeon, 30, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, 6);
ViewPosition = { vx, vy };
Pass3();
DRLG_Init_Globals();
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
memcpy(pdungeon, dungeon, sizeof(pdungeon));
}
void LoadPreL4Dungeon(const char *path)
void LoadL4Dungeon(const char *path, int vx, int vy)
{
dminPosition = Point(0, 0).megaToWorld();
dmaxPosition = Point(40, 40).megaToWorld();
ViewPosition = { vx, vy };
DRLG_Init_Globals();
InitDungeonFlags();
memset(dungeon, 30, sizeof(dungeon));
auto dunData = LoadFileInMem<uint16_t>(path);
PlaceDunTiles(dunData.get(), { 0, 0 }, 6);
Pass3();
SetMapMonsters(dunData.get(), Point(0, 0).megaToWorld());
SetMapObjects(dunData.get(), 0, 0);
}
} // namespace devilution

28
Source/gendung.cpp

@ -397,6 +397,8 @@ dungeon_type GetLevelType(int level)
void CreateDungeon(uint32_t rseed, lvl_entry entry)
{
DRLG_Init_Globals();
switch (leveltype) {
case DTYPE_TOWN:
CreateTown(entry);
@ -418,6 +420,8 @@ void CreateDungeon(uint32_t rseed, lvl_entry entry)
default:
app_fatal("Invalid level type");
}
Make_SetPC(SetPiece);
}
void FillSolidBlockTbls()
@ -511,11 +515,6 @@ void DRLG_InitSetPC()
SetPiece = { { 0, 0 }, { 0, 0 } };
}
void DRLG_SetPC()
{
Make_SetPC(SetPiece);
}
void Make_SetPC(Rectangle area)
{
Point position = area.position.megaToWorld();
@ -641,6 +640,20 @@ void DRLG_HoldThemeRooms()
}
}
void SetSetPieceRoom(Point position, int floorId)
{
if (pSetPiece == nullptr)
return;
PlaceDunTiles(pSetPiece.get(), position, floorId);
SetPiece = { position, { SDL_SwapLE16(pSetPiece[0]), SDL_SwapLE16(pSetPiece[1]) } };
}
void FreeQuestSetPieces()
{
pSetPiece = nullptr;
}
void DRLG_LPass3(int lv)
{
{
@ -689,6 +702,9 @@ void DRLG_LPass3(int lv)
void DRLG_Init_Globals()
{
dminPosition = Point(0, 0).megaToWorld();
dmaxPosition = Point(40, 40).megaToWorld();
memset(dItem, 0, sizeof(dItem));
memset(dFlags, 0, sizeof(dFlags));
memset(dPlayer, 0, sizeof(dPlayer));
memset(dMonster, 0, sizeof(dMonster));
@ -697,6 +713,8 @@ void DRLG_Init_Globals()
memset(dSpecial, 0, sizeof(dSpecial));
int8_t c = DisableLighting ? 0 : 15;
memset(dLight, c, sizeof(dLight));
DRLG_InitTrans();
DRLG_InitSetPC();
}
bool SkipThemeRoom(int x, int y)

3
Source/gendung.h

@ -324,7 +324,6 @@ void DRLG_MRectTrans(Rectangle area);
void DRLG_RectTrans(Rectangle area);
void DRLG_CopyTrans(int sx, int sy, int dx, int dy);
void DRLG_InitSetPC();
void DRLG_SetPC();
void Make_SetPC(Rectangle area);
/**
* @param tries Tiles to try, 1600 will scan the full map
@ -334,6 +333,8 @@ std::optional<Point> 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();
void SetSetPieceRoom(Point position, int floorId);
void FreeQuestSetPieces();
void DRLG_LPass3(int lv);
void DRLG_Init_Globals();
bool SkipThemeRoom(int x, int y);

1
Source/setmaps.cpp

@ -117,7 +117,6 @@ void LoadSetMap()
case SL_POISONWATER:
if (Quests[Q_PWATER]._qactive == QUEST_INIT)
Quests[Q_PWATER]._qactive = QUEST_ACTIVE;
LoadPreL3Dungeon("Levels\\L3Data\\Foulwatr.DUN");
LoadL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 31, 83);
LoadPalette("Levels\\L3Data\\L3pfoul.pal");
InitPWaterTriggers();

88
Source/town.cpp

@ -148,6 +148,46 @@ void TownCloseGrave()
SetDungeonMicros();
}
void InitTownPieces()
{
for (int y = 0; y < MAXDUNY; y++) {
for (int x = 0; x < MAXDUNX; x++) {
if (dPiece[x][y] == 360) {
dSpecial[x][y] = 1;
} else if (dPiece[x][y] == 358) {
dSpecial[x][y] = 2;
} else if (dPiece[x][y] == 129) {
dSpecial[x][y] = 6;
} else if (dPiece[x][y] == 130) {
dSpecial[x][y] = 7;
} else if (dPiece[x][y] == 128) {
dSpecial[x][y] = 8;
} else if (dPiece[x][y] == 117) {
dSpecial[x][y] = 9;
} else if (dPiece[x][y] == 157) {
dSpecial[x][y] = 10;
} else if (dPiece[x][y] == 158) {
dSpecial[x][y] = 11;
} else if (dPiece[x][y] == 156) {
dSpecial[x][y] = 12;
} else if (dPiece[x][y] == 162) {
dSpecial[x][y] = 13;
} else if (dPiece[x][y] == 160) {
dSpecial[x][y] = 14;
} else if (dPiece[x][y] == 214) {
dSpecial[x][y] = 15;
} else if (dPiece[x][y] == 212) {
dSpecial[x][y] = 16;
} else if (dPiece[x][y] == 217) {
dSpecial[x][y] = 17;
} else if (dPiece[x][y] == 216) {
dSpecial[x][y] = 18;
}
}
}
}
/**
* @brief Initialize all of the levels data
*/
@ -196,6 +236,8 @@ void DrlgTPass3()
} else {
FillTile(60, 70, 71);
}
InitTownPieces();
}
} // namespace
@ -284,8 +326,6 @@ void CreateTown(lvl_entry entry)
{
dminPosition = { 10, 10 };
dmaxPosition = { 84, 84 };
DRLG_InitTrans();
DRLG_Init_Globals();
if (entry == ENTRY_MAIN) { // New game
ViewPosition = { 75, 68 };
@ -310,50 +350,6 @@ void CreateTown(lvl_entry entry)
}
DrlgTPass3();
memset(dFlags, 0, sizeof(dFlags));
memset(dLight, 0, sizeof(dLight));
memset(dFlags, 0, sizeof(dFlags));
memset(dPlayer, 0, sizeof(dPlayer));
memset(dMonster, 0, sizeof(dMonster));
memset(dObject, 0, sizeof(dObject));
memset(dItem, 0, sizeof(dItem));
memset(dSpecial, 0, sizeof(dSpecial));
for (int y = 0; y < MAXDUNY; y++) {
for (int x = 0; x < MAXDUNX; x++) {
if (dPiece[x][y] == 360) {
dSpecial[x][y] = 1;
} else if (dPiece[x][y] == 358) {
dSpecial[x][y] = 2;
} else if (dPiece[x][y] == 129) {
dSpecial[x][y] = 6;
} else if (dPiece[x][y] == 130) {
dSpecial[x][y] = 7;
} else if (dPiece[x][y] == 128) {
dSpecial[x][y] = 8;
} else if (dPiece[x][y] == 117) {
dSpecial[x][y] = 9;
} else if (dPiece[x][y] == 157) {
dSpecial[x][y] = 10;
} else if (dPiece[x][y] == 158) {
dSpecial[x][y] = 11;
} else if (dPiece[x][y] == 156) {
dSpecial[x][y] = 12;
} else if (dPiece[x][y] == 162) {
dSpecial[x][y] = 13;
} else if (dPiece[x][y] == 160) {
dSpecial[x][y] = 14;
} else if (dPiece[x][y] == 214) {
dSpecial[x][y] = 15;
} else if (dPiece[x][y] == 212) {
dSpecial[x][y] = 16;
} else if (dPiece[x][y] == 217) {
dSpecial[x][y] = 17;
} else if (dPiece[x][y] == 216) {
dSpecial[x][y] = 18;
}
}
}
}
} // namespace devilution

Loading…
Cancel
Save