- Implemented collision tests to verify overlap and movement logic for collision bodies. - Enhanced entity dispatch entry tests to cover initialization, group ID management, and process handling. - Expanded file system tests to include crash diagnostics and ensure proper game data root detection. - Created isometric controls tests to validate movement requests and screen projection calculations. - Added map renderer tests to check fixed map loading and rendering functionality. - Introduced map sorter tests to confirm correct rendering order for various items.
55 lines
2.2 KiB
C++
55 lines
2.2 KiB
C++
#include "remorse/file_system.h"
|
|
#include "remorse/fixed_map.h"
|
|
#include "remorse/map_renderer.h"
|
|
|
|
#include <algorithm>
|
|
#include <cassert>
|
|
#include <filesystem>
|
|
|
|
int main()
|
|
{
|
|
const auto root = remorse::findGameDataRoot(std::filesystem::current_path());
|
|
assert(root.has_value());
|
|
|
|
remorse::MapRenderOptions options;
|
|
options.mapIndex = 1;
|
|
options.maxWidth = 320;
|
|
options.maxHeight = 200;
|
|
|
|
const auto image = remorse::renderMapPreview(*root, options);
|
|
assert(image.has_value());
|
|
assert(image->width > 0);
|
|
assert(image->height > 0);
|
|
assert(!image->pixels.empty());
|
|
assert(image->decodedItemCount > 0);
|
|
assert(image->paintedItemCount > 0);
|
|
|
|
const auto fixedPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "FIXED.DAT");
|
|
assert(fixedPath.has_value());
|
|
const auto archive = remorse::loadFixedMapArchive(*fixedPath);
|
|
assert(archive.has_value());
|
|
const auto fixedMap = remorse::loadFixedMap(*archive, options.mapIndex);
|
|
assert(fixedMap.has_value());
|
|
remorse::s32 minX = fixedMap->entries.front().x;
|
|
remorse::s32 minY = fixedMap->entries.front().y;
|
|
remorse::s32 maxX = minX;
|
|
remorse::s32 maxY = minY;
|
|
for (const remorse::FixedMapEntry& entry : fixedMap->entries) {
|
|
minX = std::min(minX, static_cast<remorse::s32>(entry.x));
|
|
minY = std::min(minY, static_cast<remorse::s32>(entry.y));
|
|
maxX = std::max(maxX, static_cast<remorse::s32>(entry.x));
|
|
maxY = std::max(maxY, static_cast<remorse::s32>(entry.y));
|
|
}
|
|
options.maxWidth = 1280;
|
|
options.maxHeight = 760;
|
|
options.viewCenter = remorse::WorldPoint{(minX + maxX) / 2, (minY + maxY) / 2, 0};
|
|
const auto centeredImage = remorse::renderMapPreview(*root, options);
|
|
assert(centeredImage.has_value());
|
|
assert(centeredImage->paintedItemCount > 0);
|
|
assert(centeredImage->width == options.maxWidth);
|
|
assert(centeredImage->height == options.maxHeight);
|
|
const remorse::ScreenPoint center = remorse::projectToScreen(*options.viewCenter);
|
|
assert(centeredImage->sourceLeft == center.x - static_cast<remorse::s32>(options.maxWidth / 2));
|
|
assert(centeredImage->sourceTop == center.y - static_cast<remorse::s32>(options.maxHeight / 2));
|
|
return 0;
|
|
}
|