Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
310e3e2464 | ||
|
|
4fb8b2f551 | ||
|
|
f1a31c9940 |
No files matched your search
+5
-6
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 0.1.1 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 0.1.2 LANGUAGES CXX C)
|
||||
# the one place of the version: --version of both programs and the window title (src/version.hpp)
|
||||
add_compile_definitions(OPENBMH_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
@@ -39,7 +39,7 @@ function(bmh_add_data_test)
|
||||
set(T_DATA_DIR "${BMH_DATA}")
|
||||
endif()
|
||||
set(reason "")
|
||||
set(external_text_tests season_transition_tests environment_tests cli_console_tests
|
||||
set(external_text_tests season_transition_tests cli_console_tests
|
||||
ui_desktop_tests ui_lineup_tests format_tests app_controller_tests bank_app_tests
|
||||
cli_soak ui_cup_draw_tests league_pairings_tests ui_pending_offer_tests
|
||||
reality_reporter_layout_tests season_cup_draw_app_tests
|
||||
@@ -62,7 +62,7 @@ function(bmh_add_data_test)
|
||||
message(FATAL_ERROR "Invalid game data directory for ${T_NAME}: ${T_DATA_DIR}")
|
||||
endif()
|
||||
foreach(option IN LISTS T_REQUIRED_OPTIONS)
|
||||
if(NOT "${${option}}" OR NOT EXISTS "${${option}}")
|
||||
if("${${option}}" STREQUAL "" OR NOT EXISTS "${${option}}")
|
||||
set(reason "External test input not supplied: ${option}")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -365,9 +365,7 @@ bmh_add_data_test(NAME reschedule_tests REQUIRED_OPTIONS BMH_TEST_RESCHEDULE_TES
|
||||
|
||||
add_executable(environment_tests tests/environment_tests.cpp)
|
||||
target_link_libraries(environment_tests PRIVATE bmhcore)
|
||||
set(BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 "" CACHE PATH "External input 1 for environment_tests; not distributed")
|
||||
bmh_add_data_test(NAME environment_tests REQUIRED_OPTIONS BMH_TEST_ENVIRONMENT_TESTS_INPUT_1 COMMAND environment_tests "${BMH_DATA}"
|
||||
"${BMH_TEST_ENVIRONMENT_TESTS_INPUT_1}")
|
||||
add_test(NAME environment_tests COMMAND environment_tests)
|
||||
|
||||
add_executable(youth_academy_tests tests/youth_academy_tests.cpp)
|
||||
target_link_libraries(youth_academy_tests PRIVATE bmhcore)
|
||||
@@ -482,6 +480,7 @@ if(MSVC)
|
||||
endif()
|
||||
bmh_add_data_test(NAME app_controller_tests COMMAND app_controller_tests "${BMH_DATA}")
|
||||
set(BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 "" CACHE PATH "External input 1 for app_delay_settings_tests; not distributed")
|
||||
bmh_add_data_test(NAME app_environment_tests COMMAND app_controller_tests "${BMH_DATA}" --environment-only)
|
||||
bmh_add_data_test(NAME app_delay_settings_tests REQUIRED_OPTIONS BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1 COMMAND app_controller_tests "${BMH_DATA}"
|
||||
--delay-settings-only "${BMH_TEST_APP_DELAY_SETTINGS_TESTS_INPUT_1}")
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Contributing to OpenBMH
|
||||
|
||||
Use [issues](https://github.com/rezmer/openbmh/issues) for reproducible bugs and proposals. For a bug, include the OpenBMH version, platform, game edition, expected behaviour and the smallest sequence of actions that shows the problem. Remove personal paths and account information from diagnostic text.
|
||||
Use [issues](https://github.com/Weyoune/openbmh/issues) for reproducible bugs and proposals. For a bug, include the OpenBMH version, platform, game edition, expected behaviour and the smallest sequence of actions that shows the problem. Remove personal paths and account information from diagnostic text.
|
||||
|
||||
Keep proprietary game files out of public submissions: no executables, databases, manuals, extracted text, artwork, recordings or saved games. Prefer synthetic inputs and a short description. If an investigation requires privately owned data, coordinate an appropriate process with the maintainers instead of attaching it publicly.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ This is an independent community project, with no affiliation with or endorsemen
|
||||
|
||||
## Get started
|
||||
|
||||
Check the [releases page](https://github.com/rezmer/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
Check the [releases page](https://github.com/Weyoune/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
|
||||
1. Have your own supported game installation available.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
@@ -33,12 +33,12 @@ Version 0.1 establishes the playable engine and development interfaces. Later mi
|
||||
|
||||
## Build from source
|
||||
|
||||
The following recipes target v0.1.1. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
The following recipes target v0.1.2. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
|
||||
Clone the public repository, then run the commands for your system:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/rezmer/openbmh.git
|
||||
git clone https://github.com/Weyoune/openbmh.git
|
||||
cd openbmh
|
||||
```
|
||||
|
||||
@@ -103,6 +103,6 @@ The implementation grew from study of file formats and behaviour of a legally ob
|
||||
|
||||
OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only**, SPDX **GPL-3.0-only**. [LICENSE](LICENSE) contains the unchanged GPLv3 text; the example wording in its appendix does not change this project's version choice. Game content has separate ownership and is not covered by this license.
|
||||
|
||||
Release source is identified by the matching version tag: [v0.1.1](https://github.com/rezmer/openbmh/tree/v0.1.1) for this version. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||
Release source is identified by the matching version tag: [v0.1.2](https://github.com/Weyoune/openbmh/tree/v0.1.2) for this version. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||
|
||||
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
||||
@@ -308,9 +308,10 @@ This index includes registered and reserved names. `ListOptions` and `Help` from
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowEnvironment` | – | staff levels and the youth academy |
|
||||
| `ShowEnvironment` | – | six monthly budgets and three youth tables |
|
||||
| `SetStaffLevel` | role:enum(AssistantCoach,Doctor,Physio), level:int(0..6) | click a staff tile: level 0..6, 5 000 a month each |
|
||||
| `SetYouthAcademy` | state:enum(On,Off) | start (July/August) or stop the youth academy |
|
||||
| `SetYouthLevel` | team:enum(Youngest,Academy,Oldest), level:int(0..6) | set a youth team’s monthly budget |
|
||||
| `SetYouthAcademy` | state:enum(On,Off) | compatibility alias: middle youth budget at level 6 or 0 |
|
||||
|
||||
### `Balance`
|
||||
|
||||
|
||||
@@ -11,3 +11,27 @@ OpenBMH aims to preserve the familiar game while handling malformed input and un
|
||||
Intentional changes in code should use the marker `OpenBMH deviates from the original:` and explain their purpose. Adding a new behaviour or balance change requires a concrete description and relevant tests; this page is not permission to substitute guessed rules.
|
||||
|
||||
The [generated differences catalogue](DIFFERENCES.md) lists these markers with links to their source files.
|
||||
|
||||
## Environment and presentation in 0.1.2
|
||||
|
||||
The desktop environment provides three youth teams and three staff
|
||||
budgets, each set to zero through six stars. Youth budgets are monthly, can be
|
||||
changed throughout the season, and contribute to the finance preview, balance
|
||||
plan and booked expenses. Youth tables develop on first-division matchdays;
|
||||
promotion, relegation and age-group handover occur at the season change.
|
||||
The two previously hidden youth groups are available across data editions.
|
||||
Staff prices and the shared academy player-generation strength bands stay in
|
||||
effect. Recruitment needs an active middle youth budget and an oldest youth team
|
||||
within 25 strength points of the senior squad (the full-build mode bypasses the
|
||||
strength gate). This deliberately
|
||||
combines the six-budget environment with OpenBMH's existing player-generation rules.
|
||||
|
||||
Old saved academy lump sums remain payable once and retain their paid status.
|
||||
They are not multiplied into twelve monthly payments. Editing that tile replaces
|
||||
the old amount with the selected monthly budget. There is no new save field.
|
||||
|
||||
Live match minutes use the loaded original delay setting (A9), including zero,
|
||||
instead of an added fixed pause. A9 and the existing scene delays can be adjusted
|
||||
in Settings; loaded saves and EIN files retain their chosen speeds. VGA retrace
|
||||
animations use a 70-Hz reference instead of the host monitor's refresh rate.
|
||||
`--live-frame-ms` and `BMH_LIVE_FRAME_MS` remain explicit diagnostic overrides.
|
||||
+3
-9
@@ -6,32 +6,26 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
||||
|
||||
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
||||
- [src/cli/console/windows_environment.cpp](../src/cli/console/windows_environment.cpp): uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
|
||||
- [src/formats/le.hpp](../src/formats/le.hpp): applies a shared supported rule profile when loading editions with different rule-table values.
|
||||
- [src/formats/rule_base.cpp](../src/formats/rule_base.cpp): normalizes live-scene defaults, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit across supported editions.
|
||||
- [src/formats/rule_base.hpp](../src/formats/rule_base.hpp): normalizes live-scene options, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit.
|
||||
- [src/game/balance_plan.cpp](../src/game/balance_plan.cpp): omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
|
||||
- [src/game/balance_plan.hpp](../src/game/balance_plan.hpp): uses the supported staff and youth-academy cost categories.
|
||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules.
|
||||
- [src/game/environment.hpp](../src/game/environment.hpp): enables the supported youth academy and represents staff levels in monthly increments of five thousand.
|
||||
- [src/game/environment.hpp](../src/game/environment.hpp): uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
|
||||
- [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image.
|
||||
- [src/game/lineup.cpp](../src/game/lineup.cpp): disables the foreign-player limit in the supported rule profile.
|
||||
- [src/game/lineup.hpp](../src/game/lineup.hpp): disables the foreign-player limit and supports owner-bound designated set-piece selection.
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/month.cpp](../src/game/month.cpp): omits the two discontinued youth-group cost categories from monthly accounts.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
|
||||
- [src/game/week.hpp](../src/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
|
||||
- [src/game/weekly.cpp](../src/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
|
||||
- [src/game/weekly.hpp](../src/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
|
||||
- [src/ui/advertising.cpp](../src/ui/advertising.cpp): uses the supported youth-academy cap and its saved cost fields.
|
||||
- [src/ui/environment.cpp](../src/ui/environment.cpp): omits the two discontinued youth groups from the environment screen.
|
||||
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
|
||||
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ Complete edition-specific loading, presentation, competitions and sound support.
|
||||
|
||||
## 0.2: open data and typed state
|
||||
|
||||
Introduce a documented import format and a native save format, retaining supported legacy import where practical. Replace fixed-layout state gradually with typed clubs, players, contracts and competitions. Keep each intermediate stage usable and cover transitions with tests.
|
||||
Introduce a documented import format and a native save format, retaining supported legacy import where practical. The format concept is [OBW](formats/OBW.md). Replace fixed-layout state gradually with typed clubs, players, contracts and competitions. Keep each intermediate stage usable and cover transitions with tests.
|
||||
|
||||
## 0.3: configurable rules
|
||||
|
||||
@@ -20,7 +20,7 @@ Expose rule values and balance choices as configuration, with reproducible simul
|
||||
|
||||
## 0.4: adaptable interfaces and competitions
|
||||
|
||||
Add a scalable interface through the shared application/protocol boundary. Make league sizes and competition structures data-driven. Define content-pack formats for independently licensed artwork, names and other resources; do not distribute third-party material without permission.
|
||||
Add a scalable interface (RmlUi) through the shared application/protocol boundary. Make league sizes and competition structures data-driven. Define content-pack formats for independently licensed artwork, names and other resources; do not distribute third-party material without permission.
|
||||
|
||||
## 0.5: independently distributable content
|
||||
|
||||
|
||||
@@ -1045,6 +1045,11 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Environment_FormatError_RuntimeField` | `0xa50f0` | German-compatible image / runtime field |
|
||||
| `Environment_FormatError_RuntimeField2` | `0xa50f6` | German-compatible image / runtime field |
|
||||
| `Environment_Render_TextPointer` | `0xaeb74` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthTeams` | `0xbd4bc` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthPositionSuffix` | `0xa1698` | German-compatible image / runtime field |
|
||||
| `EnvironmentCostSuffix` | `0xa169d` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthLeagueTextPointer` | `0xaeb78` | German-compatible image / runtime field |
|
||||
| `EnvironmentYouthColors` | `0xa50fc` | German-compatible image / runtime field |
|
||||
| `Environment_SetEnvironment_ExecutableField` | `0xaf394` | German-compatible image / runtime field |
|
||||
| `EuropeNameTable` | `0xae710` | German-compatible image / runtime field |
|
||||
| `EventPasses` | `0xa2ba1` | German-compatible image / runtime field |
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
# OBW: OpenBMH world, save and pack format (concept, format version 1.0)
|
||||
|
||||
Status: **concept** for roadmap 0.2 (open data and typed state) with preparation for 0.4 (scalable interface, content packs). Nothing here is implemented yet; the legacy formats in this directory remain authoritative for the current engine.
|
||||
|
||||
## 1. Goals and non-goals
|
||||
|
||||
Goals:
|
||||
|
||||
- One documented, versioned format for a game world (start database), a running career (save) and content packs.
|
||||
- A typed model of nations, clubs, players, staff, contracts, finances and competitions that no longer depends on the memory image of a particular executable.
|
||||
- Data-driven competitions: up to **32 leagues** (national and foreign leagues together), real-world European club cups (league phase plus knockout), and national-team competitions including qualification and a Nations-League-style tiered competition.
|
||||
- Import from the supported German editions and from Football Limited (FLTD), both for a new career and for an existing `.FBM` save.
|
||||
- Preparation for a high-resolution interface built with RmlUi: logical asset keys, high-resolution crests and icons, player photos, further languages and modern font formats.
|
||||
- Forward compatibility: readers of the same major version accept files written by later minor versions.
|
||||
|
||||
Non-goals of version 1.0:
|
||||
|
||||
- The match engine and its parameters (reserved namespace `x-matchengine`, see §3.3).
|
||||
- Network play, an editor application and a binary encoding (reserved, see §2.4).
|
||||
- Layout or screen data. Interfaces are themes (§9.6), not part of a world.
|
||||
|
||||
## 2. Container and files
|
||||
|
||||
### 2.1 Container
|
||||
|
||||
Every OBW file is a ZIP archive (deflate or stored) containing UTF-8 JSON documents. The project already links miniz (`bmh_miniz`) and has a JSON reader/writer (`src/cli/json.cpp`), so the format needs no new dependency. JSON keeps worlds diffable and editable by hand or by script.
|
||||
|
||||
| Extension | `kind` | Contents |
|
||||
|---|---|---|
|
||||
| `.obw` | `world` | Start database: everything needed to begin a career |
|
||||
| `.obs` | `save` | A world plus the running state of a career |
|
||||
| `.obp` | `pack` | Overlays and assets for worlds (names, crests, photos, texts) |
|
||||
| `.obt` | `theme` | Interface theme for the RmlUi client (§9.6) |
|
||||
|
||||
An unpacked directory with the same layout is accepted wherever an archive is, which keeps development and version control simple.
|
||||
|
||||
### 2.2 Layout
|
||||
|
||||
```
|
||||
manifest.json required, §3
|
||||
world/nations.json nations and their national teams
|
||||
world/clubs.json clubs (teams of type "club")
|
||||
world/players.json players
|
||||
world/staff.json managers, coaches, other staff
|
||||
world/stadiums.json stadiums
|
||||
world/contracts.json player and staff contracts
|
||||
world/finance.json club finances, sponsors, advertising, loans, shares
|
||||
world/competitions.json competition definitions, §6
|
||||
world/calendar.json season calendar, §7
|
||||
world/rules.json rule values (training camps, interest rates, ...)
|
||||
state/... save only, §5.9
|
||||
locale/<lang>/*.po texts, §9.3
|
||||
assets/... packs and themes only, §9
|
||||
x-<name>/... extensions, §3.3
|
||||
```
|
||||
|
||||
Every table file is an object `{"schema": "<table>@<major>.<minor>", "items": [...]}`. Tables with many rows (results, history, mail) may instead be stored as JSON Lines (`*.jsonl`, one item per line, first line the header object without `items`).
|
||||
|
||||
### 2.3 Encoding rules
|
||||
|
||||
- Text is UTF-8. Legacy single-byte text is converted on import (`iso646de_to_utf8`).
|
||||
- Money is an integer in the smallest unit of the world currency (`manifest.currency`, e.g. `{"code": "DEM", "minor_units": 0}`); no floating point for money.
|
||||
- Dates are ISO 8601 calendar dates (`"1995-07-01"`), in-game time is a date plus an optional `"minute"`.
|
||||
- Percentages and ratings are integers on the scale declared by their attribute set (§5.3).
|
||||
- Optional fields may be omitted; the schema gives their default.
|
||||
|
||||
### 2.4 Reserved
|
||||
|
||||
A compact binary encoding of large `state/` tables is reserved for a later minor version as an alternative representation of the same schema (`"encoding": "cbor"` in the table header). Readers of 1.0 reject unknown encodings with a clear error.
|
||||
|
||||
## 3. Versioning and migration
|
||||
|
||||
### 3.1 Manifest
|
||||
|
||||
```json
|
||||
{
|
||||
"format": "openbmh-world",
|
||||
"format_version": "1.0",
|
||||
"kind": "world",
|
||||
"min_reader": "1.0",
|
||||
"generator": "OpenBMH 0.2.0",
|
||||
"created": "2026-10-17",
|
||||
"title": {"default": "Season 1995/96"},
|
||||
"provenance": "import:bmh-de",
|
||||
"content_license": "local-import-only",
|
||||
"currency": {"code": "DEM", "minor_units": 0},
|
||||
"start_date": "1995-07-01",
|
||||
"languages": ["de"],
|
||||
"limits": {"leagues": 32},
|
||||
"requires": [],
|
||||
"extensions": []
|
||||
}
|
||||
```
|
||||
|
||||
- `format_version` is `major.minor`. A **minor** step only adds optional fields, tables, enum values that have a documented fallback, or new stage types guarded by `requires`. A **major** step may rename, remove or re-interpret fields.
|
||||
- `min_reader` is the lowest reader version that can use the file correctly (a writer raises it when it uses a minor feature without a safe fallback).
|
||||
- `requires` lists features without which the file cannot be played, e.g. `["stage:swiss"]`; a reader that lacks one refuses the file instead of guessing.
|
||||
- `provenance` records where the content came from: `native`, `import:bmh-de`, `import:bmh-de-classic`, `import:fltd`, or `pack:<id>`. `content_license` is free text or an SPDX identifier; `local-import-only` marks data converted from a user's own installation (§8.4).
|
||||
|
||||
### 3.2 Reading and migration
|
||||
|
||||
- Readers ignore unknown fields and tables, keep them in memory and write them back unchanged (round trip), so a newer minor version survives an older tool.
|
||||
- Missing optional fields take the schema default.
|
||||
- Older major versions are upgraded on load through a chain of migrations (`migrate_1_to_2`, `migrate_2_to_3`, ...). Writers always write the newest version; a migrated save is written under a new name unless the player confirms the upgrade.
|
||||
- Each table carries its own `schema` version, so a table can advance a minor step independently; the manifest version is the highest of them.
|
||||
|
||||
### 3.3 Extensions
|
||||
|
||||
Fields and directories whose name starts with `x-` belong to extensions (`x-matchengine`, `x-realnames`, `x-editor`). The core never interprets them, preserves them on round trip and lists active ones in `manifest.extensions` with a version, e.g. `{"id": "x-matchengine", "version": "1.0"}`.
|
||||
|
||||
### 3.4 Schemas
|
||||
|
||||
Each format version is published as JSON Schema (draft 2020-12) under `docs/formats/obw/schema/<major>.<minor>/`, one file per table. The schemas are the machine-readable specification and the basis of the validator (§10).
|
||||
|
||||
## 4. Identifiers and names
|
||||
|
||||
- Every entity has a stable string id `<type>:<key>`, e.g. `nation:de`, `club:0042`, `player:01873`, `comp:de-1`, `stadium:0042`. Keys are opaque: they never encode a real name, so a world and a pack can be published independently.
|
||||
- Ids are unique within a world and never reused within a save. The engine assigns runtime indices; files never store them.
|
||||
- Nation keys use ISO 3166-1 alpha-2 where one exists, otherwise a documented private key (`nation:x-eng` for England, `nation:x-sco`, ...).
|
||||
- Every displayed name is a localized string: `{"default": "...", "en": "...", "short": {"default": "..."}}`. `default` is required; a language entry overrides it; `short` and `abbr` are optional display variants for narrow layouts.
|
||||
- Packs overlay names, crests and photos by id (§9.5), never by position.
|
||||
|
||||
## 5. Entities
|
||||
|
||||
Field lists name the type and whether the field is required (R) or optional (O, with default). Only the main fields are listed; the schema is authoritative.
|
||||
|
||||
### 5.1 Nation (`world/nations.json`)
|
||||
|
||||
| Field | Type | | Meaning |
|
||||
|---|---|---|---|
|
||||
| `id` | string | R | `nation:<key>` |
|
||||
| `name` | localized | R | |
|
||||
| `confederation` | string | R | `uefa`, `conmebol`, `caf`, `afc`, `concacaf`, `ofc`, `other` |
|
||||
| `coefficient` | integer | O 0 | Club-competition ranking points (§6.6) |
|
||||
| `strength` | integer | O 0 | Rating of the national team when no squad is simulated |
|
||||
| `national_team` | string | O | Team id of type `national` (§5.2) |
|
||||
| `playable` | bool | O false | Whether its leagues are simulated in full |
|
||||
|
||||
### 5.2 Team (`world/clubs.json`)
|
||||
|
||||
Clubs and national teams share one entity type, distinguished by `type`.
|
||||
|
||||
| Field | Type | | Meaning |
|
||||
|---|---|---|---|
|
||||
| `id` | string | R | `club:<key>` or `nt:<nation key>` |
|
||||
| `type` | enum | R | `club`, `national`, `amateur` (newcomer pool), `foreign` (strength only) |
|
||||
| `name` | localized | R | |
|
||||
| `nation` | string | R | |
|
||||
| `stadium` | string | O | |
|
||||
| `colors` | array | O | 1 to 3 `#rrggbb` values, used for generated crests and kits |
|
||||
| `reputation`, `fans`, `strength` | integer | O | Club values on the attribute scale of the world |
|
||||
| `founded` | integer | O | Year |
|
||||
| `crest` | string | O | Asset key, default `asset:club/<key>/crest` (§9.1) |
|
||||
| `x-*` | any | O | Extensions |
|
||||
|
||||
Teams without a squad (`foreign`, or `national` in a world that does not simulate national squads) carry `strength` instead of players.
|
||||
|
||||
### 5.3 Player (`world/players.json`)
|
||||
|
||||
| Field | Type | | Meaning |
|
||||
|---|---|---|---|
|
||||
| `id` | string | R | |
|
||||
| `name` | object | R | `{"first": "...", "last": "...", "known_as": "..."}`, each a plain string; `known_as` optional |
|
||||
| `born` | date | R | Age is derived from the in-game date |
|
||||
| `nationalities` | array | R | Nation ids, first entry is the sporting nationality (national-team eligibility) |
|
||||
| `positions` | array | R | `gk`, `def`, `mid`, `fwd` in the classic set; finer positions in later attribute sets |
|
||||
| `foot` | enum | O | `left`, `right`, `both` |
|
||||
| `attribute_set` | string | O world default | e.g. `bmh-classic@1` |
|
||||
| `attributes` | object | R | Values named by the attribute set, e.g. `{"strength": 7, "technique": 5, "condition": 9, "form": 6}` |
|
||||
| `character` | object | O | Traits the attribute set defines |
|
||||
| `team` | string | O | Current team id; absent for free agents |
|
||||
| `squad_number` | integer | O | |
|
||||
| `status` | object | O | Injury, suspension and card counters per competition (save only) |
|
||||
| `photo` | string | O | Default `asset:player/<key>/photo` |
|
||||
|
||||
An attribute set is declared once in `world/rules.json` with its fields, scales and meaning, so a later, finer model can sit next to the classic one without breaking the format:
|
||||
|
||||
```json
|
||||
{"id": "bmh-classic@1", "fields": {
|
||||
"strength": {"min": 1, "max": 10},
|
||||
"technique": {"min": 1, "max": 10},
|
||||
"condition": {"min": 0, "max": 100},
|
||||
"form": {"min": 1, "max": 10}}}
|
||||
```
|
||||
|
||||
The exact list and scales of `bmh-classic@1` are fixed when the importer is written, from the fields the current engine uses (`Player` in `src/game/state.hpp`).
|
||||
|
||||
### 5.4 Staff and managers (`world/staff.json`)
|
||||
|
||||
Managers (human or computer), coaches and other employees: `id`, `name`, `born`, `nation`, `role` (`manager`, `coach`, `physio`, ...), `team`, `attributes`. In a save, `state/managers.json` adds the human manager profile: options, ratings, history, automation settings.
|
||||
|
||||
### 5.5 Contracts (`world/contracts.json`)
|
||||
|
||||
`id`, `person` (player or staff id), `team`, `start`, `end`, `salary` (money per season), `bonuses` (signing, per goal, ...), `release_clause` (O), `options` (O). One active contract per person and team; the history is kept in the save.
|
||||
|
||||
### 5.6 Stadiums (`world/stadiums.json`)
|
||||
|
||||
`id`, `name`, `capacity` split by area (`standing`, `seated`, `boxes`), `facilities` (floodlights, heating, scoreboard, ... as named levels), `pitch`, `owner` (team id or `null`).
|
||||
|
||||
### 5.7 Finance (`world/finance.json`)
|
||||
|
||||
Per team: balance, ticket prices, sponsors (shirt, boards, with duration and value), advertising, loans (amount, rate, due date), shares and other income or cost sources the engine models today. Rate tables such as the credit table live in `world/rules.json`.
|
||||
|
||||
### 5.8 Rules (`world/rules.json`)
|
||||
|
||||
Named rule values that are content of the world rather than of the engine: training-camp resorts (price, quality grades), credit-rate tables, attribute sets, points for a win, squad limits. Today these values are read from the executable of the selected edition; in OBW they are ordinary data (and the starting point of the configurable rules of roadmap 0.3).
|
||||
|
||||
### 5.9 Save state (`state/`, saves only)
|
||||
|
||||
| File | Contents |
|
||||
|---|---|
|
||||
| `state/career.json` | Current date, season, phase, active human managers, settings |
|
||||
| `state/rng.json` | State of the random generator(s) (`docs/RNG.md`), so a load continues deterministically |
|
||||
| `state/tables.json` | Standings per competition stage and group |
|
||||
| `state/results.jsonl` | Every played or scheduled match: competition, stage, round, home, away, result, after extra time / penalties |
|
||||
| `state/squads.json` | Lineups, formations, tactics per team |
|
||||
| `state/history.jsonl` | Season history: champions, cup winners, top scorers, records |
|
||||
| `state/mail.jsonl` | Messages and news |
|
||||
| `state/market.json` | Transfer list, open bids, loan offers |
|
||||
| `state/x-legacy.json` | Unmapped legacy values carried over by the importer (§8.3) |
|
||||
|
||||
## 6. Competitions
|
||||
|
||||
### 6.1 Model
|
||||
|
||||
A competition is an ordered list of **stages**. Each stage takes teams from **slots** (§6.4), plays a format and hands teams on (to the next stage, to another competition, or to a final ranking).
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "comp:de-2",
|
||||
"name": {"default": "2. Liga"},
|
||||
"type": "league",
|
||||
"nation": "nation:de",
|
||||
"tier": 2,
|
||||
"season_cycle": 1,
|
||||
"stages": [{
|
||||
"id": "regular",
|
||||
"format": "league",
|
||||
"teams": 18,
|
||||
"legs": 2,
|
||||
"points": {"win": 3, "draw": 1, "loss": 0},
|
||||
"tiebreakers": ["points", "goal_difference", "goals_for", "head_to_head", "draw_lots"],
|
||||
"matchdays": "calendar:league-weekends"
|
||||
}],
|
||||
"movement": [
|
||||
{"ranks": [1, 2], "to": "comp:de-1"},
|
||||
{"ranks": [3], "to": "comp:de-1/playoff", "role": "challenger"},
|
||||
{"ranks": [16, 18], "to": "comp:de-3"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`type` is `league` (counts towards the league limit), `cup` (national cup), `club_international`, `national_team`, `friendly` or `indoor`.
|
||||
|
||||
### 6.2 Stage formats
|
||||
|
||||
| Format | Purpose | Main parameters |
|
||||
|---|---|---|
|
||||
| `league` | Round robin | `teams`, `legs` (1, 2, n), `points`, `tiebreakers`, fixture generator |
|
||||
| `groups` | Several round robins | `groups`, `teams_per_group`, `legs`, seeding `pots`, draw constraints (e.g. no two teams of one nation) |
|
||||
| `swiss` | League phase with a fixed number of games against drawn opponents | `teams` (e.g. 36), `matches` (e.g. 8), `pots`, `home_away_balance`, one common table |
|
||||
| `knockout` | Ties | `legs` (1 or 2), `seeded`, `draw` (`open`, `seeded`, `bracket`), `extra_time`, `penalties`, `away_goals` (on/off), `neutral_venue`, `replay` (FA-Cup style) |
|
||||
| `playoff` | Ties between teams of different competitions (relegation, qualification) | as `knockout` plus the roles of the participants |
|
||||
| `final` | Single match or final tournament | `venue`, `teams` |
|
||||
|
||||
Common stage parameters: `extra_time` (minutes), `penalties`, `suspensions` (cards that lead to a ban, counted per competition or per stage), `substitutions`, `squad_registration` (size, home-grown quota), `prize_money` per round and result, `tv_money`, `gate_split`. New formats are added through a minor version with an entry in `manifest.requires`.
|
||||
|
||||
### 6.3 Fixture generation
|
||||
|
||||
A `league` or `groups` stage names a generator: `"generator": "round-robin"` (circle method, home/away balanced) works for every size. The legacy round tables of the original game remain available as `"generator": "legacy:<teams>"` for imported worlds, so imported careers keep their familiar order; they come from the user's installation, not from the format.
|
||||
|
||||
### 6.4 Slots and qualification
|
||||
|
||||
Participants are declared, not hard-coded:
|
||||
|
||||
```json
|
||||
"slots": [
|
||||
{"from": "comp:de-1", "ranks": [1, 4], "stage": "league-phase"},
|
||||
{"from": "comp:de-cup", "winner": true, "to": "comp:uel", "stage": "league-phase",
|
||||
"fallback": {"from": "comp:de-1", "next_unqualified": true}},
|
||||
{"from": "coefficient", "nation_rank": [1, 4], "places": 4},
|
||||
{"holder": "comp:ucl", "stage": "league-phase"}
|
||||
]
|
||||
```
|
||||
|
||||
A slot source is: a rank range of a stage, the winner/runner-up of a competition, the holder of a title, the next team not yet qualified (substitution rules), a coefficient ranking, or an explicit list. The engine resolves all slots at season end in the order given by `world/calendar.json`.
|
||||
|
||||
### 6.5 League pyramid
|
||||
|
||||
`movement` on a league connects tiers: promotion, relegation and playoffs between two leagues, several parallel lower leagues feeding one league (the two regional third divisions of the German editions), and a refill pool for the lowest tier (`"refill": {"from": "pool:amateur", "count": 2}`). This replaces the fixed per-edition tables in `src/game/schedule.hpp` (`kLeagueRelegation`, `kLeagueEurope`, `kGroupBelow`, `kNewcomerFirst`).
|
||||
|
||||
### 6.6 Coefficients
|
||||
|
||||
`world/rules.json` may define coefficient rankings (club and nation) with the points per result and per round reached and the number of seasons summed. They drive seeding pots and the number of European places per nation. A world may instead fix places per nation (`"places": {"nation:de": {"ucl": 4, "uel": 2}}`), which is how imported legacy worlds start.
|
||||
|
||||
### 6.7 Templates
|
||||
|
||||
The project ships competition templates under `docs/formats/obw/templates/`. They contain structure only, with neutral names:
|
||||
|
||||
- **Club competitions:** a champions cup with a 36-team league phase, a knockout playoff for places 9 to 24, round of 16 to final; a second and a third club cup in the same shape; a super cup; the knockout-only cups of the original game.
|
||||
- **National teams:** a world cup with continental qualification groups and playoffs, a continental championship with qualification, and a **tiered nations league**. The nations league has leagues A to D with groups of three or four, promotion and relegation between tiers, a final tournament for the group winners of A, and playoffs that can feed continental-championship places.
|
||||
- **National cups and side competitions:** knockout national cups (with or without replays and a qualifying round), an indoor tournament, friendlies.
|
||||
|
||||
### 6.8 National teams
|
||||
|
||||
A world that simulates national teams gives each `national` team a call-up rule: squad size, eligibility through `nationalities[0]`, selection by attribute set (best `n` by position) or by a human manager. International windows in the calendar (§7) suspend club play when the world asks for it (`"club_break": true`). Worlds without national squads use `strength` and simulate only results.
|
||||
|
||||
## 7. Calendar
|
||||
|
||||
`world/calendar.json` describes a season as dated events, independent of the executable's day table:
|
||||
|
||||
```json
|
||||
{
|
||||
"season_start": "07-01",
|
||||
"season_length_days": 365,
|
||||
"windows": [
|
||||
{"id": "summer-transfer", "type": "transfer", "from": "07-01", "to": "08-31"},
|
||||
{"id": "intl-sep", "type": "international", "from": "09-02", "to": "09-10", "club_break": true}
|
||||
],
|
||||
"series": [
|
||||
{"id": "league-weekends", "weekday": "sat", "from": "08-08", "to": "05-20", "skip": ["winter-break", "intl-*"]},
|
||||
{"id": "ucl-league-phase", "weekdays": ["tue", "wed"], "dates": ["09-16", "09-30"]}
|
||||
],
|
||||
"events": [
|
||||
{"date": "06-30", "action": "season_end"},
|
||||
{"date": "01-05", "action": "training_camp_window"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Dates are month-day within the season; the engine maps them to concrete days each year, including leap years and seasons whose first day falls on a different weekday (the cases fixed in the current calendar code). Stages refer to a series by id. Imported worlds receive a calendar generated from the edition's day table, so the familiar rhythm stays.
|
||||
|
||||
## 8. Import from BMH and Football Limited
|
||||
|
||||
### 8.1 Sources
|
||||
|
||||
The importer (planned module `src/import/`) reuses the existing loaders:
|
||||
|
||||
| Source | Loader | Result |
|
||||
|---|---|---|
|
||||
| Master database `M3D.MAN` / `M3E.MAN` | `src/formats/m3d.cpp` | Clubs, players, staff, stadiums |
|
||||
| Executable tables (league sizes, ladders, calendar, fixture tables, rule values) | `src/formats/le.cpp`, `src/launch/fltd.cpp`, `src/game/schedule.hpp` installers | Competitions, calendar, rules |
|
||||
| Text database `TEXTD.BLK` / `TEXTE.BLK` | `src/formats/textd.cpp` | Local language layer `de-original` / `en-original` |
|
||||
| Save `*.FBM` | `src/formats/fbm.cpp`, `savestate.cpp` | `state/` of a save |
|
||||
| Crests and pictures `*.VGA`, `WAPPEN.LBM` | `src/formats/vga.cpp` | Low-resolution fallback assets, local only |
|
||||
|
||||
Edition detection is the one the launcher already performs (`src/launch/game_data.cpp`).
|
||||
|
||||
### 8.2 Mapping per edition
|
||||
|
||||
Every edition has a mapping table in the importer (to be published with it as `docs/formats/obw/import.md`):
|
||||
|
||||
| Legacy league | German editions | Football Limited | OBW |
|
||||
|---|---|---|---|
|
||||
| 0 | 1st division, 18 teams | 1st division, 20 teams | `comp:<n>-1`, tier 1 |
|
||||
| 1 | 2nd division, 18 | 2nd division, 20 | tier 2 |
|
||||
| 2, 3 | Two parallel third divisions A and B, 18 each, one promotion group | 3rd and 4th division, 20 each | tier 3 (two leagues) / tiers 3 and 4 |
|
||||
| 4 | Fourth tier, 18 | Fifth league, 10 teams, not played | tier 4 / tier 5 with `"played": false` |
|
||||
| 5-8 | Four foreign leagues of 12 | Same four foreign leagues of 12 | `comp:<nation>-1` each, `nation.playable = true` |
|
||||
| Newcomer pool | 30 amateur clubs | 12 further named clubs | `pool:amateur` |
|
||||
|
||||
Cups, European cups, the indoor tournament, the English FA Cup with its qualifying stage and the League Cup become competitions with the same rules the engine applies today. Relegation places, European places and promotion groups are taken from the installed tables (`kLeagueRelegation`, `kLeagueEurope`, `kGroupBelow`), not re-typed by hand.
|
||||
|
||||
### 8.3 Fidelity
|
||||
|
||||
- A new career imported from an installation must produce the same first season in the engine as the legacy start (same fixtures, same participants), verified by the regression runs.
|
||||
- A converted `.FBM` must continue with the same results as the legacy save for a fixed number of turns.
|
||||
- Values the typed model does not yet understand go to `state/x-legacy.json` with their legacy name, so nothing is lost while the model grows area by area.
|
||||
|
||||
### 8.4 Rights
|
||||
|
||||
Imported content stays on the player's machine. The importer marks it `"provenance": "import:..."` and `"content_license": "local-import-only"`; tools refuse to bundle such a world into a distributable pack. Only worlds and packs with their own licence may be shared.
|
||||
|
||||
## 9. Assets, languages, fonts and the RmlUi interface
|
||||
|
||||
### 9.1 Asset keys
|
||||
|
||||
Data never refers to file paths. It uses logical keys:
|
||||
|
||||
| Key | Meaning |
|
||||
|---|---|
|
||||
| `asset:club/<key>/crest` | Club crest |
|
||||
| `asset:club/<key>/kit/home` | Kit |
|
||||
| `asset:player/<key>/photo` | Player photo |
|
||||
| `asset:staff/<key>/photo` | Staff photo |
|
||||
| `asset:comp/<key>/logo`, `asset:comp/<key>/trophy` | Competition logo and trophy |
|
||||
| `asset:nation/<key>/flag` | Flag |
|
||||
| `asset:stadium/<key>/image` | Stadium picture |
|
||||
| `asset:icon/<name>` | Interface icon |
|
||||
|
||||
### 9.2 Resolution and image formats
|
||||
|
||||
A resolver looks a key up in the active packs by priority (§9.5), then in the world, then falls back: original low-resolution graphics of the installation where one exists, a crest generated from `colors`, a silhouette for photos, a neutral icon.
|
||||
|
||||
- **Crests, logos, flags, icons:** SVG preferred (scales to every resolution). Otherwise PNG with alpha in size steps 64, 128, 256 and 512 px (`crest@128.png`). The resolver picks the smallest step not below the requested size.
|
||||
- **Photos:** PNG, JPEG or WebP, aspect 3:4, reference size 300×400 px, larger allowed. Faces centred; the interface crops, it never stretches.
|
||||
- **Pictures** (stadiums, backgrounds): PNG, JPEG or WebP, 16:9 reference 1920×1080.
|
||||
|
||||
Asset metadata sits next to the files in `assets/index.json`: key, files per size, author, source and licence (required).
|
||||
|
||||
### 9.3 Languages
|
||||
|
||||
- Interface texts use gettext `.po` files under `locale/<lang>/openbmh.po` (`msgctxt` for context, plural forms, mature translator tools such as Poedit and Weblate). Message ids are stable English keys.
|
||||
- Data names are localized strings inside the tables (§4); packs can add languages to them.
|
||||
- The original text databases are imported into a local layer `de-original` or `en-original`, which the classic interface uses. New interfaces use the project's own texts.
|
||||
- A fallback chain is configured by the player, e.g. `["en-GB", "en", "de"]`.
|
||||
- Text is shaped as Unicode (RmlUi supports it); no single-byte substitutions outside the legacy layer.
|
||||
|
||||
### 9.4 Fonts
|
||||
|
||||
- TrueType and OpenType (`.ttf`, `.otf`); RmlUi renders them through FreeType. Variable fonts are allowed.
|
||||
- A theme declares font families with weights, a fallback chain covering the languages it claims, and the licence of every font file (for example SIL OFL).
|
||||
- The original bitmap fonts stay for the classic interface only.
|
||||
|
||||
### 9.5 Content packs (`.obp`)
|
||||
|
||||
```json
|
||||
{
|
||||
"format": "openbmh-world",
|
||||
"format_version": "1.0",
|
||||
"kind": "pack",
|
||||
"id": "pack:example-crests",
|
||||
"title": {"default": "Example crests"},
|
||||
"targets": [{"world_provenance": "import:bmh-de"}],
|
||||
"priority": 100,
|
||||
"content_license": "CC-BY-4.0",
|
||||
"overlays": ["names", "assets", "locale"]
|
||||
}
|
||||
```
|
||||
|
||||
- A pack contains `overlay/<table>.json` files with partial entities by id (only the fields it changes), `assets/` and `locale/`.
|
||||
- Several packs stack; the higher `priority` wins per field and per asset key. A pack may not add or remove entities in 1.0 (that is a world, not a pack), which keeps saves valid when a pack is removed.
|
||||
- `targets` restricts a pack to worlds by provenance or world id.
|
||||
- The project distributes only the format, tools and its own or freely licensed material. Packs with real names, crests or photos are made and shared by their authors under their own responsibility. The team's internal real-name pack uses this format and stays private.
|
||||
|
||||
### 9.6 RmlUi themes (`.obt`)
|
||||
|
||||
- A theme contains `.rml` documents, `.rcss` style sheets, fonts, icons and its `locale/` texts, plus a manifest naming the client version it targets.
|
||||
- Interfaces bind to a **view model**, not to the world files. The client exposes data models (RmlUi data bindings) built from the application/protocol layer (`docs/protocol.md`), with ids and asset keys as values. RmlUi loads images through a file interface that resolves `asset:` keys (§9.2).
|
||||
- Neither worlds nor packs contain layout, so a theme works with every world, and the classic 320×200 interface keeps working next to it.
|
||||
|
||||
## 10. Validation and limits
|
||||
|
||||
The validator (planned `openbmh_cli --validate <file>`) checks, in this order:
|
||||
|
||||
1. Container, manifest, `format_version`, `min_reader`, `requires`.
|
||||
2. Every table against its JSON Schema.
|
||||
3. References: every id used exists and has the right type; no id is defined twice.
|
||||
4. Competition logic: slot counts match stage sizes; movements between tiers are balanced; every stage can be scheduled in the calendar; fixture generators exist for the sizes.
|
||||
5. Engine limits declared in `manifest.limits` and enforced by the engine of a version. For 1.0:
|
||||
|
||||
| Limit | Value |
|
||||
|---|---|
|
||||
| Competitions of type `league` (national and foreign) | **32** |
|
||||
| Teams per league | 4 to 24 |
|
||||
| Squad size per team | engine maximum of the attribute set |
|
||||
| Groups per stage | 16 |
|
||||
|
||||
The format itself has no fixed limits; a later engine raises them by changing `limits` and its own checks, without a format change.
|
||||
|
||||
Errors name the file, the JSON path and the rule (`clubs.json: items[41].stadium: unknown id stadium:0999`).
|
||||
|
||||
## 11. Implementation steps
|
||||
|
||||
| Step | Roadmap | Content |
|
||||
|---|---|---|
|
||||
| 1 | 0.2 | Schemas 1.0, reader/writer, validator, round-trip tests with synthetic worlds |
|
||||
| 2 | 0.2 | Importer for German editions and FLTD into `.obw`; adapter OBW → current `GameState`; regression: same first seasons |
|
||||
| 3 | 0.2 | `.FBM` → `.obs` conversion and native OBW saves; area by area the engine reads typed data instead of the memory image (clubs, players, contracts, finances, then competitions) |
|
||||
| 4 | 0.3 | `rules.json` drives the rule values; balance changes as data |
|
||||
| 5 | 0.4 | Generic competition engine (stage formats, slots, pyramid, variable league sizes up to the limits); templates for the real-world club cups and national-team competitions |
|
||||
| 6 | 0.4 | Asset resolver, packs, `.po` languages, RmlUi client with themes |
|
||||
| 7 | 0.5 | Own worlds that need no original data |
|
||||
|
||||
Each step keeps the game playable and the regression runs green; the legacy formats stay readable as import sources.
|
||||
@@ -19,6 +19,7 @@ Unless a page says otherwise, integer fields are little endian. Legacy strings u
|
||||
| Audio containers | `S/2000` through `S/2003` | [SOUND](SOUND.md) | `src/audio/container.cpp`, `original.cpp` |
|
||||
| Executable data | German LE and English X-32 images | [LE](LE.md), [executable layout](EXECUTABLE_LAYOUT.md) | `src/formats/le.cpp`, `src/launch/fltd.cpp` |
|
||||
| IFF crest template | `WAPPEN.LBM` | [WAPPEN](WAPPEN.md) | Not loaded by OpenBMH |
|
||||
| OpenBMH world, save and pack (concept) | `*.obw`, `*.obs`, `*.obp`, `*.obt` | [OBW](OBW.md) | Planned for 0.2 |
|
||||
|
||||
German and English editions can share a physical format while differing in text, league contents, executable layout and currency. Select the edition through the supplied installation; do not rename files or patch a save header to simulate another version. Original English V2.20 save import is a separate compatibility limitation from English installation support.
|
||||
|
||||
|
||||
@@ -1,21 +1,40 @@
|
||||
# OpenBMH v0.1.1
|
||||
# OpenBMH v0.1.2
|
||||
|
||||
OpenBMH reconstructs the Bundesliga Manager Hattrick engine in C++20. The graphical client uses SDL2; the console provides command batches and local manager-client transports over the same career session. This release needs a supported game installation supplied by the player. No original executable, artwork, music, text database, manual or saved game is included.
|
||||
|
||||
## Changes in 0.1.2
|
||||
|
||||
- The environment menu shows all six original artwork panels: three youth teams,
|
||||
assistant coach, doctor and physio. Youth panels include their league and rank.
|
||||
- All six monthly budgets can be set directly to zero through six stars. Youth
|
||||
development, season promotion/relegation, finance previews and monthly accounts
|
||||
share those values. Existing academy lump-sum saves retain their paid status.
|
||||
- Match-minute pacing follows the loaded original delay setting; A9 in Settings
|
||||
allows faster or slower progression. No fixed 250-ms pause is added. Retrace
|
||||
animations use the original reference rate on different host monitors.
|
||||
- External test fixtures are now recognised correctly by CMake instead of being
|
||||
reported as unavailable despite configured paths.
|
||||
|
||||
See [compatibility decisions](../../COMPATIBILITY.md) for youth recruitment and
|
||||
legacy contract handling. The previous UI corrections remain included.
|
||||
|
||||
## Changes in 0.1.1
|
||||
|
||||
- Live lineup navigation preserves the saved pitch view and allows repeated switches between the team list and pitch. Right-click can leave the dialog even when the pointer moves between press and release ([#1](https://github.com/rezmer/openbmh/issues/1)).
|
||||
- The instruction panel restores original control symbols, substitute information, red coverage on player hover and pitch-position hints ([#2](https://github.com/rezmer/openbmh/issues/2)).
|
||||
- Right-click cancels load/save dialogs, including settings and desktop-layout files ([#3](https://github.com/rezmer/openbmh/issues/3)).
|
||||
- Save filenames accept typing immediately, replace a selected existing name and support Ctrl+A/Cmd+A. This also applies to desktop layouts saved as MEN files ([#4](https://github.com/rezmer/openbmh/issues/4)).
|
||||
- Live lineup navigation preserves the saved pitch view and allows repeated switches between the team list and pitch. Right-click can leave the dialog even when the pointer moves between press and release ([#1](https://github.com/Weyoune/openbmh/issues/1)).
|
||||
- The instruction panel restores original control symbols, substitute information, red coverage on player hover and pitch-position hints ([#2](https://github.com/Weyoune/openbmh/issues/2)).
|
||||
- Right-click cancels load/save dialogs, including settings and desktop-layout files ([#3](https://github.com/Weyoune/openbmh/issues/3)).
|
||||
- Save filenames accept typing immediately, replace a selected existing name and support Ctrl+A/Cmd+A. This also applies to desktop layouts saved as MEN files ([#4](https://github.com/Weyoune/openbmh/issues/4)).
|
||||
|
||||
These corrections passed targeted UI/controller checks and Linux SDL input replays, including normal and Reality matches, substitutions, file writing and a fresh-process reload. Physical macOS window verification remains human QA. Use the new 0.1.1 packages to test these fixes; older 0.1.0 builds do not include them.
|
||||
These corrections passed targeted UI/controller checks and Linux SDL input replays, including normal and Reality matches, substitutions, file writing and a fresh-process reload. Physical macOS window verification remains human QA. Use packages from 0.1.1 or later to test these fixes; older 0.1.0 builds do not include them.
|
||||
|
||||
## Scope
|
||||
|
||||
The engine includes career management, leagues and cups, transfers and contracts, finances, training and camps, stadium management, live match interventions, audio playback and normal saves. Supported actions remain subject to mode, manager and phase restrictions; an unimplemented path reports an explicit error rather than an invented result. The project aims for recognisable behaviour and plausible results, not a promise that every original version produces identical events.
|
||||
|
||||
German game editions are the primary compatibility target. **Football Limited support is experimental.** English installation loading and edition-specific text/layout data are supported paths, while original V2.20 save import, English audio and remaining competition/interface differences have limitations. Check current issues before relying on a particular English workflow.
|
||||
German game editions are the primary compatibility target. **Football Limited support is experimental.** English installation loading and edition-specific text/layout data are supported paths, while original V2.20 save import, English audio and remaining competition/interface differences have limitations. A known limitation can reject an English save made after the first calendar
|
||||
advance: the saved turn cursor may no longer match the active calendar. Initial
|
||||
save/reload works; a complete English career is not yet verified. Check current
|
||||
issues before relying on a particular English workflow.
|
||||
|
||||
## Compatibility decisions
|
||||
|
||||
@@ -34,7 +53,7 @@ Version 0.1 ships binary packages for Windows x64, macOS on Apple silicon (arm64
|
||||
|
||||
## License
|
||||
|
||||
The matching application source tag is [v0.1.1](https://github.com/rezmer/openbmh/tree/v0.1.1). Source/build and relinking materials for linked components must also accompany or be offered with binary releases under their licenses.
|
||||
The matching application source tag is [v0.1.2](https://github.com/Weyoune/openbmh/tree/v0.1.2). Source/build and relinking materials for linked components must also accompany or be offered with binary releases under their licenses.
|
||||
|
||||
OpenBMH-owned code and documentation use GPL-3.0-only. Third-party components retain their licenses; the full texts accompany the package. Read [LICENSE](../../../LICENSE) and [THIRD_PARTY_NOTICES](../../../THIRD_PARTY_NOTICES.md). These licenses do not grant rights to original game content.
|
||||
|
||||
|
||||
@@ -4558,9 +4558,9 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
|
||||
const bool consumed = (request.column == 7 &&
|
||||
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
|
||||
(scoped_settings && request.row == 8))) ||
|
||||
// B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
|
||||
// A9 match minutes; B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
|
||||
// I9 cup draw; K9 Reality report; M9 preview/shootout; P9 shot.
|
||||
(request.column == 8 && ((request.row >= 1 && request.row <= 6) ||
|
||||
(request.column == 8 && ((request.row >= 0 && request.row <= 6) ||
|
||||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
|
||||
if (!consumed || old >= 200) {
|
||||
error = "Diese Einstellung ist noch nicht verfügbar.";
|
||||
|
||||
+6
-10
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||
//
|
||||
@@ -97,7 +98,7 @@ int main(int argc, char** argv) {
|
||||
fs::path data, save_directory;
|
||||
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
bool muted = false, music_enabled = true;
|
||||
int live_frame_ms = 10;
|
||||
int live_frame_ms = 0;
|
||||
bool live_frame_ms_explicit = false;
|
||||
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
|
||||
live_frame_ms = std::clamp(std::atoi(configured), 0, 1000);
|
||||
@@ -478,14 +479,8 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
};
|
||||
auto wait_source_retraces = [&](unsigned count) {
|
||||
// SDL has no VGA status-port equivalent. Approximate Source's
|
||||
// retrace waits with the active display's reported refresh period;
|
||||
// keep the previous frame visible and present the next frame once.
|
||||
SDL_DisplayMode mode{};
|
||||
const int display = SDL_GetWindowDisplayIndex(window);
|
||||
int refresh_hz = display >= 0 && SDL_GetCurrentDisplayMode(display, &mode) == 0
|
||||
? mode.refresh_rate : 0;
|
||||
if (refresh_hz <= 0) refresh_hz = 60; // explicit host fallback; not an Original VGA claim
|
||||
// Keep the VGA cadence on 60/120/144-Hz host displays alike.
|
||||
constexpr auto refresh_hz = ui::kOriginalRefreshHz;
|
||||
const Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||
const Uint64 ticks_per_wait = (frequency + Uint64(refresh_hz) - 1) / Uint64(refresh_hz);
|
||||
for (unsigned i = 0; running && i < count; ++i) {
|
||||
@@ -2158,7 +2153,8 @@ int main(int argc, char** argv) {
|
||||
live_frame_shown = true;
|
||||
}
|
||||
}
|
||||
const int frame_delay = live_frame_ms_explicit ? live_frame_ms : std::max(live_frame_ms, 250);
|
||||
const int frame_delay = live_frame_ms_explicit ? live_frame_ms :
|
||||
int(ui::live_delay_milliseconds(state.memory.u8(::bmh::layout::Main_FormatError_ExecutableField)));
|
||||
if (live_frame_shown && !live_skipped && frame_delay > 0)
|
||||
SDL_Delay(Uint32(frame_delay));
|
||||
},
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// OpenBMH deviates from the original: uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
|
||||
// The club environment (menu 24, docs/CLI_CONCEPT/06-verein.md 10, H2 p. 93, supported rule profile p. 107,
|
||||
// 111): co-trainer, doctor and physio in levels of 5 000 a month, and the supported rule profile youth
|
||||
// academy that costs a season price of the league.
|
||||
//
|
||||
// The rules are the engine's (src/game/environment.hpp, a port of Image with the
|
||||
// supported rule profile patch); a command is one click of the original screen.
|
||||
// The console and desktop share all six monthly environment budgets.
|
||||
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "cli/console/console.hpp"
|
||||
@@ -19,20 +13,21 @@ using namespace detail;
|
||||
void Console::register_environment_commands() {
|
||||
auto show = [this] {
|
||||
const EnvironmentState s = environment_state(session_->state(), active_slot());
|
||||
std::vector<std::vector<std::string>> rows = {
|
||||
{"AssistantCoach", std::to_string(s.level[kCoTrainer]), money(s.monthly[kCoTrainer])},
|
||||
{"Doctor", std::to_string(s.level[kDoctor]), money(s.monthly[kDoctor])},
|
||||
{"Physio", std::to_string(s.level[kPhysio]), money(s.monthly[kPhysio])},
|
||||
{"YouthAcademy", s.monthly[kYouthAcademy] != 0 ? "on" : "off", money(s.youth_price) + " per season"}};
|
||||
emit_table({"Item", "Level", "Costs"}, rows);
|
||||
emit('i', std::string("youth academy: ") + (s.youth_paid ? "paid this season" : s.youth_open ? "can be started (July/August)"
|
||||
: "too late for this season"));
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
constexpr const char* names[] = {"YouthYoungest", "YouthAcademy", "YouthOldest", "AssistantCoach", "Doctor", "Physio"};
|
||||
for (int i = 0; i < kEnvironmentItems; ++i)
|
||||
rows.push_back({names[i], std::to_string(s.level[size_t(i)]), money(s.monthly[size_t(i)])});
|
||||
emit_table({"Item", "Level", "MonthlyCosts"}, rows);
|
||||
rows.clear();
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
rows.push_back({names[i], std::to_string(s.youth_position[i] + 1), std::to_string(s.youth_league[i] + 1)});
|
||||
emit_table({"YouthTeam", "Position", "Division"}, rows);
|
||||
};
|
||||
openers_[24] = [this, show] {
|
||||
open_window("Environment");
|
||||
show();
|
||||
};
|
||||
add({"Environment", "ShowEnvironment", {}, "staff levels and the youth academy", false}, [show](const Values&) { show(); });
|
||||
add({"Environment", "ShowEnvironment", {}, "all six monthly budgets and youth tables", false}, [show](const Values&) { show(); });
|
||||
auto apply = [this, show](int item, int level) {
|
||||
std::string error;
|
||||
const auto r=app::EnvironmentActions(*session_).set_console(
|
||||
@@ -44,11 +39,14 @@ void Console::register_environment_commands() {
|
||||
add({"Environment", "SetStaffLevel", {choice("role", {"AssistantCoach", "Doctor", "Physio"}), integer("level", 0, 6)},
|
||||
"click a staff tile: level 0..6, 5 000 a month each", true},
|
||||
[apply](const Values& v) { apply(kCoTrainer + v.choice("role"), int(v.integer("level"))); });
|
||||
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "start (July/August) or stop the youth academy", true},
|
||||
add({"Environment", "SetYouthLevel", {choice("team", {"Youngest", "Academy", "Oldest"}), integer("level", 0, 6)},
|
||||
"set one youth team's monthly budget, level 0..6", true},
|
||||
[apply](const Values& v) { apply(v.choice("team"), int(v.integer("level"))); });
|
||||
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "set the middle youth budget to level 6 or 0", true},
|
||||
[this, apply](const Values& v) {
|
||||
const bool on = environment_state(session_->state(), active_slot()).monthly[kYouthAcademy] != 0;
|
||||
const bool want = v.choice("state") == 0;
|
||||
// the original's click on an active academy switches it off: click only for a change
|
||||
// Retain the old On/Off command as an alias for the middle youth budget.
|
||||
if (on == want) emit('+', std::string("youth academy already ") + (on ? "on" : "off"));
|
||||
else apply(kYouthAcademy, want ? 6 : 0);
|
||||
});
|
||||
|
||||
@@ -1026,6 +1026,11 @@ inline constexpr auto EnglishLeagueCupSemiFinalResults = 0x7d002;
|
||||
inline constexpr auto Environment_FormatError_RuntimeField = 0xa50f0;
|
||||
inline constexpr auto Environment_FormatError_RuntimeField2 = 0xa50f6;
|
||||
inline constexpr auto Environment_Render_TextPointer = 0xaeb74;
|
||||
inline constexpr auto EnvironmentYouthTeams = 0xbd4bc;
|
||||
inline constexpr auto EnvironmentYouthPositionSuffix = 0xa1698;
|
||||
inline constexpr auto EnvironmentCostSuffix = 0xa169d;
|
||||
inline constexpr auto EnvironmentYouthLeagueTextPointer = 0xaeb78;
|
||||
inline constexpr auto EnvironmentYouthColors = 0xa50fc;
|
||||
inline constexpr auto Environment_SetEnvironment_ExecutableField = 0xaf394;
|
||||
inline constexpr auto EuropeNameTable = 0xae710;
|
||||
inline constexpr auto EventPasses = 0xa2ba1;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/balance_plan.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -160,13 +161,6 @@ uint32_t catering_per_game(const GameState& g, int m, int32_t gate) {
|
||||
return sum;
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
|
||||
// TeamLeague3 (supported rule profile patch): the youth academy limit of the league
|
||||
int32_t youth_limit(const GameState& g, int m) {
|
||||
const int league = team_league(g.manager_teams.at(size_t(m)));
|
||||
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
}
|
||||
|
||||
// The redraw of BalanceFromGame2 (with its continuation Redraw and the patch at
|
||||
// Redraw2): recomputes the items if `refresh` asks for it, then the spectator income
|
||||
// and the totals.
|
||||
@@ -228,12 +222,12 @@ void redraw(const GameState& source, BalancePlanDraft& d) {
|
||||
r[4] = wrap(int64_t(r[4]) + int64_t(facility_income(g, m)) * months);
|
||||
const uint32_t catering = catering_per_game(g, m, r[kBalanceAverageGate]);
|
||||
r[4] = wrap(int64_t(r[4]) + int64_t((catering * uint32_t(home)) / 12) * months);
|
||||
// running costs Spending: the patch counts only the youth academy (index 1),
|
||||
// with the whole league limit while +0x880 is below it
|
||||
const uint32_t costs = ::bmh::layout::Spending + uint32_t(m) * 0x24;
|
||||
if (mem32(g, costs + 4) != 0 && int64_t(months) * mem32(g, costs + 4) != 0) {
|
||||
const int32_t limit = youth_limit(g, m);
|
||||
if (uint32_t(rec32(g, m, 0x880)) < uint32_t(limit)) r[9] = wrap(int64_t(r[9]) + limit);
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
const auto value = environment_monthly_cost(g, m, k);
|
||||
const auto raw = mem32(g, costs + uint32_t(k) * 4);
|
||||
const int count = k == kYouthAcademy && raw > kEnvironmentStep[k] * 6 ? 1 : months;
|
||||
r[9] = wrap(int64_t(r[9]) + int64_t(count) * value);
|
||||
}
|
||||
for (int k = 0; k < 3; k++) r[size_t(10 + k)] = wrap(int64_t(r[size_t(10 + k)]) + int64_t(months) * mem32(g, costs + 0xc + uint32_t(k) * 4));
|
||||
for (int k = 0; k < 2; k++) r[size_t(14 + k)] = wrap(int64_t(r[size_t(14 + k)]) + int64_t(months) * rec32(g, m, 0x854 + size_t(k) * 4));
|
||||
@@ -276,11 +270,7 @@ int32_t stadium_required_attendance(const GameState& source, int manager) {
|
||||
int32_t costs = wrap(int64_t(facility_costs(g, m)) + rec32(g, m, 0x854) + rec32(g, m, 0x858));
|
||||
costs = wrap(int64_t(costs) + monthly_pay(g, m, 0xa));
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
int32_t value = mem32(g, ::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4);
|
||||
if (k == 0 || k == 2) value = 0; // OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
|
||||
// supported rule profile MonthlyExpenses
|
||||
if (k == 1 && value != 0)
|
||||
value = uint32_t(rec32(g, m, 0x880)) < uint32_t(youth_limit(g, m)) ? youth_limit(g, m) : 0;
|
||||
const int32_t value = environment_monthly_cost(g, m, k);
|
||||
costs = wrap(int64_t(costs) + value);
|
||||
}
|
||||
costs = wrap(int64_t(costs) - shares_and_loans(g, m, 2, 0) + int(rec8(g, m, 0x179)) * 1000);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// OpenBMH deviates from the original: uses the supported staff and youth-academy cost categories.
|
||||
// All three youth budgets and staff costs share the monthly environment model.
|
||||
// The balance plan ("Bilanz", desk menu 28, mode III; H2 p. 26-27; BMH.exe V2.24 + supported rule profile
|
||||
// patch): the screen BalanceFromGame2 projects the club's income and expenses for the business
|
||||
// year and lets the manager change every item. When he leaves the screen the resulting
|
||||
|
||||
+97
-87
@@ -1,103 +1,113 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "game/messages.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/week.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr uint32_t kSpending = ::bmh::layout::Spending; // + manager * 0x24 + item * 4
|
||||
constexpr size_t kRecordSize = 0xb0c;
|
||||
constexpr size_t kYouthPaid = 0x880; // youth expenses booked this season
|
||||
// EnvironmentRuntimeField: the step of each item in thousands (items 3..5: 5 000 per level)
|
||||
constexpr int kUnit[kEnvironmentItems] = {2, 4, 5, 5, 5, 5};
|
||||
|
||||
uint32_t spending_at(int manager, int item) { return kSpending + uint32_t(manager) * 0x24 + uint32_t(item) * 4; }
|
||||
|
||||
// TeamLeague3: the academy's season price by the club's league
|
||||
int32_t youth_price(const GameState& g, int manager) {
|
||||
const int league = team_league(g.manager_teams.at(size_t(manager)));
|
||||
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
|
||||
uint32_t spending_at(int manager, int item) {
|
||||
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
|
||||
}
|
||||
|
||||
// YouthOpen: July (unless the Bundesliga is past its 17th round) or August
|
||||
bool youth_open(const GameState& g) {
|
||||
const int month = month_code(g.date);
|
||||
if (month == 7) return !(g.league_rounds.at(0) > 0x11);
|
||||
return month == 8;
|
||||
void validate_manager(const GameState& g, int manager) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
|
||||
!g.memory.has(youth_at(manager) + 8) || !g.memory.has(spending_at(manager, 5) + 3))
|
||||
throw FormatError("environment: invalid manager or truncated budgets");
|
||||
}
|
||||
|
||||
bool youth_paid(const GameState& g, int manager) {
|
||||
const size_t at = size_t(manager) * kRecordSize + kYouthPaid;
|
||||
const uint32_t paid = uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
return paid >= uint32_t(youth_price(g, manager));
|
||||
int direction(int value) { return (value > 0) - (value < 0); }
|
||||
int signed_clamp(int value, int low, int high) {
|
||||
return std::clamp(int(int8_t(uint8_t(value))), low, high);
|
||||
}
|
||||
bool legacy_academy(const GameState& g, int manager) {
|
||||
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
|
||||
return value == 1500000 || value == 1000000 || value == 580000 || value == 280000;
|
||||
}
|
||||
uint32_t academy_paid(const GameState& g, int manager) {
|
||||
const auto at = size_t(manager) * 0xb0c + 0x880;
|
||||
return uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
}
|
||||
}
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
const auto value = g.memory.u32(spending_at(manager, item));
|
||||
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
|
||||
return int32_t(value);
|
||||
}
|
||||
bool environment_academy_active(const GameState& g, int manager) {
|
||||
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
EnvironmentState s;
|
||||
for (int i = 0; i < kEnvironmentItems; i++) {
|
||||
s.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
|
||||
// the stars (SizeT7): staff value / step, the academy 6 when on, 0/2 none
|
||||
if (i >= 3) s.level[size_t(i)] = std::clamp(s.monthly[size_t(i)] / (kUnit[i] * 1000), 0, 6);
|
||||
else if (i == kYouthAcademy) s.level[size_t(i)] = s.monthly[size_t(i)] != 0 ? 6 : 0;
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
result.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
|
||||
result.level[size_t(i)] = std::clamp(result.monthly[size_t(i)] / kEnvironmentStep[size_t(i)], 0, 6);
|
||||
}
|
||||
s.youth_price = youth_price(g, manager);
|
||||
s.youth_paid = youth_paid(g, manager);
|
||||
s.youth_open = youth_open(g);
|
||||
return s;
|
||||
}
|
||||
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems || level < 0 ||
|
||||
level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
const uint32_t at = spending_at(manager, item);
|
||||
const int32_t before = int32_t(g.memory.u32(at));
|
||||
int32_t value = 0;
|
||||
EnvironmentResult result = EnvironmentResult::changed;
|
||||
if (item >= 3) {
|
||||
value = level * kUnit[item] * 1000;
|
||||
} else if (item == kYouthAcademy) {
|
||||
// YouthPrice: a click on an active academy means "off"
|
||||
int wanted = level;
|
||||
if (before != 0 && wanted != 0) wanted = 0;
|
||||
const int32_t price = youth_price(g, manager);
|
||||
if (!youth_paid(g, manager)) {
|
||||
if (wanted == 0) {
|
||||
value = 0;
|
||||
} else if (!youth_open(g)) {
|
||||
value = 0;
|
||||
result = EnvironmentResult::too_late;
|
||||
if (message) *message = message_text(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField); // "Zu spät für diese Saison..."
|
||||
} else {
|
||||
value = price;
|
||||
}
|
||||
} else {
|
||||
// paid this season: stays on; a click meant as "off" brings the second string of
|
||||
// the same text block (*Environment_SetEnvironment_ExecutableField + 0x42)
|
||||
value = price;
|
||||
if (wanted == 0) {
|
||||
result = EnvironmentResult::contract_runs;
|
||||
if (message) {
|
||||
*message = message_text_following(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField);
|
||||
// OpenBMH-authored notice when an edition has no academy tail text.
|
||||
if (message->empty()) *message = "This academy contract stays active until the season ends.";
|
||||
}
|
||||
}
|
||||
}
|
||||
for (uint32_t i = 0; i < 3; ++i) {
|
||||
result.youth_strength[i] = g.memory.u8(youth_at(manager) + i);
|
||||
result.youth_position[i] = g.memory.u8(youth_at(manager) + 3 + i);
|
||||
result.youth_league[i] = g.memory.u8(youth_at(manager) + 6 + i);
|
||||
if (result.youth_position[i] > 11 || result.youth_league[i] > 2)
|
||||
throw FormatError("environment: invalid youth table");
|
||||
}
|
||||
g.memory.set32(at, uint32_t(value));
|
||||
if (result == EnvironmentResult::changed && value == before) result = EnvironmentResult::unchanged;
|
||||
return result;
|
||||
}
|
||||
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (message) message->clear();
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
|
||||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
const auto at = spending_at(manager, item);
|
||||
const auto value = uint32_t(level * kEnvironmentStep[size_t(item)]);
|
||||
if (g.memory.u32(at) == value) return EnvironmentResult::unchanged;
|
||||
g.memory.set32(at, value);
|
||||
return EnvironmentResult::changed;
|
||||
}
|
||||
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand) {
|
||||
const auto observed = environment_state(g, manager);
|
||||
std::array<uint8_t, 44> movement{};
|
||||
uint8_t step = 4;
|
||||
for (auto& value : movement) {
|
||||
value = step;
|
||||
if (step != 0 && rand.range(0, 8) == 0) --step;
|
||||
}
|
||||
const auto round = g.league_rounds.at(0);
|
||||
if (round >= movement.size()) throw FormatError("environment: youth round outside season");
|
||||
constexpr int division_strength[] = {85, 70, 57};
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
int strength = observed.youth_strength[i];
|
||||
int position = observed.youth_position[i];
|
||||
const int opponent = uint8_t(division_strength[observed.youth_league[i]] - position);
|
||||
const int ratio = strength == 0 ? 100 :
|
||||
int((((int64_t(observed.monthly[i]) * 100 / ((1 << i) * 10000)) >> 1) + 40) * 100 / strength);
|
||||
int change = direction(ratio - 100);
|
||||
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
|
||||
if (std::abs(ratio - 100) <= rand.range(0, 30)) change = 0;
|
||||
if (rand.range(0, 2) == 0) strength = uint8_t(strength + change);
|
||||
strength = signed_clamp(strength, 10, 85);
|
||||
g.memory.set8(youth_at(manager) + uint32_t(i), uint8_t(strength));
|
||||
const int difference = strength - opponent;
|
||||
change = direction(difference);
|
||||
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
|
||||
if (rand.range(0, 3) != 0 && std::abs(difference) * 2 < rand.range(1, 18)) change = 0;
|
||||
position = signed_clamp(uint8_t(position - change * rand.range(1, movement[round])), 0, 11);
|
||||
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(position));
|
||||
}
|
||||
}
|
||||
void finish_youth_season(GameState& g, int manager) {
|
||||
const auto observed = environment_state(g, manager);
|
||||
for (int i = 2; i >= 0; --i) {
|
||||
auto division = observed.youth_league[size_t(i)];
|
||||
const int position = observed.youth_position[size_t(i)];
|
||||
int next_position = 5;
|
||||
if (position < 2 && division != 0) { --division; next_position = position + 10; }
|
||||
if (position > 10 && division < 2) { ++division; next_position = position - 10; }
|
||||
if (i != 0) g.memory.set8(youth_at(manager) + uint32_t(i),
|
||||
uint8_t((int(observed.youth_strength[size_t(i - 1)]) + observed.youth_strength[size_t(i)] * 2) / 3));
|
||||
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(next_position));
|
||||
g.memory.set8(youth_at(manager) + 6 + uint32_t(i), division);
|
||||
}
|
||||
}
|
||||
} // namespace bmh
|
||||
+17
-33
@@ -1,47 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// OpenBMH deviates from the original: enables the supported youth academy and represents staff levels in monthly increments of five thousand.
|
||||
// The club environment ("Umfeld", desk menu 24, H2 p. 93; supported rule profile manual p. 107, 111):
|
||||
// the screen Image with the supported rule profile patch (SizeT7 / EnvironmentOperation /
|
||||
// YouthPrice / YouthOpen). Six monthly running costs per manager live at
|
||||
// Spending + manager * 0x24 (u32 each); the month change books them
|
||||
// (month.cpp monthly_expenses) and the staff values steer training, injuries and healing.
|
||||
//
|
||||
// item 0, 2 the original's two other youth age groups: the patch always sets 0
|
||||
// item 1 the youth academy (supported rule profile): on or off. On it is the league's season price
|
||||
// (TeamLeague3: 1.5 M, 1 M, 580 000, 280 000), paid in full at the next month
|
||||
// change while record +0x880 (youth expenses this season) is below it. It can
|
||||
// be switched on in July and August only ("Zu spät für diese Saison...") and
|
||||
// not switched off once paid ("Der Vertrag läuft bis zum Saisonende.").
|
||||
// item 3..5 co-trainer, doctor, physio: level 0..6 times 5 000 a month (EnvironmentRuntimeField)
|
||||
//
|
||||
// A click on a tile sets the level from the mouse position (supported rule profile: one click per value).
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "game/random.hpp"
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthAcademy = 1, kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// OpenBMH deviates from the original: uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
|
||||
inline constexpr std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{}; // Spending values
|
||||
std::array<int, kEnvironmentItems> level{}; // the stars the screen draws (0..6)
|
||||
int32_t youth_price = 0; // the season price of the academy for the club's league
|
||||
bool youth_paid = false; // record +0x880 reached the price: cannot be switched off
|
||||
bool youth_open = false; // July/August: the academy can still be switched on
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
std::array<int, kEnvironmentItems> level{};
|
||||
std::array<uint8_t, 3> youth_strength{}, youth_position{}, youth_league{};
|
||||
};
|
||||
|
||||
EnvironmentState environment_state(const GameState& g, int manager);
|
||||
|
||||
enum class EnvironmentResult : uint8_t { changed, unchanged, too_late, contract_runs, invalid };
|
||||
|
||||
// A click on `item` at `level` (0..6; for the academy any level > 0 means "on" and a click on
|
||||
// an active academy switches it off). `message` gets the original's message box text, if any.
|
||||
// Preserve already saved lump-sum academy contracts until the user edits them.
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item);
|
||||
bool environment_academy_active(const GameState& g, int manager);
|
||||
enum class EnvironmentResult : uint8_t { changed, unchanged, invalid };
|
||||
// Set a monthly budget to level 0..6, without an immediate debit or random draw.
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message = nullptr);
|
||||
|
||||
// Youth results advance with first-division matchdays. Promotion/relegation and
|
||||
// the handover to the next age group happen before annual accounts.
|
||||
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand);
|
||||
void finish_youth_season(GameState& g, int manager);
|
||||
} // namespace bmh
|
||||
+2
-25
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/matchday.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -676,30 +677,6 @@ void manager_match_record(GameState& g, const MatchGroup& grp, int m, int home_g
|
||||
}
|
||||
|
||||
|
||||
// TicketPriceDraws: per human manager on a first league matchday. It once let the three
|
||||
// ticket prices drift; in this version its stores were turned into comparisons (CMP
|
||||
// instead of MOV), so only the random numbers remain.
|
||||
void ticket_price_draws(const GameState& g, int manager, WatcomRandom& rand) {
|
||||
uint8_t step[0x2c];
|
||||
int b = 4;
|
||||
for (int i = 0; i < 0x2c; i++) {
|
||||
step[i] = uint8_t(b);
|
||||
if (b != 0 && rand.range(0, 8) == 0) b--;
|
||||
}
|
||||
(void)g;
|
||||
(void)manager;
|
||||
const int round = g.league_rounds.empty() ? 0 : g.league_rounds[0];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// the direction terms depend on the prices, but only as values, not as draw counts
|
||||
if (rand.range(0, 4) == 0) rand.range(0, 2);
|
||||
rand.range(0, 30);
|
||||
rand.range(0, 2);
|
||||
if (rand.range(0, 4) == 0) rand.range(0, 2);
|
||||
if (rand.range(0, 3) != 0) rand.range(1, 18);
|
||||
rand.range(1, step[round < 0x2c ? round : 0x2b]);
|
||||
}
|
||||
}
|
||||
|
||||
// ManagerOf(manager, 0, value): the manager's position of this season.
|
||||
static void store_season_position(GameState& g, int manager, int value) {
|
||||
int season = std::min(g.season, 0x31);
|
||||
@@ -742,7 +719,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
|
||||
for (int league = kFirst[c]; league < kFirst[c] + kCount[c]; league++) {
|
||||
if (league == 0) {
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++) {
|
||||
ticket_price_draws(g, int(m), rand);
|
||||
advance_youth_teams(g, int(m), rand);
|
||||
const size_t rec = m * kManagerRecord;
|
||||
if (g.league_rounds.at(0) == 0x10) wr32(g.manager_records, rec + 0x320, rd32(g.manager_records, rec + 0x308));
|
||||
uint8_t& d = g.manager_records.at(rec + 0x220); // point deduction countdown
|
||||
|
||||
+3
-15
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/month.hpp"
|
||||
#include "game/trace.hpp"
|
||||
|
||||
@@ -482,11 +483,9 @@ void return_loans(GameState& g, WatcomRandom& rand, GameRandom* game, MinuteRepo
|
||||
}
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
|
||||
// OriginalFinancePreview(1): the month's expenses of a human manager: facility maintenance
|
||||
// (BMHExeXa), record +0x854/+0x858, the wages of the squad (MonthlyPay with flags
|
||||
// 14), the six running costs of Spending (the youth work capped per league by the
|
||||
// supported rule profile patch MonthlyExpenses, which also drops the youth groups 0 and 2) and the debt
|
||||
// 14), all six monthly environment budgets and the debt
|
||||
// service (+0x179 x 1000); each booked in the statistics.
|
||||
int32_t monthly_expenses(GameState& g, int m) {
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
@@ -514,18 +513,7 @@ int32_t monthly_expenses(GameState& g, int m) {
|
||||
}
|
||||
sum += wages;
|
||||
for (int k = 0; k < 6; k++) {
|
||||
int32_t v = int32_t(g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4));
|
||||
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
|
||||
// MonthlyExpenses (supported rule profile patch): the two other youth groups (items 0 and 2) cost
|
||||
// nothing any more, whatever the saved value
|
||||
if (k == 0 || k == 2) v = 0;
|
||||
if (k == 1 && v != 0) {
|
||||
// TeamLeague3: the limit of the league (1.5 M, 1 M, 580000, 280000); the full
|
||||
// limit is paid while +0x880 is below it, nothing after
|
||||
const int league = team_league(g.manager_teams.at(size_t(m)));
|
||||
const uint32_t limit = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
v = rd32(r, rec + 0x880) < limit ? int32_t(limit) : 0;
|
||||
}
|
||||
const int32_t v = environment_monthly_cost(g, m, k);
|
||||
if (k >= 3 && k <= 5) add32(r, rec + 0x878 + size_t(k) * 4, v);
|
||||
else add32(r, rec + 0x880, v);
|
||||
sum += v;
|
||||
|
||||
+15
-17
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/season.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -641,25 +642,21 @@ namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// YouthAcademyPlayer(manager) with the supported rule profile patch (SeasonOperation2, SeasonOperation3, SeasonOperation4,
|
||||
// SeasonOperation5): the youth academy's player at the season accounts. Only when the academy
|
||||
// was paid in full this season (record +0x880 reached the league's price, TeamLeague3) and
|
||||
// the squad has at most 22 players (SquadCount(team, 3)). A computer club's young player
|
||||
// moves to the club: the slots 0x86f..0 of the big clubs are searched downwards (squads of
|
||||
// human managers skipped) for a player not on loan whose age (years after 16) is at most
|
||||
// G(t, t + 3), t starting at 15 and lowered by one for every pass that finds none. He leaves
|
||||
// his club (ReleasePlayer), gets new values around a level of the club's league
|
||||
// (GeneratePlayer with 0x3000: G(79, 95) first division, G(69, 85) second, G(49, 68) third,
|
||||
// G(29, 48) below), a place in the squad with a fresh board entry (PendingOfferAnswer with the
|
||||
// player id | 0xf000), mood 0x69 and an age of W(0, 4) (16..20). Returns whether a player
|
||||
// came. The original's G(0, 0) before the search is kept.
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// The middle youth budget enables the existing enhanced academy recruitment.
|
||||
// Old lump-sum contracts remain eligible after their saved season payment.
|
||||
// Player search, strength bands, age and board setup retain the shared rules.
|
||||
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
|
||||
const int team = g.manager_teams.at(size_t(m));
|
||||
const int league = club_league(team);
|
||||
const uint32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
if (uint32_t(rec32(g, m, 0x880)) < price) return false;
|
||||
if (!environment_academy_active(g, m)) return false;
|
||||
if (squad_count(g, team, 3) > 0x16) return false;
|
||||
const auto budget = g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + kYouthAcademy * 4);
|
||||
if (budget <= uint32_t(kEnvironmentStep[kYouthAcademy] * 6) &&
|
||||
g.memory.u8(::bmh::layout::CareerDuration) != 1 &&
|
||||
int(g.memory.u8(::bmh::layout::EnvironmentYouthTeams + uint32_t(m) * 0x24 + 2)) <
|
||||
team_average(g, team, 0xf3).value - 25)
|
||||
return false;
|
||||
const SquadRange own = squad_range(team);
|
||||
if (game.range(0, 0) != 0) return false;
|
||||
for (int t = 0xf;; --t) {
|
||||
@@ -708,6 +705,7 @@ namespace {
|
||||
void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
|
||||
const SeasonTaxHooks& tax_hooks, SeasonTaxState& tax_state) {
|
||||
for (size_t i = 0; i < 0xc; i++) rec8(g, m, 0x754 + i) = 0;
|
||||
finish_youth_season(g, m);
|
||||
if (!g.memory.has(::bmh::layout::Season_SeasonAccounts_RuntimeField)) g.memory.add_block(::bmh::layout::Season_SeasonAccounts_RuntimeField, 4); // (runtime only, not saved)
|
||||
g.memory.set8(::bmh::layout::Season_SeasonAccounts_RuntimeField + uint32_t(m), 0);
|
||||
season_event(g, m, game, rand, report);
|
||||
@@ -720,8 +718,8 @@ void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand,
|
||||
const SquadRange range = squad_range(team);
|
||||
for (size_t s = 0; s < 24; s++)
|
||||
if (g.squad_slots.at(range.first + s) != 0x0FFF) season_bonus(g, m, int(s), uint8_t(pos), true);
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// YouthAcademyPlayer: the youth academy's player (supported rule profile), posted as Season_SeasonAccounts_TextPointer
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// Academy recruitment is posted after the youth season has settled.
|
||||
if (youth_academy_player(g, m, game, rand, report)) post_text(g, m, text_id(::bmh::layout::Season_SeasonAccounts_TextPointer));
|
||||
if (report.unsupported) return;
|
||||
if (league == 0 && pos < 100) rec8(g, m, 0x21c) = 1; // the best human club of the first division
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#pragma once
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// From one season to the next (BMH.exe V2.24 + supported rule profile patch).
|
||||
//
|
||||
// On 1 July the "Weiter" loop (DailyInterest) ends the season: CareerSession_RuntimeError_RuntimeField4 = 1, the season
|
||||
@@ -94,10 +94,10 @@ void answer_offers(GameState& g, int manager, bool accept, WatcomRandom& rand, M
|
||||
// offer slots (transfer list entries 0x28..0x2b, OfferSlots) are freed.
|
||||
void free_offer_slots(GameState& g);
|
||||
|
||||
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
|
||||
// YouthAcademyPlayer (supported rule profile youth academy, season accounts): when manager `m` paid the academy in
|
||||
// full this season (+0x880) and has room, a young player of a computer club joins his squad
|
||||
// with values by the league (see season.cpp). Returns whether one came.
|
||||
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
// Annual recruitment with an active middle youth budget (or a paid legacy
|
||||
// academy contract), provided the squad has room. Shared player strength bands
|
||||
// remain in effect; see season.cpp.
|
||||
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
// ClubBalance(0): every club's mood (TeamMorale, W(20, 30)) and flags (*TeamFlags): a random
|
||||
|
||||
+4
-14
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "ui/advertising.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
@@ -182,10 +183,9 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
|
||||
std::array<int, 13>{0,31,28,31,30,31,30,31,31,30,31,30,31}[size_t(month)];
|
||||
income = wrap_add(income, wrap_neg(wrap_mul(original_finance_adjustment(game, manager), month_factor)));
|
||||
|
||||
// OpenBMH deviates from the original: uses the supported youth-academy cap and its saved cost fields.
|
||||
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
|
||||
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
|
||||
// MonthlyPay flags 0x0a (salary+bonus without statistic writes), and six
|
||||
// saved supported rule profile cost words. The cap for index 1 comes from TeamLeague3.
|
||||
// saved monthly environment budgets.
|
||||
int32_t expenses = 0;
|
||||
for (int i = 0; i < 14; ++i) expenses = wrap_add(expenses, kFacilityCost[size_t(i)]);
|
||||
for (int i = 14; i < 22; ++i)
|
||||
@@ -202,18 +202,8 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
|
||||
expenses = wrap_add(expenses, signed32(u32(game.tactics, board + 0x50)));
|
||||
expenses = wrap_add(expenses, int32_t(bonus));
|
||||
}
|
||||
const int team = int(u32(game.manager_records, rec + 0x290) & 0xffff);
|
||||
const int league = team > 0x164 ? 0 : team_league(team); // TeamLeague2
|
||||
const int32_t youth_cap = league == 0 ? 1500000 : league == 1 ? 1000000 :
|
||||
league <= 3 ? 580000 : 280000;
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
int32_t item = mem_i32(game, ::bmh::layout::Spending + uint32_t(manager) * 0x24 + uint32_t(k) * 4);
|
||||
if (k == 0 || k == 2) {
|
||||
// MonthlyExpenses clears these indexes unconditionally (CMP AX,3 / CMP AX,1).
|
||||
item = 0;
|
||||
} else if (k == 1 && item != 0) {
|
||||
item = u32(game.manager_records, rec + 0x880) < uint32_t(youth_cap) ? youth_cap : 0;
|
||||
}
|
||||
const int32_t item = environment_monthly_cost(game, manager, k);
|
||||
expenses = wrap_add(expenses, item);
|
||||
}
|
||||
expenses = wrap_add(expenses, wrap_neg(original_share_adjustment(game, manager, false)));
|
||||
|
||||
@@ -167,17 +167,17 @@ int main(int argc, char** argv) {
|
||||
cap_fixture.memory.set32(::bmh::layout::Spending + 4, 99);
|
||||
cap_fixture.memory.set32(::bmh::layout::Spending, 111);
|
||||
cap_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
||||
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 1543400,
|
||||
"costs 0/2 stay zero while the youth-cost item uses the source league cap");
|
||||
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 43832,
|
||||
"all three youth budgets enter the monthly finance preview");
|
||||
put32(cap_fixture.manager_records, 0x880, 1500000);
|
||||
const auto no_cap_preview = advertising_from_game(cap_fixture, 0).finance_preview;
|
||||
check(no_cap_preview.expenses == 43400,
|
||||
"the youth-cost item is suppressed once funds reach the strict source threshold");
|
||||
check(no_cap_preview.expenses == 43832,
|
||||
"ordinary monthly youth budgets continue after the former academy threshold");
|
||||
GameState ignored_cost_fixture = finance_fixture;
|
||||
ignored_cost_fixture.memory.set32(::bmh::layout::Spending, 111);
|
||||
ignored_cost_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
|
||||
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43400,
|
||||
"legacy routine clears cost items zero and two regardless of their saved values");
|
||||
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43733,
|
||||
"the youngest and oldest youth budgets both enter expenses");
|
||||
GameState loan_fixture = finance_fixture;
|
||||
loan_fixture.memory.set32(::bmh::layout::Loans + 8, 100);
|
||||
const auto loan_preview = advertising_from_game(loan_fixture, 0).finance_preview;
|
||||
|
||||
+24
-13
@@ -72,6 +72,11 @@ EnvironmentView environment_from_game(const bmh::GameState& game, uint64_t revis
|
||||
view.values = bmh::environment_state(game, manager);
|
||||
for (int i = 0; i < kEnvironmentItems; ++i)
|
||||
view.cost_text[size_t(i)] = bmh::format_number(game, view.values.monthly[size_t(i)], 0x185);
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
view.youth_position_text[i] = format_number(game, view.values.youth_position[i] + 1, 0x81);
|
||||
view.youth_league_text[i] = format_number(game, view.values.youth_league[i] + 1, 2) +
|
||||
message_text(game, ::bmh::layout::EnvironmentYouthLeagueTextPointer);
|
||||
}
|
||||
view.decorated_background = !game.memory.has(::bmh::layout::PlainBackground) || game.memory.u8(::bmh::layout::PlainBackground) == 0;
|
||||
view.gradient_text = (!game.memory.has(::bmh::layout::TextGradientDisabled) || game.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
|
||||
view.solid_panel_background = game.memory.has(::bmh::layout::SolidPanelBackground) && game.memory.u8(::bmh::layout::SolidPanelBackground) != 0;
|
||||
@@ -117,9 +122,14 @@ std::string environment_view_json(const EnvironmentView& s) {
|
||||
for (size_t i = 0; i < s.values.monthly.size(); ++i) { if (i) out << ','; out << s.values.monthly[i]; }
|
||||
out << "],\"level\":[";
|
||||
for (size_t i = 0; i < s.values.level.size(); ++i) { if (i) out << ','; out << s.values.level[i]; }
|
||||
out << "],\"youth_price\":" << s.values.youth_price << ",\"youth_paid\":"
|
||||
<< (s.values.youth_paid ? "true" : "false") << ",\"youth_open\":"
|
||||
<< (s.values.youth_open ? "true" : "false") << '}';
|
||||
out << "],\"youth_teams\":[";
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (i) out << ',';
|
||||
out << "{\"strength\":" << int(s.values.youth_strength[i])
|
||||
<< ",\"position\":" << int(s.values.youth_position[i])
|
||||
<< ",\"league\":" << int(s.values.youth_league[i]) << '}';
|
||||
}
|
||||
out << "]}";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@@ -194,9 +204,6 @@ Image EnvironmentScreen::render() const {
|
||||
throw FormatError("environment: Original badge crop outside atlas");
|
||||
crop(out, badge_atlas_, badge_x, 0, 0x8c, 0x61, 0x26, 0x26);
|
||||
for (int item = 0; item < kEnvironmentItems; ++item) {
|
||||
// OpenBMH deviates from the original: omits the two discontinued youth groups from the environment screen.
|
||||
// supported rule profile BypassesTwoDiscontinuedYouthGroups bypasses the two discontinued youth groups.
|
||||
if (item < 3 && item != kYouthAcademy) continue;
|
||||
const int x = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), y = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
crop(out, tiles_, item * 0x33, 0x46, x, y, 0x33, 0x29);
|
||||
// CallsTwiceForUpperLowerCaptionStrips calls LoadGameEndTaxAnimationAssets twice for the upper and lower caption strips.
|
||||
@@ -215,25 +222,29 @@ Image EnvironmentScreen::render() const {
|
||||
for (int yy = top; yy <= bottom; ++yy) out.at(right, yy) = 0x40;
|
||||
};
|
||||
panel(x - 4, y - 10, x + 0x36, y - 1);
|
||||
panel(x - 4, y + 0x29, x + 0x36, y + 0x31);
|
||||
const int unit = item == kYouthAcademy ? 1 : item >= 3 ? 5000 : 1;
|
||||
const int count = item == kYouthAcademy ? (state_.values.monthly[size_t(item)] != 0 ? 6 : 0)
|
||||
: std::clamp(state_.values.monthly[size_t(item)] / unit, 0, 6);
|
||||
panel(x - 4, y + 0x29, x + 0x36, y + 0x31 + (item < 3 ? 6 : 0));
|
||||
const int count = state_.values.level[size_t(item)];
|
||||
for (int star = 0; star < count; ++star)
|
||||
crop(out, tiles_, 0x1e, 0x1e, x + star * 9, y - 8, 7, 6, 0);
|
||||
// The tile artwork already contains its Source caption. CallsTwiceForUpperLowerCaptionStrips draws
|
||||
// the dynamic expense in the lower strip at baseline y+0x30; a second
|
||||
// invented TEXTD caption here overwrote the baked-in names and shifted
|
||||
// the cost down into the hit area.
|
||||
const auto& cost = state_.cost_text[size_t(item)];
|
||||
const auto cost = state_.cost_text[size_t(item)] + exe_.cstring(::bmh::layout::EnvironmentCostSuffix);
|
||||
text(out, x + 0x32 / 2 - font_.text_width(cost) / 2, y + 0x30, cost, 0x6b);
|
||||
if (item < 3) {
|
||||
const auto caption = state_.youth_position_text[size_t(item)] +
|
||||
exe_.cstring(::bmh::layout::EnvironmentYouthPositionSuffix) + state_.youth_league_text[size_t(item)];
|
||||
text(out, x + 0x32 / 2 - font_.text_width(caption) / 2, y + 0x36,
|
||||
caption, exe_.u8(::bmh::layout::EnvironmentYouthColors + item));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
|
||||
if (pending_) return false;
|
||||
press_seen_ = true;
|
||||
pending_.reset();
|
||||
pressed_item_ = pressed_level_ = -1;
|
||||
pressed_right_ = right;
|
||||
if (right) return true;
|
||||
@@ -241,7 +252,7 @@ bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
|
||||
const int left = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), top = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
if (x >= left - 9 && x <= left + 0x36 && y >= top - 10 && y <= top + 0x29) {
|
||||
pressed_item_ = item;
|
||||
pressed_level_ = std::clamp((x - left + 4) / 9, 0, 6);
|
||||
pressed_level_ = std::clamp((x - left + 9) / 9, 0, 6);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ struct EnvironmentView {
|
||||
std::string club_name;
|
||||
uint16_t badge_sprite = 0;
|
||||
std::array<std::string, 6> cost_text{};
|
||||
std::array<std::string, 3> youth_position_text{}, youth_league_text{};
|
||||
bool decorated_background = true;
|
||||
bool gradient_text = true;
|
||||
bool solid_panel_background = false;
|
||||
|
||||
@@ -33,9 +33,11 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
const auto panel = load_vga(asset_path(data / "KB", "56.VGA"));
|
||||
const auto body = load_font(asset_path(data / "F", "BMH3.FNT"));
|
||||
SpriteFont sprite(data);
|
||||
// All four visible groups exercise an empty and an occupied star rail.
|
||||
state.values.monthly[1] = 0;
|
||||
for (int item = 3; item < 6; ++item) state.values.monthly[size_t(item)] = 10000;
|
||||
// All six visible groups exercise an empty and an occupied star rail.
|
||||
for (int item = 0; item < 6; ++item) {
|
||||
state.values.level[size_t(item)] = item < 3 ? 0 : 2;
|
||||
state.values.monthly[size_t(item)] = state.values.level[size_t(item)] * kEnvironmentStep[size_t(item)];
|
||||
}
|
||||
for (int mode = 0; mode < 3; ++mode) {
|
||||
state.decorated_background = mode != 1;
|
||||
state.plain_background = mode == 2;
|
||||
@@ -56,9 +58,9 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
sprite.draw(base, 5, 235, original_to_utf8(state.club_name), 5);
|
||||
for (int y = 0; y < 240; ++y) for (int x = 0; x < 320; ++x) {
|
||||
bool foreground = x >= 125 && x <= 195 && y >= 82 && y <= 151;
|
||||
for (int item : {1, 3, 4, 5}) {
|
||||
for (int item : {0, 1, 2, 3, 4, 5}) {
|
||||
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
foreground |= x >= tx - 4 && x <= tx + 54 && y >= ty - 10 && y <= ty + 49;
|
||||
foreground |= x >= tx - 4 && x <= tx + 54 && y >= ty - 10 && y <= ty + 49 + (item < 3 ? 6 : 0);
|
||||
}
|
||||
if (!foreground) check(pixel(actual, x, y) == pixel(base, x, y),
|
||||
"Source KB129/flat background, centered title and active club footer");
|
||||
@@ -76,14 +78,14 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
check(transparent_center > 0 && center_ink > 0, "central crop oracle covers transparent and ink pixels");
|
||||
check(actual.at(139, 96) == 0x46 && actual.at(178, 96) == 0x40 &&
|
||||
actual.at(139, 135) == 0x40, "Source badge frame and corner overwrite order");
|
||||
for (int item : {1, 3, 4, 5}) {
|
||||
for (int item : {0, 1, 2, 3, 4, 5}) {
|
||||
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
|
||||
for (int y = 0; y < 41; ++y) for (int x = 0; x < 51; ++x)
|
||||
check(pixel(actual, tx + x, ty + y) == pixel(art, item * 51 + x, 70 + y),
|
||||
"legacy routine tile is opaque, without a fabricated c0 comparekey");
|
||||
// The Source upper panel is copied first; each nonzero star pixel
|
||||
// replaces it. A zero in the star bitmap exposes that panel.
|
||||
const int stars = item == 1 ? 0 : 2;
|
||||
const int stars = state.values.level[size_t(item)];
|
||||
for (int y = ty - 9; y <= ty - 2; ++y) for (int x = tx - 3; x <= tx + 53; ++x) {
|
||||
uint8_t expected = state.solid_panel_background ? 0x42 : pixel(panel, x - 1, y - 20);
|
||||
for (int n = 0; n < stars; ++n)
|
||||
@@ -93,7 +95,7 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
|
||||
}
|
||||
check(pixel(actual, x, y) == expected, "Source star zero pixels expose the opaque KB56/flat rail");
|
||||
}
|
||||
const auto& cost = state.cost_text[size_t(item)];
|
||||
const auto cost = state.cost_text[size_t(item)] + exe.cstring(::bmh::layout::EnvironmentCostSuffix);
|
||||
const int width = body.text_width(cost), left = tx + 25 - width / 2;
|
||||
Image mask(width, body.height);
|
||||
body.draw(mask, 0, 0, cost, 1);
|
||||
@@ -171,7 +173,7 @@ int main(int argc, char** argv) {
|
||||
check(screen.key("ESC").kind == EnvironmentRequestKind::none && !screen.close_requested() &&
|
||||
screen.state_json() == held, "back cannot steal a held staff control before its release");
|
||||
const auto request = screen.release(x + 31, y + 5);
|
||||
check(request.kind == EnvironmentRequestKind::set_item && request.item == 3 && request.level == 3 &&
|
||||
check(request.kind == EnvironmentRequestKind::set_item && request.item == 3 && request.level == 4 &&
|
||||
request.manager_slot == state.manager_slot && request.runtime_club == state.runtime_club &&
|
||||
request.revision == 17 && request.owner == owner,
|
||||
"tile release emits a typed, manager/revision-owned level request");
|
||||
@@ -182,13 +184,13 @@ int main(int argc, char** argv) {
|
||||
|
||||
auto updated = state;
|
||||
updated.revision = 18;
|
||||
updated.values.level[3] = 3;
|
||||
updated.values.monthly[3] = 15000;
|
||||
updated.cost_text[3] = format_number(game, 15000, 0x185);
|
||||
updated.values.level[3] = 4;
|
||||
updated.values.monthly[3] = 20000;
|
||||
updated.cost_text[3] = format_number(game, 20000, 0x185);
|
||||
updated.owner.revision = 18;
|
||||
screen.acknowledge(updated);
|
||||
check(!screen.pending() && screen.state().revision == 18 &&
|
||||
screen.state().values.monthly[3] == 15000,
|
||||
screen.state().values.monthly[3] == 20000,
|
||||
"valid source mutation ACK refreshes the screen and clears the pending action");
|
||||
|
||||
const auto notice = environment_notice_dialog(game, state.manager_slot,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace bmh::ui {
|
||||
// Saved column-nine delays are source timer units. Values below six use
|
||||
// integer halving; zero genuinely disables the pause.
|
||||
constexpr uint32_t live_delay_milliseconds(uint8_t saved) {
|
||||
return uint32_t(saved < 6 ? saved / 2 : saved) * 20;
|
||||
}
|
||||
// VGA mode 13h timing is independent of the host monitor's refresh rate.
|
||||
inline constexpr unsigned kOriginalRefreshHz = 70;
|
||||
} // namespace bmh::ui
|
||||
@@ -1670,6 +1670,26 @@ void check_environment_controller(const std::filesystem::path& data) {
|
||||
flow.environment()->state().values.level[3] == 6 &&
|
||||
flow.environment()->state().values.monthly[3] == 30000,
|
||||
"valid environment transaction commits once and keeps the source screen open");
|
||||
for (int item : {0, 1, 2, 4, 5}) {
|
||||
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item) + 18;
|
||||
const int ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item) + 5;
|
||||
const auto before = session->state();
|
||||
const auto old_revision = revision;
|
||||
(void)flow.pointer_down(tx, ty);
|
||||
const auto write = flow.click(tx, ty);
|
||||
check(write.request == FlowRequest::environment_action && write.environment_action.item == item &&
|
||||
write.environment_action.level == 3 && serve(write).empty(),
|
||||
"every youth and staff tile submits its own three-star budget");
|
||||
auto expected = before;
|
||||
expected.memory.set32(::bmh::layout::Spending + uint32_t(item) * 4, uint32_t(kEnvironmentStep[size_t(item)] * 3));
|
||||
check(save_stream(session->state()) == save_stream(expected) && revision == old_revision + 1 &&
|
||||
session->rand().seed() == watcom_before.seed() && session->rand().calls() == watcom_before.calls() &&
|
||||
session->game().seed() == game_rng_before.seed() && session->game().calls() == game_rng_before.calls(),
|
||||
"a tile edit changes only its saved budget and revision, without a turn or RNG draw");
|
||||
(void)flow.pointer_down(tx, ty);
|
||||
check(serve(flow.click(tx, ty)).empty() && revision == old_revision + 1 && !flow.pending_environment(),
|
||||
"clicking the same youth or staff level again ACKs without toggling or another revision");
|
||||
}
|
||||
(void)flow.pointer_down(10, 10, true);
|
||||
const auto close = flow.click(10, 10, true);
|
||||
check(close.request == FlowRequest::submenu_closed && !flow.in_environment() && flow.screen_name() == "desktop",
|
||||
@@ -3241,7 +3261,7 @@ void check_live_delay_settings_writer(const std::filesystem::path& data,const st
|
||||
app::CareerSession session(data,8128,save_path);auto& game=session.state();
|
||||
const int manager=int(game.memory.u8(::bmh::layout::ActiveManager));uint64_t revision=1;std::string error;
|
||||
const auto exe=load_le(ui::asset_path(data,"BMH.exe"));const auto w=session.rand();const auto g=session.game();
|
||||
const std::array<std::pair<int,int>,13> cells{{{3,7},{4,7},{5,7},{6,7},{1,8},{2,8},{3,8},{4,8},{5,8},{6,8},{10,8},{12,8},{15,8}}};
|
||||
const std::array<std::pair<int,int>,14> cells{{{3,7},{4,7},{5,7},{6,7},{0,8},{1,8},{2,8},{3,8},{4,8},{5,8},{6,8},{10,8},{12,8},{15,8}}};
|
||||
for(const auto [row,col]:cells) {
|
||||
auto state=settings_from_game(game,manager,revision,exe);const size_t index=size_t(row*9+col);
|
||||
const auto old=state.cells[index];check(old<200,"real WEEK196 exposes the consumed speed/delay cell");
|
||||
@@ -6959,6 +6979,9 @@ int main(int argc, char** argv) {
|
||||
try {
|
||||
if (argc != 2 && argc != 3 && argc != 4) throw std::runtime_error("app_controller_tests requires data directory [optional Original save]");
|
||||
const std::filesystem::path data = argv[1];
|
||||
if(argc==3 && std::string_view(argv[2])=="--environment-only") {
|
||||
check_environment_controller(data);return 0;
|
||||
}
|
||||
if(argc==4 && std::string_view(argv[2])=="--delay-settings-only") {
|
||||
check_live_delay_settings_writer(data,argv[3]);check_gameplay_switches_writer(data,argv[3]);
|
||||
check_settings_refusal_controller(data,argv[3]);return 0;
|
||||
|
||||
+72
-82
@@ -1,91 +1,81 @@
|
||||
#include "runtime_fixture_tables.hpp"
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "test_inputs.hpp"
|
||||
// The club environment (desk menu 24, src/game/environment.hpp) on a real savegame: staff
|
||||
// levels, and the supported edition youth academy - only in July/August, the league's season price,
|
||||
// no switching off once paid.
|
||||
|
||||
#include <filesystem>
|
||||
#include "game/environment.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "formats/fbm.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "game/career.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
|
||||
using namespace bmh;
|
||||
|
||||
namespace {
|
||||
|
||||
void check(bool ok, const std::string& message) {
|
||||
if (!ok) throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
void set_rec32(GameState& g, size_t o, uint32_t v) {
|
||||
for (int i = 0; i < 4; i++) g.manager_records.at(o + size_t(i)) = uint8_t(v >> (8 * i));
|
||||
}
|
||||
|
||||
void environment_test(GameState g) {
|
||||
// staff: level * 5 000
|
||||
check(set_environment(g, 0, kDoctor, 4) != EnvironmentResult::invalid, "doctor level");
|
||||
EnvironmentState s = environment_state(g, 0);
|
||||
check(s.monthly[kDoctor] == 20000 && s.level[kDoctor] == 4, "doctor 4 x 5 000");
|
||||
check(set_environment(g, 0, kPhysio, 7) == EnvironmentResult::invalid, "level 7 is no level");
|
||||
// the other two youth groups are always 0
|
||||
set_environment(g, 0, 0, 6);
|
||||
check(environment_state(g, 0).monthly[0] == 0, "item 0 stays 0");
|
||||
// the academy out of season (the savegame is in spring)
|
||||
set_rec32(g, 0x880, 0);
|
||||
std::string message;
|
||||
check(set_environment(g, 0, kYouthAcademy, 6, &message) == EnvironmentResult::too_late, "too late in spring");
|
||||
check(message.find("Zu sp") == 0 && environment_state(g, 0).monthly[kYouthAcademy] == 0, "too late message, stays off");
|
||||
// July: on at the league's price, a second click switches it off again before it is paid
|
||||
g.date = g.season_start + 5;
|
||||
g.league_rounds.at(0) = 0;
|
||||
s = environment_state(g, 0);
|
||||
check(s.youth_open && !s.youth_paid, "July: the academy can be started");
|
||||
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::changed, "academy on");
|
||||
const int league = team_league(g.manager_teams.at(0));
|
||||
const int32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
|
||||
check(environment_state(g, 0).monthly[kYouthAcademy] == price, "season price of the league");
|
||||
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::changed &&
|
||||
environment_state(g, 0).monthly[kYouthAcademy] == 0, "a click on the active academy switches it off");
|
||||
// paid this season: stays on
|
||||
set_environment(g, 0, kYouthAcademy, 6);
|
||||
set_rec32(g, 0x880, uint32_t(price));
|
||||
message.clear();
|
||||
check(set_environment(g, 0, kYouthAcademy, 0, &message) == EnvironmentResult::contract_runs, "paid: no switching off");
|
||||
check(message == bmh::test::expected_text("environment_tests.0") && environment_state(g, 0).monthly[kYouthAcademy] == price,
|
||||
"paid: the contract runs");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
check(argc == 3, "usage: environment_tests ORIGINAL_DATA SAVEGAME");
|
||||
if (!*argv[1]) {
|
||||
std::cout << "environment tests: skipped (Original data directory not configured)\n";
|
||||
return 0;
|
||||
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
GameState fixture() {
|
||||
GameState g;
|
||||
g.manager_teams = {0, 1};
|
||||
g.manager_records.resize(2 * 0xb0c);
|
||||
g.league_rounds.resize(1);
|
||||
g.memory.add_block(layout::EnvironmentYouthTeams, 0x90);
|
||||
for (uint32_t m = 0; m < 2; ++m)
|
||||
for (uint32_t i = 0; i < 3; ++i) {
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i, uint8_t(60 - i * 10));
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i + 3, 6);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + m * 0x24 + i + 6, uint8_t(i));
|
||||
}
|
||||
const auto exe = bmh::test::load_executable(std::filesystem::path(argv[1]) / "BMH.exe");
|
||||
const auto file = load_savegame(argv[2]);
|
||||
const DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
GameState g = GameState::from_save(SaveState(file.stream, counts), counts);
|
||||
competition_pointers(g.memory, exe);
|
||||
const auto texts = load_textd(std::filesystem::path(argv[1]) / "TEXTD.BLK");
|
||||
g.texts = &texts;
|
||||
environment_test(g);
|
||||
std::cout << "environment tests: ok\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << "environment tests: " << error.what() << "\n";
|
||||
return 1;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
void budgets() {
|
||||
auto g = fixture();
|
||||
for (int i = 0; i < 6; ++i) check(set_environment(g, 0, i, 6) == EnvironmentResult::changed, "all six budgets accept maximum");
|
||||
const auto s = environment_state(g, 0);
|
||||
check(s.monthly == std::array<int32_t, 6>{12000,24000,30000,30000,30000,30000}, "six monthly costs match the supported price units");
|
||||
check(environment_state(g, 1).monthly == std::array<int32_t, 6>{}, "other manager's budgets are isolated");
|
||||
check(set_environment(g, 0, kYouthAcademy, 6) == EnvironmentResult::unchanged, "repeating a level does not toggle the youth budget");
|
||||
for (int i = 0; i < 6; ++i) check(environment_monthly_cost(g, 0, i) == s.monthly[size_t(i)], "all six selected budgets reach monthly accounting");
|
||||
check(set_environment(g, 0, kYouthAcademy, 0) == EnvironmentResult::changed && !environment_academy_active(g, 0), "youth budget can be stopped");
|
||||
check(set_environment(g, 0, 6, 2) == EnvironmentResult::invalid &&
|
||||
set_environment(g, -1, 0, 1) == EnvironmentResult::invalid &&
|
||||
set_environment(g, 0, 0, 7) == EnvironmentResult::invalid, "invalid requests rejected");
|
||||
g.memory.set32(layout::Spending + 4, 1500000);
|
||||
check(environment_monthly_cost(g, 0, 1) == 1500000 && !environment_academy_active(g, 0), "unpaid legacy contract retains one season payment");
|
||||
for (int i = 0; i < 4; ++i) g.manager_records[0x880 + size_t(i)] = uint8_t(1500000u >> (i * 8));
|
||||
check(environment_monthly_cost(g, 0, 1) == 0 && environment_academy_active(g, 0), "paid legacy contract is never debited again");
|
||||
set_environment(g, 0, 1, 2);
|
||||
check(environment_monthly_cost(g, 0, 1) == 8000 && environment_academy_active(g, 0), "an explicit edit replaces the legacy contract with a monthly budget");
|
||||
}
|
||||
void progression() {
|
||||
auto funded = fixture(), unfunded = fixture();
|
||||
for (int i = 0; i < 3; ++i) set_environment(funded, 0, i, 6);
|
||||
WatcomRandom rich(4711), poor(4711);
|
||||
for (int round = 0; round < 100; ++round) {
|
||||
funded.league_rounds[0] = unfunded.league_rounds[0] = uint8_t(round % 34);
|
||||
advance_youth_teams(funded, 0, rich);
|
||||
advance_youth_teams(unfunded, 0, poor);
|
||||
}
|
||||
const auto a = environment_state(funded, 0), b = environment_state(unfunded, 0);
|
||||
check(a.youth_strength[0] > b.youth_strength[0] && a.youth_strength[1] > b.youth_strength[1] &&
|
||||
a.youth_strength[2] > b.youth_strength[2], "investment changes development in every youth group");
|
||||
check(rich.seed() == poor.seed() && rich.calls() == poor.calls(), "budgets do not change the youth algorithm's RNG call sequence");
|
||||
check(environment_state(funded, 1).youth_position == std::array<uint8_t,3>{6,6,6}, "youth results remain manager-local");
|
||||
auto g = fixture();
|
||||
for (uint32_t i = 0; i < 3; ++i) g.memory.set8(layout::EnvironmentYouthTeams + i, uint8_t(30 + 20 * i));
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 3, 0);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 6, 1);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 4, 11);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 7, 0);
|
||||
g.memory.set8(layout::EnvironmentYouthTeams + 5, 11);
|
||||
finish_youth_season(g, 0);
|
||||
const auto s = environment_state(g, 0);
|
||||
check(s.youth_league == std::array<uint8_t,3>{0,1,2} && s.youth_position == std::array<uint8_t,3>{10,1,5}, "season transition handles promotion, relegation and bottom division");
|
||||
check(s.youth_strength == std::array<uint8_t,3>{30,43,63}, "age-group handover uses previous strengths without cascading");
|
||||
}
|
||||
void timing() {
|
||||
using bmh::ui::live_delay_milliseconds;
|
||||
check(live_delay_milliseconds(0) == 0 && live_delay_milliseconds(1) == 0 &&
|
||||
live_delay_milliseconds(2) == 20 && live_delay_milliseconds(5) == 40 &&
|
||||
live_delay_milliseconds(6) == 120 && live_delay_milliseconds(30) == 600 &&
|
||||
live_delay_milliseconds(198) == 3960, "original integer delay scale includes zero and manual speed range");
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
try { budgets(); progression(); timing(); std::cout << "environment and live timing: ok\n"; return 0; }
|
||||
catch (const std::exception& e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
}
|
||||
@@ -39,7 +39,20 @@ void youth_test(GameState g) {
|
||||
GameRandom game(4711);
|
||||
WatcomRandom rand(815);
|
||||
MinuteReport report;
|
||||
auto monthly = g;
|
||||
monthly.memory.set32(::bmh::layout::Spending + 4, 8000);
|
||||
monthly.memory.set8(::bmh::layout::CareerDuration, 0);
|
||||
monthly.memory.set8(::bmh::layout::EnvironmentYouthTeams + 2, 10);
|
||||
check(team_average(monthly, team, 0xf3).value > 35, "fixture has a stronger senior squad");
|
||||
check(!youth_academy_player(monthly, 0, game, rand, report) && game.calls() == 0 && rand.calls() == 0,
|
||||
"monthly recruitment requires the oldest youth team's strength without consuming RNG on refusal");
|
||||
monthly.memory.set8(::bmh::layout::EnvironmentYouthTeams + 2, 85);
|
||||
GameRandom monthly_game(4711);
|
||||
WatcomRandom monthly_rand(815);
|
||||
check(youth_academy_player(monthly, 0, monthly_game, monthly_rand, report) && !report.unsupported,
|
||||
"an active monthly budget and sufficiently strong youth team recruit without a season lump sum");
|
||||
// unpaid: nothing happens, nothing is drawn
|
||||
g.memory.set32(::bmh::layout::Spending + 4, price);
|
||||
set_rec32(g, 0x880, price - 1);
|
||||
check(!youth_academy_player(g, 0, game, rand, report) && game.calls() == 0 && rand.calls() == 0, "unpaid academy");
|
||||
// paid
|
||||
|
||||
@@ -65,6 +65,8 @@ SECRET_PATTERNS = (
|
||||
re.compile(r"(?m)^(?:export\s+)?[A-Z_]*(?:TOKEN|PASSWORD|SECRET|API_KEY)\s*=\s*[A-Za-z0-9_./+-]{20,}(?:\s|$)"),
|
||||
)
|
||||
EMAIL = re.compile(r"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b", re.IGNORECASE)
|
||||
# Resolution-qualified artwork names are filenames, including in older commits.
|
||||
SIZED_ASSET_NAME = re.compile(r"[A-Z0-9._+-]+@[1-9][0-9]{0,4}\.(?:png|jpe?g|webp|svg|gif|avif)", re.IGNORECASE)
|
||||
# Project bot identities and the co-author trailer address are not personal data.
|
||||
BOT_EMAILS = {"codex@openbmh.invalid", "claude@openbmh.invalid", "noreply@anthropic.com"}
|
||||
HEX_NUMBER = re.compile(r"\b0x(?P<digits>[0-9a-f]{5,8})(?:u(?:ll?|z)?|ll?u?|z)?\b", re.IGNORECASE)
|
||||
@@ -187,7 +189,7 @@ def scan_blob(name: str, blob: bytes) -> list[Finding]:
|
||||
for match in pattern.finditer(text):
|
||||
result.append(Finding(name, line_at(text, match.start()), rule))
|
||||
for match in EMAIL.finditer(text):
|
||||
if match.group().lower() not in BOT_EMAILS:
|
||||
if match.group().lower() not in BOT_EMAILS and not SIZED_ASSET_NAME.fullmatch(match.group()):
|
||||
result.append(Finding(name, line_at(text, match.start()), "personal-email"))
|
||||
if PurePosixPath(name).suffix.lower() in SOURCE_SUFFIXES:
|
||||
result.extend(layout_findings(name, text))
|
||||
|
||||
@@ -20,6 +20,12 @@ class BlobChecks(unittest.TestCase):
|
||||
def rules(self, name, text):
|
||||
return {finding.rule for finding in guard.scan_blob(name, text.encode())}
|
||||
|
||||
def test_resolution_asset_names_are_not_personal_emails(self):
|
||||
for filename in ["crest@128.png", "icon@64.svg", "photo@1024.webp"]:
|
||||
self.assertNotIn("personal-email", self.rules("docs/formats/EXAMPLE.md", filename))
|
||||
for address in ["person@" + "128.example.org", "person@" + "abc.png", "person@" + "example.org"]:
|
||||
self.assertIn("personal-email", self.rules("README.md", address))
|
||||
|
||||
def test_legacy_names_without_english_word_false_positives(self):
|
||||
self.assertIn("legacy-address-symbol", self.rules("src/a.cpp", "FUN" + "_00012345();"))
|
||||
self.assertIn("legacy-address-symbol", self.rules("src/a.cpp", "raw_" + "ba384"))
|
||||
|
||||
Reference in new issue
Block a user