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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061// One-bank sprite policy: extracted close art is authoritative; lower zoom ids are generated from it.#include "sc2k/render/asset_loader.hpp"#include <cstdio>
#include "test_harness.hpp"#include "test_paths.hpp"
int main() { using namespace sc2k::render;
// Pure replacement check: deriving must overwrite stale historical lower-bank records. SpriteBank synthetic; Sprite close; close.width = close.height = 4; close.mask.assign(16, 1); close.index.assign(16, 42); Sprite stale = close; stale.width = stale.height = 2; stale.mask.assign(4, 1); stale.index.assign(4, 7); synthetic.set(1200, close); synthetic.set(700, stale); synthetic.derive_lower_zoom_banks(); const Sprite* medium = synthetic.get(700); const Sprite* small = synthetic.get(200); CHECK(medium && medium->width == 2 && medium->height == 2 && medium->index[0] == 42); CHECK(small && small->width == 1 && small->height == 1 && small->index[0] == 42);
const std::string dir = classic_assets_dir(); if (!have_render_assets()) { std::printf("sprite_banks: derivation OK; SKIP real bank (need extracted sprites in %s)\n", dir.c_str()); return failures ? 1 : 0; }
SpriteBank bank; CHECK(add_loose_sprites(bank, dir + "/sprites") > 400); bank.derive_lower_zoom_banks(); int complete = 0; for (int id = 1001; id < 1500; ++id) { const Sprite* large = bank.get(id); if (!large) continue; const Sprite* med = bank.get(id - 500); const Sprite* far = bank.get(id - 1000); CHECK(med && far); if (med && far) { CHECK(med->width == (large->width + 1) / 2 && med->height == (large->height + 1) / 2); CHECK(far->width == (med->width + 1) / 2 && far->height == (med->height + 1) / 2); ++complete; } } CHECK(complete > 400); CHECK(bank.get(1073) && bank.get(573) && bank.get(73)); // all id ranges come from the close record
if (failures == 0) { std::printf("sprite_banks: %d close sprites supply all three id ranges\n", complete); return 0; } std::printf("sprite_banks: %d failure(s)\n", failures); return 1;}