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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354// Verifies the simulation's master-clock calendar (verified derivation:// month = (clock/25)%12, year = startYear + clock/300, 25 ticks/month, 300/year).#include "sc2k/sim/simulation.hpp"#include "sc2k/io/sc2_file.hpp"#include <cstdio>#include <string>#include "test_paths.hpp"
#include "test_harness.hpp"
int main() { using namespace sc2k;
// Synthetic city: start year 1900, clock 0. City c; c.set_misc_be32(sc2k::misc::kStartYear, 1900); // start year 1900 // days (clock) = 0 Simulation sim(c);
CHECK(sim.year() == 1900); CHECK(sim.month() == 0); CHECK(sim.clock() == 0);
for (int i = 0; i < 25; ++i) sim.tick(); // one month CHECK(sim.clock() == 25); CHECK(sim.month() == 1); CHECK(sim.year() == 1900);
for (int i = 0; i < 25 * 11; ++i) sim.tick(); // to end of year 1 (clock 300) CHECK(sim.clock() == 300); CHECK(sim.year() == 1901); CHECK(sim.month() == 0);
// A real city's clock initialises from dwCityDays, and the calendar matches its stored date. { City rc; auto r = io::load_sc2((city_file("BAYVIEW.SC2")), rc); if (r.ok) { Simulation rs(rc); std::printf(" BAYVIEW: startYear=%d days=%d -> year=%d month=%d\n", rc.start_year(), rc.days(), rs.year(), rs.month()); CHECK(rs.year() >= rc.start_year()); CHECK(rs.month() >= 0 && rs.month() < 12); } }
if (failures == 0) { std::printf("calendar: all checks passed\n"); return 0; } std::printf("calendar: %d failure(s)\n", failures); return 1;}