Browse Source

🧹 Only load town TIL-file once

pull/1873/head
Anders Jenbo 5 years ago
parent
commit
05631eca36
  1. 35
      Source/town.cpp

35
Source/town.cpp

@ -17,12 +17,11 @@ namespace {
/**
* @brief Load level data into dPiece
* @param megas Map from mega tiles to macro tiles
* @param path Path of dun file
* @param xi upper left destination
* @param yy upper left destination
*/
void T_FillSector(MegaTile *megas, const char *path, int xi, int yy)
void T_FillSector(const char *path, int xi, int yy)
{
auto dunData = LoadFileInMem<uint16_t>(path);
@ -67,10 +66,12 @@ void T_FillSector(MegaTile *megas, const char *path, int xi, int yy)
*/
void T_FillTile(MegaTile *megas, int xx, int yy, int t)
{
dPiece[xx + 0][yy + 0] = SDL_SwapLE16(megas[t - 1].micro1) + 1;
dPiece[xx + 1][yy + 0] = SDL_SwapLE16(megas[t - 1].micro2) + 1;
dPiece[xx + 0][yy + 1] = SDL_SwapLE16(megas[t - 1].micro3) + 1;
dPiece[xx + 1][yy + 1] = SDL_SwapLE16(megas[t - 1].micro4) + 1;
MegaTile mega = pMegaTiles[t - 1];
dPiece[xx + 0][yy + 0] = SDL_SwapLE16(mega.micro1) + 1;
dPiece[xx + 1][yy + 0] = SDL_SwapLE16(mega.micro2) + 1;
dPiece[xx + 0][yy + 1] = SDL_SwapLE16(mega.micro3) + 1;
dPiece[xx + 1][yy + 1] = SDL_SwapLE16(mega.micro4) + 1;
}
/**
@ -161,24 +162,22 @@ void T_Pass3()
}
}
auto megaTiles = LoadFileInMem<MegaTile>("Levels\\TownData\\Town.TIL");
T_FillSector(megaTiles.get(), "Levels\\TownData\\Sector1s.DUN", 46, 46);
T_FillSector(megaTiles.get(), "Levels\\TownData\\Sector2s.DUN", 46, 0);
T_FillSector(megaTiles.get(), "Levels\\TownData\\Sector3s.DUN", 0, 46);
T_FillSector(megaTiles.get(), "Levels\\TownData\\Sector4s.DUN", 0, 0);
T_FillSector("Levels\\TownData\\Sector1s.DUN", 46, 46);
T_FillSector("Levels\\TownData\\Sector2s.DUN", 46, 0);
T_FillSector("Levels\\TownData\\Sector3s.DUN", 0, 46);
T_FillSector("Levels\\TownData\\Sector4s.DUN", 0, 0);
if (gbIsSpawn || !gbIsMultiplayer) {
if (gbIsSpawn || (!(plr[myplr].pTownWarps & 1) && (!gbIsHellfire || plr[myplr]._pLevel < 10))) {
T_FillTile(megaTiles.get(), 48, 20, 320);
T_FillTile(pMegaTiles.get(), 48, 20, 320);
}
if (gbIsSpawn || (!(plr[myplr].pTownWarps & 2) && (!gbIsHellfire || plr[myplr]._pLevel < 15))) {
T_FillTile(megaTiles.get(), 16, 68, 332);
T_FillTile(megaTiles.get(), 16, 70, 331);
T_FillTile(pMegaTiles.get(), 16, 68, 332);
T_FillTile(pMegaTiles.get(), 16, 70, 331);
}
if (gbIsSpawn || (!(plr[myplr].pTownWarps & 4) && (!gbIsHellfire || plr[myplr]._pLevel < 20))) {
for (x = 36; x < 46; x++) {
T_FillTile(megaTiles.get(), x, 78, GenerateRnd(4) + 1);
T_FillTile(pMegaTiles.get(), x, 78, GenerateRnd(4) + 1);
}
}
}
@ -196,9 +195,9 @@ void T_Pass3()
}
if (quests[Q_PWATER]._qactive != QUEST_DONE && quests[Q_PWATER]._qactive != QUEST_NOTAVAIL) {
T_FillTile(megaTiles.get(), 60, 70, 342);
T_FillTile(pMegaTiles.get(), 60, 70, 342);
} else {
T_FillTile(megaTiles.get(), 60, 70, 71);
T_FillTile(pMegaTiles.get(), 60, 70, 71);
}
}

Loading…
Cancel
Save