Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758// Load the extracted close sprite PNGs + master palette and check known-answer facts.// Skips (passes) cleanly if the game data isn't installed, so `make test` stays portable.#include "sc2k/render/asset_loader.hpp"#include <cstdio>
using namespace sc2k::render;
#include "test_harness.hpp"#include "test_paths.hpp"
int main() { const std::string adir = classic_assets_dir(); if (!have_render_assets()) { std::printf("sprite_bank: SKIP (no extracted assets under %s — run extract_assets.py)\n", adir.c_str()); return 0; }
const Assets a = load_assets();
// The extracted close bank holds ~500 sprites. CHECK(a.bank.size() > 400);
// Sprite 1256 is the first directory record: a 32x17 terrain tile (id 0x04E8, h=0x11, w=0x20). const Sprite* terrain = a.bank.get(1256); CHECK(terrain != nullptr); if (terrain) { CHECK(terrain->width == 32); CHECK(terrain->height == 17); // A real decoded tile has opaque pixels. std::size_t opaque = 0; for (auto m : terrain->mask) opaque += m; CHECK(opaque > 0); // Every opaque pixel's palette index resolves to an opaque colour. CHECK(a.palette[terrain->index[0]].a == 0xFF); }
// A representative low-density residential building sprite (XBLD ~0x71) should exist. int presentBuildings = 0; for (int code = 0x70; code <= 0x90; ++code) if (a.bank.get(1000 + code)) ++presentBuildings; CHECK(presentBuildings > 0);
// Palette: 256 entries, all opaque, not uniformly black (it really parsed colours). int nonBlack = 0; for (int i = 0; i < 256; ++i) { CHECK(a.palette[std::uint8_t(i)].a == 0xFF); if (a.palette[std::uint8_t(i)].r | a.palette[std::uint8_t(i)].g | a.palette[std::uint8_t(i)].b) ++nonBlack; } CHECK(nonBlack > 100);
if (failures == 0) { std::printf("sprite_bank: all checks passed (%zu sprites)\n", a.bank.size()); return 0; } std::printf("sprite_bank: %d failure(s)\n", failures); return 1;}