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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152// File → Load path KAT: assigning a freshly-loaded city into the in-place City + Simulation::reload()// swaps the world and re-inits the sim clock/budget (this is exactly what the Load City picker does on// selection). Verify numerically that the data actually changes. Skips without the cities.#include "sc2k/io/sc2_file.hpp"#include "sc2k/sim/simulation.hpp"#include "sc2k/render/asset_loader.hpp"#include <cstdio>#include <fstream>#include <string>
#include "test_harness.hpp"#include "test_paths.hpp"static long dev_buildings(const sc2k::City& c) { long n = 0; for (int i = 0; i < 128 * 128; ++i) if (c.xbld.cells[i] >= 0x6c) ++n; return n;}
int main() { using namespace sc2k; const std::string dir = cities_dir(); if (!exists(dir + "TOKYO.SC2") || !exists(dir + "LONDON.SC2")) { std::printf("load: SKIP (need TOKYO.SC2 + LONDON.SC2)\n"); return 0; } City city; CHECK(io::load_sc2(dir + "TOKYO.SC2", city).ok); Simulation sim(city); const long b0 = dev_buildings(city); const std::int32_t d0 = sim.clock();
// The Load action: load another city into a temp, assign in place, reload the sim. City loaded; CHECK(io::load_sc2(dir + "LONDON.SC2", loaded).ok); city = loaded; sim.reload(); const long b1 = dev_buildings(city);
CHECK(b1 != b0); // the world changed CHECK(sim.clock() != d0); // the clock re-seeded from the new city CHECK(sim.clock() == static_cast<std::int32_t>(city.days())); std::printf("load: TOKYO(%ld bldgs) -> LONDON(%ld bldgs), clock %d -> %d\n", b0, b1, d0, sim.clock());
if (failures == 0) { std::printf("load: all checks passed\n"); return 0; } std::printf("load: %d failure(s)\n", failures); return 1;}