Files
Dreierpack-Manager/tests/modern_traffic_tests.cpp
ClaudeandClaude Opus 5.5 0046ab90d0 Modern: the traffic access has four stages
The Modern interface shows four stages for the traffic access, the original
has three. A Modern world (WorldLayout::traffic_stages = 4) keeps the
condition byte in steps of 64 (64, 128, 192, 255) and offers a build up to
stage 3; every stage weighs as one original stage. New careers convert the
original start table, older Modern saves are converted on load
(traffic_scale). Classic data keeps three stages; the Classic equivalence is
unchanged. Also: the live ticker takes the matches from the desk day on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:53:31 +01:00

49 lines
2.4 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// The traffic access stages (modern/game/traffic.hpp): the original's three in steps of 0x55,
// a Modern world's four in steps of 64, and the conversion of the original's scale.
#include <cstdio>
#include "game/world_layout.hpp"
#include "modern/game/traffic.hpp"
using namespace bmh;
using namespace bmh::modern;
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::fprintf(stderr, "FAIL: %s\n", what);
++failures;
}
}
} // namespace
int main() {
// Classic: 0 -> 85 -> 170 -> 255, a build is offered below 0xab
set_world_layout(classic_world_layout());
check(traffic_after_build(0) == 85 && traffic_after_build(85) == 170 && traffic_after_build(170) == 255, "classic builds");
check(traffic_buildable(170) && !traffic_buildable(255), "classic offer limit");
check(traffic_stage(85) == 1 && traffic_stage(170) == 2 && traffic_stage(255) == 3 && traffic_stage(84) == 1, "classic stages");
check(traffic_full_stages(255) == 3 && traffic_full_stages(169) == 1, "classic size steps");
check(traffic_from_original(170) == 170, "classic keeps its scale");
// a Modern world: 0 -> 64 -> 128 -> 192 -> 255, a build is offered below 193
WorldLayout modern = classic_world_layout();
modern.traffic_stages = 4;
set_world_layout(modern);
check(traffic_after_build(0) == 64 && traffic_after_build(64) == 128 && traffic_after_build(128) == 192 &&
traffic_after_build(192) == 255, "four builds");
check(traffic_buildable(192) && !traffic_buildable(255), "fourth stage offered, then no more");
check(traffic_stage(64) == 1 && traffic_stage(128) == 2 && traffic_stage(192) == 3 && traffic_stage(255) == 4, "four stages");
check(traffic_stage(63) == 1 && traffic_stage(191) == 3, "aged values keep their stage");
check(traffic_full_stages(255) == 4 && traffic_full_stages(192) == 3 && traffic_full_stages(191) == 2, "size steps");
check(traffic_stage_boundary(128) && !traffic_stage_boundary(127), "ageing message at a stage boundary");
check(traffic_from_original(85) == 64 && traffic_from_original(170) == 128 && traffic_from_original(255) == 192 &&
traffic_from_original(0) == 0 && traffic_from_original(150) == 128, "the original's stages in the new scale");
set_world_layout(classic_world_layout());
if (failures == 0) std::printf("modern traffic tests passed\n");
return failures == 0 ? 0 : 1;
}