Crusader_Decomp/rebuild/remorse/tests/shape_archive_tests.cpp

34 lines
1.2 KiB
C++
Raw Permalink Normal View History

#include "remorse/file_system.h"
#include "remorse/shape_archive.h"
#include <cassert>
#include <filesystem>
int main()
{
const auto root = remorse::findGameDataRoot(std::filesystem::current_path());
assert(root.has_value());
const auto shapesPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "SHAPES.FLX");
assert(shapesPath.has_value());
const auto archive = remorse::loadShapeArchive(*shapesPath);
assert(archive.has_value());
bool decodedFrame = false;
for (remorse::u32 shape = 0; shape < archive->archive.entryCount; ++shape) {
const auto frame = remorse::decodeShapeFrame(*archive, shape, 0);
if (frame && !frame->pixels.empty()) {
assert(frame->frame.width > 0);
assert(frame->frame.height > 0);
const auto parsedFrames = remorse::loadShapeFrames(*archive, shape);
assert(parsedFrames && !parsedFrames->empty());
const auto decodedFromParsed = remorse::decodeShapeFrame(parsedFrames->front());
assert(decodedFromParsed && decodedFromParsed->pixels == frame->pixels);
decodedFrame = true;
break;
}
}
assert(decodedFrame);
return 0;
}