From 05631eca366d15edfd2e87a969f61b43a045d032 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 5 May 2021 11:18:47 +0200 Subject: [PATCH] :broom: Only load town TIL-file once --- Source/town.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/town.cpp b/Source/town.cpp index f464af83f..cbebd6c2f 100644 --- a/Source/town.cpp +++ b/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(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("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); } }