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.
12345678910111213141516171819202122232425262728293031323334353637383940// Validates the workforce Life-Expectancy / Education-Quotient computation (sim/workforce.hpp) byte-exact// against the saved bWorkforceLE (MISC 0x48) / dwWorkforceEQ (0x4C) on the bundled cities. Needs the game's// CITIES/ folder; skips cleanly otherwise.#include "sc2k/sim/workforce.hpp"#include "sc2k/io/sc2_file.hpp"#include "sc2k/render/asset_loader.hpp"#include <cstdio>#include <fstream>
using namespace sc2k;
#include "test_harness.hpp"#include "test_paths.hpp"
int main() { const std::string root = cities_dir(); if (!exists(root + "TOKYO.SC2")) { std::printf("workforce: SKIP (no CITIES/)\n"); return 0; } int n = 0; for (const char* nm : {"TOKYO", "LONDON", "NYC", "PARIS", "BAYVIEW", "BIGGESTC"}) { City c; if (!io::load_sc2(root + nm + std::string(".SC2"), c).ok) continue; ++n; const WorkforceStats w = compute_workforce(c); const int savedLE = c.misc_be32(sc2k::misc::kLifeExpectancy), savedEQ = c.misc_be32(sc2k::misc::kEducationQuotient); CHECK(w.life_expectancy == savedLE); CHECK(w.education_quotient == savedEQ); std::printf(" %-9s LE=%3d(saved %3d) EQ=%3d(saved %3d)\n", nm, w.life_expectancy, savedLE, w.education_quotient, savedEQ); } CHECK(n >= 3); if (failures == 0) std::printf("workforce: all checks passed (%d cities)\n", n); else std::printf("workforce: %d FAILED\n", failures); return failures ? 1 : 0;}