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>
This commit is contained in:
1 parent
fda4b72967
commit
0046ab90d0
18 files changed
+154
-16
No files matched your search
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "modern/game/traffic.hpp"
|
||||
#include "modern/game/modern_state.hpp"
|
||||
#include "modern/game/environment.hpp"
|
||||
#include "modern/game/balance_plan.hpp"
|
||||
@@ -50,7 +51,7 @@ int32_t wrap(int64_t v) { return int32_t(uint32_t(uint64_t(v))); }
|
||||
// Add32: the level of a facility (facility 0: its size step)
|
||||
uint32_t facility_level(const ModernState& g, int m, int k) {
|
||||
const uint8_t v = rec8(g, m, size_t(k));
|
||||
return k == 0 ? uint32_t((v - 1) / 0x55 + 1) & 0xff : 1;
|
||||
return k == 0 ? uint32_t(traffic_stage(v)) & 0xff : 1; // the traffic access by its stage (traffic.hpp)
|
||||
}
|
||||
|
||||
// DailyInterest2(0): the interest of one day without booking it - negative is income
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "modern/game/traffic.hpp"
|
||||
#include "modern/game/modern_state.hpp"
|
||||
#include "modern/game/career.hpp"
|
||||
|
||||
@@ -446,7 +447,7 @@ void build_stadium(ModernState& g, const LeImage& exe, int m, int league, int mo
|
||||
const uint8_t level = mode == 1 ? 3 : exe.u8(::bmh::layout::Career_BuildStadium_RuntimeField + uint32_t(i + league * 0x17));
|
||||
if (i == 0x10 || i == 0x11 || level == 0) continue;
|
||||
if (i == 0) {
|
||||
rec[0] = uint8_t(exe.u8(::bmh::layout::Career_BuildStadium_RuntimeField + uint32_t(league * 0x17)) + (mode == 1 ? 0x55 : 0));
|
||||
rec[0] = traffic_from_original(uint8_t(exe.u8(::bmh::layout::Career_BuildStadium_RuntimeField + uint32_t(league * 0x17)) + (mode == 1 ? 0x55 : 0)));
|
||||
} else {
|
||||
rec[i] = uint8_t(rand.range(exe.u8(::bmh::layout::Career_BuildStadium_RuntimeField2 + uint32_t(i * 5)), exe.u8(::bmh::layout::Career_BuildStadium_RuntimeField3 + uint32_t(i * 5))) << 2);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "modern/game/traffic.hpp"
|
||||
#include "modern/game/modern_state.hpp"
|
||||
#include "modern/game/matchday_setup.hpp"
|
||||
#include "game/trace.hpp"
|
||||
@@ -108,7 +109,7 @@ int32_t catering_income(const ModernState& g, int manager, int32_t spectators, W
|
||||
for (int k = 0; k < 14; k++) {
|
||||
const uint8_t v = g.manager_records.at(rec + size_t(k));
|
||||
if (v == 0) continue;
|
||||
const uint32_t level = k == 0 ? uint32_t((v - 1) / 0x55 + 1) & 0xFF : 1; // Add32
|
||||
const uint32_t level = k == 0 ? uint32_t(traffic_stage(v)) & 0xFF : 1; // Add32 (traffic.hpp)
|
||||
sum += kPerVisitor[k] * uint32_t(spectators) * level / 100;
|
||||
}
|
||||
if (sum != 0) sum = uint32_t(rand.range(0x55, 0x73)) * sum / 100;
|
||||
@@ -724,7 +725,7 @@ int attendance(ModernState& g, int home, int away, int bits, int temperature, in
|
||||
for (int k = 0; k < 10; k++) {
|
||||
const int v = r8(size_t(k));
|
||||
// MatchdaySetupRuntimeField6[0] is overwritten with the step of the stadium size
|
||||
const int32_t step = k == 0 ? int32_t(v / 0x55 * 25000) : kStadiumSteps[k];
|
||||
const int32_t step = k == 0 ? int32_t(traffic_full_stages(v) * 25000) : kStadiumSteps[k];
|
||||
if (step < n && (v == 0 || k == 0)) n -= n / rand.range(10, 20);
|
||||
}
|
||||
const int wet = int(uint32_t(100 - covered) * uint32_t(uint8_t(rain)) * 8) / 100;
|
||||
|
||||
@@ -82,6 +82,9 @@ struct ModernState : GameState {
|
||||
std::string career_id;
|
||||
std::vector<std::string> manager_ids;
|
||||
uint32_t manager_serial = 0;
|
||||
// The scale of the traffic access bytes (traffic.hpp): 0 the original's (steps of 0x55), 64 the
|
||||
// four stages of a Modern world. Older Modern saves are converted when loaded.
|
||||
uint8_t traffic_scale = 0;
|
||||
// Players whose age the data set gives (birth date); the others carry a placeholder the
|
||||
// career start replaces as in the original. Needed only while a career starts (not saved).
|
||||
std::vector<bool> world_age_known;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "modern/game/traffic.hpp"
|
||||
#include "modern/game/modern_state.hpp"
|
||||
#include "modern/game/environment.hpp"
|
||||
#include "modern/game/month.hpp"
|
||||
@@ -531,7 +532,7 @@ int32_t monthly_income(ModernState& g, int m) {
|
||||
for (int k = 0; k < 6; k++) {
|
||||
const uint8_t v = r.at(rec + size_t(k));
|
||||
if (v == 0) continue;
|
||||
const int level = k == 0 ? ((v - 1) / 0x55 + 1) & 0xFF : 1; // Add32
|
||||
const int level = k == 0 ? traffic_stage(v) & 0xFF : 1; // Add32 (traffic.hpp)
|
||||
sum += level * kFacilityIncome[k];
|
||||
}
|
||||
add32(r, rec + 0x86c, sum);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// The traffic access (Verkehrsanbindung, stadium periphery object 0, manager record +0x00):
|
||||
// the only periphery object with stages. Its condition byte grows by one stage per finished
|
||||
// build and sinks with the stadium's ageing; a stage counts while the byte is above the stage
|
||||
// below it.
|
||||
//
|
||||
// The original has three stages in steps of 0x55 (85, 170, 255; a new build is offered below
|
||||
// 0xab). A Modern world has four, as the Modern interface shows them: steps of 64 (64, 128,
|
||||
// 192, 255; a build is offered below 193). Every stage weighs as much as one original stage
|
||||
// (income per visitor, monthly income, the attendance step). Classic data in the Modern core
|
||||
// keeps the original three (WorldLayout::traffic_stages).
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
||||
#include "game/world_layout.hpp"
|
||||
|
||||
namespace bmh::modern {
|
||||
|
||||
inline bool four_traffic_stages() { return world_layout().traffic_stages == 4; }
|
||||
inline int traffic_step() { return four_traffic_stages() ? 64 : 0x55; }
|
||||
|
||||
// The stage of a condition byte, 0 = none (the original's Add32 level).
|
||||
inline int traffic_stage(int v) { return v <= 0 ? 0 : (v - 1) / traffic_step() + 1; }
|
||||
|
||||
// The completed stages (MatchdaySetup's size step: the original's v / 0x55; 255 is stage 4).
|
||||
inline int traffic_full_stages(int v) {
|
||||
if (!four_traffic_stages()) return v / 0x55;
|
||||
return v >= 255 ? 4 : v / 64;
|
||||
}
|
||||
|
||||
// Whether the building firm offers another stage.
|
||||
inline bool traffic_buildable(int v) { return v < (four_traffic_stages() ? 3 * 64 + 1 : 0xab); }
|
||||
|
||||
// The condition byte after a finished build: the next full stage.
|
||||
inline uint8_t traffic_after_build(int v) {
|
||||
const int step = traffic_step();
|
||||
return uint8_t(std::min(255, (v == 0 ? 1 : (v - 1) / step + 2) * step));
|
||||
}
|
||||
|
||||
// The original's value of a stage boundary (the ageing message at each boundary).
|
||||
inline bool traffic_stage_boundary(int v) { return v % traffic_step() == 0; }
|
||||
|
||||
// A condition byte of the original's scale (start tables, older Modern saves) in this world's scale.
|
||||
inline uint8_t traffic_from_original(int v) {
|
||||
if (!four_traffic_stages() || v == 0) return uint8_t(v);
|
||||
return uint8_t(std::min(255, ((v - 1) / 0x55 + 1) * 64));
|
||||
}
|
||||
|
||||
} // namespace bmh::modern
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "modern/game/traffic.hpp"
|
||||
#include "modern/game/modern_state.hpp"
|
||||
#include "modern/game/weekly.hpp"
|
||||
#include "modern/game/club_player_detail.hpp"
|
||||
@@ -171,7 +172,7 @@ int facility_rating(ModernState& g, int manager, int* second, WatcomRandom* rand
|
||||
const uint8_t v = rec.b(size_t(i));
|
||||
if (v == 0) continue;
|
||||
int level;
|
||||
if (i < 0xe || i == 0x10 || i == 0x11) level = i == 0 ? (v - 1) / 0x55 + 1 : 1;
|
||||
if (i < 0xe || i == 0x10 || i == 0x11) level = i == 0 ? traffic_stage(v) : 1;
|
||||
else level = rec.b(size_t(i) + 0x2e) & 7;
|
||||
sum += (level & 0xFF) * kFacility[i * 5];
|
||||
}
|
||||
@@ -365,7 +366,7 @@ void facility_ageing(ModernState& g, int manager, GameRandom& game, WatcomRandom
|
||||
if (weeks == 0 && rec.b(size_t(i)) != 0 && rec.b(0x1e + size_t(i)) == 0) {
|
||||
uint8_t& v = rec.b(size_t(i));
|
||||
v--;
|
||||
if ((i == 0 && v % 0x55 == 0) || rec.b(0x1e + size_t(i)) + v == 0) {
|
||||
if ((i == 0 && traffic_stage_boundary(v)) || rec.b(0x1e + size_t(i)) + v == 0) {
|
||||
if (i < 0xe) {
|
||||
message = true;
|
||||
} else if (i < 0x16) {
|
||||
@@ -388,7 +389,7 @@ void facility_ageing(ModernState& g, int manager, GameRandom& game, WatcomRandom
|
||||
uint8_t& build = rec.b(0x1e + size_t(i));
|
||||
if (build != 0 && --build == 0) {
|
||||
uint8_t& v = rec.b(size_t(i));
|
||||
if (i == 0) v = uint8_t((v == 0 ? 1 : (v - 1) / 0x55 + 2) * 0x55);
|
||||
if (i == 0) v = traffic_after_build(v);
|
||||
else v = uint8_t(rand.range(kFacility[i * 5 + 2], kFacility[i * 5 + 3]) << 2);
|
||||
if (i > 0xd) {
|
||||
rec.b(0x2e + size_t(i)) = uint8_t((rec.b(0x2e + size_t(i)) >> 4) & 7);
|
||||
|
||||
Reference in new issue
Block a user