Browse Source
1. Load assets from the bundle on Mac.
2. In timedemo_test, load MPQs before overriding pref path,
so that they can also be loaded from the user/system location.
3. Fix various double directory separators ("build//assets" etc).
pull/7594/head
5 changed files with 110 additions and 106 deletions
@ -1,95 +1,93 @@ |
|||||||
/**
|
/**
|
||||||
* @file drlg_test.hpp |
* @file drlg_test.hpp |
||||||
* |
* |
||||||
* Helpers for dungeon related tests. |
* Helpers for dungeon related tests. |
||||||
*/ |
*/ |
||||||
#pragma once |
#pragma once |
||||||
|
|
||||||
#include "engine/load_file.hpp" |
#include <gtest/gtest.h> |
||||||
#include "levels/themes.h" |
|
||||||
#include "multi.h" |
#include "engine/load_file.hpp" |
||||||
#include "player.h" |
#include "levels/themes.h" |
||||||
#include "quests.h" |
#include "multi.h" |
||||||
#include "utils/paths.h" |
#include "player.h" |
||||||
|
#include "quests.h" |
||||||
using namespace devilution; |
#include "utils/paths.h" |
||||||
|
|
||||||
int GetTileCount(dungeon_type levelType) |
using namespace devilution; |
||||||
{ |
|
||||||
switch (levelType) { |
int GetTileCount(dungeon_type levelType) |
||||||
case DTYPE_TOWN: |
{ |
||||||
return 376; |
switch (levelType) { |
||||||
case DTYPE_CATHEDRAL: |
case DTYPE_TOWN: |
||||||
return 206; |
return 376; |
||||||
case DTYPE_CATACOMBS: |
case DTYPE_CATHEDRAL: |
||||||
return 160; |
return 206; |
||||||
case DTYPE_CAVES: |
case DTYPE_CATACOMBS: |
||||||
return 206; |
return 160; |
||||||
case DTYPE_HELL: |
case DTYPE_CAVES: |
||||||
return 137; |
return 206; |
||||||
case DTYPE_NEST: |
case DTYPE_HELL: |
||||||
return 166; |
return 137; |
||||||
case DTYPE_CRYPT: |
case DTYPE_NEST: |
||||||
return 217; |
return 166; |
||||||
default: |
case DTYPE_CRYPT: |
||||||
app_fatal("Invalid level type"); |
return 217; |
||||||
} |
default: |
||||||
} |
app_fatal("Invalid level type"); |
||||||
|
} |
||||||
std::unique_ptr<uint16_t[]> DunData; |
} |
||||||
|
|
||||||
void LoadExpectedLevelData(const char *fixture) |
std::unique_ptr<uint16_t[]> DunData; |
||||||
{ |
|
||||||
std::string dunPath = "test/fixtures/"; |
void LoadExpectedLevelData(const char *fixture) |
||||||
|
{ |
||||||
paths::SetPrefPath(paths::BasePath()); |
// Set look up path to the location to load set pieces from later:
|
||||||
paths::SetAssetsPath(paths::BasePath() + "/" + dunPath); |
paths::SetPrefPath(paths::BasePath() + "test/fixtures/"); |
||||||
|
DunData = LoadFileInMem<uint16_t>(fixture); |
||||||
dunPath.append(fixture); |
ASSERT_NE(DunData, nullptr) << "Unable to load test fixture " << fixture; |
||||||
DunData = LoadFileInMem<uint16_t>(dunPath.c_str()); |
ASSERT_EQ(Size(DMAXX, DMAXY), Size(SDL_SwapLE16(DunData[0]), SDL_SwapLE16(DunData[1]))); |
||||||
ASSERT_NE(DunData, nullptr) << "Unable to load test fixture " << dunPath; |
} |
||||||
ASSERT_EQ(Size(DMAXX, DMAXY), Size(SDL_SwapLE16(DunData[0]), SDL_SwapLE16(DunData[1]))); |
|
||||||
} |
void TestInitGame(bool fullQuests = true, bool originalCathedral = true) |
||||||
|
{ |
||||||
void TestInitGame(bool fullQuests = true, bool originalCathedral = true) |
Players.resize(1); |
||||||
{ |
MyPlayer = &Players[0]; |
||||||
Players.resize(1); |
MyPlayer->pOriginalCathedral = originalCathedral; |
||||||
MyPlayer = &Players[0]; |
|
||||||
MyPlayer->pOriginalCathedral = originalCathedral; |
sgGameInitInfo.fullQuests = fullQuests ? 1 : 0; |
||||||
|
gbIsMultiplayer = !fullQuests; |
||||||
sgGameInitInfo.fullQuests = fullQuests ? 1 : 0; |
|
||||||
gbIsMultiplayer = !fullQuests; |
InitQuests(); |
||||||
|
} |
||||||
InitQuests(); |
|
||||||
} |
void TestCreateDungeon(int level, uint32_t seed, lvl_entry entry) |
||||||
|
{ |
||||||
void TestCreateDungeon(int level, uint32_t seed, lvl_entry entry) |
currlevel = level; |
||||||
{ |
leveltype = GetLevelType(level); |
||||||
currlevel = level; |
|
||||||
leveltype = GetLevelType(level); |
pMegaTiles = std::make_unique<MegaTile[]>(GetTileCount(leveltype)); |
||||||
|
|
||||||
pMegaTiles = std::make_unique<MegaTile[]>(GetTileCount(leveltype)); |
CreateDungeon(seed, entry); |
||||||
|
CreateThemeRooms(); |
||||||
CreateDungeon(seed, entry); |
|
||||||
CreateThemeRooms(); |
const uint16_t *tileLayer = &DunData[2]; |
||||||
|
|
||||||
const uint16_t *tileLayer = &DunData[2]; |
for (int y = 0; y < DMAXY; y++) { |
||||||
|
for (int x = 0; x < DMAXX; x++) { |
||||||
for (int y = 0; y < DMAXY; y++) { |
auto tileId = static_cast<uint8_t>(SDL_SwapLE16(*tileLayer)); |
||||||
for (int x = 0; x < DMAXX; x++) { |
tileLayer++; |
||||||
auto tileId = static_cast<uint8_t>(SDL_SwapLE16(*tileLayer)); |
ASSERT_EQ(dungeon[x][y], tileId) << "Tiles don't match at " << x << "x" << y; |
||||||
tileLayer++; |
} |
||||||
ASSERT_EQ(dungeon[x][y], tileId) << "Tiles don't match at " << x << "x" << y; |
} |
||||||
} |
|
||||||
} |
const uint16_t *transparentLayer = &DunData[2 + DMAXX * DMAXY * 13]; |
||||||
|
|
||||||
const uint16_t *transparentLayer = &DunData[2 + DMAXX * DMAXY * 13]; |
for (int y = 16; y < 16 + DMAXY * 2; y++) { |
||||||
|
for (int x = 16; x < 16 + DMAXX * 2; x++) { |
||||||
for (int y = 16; y < 16 + DMAXY * 2; y++) { |
auto sectorId = static_cast<uint8_t>(SDL_SwapLE16(*transparentLayer)); |
||||||
for (int x = 16; x < 16 + DMAXX * 2; x++) { |
transparentLayer++; |
||||||
auto sectorId = static_cast<uint8_t>(SDL_SwapLE16(*transparentLayer)); |
ASSERT_EQ(dTransVal[x][y], sectorId) << "Room/region indexes don't match at " << x << "x" << y; |
||||||
transparentLayer++; |
} |
||||||
ASSERT_EQ(dTransVal[x][y], sectorId) << "Room/region indexes don't match at " << x << "x" << y; |
} |
||||||
} |
} |
||||||
} |
|
||||||
} |
|
||||||
|
|||||||
Loading…
Reference in new issue