Initial public OpenBMH 0.1 source (by Codex)
This commit is contained in:
commit
558fbf166b
613 files changed
+168029
No files matched your search
@@ -0,0 +1,2 @@
|
||||
* text=auto eol=lf
|
||||
*.bat text eol=crlf
|
||||
@@ -0,0 +1,39 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
name: Bug report
|
||||
description: Report a reproducible OpenBMH problem.
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "Do not attach original game files, saves, screenshots, recordings or logs containing game text or personal information. Describe the problem in your own words."
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: OpenBMH version or commit
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: platform
|
||||
attributes:
|
||||
label: Operating system and architecture
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: edition
|
||||
attributes:
|
||||
label: Game edition and version
|
||||
description: "Edition name only; do not upload its files."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: "Include relevant settings or console commands, with private paths removed."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: behavior
|
||||
attributes:
|
||||
label: Expected and actual behavior
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,93 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
name: Build without game data
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner: ubuntu-24.04
|
||||
platform: linux-x64
|
||||
- runner: windows-2022
|
||||
platform: windows-x64
|
||||
- runner: macos-14
|
||||
platform: macos-arm64
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
SDL_VIDEODRIVER: dummy
|
||||
SDL_AUDIODRIVER: dummy
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
- name: Install Linux build dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y build-essential git cmake ninja-build pkg-config libgtk-3-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxfixes-dev libxss-dev libasound2-dev libpulse-dev libgl1-mesa-dev libudev-dev
|
||||
- name: Verify source export
|
||||
run: python3 tools/public_release/check_public_tree.py --root . --history
|
||||
- name: Set up MSVC x64
|
||||
if: runner.os == 'Windows'
|
||||
uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0
|
||||
with:
|
||||
arch: x64
|
||||
- name: Configure Windows x64
|
||||
if: runner.os == 'Windows'
|
||||
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBMH_DATA= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Configure Linux
|
||||
if: runner.os == 'Linux'
|
||||
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBMH_DATA= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSDL_ALSA=ON -DSDL_PULSEAUDIO=ON -DSDL_X11=ON
|
||||
- name: Verify Linux audio and video backends
|
||||
if: runner.os == 'Linux'
|
||||
shell: python
|
||||
run: |
|
||||
import pathlib, re
|
||||
required = ['SDL_AUDIO_DRIVER_ALSA', 'SDL_AUDIO_DRIVER_PULSEAUDIO', 'SDL_VIDEO_DRIVER_X11']
|
||||
headers = list(pathlib.Path('build/_deps/sdl2-build').rglob('SDL_config.h'))
|
||||
assert any(all(re.search(r'^#define\s+' + macro + r'\s+1\s*$', p.read_text(), re.M) for macro in required) for p in headers), 'ALSA/PulseAudio/X11 were not configured into SDL'
|
||||
- name: Configure macOS arm64
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
test "$(uname -m)" = arm64
|
||||
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DBMH_DATA= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Build every target
|
||||
run: cmake --build build --config Release --parallel 2
|
||||
- name: Run synthetic tests and report data tests as skipped
|
||||
run: ctest --test-dir build -C Release --output-on-failure --output-junit test-results.xml
|
||||
- name: Package products and licenses
|
||||
run: python3 tools/package/make_package.py --build build --out dist --platform ${{ matrix.platform }}
|
||||
- name: Package corresponding source and pinned dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: python3 tools/package/make_source_package.py --source . --build build --out source-dist
|
||||
- name: Upload corresponding source
|
||||
if: runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: OpenBMH-source
|
||||
path: source-dist/*.zip
|
||||
if-no-files-found: error
|
||||
- name: Upload package
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: OpenBMH-${{ matrix.platform }}
|
||||
path: dist/*.zip
|
||||
if-no-files-found: error
|
||||
- name: Upload test report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: tests-${{ matrix.platform }}
|
||||
path: build/test-results.xml
|
||||
if-no-files-found: warn
|
||||
@@ -0,0 +1,40 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
name: Prepare release packages
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
draft:
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: OpenBMH-*
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
- name: Create draft for review
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
for package in dist/*.zip; do
|
||||
case "$(basename "$package")" in
|
||||
OpenBMH-${RELEASE_TAG#v}-*.zip) ;;
|
||||
*) echo "Release tag and package version differ" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
gh release create "$RELEASE_TAG" dist/*.zip --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/0.1/RELEASE_NOTES.md
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
# Game installations, saves, captures and local reference data stay external.
|
||||
/game-data/
|
||||
/reference-data/
|
||||
/local-data/
|
||||
*.FBM
|
||||
*.fbm
|
||||
*.VGA
|
||||
*.vga
|
||||
*.BLK
|
||||
*.blk
|
||||
*.COL
|
||||
*.col
|
||||
*.LBM
|
||||
*.lbm
|
||||
*.FNT
|
||||
*.fnt
|
||||
*.WAP
|
||||
*.wap
|
||||
*.wav
|
||||
*.avi
|
||||
|
||||
# Build output and platform tooling.
|
||||
/build*/
|
||||
/out/
|
||||
/dist/
|
||||
/_deps/
|
||||
/.cache/
|
||||
/.vs/
|
||||
*.exe
|
||||
*.EXE
|
||||
*.dll
|
||||
*.dylib
|
||||
*.so
|
||||
*.o
|
||||
*.obj
|
||||
*.a
|
||||
*.lib
|
||||
*.pdb
|
||||
*.zip
|
||||
*.7z
|
||||
*.dmg
|
||||
__pycache__/
|
||||
.DS_Store
|
||||
@@ -0,0 +1,11 @@
|
||||
# Acknowledgements
|
||||
|
||||
OpenBMH recognises the programmers, artists, musicians, designers and other contributors who created *Bundesliga Manager Hattrick* and *Football Limited*. Their work is the reason this reconstruction exists. The credits in the original games remain the authoritative record of their contributors.
|
||||
|
||||
The *Bundesliga Manager Hattrick* credits name Werner Krahe and Jens Onnen among the original contributors. We thank them and the wider teams behind both games.
|
||||
|
||||
Thanks also to the player and fan-edition communities for preserving knowledge of these games, documenting their behaviour and keeping interest in football management games alive.
|
||||
|
||||
The project benefits from the work of the SDL, miniz, LZMA SDK, nativefiledialog-extended and Nuked OPL3 contributors, and from development tools including Ghidra, DOSBox, CMake and Ninja. Dependency copyrights and license terms are recorded in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
||||
|
||||
Acknowledgement does not imply sponsorship, affiliation or endorsement. Original games and third-party projects retain their own rights and identities.
|
||||
@@ -0,0 +1,18 @@
|
||||
# Working on OpenBMH
|
||||
|
||||
Start with [README.md](README.md), [CONTRIBUTING.md](CONTRIBUTING.md) and [docs/architecture.md](docs/architecture.md). Use [docs/CONSOLE_CLIENTS.md](docs/CONSOLE_CLIENTS.md) when writing clients that operate the game.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- This repository distributes implementation and documentation, not original game content. Do not add original executables, saves, graphics, audio, manuals, text inventories or decompiled output.
|
||||
- Use synthetic fixtures for public tests. Read a locally supplied game installation only through documented configuration such as `BMH_DATA`; do not bake a developer's filesystem path into code or docs.
|
||||
- Work within the requested scope. Check existing changes and coordinate shared-file edits. Do not overwrite another contributor's work.
|
||||
- Do not publish releases, push branches or contact external services unless the task authorises it.
|
||||
|
||||
## Code and tests
|
||||
|
||||
Keep rules in `src/game`, file readers in `src/formats` and session ownership/rollback in `src/app`. Reuse shared actions from graphical and console frontends. Preserve deterministic random streams, save layout and revision/manager checks. Errors need explicit outcomes; do not invent a gameplay fallback for an unsupported path.
|
||||
|
||||
Use semantic identifiers and English comments. Document deliberate compatibility changes. Run checks appropriate to the actual change and report their outcome and limits; do not claim unexecuted platform or runtime tests. Keep generated builds outside tracked source files.
|
||||
|
||||
OpenBMH-owned changes use GPL-3.0-only. Third-party notices and full license texts must remain intact, including attribution within upstream license files. Report licensing questions to the maintainers instead of rewriting vendor notices.
|
||||
+1090
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
# 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.
|
||||
|
||||
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.
|
||||
|
||||
## Changes and review
|
||||
|
||||
Keep patches focused on a concrete problem. Describe the resulting behaviour, relevant compatibility decisions and validation. Discuss architecture changes, balance changes and substantial new features before investing in a large patch.
|
||||
|
||||
- Use C++20 and the conventions of the surrounding code; write new comments in English.
|
||||
- Keep gameplay in `src/game`, format handling in `src/formats` and shared session transactions in `src/app`. Frontends translate input and display projections.
|
||||
- Preserve explicit integer widths, signedness, deterministic random consumption and save compatibility.
|
||||
- Treat malformed input, stale revisions and unsupported modes explicitly. Do not silently substitute guessed gameplay.
|
||||
- Mark intentional differences with `OpenBMH deviates from the original:` and explain them in [compatibility documentation](docs/COMPATIBILITY.md).
|
||||
- Use semantic names for concepts. File offsets and compatibility layout constants belong with format documentation; implementation notes should explain the operation rather than cite disassembly labels.
|
||||
|
||||
## Validation
|
||||
|
||||
Follow [BUILDING.md](docs/BUILDING.md), build the affected targets and run the appropriate CTest subset. Prefer tests with synthetic data that can run from a clean checkout. Tests needing a player's game installation must be conditional on `BMH_DATA`; unavailable private fixtures must not become public dependencies. State which checks ran and their limits. A build on one operating system does not establish native behaviour on another.
|
||||
|
||||
For UI changes, exercise input and state transitions as well as rendering. For session actions, cover rejected/stale input and rollback where those risks are relevant. Avoid making tests restate an implementation without checking behaviour.
|
||||
|
||||
## Licensing
|
||||
|
||||
Contributions to OpenBMH's own code and documentation are under **GPL-3.0-only**. Submit only work you have the right to contribute. Keep existing third-party copyright and license notices intact; vendored code retains its upstream license. Do not add proprietary resources to tests or examples. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,108 @@
|
||||
# OpenBMH
|
||||
|
||||
A modern and faithful open source rebuild of the *Bundesliga Manager Hattrick* engine.
|
||||
|
||||
OpenBMH is a standalone C++20 engine with an SDL2 interface for *Bundesliga Manager Hattrick* (1994/95) and its English edition, *Football Limited*. The project develops a playable reconstruction alongside a platform for new rules, content and interfaces. Keeping the familiar game enjoyable and making it easier to extend are equally important goals.
|
||||
|
||||
The engine reads a game installation supplied by the player. Game data, artwork, music, manuals and the original executable are not distributed with OpenBMH. Its aim is recognisable behaviour and plausible results; documented compatibility decisions and safety fixes take precedence over reproducing every original fault.
|
||||
|
||||
This is an independent community project, with no affiliation with or endorsement by the original rights holders, the DFL or the Bundesliga. It is an engine implementation, not an official source release or a remaster.
|
||||
|
||||
## 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.
|
||||
|
||||
1. Have your own supported game installation available.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `openbmh_play` (`openbmh_play.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
|
||||
From a terminal:
|
||||
|
||||
```sh
|
||||
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
```
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [0.1 release notes](docs/release/0.1/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
|
||||
The graphical client and console share career management, matches, transfers, contracts, finances, training, stadium management and save handling. The console supports command batches, structured views and multiple manager clients. Audio is decoded from the user's installation where supported.
|
||||
|
||||
Version 0.1 establishes the playable engine and development interfaces. Later milestones introduce an open data format and typed model, configurable rules, a scalable interface and independently distributable content. These are goals rather than delivery dates; the [roadmap](docs/ROADMAP.md) describes their dependencies.
|
||||
|
||||
## Build from source
|
||||
|
||||
The following recipes target v0.1.0. 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
|
||||
cd openbmh
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
Install Visual Studio 2022 or its Build Tools with **Desktop development with C++**, a Windows SDK and CMake. From Developer PowerShell, using the Visual Studio generator:
|
||||
|
||||
```powershell
|
||||
cmake -S . -B build-windows -G "Visual Studio 17 2022" -A x64
|
||||
cmake --build build-windows --config Release
|
||||
ctest --test-dir build-windows -C Release --output-on-failure
|
||||
.\build-windows\Release\openbmh_play.exe --data "path/to/game" --save-directory "path/to/saves"
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
On Debian or Ubuntu, install the compiler and development libraries. This example uses the default GTK3 file dialog backend:
|
||||
|
||||
```sh
|
||||
sudo apt install build-essential git cmake ninja-build pkg-config libgtk-3-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxfixes-dev libxss-dev libasound2-dev libpulse-dev libgl1-mesa-dev libudev-dev
|
||||
cmake -S . -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build-linux
|
||||
ctest --test-dir build-linux --output-on-failure
|
||||
./build-linux/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
```
|
||||
|
||||
Use a newer CMake if your distribution ships a version older than 3.24. A Linux binary can still require system libraries such as GTK3; a ZIP is not a guarantee of portability across distributions.
|
||||
|
||||
### macOS
|
||||
|
||||
Apple's Command Line Tools supply the compiler and SDK; full Xcode is not required. Install CMake and Ninja separately, for example with Homebrew. On Apple Silicon:
|
||||
|
||||
```sh
|
||||
xcode-select --install
|
||||
brew install cmake ninja
|
||||
cmake -S . -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
cmake --build build-macos
|
||||
ctest --test-dir build-macos --output-on-failure
|
||||
./build-macos/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
```
|
||||
|
||||
On Intel Macs omit the arm64 setting or select `x86_64`. These commands build terminal executables; they do not create a signed application bundle.
|
||||
|
||||
Game-data tests are optional: add `-DBMH_DATA="path/to/game"` when configuring to supply your own installation. The repository includes no original test data. See [BUILDING](docs/BUILDING.md) for test skips, system SDL2 and packaging details.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Build from source](docs/BUILDING.md) and [platform notes](docs/BUILD_PLATFORMS.md)
|
||||
- [Architecture](docs/architecture.md), [file formats](docs/formats/README.md) and [random generators](docs/RNG.md)
|
||||
- [Console reference](docs/CLI_CONCEPT/README.md), [structured protocol](docs/protocol.md) and [client/agent introduction](docs/CONSOLE_CLIENTS.md)
|
||||
- [Compatibility decisions](docs/COMPATIBILITY.md)
|
||||
|
||||
## Contribute
|
||||
|
||||
Reports with reproducible steps, documentation corrections and focused patches are welcome. Discuss larger design changes in an issue before implementing them. [CONTRIBUTING.md](CONTRIBUTING.md) explains the review and testing conventions. Do not upload original game files, screenshots, recordings, copied text databases or saved games to public issues or pull requests.
|
||||
|
||||
## How the project was developed
|
||||
|
||||
The implementation grew from study of file formats and behaviour of a legally obtained game installation. The public repository contains independently written implementation and format documentation. It does not contain the proprietary implementation or its extracted resources.
|
||||
|
||||
## License and thanks
|
||||
|
||||
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.0](https://github.com/rezmer/openbmh/tree/v0.1.0) 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).
|
||||
@@ -0,0 +1,21 @@
|
||||
# Third-party notices
|
||||
|
||||
OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the licenses of the components below. Their upstream copyright and permission notices remain in the source and in [docs/licenses](docs/licenses/README.md). The original game's executable, data, graphics, text and audio are supplied separately by the player and are not licensed or distributed by this project.
|
||||
|
||||
| Component | Version used by the build | License | Included notice |
|
||||
|---|---|---|---|
|
||||
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
|
||||
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
|
||||
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
|
||||
| [miniz](https://github.com/richgel999/miniz/releases/tag/3.0.2) | 3.0.2 amalgamation | MIT; embedded public-domain notices remain in its source | [miniz.txt](docs/licenses/miniz.txt), [source notices](docs/licenses/miniz-source-notices.txt) |
|
||||
| [LZMA SDK decoder files](https://github.com/ip7z/7zip/tree/24.09/C) | Selected C files from 7-Zip 24.09 | Public domain, as marked in the selected files | [LZMA-SDK.txt](docs/licenses/LZMA-SDK.txt) |
|
||||
| [nativefiledialog-extended](https://github.com/btzy/nativefiledialog-extended/tree/v1.2.1) | 1.2.1 | zlib license | [nativefiledialog-extended.txt](docs/licenses/nativefiledialog-extended.txt) |
|
||||
| [Nuked OPL3](https://github.com/nukeykt/Nuked-OPL3/tree/765ec962e473aeb767e4cba74ffdc8f588ffbfe8) | Commit `765ec962e473aeb767e4cba74ffdc8f588ffbfe8` | LGPL-2.1-or-later | [LGPL-2.1.txt](docs/licenses/LGPL-2.1.txt), [copyright and source notice](docs/licenses/Nuked-OPL3-notices.txt) |
|
||||
|
||||
The miniz implementation provides a zlib-compatible API; it is not the zlib library. OpenBMH does not directly link a separate zlib dependency. SDL2 and nativefiledialog-extended use the **zlib license**, which is distinct from using zlib code. A system-library build or distributor's package can have additional runtime dependencies; its notices must match the libraries actually included.
|
||||
|
||||
Only the public-domain C decoding subset is taken from the 7-Zip source package. This statement does not describe all of 7-Zip: other parts of that upstream project have different licenses and are not included here.
|
||||
|
||||
Nuked OPL3 is linked into the audio implementation. A binary distribution must retain its LGPL notices and provide the corresponding library source and the materials needed to exercise the LGPL's modification and relinking rights. For a source release, the vendored implementation and its build files are included. Binary distributors must also satisfy the source-distribution obligations of OpenBMH's GPL license. Merely copying license texts does not replace these obligations.
|
||||
|
||||
Native platform libraries, such as GTK on Linux, may be required at runtime even when they are not bundled. Compiler runtime files included with a binary package retain their own terms. See the package's file list and platform notes for the actual distribution.
|
||||
@@ -0,0 +1,52 @@
|
||||
# Building OpenBMH
|
||||
|
||||
Requirements: a C++20 compiler, CMake 3.24 or newer, Git and a supported build tool such as Ninja. The CMake project fetches pinned SDL2, miniz, 7-Zip C decoder and nativefiledialog-extended sources. Network access is needed on the first configure unless these dependencies are supplied locally. Nuked OPL3 is included in the source tree.
|
||||
|
||||
```sh
|
||||
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
ctest --test-dir build --output-on-failure
|
||||
```
|
||||
|
||||
The public checkout does not include game data. Tests that require a game installation are conditional; configure with `-DBMH_DATA="path/to/game"` to make locally available data eligible. Private saved-game fixtures are not supplied by the project. Read the test output to distinguish executed and skipped checks.
|
||||
|
||||
Main programs are `openbmh_play` (graphical game) and `openbmh_cli` (console and protocol). Single-configuration generators put them in the build directory; multi-configuration generators normally add a configuration directory. On Windows they have the `.exe` suffix.
|
||||
|
||||
## Windows
|
||||
|
||||
Use an MSVC environment with C++20 support and its Windows SDK, or another toolchain explicitly supported by the project's build configuration. From a Developer PowerShell with CMake and Ninja available:
|
||||
|
||||
```powershell
|
||||
cmake -S . -B build-windows -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build-windows
|
||||
ctest --test-dir build-windows --output-on-failure
|
||||
```
|
||||
|
||||
With a Visual Studio generator, choose one actually provided by your installed CMake and add `--config Release` / `-C Release` to build and test commands. Native file dialogs and runtime-library deployment require the platform SDK and package-specific checks.
|
||||
|
||||
## Linux
|
||||
|
||||
Install a C++20 compiler, Git, CMake, Ninja, pkg-config and the development packages required by SDL2 and the dialog backend. The default Linux dialog backend uses GTK3. For example, Debian-family development packages include `build-essential`, `cmake`, `ninja-build`, `git`, `pkg-config` and `libgtk-3-dev`; SDL2's selected video/audio backends may need additional development libraries.
|
||||
|
||||
The common commands above build the bundled SDL2. To use an installed SDL2 CMake package instead, configure with `-DBMH_USE_SYSTEM_SDL2=ON`. Its version and backend configuration then come from the installed package.
|
||||
|
||||
## macOS
|
||||
|
||||
Apple's **Command Line Tools are sufficient** for the compiler and SDK; the full Xcode application is not a prerequisite for a command-line build. Install the tools with `xcode-select --install`, and install CMake and Ninja separately. On an Apple Silicon machine:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
cmake --build build-macos
|
||||
ctest --test-dir build-macos --output-on-failure
|
||||
```
|
||||
|
||||
Use native toolchain/dependency architectures consistently. A terminal executable and a Finder-launchable, signed `.app` package are different deliverables. The commands describe the build procedure, not a claim that a particular Windows or macOS binary has passed native acceptance.
|
||||
|
||||
## Run with your data
|
||||
|
||||
```sh
|
||||
build/openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
build/openbmh_cli --console --data "path/to/game" --saves "path/to/saves" --seed 1
|
||||
```
|
||||
|
||||
For redistribution, include [LICENSE](../LICENSE), [THIRD_PARTY_NOTICES.md](../THIRD_PARTY_NOTICES.md), the full texts in [licenses/](licenses/README.md), and the corresponding source and build information required by the applicable licenses. Inspect the actual libraries in each platform package; static SDL2 alone does not establish that every dependency is static.
|
||||
@@ -0,0 +1,9 @@
|
||||
# Platform notes
|
||||
|
||||
[BUILDING.md](BUILDING.md) contains Windows, Linux and macOS build commands. C++20, CMake and platform SDKs are required. macOS command-line builds need Apple's Command Line Tools, not the complete Xcode application.
|
||||
|
||||
A successful cross-build, source review or Linux run does not establish a native Windows/macOS result. Release notes must state which packaged platforms were actually validated. Packaging is separate from compilation: check runtime dependencies, writable save directories, file dialogs, Unicode paths, display scaling and audio on the target platform.
|
||||
|
||||
On macOS an unsigned terminal executable does not automatically provide Finder integration, an application bundle or notarisation. On Windows a statically built SDL2 does not remove the need to check compiler runtimes. System-library builds inherit the versions and backend choices of their installed dependencies.
|
||||
|
||||
All packages require the user's game data. No platform package may include original executables or extracted resources. See [third-party notices](../THIRD_PARTY_NOTICES.md) for distribution material.
|
||||
@@ -0,0 +1,53 @@
|
||||
# Console syntax and responses
|
||||
|
||||
The console runs command blocks against one career session. Start it with `openbmh_cli --console --data "path/to/game" --saves "path/to/saves"`. This language is distinct from the narrower JSON request protocol used without `--console`.
|
||||
|
||||
## Input
|
||||
|
||||
Put one command on each line and finish the block with `go.` on a line of its own. `clear.` discards an unexecuted block. Blank lines and lines beginning with `//` are ignored. Commands execute in order; a failure stops the remaining commands. Earlier successful actions remain committed: a block is not one transaction.
|
||||
|
||||
Command syntax is `[@player] Name(argument, name=value)`. The player prefix uses seats 1–4. Names ignore case, dots and underscores. Arguments can be positional, followed by named arguments; quote strings containing spaces, commas or punctuation. Escape a literal quote or backslash with a backslash. Integer values can use underscores as separators. Boolean values include `true`/`false` and `on`/`off`. Parameter types and accepted enum values are checked before an action is dispatched.
|
||||
|
||||
Use `id:n` for a player ID where accepted, `slot:n` for a current squad position, and `club:n` for a master club reference. Rows and slots are temporary references. Player IDs, master club indices, runtime team IDs and name-pool identity keys are different domains. Obtain the appropriate reference from the current list or state view.
|
||||
|
||||
## Responses
|
||||
|
||||
Text lines carry a leading class: `#` status, `>` command option, `|` table row, `+` success, `!` error, `?` question, `i` information, `~` match event and `c` chat. Status headers are emitted when needed; absence of a new header does not imply that the window or match has ended. Read the final status and all intervening question/error lines.
|
||||
|
||||
`--json` in console mode emits structured line records with `class`, `window`, `player`, `text` and optional `data`. This is the structured representation of console output, not the standalone request protocol. Prefer it over parsing translated prose. Legacy game strings can still expose encoding limitations; retain raw bytes if reporting a decoder problem.
|
||||
|
||||
## Questions and ownership
|
||||
|
||||
A question has an ID, a recipient and listed options. Answer with `Answer(id, option)`, using the actual ID and option from the response. Only its owner can decide it. A question can occur during another manager's turn or while advancing the shared match clock. `GoBack` can select a question's default or cancel an editor; it is not a harmless substitute for an explicit answer.
|
||||
|
||||
`ListOptions` and `Help` describe the current build. Common failures include `E_BAD_ARGUMENT`, `E_NOT_IN_WINDOW`, `E_NOT_YOUR_TURN`, `E_PENDING_QUESTION`, `E_RULE`, `E_MODE_LOCKED`, `E_PHASE_LOCKED`, `E_IO` and `E_ENGINE_GAP`. A recognised name does not guarantee that every mode or path is implemented. Preserve an unexpected error and inspect state before deciding whether to retry.
|
||||
|
||||
The [client introduction](../CONSOLE_CLIENTS.md) covers transport, turn ownership, safe batching and replay.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `*`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListOptions` | [command:string \| all] | commands possible here; ListOptions(all) also shows locked ones |
|
||||
| `GoBack` | – | right mouse button: one level back, otherwise nothing |
|
||||
| `Chat` | [to:int], text:string | message to all, or to one player (0 = only the log) |
|
||||
| `ChatLog` | [count:int=20] | the last chat messages |
|
||||
| `Answer` | id:int, option:enum | answer the open question |
|
||||
| `Status` | – | window, player and a short overview |
|
||||
| `State` | view:enum(Desk,Table,Lineup,Mailbox,Bank,Market,Advertising,Contracts,Stadium,Toto,Training,Camp) | the full projection of a view as structured (JSON) data |
|
||||
| `Advice` | – | situations that need a decision now: form, squad, contracts, advertising, money |
|
||||
| `Scoreboard` | – | all human managers: league, place, points, balance, strength of the best eleven |
|
||||
| `Help` | [command:string] | command reference (all windows) |
|
||||
| `Quit` | [force:bool=false] | end the session (asks first during a game) |
|
||||
| `HarnessState` | [path:string] | Harness State. See current Help for behaviour and bounds. |
|
||||
| `HarnessHash` | – | Harness Hash. See current Help for behaviour and bounds. |
|
||||
| `HarnessInvariants` | – | Harness Invariants. See current Help for behaviour and bounds. |
|
||||
| `HarnessAutopilot` | player:int(1..4), policy:enum(Default,Saver,Spender,Random,Off) | Harness Autopilot. See current Help for behaviour and bounds. |
|
||||
| `HarnessFast` | matchdays:int, [until:enum(Matchday,Season,GameEnd)] | Harness Fast. See current Help for behaviour and bounds. |
|
||||
| `HarnessCoverage` | – | Harness Coverage. See current Help for behaviour and bounds. |
|
||||
| `HarnessSeed` | – | Harness Seed. See current Help for behaviour and bounds. |
|
||||
| `HarnessExpect` | text:string | Harness Expect. See current Help for behaviour and bounds. |
|
||||
@@ -0,0 +1,67 @@
|
||||
# Windows and navigation
|
||||
|
||||
A console window is a session context, not a separate game process. `Open(window)` enters an available window from the desktop. Nested editors and information cards return to their parent through `GoBack`. Pending questions and staged engine operations can restrict navigation.
|
||||
|
||||
A dot in a window name denotes a specialised context, for example `Transfer.Negotiate`. It does not imply that a client can open it directly without selecting a player. Global commands use `*` in the catalogue. `ListOptions` is the reliable guide to the current context; an operation allowed on the desktop may be forbidden during a live match or another manager's turn.
|
||||
|
||||
The following identifiers occur in the command catalogue. Some are reserved or only available in particular modes. They are API names, not a guarantee of complete support for every original screen.
|
||||
|
||||
| Window | Reference |
|
||||
|---|---|
|
||||
| `NewGame` | [Commands](03-start.md) |
|
||||
| `NewGame.Select` | [Commands](03-start.md) |
|
||||
| `NewGame.Select.Confirm` | [Commands](03-start.md) |
|
||||
| `NewPlayer` | [Commands](03-start.md) |
|
||||
| `Desktop` | [Commands](04-schreibtisch.md) |
|
||||
| `Mailbox` | [Commands](04-schreibtisch.md) |
|
||||
| `Desktop.Drawer` | [Commands](04-schreibtisch.md) |
|
||||
| `Calendar` | [Commands](04-schreibtisch.md) |
|
||||
| `LoadGame` | [Commands](04-schreibtisch.md) |
|
||||
| `SaveGame` | [Commands](04-schreibtisch.md) |
|
||||
| `NewGame.LoadGame` | [Commands](04-schreibtisch.md) |
|
||||
| `LeagueTable` | [Commands](05-information.md) |
|
||||
| `Fixtures` | [Commands](05-information.md) |
|
||||
| `Strengths` | [Commands](05-information.md) |
|
||||
| `TeamInfo` | [Commands](05-information.md) |
|
||||
| `Achievements` | [Commands](05-information.md) |
|
||||
| `OtherGames` | [Commands](05-information.md) |
|
||||
| `IndoorTable` | [Commands](05-information.md) |
|
||||
| `TopScorers` | [Commands](05-information.md) |
|
||||
| `FairPlay` | [Commands](05-information.md) |
|
||||
| `HighScore` | [Commands](05-information.md) |
|
||||
| `Statistics` | [Commands](05-information.md) |
|
||||
| `Lineup` | [Commands](06-verein.md) |
|
||||
| `Lineup.Pitch` | [Commands](06-verein.md) |
|
||||
| `Lineup.Order` | [Commands](06-verein.md) |
|
||||
| `Lineup.Marking` | [Commands](06-verein.md) |
|
||||
| `Lineup.SetPieces` | [Commands](06-verein.md) |
|
||||
| `PlayerCard` | [Commands](06-verein.md) |
|
||||
| `PlayerCard.Statistics` | [Commands](06-verein.md) |
|
||||
| `Tactics` | [Commands](06-verein.md) |
|
||||
| `Training` | [Commands](06-verein.md) |
|
||||
| `TrainingCamp` | [Commands](06-verein.md) |
|
||||
| `Transfer` | [Commands](06-verein.md) |
|
||||
| `Transfer.Negotiate` | [Commands](06-verein.md) |
|
||||
| `Transfer.Search` | [Commands](06-verein.md) |
|
||||
| `Transfer.Poach` | [Commands](06-verein.md) |
|
||||
| `Transfer.Offers` | [Commands](06-verein.md) |
|
||||
| `Contracts` | [Commands](06-verein.md) |
|
||||
| `Contracts.Negotiate` | [Commands](06-verein.md) |
|
||||
| `Bank` | [Commands](06-verein.md) |
|
||||
| `Bank.Account` | [Commands](06-verein.md) |
|
||||
| `Bank.Savings` | [Commands](06-verein.md) |
|
||||
| `Bank.Shares` | [Commands](06-verein.md) |
|
||||
| `Bank.RealEstate` | [Commands](06-verein.md) |
|
||||
| `Bank.Credit` | [Commands](06-verein.md) |
|
||||
| `Stadium` | [Commands](06-verein.md) |
|
||||
| `Stadium.Periphery` | [Commands](06-verein.md) |
|
||||
| `Stadium.Data` | [Commands](06-verein.md) |
|
||||
| `Advertising` | [Commands](06-verein.md) |
|
||||
| `Environment` | [Commands](06-verein.md) |
|
||||
| `Balance` | [Commands](06-verein.md) |
|
||||
| `Toto` | [Commands](06-verein.md) |
|
||||
| `Friendlies` | [Commands](06-verein.md) |
|
||||
| `Reschedule` | [Commands](06-verein.md) |
|
||||
| `Match` | [Commands](07-spieltag.md) |
|
||||
| `GameEnd` | [Commands](07-spieltag.md) |
|
||||
| `Settings` | [Commands](08-einstellungen.md) |
|
||||
@@ -0,0 +1,57 @@
|
||||
# Starting or loading a career
|
||||
|
||||
Startup moves from `NewGame` to `NewGame.Select`, then asks each selected manager to confirm their choices. Use `ShowOptions` and `ListTeams` to obtain the current values and master club references. Do not assume that the same numeric club identifies the same content in German and English installations.
|
||||
|
||||
`NewGame` sets the duration, difficulty, manager count, mode and league/world choices. Team selection records a manager name, club, starting league, strength band and portrait. `Confirm` opens a question; answer its actual ID explicitly. With several managers, finish each selection before the first desktop appears.
|
||||
|
||||
`OpenLoadBrowser` / `LoadGame` enter normal save loading. Paths are resolved against the configured save browser. The loader validates format/version compatibility; renaming an unsupported save or altering its header does not make it supported. Adding a manager later uses `NewPlayer` and remains subject to the running career's rules.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `NewGame`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowOptions` | – | show the options with their current values |
|
||||
| `NewGame` | duration:int(1..5), difficulty:int(1..10), managers:int(1..4), mode:int(1..3), league:bool, world:bool | set all options and continue (= right mouse) |
|
||||
| `SetDuration` | duration:int(1..5) | 1-4 seasons, 5 = endless |
|
||||
| `SetDifficulty` | difficulty:int(1..10) | number of balls |
|
||||
| `SetManagers` | managers:int(1..4) | human managers |
|
||||
| `SetMode` | mode:int(1..3) | range of desk functions |
|
||||
| `SetLeagueMode` | on:bool | league mode on/off |
|
||||
| `SetWorldMode` | on:bool | world cup mode on/off |
|
||||
| `OpenLoadBrowser` | – | open the load browser |
|
||||
| `LoadGame` | filename:string | load a saved game |
|
||||
|
||||
### `NewGame.Select`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListTeams` | [league:int \| tab:enum] | clubs of a picker tab (Bundesliga ... AdditionalB) |
|
||||
| `ListPortraits` | – | the twelve portraits and who took them |
|
||||
| `ListStrengths` | – | the three club strengths |
|
||||
| `ShowSelection` | – | the choices of this player |
|
||||
| `SetManagerName` | name:string(1..20) | the manager's name (1-20 characters) |
|
||||
| `SetClub` | club:Club | the club: club:<n> from ListTeams or "name" |
|
||||
| `SetStartLeague` | league:enum(Bundesliga,SecondLeague,RegionalA,RegionalB,Oberliga) | the league to start in |
|
||||
| `SetStrength` | strength:enum(Upper,Middle,Lower) | the club's strength |
|
||||
| `SetPortrait` | portrait:int(0..11) | the manager's portrait |
|
||||
| `SelectTeam` | managerName:string, club:Club, startLeague:enum, strength:enum, portrait:int | set all five and ask for confirmation |
|
||||
| `Confirm` | – | show the summary and ask "all details correct?" |
|
||||
|
||||
### `NewGame.Select.Confirm`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSummary` | – | the choices of this player |
|
||||
|
||||
### `NewPlayer`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowNewPlayerOptions` | – | Show New Player Options. See current Help for behaviour and bounds. |
|
||||
| `SetManagers` | managers:int(current..4) | Set Managers. See current Help for behaviour and bounds. |
|
||||
| `SetDifficulty` | difficulty:int(1..10) | Set Difficulty. See current Help for behaviour and bounds. |
|
||||
| `Confirm` | – | Confirm. See current Help for behaviour and bounds. |
|
||||
@@ -0,0 +1,77 @@
|
||||
# Desktop, calendar and saved games
|
||||
|
||||
`Desktop` is the management turn. Read `ShowDesk`, `ShowDate`, `ShowFinance`, `ShowOpponent` or `State(Desk)` before making decisions. `Open(window)` navigates to an available management window. Restrictions depend on game mode, manager role, phase and pending questions.
|
||||
|
||||
`Kickoff` hands control to the next manager or starts calendar processing once all required managers have finished. It can produce information, questions, a match window, a season boundary or the next desktop. Put it last in a batch and inspect its complete response.
|
||||
|
||||
`Calendar` reads the current schedule. `Mailbox` lists messages and supports normal keep/delete actions. Message rows are snapshot references; refresh them after a mutation. `LoadGame`, `SaveGame` and `NewGame.LoadGame` share browser commands. Select a file and use the normal `Save` action; resolve overwrite/delete questions explicitly. Save only a committed state accepted by the session.
|
||||
|
||||
Desktop layout commands are listed for discoverability. Some legacy layout operations can return `E_ENGINE_GAP`; appearance in this index is not a claim that every editor function is available.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `Desktop`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowDesk` | – | all displays of the desk |
|
||||
| `ShowDate` | – | date, weekday, season day, league round |
|
||||
| `ShowFinance` | – | balance, savings, ticket price |
|
||||
| `ShowFanStanding` | – | standing with the fans |
|
||||
| `ShowLamps` | – | the ten warning lamps |
|
||||
| `ShowLastGames` | – | the last six games |
|
||||
| `ShowOpponent` | – | the next game and opponent |
|
||||
| `ShowPositionCurves` | [own\|opponent] | table positions per matchday |
|
||||
| `ShowAutomation` | – | the five automations |
|
||||
| `Open` | window:enum \| menu:int | open a window (click on its icon); see the lines below |
|
||||
| `Key` | letter:enum(A..Z) | a key on the desk (G = Kickoff) |
|
||||
| `SetTicketPrice` | price:int(8..25) | the ticket price (price scale) |
|
||||
| `SetAutomation` | feature:enum(Lineup,Substitution,Tactics,Marking,Training), on:bool | switch one of the five automations (Lineup: a saved formation 1-8) |
|
||||
| `Kickoff` | – | hand over to the next player or start the day |
|
||||
| `OpenMailbox` | – | open the mailbox (Kicker) |
|
||||
| `OpenDrawer` | – | open the menu bar |
|
||||
| `PullPlug` | – | the plug: quit after a question |
|
||||
|
||||
### `Mailbox`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListMessages` | – | the messages of this manager (msg numbers for Keep/Delete) |
|
||||
| `KeepMessage` | msg:int | keep a message / let it go (at most five) |
|
||||
| `DeleteMessage` | msg:int | throw a message away |
|
||||
|
||||
### `Desktop.Drawer`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListIcons` | – | List Icons. See current Help for behaviour and bounds. |
|
||||
| `MoveIcon` | window:enum, x:int, y:int | Move Icon. See current Help for behaviour and bounds. |
|
||||
| `OpenFolder` | folder:int(1..3) | Open Folder. See current Help for behaviour and bounds. |
|
||||
| `OpenTrash` | – | Open Trash. See current Help for behaviour and bounds. |
|
||||
| `StoreIcon` | window:enum, folder:int(1..3) | Store Icon. See current Help for behaviour and bounds. |
|
||||
| `RetrieveIcon` | window:enum | Retrieve Icon. See current Help for behaviour and bounds. |
|
||||
| `SaveMenuDesign` | file:string | Save Menu Design. See current Help for behaviour and bounds. |
|
||||
| `LoadMenuDesign` | file:string | Load Menu Design. See current Help for behaviour and bounds. |
|
||||
| `SetTransparent` | window:enum, on:bool | Set Transparent. See current Help for behaviour and bounds. |
|
||||
| `CloseDrawer` | – | Close Drawer. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Calendar`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowCalendar` | [month:int(1..12)] | Show Calendar. See current Help for behaviour and bounds. |
|
||||
|
||||
### `LoadGame|SaveGame|NewGame.LoadGame`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListFiles` | – | List Files. See current Help for behaviour and bounds. |
|
||||
| `ChangeDirectory` | name:string | Change Directory. See current Help for behaviour and bounds. |
|
||||
| `ParentDirectory` | – | Parent Directory. See current Help for behaviour and bounds. |
|
||||
| `SelectFile` | name:string | Select File. See current Help for behaviour and bounds. |
|
||||
| `FileInfo` | name:string | File Info. See current Help for behaviour and bounds. |
|
||||
| `Load` | [name:string] | Load. See current Help for behaviour and bounds. |
|
||||
| `Save` | [name:string], [overwrite:bool=false] | Save. See current Help for behaviour and bounds. |
|
||||
| `DeleteFile` | name:string | Delete File. See current Help for behaviour and bounds. |
|
||||
@@ -0,0 +1,139 @@
|
||||
# Tables and information windows
|
||||
|
||||
Information windows expose league tables, fixtures, strengths, player cards, honours, other competitions, calendars and statistics. Choose a league or competition using the current view's options; avoid assuming that all editions have the same names or tournament structure.
|
||||
|
||||
A club's master identity and current runtime position differ. Use the identity returned for the intended action rather than reusing a row from another table. Sorting, range and home/away filters affect the current view; they do not rewrite the competition's saved result history.
|
||||
|
||||
`OpenPlayer` and `OpenTeamInfo` can create nested windows. `GoBack` closes the current level, subject to pending questions. Read-only reports can still be unavailable outside their supported mode or phase. Use `State(Table)` when a client needs an owned structured league table.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `LeagueTable`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowTable` | [league:int(0..8)] | the table (without league: the one shown) |
|
||||
| `SetLeague` | league:int(0..8) | show another league |
|
||||
| `ToggleEurope` | – | Toggle Europe. See current Help for behaviour and bounds. |
|
||||
| `SetView` | view:enum(Total,Home,Away) | Set View. See current Help for behaviour and bounds. |
|
||||
| `SetCriteria` | points:bool, goals:bool, goalsAgainst:bool | Set Criteria. See current Help for behaviour and bounds. |
|
||||
| `SetRange` | all \| from:int, to:int | Set Range. See current Help for behaviour and bounds. |
|
||||
| `SetPointsMode` | mode:enum(Normal,English) | Set Points Mode. See current Help for behaviour and bounds. |
|
||||
| `ComputerTip` | – | Computer Tip. See current Help for behaviour and bounds. |
|
||||
| `OpenFixtures` | – | the fixtures of this league |
|
||||
| `OpenStrengths` | – | Open Strengths. See current Help for behaviour and bounds. |
|
||||
| `OpenTeamInfo` | club:Club | Open Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Fixtures`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowFixtures` | [league:int, matchday:int] | the page shown (optionally another league / matchday first) |
|
||||
| `SetLeague` | league:int(0..8) | another league |
|
||||
| `SetMatchday` | matchday:int | go to a matchday |
|
||||
| `NextMatchday` | – | the next matchday (arrow) |
|
||||
| `PreviousMatchday` | – | the previous matchday (arrow) |
|
||||
| `FindGame` | home:Club, away:Club | Find Game. See current Help for behaviour and bounds. |
|
||||
| `GamesOf` | club:Club | Games Of. See current Help for behaviour and bounds. |
|
||||
| `Page` | n:int | Page. See current Help for behaviour and bounds. |
|
||||
| `ShowPostponed` | – | the postponed games |
|
||||
| `ComputerTip` | – | the computer's forecast for this page |
|
||||
| `OpenTable` | – | the league table |
|
||||
| `OpenStrengths` | – | Open Strengths. See current Help for behaviour and bounds. |
|
||||
| `OpenTeamInfo` | club:Club | Open Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Strengths`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowStrengths` | [league:int] | Show Strengths. See current Help for behaviour and bounds. |
|
||||
| `SetLeague` | league:int(0..8) | Set League. See current Help for behaviour and bounds. |
|
||||
| `SetCriteria` | fitness:bool, skill:bool, form:bool, morale:bool | Set Criteria. See current Help for behaviour and bounds. |
|
||||
| `SetLines` | goalkeeper:bool, defence:bool, midfield:bool, attack:bool | Set Lines. See current Help for behaviour and bounds. |
|
||||
| `SetZeroValue` | – | Set Zero Value. See current Help for behaviour and bounds. |
|
||||
| `SortByAge` | on:bool | Sort By Age. See current Help for behaviour and bounds. |
|
||||
| `SetPlayerFilter` | filter:enum(All,OnPitchOnly) | Set Player Filter. See current Help for behaviour and bounds. |
|
||||
| `OpenFixtures` | – | Open Fixtures. See current Help for behaviour and bounds. |
|
||||
| `OpenTable` | – | Open Table. See current Help for behaviour and bounds. |
|
||||
| `OpenTeamInfo` | club:Club | Open Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
### `TeamInfo`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `OpenTeamInfo` | club:Club | Open Team Info. See current Help for behaviour and bounds. |
|
||||
| `ShowTeamSquad` | [view:enum(A,B)] | the club's squad |
|
||||
| `ShowTeamStatistics` | [scope:enum(Home,Away,Total)] | Show Team Statistics. See current Help for behaviour and bounds. |
|
||||
| `SetBroadcast` | club:Club, mode:enum(Dots,Headphones,Camera) | Set Broadcast. See current Help for behaviour and bounds. |
|
||||
| `ShowPlayer` | player:Player | a player of this club |
|
||||
| `CloseTeamInfo` | – | back to where it was opened |
|
||||
|
||||
### `Achievements`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowAchievements` | – | Show Achievements. See current Help for behaviour and bounds. |
|
||||
| `ShowCompetitionSeason` | competition:enum(League,DfbCup,European) | Show Competition Season. See current Help for behaviour and bounds. |
|
||||
|
||||
### `OtherGames`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowCompetition` | [competition:enum, round:enum, matchday:int] | Show Competition. See current Help for behaviour and bounds. |
|
||||
| `SetCompetition` | competition:enum(DfbCup,UefaCup,ChampionsLeague,CupWinners,World,SuperCup) | Set Competition. See current Help for behaviour and bounds. |
|
||||
| `SetRound` | round:string | Set Round. See current Help for behaviour and bounds. |
|
||||
| `NextMatchday` | – | Next Matchday. See current Help for behaviour and bounds. |
|
||||
| `PreviousMatchday` | – | Previous Matchday. See current Help for behaviour and bounds. |
|
||||
| `CompleteView` | – | Complete View. See current Help for behaviour and bounds. |
|
||||
| `OpenTeamInfo` | club:Club | Open Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
### `IndoorTable`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowIndoorTable` | – | Show Indoor Table. See current Help for behaviour and bounds. |
|
||||
| `OpenTeamInfo` | club:Club | Open Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
### `TopScorers`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowScorers` | [list:enum(Goals,Assists,Score), scope:enum(League,Managers)] | the best ten: goals, assists or both; whole league or managers' clubs |
|
||||
| `SetList` | list:enum(Goals,Assists,Score) | TORSCHÜTZEN / VORLAGEN / SCORER |
|
||||
| `SetScope` | scope:enum(League,Managers) | GESAMTE LIGA / NUR MANAGER |
|
||||
|
||||
### `FairPlay`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowFairPlay` | – | Show Fair Play. See current Help for behaviour and bounds. |
|
||||
|
||||
### `HighScore`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowHighScore` | – | the high score list and your current score |
|
||||
|
||||
### `Statistics`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `OpenView` | view:enum(Opportunities,AllTimeTable,SeriesRecords,Transfers,WorldCup,Winners,Charts,Finances,MinuteStats) | Open View. See current Help for behaviour and bounds. |
|
||||
| `ShowOpportunities` | [mode:enum(A,B,C,D)] | Show Opportunities. See current Help for behaviour and bounds. |
|
||||
| `ShowAllTimeTable` | [country:enum(Bundesliga,France,England,Spain,Italy)], [mode:enum(Absolute,Relative)] | Show All Time Table. See current Help for behaviour and bounds. |
|
||||
| `ShowSeriesRecords` | – | Show Series Records. See current Help for behaviour and bounds. |
|
||||
| `ShowTransferHistory` | – | Show Transfer History. See current Help for behaviour and bounds. |
|
||||
| `ShowWorldCupStats` | [nation:string] | Show World Cup Stats. See current Help for behaviour and bounds. |
|
||||
| `ShowWinners` | [competition:enum(League,DfbCup,ChampionsLeague,CupWinners,WorldCup,EuroCup,IndoorMasters,SuperCup)] | Show Winners. See current Help for behaviour and bounds. |
|
||||
| `ShowCharts` | kind:enum(TablePosition,GateIncome,Balance,Strength,AdvertisingIncome,Assets), [mode:enum(Absolute,Relative)] | Show Charts. See current Help for behaviour and bounds. |
|
||||
| `ShowFinances` | – | Show Finances. See current Help for behaviour and bounds. |
|
||||
| `ShowMinuteStats` | – | Show Minute Stats. See current Help for behaviour and bounds. |
|
||||
|
||||
### `*`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListLeagues` | – | leagues with number and size |
|
||||
| `ListClubs` | [league:int] | List Clubs. See current Help for behaviour and bounds. |
|
||||
@@ -0,0 +1,351 @@
|
||||
# Club management
|
||||
|
||||
Club windows share the same session actions as the graphical client. Read a projection, choose current identifiers, apply an action and inspect its result before using a stale row or price again.
|
||||
|
||||
## Squad, tactics and training
|
||||
|
||||
`Lineup` lists squad members and positions; use explicit player references for moves and orders. The engine checks availability, formation and substitution rules. `Tactics` changes preparation values, while automation flags can delegate selected decisions. `Training` has types, areas, intensity and focus; opening or initialising a plan is an action distinct from merely reading it. A legal starting eleven takes priority over speculative transfers.
|
||||
|
||||
## Transfers and contracts
|
||||
|
||||
`Transfer` provides market filters, players and purchase/loan actions. `HirePlayer` requests an ordinary loan for a supported duration; free agents must be bought rather than borrowed. `Transfer.Negotiate` holds a staged offer: change fields with `SetOffer` or `SetOfferField`, submit with `SubmitOffer`, or cancel through `GoBack`. The engine applies qualification, squad capacity, wages, fees and acceptance rules; an opened editor is not an accepted purchase.
|
||||
|
||||
A loan expiry can suspend calendar processing for a return question addressed to the borrowing manager. The manager chooses the displayed No or Yes option. Yes opens the normal staged buyback negotiation; cancelling that editor follows the ordinary return path. Only the owning manager can edit or close it. Do not start another calendar operation while a modal question or editor owns the suspended operation.
|
||||
|
||||
`Contracts.Negotiate` is a separate contract editor. Player IDs remain distinct from squad positions and temporary offer rows. Refresh demand and offer views after changes; neither a displayed demand nor a pending offer guarantees final acceptance.
|
||||
|
||||
## Finance and facilities
|
||||
|
||||
`Bank`, `Advertising`, `Stadium`, `Toto` and related subwindows expose normal financial actions. Quotes and offer rows belong to their current projection. Advertising slots can be empty, active or require renewal; reading a general budget does not itself secure a sponsor. Training camps use edition-provided resort tables and the displayed currency conversion. Read the actual quote instead of hardcoding a price from another edition.
|
||||
|
||||
Loans, deposits, shares, facilities and campaigns all have rule and budget checks. A cash balance alone does not establish affordability when wages, credit or a pending obligation also matter.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `Lineup`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSquad` | [view:enum(A,B)] | the squad: values, strength, place |
|
||||
| `SetSquadView` | view:enum(A,B) | DATEN-A / DATEN-B |
|
||||
| `SwapPlayers` | first:Player, second:Player | exchange two players' places |
|
||||
| `OpenPlayer` | player:Player | the player card (PlayerCard) |
|
||||
| `OpenPitch` | – | the pitch (Lineup.Pitch) |
|
||||
| `OpenTeamList` | – | Open Team List. See current Help for behaviour and bounds. |
|
||||
| `ShowForeigners` | – | Show Foreigners. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Lineup.Pitch`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowPitch` | – | the eleven with depth/lane, formations, automatic weights |
|
||||
| `SetFormation` | slot:int(1..8) | one of the eight formations (1-4 given, 5-8 own); the automatic line-up takes over |
|
||||
| `SaveFormation` | slot:int(5..8) | save the current positions in an own formation slot (long press) |
|
||||
| `MovePlayer` | player:Player, depth:int, lane:int | place a starter freely (switches the automatic line-up off) |
|
||||
| `SwapPitch` | first:Player, second:Player | exchange two players on the pitch / bench |
|
||||
| `SetAutoWeights` | kind:enum(Position,SideAndRole,Fatigue), value:int(0..3) | an automatic line-up weight (the cup is clicked until the value); then SetFormation again |
|
||||
| `ShowAutoWeights` | – | the three automatic line-up weights |
|
||||
| `ScrollList` | direction:enum(Up,Down) | Scroll List. See current Help for behaviour and bounds. |
|
||||
| `SetSquadView` | view:enum(A,B) | DATEN-A / DATEN-B |
|
||||
| `OpenTeamList` | – | Open Team List. See current Help for behaviour and bounds. |
|
||||
| `OpenOrder` | – | ORDER: the instructions of the starters (Lineup.Order) |
|
||||
| `OpenMarking` | – | Open Marking. See current Help for behaviour and bounds. |
|
||||
| `ShowZoneCoverage` | – | Show Zone Coverage. See current Help for behaviour and bounds. |
|
||||
| `OpenSetPieces` | – | Open Set Pieces. See current Help for behaviour and bounds. |
|
||||
| `ShowPairs` | – | the Hall partners stored on the tactics board |
|
||||
| `PairPlayers` | first:Player, second:Player, depth:int(0..19), lane:int(0..8) | place the first Hall starter beside the second at the explicit target coordinates |
|
||||
|
||||
### `Lineup.Order`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowOrders` | – | offense, running, commitment, fighting of every starter |
|
||||
| `SetOrder` | player:Player, aspect:enum(Offense,Run,Commitment,Fighting), value:int | one instruction of a starter (as a click in its bar) |
|
||||
|
||||
### `Lineup.Marking`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowOpponentSquad` | – | Show Opponent Squad. See current Help for behaviour and bounds. |
|
||||
| `SetMarking` | own:Player, opponent:Player | Set Marking. See current Help for behaviour and bounds. |
|
||||
| `ClearMarking` | opponent:Player | Clear Marking. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Lineup.SetPieces`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSetPieces` | – | Show Set Pieces. See current Help for behaviour and bounds. |
|
||||
| `SetSetPieceTaker` | kind:enum(FreeKick,Penalty,Corner), player:Player | Set Set Piece Taker. See current Help for behaviour and bounds. |
|
||||
| `SetSetPieceAuto` | [kind:enum(FreeKick,Penalty,Corner)] | Set Set Piece Auto. See current Help for behaviour and bounds. |
|
||||
|
||||
### `PlayerCard`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowPlayer` | [player:Player] | the card (another player of the squad by name) |
|
||||
| `OpenPlayer` | player:Player | another player's card |
|
||||
| `OpenPlayerStatistics` | – | the development charts (own players) |
|
||||
| `Negotiate` | – | Negotiate. See current Help for behaviour and bounds. |
|
||||
| `NationalSquadAdd` | – | National Squad Add. See current Help for behaviour and bounds. |
|
||||
| `NationalSquadRemove` | – | National Squad Remove. See current Help for behaviour and bounds. |
|
||||
|
||||
### `PlayerCard.Statistics`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowPlayerStatistics` | [chart:enum(Value,Form,Strength,Total), mode:enum(Absolute,Relative)] | a development chart as a series |
|
||||
| `SetChart` | chart:enum(Value,Form,Strength,Total) | SPIELER-WERT / FORM / STÄRKE / GESAMT |
|
||||
| `SetMode` | mode:enum(Absolute,Relative) | ABS / REL |
|
||||
| `BackToPlayerInfo` | – | back to the card |
|
||||
|
||||
### `Tactics`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowTactics` | – | the eight settings with value and maximum |
|
||||
| `SetTactic` | item:int(0..7), value:int | set a value directly (item 0 ends the assistant's D/O control) |
|
||||
| `CycleTactic` | item:int(0..6) | a click: value + 1, after the maximum 0 |
|
||||
|
||||
### `Training`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowTraining` | – | types, areas, sums, players, automation |
|
||||
| `SetTrainingType` | type:enum(TOR,ABW,MIT,STU), balls:int(0..3) | balls of a player type (sum <= 8) |
|
||||
| `SetTrainingArea` | area:enum(Fitness,Skill,Corner,FreeKick,Tackling,Pass,Shot,Speed,Game), balls:int(0..3) | balls of a training area (F+S <= 4, rest <= 18) |
|
||||
| `SetPlayerIntensity` | player:Player, intensity:int(1..3) | training intensity of a player |
|
||||
| `CyclePlayerFocus` | player:Player | the player's focus symbol: next focus |
|
||||
| `SetTrainingAutomation` | index:int(0..4), on:bool | one automation bit (D p. 109) |
|
||||
| `InitializeTraining` | – | the original initialization (only when needed) |
|
||||
|
||||
### `TrainingCamp`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListResorts` | – | the eight sports schools with stars and price |
|
||||
| `ShowCamp` | – | sliders, recuperation, visits |
|
||||
| `SetCampFocus` | fitness:int(0..15), skill:int(0..15), game:int(0..15) | the three sliders; recuperation follows |
|
||||
| `BookCamp` | resort:int(0..7) | MACH ICH: book the sports school |
|
||||
|
||||
### `Transfer`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowMarket` | [page:int] | the offered players (20 per page) |
|
||||
| `SetMarketFilter` | positions:list(TOR,ABW,MIT,STU) \| All | ALLE / TOR / ABW / MIT / STU |
|
||||
| `SetSquadView` | view:enum(Active,Team) | Set Squad View. See current Help for behaviour and bounds. |
|
||||
| `SetSquadSheet` | sheet:enum(A,B) | Set Squad Sheet. See current Help for behaviour and bounds. |
|
||||
| `SetMarketVisible` | on:bool | Set Market Visible. See current Help for behaviour and bounds. |
|
||||
| `ShowPlayer` | player:Player | Show Player. See current Help for behaviour and bounds. |
|
||||
| `SellPlayer` | player:Player | VER-KAUFEN: put an own player on the list |
|
||||
| `LoanOutPlayer` | player:Player, months:int(12\|24) | VER-LEIHEN: offer an own player for loan |
|
||||
| `BuyPlayer` | player:Player | VER-KAUFEN on a market player: the offer editor |
|
||||
| `HirePlayer` | player:Player, months:int(12\|24) | VER-LEIHEN on a market player: the loan offer |
|
||||
| `OpenOffers` | player:Player | Open Offers. See current Help for behaviour and bounds. |
|
||||
| `OpenSearch` | – | Open Search. See current Help for behaviour and bounds. |
|
||||
| `OpenPoach` | – | ABWERBEN: pick a player of another club (Transfer.Poach) |
|
||||
| `ShowTransferNews` | [count:int] | Show Transfer News. See current Help for behaviour and bounds. |
|
||||
| `ShowTeamInfo` | – | Show Team Info. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Transfer.Negotiate`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowNegotiation` | – | demand, quote and your offer |
|
||||
| `SetOffer` | fee:money, salary:money, years:int(1..4), bonusGoal:int, bonusPoints:int, bonusAppearance:int, bonusChampion:int, bonus2to5:int, bonus6to10:int, bonusAvoidRelegation:int | all ten fields |
|
||||
| `SetOfferField` | field:enum(Fee,Salary,Years,BonusGoal,BonusPoints,BonusAppearance,BonusChampion,Bonus2to5,Bonus6to10,BonusAvoidRelegation), value:int | change one field (a fresh quote follows) |
|
||||
| `SubmitOffer` | – | ANGEBOT: hand in the offer |
|
||||
| `ShowTeamInfo` | – | TEAM-INFO: your club's squad, as the editor shows it |
|
||||
| `ShowPlayerInfo` | – | SPIELER-INFO: the player's card with his market value |
|
||||
|
||||
### `Transfer.Search`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSearchProfile` | – | Show Search Profile. See current Help for behaviour and bounds. |
|
||||
| `SuggestProfile` | – | Suggest Profile. See current Help for behaviour and bounds. |
|
||||
| `SetSearchProfile` | types:list(TOR,ABW,MIT,STU), age:range, strength:range, focus:list(Fitness,Skill,Form), side:enum(Left,Right,Both), style:enum(Defensive,Offensive,Both), price:enum(Min,Normal,Max) | Set Search Profile. See current Help for behaviour and bounds. |
|
||||
| `StartSearch` | – | Start Search. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Transfer.Poach`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListPoachClubs` | [league:int] | the clubs of a league (default: own) |
|
||||
| `ListClubPlayers` | club:Club | the players of the club |
|
||||
| `PoachPlayer` | player:Player | the offer to a player of another club (decided at once) |
|
||||
|
||||
### `Transfer.Offers`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListOffers` | [player:Player] | List Offers. See current Help for behaviour and bounds. |
|
||||
| `AcceptOffer` | offer:int | Accept Offer. See current Help for behaviour and bounds. |
|
||||
| `RejectOffer` | offer:int | Reject Offer. See current Help for behaviour and bounds. |
|
||||
| `NegotiateOffer` | offer:int | Negotiate Offer. See current Help for behaviour and bounds. |
|
||||
| `ChooseBuyer` | player:Player, offer:int | Choose Buyer. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Contracts`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowContracts` | [sheet:enum(A,B)] | the squad with salaries and contract months |
|
||||
| `ShowTeamBonuses` | – | the seven team bonuses (percent of the salary) |
|
||||
| `SetTeamBonus` | kind:enum(Goal,Points,Appearance,Champion,Place2to5,Place6to10,AvoidRelegation), percent:int | a team bonus; it can only be raised |
|
||||
| `OpenNegotiation` | player:Player | the player's demands (Contracts.Negotiate) |
|
||||
|
||||
### `Contracts.Negotiate`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowDemands` | – | the demands for 1-4 years |
|
||||
| `SetContractOffer` | years:int(1..4), salary:money | the salary offer (monthly) |
|
||||
| `SetInsurance` | form:enum(A,B,C,D), months:int | insure the player (no question) |
|
||||
| `SetPlayerBonus` | kind:enum(Goal,Points,Appearance,Champion,Place2to5,Place6to10,AvoidRelegation), percent:int | a bonus for this player (PRÄMIEN) |
|
||||
| `MakeOffer` | – | ANGEBOT MACHEN: the player decides |
|
||||
|
||||
### `Bank`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowBank` | – | balance, savings, credit line, season base |
|
||||
| `OpenAccount` | – | the finance overview (Bank.Account) |
|
||||
| `OpenSavings` | – | the fixed deposit (Bank.Savings) |
|
||||
| `OpenCredit` | [lender:enum(Bank,Manager1,Manager2,Manager3,Manager4)] | the credit view (Bank.Credit) |
|
||||
| `OpenRealEstate` | – | real estate funds (Bank.RealEstate) |
|
||||
| `OpenShares` | – | the stock market (Bank.Shares) |
|
||||
|
||||
### `Bank.Account`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowFinanceOverview` | – | assets, debts and net worth |
|
||||
| `ShowAssetProfitLoss` | asset:int(0..11) | profit/loss of a share |
|
||||
|
||||
### `Bank.Savings`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSavings` | – | account and fixed deposit |
|
||||
| `Deposit` | amount:money(>0) | account -> fixed deposit |
|
||||
| `Withdraw` | amount:money(>0) | fixed deposit -> account |
|
||||
|
||||
### `Bank.Shares`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListShares` | – | the twelve shares |
|
||||
| `ShowShare` | asset:int(0..11) | one share with its last 30 prices |
|
||||
| `ShareAdvice` | asset:int(0..11) | the bank's tip for a share |
|
||||
| `BuyShares` | asset:int(0..11), count:int(>0) | buy shares |
|
||||
| `SellShares` | asset:int(0..11), count:int(>0) | sell shares |
|
||||
|
||||
### `Bank.RealEstate`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListRealEstate` | – | the six real estate funds |
|
||||
| `BuyRealEstate` | type:int(0..5), units:int(>0) | buy units |
|
||||
| `SellRealEstate` | type:int(0..5), units:int(>0) | sell units |
|
||||
|
||||
### `Bank.Credit`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowCredit` | [lender:enum(Bank,Manager1..4)] | the credit rows with the editable ranges |
|
||||
| `SetCreditAmount` | amount:money | AUSGEZAHLTER BETRAG: the credit |
|
||||
| `SetCreditPayment` | monthly:money | the monthly payment: within 20 % of the annuity for a credit from a manager |
|
||||
| `SetCreditTerm` | months:int | LAUFZEIT in months |
|
||||
| `RepayCredit` | amount:money \| All | RÜCKZAHLUNG: pay back (All = as much as possible) |
|
||||
| `ConfirmCredit` | – | book the changes (asks about fees) |
|
||||
| `CancelCredit` | – | discard the changes |
|
||||
|
||||
### `Stadium`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowStadium` | – | facilities, maintenance and blocks |
|
||||
| `ShowFutureExpansion` | – | Show Future Expansion. See current Help for behaviour and bounds. |
|
||||
| `QuoteBlockExpansion` | block:enum(A..H), seats:int, seated:bool, roofed:bool | Quote Block Expansion. See current Help for behaviour and bounds. |
|
||||
| `ConfirmBlockExpansion` | [tip:bool=false] | Confirm Block Expansion. See current Help for behaviour and bounds. |
|
||||
| `DeclineBlockExpansion` | – | Decline Block Expansion. See current Help for behaviour and bounds. |
|
||||
| `BuildFacility` | facility:enum(Floodlights,Scoreboard,PitchHeating,VipLounge) | technical expansion (AUSBAUEN): tier and tip questions |
|
||||
| `Maintain` | item:enum(Pitch,Comfort,Condition,Safety) | maintenance: tier and tip questions |
|
||||
| `SetTicketPrice` | price:int(8..25) | the ticket price (as on the desk) |
|
||||
| `OpenPeriphery` | – | SICHT: PANORAMA (Stadium.Periphery) |
|
||||
| `OpenData` | – | Open Data. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Stadium.Periphery`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListPeriphery` | – | the 14 objects: built, building, days |
|
||||
| `QuotePeriphery` | object:int(0..13) | the building firm's current offer (question) |
|
||||
| `BuildPeriphery` | object:int(0..13), price:money | accept the offer |
|
||||
| `DeclinePeriphery` | object:int(0..13), price:money | decline the offer |
|
||||
| `OpenInterior` | – | SICHT: INNEN (back to Stadium) |
|
||||
|
||||
### `Stadium.Data`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowStadiumData` | [chart:enum(Spectators,Admission,StadiumValue,ExtraIncome,Income,Costs), mode:enum(Absolute,Relative)] | Show Stadium Data. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Advertising`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowAdvertising` | – | all boards, shirt, TV and the spending |
|
||||
| `ListAdOffers` | slot:enum(Board1..Board14,Shirt,Tv) | the offers for a board, the shirt or TV (an expired contract: renewal first) |
|
||||
| `AcceptAdOffer` | slot:enum, offer:int | ANNEHMEN |
|
||||
| `DeclineAdOffer` | – | ABBRECHEN |
|
||||
| `SetSpending` | kind:enum(PublicRelations,FanCare), amount:money | monthly budget for press work or fan care |
|
||||
| `BuyFanItems` | amount:money | buy fan articles (sold in 6-9 weeks) |
|
||||
|
||||
### `Environment`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowEnvironment` | – | staff levels and the youth academy |
|
||||
| `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 |
|
||||
|
||||
### `Balance`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowBalance` | – | all items, the view and the planned profit or loss |
|
||||
| `SetBalanceView` | view:enum(SoFar,Real,Future) | left button: so far / real / future |
|
||||
| `SetBalanceItem` | item:enum(IncomeShirt,IncomeBoards,IncomeTv,IncomePeriphery,IncomeRentInterest,IncomeMisc,ExpenseSalaries,ExpenseStadium,ExpenseYouth,ExpenseCoTrainer,ExpenseDoctor,ExpensePhysio,ExpenseTrainingCamp,ExpenseFanCare,ExpensePr,ExpenseInterest,ExpenseMisc,OtherHomeGames,AverageGate,TicketPrice), value:int | change a planned value (views Real and Future) |
|
||||
| `TakeActuals` | – | "Werte akt.": drop the own changes, back to the game's figures |
|
||||
|
||||
### `Toto`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowToto` | – | the eleven matches with your tips |
|
||||
| `SetTip` | match:int(1..11), tip:enum(1,0,2) | the tip for one match |
|
||||
| `SetStake` | amount:money(>=0) | the stake |
|
||||
| `SubmitToto` | [stake:money, tips:list(11)] | MACH ICH: hand in the coupon |
|
||||
| `ClearToto` | – | all tips back to 1, stake 0 |
|
||||
|
||||
### `Friendlies`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListFriendlyOpponents` | [league:int(0..8)] | the clubs of a league (default: own) |
|
||||
| `ProposeFriendly` | club:Club, venue:enum(Home,Away) | the offer: costs and who pays |
|
||||
| `ListFreeDates` | – | the days the friendly can be played |
|
||||
| `SetFriendlyDate` | date:date | book the friendly on a free date (YYYY-MM-DD) |
|
||||
|
||||
### `Reschedule`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ListRescheduleGames` | – | own home league matches that can be moved |
|
||||
| `ListRescheduleDates` | game:date | the days the match can be moved to |
|
||||
| `MoveGame` | game:date, to:date | move the match to a free day |
|
||||
| `ListMovedGames` | – | moved matches that can still be taken back (new date) |
|
||||
| `UndoMove` | game:date | take a move back (game = the new date); the match is played on its matchday again |
|
||||
@@ -0,0 +1,57 @@
|
||||
# Matches and season boundaries
|
||||
|
||||
The console's stepped clock allows managers to inspect a live match and intervene through the normal tactics and substitution actions. Start with the current status, own pairing and statistics; a global match window can exist on a cup day when a particular manager has no fixture.
|
||||
|
||||
`Step(minutes)` advances a requested interval. `Run(Halftime)` requests the half-time boundary, and `Run(End)` requests completion. These are shared clock commands: with multiple seats, every required seat must submit readiness. Place the clock command last in the block. Read the returned minute and phase before the next request; never ask for half-time after it has already passed. If another seat advances to an intermediate stop, inspect that actual state rather than assuming the previous request's target was reached.
|
||||
|
||||
Only intervene in a match that actually includes the manager's team. A manager without a fixture still participates in the shared clock barrier. Do not manufacture substitutions or tactical mutations merely because another team's match is running.
|
||||
|
||||
Status can report `matchday running, minute N` without a new `# Window: Match` header. Questions can interrupt a clock request and belong to another manager. Follow the question ownership rules in [syntax](01-grundlagen.md) and the [client introduction](../CONSOLE_CLIENTS.md).
|
||||
|
||||
At a season-end desktop, inspect the completed table and financial/squad position before continuing. A historical final table is not itself a new year transition. `State(Desk)` supplies the phase and season index for clients that need to track the boundary. Finite careers can terminate in `GameEnd`; do not keep submitting advance commands after completion.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `Match`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `Step` | [minutes:int=1] | let the clock run n minutes (default 1) |
|
||||
| `Run` | [until:enum(Halftime,End)=End] | run to half time or to the end of the day |
|
||||
| `Pause` | – | Pause. See current Help for behaviour and bounds. |
|
||||
| `Resume` | – | Resume. See current Help for behaviour and bounds. |
|
||||
| `ShowMatchStats` | [match:int] | the scoreboard: score, chances, cards, spectators, weather |
|
||||
| `Watch` | match:int | Watch. See current Help for behaviour and bounds. |
|
||||
| `Substitute` | out:Player, in:Player | a substitution: a player leaves, a bench player comes on |
|
||||
| `SetFormation` | slot:int(1..8) | not during a match (move single players with MovePlayer) |
|
||||
| `MovePlayer` | player:Player, depth:int, lane:int | place a starter on another position for the rest of the match (from minute 3) |
|
||||
| `SetTactic` | item:int(0..7), value:int | change a tactic setting during the match (item 0 ends the assistant's D/O control) |
|
||||
| `ShowTactics` | – | the eight tactic settings of your team in this match |
|
||||
| `SetMarking` | own:Player, opponent:Player | Set Marking. See current Help for behaviour and bounds. |
|
||||
| `SetOrder` | player:Player, aspect:enum, value:int | Set Order. See current Help for behaviour and bounds. |
|
||||
| `Open` | window:enum(Lineup,Tactics,Table,Fixtures,Settings) | Open. See current Help for behaviour and bounds. |
|
||||
| `ShowSquad` | – | your team on the pitch and on the bench |
|
||||
|
||||
### `Desktop|Lineup|Friendlies`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowNationalSquad` | – | Show National Squad. See current Help for behaviour and bounds. |
|
||||
| `NationalSquadAdd` | player:Player | National Squad Add. See current Help for behaviour and bounds. |
|
||||
| `NationalSquadRemove` | player:Player | National Squad Remove. See current Help for behaviour and bounds. |
|
||||
|
||||
### `GameEnd`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowHighScore` | – | Show High Score. See current Help for behaviour and bounds. |
|
||||
| `NewGame` | duration:int(1..5), difficulty:int(1..10), managers:int(1..4), mode:int(1..3), league:bool, world:bool | New Game. See current Help for behaviour and bounds. |
|
||||
| `LoadGame` | filename:string | Load Game. See current Help for behaviour and bounds. |
|
||||
|
||||
### `Desktop`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSportschau` | [part:enum(Results,TimeBar,BestEleven,MatchdayOverview)] | Show Sportschau. See current Help for behaviour and bounds. |
|
||||
@@ -0,0 +1,24 @@
|
||||
# Settings
|
||||
|
||||
`Settings` operates on the career's normal switch settings. Supported boolean switches, numeric values and ranges are defined by the current projection and command help. The [settings format](../formats/EIN.md) includes reserved and multivalued cells; clients should not replace the raw matrix with their own boolean array.
|
||||
|
||||
Frontend capabilities can lock unavailable audio controls. Music preference, effects preference and actual playback-device readiness are different states. Use the projected availability and normal actions. Graphical process options such as `--mute`, `--no-music` or `--volume` are launch options, not new console commands or save fields.
|
||||
|
||||
Availability also depends on mode and manager role. A setting rejected by the engine should remain unchanged; do not bypass the rejection by patching a save.
|
||||
|
||||
## Command index
|
||||
|
||||
This index includes registered and reserved names. `ListOptions` and `Help` from the running build determine current signatures and availability. An indexed command may reject an unsupported context with `E_ENGINE_GAP`. Parameters retain the console notation; `—` means none.
|
||||
|
||||
### `Settings`
|
||||
|
||||
| Command | Parameters | Purpose |
|
||||
|---|---|---|
|
||||
| `ShowSettings` | [group:enum(Results,Sound,Game,Limits,MenuEdit,Functions,Sportschau,Display,Values,Delays)] | the switch field A1-T9 |
|
||||
| `ShowSwitch` | key:string | one switch |
|
||||
| `SetSwitch` | key:string, value:int | set a switch (on/off or a number) |
|
||||
| `IncreaseSwitch` | key:string | the plus field (columns 8, 9) |
|
||||
| `DecreaseSwitch` | key:string | the minus field (columns 8, 9) |
|
||||
| `LoadSettings` | file:string | Load Settings. See current Help for behaviour and bounds. |
|
||||
| `SaveSettings` | file:string | Save Settings. See current Help for behaviour and bounds. |
|
||||
| `ShowReadme` | – | Show Readme. See current Help for behaviour and bounds. |
|
||||
@@ -0,0 +1,9 @@
|
||||
# Text, encoding and editions
|
||||
|
||||
The installation supplies game text and names. The command vocabulary stays stable across editions; it is not translated into the selected game's display language. German and English installation data can have different text, league contents, executable layouts and currency presentation. English support remains experimental as described in the [release notes](../release/0.1/RELEASE_NOTES.md).
|
||||
|
||||
Legacy bytes are decoded at the display boundary. Client-facing text is intended to be UTF-8, while save and database offsets refer to legacy byte pools. Avoid using a displayed name as a persistent identifier: names may be edited, ambiguous or rendered differently. Prefer the ID domain required by the current command.
|
||||
|
||||
Structured records separate data from prose. Clients should decide from IDs, enums, numeric fields, question options and error codes rather than searching for a translated sentence. Preserve raw response bytes when investigating an encoding problem, and avoid publishing proprietary text collections or full game logs containing original content.
|
||||
|
||||
[TEXTD](../formats/TEXTD.md) describes the text database's structure. Replacement text requires an independent redistribution license. No extracted text inventory is included in this repository.
|
||||
@@ -0,0 +1,9 @@
|
||||
# Developing clients and tests
|
||||
|
||||
Start with the [client introduction](../CONSOLE_CLIENTS.md). A client should keep policy separate from transport: the transport submits one block, preserves the whole response and returns ownership, questions, errors and structured records to the policy. The policy then chooses a legal action for its own manager.
|
||||
|
||||
For automated checks, use independently created input and synthetic fixtures. Parser tests should exercise quoting, named arguments and block boundaries. Session tests should verify real outcomes such as a rejected stale action leaving state unchanged, a question being resolved by its actual owner, or a cancelled staged offer releasing its suspended operation. A printout matching a proposed answer is not evidence that the game state changed correctly.
|
||||
|
||||
Replay checks compare execution with the same binary, data and initial state; they do not prove universal compatibility with every original edition. Keep test outputs private when they contain game text or personal information. Public bug reports should contain minimal independently written steps, relevant version identifiers and the observed failure, without original executables, artwork, recordings or saved games.
|
||||
|
||||
Build/test setup is described in [BUILDING](../BUILDING.md). Original-data checks require a user-supplied installation and can be skipped when that input is absent. Do not report a skipped check as passed. New frontend code should reuse session actions rather than implementing another transfer, match or finance engine.
|
||||
@@ -0,0 +1,69 @@
|
||||
# Small console examples
|
||||
|
||||
These fragments illustrate the console syntax. They are not a recorded game session. Run each only in the indicated context and inspect the actual response before submitting a dependent block.
|
||||
|
||||
## Discover commands
|
||||
|
||||
```text
|
||||
ListOptions
|
||||
Help
|
||||
Status
|
||||
go.
|
||||
```
|
||||
|
||||
## Inspect a running career
|
||||
|
||||
```text
|
||||
State(Desk)
|
||||
State(Lineup)
|
||||
Advice
|
||||
go.
|
||||
```
|
||||
|
||||
`State` requires a running career. A manager client can only inspect its permitted owned views. Read returned IDs before constructing actions that refer to a player or club.
|
||||
|
||||
## Open a management window
|
||||
|
||||
From the active manager's desktop:
|
||||
|
||||
```text
|
||||
Open(Tactics)
|
||||
ListOptions
|
||||
go.
|
||||
```
|
||||
|
||||
Choose a supported setting using the returned help, then close the window before ending the turn. A command executed earlier in a failed batch is not undone.
|
||||
|
||||
## Resolve a question
|
||||
|
||||
If the current response addresses question ID 42 to this manager and lists `No` as an option, this block selects it:
|
||||
|
||||
```text
|
||||
Answer(42, No)
|
||||
go.
|
||||
```
|
||||
|
||||
The number 42 is illustrative. Always use the actual ID, owner and options. Do not repeat a previous answer against a new question.
|
||||
|
||||
## Finish a turn or advance a match
|
||||
|
||||
From the desktop, after completing management decisions:
|
||||
|
||||
```text
|
||||
Kickoff
|
||||
go.
|
||||
```
|
||||
|
||||
From an active match before half-time:
|
||||
|
||||
```text
|
||||
ShowMatchStats
|
||||
Run(Halftime)
|
||||
go.
|
||||
```
|
||||
|
||||
Check the returned minute and current phase before advancing again. Use `Run(End)` after half-time. With multiple managers, the shared clock waits for every required seat. Questions can interrupt these requests.
|
||||
|
||||
## Ask a mailbox client to wait
|
||||
|
||||
After starting a multi-seat server as described in the [client introduction](../CONSOLE_CLIENTS.md), send `WaitTurn` followed by `go.` to that seat using `--send`. Keep that one request pending until its response arrives. Do not start a second client for the same seat merely because the server has not answered yet.
|
||||
@@ -0,0 +1,13 @@
|
||||
# Alternative frontends
|
||||
|
||||
A frontend can use the console without duplicating gameplay rules. Start `openbmh_cli --console` with standard input/output, a directory mailbox or a loopback socket. All three reach the same session. See the [client introduction](../CONSOLE_CLIENTS.md) for framing and ownership.
|
||||
|
||||
`--json` emits one JSON object per output line. Each has a line class, window, player and text; structured information is carried in `data`. Table records include both displayed cells and named values where available. Question records include their ID, recipient, options and default. Inspect these fields instead of parsing translated labels.
|
||||
|
||||
`State(view)` returns an owned projection. Supported views include `Desk`, `Table`, `Lineup`, `Mailbox`, `Bank`, `Market`, `Advertising`, `Contracts`, `Stadium`, `Toto`, `Training` and `Camp`. Mutations still use the current window's commands and the session's normal validation. A state snapshot does not grant permission to act for another manager.
|
||||
|
||||
Semantic fields such as `plain_background`, `solid_panel_background`, `compact_dialog_frame`, `replay_progression_mode` and `replay_chance_mode` describe projected behaviour. Their names are independent of executable table locations. Presence flags such as `has_replay_progression_mode` describe whether the corresponding value is available; they are not extra gameplay switches.
|
||||
|
||||
Rendering should retain the revision and identifiers associated with a projection. Refresh after successful mutation, manager handoff or a season transition. Modal editors have their own lifetime: update their staged fields or cancel through their owning action, and do not keep rendering pointers into a mutable session object.
|
||||
|
||||
The transport is a local integration interface, not an authenticated public game service. A network-facing application needs its own access control and deployment design; changing the socket bind address is not a complete service architecture.
|
||||
@@ -0,0 +1,26 @@
|
||||
# Console reference
|
||||
|
||||
`openbmh_cli --console` provides a window-oriented command language over the same career session used by the graphical game. It supports interactive use, scripts, independent manager clients and alternative frontends. It is separate from the smaller [JSON request protocol](../protocol.md) selected without `--console`.
|
||||
|
||||
```sh
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves" --seed 1
|
||||
```
|
||||
|
||||
Enter `ListOptions`, then `go.` on its own line to see the current commands. Use `Help` for signatures. Commands execute as a block when `go.` is read; they are not executed merely by entering a line.
|
||||
|
||||
- [Syntax, output, errors and questions](01-grundlagen.md)
|
||||
- [Windows and navigation](02-fenster.md)
|
||||
- [Starting and loading careers](03-start.md)
|
||||
- [Desktop, calendar and saved games](04-schreibtisch.md)
|
||||
- [Tables and information](05-information.md)
|
||||
- [Club management](06-verein.md)
|
||||
- [Matches and season boundaries](07-spieltag.md)
|
||||
- [Settings](08-einstellungen.md)
|
||||
- [Text and edition handling](09-texte.md)
|
||||
- [Client development and tests](10-agenten-und-tests.md)
|
||||
- [Small examples](12-beispiele.md)
|
||||
- [Alternative frontends](15-frontends.md)
|
||||
|
||||
The [client and agent introduction](../CONSOLE_CLIENTS.md) explains mailbox/socket transport and safe ownership rules. [commands.csv](commands.csv) is a machine-readable command/window index. Its nine-column schema is retained for existing tooling; descriptive provenance columns may be empty, and implementation markers are not a runtime capability query. The running build's `ListOptions` and `Help` take precedence over this index. Recognised operations can still return `E_ENGINE_GAP` when a required engine path is unavailable.
|
||||
|
||||
Examples use independently written names and placeholder paths. The repository supplies no original game content, text catalogue or recorded game session.
|
||||
@@ -0,0 +1,349 @@
|
||||
"window";"command";"parameters";"effect";"errors";"engine";"c4";"status";"source"
|
||||
"*";"ListOptions";"[command:string | all]";"commands possible here; ListOptions(all) also shows locked ones";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"GoBack";"–";"right mouse button: one level back, otherwise nothing";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Chat";"[to:int], text:string";"message to all, or to one player (0 = only the log)";"E_BAD_ARGUMENT";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"ChatLog";"[count:int=20]";"the last chat messages";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Answer";"id:int, option:enum";"answer the open question";"E_NOT_YOUR_TURN, E_BAD_ARGUMENT";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Status";"–";"window, player and a short overview";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"State";"view:enum(Desk,Table,Lineup,Mailbox,Bank,Market,Advertising,Contracts,Stadium,Toto,Training,Camp)";"the full projection of a view as structured (JSON) data";"E_NOT_IN_WINDOW, E_MODE_LOCKED";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Advice";"–";"situations that need a decision now: form, squad, contracts, advertising, money";"E_NOT_IN_WINDOW";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Scoreboard";"–";"all human managers: league, place, points, balance, strength of the best eleven";"E_NOT_IN_WINDOW";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Help";"[command:string]";"command reference (all windows)";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"Quit";"[force:bool=false]";"end the session (asks first during a game)";"—";"";"";"ready";"01-grundlagen.md"
|
||||
"NewGame";"ShowOptions";"–";"show the options with their current values";"—";"";"";"partial";"03-start.md"
|
||||
"NewGame";"NewGame";"duration:int(1..5), difficulty:int(1..10), managers:int(1..4), mode:int(1..3), league:bool, world:bool";"set all options and continue (= right mouse)";"E_BAD_ARGUMENT";"";"";"partial";"03-start.md"
|
||||
"NewGame";"SetDuration";"duration:int(1..5)";"1-4 seasons, 5 = endless";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame";"SetDifficulty";"difficulty:int(1..10)";"number of balls";"E_BAD_ARGUMENT";"";"";"partial";"03-start.md"
|
||||
"NewGame";"SetManagers";"managers:int(1..4)";"human managers";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame";"SetMode";"mode:int(1..3)";"range of desk functions";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame";"SetLeagueMode";"on:bool";"league mode on/off";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewGame";"SetWorldMode";"on:bool";"world cup mode on/off";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewGame";"OpenLoadBrowser";"–";"open the load browser";"—";"";"";"ready";"03-start.md"
|
||||
"NewGame";"LoadGame";"filename:string";"load a saved game";"E_IO, E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"ListTeams";"[league:int | tab:enum]";"clubs of a picker tab (Bundesliga ... AdditionalB)";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"ListPortraits";"–";"the twelve portraits and who took them";"—";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"ListStrengths";"–";"the three club strengths";"—";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"ShowSelection";"–";"the choices of this player";"—";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"SetManagerName";"name:string(1..20)";"the manager's name (1-20 characters)";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"SetClub";"club:Club";"the club: club:<n> from ListTeams or ""name""";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"SetStartLeague";"league:enum(Bundesliga,SecondLeague,RegionalA,RegionalB,Oberliga)";"the league to start in";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"SetStrength";"strength:enum(Upper,Middle,Lower)";"the club's strength";"E_BAD_ARGUMENT";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"SetPortrait";"portrait:int(0..11)";"the manager's portrait";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"SelectTeam";"managerName:string, club:Club, startLeague:enum, strength:enum, portrait:int";"set all five and ask for confirmation";"—";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select";"Confirm";"–";"show the summary and ask ""all details correct?""";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewGame.Select.Confirm";"ShowSummary";"–";"the choices of this player";"—";"";"";"ready";"03-start.md"
|
||||
"NewPlayer";"ShowNewPlayerOptions";"–";"Show New Player Options. See current Help for behaviour and bounds.";"—";"";"";"ready";"03-start.md"
|
||||
"NewPlayer";"SetManagers";"managers:int(current..4)";"Set Managers. See current Help for behaviour and bounds.";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewPlayer";"SetDifficulty";"difficulty:int(1..10)";"Set Difficulty. See current Help for behaviour and bounds.";"E_RULE";"";"";"ready";"03-start.md"
|
||||
"NewPlayer";"Confirm";"–";"Confirm. See current Help for behaviour and bounds.";"—";"";"";"ready";"03-start.md"
|
||||
"Desktop";"ShowDesk";"–";"all displays of the desk";"—";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"ShowDate";"–";"date, weekday, season day, league round";"—";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"ShowFinance";"–";"balance, savings, ticket price";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop";"ShowFanStanding";"–";"standing with the fans";"—";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"ShowLamps";"–";"the ten warning lamps";"—";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"ShowLastGames";"–";"the last six games";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop";"ShowOpponent";"–";"the next game and opponent";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop";"ShowPositionCurves";"[own|opponent]";"table positions per matchday";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop";"ShowAutomation";"–";"the five automations";"—";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"Open";"window:enum | menu:int";"open a window (click on its icon); see the lines below";"E_MODE_LOCKED, E_BAD_ARGUMENT";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"Key";"letter:enum(A..Z)";"a key on the desk (G = Kickoff)";"E_BAD_ARGUMENT";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"SetTicketPrice";"price:int(8..25)";"the ticket price (price scale)";"E_BAD_ARGUMENT, E_PHASE_LOCKED";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop";"SetAutomation";"feature:enum(Lineup,Substitution,Tactics,Marking,Training), on:bool";"switch one of the five automations (Lineup: a saved formation 1-8)";"E_RULE";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"Kickoff";"–";"hand over to the next player or start the day";"E_PENDING_QUESTION";"";"";"ready";"04-schreibtisch.md"
|
||||
"Desktop";"OpenMailbox";"–";"open the mailbox (Kicker)";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop";"OpenDrawer";"–";"open the menu bar";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop";"PullPlug";"–";"the plug: quit after a question";"—";"";"";"ready";"04-schreibtisch.md"
|
||||
"Mailbox";"ListMessages";"–";"the messages of this manager (msg numbers for Keep/Delete)";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"Mailbox";"KeepMessage";"msg:int";"keep a message / let it go (at most five)";"E_RULE";"";"";"partial";"04-schreibtisch.md"
|
||||
"Mailbox";"DeleteMessage";"msg:int";"throw a message away";"E_BAD_ARGUMENT";"";"";"partial";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"ListIcons";"–";"List Icons. See current Help for behaviour and bounds.";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"MoveIcon";"window:enum, x:int, y:int";"Move Icon. See current Help for behaviour and bounds.";"E_RULE";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"OpenFolder";"folder:int(1..3)";"Open Folder. See current Help for behaviour and bounds.";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"OpenTrash";"–";"Open Trash. See current Help for behaviour and bounds.";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"StoreIcon";"window:enum, folder:int(1..3)";"Store Icon. See current Help for behaviour and bounds.";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"RetrieveIcon";"window:enum";"Retrieve Icon. See current Help for behaviour and bounds.";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"SaveMenuDesign";"file:string";"Save Menu Design. See current Help for behaviour and bounds.";"E_IO";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"LoadMenuDesign";"file:string";"Load Menu Design. See current Help for behaviour and bounds.";"E_IO";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"SetTransparent";"window:enum, on:bool";"Set Transparent. See current Help for behaviour and bounds.";"—";"";"";"gap";"04-schreibtisch.md"
|
||||
"Desktop.Drawer";"CloseDrawer";"–";"Close Drawer. See current Help for behaviour and bounds.";"E_RULE";"";"";"gap";"04-schreibtisch.md"
|
||||
"Calendar";"ShowCalendar";"[month:int(1..12)]";"Show Calendar. See current Help for behaviour and bounds.";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"ListFiles";"–";"List Files. See current Help for behaviour and bounds.";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"ChangeDirectory";"name:string";"Change Directory. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"ParentDirectory";"–";"Parent Directory. See current Help for behaviour and bounds.";"—";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"SelectFile";"name:string";"Select File. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"FileInfo";"name:string";"File Info. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"Load";"[name:string]";"Load. See current Help for behaviour and bounds.";"E_IO, E_RULE";"";"";"partial";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"Save";"[name:string], [overwrite:bool=false]";"Save. See current Help for behaviour and bounds.";"E_IO, E_RULE";"";"";"ready";"04-schreibtisch.md"
|
||||
"LoadGame|SaveGame|NewGame.LoadGame";"DeleteFile";"name:string";"Delete File. See current Help for behaviour and bounds.";"E_IO, E_ENGINE_GAP";"";"";"partial";"04-schreibtisch.md"
|
||||
"LeagueTable";"ShowTable";"[league:int(0..8)]";"the table (without league: the one shown)";"E_BAD_ARGUMENT";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"SetLeague";"league:int(0..8)";"show another league";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"ToggleEurope";"–";"Toggle Europe. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"SetView";"view:enum(Total,Home,Away)";"Set View. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"SetCriteria";"points:bool, goals:bool, goalsAgainst:bool";"Set Criteria. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"SetRange";"all | from:int, to:int";"Set Range. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"SetPointsMode";"mode:enum(Normal,English)";"Set Points Mode. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"ComputerTip";"–";"Computer Tip. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"engine";"05-information.md"
|
||||
"LeagueTable";"OpenFixtures";"–";"the fixtures of this league";"—";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"OpenStrengths";"–";"Open Strengths. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"LeagueTable";"OpenTeamInfo";"club:Club";"Open Team Info. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"ShowFixtures";"[league:int, matchday:int]";"the page shown (optionally another league / matchday first)";"E_BAD_ARGUMENT";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"SetLeague";"league:int(0..8)";"another league";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"SetMatchday";"matchday:int";"go to a matchday";"E_BAD_ARGUMENT";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"NextMatchday";"–";"the next matchday (arrow)";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"PreviousMatchday";"–";"the previous matchday (arrow)";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"FindGame";"home:Club, away:Club";"Find Game. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"GamesOf";"club:Club";"Games Of. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"Page";"n:int";"Page. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"ShowPostponed";"–";"the postponed games";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"ComputerTip";"–";"the computer's forecast for this page";"E_ENGINE_GAP";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"OpenTable";"–";"the league table";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"OpenStrengths";"–";"Open Strengths. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Fixtures";"OpenTeamInfo";"club:Club";"Open Team Info. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"Strengths";"ShowStrengths";"[league:int]";"Show Strengths. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"SetLeague";"league:int(0..8)";"Set League. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"SetCriteria";"fitness:bool, skill:bool, form:bool, morale:bool";"Set Criteria. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"SetLines";"goalkeeper:bool, defence:bool, midfield:bool, attack:bool";"Set Lines. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"SetZeroValue";"–";"Set Zero Value. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"SortByAge";"on:bool";"Sort By Age. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"SetPlayerFilter";"filter:enum(All,OnPitchOnly)";"Set Player Filter. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"OpenFixtures";"–";"Open Fixtures. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"OpenTable";"–";"Open Table. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Strengths";"OpenTeamInfo";"club:Club";"Open Team Info. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"TeamInfo";"OpenTeamInfo";"club:Club";"Open Team Info. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"TeamInfo";"ShowTeamSquad";"[view:enum(A,B)]";"the club's squad";"—";"";"";"partial";"05-information.md"
|
||||
"TeamInfo";"ShowTeamStatistics";"[scope:enum(Home,Away,Total)]";"Show Team Statistics. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"TeamInfo";"SetBroadcast";"club:Club, mode:enum(Dots,Headphones,Camera)";"Set Broadcast. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"TeamInfo";"ShowPlayer";"player:Player";"a player of this club";"—";"";"";"ready";"05-information.md"
|
||||
"TeamInfo";"CloseTeamInfo";"–";"back to where it was opened";"—";"";"";"partial";"05-information.md"
|
||||
"Achievements";"ShowAchievements";"–";"Show Achievements. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Achievements";"ShowCompetitionSeason";"competition:enum(League,DfbCup,European)";"Show Competition Season. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"ShowCompetition";"[competition:enum, round:enum, matchday:int]";"Show Competition. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT, E_RULE";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"SetCompetition";"competition:enum(DfbCup,UefaCup,ChampionsLeague,CupWinners,World,SuperCup)";"Set Competition. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"SetRound";"round:string";"Set Round. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"NextMatchday";"–";"Next Matchday. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"PreviousMatchday";"–";"Previous Matchday. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"CompleteView";"–";"Complete View. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"OtherGames";"OpenTeamInfo";"club:Club";"Open Team Info. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"IndoorTable";"ShowIndoorTable";"–";"Show Indoor Table. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"IndoorTable";"OpenTeamInfo";"club:Club";"Open Team Info. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"05-information.md"
|
||||
"TopScorers";"ShowScorers";"[list:enum(Goals,Assists,Score), scope:enum(League,Managers)]";"the best ten: goals, assists or both; whole league or managers' clubs";"—";"";"";"ready";"05-information.md"
|
||||
"TopScorers";"SetList";"list:enum(Goals,Assists,Score)";"TORSCHÜTZEN / VORLAGEN / SCORER";"—";"";"";"ready";"05-information.md"
|
||||
"TopScorers";"SetScope";"scope:enum(League,Managers)";"GESAMTE LIGA / NUR MANAGER";"—";"";"";"ready";"05-information.md"
|
||||
"FairPlay";"ShowFairPlay";"–";"Show Fair Play. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"HighScore";"ShowHighScore";"–";"the high score list and your current score";"—";"";"";"ready";"05-information.md"
|
||||
"Statistics";"OpenView";"view:enum(Opportunities,AllTimeTable,SeriesRecords,Transfers,WorldCup,Winners,Charts,Finances,MinuteStats)";"Open View. See current Help for behaviour and bounds.";"—";"";"";"cli";"05-information.md"
|
||||
"Statistics";"ShowOpportunities";"[mode:enum(A,B,C,D)]";"Show Opportunities. See current Help for behaviour and bounds.";"—";"";"";"engine";"05-information.md"
|
||||
"Statistics";"ShowAllTimeTable";"[country:enum(Bundesliga,France,England,Spain,Italy)], [mode:enum(Absolute,Relative)]";"Show All Time Table. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowSeriesRecords";"–";"Show Series Records. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowTransferHistory";"–";"Show Transfer History. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowWorldCupStats";"[nation:string]";"Show World Cup Stats. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowWinners";"[competition:enum(League,DfbCup,ChampionsLeague,CupWinners,WorldCup,EuroCup,IndoorMasters,SuperCup)]";"Show Winners. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowCharts";"kind:enum(TablePosition,GateIncome,Balance,Strength,AdvertisingIncome,Assets), [mode:enum(Absolute,Relative)]";"Show Charts. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowFinances";"–";"Show Finances. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"Statistics";"ShowMinuteStats";"–";"Show Minute Stats. See current Help for behaviour and bounds.";"—";"";"";"partial";"05-information.md"
|
||||
"*";"ListLeagues";"–";"leagues with number and size";"—";"";"";"ready";"05-information.md"
|
||||
"*";"ListClubs";"[league:int]";"List Clubs. See current Help for behaviour and bounds.";"—";"";"";"cli";"05-information.md"
|
||||
"Lineup";"ShowSquad";"[view:enum(A,B)]";"the squad: values, strength, place";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup";"SetSquadView";"view:enum(A,B)";"DATEN-A / DATEN-B";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup";"SwapPlayers";"first:Player, second:Player";"exchange two players' places";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup";"OpenPlayer";"player:Player";"the player card (PlayerCard)";"—";"";"";"ready";"06-verein.md"
|
||||
"Lineup";"OpenPitch";"–";"the pitch (Lineup.Pitch)";"E_ENGINE_GAP";"";"";"partial";"06-verein.md"
|
||||
"Lineup";"OpenTeamList";"–";"Open Team List. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup";"ShowForeigners";"–";"Show Foreigners. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"ShowPitch";"–";"the eleven with depth/lane, formations, automatic weights";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"SetFormation";"slot:int(1..8)";"one of the eight formations (1-4 given, 5-8 own); the automatic line-up takes over";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Pitch";"SaveFormation";"slot:int(5..8)";"save the current positions in an own formation slot (long press)";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Pitch";"MovePlayer";"player:Player, depth:int, lane:int";"place a starter freely (switches the automatic line-up off)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Pitch";"SwapPitch";"first:Player, second:Player";"exchange two players on the pitch / bench";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"SetAutoWeights";"kind:enum(Position,SideAndRole,Fatigue), value:int(0..3)";"an automatic line-up weight (the cup is clicked until the value); then SetFormation again";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Pitch";"ShowAutoWeights";"–";"the three automatic line-up weights";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"ScrollList";"direction:enum(Up,Down)";"Scroll List. See current Help for behaviour and bounds.";"—";"";"";"cli";"06-verein.md"
|
||||
"Lineup.Pitch";"SetSquadView";"view:enum(A,B)";"DATEN-A / DATEN-B";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"OpenTeamList";"–";"Open Team List. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"OpenOrder";"–";"ORDER: the instructions of the starters (Lineup.Order)";"—";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Pitch";"OpenMarking";"–";"Open Marking. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"ShowZoneCoverage";"–";"Show Zone Coverage. See current Help for behaviour and bounds.";"E_RULE";"";"";"gap";"06-verein.md"
|
||||
"Lineup.Pitch";"OpenSetPieces";"–";"Open Set Pieces. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"ShowPairs";"–";"the Hall partners stored on the tactics board";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Pitch";"PairPlayers";"first:Player, second:Player, depth:int(0..19), lane:int(0..8)";"place the first Hall starter beside the second at the explicit target coordinates";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Order";"ShowOrders";"–";"offense, running, commitment, fighting of every starter";"—";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Order";"SetOrder";"player:Player, aspect:enum(Offense,Run,Commitment,Fighting), value:int";"one instruction of a starter (as a click in its bar)";"E_BAD_ARGUMENT, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Lineup.Marking";"ShowOpponentSquad";"–";"Show Opponent Squad. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Marking";"SetMarking";"own:Player, opponent:Player";"Set Marking. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Lineup.Marking";"ClearMarking";"opponent:Player";"Clear Marking. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.SetPieces";"ShowSetPieces";"–";"Show Set Pieces. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Lineup.SetPieces";"SetSetPieceTaker";"kind:enum(FreeKick,Penalty,Corner), player:Player";"Set Set Piece Taker. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Lineup.SetPieces";"SetSetPieceAuto";"[kind:enum(FreeKick,Penalty,Corner)]";"Set Set Piece Auto. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"PlayerCard";"ShowPlayer";"[player:Player]";"the card (another player of the squad by name)";"—";"";"";"ready";"06-verein.md"
|
||||
"PlayerCard";"OpenPlayer";"player:Player";"another player's card";"—";"";"";"ready";"06-verein.md"
|
||||
"PlayerCard";"OpenPlayerStatistics";"–";"the development charts (own players)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"PlayerCard";"Negotiate";"–";"Negotiate. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"PlayerCard";"NationalSquadAdd";"–";"National Squad Add. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"PlayerCard";"NationalSquadRemove";"–";"National Squad Remove. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"PlayerCard.Statistics";"ShowPlayerStatistics";"[chart:enum(Value,Form,Strength,Total), mode:enum(Absolute,Relative)]";"a development chart as a series";"—";"";"";"ready";"06-verein.md"
|
||||
"PlayerCard.Statistics";"SetChart";"chart:enum(Value,Form,Strength,Total)";"SPIELER-WERT / FORM / STÄRKE / GESAMT";"—";"";"";"ready";"06-verein.md"
|
||||
"PlayerCard.Statistics";"SetMode";"mode:enum(Absolute,Relative)";"ABS / REL";"—";"";"";"ready";"06-verein.md"
|
||||
"PlayerCard.Statistics";"BackToPlayerInfo";"–";"back to the card";"—";"";"";"ready";"06-verein.md"
|
||||
"Tactics";"ShowTactics";"–";"the eight settings with value and maximum";"—";"";"";"ready";"06-verein.md"
|
||||
"Tactics";"SetTactic";"item:int(0..7), value:int";"set a value directly (item 0 ends the assistant's D/O control)";"E_BAD_ARGUMENT, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Tactics";"CycleTactic";"item:int(0..6)";"a click: value + 1, after the maximum 0";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Training";"ShowTraining";"–";"types, areas, sums, players, automation";"—";"";"";"ready";"06-verein.md"
|
||||
"Training";"SetTrainingType";"type:enum(TOR,ABW,MIT,STU), balls:int(0..3)";"balls of a player type (sum <= 8)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Training";"SetTrainingArea";"area:enum(Fitness,Skill,Corner,FreeKick,Tackling,Pass,Shot,Speed,Game), balls:int(0..3)";"balls of a training area (F+S <= 4, rest <= 18)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Training";"SetPlayerIntensity";"player:Player, intensity:int(1..3)";"training intensity of a player";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Training";"CyclePlayerFocus";"player:Player";"the player's focus symbol: next focus";"—";"";"";"ready";"06-verein.md"
|
||||
"Training";"SetTrainingAutomation";"index:int(0..4), on:bool";"one automation bit (D p. 109)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Training";"InitializeTraining";"–";"the original initialization (only when needed)";"—";"";"";"ready";"06-verein.md"
|
||||
"TrainingCamp";"ListResorts";"–";"the eight sports schools with stars and price";"—";"";"";"ready";"06-verein.md"
|
||||
"TrainingCamp";"ShowCamp";"–";"sliders, recuperation, visits";"—";"";"";"ready";"06-verein.md"
|
||||
"TrainingCamp";"SetCampFocus";"fitness:int(0..15), skill:int(0..15), game:int(0..15)";"the three sliders; recuperation follows";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"TrainingCamp";"BookCamp";"resort:int(0..7)";"MACH ICH: book the sports school";"E_INSUFFICIENT_FUNDS, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"ShowMarket";"[page:int]";"the offered players (20 per page)";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SetMarketFilter";"positions:list(TOR,ABW,MIT,STU) | All";"ALLE / TOR / ABW / MIT / STU";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SetSquadView";"view:enum(Active,Team)";"Set Squad View. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SetSquadSheet";"sheet:enum(A,B)";"Set Squad Sheet. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SetMarketVisible";"on:bool";"Set Market Visible. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"ShowPlayer";"player:Player";"Show Player. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"SellPlayer";"player:Player";"VER-KAUFEN: put an own player on the list";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"LoanOutPlayer";"player:Player, months:int(12|24)";"VER-LEIHEN: offer an own player for loan";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"BuyPlayer";"player:Player";"VER-KAUFEN on a market player: the offer editor";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"HirePlayer";"player:Player, months:int(12|24)";"VER-LEIHEN on a market player: the loan offer";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"OpenOffers";"player:Player";"Open Offers. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"OpenSearch";"–";"Open Search. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"OpenPoach";"–";"ABWERBEN: pick a player of another club (Transfer.Poach)";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer";"ShowTransferNews";"[count:int]";"Show Transfer News. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer";"ShowTeamInfo";"–";"Show Team Info. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Negotiate";"ShowNegotiation";"–";"demand, quote and your offer";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Negotiate";"SetOffer";"fee:money, salary:money, years:int(1..4), bonusGoal:int, bonusPoints:int, bonusAppearance:int, bonusChampion:int, bonus2to5:int, bonus6to10:int, bonusAvoidRelegation:int";"all ten fields";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Negotiate";"SetOfferField";"field:enum(Fee,Salary,Years,BonusGoal,BonusPoints,BonusAppearance,BonusChampion,Bonus2to5,Bonus6to10,BonusAvoidRelegation), value:int";"change one field (a fresh quote follows)";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Negotiate";"SubmitOffer";"–";"ANGEBOT: hand in the offer";"E_INSUFFICIENT_FUNDS, E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Negotiate";"ShowTeamInfo";"–";"TEAM-INFO: your club's squad, as the editor shows it";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer.Negotiate";"ShowPlayerInfo";"–";"SPIELER-INFO: the player's card with his market value";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer.Search";"ShowSearchProfile";"–";"Show Search Profile. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Search";"SuggestProfile";"–";"Suggest Profile. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Search";"SetSearchProfile";"types:list(TOR,ABW,MIT,STU), age:range, strength:range, focus:list(Fitness,Skill,Form), side:enum(Left,Right,Both), style:enum(Defensive,Offensive,Both), price:enum(Min,Normal,Max)";"Set Search Profile. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Search";"StartSearch";"–";"Start Search. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Poach";"ListPoachClubs";"[league:int]";"the clubs of a league (default: own)";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer.Poach";"ListClubPlayers";"club:Club";"the players of the club";"—";"";"";"ready";"06-verein.md"
|
||||
"Transfer.Poach";"PoachPlayer";"player:Player";"the offer to a player of another club (decided at once)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Transfer.Offers";"ListOffers";"[player:Player]";"List Offers. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Offers";"AcceptOffer";"offer:int";"Accept Offer. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Offers";"RejectOffer";"offer:int";"Reject Offer. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Offers";"NegotiateOffer";"offer:int";"Negotiate Offer. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"partial";"06-verein.md"
|
||||
"Transfer.Offers";"ChooseBuyer";"player:Player, offer:int";"Choose Buyer. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Contracts";"ShowContracts";"[sheet:enum(A,B)]";"the squad with salaries and contract months";"—";"";"";"ready";"06-verein.md"
|
||||
"Contracts";"ShowTeamBonuses";"–";"the seven team bonuses (percent of the salary)";"E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Contracts";"SetTeamBonus";"kind:enum(Goal,Points,Appearance,Champion,Place2to5,Place6to10,AvoidRelegation), percent:int";"a team bonus; it can only be raised";"E_RULE, E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Contracts";"OpenNegotiation";"player:Player";"the player's demands (Contracts.Negotiate)";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Contracts.Negotiate";"ShowDemands";"–";"the demands for 1-4 years";"—";"";"";"partial";"06-verein.md"
|
||||
"Contracts.Negotiate";"SetContractOffer";"years:int(1..4), salary:money";"the salary offer (monthly)";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Contracts.Negotiate";"SetInsurance";"form:enum(A,B,C,D), months:int";"insure the player (no question)";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Contracts.Negotiate";"SetPlayerBonus";"kind:enum(Goal,Points,Appearance,Champion,Place2to5,Place6to10,AvoidRelegation), percent:int";"a bonus for this player (PRÄMIEN)";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Contracts.Negotiate";"MakeOffer";"–";"ANGEBOT MACHEN: the player decides";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Bank";"ShowBank";"–";"balance, savings, credit line, season base";"—";"";"";"partial";"06-verein.md"
|
||||
"Bank";"OpenAccount";"–";"the finance overview (Bank.Account)";"—";"";"";"partial";"06-verein.md"
|
||||
"Bank";"OpenSavings";"–";"the fixed deposit (Bank.Savings)";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank";"OpenCredit";"[lender:enum(Bank,Manager1,Manager2,Manager3,Manager4)]";"the credit view (Bank.Credit)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Bank";"OpenRealEstate";"–";"real estate funds (Bank.RealEstate)";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank";"OpenShares";"–";"the stock market (Bank.Shares)";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank.Account";"ShowFinanceOverview";"–";"assets, debts and net worth";"—";"";"";"partial";"06-verein.md"
|
||||
"Bank.Account";"ShowAssetProfitLoss";"asset:int(0..11)";"profit/loss of a share";"E_ENGINE_GAP";"";"";"partial";"06-verein.md"
|
||||
"Bank.Savings";"ShowSavings";"–";"account and fixed deposit";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank.Savings";"Deposit";"amount:money(>0)";"account -> fixed deposit";"E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Bank.Savings";"Withdraw";"amount:money(>0)";"fixed deposit -> account";"E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Bank.Shares";"ListShares";"–";"the twelve shares";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank.Shares";"ShowShare";"asset:int(0..11)";"one share with its last 30 prices";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank.Shares";"ShareAdvice";"asset:int(0..11)";"the bank's tip for a share";"E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Bank.Shares";"BuyShares";"asset:int(0..11), count:int(>0)";"buy shares";"E_INSUFFICIENT_FUNDS, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Bank.Shares";"SellShares";"asset:int(0..11), count:int(>0)";"sell shares";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Bank.RealEstate";"ListRealEstate";"–";"the six real estate funds";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank.RealEstate";"BuyRealEstate";"type:int(0..5), units:int(>0)";"buy units";"E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Bank.RealEstate";"SellRealEstate";"type:int(0..5), units:int(>0)";"sell units";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"ShowCredit";"[lender:enum(Bank,Manager1..4)]";"the credit rows with the editable ranges";"—";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"SetCreditAmount";"amount:money";"AUSGEZAHLTER BETRAG: the credit";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"SetCreditPayment";"monthly:money";"the monthly payment: within 20 % of the annuity for a credit from a manager";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"SetCreditTerm";"months:int";"LAUFZEIT in months";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"RepayCredit";"amount:money | All";"RÜCKZAHLUNG: pay back (All = as much as possible)";"E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"ConfirmCredit";"–";"book the changes (asks about fees)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Bank.Credit";"CancelCredit";"–";"discard the changes";"—";"";"";"ready";"06-verein.md"
|
||||
"Stadium";"ShowStadium";"–";"facilities, maintenance and blocks";"—";"";"";"partial";"06-verein.md"
|
||||
"Stadium";"ShowFutureExpansion";"–";"Show Future Expansion. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Stadium";"QuoteBlockExpansion";"block:enum(A..H), seats:int, seated:bool, roofed:bool";"Quote Block Expansion. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"06-verein.md"
|
||||
"Stadium";"ConfirmBlockExpansion";"[tip:bool=false]";"Confirm Block Expansion. See current Help for behaviour and bounds.";"E_INSUFFICIENT_FUNDS";"";"";"partial";"06-verein.md"
|
||||
"Stadium";"DeclineBlockExpansion";"–";"Decline Block Expansion. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Stadium";"BuildFacility";"facility:enum(Floodlights,Scoreboard,PitchHeating,VipLounge)";"technical expansion (AUSBAUEN): tier and tip questions";"E_INSUFFICIENT_FUNDS, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Stadium";"Maintain";"item:enum(Pitch,Comfort,Condition,Safety)";"maintenance: tier and tip questions";"E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Stadium";"SetTicketPrice";"price:int(8..25)";"the ticket price (as on the desk)";"E_BAD_ARGUMENT";"";"";"partial";"06-verein.md"
|
||||
"Stadium";"OpenPeriphery";"–";"SICHT: PANORAMA (Stadium.Periphery)";"—";"";"";"ready";"06-verein.md"
|
||||
"Stadium";"OpenData";"–";"Open Data. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Stadium.Periphery";"ListPeriphery";"–";"the 14 objects: built, building, days";"—";"";"";"ready";"06-verein.md"
|
||||
"Stadium.Periphery";"QuotePeriphery";"object:int(0..13)";"the building firm's current offer (question)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Stadium.Periphery";"BuildPeriphery";"object:int(0..13), price:money";"accept the offer";"E_INSUFFICIENT_FUNDS, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Stadium.Periphery";"DeclinePeriphery";"object:int(0..13), price:money";"decline the offer";"—";"";"";"ready";"06-verein.md"
|
||||
"Stadium.Periphery";"OpenInterior";"–";"SICHT: INNEN (back to Stadium)";"—";"";"";"partial";"06-verein.md"
|
||||
"Stadium.Data";"ShowStadiumData";"[chart:enum(Spectators,Admission,StadiumValue,ExtraIncome,Income,Costs), mode:enum(Absolute,Relative)]";"Show Stadium Data. See current Help for behaviour and bounds.";"—";"";"";"partial";"06-verein.md"
|
||||
"Advertising";"ShowAdvertising";"–";"all boards, shirt, TV and the spending";"—";"";"";"ready";"06-verein.md"
|
||||
"Advertising";"ListAdOffers";"slot:enum(Board1..Board14,Shirt,Tv)";"the offers for a board, the shirt or TV (an expired contract: renewal first)";"E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Advertising";"AcceptAdOffer";"slot:enum, offer:int";"ANNEHMEN";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Advertising";"DeclineAdOffer";"–";"ABBRECHEN";"—";"";"";"ready";"06-verein.md"
|
||||
"Advertising";"SetSpending";"kind:enum(PublicRelations,FanCare), amount:money";"monthly budget for press work or fan care";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Advertising";"BuyFanItems";"amount:money";"buy fan articles (sold in 6-9 weeks)";"E_INSUFFICIENT_FUNDS, E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Environment";"ShowEnvironment";"–";"staff levels and the youth academy";"E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Environment";"SetStaffLevel";"role:enum(AssistantCoach,Doctor,Physio), level:int(0..6)";"click a staff tile: level 0..6, 5 000 a month each";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Environment";"SetYouthAcademy";"state:enum(On,Off)";"start (July/August) or stop the youth academy";"—";"";"";"ready";"06-verein.md"
|
||||
"Balance";"ShowBalance";"–";"all items, the view and the planned profit or loss";"E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Balance";"SetBalanceView";"view:enum(SoFar,Real,Future)";"left button: so far / real / future";"—";"";"";"ready";"06-verein.md"
|
||||
"Balance";"SetBalanceItem";"item:enum(IncomeShirt,IncomeBoards,IncomeTv,IncomePeriphery,IncomeRentInterest,IncomeMisc,ExpenseSalaries,ExpenseStadium,ExpenseYouth,ExpenseCoTrainer,ExpenseDoctor,ExpensePhysio,ExpenseTrainingCamp,ExpenseFanCare,ExpensePr,ExpenseInterest,ExpenseMisc,OtherHomeGames,AverageGate,TicketPrice), value:int";"change a planned value (views Real and Future)";"E_RULE, E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Balance";"TakeActuals";"–";"""Werte akt."": drop the own changes, back to the game's figures";"—";"";"";"ready";"06-verein.md"
|
||||
"Toto";"ShowToto";"–";"the eleven matches with your tips";"—";"";"";"ready";"06-verein.md"
|
||||
"Toto";"SetTip";"match:int(1..11), tip:enum(1,0,2)";"the tip for one match";"E_BAD_ARGUMENT";"";"";"ready";"06-verein.md"
|
||||
"Toto";"SetStake";"amount:money(>=0)";"the stake";"E_BAD_ARGUMENT, E_INSUFFICIENT_FUNDS";"";"";"ready";"06-verein.md"
|
||||
"Toto";"SubmitToto";"[stake:money, tips:list(11)]";"MACH ICH: hand in the coupon";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Toto";"ClearToto";"–";"all tips back to 1, stake 0";"—";"";"";"ready";"06-verein.md"
|
||||
"Friendlies";"ListFriendlyOpponents";"[league:int(0..8)]";"the clubs of a league (default: own)";"E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Friendlies";"ProposeFriendly";"club:Club, venue:enum(Home,Away)";"the offer: costs and who pays";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Friendlies";"ListFreeDates";"–";"the days the friendly can be played";"—";"";"";"ready";"06-verein.md"
|
||||
"Friendlies";"SetFriendlyDate";"date:date";"book the friendly on a free date (YYYY-MM-DD)";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Reschedule";"ListRescheduleGames";"–";"own home league matches that can be moved";"E_MODE_LOCKED";"";"";"ready";"06-verein.md"
|
||||
"Reschedule";"ListRescheduleDates";"game:date";"the days the match can be moved to";"—";"";"";"ready";"06-verein.md"
|
||||
"Reschedule";"MoveGame";"game:date, to:date";"move the match to a free day";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Reschedule";"ListMovedGames";"–";"moved matches that can still be taken back (new date)";"—";"";"";"ready";"06-verein.md"
|
||||
"Reschedule";"UndoMove";"game:date";"take a move back (game = the new date); the match is played on its matchday again";"E_RULE";"";"";"ready";"06-verein.md"
|
||||
"Match";"Step";"[minutes:int=1]";"let the clock run n minutes (default 1)";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"Run";"[until:enum(Halftime,End)=End]";"run to half time or to the end of the day";"—";"";"";"ready";"07-spieltag.md"
|
||||
"Match";"Pause";"–";"Pause. See current Help for behaviour and bounds.";"—";"";"";"gap";"07-spieltag.md"
|
||||
"Match";"Resume";"–";"Resume. See current Help for behaviour and bounds.";"—";"";"";"gap";"07-spieltag.md"
|
||||
"Match";"ShowMatchStats";"[match:int]";"the scoreboard: score, chances, cards, spectators, weather";"—";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"Watch";"match:int";"Watch. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"Substitute";"out:Player, in:Player";"a substitution: a player leaves, a bench player comes on";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"SetFormation";"slot:int(1..8)";"not during a match (move single players with MovePlayer)";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"MovePlayer";"player:Player, depth:int, lane:int";"place a starter on another position for the rest of the match (from minute 3)";"E_RULE";"";"";"ready";"07-spieltag.md"
|
||||
"Match";"SetTactic";"item:int(0..7), value:int";"change a tactic setting during the match (item 0 ends the assistant's D/O control)";"E_RULE";"";"";"ready";"07-spieltag.md"
|
||||
"Match";"ShowTactics";"–";"the eight tactic settings of your team in this match";"E_RULE";"";"";"ready";"07-spieltag.md"
|
||||
"Match";"SetMarking";"own:Player, opponent:Player";"Set Marking. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"SetOrder";"player:Player, aspect:enum, value:int";"Set Order. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Match";"Open";"window:enum(Lineup,Tactics,Table,Fixtures,Settings)";"Open. See current Help for behaviour and bounds.";"—";"";"";"gap";"07-spieltag.md"
|
||||
"Match";"ShowSquad";"–";"your team on the pitch and on the bench";"—";"";"";"partial";"07-spieltag.md"
|
||||
"Desktop|Lineup|Friendlies";"ShowNationalSquad";"–";"Show National Squad. See current Help for behaviour and bounds.";"—";"";"";"partial";"07-spieltag.md"
|
||||
"Desktop|Lineup|Friendlies";"NationalSquadAdd";"player:Player";"National Squad Add. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"Desktop|Lineup|Friendlies";"NationalSquadRemove";"player:Player";"National Squad Remove. See current Help for behaviour and bounds.";"E_RULE";"";"";"partial";"07-spieltag.md"
|
||||
"GameEnd";"ShowHighScore";"–";"Show High Score. See current Help for behaviour and bounds.";"—";"";"";"ready";"07-spieltag.md"
|
||||
"GameEnd";"NewGame";"duration:int(1..5), difficulty:int(1..10), managers:int(1..4), mode:int(1..3), league:bool, world:bool";"New Game. See current Help for behaviour and bounds.";"E_BAD_ARGUMENT";"";"";"ready";"07-spieltag.md"
|
||||
"GameEnd";"LoadGame";"filename:string";"Load Game. See current Help for behaviour and bounds.";"E_IO";"";"";"ready";"07-spieltag.md"
|
||||
"Desktop";"ShowSportschau";"[part:enum(Results,TimeBar,BestEleven,MatchdayOverview)]";"Show Sportschau. See current Help for behaviour and bounds.";"E_ENGINE_GAP";"";"";"gap";"07-spieltag.md"
|
||||
"Settings";"ShowSettings";"[group:enum(Results,Sound,Game,Limits,MenuEdit,Functions,Sportschau,Display,Values,Delays)]";"the switch field A1-T9";"—";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"ShowSwitch";"key:string";"one switch";"E_BAD_ARGUMENT";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"SetSwitch";"key:string, value:int";"set a switch (on/off or a number)";"E_BAD_ARGUMENT, E_PHASE_LOCKED";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"IncreaseSwitch";"key:string";"the plus field (columns 8, 9)";"E_BAD_ARGUMENT";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"DecreaseSwitch";"key:string";"the minus field (columns 8, 9)";"E_BAD_ARGUMENT";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"LoadSettings";"file:string";"Load Settings. See current Help for behaviour and bounds.";"E_IO";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"SaveSettings";"file:string";"Save Settings. See current Help for behaviour and bounds.";"E_IO";"";"";"partial";"08-einstellungen.md"
|
||||
"Settings";"ShowReadme";"–";"Show Readme. See current Help for behaviour and bounds.";"E_IO";"";"";"partial";"08-einstellungen.md"
|
||||
"*";"HarnessState";"[path:string]";"Harness State. See current Help for behaviour and bounds.";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessHash";"–";"Harness Hash. See current Help for behaviour and bounds.";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessInvariants";"–";"Harness Invariants. See current Help for behaviour and bounds.";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessAutopilot";"player:int(1..4), policy:enum(Default,Saver,Spender,Random,Off)";"Harness Autopilot. See current Help for behaviour and bounds.";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessFast";"matchdays:int, [until:enum(Matchday,Season,GameEnd)]";"Harness Fast. See current Help for behaviour and bounds.";"E_RULE";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessCoverage";"–";"Harness Coverage. See current Help for behaviour and bounds.";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessSeed";"–";"Harness Seed. See current Help for behaviour and bounds.";"—";"";"";"cli";"01-grundlagen.md"
|
||||
"*";"HarnessExpect";"text:string";"Harness Expect. See current Help for behaviour and bounds.";"E_RULE";"";"";"cli";"01-grundlagen.md"
|
||||
|
@@ -0,0 +1,13 @@
|
||||
# Compatibility decisions
|
||||
|
||||
OpenBMH aims to preserve the familiar game while handling malformed input and unsafe edge cases explicitly. A reconstruction can remain faithful without reproducing a crash or pretending to implement an unknown path.
|
||||
|
||||
- Content such as names, text, graphics and edition-specific tables is loaded from the user's installation. OpenBMH's shared rule base supplies simulation values; selecting another data edition does not select a separate engine.
|
||||
- Safety checks reject transactions that would exhaust required return capacity, use stale identities or lose a valid state. Unsupported operations report their limitation rather than inventing an outcome.
|
||||
- Calendar progression handles boundary days and seasonal transitions without relying on unsafe fixed-day assumptions.
|
||||
- Saves are written from the committed session state. Saving does not deliberately replay unrelated game actions.
|
||||
- The reconstruction uses two deterministic random generators with explicit integer semantics. This supports reproducible runs, but is not a promise of complete bit-for-bit equivalence to every original edition or across changed engine versions.
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,47 @@
|
||||
# Writing a console client or agent
|
||||
|
||||
The console is a local control interface for one running career. Human clients, bots and alternative frontends use the same actions and rule checks. Start with [the console reference](CLI_CONCEPT/README.md); use runtime `ListOptions` and `Help` rather than guessing a command from a graphical label.
|
||||
|
||||
## Choose a transport
|
||||
|
||||
For a single process, start `openbmh_cli --console --data "path/to/game" --saves "path/to/saves"`. Send command lines on stdin and finish each block with `go.`. `--json` provides structured output records.
|
||||
|
||||
For separate manager processes, start a local mailbox server:
|
||||
|
||||
```sh
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves" --serve mailbox --seats 4 --seed 1
|
||||
```
|
||||
|
||||
A client sends one block on stdin to:
|
||||
|
||||
```sh
|
||||
openbmh_cli --send mailbox/seat1 --timeout 3600
|
||||
```
|
||||
|
||||
The client still supplies a terminating `go.` line. Seats are numbered 1–4 and represent human manager slots, not runtime team IDs. Submit one request at a time for each seat. A long-running `WaitTurn` or match-clock request must finish before another client uses that seat. A timeout or interrupted shell client does not establish that the server cancelled the game action.
|
||||
|
||||
Alternatively, `--listen PORT --seats N` binds a local socket on `127.0.0.1`. A connection selects `SEAT k` when seats are enabled. Blocks end with `go.` and responses with a line containing only `.`. Keep one connection/request owner per seat. See `--help` for supported combinations of transport and log options.
|
||||
|
||||
## Track ownership and the whole response
|
||||
|
||||
Keep the current seat, window, manager/club identity, phase and pending question/editor. Parse the entire response before choosing the next action. A question can arrive in information produced during another manager's turn or a suspended calendar advance. Match the question's recipient to this client; answer with its actual ID and listed option.
|
||||
|
||||
The seat hub can prefix a response with information accumulated while other managers played. Do not mistake an old desktop in that feed for the current owned projection. Retain questions and errors from the full response, then use the current own state for financial or squad decisions. A new window header is not emitted after every operation. Status can instead report `matchday running, minute N`.
|
||||
|
||||
Use `WaitTurn` when another seat owns management. At a desktop, apply a short batch of independent decisions, then put `Kickoff` last. Reinspect after actions that open a question, negotiate a contract or change the meaning of a row. Unknown questions require a policy decision; `GoBack` can commit a default or cancel an editor and must not be used as a generic acknowledgement.
|
||||
|
||||
## Shared matches and calendar boundaries
|
||||
|
||||
In a stepped match, `Run` and `Step` participate in a barrier across the required seats. Put the clock command last. Read the returned actual minute and phase before choosing another stop; do not request half-time after that boundary. A manager without a fixture still participates in the barrier but should not issue substitutions or tactical edits for another team's match.
|
||||
|
||||
Questions and staged offer editors can suspend a calendar operation. Finish the owning question/editor before requesting another advance. Once an answered clock request returns without advancement, inspect why before sending another readiness request; blindly replaying a mutation can duplicate an effect.
|
||||
|
||||
A useful automated policy inspects budget, advertising, contracts, squad availability and tactics at deliberate intervals, using explicit rules and bounds. `Advice` supplies observations, not a complete strategy. Count actual `season_index` changes and inspect `phase` at year end; a historical table or summary does not constitute another completed season.
|
||||
|
||||
## Reproducibility and recovery
|
||||
|
||||
Record the binary version, data edition, seed, time mode and the exact submitted blocks when a reproducible session matters. The seed alone is insufficient if the initial save, data or command order differs. `--log`, `--replay` and, for supported multi-seat sessions, `--resume` provide execution records; a replay must use compatible inputs.
|
||||
|
||||
Keep an independent input receipt. Mailbox request files are transport state: a held request may be rewritten to `WaitTurn`, including a request originally submitted as a clock command. Such a file is not proof of what was first sent. Preserve responses and raw bytes before decoding diagnostics. Do not publish logs containing proprietary game text, saves or personal data.
|
||||
|
||||
For restart, use a fresh mailbox, pin the intended binary and verify the recovered current phase, manager and pending operation. Do not silently adopt an old client request or run two processes against the same seat. Normal saved games and replay are the supported starting points; editing native state to get past a question defeats the ownership checks the client is meant to exercise.
|
||||
@@ -0,0 +1,37 @@
|
||||
# Intentional differences from the original
|
||||
|
||||
Generated from source comment markers by `tools/public_release/collect_differences.py`.
|
||||
|
||||
See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These entries
|
||||
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/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/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): omits DOS drive and delete buttons in the directory-confined save/load view.
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
# Random generators
|
||||
|
||||
OpenBMH uses two explicit stateful generators in `src/game/random.hpp`. Frontends do not create gameplay randomness. Save and rollback operations must preserve the relevant generator state and call order.
|
||||
|
||||
## General generator
|
||||
|
||||
The compatibility generator uses a 32-bit unsigned linear recurrence:
|
||||
|
||||
```text
|
||||
seed = seed * 0x41C64E6D + 0x3039 (modulo 2^32)
|
||||
r = (seed >> 16) & 0x7FFF
|
||||
n = hi - lo + 1
|
||||
product = signed32(unsigned32(r) * unsigned32(n))
|
||||
result = lo + product / 32768
|
||||
```
|
||||
|
||||
The product wraps at 32 bits and signed division truncates toward zero. For an empty range it returns the lower bound without drawing. A run's initial seed is supplied explicitly by the session/CLI when reproducibility is required.
|
||||
|
||||
## Game generator
|
||||
|
||||
The second stream has a separate recurrence and can be reseeded by defined game operations:
|
||||
|
||||
```text
|
||||
seed = signed32(unsigned32(seed) * 16 + 0xA7) % 4000000
|
||||
product = signed32(unsigned32(seed) * unsigned32(hi - lo + 1))
|
||||
result = product / 4000000 + lo
|
||||
```
|
||||
|
||||
Signed division truncates toward zero; overflow in the indicated products wraps at 32 bits before signed interpretation. Replacing this with floating-point arithmetic or a standard-library distribution changes results. Negative intermediate values must retain their specified semantics.
|
||||
|
||||
Observing or rendering a value should not draw random numbers unless opening that actual game operation requires it. Transactional failures restore both streams with the game state. A seed alone is not a complete replay specification: engine version, data, options and command order also matter.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Roadmap
|
||||
|
||||
OpenBMH combines a playable reconstruction with a foundation for extension. These milestones describe direction and dependencies, not promised dates.
|
||||
|
||||
## 0.1: a usable engine
|
||||
|
||||
Career management, matches, finances, transfers, original-style SDL2 screens, audio and a console share the same session logic. German game data is the primary target; Football Limited support is experimental. Compatibility and remaining limitations are documented in the [release notes](release/0.1/RELEASE_NOTES.md).
|
||||
|
||||
## 0.15: broader English compatibility
|
||||
|
||||
Complete edition-specific loading, presentation, competitions and sound support. Imported content determines names, text, clubs and league organisation; a shared engine rule base defines the simulation.
|
||||
|
||||
## 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.
|
||||
|
||||
## 0.3: configurable rules
|
||||
|
||||
Expose rule values and balance choices as configuration, with reproducible simulations to assess changes. Improve tactical automation, transfer decisions and scoring distributions through documented changes rather than hidden edition-specific branches.
|
||||
|
||||
## 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.
|
||||
|
||||
## 0.5: independently distributable content
|
||||
|
||||
Provide original or freely licensed graphics, sound and generated football worlds so that OpenBMH can be played without proprietary game data. Support editors, new competitions and multiplayer clients built on the same engine interfaces.
|
||||
|
||||
The typed model and open format are prerequisites for flexible competitions, configurable rules and new content. See [architecture](architecture.md) for the current boundaries and [compatibility decisions](COMPATIBILITY.md) for intentional departures.
|
||||
@@ -0,0 +1,39 @@
|
||||
# Architecture
|
||||
|
||||
OpenBMH is a C++20 engine with graphical and console frontends. The implementation reads externally supplied game data; it does not execute the original program. See [file formats](formats/README.md) for the compatibility representations and [roadmap](ROADMAP.md) for the planned typed model.
|
||||
|
||||
## Layers
|
||||
|
||||
| Directory | Responsibility |
|
||||
|---|---|
|
||||
| `src/formats` | Binary readers, explicit-width records, palettes, fonts, images, text, executable-data loading and save containers |
|
||||
| `src/game` | Game state, random generators, career setup, scheduling, match simulation, accounting and weekly/monthly/seasonal progression |
|
||||
| `src/app` | CareerSession, shared actions, revisions, ownership, transactional publication and rollback |
|
||||
| `src/ui` | View projections, rendering and input interpretation for game screens |
|
||||
| `src/cli` | Command language, structured protocol, console windows and multi-client seat routing |
|
||||
| `src/audio` | Bank decoding, synthesis, playback and cues, without authority to change gameplay |
|
||||
| `src/launch` | Locating user data, archive extraction, edition normalisation and file selection |
|
||||
|
||||
`bmhcore` contains the format and game layers. `bmhui`, `openbmh_audio` and the application session provide reusable pieces above it. Frontends should translate actions and display results; they should not introduce independent transfer, calendar or financial rules.
|
||||
|
||||
## Session boundary
|
||||
|
||||
`CareerSession` owns the live game, the two random streams and progression state. Requests identify the manager and the revision they observed. Shared actions validate that identity, stage state and random effects, and publish supported results together. Rejected requests must not leave partial transactions.
|
||||
|
||||
Some calendar operations need synchronous human decisions. Their presenters own a staged state until the question or editor returns. A console worker hands control to the input thread while paused; exactly one thread operates on that transaction at a time. Cancellation, failure and process shutdown must release the owner and preserve the transaction's rollback contract. A view must not read live state as though it were the paused staged state.
|
||||
|
||||
## Calendar and matches
|
||||
|
||||
The turn driver moves between manager desks, match clocks and calendar events. Weekly, monthly and seasonal processing can produce decisions as well as simulation results. Match groups contain the day's competitions; a manager can intervene only in a group involving that manager's team. A multi-client match clock advances at a barrier shared by all seats.
|
||||
|
||||
## Compatibility state
|
||||
|
||||
The current game model combines interpreted vectors with fixed-layout compatibility blocks. Identifiers are not interchangeable: a club's stable identity, current runtime team index, squad row and player id represent different things. Guard each at its boundary. Fixed offsets belong to file/layout code; preserve integer widths and signedness when porting calculations.
|
||||
|
||||
Legacy saves serialize blocks in a fixed order and store name pools separately. Runtime UI owners, pending input and frontend capabilities are not additional save fields. See [FBM](formats/FBM.md), [state records](formats/STATE.md) and [RNG](RNG.md).
|
||||
|
||||
## Public interfaces and validation
|
||||
|
||||
The [console reference](CLI_CONCEPT/README.md) documents window commands. [protocol.md](protocol.md) describes structured requests, and [CONSOLE_CLIENTS.md](CONSOLE_CLIENTS.md) explains safe client ownership and batching. Prefer shared projections/actions when adding another frontend.
|
||||
|
||||
Use synthetic data for public tests and locally supplied installations only for data-dependent checks. Renderer tests, simulation tests and target-platform runtime checks answer different questions; document what each validates. See [CONTRIBUTING.md](../CONTRIBUTING.md).
|
||||
@@ -0,0 +1,7 @@
|
||||
# Palette: `M3PC.COL`
|
||||
|
||||
The file contains 256 RGB triplets: 768 bytes, with each channel a six-bit VGA DAC value. `load_palette` in `src/formats/palette.cpp` requires at least that size and ignores trailing data.
|
||||
|
||||
A channel is masked with `0x3f` and expanded to eight bits using `(v * 255 + 31) / 63`. Rendering uses opaque alpha unless the drawing operation supplies transparency separately. No palette index is inherently transparent.
|
||||
|
||||
Some [VGA](VGA.md) images supply a separate palette. The same channel conversion applies. `Palette::nearest` is an implementation helper for colour matching, not an additional file field.
|
||||
@@ -0,0 +1,11 @@
|
||||
# Legacy installation configuration
|
||||
|
||||
`SOUND.CFG` and `PFAD.MAN` belong to the DOS installation. OpenBMH uses host SDL audio and its data-directory configuration instead of DOS ports, IRQs, DMA channels or path-prefix files.
|
||||
|
||||
## `SOUND.CFG`
|
||||
|
||||
The 30-byte file begins with the nine-byte `ALPTRAUM!` signature. A marker byte and two words precede two eight-byte device records. Each record contains four little-endian words representing the enabled state and legacy Sound Blaster configuration. These values describe the old machine, not valid SDL device settings.
|
||||
|
||||
## `PFAD.MAN`
|
||||
|
||||
This short legacy text file supplies a DOS path prefix. OpenBMH accepts a game location through startup selection or `--data`. Do not copy machine-specific DOS configuration into a new OpenBMH configuration file.
|
||||
@@ -0,0 +1,7 @@
|
||||
# Switch settings: `.EIN` and saved settings
|
||||
|
||||
The legacy settings block is 180 bytes: twenty rows of nine bytes, without a header or encryption. The same block is retained in [FBM](FBM.md). OpenBMH's settings actions operate on the career's block; standalone `.EIN` import is not the save mechanism.
|
||||
|
||||
Rows are indexed 0–19 and columns 0–8 in code. On-screen row letters and one-based column labels are presentation conventions. For supported boolean cells, zero means enabled and one means disabled. Some cells carry high-bit flags, reserved values or numeric settings; do not normalise the whole block to booleans.
|
||||
|
||||
`src/game/state.hpp`, the settings action implementation and the settings projection define supported cells and their bounds. Availability can also depend on the current frontend's audio capabilities. A failed audio device is not represented by rewriting the stored music preference. Clients should use the projected availability and normal actions rather than editing raw settings bytes.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,33 @@
|
||||
# Savegame container: `.FBM`
|
||||
|
||||
`src/formats/fbm.cpp` reads the outer container. `src/formats/savestate.cpp` splits the decoded state; `src/game/save.cpp` writes the normal save representation. Saving goes through `CareerSession` so the manager, phase and committed state are validated.
|
||||
|
||||
## Container layout
|
||||
|
||||
| Part | Size | Meaning |
|
||||
|---|---|---|
|
||||
| Plain header | Variable | Manager/date information for the load list |
|
||||
| Signature area | 10 bytes | Eight-byte `KRON_FBM` signature and two following bytes |
|
||||
| First ID | u32 | Container identifier |
|
||||
| Version | 6 bytes | NUL-terminated version field, normally `V2.24` for the supported state layout |
|
||||
| Second ID | u32 | Save identifier |
|
||||
| Random byte | u8 | Header value |
|
||||
| Initial key | u8 | Rolling-cipher seed |
|
||||
| Stream | Remaining bytes except checksum | Encrypted state and name pools |
|
||||
| Checksum | u8 | Initial key plus all decoded stream bytes, modulo 256 |
|
||||
|
||||
The loader searches for the signature after the plain header and checks the fixed fields fit. A bad checksum is represented by `Savegame::checksum_ok`; callers must decide whether to accept the save. Neither the cipher nor this checksum provides security or authenticity.
|
||||
|
||||
For each byte, decrypt with `plain = (encrypted - key) XOR key`, or encrypt with `encrypted = (plain XOR key) + key`. Reduce all byte arithmetic modulo 256, then subtract `0x29` from the key before the next byte.
|
||||
|
||||
## Decoded stream
|
||||
|
||||
The supported layout contains a fixed ordered block table, followed by four name pools. Blocks have no tags or encoded lengths. Their sizes depend on the layout and database counts; `kBlocks` in `src/formats/savestate.cpp` is the authoritative order. Some blocks describe fixed arrays and others hold the contents of legacy dynamically allocated tables. The final optional team-record block is present only when its saved presence field is nonzero.
|
||||
|
||||
Each name pool has a u16 byte length followed by that many bytes, in club, player, referee and stadium order. These pools preserve renamed entities. The splitter rejects missing/truncated blocks or pools and requires exact stream consumption. See [STATE](STATE.md) for interpreted records and [M3D](M3D.md) for pool references.
|
||||
|
||||
## Edition compatibility
|
||||
|
||||
Original Football Limited V2.20 saves use a different state block list despite sharing the signature and rolling cipher. They are not interchangeable with the V2.24 layout. Reading an English installation and importing its original saves are separate features; do not edit a version string to bypass the distinction. OpenBMH's own English careers use the session's supported save representation.
|
||||
|
||||
Keep a backup before using a save with another engine version. Unknown bytes retained for compatibility are not safe targets for direct client manipulation.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Bitmap fonts: `.FNT`
|
||||
|
||||
`src/formats/font.cpp` loads a 28-byte little-endian header followed by a bitmap and glyph tables. The layout resembles an Amiga TextFont with pointer slots stored as placeholders.
|
||||
|
||||
| Offset | Type | Meaning |
|
||||
|---|---|---|
|
||||
| 0 | u16 | Glyph height |
|
||||
| 2 | u8 | Style |
|
||||
| 3 | u8 | Flags; value 2 omits the spacing table |
|
||||
| 4 | u16 | Nominal advance |
|
||||
| 6 | u16 | Baseline |
|
||||
| 8 | u8 | First character |
|
||||
| 9 | u8 | Last character |
|
||||
| 10 | u16 | Reserved |
|
||||
| 12 | u32 | Bitmap pointer placeholder |
|
||||
| 16 | u16 | Bytes per bitmap row |
|
||||
| 18 | u16 | Reserved |
|
||||
| 20 | u32 | Glyph-location pointer placeholder |
|
||||
| 24 | u32 | Spacing pointer placeholder |
|
||||
|
||||
Let `n = last - first + 2`; the extra entry is the replacement glyph. After the header come:
|
||||
|
||||
1. `height * row_bytes` bytes of one-bit bitmap, most significant bit first.
|
||||
2. `n` pairs of u16 bit offset and bit width.
|
||||
3. `n` signed 16-bit advances, unless flags equal 2. Fixed-width glyphs use the nominal advance instead.
|
||||
|
||||
The loader requires the computed total size to match. Characters outside the supported range use the replacement glyph. Legacy character conversion is described in the [format index](README.md); use the supplied font with its matching text encoding.
|
||||
@@ -0,0 +1,15 @@
|
||||
# Executable images used as data
|
||||
|
||||
OpenBMH reads tables and text from the user's original executable. It does not execute that program. The file is not part of the OpenBMH distribution.
|
||||
|
||||
## German LE image
|
||||
|
||||
`src/formats/le.cpp` loads the DOS/4GW Linear Executable format. The DOS header's u32 field at `0x3c` locates the LE header. Object records define virtual sizes, image bases and page ranges. Page-map entries locate file data; unloaded areas are zero-filled. The image applies supported internal relocation records before consumers follow pointers.
|
||||
|
||||
The reader supports the internal offset/selector forms required by the installation. External fixups are rejected. Bounds and object validation belong to the loader; arbitrary executable formats are not accepted merely because they begin with an MZ stub. String access decodes the legacy single-byte encoding.
|
||||
|
||||
## English X-32 image
|
||||
|
||||
Football Limited uses a different executable layout. `src/launch/fltd.cpp` prepares supported English executable data and maps the required tables into the engine's expected data view. It is not an instruction emulator or a conversion of English game rules into a separate engine.
|
||||
|
||||
The [executable layout reference](EXECUTABLE_LAYOUT.md) describes supported table locations and semantic layout identifiers. A byte address is meaningful only with its edition and image layout. Application APIs should expose the table's meaning rather than an address-derived field name.
|
||||
@@ -0,0 +1,37 @@
|
||||
# Master database: `M3D.MAN` / `M3E.MAN`
|
||||
|
||||
`load_database` in `src/formats/m3d.cpp` reads an unencrypted sequence of string pools and parallel tables. Counts are supplied by `DbCounts`, not stored in the file. Default counts are 419 clubs, 2,574 players, 168 team records and an auxiliary extent of 3,096. Readers must agree on these counts; changing a count without rebuilding dependent tables does not define a valid new database.
|
||||
|
||||
Let `C`, `P`, `T` and `A` denote those counts. The stream order is:
|
||||
|
||||
| Size | Content |
|
||||
|---|---|
|
||||
| 4 × u16 | Byte lengths of club, player, referee and stadium name pools |
|
||||
| `A + 50` bytes | Player bonus/flag table and auxiliary entries |
|
||||
| Sum of pool lengths | Four consecutive NUL-separated name pools |
|
||||
| `C` × u16 | Club name offsets into pool 0 |
|
||||
| `P` × u16 | Player name offsets into pool 1 |
|
||||
| 100 bytes | Auxiliary table |
|
||||
| `T` × u16 | Auxiliary team table |
|
||||
| `C` × u16 | Club crest/flag words; low nine bits select a crest |
|
||||
| 251 + 189 + 50 + 419 + 168 bytes | Five fixed-size auxiliary tables |
|
||||
| `2 * (A - 4) + 108` bytes | Squad-list words |
|
||||
| `P` × u32, three times | Three parallel player-word tables |
|
||||
|
||||
The loader checks bounds and requires complete consumption. Pool references are byte offsets; they are neither club IDs nor Unicode indices. The name pools also occur in [savegame trailers](FBM.md). A career initialises and reorders parts of the database, so its runtime team IDs can differ from the master club index.
|
||||
|
||||
## Player words
|
||||
|
||||
A squad-list word stores a twelve-bit player ID and four flag bits. Player ID `0xfff` means no player. The `Player` accessors in `src/formats/m3d.hpp` interpret the three words in file order:
|
||||
|
||||
| Word | Bits | Meaning |
|
||||
|---|---|---|
|
||||
| 1 | 0–6 | Form |
|
||||
| 1 | 7–13 | Technique |
|
||||
| 1 | 14–20 | Condition |
|
||||
| 2 | 0–13 | Seven two-bit skills: teamplay, speed, shooting, passing, tackling, free kick, corner |
|
||||
| 2 | 27–31 | Nationality |
|
||||
| 3 | 0–1 | Position: goalkeeper, defender, midfielder, forward |
|
||||
| 3 | 21–25 | Age minus 16 |
|
||||
|
||||
Other bits carry additional state or remain uninterpreted by these accessors. Preserve them when changing a supported field. Display strength is `min((((form >> 3) + 94) * (technique + condition) / 100) / 2, 99)` with integer division in that order. It is a derived value, not an extra database field.
|
||||
@@ -0,0 +1,7 @@
|
||||
# Formation coordinates: `M3.DAT`
|
||||
|
||||
The file is a 1,408-byte raw block containing four 352-byte manager slots. Each slot contains an outdoor and indoor set, each with eight 22-byte formation records.
|
||||
|
||||
A record stores eleven horizontal coordinates followed by eleven vertical coordinates. For a formation `f` and player slot `p`, the horizontal coordinate is at `set_base + f * 22 + p`; the vertical coordinate is eleven bytes later. The indoor set begins 176 bytes into the manager slot.
|
||||
|
||||
Career initialisation copies the first manager slot over the other three. Subsequently the manager-specific block is retained in [FBM](FBM.md). The semantic accessor is `GameState::formation_position` in `src/game/state.cpp`. Coordinates belong to the game's pitch grid, not directly to screen pixels.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Desktop layout: `.MEN`
|
||||
|
||||
A desktop layout is 864 bytes: 54 entries of 16 bytes, without a header or encryption. `src/ui/desk_state.cpp` interprets the list. New careers initialise manager slots from the installation's layout; saved careers retain their layouts in [FBM](FBM.md).
|
||||
|
||||
Entry zero is the list head. Byte 5 contains the first visible entry; each following entry uses byte 5 for its successor and byte 6 for its predecessor. Index zero terminates a chain and `0xff` denotes an unlisted entry. The reader checks indices and detects cycles.
|
||||
|
||||
| Offset within entry | Type | Meaning |
|
||||
|---|---|---|
|
||||
| 0 | u16 | Horizontal coordinate; bit `0x1000` hides the entry |
|
||||
| 2 | u8 | Vertical coordinate |
|
||||
| 3 | u8 | Width |
|
||||
| 4 | u8 | Height |
|
||||
| 5 | u8 | Next entry |
|
||||
| 6 | u8 | Previous entry |
|
||||
| 7–11 | bytes | Reserved |
|
||||
| 12 | u8 | Item kind |
|
||||
| 13 | u8 | Drawer state; bit 7 indicates open |
|
||||
| 14–15 | bytes | Reserved |
|
||||
|
||||
Icon kinds occupy 0–29; drawer kinds occupy 50–72. The graphical client decides which kinds it can display and which actions are available in the current mode. A kind number is not a console window ID. Unrecognised or inactive layout data must not be interpreted as an executable action.
|
||||
@@ -0,0 +1,25 @@
|
||||
# File formats
|
||||
|
||||
OpenBMH reads files from a game installation supplied by the user. This directory documents their structure and the implementation's interfaces; it does not distribute game content or inventories of extracted text or artwork.
|
||||
|
||||
Unless a page says otherwise, integer fields are little endian. Legacy strings use a single-byte encoding; the German character substitutions are handled by `iso646de_to_utf8` in `src/formats/binary.cpp`. Text presented to clients is converted to UTF-8. Do not interpret a legacy byte offset as a Unicode character index.
|
||||
|
||||
| Data | Files | Documentation | Implementation |
|
||||
|---|---|---|---|
|
||||
| Palette | `M3PC.COL` | [COL](COL.md) | `src/formats/palette.cpp` |
|
||||
| Indexed images | `KB/*.VGA`, `W/*.VGA` | [VGA](VGA.md) | `src/formats/vga.cpp` |
|
||||
| Bitmap fonts | `F/*.FNT` | [FNT](FNT.md) | `src/formats/font.cpp` |
|
||||
| Text database | `TEXTD.BLK`, `TEXTE.BLK` | [TEXTD](TEXTD.md) | `src/formats/textd.cpp` |
|
||||
| Master database | `M3D.MAN`, `M3E.MAN` | [M3D](M3D.md) | `src/formats/m3d.cpp` |
|
||||
| Desktop layout | `M3.MEN`, `*.MEN` | [M3MEN](M3MEN.md) | `src/ui/desk_state.cpp` |
|
||||
| Formation coordinates | `M3.DAT` | [M3DAT](M3DAT.md) | `src/game/state.cpp` |
|
||||
| Settings | `*.EIN`, saved settings block | [EIN](EIN.md) | `src/game/state.hpp` |
|
||||
| Save container and state | `*.FBM` | [FBM](FBM.md), [STATE](STATE.md) | `src/formats/fbm.cpp`, `savestate.cpp` |
|
||||
| Legacy configuration | `SOUND.CFG`, `PFAD.MAN` | [CONFIG](CONFIG.md) | Not used for host device configuration |
|
||||
| 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 |
|
||||
|
||||
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.
|
||||
|
||||
The loaders and accessors are authoritative for supported bounds and validation. Unknown fields are preserved where required by save compatibility; an unexplained value is not an extension point. File offsets and record strides here describe formats, not stable application API names.
|
||||
@@ -0,0 +1,36 @@
|
||||
# Audio containers: `S/2000` through `S/2003`
|
||||
|
||||
`src/audio/container.cpp` validates the sound containers and decodes bounded PCM samples. `src/audio/original.cpp` implements the supported music sequencer, OPL instrument path, sample channel and effect dispatch. Audio resources and instrument values come from the user's installation; none are distributed here.
|
||||
|
||||
## Container structure
|
||||
|
||||
| Offset | Size | Meaning |
|
||||
|---|---|---|
|
||||
| 0 | 4 | `FORM` signature |
|
||||
| 4 | u32, little endian | Declared length |
|
||||
| 8 | 8 | `ALPTRAUM` type |
|
||||
| 16 | Variable | Consecutive chunks |
|
||||
|
||||
Each chunk has a four-byte ID, a little-endian u32 payload length and its payload. Unlike standard padded IFF chunks, these chunks are adjacent without an alignment byte. The walker rejects overflows and requires the final chunk to end at the file boundary.
|
||||
|
||||
Music banks contain `HEDR`, `SONG`, `TRCK`, `PART`, `INST` and `SAMP` chunks. The effects bank uses `HEDR`, `SEFX`, `INST` and `SAMP`. The usual FORM length excludes the first eight bytes. The supported effects variant instead declares the whole file size; this exception is accepted only with its validated fixed chunk layout.
|
||||
|
||||
## PCM samples
|
||||
|
||||
A `SAMP` payload starts with two u16 words: a header field and the sample count. Each sample has a 16-byte descriptor followed by a shared unsigned eight-bit mono data area. Within a descriptor:
|
||||
|
||||
| Offset | Type | Meaning |
|
||||
|---|---|---|
|
||||
| 0 | u16 | Start relative to the sample-data area |
|
||||
| 2 | u16 | Length in bytes |
|
||||
| 8 | u16 | Sample rate |
|
||||
|
||||
`decode_sample` checks the descriptor table and sample bounds, rejects empty samples and validates the rate. Conversion to signed sixteen-bit PCM is `(value - 128) * 256`.
|
||||
|
||||
## Sequencing and effects
|
||||
|
||||
`SONG`, `TRCK` and `PART` provide sequence order and timed note events; `INST` supplies instrument records. `OriginalSynth` schedules the supported register and sample operations using a deterministic audio tick. Nuked OPL3 renders the OPL-compatible register stream. This audio clock is separate from career random generators and match time.
|
||||
|
||||
The effects table has a four-byte prefix and sixteen-byte records. Instrument-backed effects and sample-backed effects use separate paths. `decode_original_cue` alone supports the direct sample-backed subset; this does not mean the full synthesiser lacks the instrument path. Music and effects settings control playback, while actual device availability belongs to the frontend. English audio compatibility remains subject to the release's experimental edition limits.
|
||||
|
||||
Sample-domain output checks establish decoder behaviour, not the timing or audible quality of a physical audio device. Platform listening and device checks are separate validation work.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Interpreting saved game state
|
||||
|
||||
The [FBM container](FBM.md) contains fixed-order state blocks rather than a self-describing object graph. `src/formats/savestate.cpp` defines the physical layout; `src/game/state.hpp` and `state.cpp` provide semantic accessors. Keep those implementations as the single source of truth when adding a field.
|
||||
|
||||
## Manager records
|
||||
|
||||
Five compatibility slots use 2,828-byte records. Not every slot represents a playable manager. Important offsets within each record include:
|
||||
|
||||
| Record offset | Type | Meaning |
|
||||
|---|---|---|
|
||||
| `0x0a8` | Fixed character area | Manager name |
|
||||
| `0x290` | i16 | Runtime team ID; a sentinel represents no club |
|
||||
| `0x314` | i32 | Cash balance in the engine's currency units |
|
||||
| `0x748` | i32 array | First income accounting table |
|
||||
| `0x85c` | i32 array | Second income accounting table |
|
||||
|
||||
Financial projections can include computed expenses; raw accounting tables do not by themselves reproduce the complete balance screen. A displayed currency conversion is not a change to saved arithmetic.
|
||||
|
||||
Other blocks retain desktop layouts, settings, formation coordinates, tactics, transfers, loan ledgers, calendar state, results, player words and name offsets. Loan duration is kept separately from a player's contract-byte sentinel; a sentinel must not be read as a real multi-century contract.
|
||||
|
||||
## Identity and schedule
|
||||
|
||||
Master club indices, club-name pool offsets, runtime team IDs, player IDs and squad rows are distinct identifiers. Initialisation can shuffle clubs between runtime positions. Promotion and relegation can change those positions again. Use a session's current projections to resolve identity rather than holding a runtime row across a season boundary.
|
||||
|
||||
The base league structure contains five eighteen-team and four twelve-team ranges. A result byte packs home goals in the high nibble and away goals in the low nibble; `0xcc` denotes an unplayed result. The schedule combines round templates with current calendar and competition state. Tables additionally incorporate deductions and selected competition rules; clients should request a table projection instead of deriving one from raw results alone.
|
||||
|
||||
Do not serialise frontend capabilities, pointers, callback owners or request IDs into this compatibility state. Session staging and rollback must include the associated runtime state and both [random streams](../RNG.md), not just selected byte arrays.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Text database: `TEXTD.BLK` / `TEXTE.BLK`
|
||||
|
||||
`src/formats/textd.cpp` reads a seven-byte header followed by consecutive NUL-terminated legacy strings.
|
||||
|
||||
| Offset | Type | Meaning |
|
||||
|---|---|---|
|
||||
| 0 | u8 | Edition-specific identifier |
|
||||
| 1 | u16 | Declared buffer size |
|
||||
| 3 | u32 | Header field with no application-level interpretation |
|
||||
| 7 | bytes | String buffer |
|
||||
|
||||
The loader indexes the first 1,382 strings and rejects a shorter database. Declared buffer size can differ from the actual payload; the loader takes the remaining file bytes rather than trusting it as a stream length. Each stored offset is relative to the start of the string buffer, not to the file or a UTF-8 result.
|
||||
|
||||
Strings are converted through the legacy character decoder when displayed. Currency labels and other edition content come from the installation. The text database is not copied into a savegame; the name pools stored in [FBM](FBM.md) are separate.
|
||||
|
||||
This document intentionally describes structure only. A distributable replacement must provide independently licensed text; copying or translating the supplied game's text database does not create a new license for it.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Indexed bitmap: `.VGA`
|
||||
|
||||
`src/formats/vga.cpp` decodes eight-bit palette indices from a continuous run-length stream. Coordinates use a top-left origin.
|
||||
|
||||
| Offset | Type | Meaning |
|
||||
|---|---|---|
|
||||
| 0 | u16 | Width |
|
||||
| 2 | u16 | Height |
|
||||
| 4 | u32 | Encoded length, including one trailing byte |
|
||||
| 8 | bytes | Encoded pixel stream |
|
||||
|
||||
For a control byte `c >= 0x80`, repeat the following byte `c - 0x7f` times. Otherwise copy the next `c + 1` literal bytes. Decoding continues across row boundaries until `width * height` indices have been produced. The loader rejects truncated data and requires exactly one byte to remain within the declared stream afterwards. A run exceeding the pixel count is clipped by the decoder.
|
||||
|
||||
The default colours come from [M3PC.COL](COL.md). Certain full-screen resources append a 768-byte palette after the encoded stream; callers loading those resources must select that palette separately. `decode_vga` itself returns indices and does not interpret appended palette data.
|
||||
|
||||
Crest sheets use 38 by 38 pixel cells, eight per sheet. For a nine-bit crest ID, the file number is `id >> 3` and the horizontal cell is `id & 7`. This describes the lookup scheme rather than any particular copyrighted crest or sheet content.
|
||||
@@ -0,0 +1,7 @@
|
||||
# IFF crest templates: `WAPPEN.LBM`
|
||||
|
||||
OpenBMH does not load this file. Its crest renderer uses indexed [VGA](VGA.md) sheets. No authorship or redistribution permission for templates found alongside a game installation is implied by their filename.
|
||||
|
||||
An IFF `FORM` of type `PBM ` can contain a `BMHD` bitmap header, an eight-bit RGB `CMAP`, optional application chunks and a `BODY` with chunky pixel indices. IFF lengths and header integers are big endian; chunks are padded to even boundaries.
|
||||
|
||||
For ByteRun1-compressed data, controls 0–127 copy the next `n + 1` bytes, controls 129–255 repeat the next byte `257 - n` times, and 128 is a no-op. This encoding differs from the game's VGA run-length stream. Adding a loader would require its own input validation and independently licensed test fixture.
|
||||
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random
|
||||
Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
@@ -0,0 +1,7 @@
|
||||
LZMA SDK
|
||||
--------
|
||||
|
||||
This package also contains some files from LZMA SDK
|
||||
You can download LZMA SDK from:
|
||||
http://www.7-zip.org/sdk.html
|
||||
LZMA SDK is written and placed in the public domain by Igor Pavlov.
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Nuked OPL3
|
||||
* Copyright (C) 2013-2020 Nuke.YKT
|
||||
*
|
||||
* This file is part of Nuked OPL3.
|
||||
*
|
||||
* Nuked OPL3 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* Nuked OPL3 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Nuked OPL3. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
* Nuked OPL3 emulator.
|
||||
* Thanks:
|
||||
* MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh):
|
||||
* Feedback and Rhythm part calculation information.
|
||||
* forums.submarine.org.uk(carbon14, opl3):
|
||||
* Tremolo and phase generator calculation information.
|
||||
* OPLx decapsulated(Matthew Gambrell, Olli Niemitalo):
|
||||
* OPL2 ROMs.
|
||||
* siliconpr0n.org(John McMaster, digshadow):
|
||||
* YMF262 and VRC VII decaps and die shots.
|
||||
*
|
||||
* version: 1.8
|
||||
*/
|
||||
@@ -0,0 +1,14 @@
|
||||
# Included license texts
|
||||
|
||||
These files preserve upstream license and attribution wording. They are not a grant covering original game content. OpenBMH's GPL-3.0-only notice and the full GPLv3 text are in the root [README](../../README.md) and [LICENSE](../../LICENSE).
|
||||
|
||||
- [SDL2](SDL2.txt): SDL 2.32.10 `LICENSE.txt`.
|
||||
- SDL2's bundled HIDAPI: [license options](SDL2-HIDAPI-options.txt), [BSD-3-Clause](SDL2-HIDAPI-BSD.txt), [original license](SDL2-HIDAPI-original.txt).
|
||||
- [SDL2 yuv2rgb](SDL2-yuv2rgb.txt): BSD-3-Clause notice for that included source component.
|
||||
- [miniz](miniz.txt): the MIT license shipped with the 3.0.2 amalgamation. [Additional verbatim source notices](miniz-source-notices.txt), including the additional copyright attribution and public-domain dedication, are also retained.
|
||||
- [LZMA SDK](LZMA-SDK.txt): the public-domain declaration from the 7-Zip 24.09 documentation. Only individually marked public-domain decoder files are used.
|
||||
- [nativefiledialog-extended](nativefiledialog-extended.txt): version 1.2.1 zlib license.
|
||||
- [Nuked OPL3 copyright and license notice](Nuked-OPL3-notices.txt): unchanged leading notice from its vendored implementation.
|
||||
- [LGPL version 2.1](LGPL-2.1.txt): full license supplied with Nuked OPL3. Its source notices permit version 2.1 or any later version.
|
||||
|
||||
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
|
||||
@@ -0,0 +1,26 @@
|
||||
Copyright (c) 2010, Alan Ott, Signal 11 Software
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Signal 11 Software nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,13 @@
|
||||
HIDAPI can be used under one of three licenses.
|
||||
|
||||
1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt
|
||||
2. A BSD-Style License, in LICENSE-bsd.txt.
|
||||
3. The more liberal original HIDAPI license. LICENSE-orig.txt
|
||||
|
||||
The license chosen is at the discretion of the user of HIDAPI. For example:
|
||||
1. An author of GPL software would likely use HIDAPI under the terms of the
|
||||
GPL.
|
||||
|
||||
2. An author of commercial closed-source software would likely use HIDAPI
|
||||
under the terms of the BSD-style license or the original HIDAPI license.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
HIDAPI - Multi-Platform library for
|
||||
communication with HID devices.
|
||||
|
||||
Copyright 2009, Alan Ott, Signal 11 Software.
|
||||
All Rights Reserved.
|
||||
|
||||
This software may be used by anyone for any reason so
|
||||
long as the copyright notice in the source files
|
||||
remains intact.
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2016, Adrien Descamps
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of yuv2rgb nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,18 @@
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||
* Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
*/
|
||||
|
||||
/* Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at
|
||||
http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/.
|
||||
This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. */
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||
* Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||
* Copyright 2016 Martin Raiber
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
@@ -0,0 +1,22 @@
|
||||
Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,16 @@
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# JSON Lines request protocol
|
||||
|
||||
`openbmh_cli` without `--console` offers a small JSON request adapter for a single `app::CareerSession`. It reads one JSON object per line and writes one response per line. `--text` is an interactive shorthand for this adapter. The broader window-oriented console and its `--json` output are a separate interface; use the [console reference](CLI_CONCEPT/README.md) for interactive questions, live matches and multiple manager clients.
|
||||
|
||||
```sh
|
||||
openbmh_cli --data "path/to/game" --seed 1 --json
|
||||
openbmh_cli --data "path/to/game" --seed 1 --json --log session.jsonl
|
||||
openbmh_cli --replay session.jsonl --json
|
||||
```
|
||||
|
||||
A request has `cmd` and the fields accepted for that command. Mutations carry an integer `manager` and the current `revision`. Responses contain `ok` and `revision`; errors add a stable `error` code and can include diagnostic `detail`. A rejected stale or foreign action must not mutate the projected state. Seed values are unsigned 32-bit decimal or hexadecimal values.
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Fields | Behavior |
|
||||
|---|---|---|
|
||||
| `help` | — | Machine-readable command and parameter list. |
|
||||
| `new` | `options`, `managers` | Creates a career. This adapter accepts exactly one manager. `options` supports `duration` (0–5), `difficulty` (0–9), `mode` (0–3), `league`, `world`, and `managers:1`. The single manager has `name`, `master_club`, optional `start_league`, `strength` (0–2), and `portrait` (0–11). |
|
||||
| `load` | `path` | Loads through `CareerSession`; a failed load leaves the current career active. |
|
||||
| `save` | `manager`, `revision`, `path`, optional `overwrite` | Saves through the Session after checking the current manager and revision. |
|
||||
| `status`, `desk` | — | Read the desktop projection and a compact status object. |
|
||||
| `kickoff` | `manager`, `revision` | Calls the existing turn driver through `dispatch_kickoff`, advancing to the next desk. Returns state and available desk/audio event metadata. |
|
||||
| `results` | — | Reads the owned results of the last completed event; `kickoff` also returns this object. A manager handoff or empty event has no new results. |
|
||||
| `tactics`, `training` | — | Read current preparation values. Reading training does not initialize or recalculate it. |
|
||||
| `tactics.set` | envelope, `index` (0–7), `value` | Sets a supported tactic; index 0 also disables the attitude assistant. |
|
||||
| `training.initialize` | envelope | Performs the normal first-open initialization only when needed. |
|
||||
| `training.type`, `training.area` | envelope, `index`, `value` (1–3) | Changes one of 4 types or 9 areas, validating supported plan limits and automation flags. |
|
||||
| `training.intensity` | envelope, `row`, `value` (1–3) | Changes the player currently occupying the selected squad row. |
|
||||
| `training.focus` | envelope, `row` | Cycles that player's training focus. |
|
||||
| `training.auto` | envelope, `index` (0–4), `value` (0–1) | Toggles a training automation bit, validating the expected value and visible context. |
|
||||
| `table` | `manager`, `league` (0–8) | Reads the selected full-season overall table in Engine rank order, with point deductions. Requires the active manager. |
|
||||
| `mail` | `manager` (0–3) | Reads the selected existing manager's mailbox, sorted by date and physical slot. Does not mark, keep or delete messages. |
|
||||
| `camp.focus` | envelope, `focus` (4 integers) | Dispatches a training-camp focus change. |
|
||||
| `camp.book` | envelope, `resort` (0–7) | Books the selected camp. |
|
||||
| `bank.deposit`, `bank.withdraw` | envelope, positive `amount` | Moves funds through the bank dispatch API. |
|
||||
| `bank.shares.buy`, `bank.shares.sell`, `bank.tip` | envelope, `asset` (0–11), optional `count` | Uses the bank dispatch API. |
|
||||
| `bank.fund.buy`, `bank.fund.sell` | envelope, `asset` (0–5), `count` (1–10) | Uses the bank dispatch API. |
|
||||
| `stadium.open` | envelope | Opens the existing stadium projection/action. |
|
||||
| `stadium.offer` | envelope, `object` (0–13) | Requests the existing periphery quote. |
|
||||
| `stadium.build`, `stadium.decline` | envelope, `object` (0–13), `price` | Uses the existing stadium dispatch API. |
|
||||
| `toto.submit` | envelope, `stake`, `tips` (11 values, each 0–2) | Submits through the existing Toto dispatch API. |
|
||||
| `quit` | — | Ends the input loop. |
|
||||
|
||||
The `envelope` above means integer `manager` and `revision`. This adapter uses one manager,
|
||||
slot 0; a different manager or stale revision is rejected. A failed `new` does not
|
||||
create a Session. A successful `load` starts a new CLI revision sequence.
|
||||
|
||||
The text mode is intentionally narrower: `help`, `new <master_club> <quoted name>
|
||||
[strength]`, `load <quoted path>`, `save <quoted path>`, `status`, `desk`, `kickoff`,
|
||||
`camp.book <resort>`, `results`, `tactics`, `tactics.set <index> <value>`, `training`,
|
||||
`training.initialize`, `training.type <index> <value>`, `training.area <index> <value>`,
|
||||
`training.intensity <row> <value>`, `training.focus <row>`,
|
||||
`training.auto <index> <value>`, `table <manager> <league>`, `mail <manager>`,
|
||||
bank deposit/withdraw/share/fund/tip actions, and `quit`. `help`
|
||||
prints parameter hints. Use JSON mode for all option fields, camp focus, stadium and Toto
|
||||
requests, and for machine clients.
|
||||
|
||||
## Errors and scope
|
||||
|
||||
Malformed JSON, unexpected fields and invalid field types return `invalid_request`. Unknown operations return `unsupported_command`; recognised operations without a session adapter return `career_session_api_unavailable`. `help` describes the command set implemented by this adapter. An operation can also be rejected by its normal phase, mode, manager or rule checks. These outcomes must not be converted into successful client-side approximations.
|
||||
|
||||
This adapter does not expose the console's full squad, calendar, finance, live-match, question/answer or multi-seat interfaces. Its `new` operation requires one manager. A loaded career is subject to the session's actual continuation and revision checks; a successful read alone is not a claim that every later action is available in this adapter.
|
||||
|
||||
`table` returns owned club names, a club identity key, runtime team ID, ranks, games, wins/draws/losses, goals and points. Identity keys, runtime positions and master database indices are distinct. `mail` returns a snapshot of mailbox slots and recipient/keep masks. Keeping is not the same as marking read. Slot references can change when messages are compacted and are not persistent message IDs.
|
||||
|
||||
## Log and replay
|
||||
|
||||
`--log FILE` writes a header with protocol version, data location and seed, then canonical request/response records. `--replay FILE` repeats those requests and reports a mismatch. Replay can overwrite a path recorded by a save operation, so use an isolated writable save directory. Keep the same compatible binary and data when comparing a run.
|
||||
|
||||
The log contains supplied values and game responses, potentially including proprietary text or personal paths. It is not a distributable substitute for game data, nor a complete serialisation of every hidden session mechanism. Do not attach a full game log or save to a public issue; prepare minimal independently written reproduction steps.
|
||||
|
||||
Text errors use `ERROR <code>: <detail>`; successful text replies use `OK`. JSON mode emits one JSON response per request line. Transport framing and field names are part of this adapter's API; executable table addresses are not.
|
||||
@@ -0,0 +1,44 @@
|
||||
OpenBMH v0.1.0
|
||||
===============
|
||||
|
||||
OpenBMH ist eine eigenstaendige Neuumsetzung der Engine von Bundesliga Manager
|
||||
Hattrick und der englischen Fassung Football Limited. Die englische Unterstuetzung
|
||||
ist experimentell. Originale Spielinhalte sind nicht enthalten; du benoetigst eine
|
||||
eigene unterstuetzte Installation. Originale V2.20-Spielstaende der englischen
|
||||
Fassung sind nicht mit dem unterstuetzten Speicherlayout austauschbar.
|
||||
|
||||
Start
|
||||
-----
|
||||
Paket in einen eigenen Ordner oder neben die Installation entpacken.
|
||||
openbmh_play starten (unter Windows openbmh_play.exe). Der Dateidialog nimmt einen
|
||||
Spielordner, die Programmdatei oder ZIP/7z mit einer einzelnen Installation an.
|
||||
|
||||
Aus einem Terminal:
|
||||
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
|
||||
Unter Windows den Programmnamen um .exe ergaenzen. Ein beschreibbarer separater
|
||||
Spielstandordner wird empfohlen. Vorhandene Spielstaende vorher sichern.
|
||||
Tonoptionen: --mute, --no-music, --volume 0.5. --version zeigt die Programmversion.
|
||||
In der Konsole zeigt ListOptions die aktuellen Befehle; eine eigene Zeile go.
|
||||
fuehrt den eingegebenen Block aus. Help beschreibt die Parameter.
|
||||
|
||||
Dokumentation und Rueckmeldungen
|
||||
-------------------------------
|
||||
README.md enthaelt die Bauanleitungen fuer Windows, Linux und macOS.
|
||||
Die Releasehinweise beschreiben den Umfang und die bekannten Grenzen.
|
||||
Linux benoetigt je nach Paket Systembibliotheken, insbesondere GTK3 fuer den
|
||||
Standard-Dateidialog. Plattform-Bauhinweise sind kein Nachweis eines nativen Tests.
|
||||
|
||||
Fehler mit Programmversion, Spielfassung und kurzen eigenen Schritten melden.
|
||||
Keine Originaldateien, Spielbilder, Aufnahmen, Textlisten oder Spielstaende in
|
||||
oeffentliche Issues hochladen.
|
||||
|
||||
Lizenz
|
||||
------
|
||||
Eigener OpenBMH-Code und Dokumentation: GNU GPL Version 3 ausschliesslich
|
||||
(GPL-3.0-only). LICENSE enthaelt den vollstaendigen Text. Drittanbieter behalten
|
||||
ihre Lizenzen; siehe THIRD_PARTY_NOTICES.md und docs/licenses/.
|
||||
Diese Lizenzen gelten nicht fuer die separat benoetigten Originalinhalte.
|
||||
OpenBMH ist ein unabhaengiges Projekt ohne Verbindung oder Billigung durch die
|
||||
urspruenglichen Rechteinhaber, DFL oder Bundesliga.
|
||||
@@ -0,0 +1,32 @@
|
||||
# OpenBMH v0.1.0
|
||||
|
||||
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.
|
||||
|
||||
## 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.
|
||||
|
||||
## Compatibility decisions
|
||||
|
||||
OpenBMH uses shared rule values across supported German editions, with installation-specific content read from the selected data. It includes safety handling around invalid input, calendar boundaries, capacity checks and suspended operations. See [compatibility decisions](../../COMPATIBILITY.md) and [architecture](../../architecture.md). This is an independent reconstruction, not an official update to the original game.
|
||||
|
||||
## Running
|
||||
|
||||
Extract the package to a separate directory or alongside your installation. `openbmh_play` can select a game directory, executable or a ZIP/7z containing one supported installation. Use an explicit writable save directory when the original directory is read-only, and keep backups.
|
||||
|
||||
```sh
|
||||
openbmh_play --data "path/to/game" --save-directory "path/to/saves"
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
```
|
||||
|
||||
Packages and their native platform results are listed with the release assets. The [build instructions](../../BUILDING.md) cover Windows, Linux and macOS source builds; an instruction is not a claim of native acceptance. Linux's default file dialog backend requires GTK3 system libraries. A macOS terminal executable is distinct from a signed application bundle.
|
||||
|
||||
## License
|
||||
|
||||
The matching application source tag is [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0). 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.
|
||||
|
||||
For reports, include the OpenBMH version, data edition, independently written steps and the observed result. Do not upload original files, game screenshots, recordings, text collections or saved games to public issues.
|
||||
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
namespace bmh::app::detail {
|
||||
|
||||
template<class Checkpoint, class Restore>
|
||||
bool apply_window(CareerSession& session, uint64_t& revision, Checkpoint before,
|
||||
Restore restore_checkpoint, const std::function<bool()>& action) {
|
||||
const auto game = session.game();
|
||||
const auto rand = session.rand();
|
||||
const auto old_revision = revision;
|
||||
const auto restore = [&] {
|
||||
session.game() = game;
|
||||
session.rand() = rand;
|
||||
// Some owners reconstruct their saved RNG identity during restore.
|
||||
restore_checkpoint(std::move(before));
|
||||
revision = old_revision;
|
||||
};
|
||||
try {
|
||||
if (action()) return true;
|
||||
} catch (...) {
|
||||
restore();
|
||||
throw;
|
||||
}
|
||||
restore();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool apply_native(CareerSession& session, uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session, revision, session.state(),
|
||||
[&](GameState before) { session.state() = std::move(before); }, action);
|
||||
}
|
||||
|
||||
} // namespace bmh::app::detail
|
||||
@@ -0,0 +1,75 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#pragma once
|
||||
|
||||
#include "audio/playback.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
inline openbmh::audio::OriginalAssets original_audio_assets(
|
||||
const std::filesystem::path& directory, const LeImage& exe) {
|
||||
openbmh::audio::OriginalAssets assets;
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
assets.containers[i] = read_file(ui::asset_path(directory / "S", std::to_string(2000 + i)));
|
||||
for (unsigned i = 0; i < assets.tables.frequencies.size(); ++i)
|
||||
assets.tables.frequencies[i] = exe.u16(::bmh::layout::Audio_OriginalAudioAssets_RuntimeField2 + 2 * i);
|
||||
for (unsigned i = 0; i < assets.tables.operators.size(); ++i)
|
||||
assets.tables.operators[i] = exe.u8(::bmh::layout::Audio_OriginalAudioAssets_RuntimeField + 16 * i);
|
||||
return assets;
|
||||
}
|
||||
|
||||
inline openbmh::audio::OriginalAudioOptions original_audio_options(const GameState& state, bool music) {
|
||||
const auto on = [&](std::uint32_t address) {
|
||||
return !state.memory.has(address) || (state.memory.u8(address) & 0x7f) == 0;
|
||||
};
|
||||
// A5 governs match presentation and is checked by the match observer. It
|
||||
// must not mute menu clicks. A6/A7 are independent saved music/click switches.
|
||||
return {music && on(::bmh::layout::Audio_OriginalAudioOptions_ExecutableField), true, on(::bmh::layout::Audio_OriginalAudioOptions_ExecutableField2)};
|
||||
}
|
||||
inline bool match_sound_enabled(const GameState& state) {
|
||||
return !state.memory.has(::bmh::layout::Audio_MatchSoundEnabled_RuntimeField) || (state.memory.u8(::bmh::layout::Audio_MatchSoundEnabled_RuntimeField) & 0x7f) == 0;
|
||||
}
|
||||
inline void original_audio_command(openbmh::audio::Playback& playback, std::uint8_t id) {
|
||||
if (!playback.original_ready() || !playback.available()) return;
|
||||
std::string error;
|
||||
playback.play_original_id(id, error);
|
||||
}
|
||||
inline void original_match_audio_command(openbmh::audio::Playback& playback,
|
||||
const GameState& state, std::uint8_t id) {
|
||||
if (match_sound_enabled(state)) original_audio_command(playback, id);
|
||||
else if (id == 3) original_audio_command(playback, 8); // Match entry still stops desk music.
|
||||
}
|
||||
|
||||
// One callback per actual SDL mouse event, including nested modal loops. No
|
||||
// rendering/hover polling, no scene inference, and no application/GameState access
|
||||
// from a possible SDL event thread. Source OriginalMouseSound maps left2/right8 to10/11.
|
||||
class OriginalMouseSound {
|
||||
public:
|
||||
explicit OriginalMouseSound(openbmh::audio::Playback& p) : playback_(p) {
|
||||
SDL_AddEventWatch(watch, this);
|
||||
}
|
||||
~OriginalMouseSound() { detach(); }
|
||||
void detach() noexcept {
|
||||
if (!attached_) return;
|
||||
SDL_DelEventWatch(watch, this);
|
||||
attached_ = false;
|
||||
}
|
||||
OriginalMouseSound(const OriginalMouseSound&) = delete;
|
||||
OriginalMouseSound& operator=(const OriginalMouseSound&) = delete;
|
||||
private:
|
||||
static int watch(void* data, SDL_Event* event) {
|
||||
if (event->type == SDL_MOUSEBUTTONDOWN) {
|
||||
auto& self = *static_cast<OriginalMouseSound*>(data);
|
||||
if (event->button.button == SDL_BUTTON_LEFT) original_audio_command(self.playback_, 10);
|
||||
if (event->button.button == SDL_BUTTON_RIGHT) original_audio_command(self.playback_, 11);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
openbmh::audio::Playback& playback_;
|
||||
bool attached_ = true;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,100 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include <functional>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
using SeasonPresenter = std::function<void(const char*, const GameState&)>;
|
||||
|
||||
using TransferOfferPresenter = std::function<int(const GameState&, const TransferOfferListView&)>;
|
||||
using TransferDecisionPresenter = std::function<void(const GameState&, const TransferDecisionEvent&)>;
|
||||
using PoachNoticePresenter = std::function<void(const GameState&,const PoachStart&,const Image&)>;
|
||||
using AdvertisingRenewalPresenter = std::function<CareerSession::AdvertisingRenewalPresentation(
|
||||
const GameState&, const AdvertisingRenewal&, const Image&)>;
|
||||
using NationalFriendlyQuestionPresenter = std::function<std::optional<bool>(
|
||||
const GameState&, ui::TaxDialogProjection, const Image&)>;
|
||||
using ContractExpiryPresenter = CareerSession::ContractExpiryPresenter;
|
||||
using LoanReturnPresenter = CareerSession::LoanReturnPresenter;
|
||||
using LoanReturnOfferPresenter = CareerSession::LoanReturnOfferPresenter;
|
||||
using LiveLineupDispatcher = std::function<LiveSubstitutionResult(const ui::LineupRequest&)>;
|
||||
using LiveTacticsDispatcher = std::function<bool(const ui::TacticsRequest&, std::string&)>;
|
||||
using LivePitchDispatcher = std::function<LiveSubstitutionResult(const ui::PitchRequest&)>;
|
||||
enum class LiveInterventionBoundary { begin, finish, abort };
|
||||
using LiveInterventionScopeDispatcher = std::function<bool(LiveInterventionBoundary, int, int, int, std::string&)>;
|
||||
using LiveInterventionPresenter = std::function<void(int, MatchEngine&, std::vector<MatchGroup>&,
|
||||
GameState&, uint64_t&, const LiveLineupDispatcher&, const LiveTacticsDispatcher&,
|
||||
const LivePitchDispatcher&, const LiveInterventionScopeDispatcher&)>;
|
||||
using LiveMatchEventPresenter = std::function<void(const LiveMatchEvent&, MatchEngine&,
|
||||
std::vector<MatchGroup>&, GameState&, uint64_t&, const LiveLineupDispatcher&,
|
||||
const LiveTacticsDispatcher&, const LivePitchDispatcher&,
|
||||
const LiveInterventionScopeDispatcher&)>;
|
||||
using EnvironmentNoticePresenter = std::function<bool(const GameState&, ui::TaxDialogProjection, const Image&)>;
|
||||
using LiveRealityPresenter = decltype(TurnDriver::live_reality);
|
||||
using PhaseResultPresenter = decltype(TurnDriver::phase_results);
|
||||
using LiveBallPresenter = std::function<void(const LiveBallEvent&,
|
||||
const std::vector<MatchGroup>&, const GameState&)>;
|
||||
using LiveChancePresenter = std::function<void(const LiveChanceEvent&,
|
||||
const std::vector<MatchGroup>&, const GameState&)>;
|
||||
using LiveShotPresenter = std::function<void(const LiveShotEvent&,
|
||||
const std::vector<MatchGroup>&, const GameState&)>;
|
||||
using LiveSetPiecePresenter = std::function<void(const LiveSetPieceEvent&,
|
||||
const std::vector<MatchGroup>&, const GameState&)>;
|
||||
using LiveBookingPresenter = std::function<void(const LiveBookingEvent&,
|
||||
const std::vector<MatchGroup>&, const GameState&)>;
|
||||
using LiveShootoutPresenter = std::function<void(const LiveShootoutEvent&,
|
||||
const std::vector<MatchGroup>&, const GameState&)>;
|
||||
|
||||
// Shared, synchronous request boundary of the SDL app. Tests drive the same
|
||||
// controller without a window; rendering and navigation never advance the engine.
|
||||
std::string serve_flow_request(ui::StartupFlow&, const ui::FlowResult&,
|
||||
std::unique_ptr<CareerSession>&, const std::filesystem::path& data,
|
||||
const std::filesystem::path& save_directory, uint32_t seed, uint64_t& revision,
|
||||
openbmh::audio::Playback&, std::optional<uint64_t>& audio_session, bool music_enabled,
|
||||
std::function<void(int, const std::vector<MatchGroup>&, const GameState&)> live_presenter = {},
|
||||
TransferOfferPresenter transfer_presenter = {},
|
||||
TransferDecisionPresenter transfer_decision_presenter = {},
|
||||
SeasonPresenter season_presenter = {},
|
||||
SeasonTaxHooks tax_presenter = {},
|
||||
SeasonHighscoreHook highscore_presenter = {},
|
||||
SeasonPromotionHook promotion_presenter = {},
|
||||
SeasonCupDrawHook cup_draw_presenter = {},
|
||||
PendingOfferHooks pending_offer_presenter = {},
|
||||
PendingOfferEntryPolicy pending_entry_policy = PendingOfferEntryPolicy::legacy_unpresented,
|
||||
HumanBuyerSaleHooks market_sale_presenter = {},
|
||||
HumanBuyerMarketEntryPolicy market_entry_policy = HumanBuyerMarketEntryPolicy::legacy_unpresented,
|
||||
TransferOfferTeamInfoPresenter team_info_presenter = {},
|
||||
TransferOfferPlayerInfoPresenter player_info_presenter = {},
|
||||
ConstructionNoticeHook construction_notice_presenter = {},
|
||||
SeasonTicketCompensationNoticeHook compensation_notice_presenter = {},
|
||||
SportschauPresentationHooks sportschau_presenter = {},
|
||||
AdvertisingRenewalPresenter advertising_renewal_presenter = {},
|
||||
CareerSession::PoachPlayerSelector poach_player_selector = {},
|
||||
PoachNoticePresenter poach_notice_presenter = {},
|
||||
ContractExpiryPresenter contract_expiry_presenter = {},
|
||||
NationalFriendlyQuestionPresenter national_friendly_question_presenter = {},
|
||||
LoanReturnPresenter loan_return_presenter = {},
|
||||
LoanReturnOfferPresenter loan_return_offer_presenter = {},
|
||||
LiveInterventionPresenter live_intervention_presenter = {},
|
||||
EnvironmentNoticePresenter environment_notice_presenter = {},
|
||||
LiveMatchEventPresenter live_match_event_presenter = {},
|
||||
LiveBallPresenter live_ball_presenter = {},
|
||||
LiveChancePresenter live_chance_presenter = {},
|
||||
LiveShotPresenter live_shot_presenter = {},
|
||||
LiveSetPiecePresenter live_set_piece_presenter = {},
|
||||
LiveBookingPresenter live_booking_presenter = {},
|
||||
LiveShootoutPresenter live_shootout_presenter = {},
|
||||
LiveRealityPresenter live_reality_presenter = {},
|
||||
PhaseResultPresenter phase_result_presenter = {}, bool enable_autosave = false);
|
||||
|
||||
// Focused controller entry for callers that only need to inject the original
|
||||
// yes/no question presenter; all unrelated synchronous hooks keep defaults.
|
||||
std::string serve_flow_request(ui::StartupFlow&, const ui::FlowResult&,
|
||||
std::unique_ptr<CareerSession>&, const std::filesystem::path& data,
|
||||
const std::filesystem::path& save_directory, uint32_t seed, uint64_t& revision,
|
||||
openbmh::audio::Playback&, std::optional<uint64_t>& audio_session, bool music_enabled,
|
||||
NationalFriendlyQuestionPresenter national_friendly_question_presenter);
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,564 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/desktop_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
ui::DeskRequest DesktopActions::menu(const ui::DeskState& observed, int kind) {
|
||||
ui::DeskRequest request;
|
||||
request.kind = ui::DeskRequestKind::open_menu;
|
||||
request.menu_kind = kind;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.revision = observed.revision;
|
||||
for (const auto& item : observed.items)
|
||||
if (item.kind == kind) request.item_id = item.id;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool DeskSettingsActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.desk_settings_checkpoint(revision),
|
||||
[&](CareerSession::DeskSettingsCheckpoint before) {
|
||||
session_.restore_desk_settings_checkpoint(std::move(before), revision);
|
||||
}, action);
|
||||
}
|
||||
|
||||
std::optional<CareerSession::DeskSettingsProjection> DeskSettingsActions::open(
|
||||
const ui::DeskRequest& request, uint64_t& revision, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<CareerSession::DeskSettingsProjection> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_desk_settings(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::dispatch(
|
||||
const CareerSession::DeskSettingsAction& request, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
std::optional<CareerSession::DeskSettingsDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_desk_settings(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::write(uint64_t sequence,
|
||||
const ui::SettingsWriteRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsWrite{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::file(uint64_t sequence,
|
||||
const ui::SaveLoadRequest& request, uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
return dispatch(CareerSession::DeskSettingsFile{sequence, request}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
std::optional<CareerSession::DeskSettingsDispatch> DeskSettingsActions::close(uint64_t sequence,
|
||||
uint64_t owner_revision, const ui::DeskRequest& observed, uint64_t& revision, std::string& error,
|
||||
const Accept& acknowledge) {
|
||||
const CareerSession::DeskSettingsOwner owner{sequence, owner_revision, observed.manager_slot, observed.item_id};
|
||||
return dispatch(CareerSession::DeskSettingsClose{owner}, revision, error, acknowledge);
|
||||
}
|
||||
|
||||
bool DeskSettingsActions::edit(const ui::SettingsState& observed, int row, int column, ui::SettingsEdit operation,
|
||||
uint64_t& revision, std::string& error) {
|
||||
ui::SettingsWriteRequest request;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.revision = observed.revision;
|
||||
request.expected_raw = observed.cells;
|
||||
request.row = uint8_t(row);
|
||||
request.column = uint8_t(column);
|
||||
request.operation = operation;
|
||||
return apply(revision, [&] { return session_.dispatch_settings(request, revision, error); });
|
||||
}
|
||||
|
||||
bool BalanceActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.balance_checkpoint(),
|
||||
[&](CareerSession::BalanceCheckpoint before) { session_.restore_balance_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
std::optional<ui::BalanceState> BalanceActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::BalanceState> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_balance_plan(request, revision, underlay, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::BalanceDispatch> BalanceActions::dispatch(const ui::BalanceRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::BalanceDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_balance_plan(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
BalancePlanDraft BalanceActions::open_draft(int manager) const { return bmh::open_balance_plan(session_.state(), manager); }
|
||||
void BalanceActions::cycle_draft(BalancePlanDraft& draft) const { cycle_balance_view(session_.state(), draft); }
|
||||
void BalanceActions::reset_draft(BalancePlanDraft& draft) const { reset_balance_plan(session_.state(), draft); }
|
||||
BalanceEditStatus BalanceActions::edit_draft(BalancePlanDraft& draft, int row, int32_t value) const {
|
||||
return edit_balance_plan(session_.state(), draft, row, value);
|
||||
}
|
||||
|
||||
bool BalanceActions::close_draft(const BalancePlanDraft& draft, uint64_t& revision) {
|
||||
bool warning = false;
|
||||
apply(revision, [&] {
|
||||
warning = bmh::close_balance_plan(session_.state(), draft);
|
||||
++revision;
|
||||
return true;
|
||||
});
|
||||
return warning;
|
||||
}
|
||||
|
||||
bool OtherGamesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.other_games_checkpoint(),
|
||||
[&](CareerSession::OtherGamesCheckpoint before) { session_.restore_other_games_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
std::optional<ui::OtherGamesState> OtherGamesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::OtherGamesState> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_other_games(request, revision, underlay, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::OtherGamesDispatch> OtherGamesActions::dispatch(const ui::OtherGamesRequest& request,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OtherGamesDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_other_games(request, revision, error, team_info);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TopScorersActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.top_scorers_checkpoint(),
|
||||
[&](CareerSession::TopScorersCheckpoint before) { session_.restore_top_scorers_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
std::optional<ui::TopScorersState> TopScorersActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::TopScorersState> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_top_scorers(request, revision, underlay, error);
|
||||
if (!result) return false;
|
||||
++revision; // Preserve the existing menu-20 opening revision.
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::TopScorersDispatch> TopScorersActions::dispatch(const ui::TopScorersRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::TopScorersDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_top_scorers(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
bool OpportunitiesActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.opportunities_checkpoint(),
|
||||
[&](CareerSession::OpportunitiesCheckpoint before) { session_.restore_opportunities_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
std::optional<ui::OpportunitiesState> OpportunitiesActions::open(const ui::DeskRequest& request,
|
||||
uint64_t& revision, const Image& underlay, std::string& error, bool national_source_case,
|
||||
int stable_identity, const OpenAccept& acknowledge) {
|
||||
std::optional<ui::OpportunitiesState> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_opportunities(request, revision, underlay, error, national_source_case, stable_identity);
|
||||
if (!result) return false;
|
||||
++revision;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::OpportunitiesDispatch> OpportunitiesActions::dispatch(const ui::OpportunitiesRequest& request,
|
||||
uint64_t& revision, std::string& error, const Accept& acknowledge) {
|
||||
std::optional<CareerSession::OpportunitiesDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_opportunities(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
bool OpportunitiesActions::preference(const ui::AnalyticsRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
if (!session_.apply_statistics_preference(request.owner, request.manager_slot,
|
||||
request.expected_flags, request.target_flags, revision, error)) return false;
|
||||
if (revision == UINT64_MAX) throw FormatError("statistics: revision exhausted");
|
||||
++revision;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
ui::OpportunitiesRequest OpportunitiesActions::close_request(const ui::OpportunitiesState& observed) {
|
||||
return {observed.identity, ui::OpportunitiesAction::close, observed.mode};
|
||||
}
|
||||
|
||||
bool ManagerJoinActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_window(session_, revision, session_.manager_join_checkpoint(),
|
||||
[&](CareerSession::ManagerJoinCheckpoint before) { session_.restore_manager_join_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
bool ManagerJoinActions::commit(uint64_t& revision, std::string& error,
|
||||
const std::function<void(ui::CareerInitializationResult&)>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
ui::CareerInitializationResult joined;
|
||||
if (!session_.commit_manager_join(joined, revision, error)) return false;
|
||||
if (acknowledge) acknowledge(joined);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool MailboxActions::dispatch(const ui::MailboxActionRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
if (!session_.dispatch_mailbox(request, revision, error)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool MailboxActions::close(const ui::MailboxCloseRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
if (!session_.acknowledge_mailbox_close(request, revision, error)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
ui::MailboxActionRequest MailboxActions::request(int manager, uint64_t revision,
|
||||
ui::MailboxActionKind kind, const ui::MailboxMessage& observed) {
|
||||
ui::MailboxActionRequest request;
|
||||
request.kind = kind;
|
||||
request.manager_slot = manager;
|
||||
request.revision = revision;
|
||||
request.entry_index = observed.entry_index;
|
||||
request.expected_entry = observed.raw_entry;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool MenuLayoutActions::dispatch(const ui::SaveLoadRequest& request, uint64_t& revision,
|
||||
std::string& error, const std::function<void()>& acknowledge) {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
if (!session_.dispatch_menu_layout(request, revision, error)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge) {
|
||||
return set_impl(request, revision, error, notice, acknowledge, false);
|
||||
}
|
||||
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_console(const ui::EnvironmentView& observed,
|
||||
int item, int level, uint64_t& revision, std::string& error, const Notice& notice) {
|
||||
return set_impl(request(observed, item, level), revision, error, notice, {}, true);
|
||||
}
|
||||
|
||||
std::optional<EnvironmentResult> EnvironmentActions::set_impl(const ui::EnvironmentRequest& request,
|
||||
uint64_t& revision, std::string& error, const Notice& notice, const std::function<void(bool)>& acknowledge,
|
||||
bool publish_console_result) {
|
||||
error.clear();
|
||||
std::optional<EnvironmentResult> result;
|
||||
const bool accepted = detail::apply_native(session_, revision, [&] {
|
||||
const auto& state = session_.state();
|
||||
if (request.kind != ui::EnvironmentRequestKind::set_item || request.revision != revision ||
|
||||
request.manager_slot < 0 || request.manager_slot > 3 || !state.memory.has(::bmh::layout::ActiveManager) ||
|
||||
state.memory.u8(::bmh::layout::ActiveManager) != request.manager_slot ||
|
||||
size_t(request.manager_slot) >= state.manager_teams.size() ||
|
||||
state.manager_teams[size_t(request.manager_slot)] != request.runtime_club) {
|
||||
error = "stale_environment_owner";
|
||||
return false;
|
||||
}
|
||||
auto staged = state;
|
||||
std::string message;
|
||||
result = set_environment(staged, request.manager_slot, request.item, request.level, &message);
|
||||
if (*result == EnvironmentResult::invalid) return true;
|
||||
if (publish_console_result) session_.state() = staged;
|
||||
if (!message.empty() && (!notice || !notice(staged, message))) {
|
||||
if (error.empty()) error = "environment_source_notice_aborted";
|
||||
return false;
|
||||
}
|
||||
const bool changed = *result == EnvironmentResult::changed;
|
||||
if (changed) {
|
||||
if (revision == UINT64_MAX) throw FormatError("environment revision exhausted");
|
||||
++revision;
|
||||
}
|
||||
// The old Console called Core directly even for its handled refusals;
|
||||
// SDL only published a changed result. Preserve both caller semantics.
|
||||
if (changed || publish_console_result) session_.state() = std::move(staged);
|
||||
if (acknowledge) acknowledge(changed);
|
||||
return true;
|
||||
});
|
||||
if (!accepted) result.reset();
|
||||
return result;
|
||||
}
|
||||
|
||||
ui::EnvironmentRequest EnvironmentActions::request(const ui::EnvironmentView& observed, int item, int level) {
|
||||
ui::EnvironmentRequest request;
|
||||
request.kind = ui::EnvironmentRequestKind::set_item;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
request.revision = observed.revision;
|
||||
request.owner = observed.owner;
|
||||
request.item = item;
|
||||
request.level = level;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool RescheduleActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
RescheduleStatus RescheduleActions::change(GameState& state, int manager, const LeagueMatchRef& match,
|
||||
int day, ui::RescheduleActionKind kind) {
|
||||
if (kind == ui::RescheduleActionKind::move) return reschedule_league_match(state, manager, match, day);
|
||||
if (kind == ui::RescheduleActionKind::undo && undo_reschedule(state, manager, day)) return RescheduleStatus::moved;
|
||||
return RescheduleStatus::invalid_match;
|
||||
}
|
||||
|
||||
RescheduleStatus RescheduleActions::dispatch(const ui::RescheduleAction& request, uint64_t& revision,
|
||||
const std::function<void()>& acknowledge) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
apply(revision, [&] {
|
||||
const auto& before = session_.state();
|
||||
const int manager = request.owner.manager_slot;
|
||||
if (request.owner.kind != ui::DeskRequestKind::open_menu || request.owner.menu_kind != 7 ||
|
||||
request.owner.revision != revision || revision == UINT64_MAX || !before.memory.has(::bmh::layout::ActiveManager) ||
|
||||
manager != int(before.memory.u8(::bmh::layout::ActiveManager))) return false;
|
||||
auto staged = before;
|
||||
const auto eligible = request.kind == ui::RescheduleActionKind::move
|
||||
? reschedulable_matches(before, manager) : moved_matches(before, manager);
|
||||
if (std::find(eligible.begin(), eligible.end(), request.match) != eligible.end())
|
||||
status = change(staged, manager, request.match, request.target_day, request.kind);
|
||||
if (status != RescheduleStatus::moved) return false;
|
||||
session_.state() = std::move(staged);
|
||||
++revision;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
return status;
|
||||
}
|
||||
|
||||
RescheduleStatus RescheduleActions::move(int manager, const LeagueMatchRef& match, int day, uint64_t& revision) {
|
||||
auto status = RescheduleStatus::invalid_match;
|
||||
apply(revision, [&] {
|
||||
status = change(session_.state(), manager, match, day, ui::RescheduleActionKind::move);
|
||||
if (status != RescheduleStatus::moved) return false;
|
||||
++revision;
|
||||
return true;
|
||||
});
|
||||
return status;
|
||||
}
|
||||
|
||||
void RescheduleActions::undo_console(int manager, int day, uint64_t& revision) {
|
||||
apply(revision, [&] {
|
||||
// Keep the Console's existing accepted-command revision after its own
|
||||
// observed moved-match selection, including Core's Boolean result.
|
||||
(void)change(session_.state(), manager, {}, day, ui::RescheduleActionKind::undo);
|
||||
++revision;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool ContractActions::dispatch(const ui::ContractRequest& request, uint64_t& revision,
|
||||
ui::ContractActionResult& result, std::string& error, const std::function<void()>& acknowledge) {
|
||||
bool accepted = false;
|
||||
try {
|
||||
return detail::apply_native(session_, revision, [&] {
|
||||
if (!session_.dispatch_contract(request, revision, result, error)) return false;
|
||||
accepted = true;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
} catch (...) {
|
||||
// Preserve the old SDL rejection's quote cleanup and consumed-ID policy.
|
||||
if (accepted) session_.clear_contract_quote();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
ui::ContractRequest ContractActions::bind(const ui::ContractsState& observed,
|
||||
ui::ContractActionKind kind, uint64_t request_id) {
|
||||
ui::ContractRequest request;
|
||||
request.kind = kind;
|
||||
request.request_id = request_id;
|
||||
request.revision = observed.revision;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::ContractRequest ContractActions::demands(const ui::ContractsState& observed,
|
||||
const ui::ContractPlayer& player, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::request_demands, request_id);
|
||||
request.row = player.row;
|
||||
request.player_id = player.player_id;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::ContractRequest ContractActions::team_bonus(const ui::ContractsState& observed,
|
||||
int index, uint8_t percent, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::submit_bonuses, request_id);
|
||||
request.proposed_bonuses = observed.team_premiums;
|
||||
request.proposed_bonuses.at(size_t(index)) = percent;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::ContractRequest ContractActions::insurance(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, uint8_t form, uint8_t months, uint64_t request_id) {
|
||||
auto request = bind(observed, ui::ContractActionKind::insure_player, request_id);
|
||||
request.row = row; request.player_id = player; request.quote_id = quote;
|
||||
request.term_column = form; request.insurance_months = months;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::ContractRequest ContractActions::offer(const ui::ContractsState& observed, int row,
|
||||
int player, uint64_t quote, const std::array<uint8_t,7>& bonuses, int years, uint32_t salary,
|
||||
const std::array<uint32_t,4>& demands, uint64_t request_id) {
|
||||
auto request = bind(observed, years > 0 ? ui::ContractActionKind::submit_offer : ui::ContractActionKind::submit_bonuses, request_id);
|
||||
request.row = row; request.player_id = player; request.quote_id = quote;
|
||||
request.proposed_bonuses = bonuses;
|
||||
if (years > 0) {
|
||||
request.term_column = uint8_t(years - 1);
|
||||
request.demand = demands.at(size_t(years - 1));
|
||||
request.monthly_salary = salary;
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
bool FriendlyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return detail::apply_native(session_, revision, action);
|
||||
}
|
||||
|
||||
FriendlyBookingRequest FriendlyActions::booking_request(const ui::FriendlyMatchRequest& observed) {
|
||||
FriendlyBookingQuote quote;
|
||||
quote.status = FriendlyQuoteStatus::quoted;
|
||||
quote.manager = observed.manager_slot;
|
||||
quote.opponent = observed.opponent;
|
||||
quote.manager_team = observed.runtime_team;
|
||||
quote.manager_home = observed.manager_home;
|
||||
quote.home_team = observed.home_team;
|
||||
quote.away_team = observed.away_team;
|
||||
quote.payer_manager = observed.payer_manager;
|
||||
quote.opponent_manager = observed.opponent_manager;
|
||||
quote.cost = observed.cost;
|
||||
quote.planner_count = uint8_t(observed.planner_count);
|
||||
return {quote, uint16_t(observed.season_day), observed.accept_opponent, observed.consenting_manager,
|
||||
observed.accept_cost, observed.approving_manager};
|
||||
}
|
||||
|
||||
ui::FriendlyBookingAck FriendlyActions::acknowledgement(const ui::FriendlyMatchRequest& request,
|
||||
const FriendlyBookingResult& outcome, uint64_t revision) const {
|
||||
ui::FriendlyBookingAck ack;
|
||||
ack.request_id = request.request_id; ack.quote_id = request.quote_id; ack.revision = revision;
|
||||
ack.accepted = true; ack.manager_slot = request.manager_slot; ack.runtime_team = request.runtime_team;
|
||||
ack.opponent = request.opponent; ack.opponent_manager = outcome.opponent_manager;
|
||||
ack.season_day = request.season_day; ack.payer_manager = outcome.payer_manager;
|
||||
ack.home_team = outcome.home_team; ack.away_team = outcome.away_team; ack.cost = outcome.cost;
|
||||
ack.planner_count = session_.state().memory.u8(::bmh::layout::FriendlyPlanCount);
|
||||
return ack;
|
||||
}
|
||||
|
||||
FriendlyActions::Booking FriendlyActions::book(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, bool national, const Accept& acknowledge) {
|
||||
Booking result;
|
||||
result.applied = apply(revision, [&] {
|
||||
if (request.kind != ui::FriendlyRequestKind::book || request.revision != revision || revision == UINT64_MAX) {
|
||||
result.result.status = FriendlyBookingStatus::stale_quote;
|
||||
return false;
|
||||
}
|
||||
if (national) {
|
||||
if (!request.national_booking) return false;
|
||||
result.result = book_national_friendly_match(session_.state(), *request.national_booking, session_.rand(), session_.game());
|
||||
} else result.result = book_friendly_match(session_.state(), booking_request(request));
|
||||
if (result.result.status != FriendlyBookingStatus::booked) return false;
|
||||
const auto next_revision = revision + 1;
|
||||
const auto ack = acknowledgement(request, result.result, next_revision);
|
||||
if (ack.planner_count != request.planner_count + 2) {
|
||||
result.planner_mismatch = true;
|
||||
return false;
|
||||
}
|
||||
if (acknowledge) acknowledge(ack);
|
||||
// Preserve the old UI caller's revision during its acknowledgement.
|
||||
revision = next_revision;
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
FriendlyActions::Booking FriendlyActions::book_club(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, false, acknowledge); }
|
||||
FriendlyActions::Booking FriendlyActions::book_national(const ui::FriendlyMatchRequest& request,
|
||||
uint64_t& revision, const Accept& acknowledge) { return book(request, revision, true, acknowledge); }
|
||||
|
||||
FriendlyBookingResult FriendlyActions::book_console(const FriendlyBookingQuote& quote, uint16_t day,
|
||||
bool accept_opponent, int consenting_manager, bool accept_cost, int approving_manager, uint64_t& revision) {
|
||||
FriendlyBookingResult result;
|
||||
apply(revision, [&] {
|
||||
result = book_friendly_match(session_.state(),
|
||||
{quote, day, accept_opponent, consenting_manager, accept_cost, approving_manager});
|
||||
if (result.status != FriendlyBookingStatus::booked) return false;
|
||||
++revision;
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
FriendlyBookingQuote FriendlyActions::quote(int manager, int opponent, bool home) const {
|
||||
return quote_friendly_match(session_.state(), manager, opponent, home);
|
||||
}
|
||||
NationalFriendlyQuote FriendlyActions::national_quote(const NationalFriendlyOwner& owner, int opponent, bool home) {
|
||||
return quote_national_friendly_match(session_.state(), owner, opponent, home, session_.rand());
|
||||
}
|
||||
FriendlyDateStatus FriendlyActions::date_status(const FriendlyBookingQuote& quote, uint16_t day) const {
|
||||
return friendly_match_date_status(session_.state(), quote, day);
|
||||
}
|
||||
FriendlyDateStatus FriendlyActions::national_date_status(const NationalFriendlyQuote& quote,
|
||||
const NationalFriendlyOwner& owner, uint16_t day) const {
|
||||
return national_friendly_match_date_status(session_.state(), quote, owner, session_.rand(), day);
|
||||
}
|
||||
NationalFriendlyOwner FriendlyActions::national_owner(const ui::FriendlyMatchRequest& request) {
|
||||
return {request.quote_id, request.revision, request.manager_slot, 0x165, 6};
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,200 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
class DesktopActions {
|
||||
public:
|
||||
static ui::DeskRequest menu(const ui::DeskState& observed, int kind);
|
||||
};
|
||||
|
||||
class DeskSettingsActions {
|
||||
public:
|
||||
explicit DeskSettingsActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
using OpenAccept = std::function<void(CareerSession::DeskSettingsProjection&)>;
|
||||
using Accept = std::function<void(CareerSession::DeskSettingsDispatch&)>;
|
||||
std::optional<CareerSession::DeskSettingsProjection> open(const ui::DeskRequest&,
|
||||
uint64_t& revision, std::string& error, const OpenAccept& = {});
|
||||
std::optional<CareerSession::DeskSettingsDispatch> write(uint64_t owner_sequence,
|
||||
const ui::SettingsWriteRequest&, uint64_t& revision, std::string& error, const Accept& = {});
|
||||
std::optional<CareerSession::DeskSettingsDispatch> file(uint64_t owner_sequence,
|
||||
const ui::SaveLoadRequest&, uint64_t& revision, std::string& error, const Accept& = {});
|
||||
std::optional<CareerSession::DeskSettingsDispatch> close(uint64_t owner_sequence,
|
||||
uint64_t owner_revision, const ui::DeskRequest& observed,
|
||||
uint64_t& revision, std::string& error, const Accept& = {});
|
||||
bool edit(const ui::SettingsState& observed, int row, int column, ui::SettingsEdit,
|
||||
uint64_t& revision, std::string& error);
|
||||
private:
|
||||
std::optional<CareerSession::DeskSettingsDispatch> dispatch(const CareerSession::DeskSettingsAction&,
|
||||
uint64_t& revision, std::string& error, const Accept&);
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class BalanceActions {
|
||||
public:
|
||||
explicit BalanceActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
using OpenAccept = std::function<void(ui::BalanceState&)>;
|
||||
using Accept = std::function<void(CareerSession::BalanceDispatch&)>;
|
||||
std::optional<ui::BalanceState> open(const ui::DeskRequest&, uint64_t& revision,
|
||||
const Image& underlay, std::string& error, const OpenAccept& = {});
|
||||
std::optional<CareerSession::BalanceDispatch> dispatch(const ui::BalanceRequest&,
|
||||
uint64_t& revision, std::string& error, const Accept& = {});
|
||||
BalancePlanDraft open_draft(int manager) const;
|
||||
void cycle_draft(BalancePlanDraft&) const;
|
||||
void reset_draft(BalancePlanDraft&) const;
|
||||
BalanceEditStatus edit_draft(BalancePlanDraft&, int row, int32_t value) const;
|
||||
bool close_draft(const BalancePlanDraft&, uint64_t& revision);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class OtherGamesActions {
|
||||
public:
|
||||
explicit OtherGamesActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
using OpenAccept = std::function<void(ui::OtherGamesState&)>;
|
||||
using Accept = std::function<void(CareerSession::OtherGamesDispatch&)>;
|
||||
std::optional<ui::OtherGamesState> open(const ui::DeskRequest&, uint64_t& revision,
|
||||
const Image& underlay, std::string& error, const OpenAccept& = {});
|
||||
std::optional<CareerSession::OtherGamesDispatch> dispatch(const ui::OtherGamesRequest&,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& = {}, const Accept& = {});
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class TopScorersActions {
|
||||
public:
|
||||
explicit TopScorersActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
using OpenAccept = std::function<void(ui::TopScorersState&)>;
|
||||
using Accept = std::function<void(CareerSession::TopScorersDispatch&)>;
|
||||
std::optional<ui::TopScorersState> open(const ui::DeskRequest&, uint64_t& revision,
|
||||
const Image& underlay, std::string& error, const OpenAccept& = {});
|
||||
std::optional<CareerSession::TopScorersDispatch> dispatch(const ui::TopScorersRequest&,
|
||||
uint64_t& revision, std::string& error, const Accept& = {});
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class OpportunitiesActions {
|
||||
public:
|
||||
explicit OpportunitiesActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
using OpenAccept = std::function<void(ui::OpportunitiesState&)>;
|
||||
using Accept = std::function<void(CareerSession::OpportunitiesDispatch&)>;
|
||||
std::optional<ui::OpportunitiesState> open(const ui::DeskRequest&, uint64_t& revision,
|
||||
const Image& underlay, std::string& error, bool national_source_case = false,
|
||||
int stable_identity = -1, const OpenAccept& = {});
|
||||
std::optional<CareerSession::OpportunitiesDispatch> dispatch(const ui::OpportunitiesRequest&,
|
||||
uint64_t& revision, std::string& error, const Accept& = {});
|
||||
bool preference(const ui::AnalyticsRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
static ui::OpportunitiesRequest close_request(const ui::OpportunitiesState& observed);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class ManagerJoinActions {
|
||||
public:
|
||||
explicit ManagerJoinActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
bool commit(uint64_t& revision, std::string& error,
|
||||
const std::function<void(ui::CareerInitializationResult&)>& acknowledge = {});
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class MailboxActions {
|
||||
public:
|
||||
explicit MailboxActions(CareerSession& session) : session_(session) {}
|
||||
bool dispatch(const ui::MailboxActionRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
bool close(const ui::MailboxCloseRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
static ui::MailboxActionRequest request(int manager, uint64_t revision,
|
||||
ui::MailboxActionKind, const ui::MailboxMessage& observed);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class MenuLayoutActions {
|
||||
public:
|
||||
explicit MenuLayoutActions(CareerSession& session) : session_(session) {}
|
||||
bool dispatch(const ui::SaveLoadRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class EnvironmentActions {
|
||||
public:
|
||||
explicit EnvironmentActions(CareerSession& session) : session_(session) {}
|
||||
using Notice = std::function<bool(const GameState&, const std::string&)>;
|
||||
std::optional<EnvironmentResult> set(const ui::EnvironmentRequest&, uint64_t& revision, std::string& error,
|
||||
const Notice& = {}, const std::function<void(bool changed)>& acknowledge = {});
|
||||
std::optional<EnvironmentResult> set_console(const ui::EnvironmentView&, int item, int level,
|
||||
uint64_t& revision, std::string& error, const Notice& = {});
|
||||
static ui::EnvironmentRequest request(const ui::EnvironmentView& observed, int item, int level);
|
||||
private:
|
||||
std::optional<EnvironmentResult> set_impl(const ui::EnvironmentRequest&, uint64_t&, std::string&,
|
||||
const Notice&, const std::function<void(bool)>&, bool publish_console_result);
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class RescheduleActions {
|
||||
public:
|
||||
explicit RescheduleActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
RescheduleStatus dispatch(const ui::RescheduleAction&, uint64_t& revision,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
RescheduleStatus move(int manager, const LeagueMatchRef&, int day, uint64_t& revision);
|
||||
void undo_console(int manager, int day, uint64_t& revision);
|
||||
private:
|
||||
static RescheduleStatus change(GameState&, int manager, const LeagueMatchRef&, int day, ui::RescheduleActionKind);
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class ContractActions {
|
||||
public:
|
||||
explicit ContractActions(CareerSession& session) : session_(session) {}
|
||||
bool dispatch(const ui::ContractRequest&, uint64_t& revision, ui::ContractActionResult&, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
static ui::ContractRequest demands(const ui::ContractsState&, const ui::ContractPlayer&, uint64_t request_id);
|
||||
static ui::ContractRequest team_bonus(const ui::ContractsState&, int index, uint8_t percent, uint64_t request_id);
|
||||
static ui::ContractRequest insurance(const ui::ContractsState&, int row, int player, uint64_t quote,
|
||||
uint8_t form, uint8_t months, uint64_t request_id);
|
||||
static ui::ContractRequest offer(const ui::ContractsState&, int row, int player, uint64_t quote,
|
||||
const std::array<uint8_t,7>& bonuses, int years, uint32_t salary,
|
||||
const std::array<uint32_t,4>& demands, uint64_t request_id);
|
||||
private:
|
||||
static ui::ContractRequest bind(const ui::ContractsState&, ui::ContractActionKind, uint64_t request_id);
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class FriendlyActions {
|
||||
public:
|
||||
explicit FriendlyActions(CareerSession& session) : session_(session) {}
|
||||
struct Booking { FriendlyBookingResult result; bool applied = false, planner_mismatch = false; };
|
||||
using Accept = std::function<void(const ui::FriendlyBookingAck&)>;
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
Booking book_club(const ui::FriendlyMatchRequest&, uint64_t& revision, const Accept& = {});
|
||||
Booking book_national(const ui::FriendlyMatchRequest&, uint64_t& revision, const Accept& = {});
|
||||
FriendlyBookingResult book_console(const FriendlyBookingQuote&, uint16_t day, bool accept_opponent,
|
||||
int consenting_manager, bool accept_cost, int approving_manager, uint64_t& revision);
|
||||
FriendlyBookingQuote quote(int manager, int opponent, bool home) const;
|
||||
NationalFriendlyQuote national_quote(const NationalFriendlyOwner&, int opponent, bool home);
|
||||
FriendlyDateStatus date_status(const FriendlyBookingQuote&, uint16_t day) const;
|
||||
FriendlyDateStatus national_date_status(const NationalFriendlyQuote&, const NationalFriendlyOwner&, uint16_t day) const;
|
||||
static NationalFriendlyOwner national_owner(const ui::FriendlyMatchRequest&);
|
||||
private:
|
||||
Booking book(const ui::FriendlyMatchRequest&, uint64_t& revision, bool national, const Accept&);
|
||||
static FriendlyBookingRequest booking_request(const ui::FriendlyMatchRequest&);
|
||||
ui::FriendlyBookingAck acknowledgement(const ui::FriendlyMatchRequest&, const FriendlyBookingResult&, uint64_t revision) const;
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,47 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// EndPhase accepts physical left/right DOWN after minute2, except at the
|
||||
// first minute of a period. Its home interval ends at0x73, leaving0x74 out.
|
||||
// Returning only a side keeps the current fixture/manager lookup in Main.
|
||||
inline std::optional<int> live_matchday_board_side(const SDL_Event& event, int minute, bool indoor) {
|
||||
if (event.type != SDL_MOUSEBUTTONDOWN ||
|
||||
(event.button.button != SDL_BUTTON_LEFT && event.button.button != SDL_BUTTON_RIGHT) ||
|
||||
minute <= 2 || (indoor ? minute == 21 : (minute == 46 || minute == 91 || minute == 106)))
|
||||
return {};
|
||||
if (event.button.x >= 0 && event.button.x <= 0x73) return 0;
|
||||
if (event.button.x >= 0xa0 && event.button.x <= 0x113) return 1;
|
||||
return {};
|
||||
}
|
||||
|
||||
// Drain only while the engine is synchronously paused in its observer hook.
|
||||
// ESC skips future presentation; QUIT is reported to the app. Only noninteractive
|
||||
// system/window notifications are put back. User input is discarded so it cannot
|
||||
// become an accidental desk/result action after the synchronous match finishes.
|
||||
inline bool pump_live_matchday_events(bool& skip_presentation) {
|
||||
std::vector<SDL_Event> deferred;
|
||||
SDL_Event event;
|
||||
bool quit = false;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
quit = true;
|
||||
skip_presentation = true;
|
||||
} else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) {
|
||||
skip_presentation = true;
|
||||
} else if (event.type == SDL_USEREVENT || event.type == SDL_WINDOWEVENT ||
|
||||
event.type == SDL_DISPLAYEVENT || event.type == SDL_SYSWMEVENT) {
|
||||
deferred.push_back(event);
|
||||
}
|
||||
}
|
||||
for (auto pending : deferred) SDL_PushEvent(&pending);
|
||||
return quit;
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
+3969
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,509 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
#include "app/action_transaction.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include "game/lineup.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
namespace bmh::app {
|
||||
using detail::apply_window;
|
||||
|
||||
bool LeagueFamilyActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto before = session_.league_family_checkpoint();
|
||||
const auto old_revision = revision;
|
||||
try {
|
||||
if (action()) return true;
|
||||
} catch (...) {
|
||||
session_.restore_league_family_checkpoint(std::move(before));
|
||||
revision = old_revision;
|
||||
throw;
|
||||
}
|
||||
session_.restore_league_family_checkpoint(std::move(before));
|
||||
revision = old_revision;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<ui::LeaguePairingsState> LeagueFamilyActions::open_pairings(
|
||||
const ui::DeskState& observed, uint64_t& revision, std::string& error) {
|
||||
ui::DeskRequest request;
|
||||
request.kind = ui::DeskRequestKind::open_menu;
|
||||
request.menu_kind = 1;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.revision = observed.revision;
|
||||
for (const auto& item : observed.items)
|
||||
if (item.kind == 1) request.item_id = item.id;
|
||||
std::optional<ui::LeaguePairingsState> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_league_pairings(request, revision, error);
|
||||
return result.has_value();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::LeaguePairingsDispatch> LeagueFamilyActions::pairings(
|
||||
const ui::LeaguePairingsIdentity& observed, LeaguePairingsAction kind, int value,
|
||||
uint64_t& revision, std::string& error) {
|
||||
ui::LeaguePairingsRequest request;
|
||||
request.identity = observed;
|
||||
request.event.kind = kind;
|
||||
request.event.value = value;
|
||||
std::optional<CareerSession::LeaguePairingsDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_league_pairings(request, revision, error);
|
||||
return result.has_value();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
ui::DeskRequest LeagueFamilyActions::pairings_entry(const ui::StrengthsIdentity& identity,
|
||||
uint64_t revision) {
|
||||
return {ui::DeskRequestKind::open_menu, identity.manager, 0, 1, -1, revision};
|
||||
}
|
||||
|
||||
ui::LeaguePairingsRequest LeagueFamilyActions::pairings_selection(
|
||||
const ui::LeaguePairingsIdentity& identity, int league) {
|
||||
return {identity, {LeaguePairingsAction::select_league, league, -1}};
|
||||
}
|
||||
|
||||
ui::StrengthsRequest LeagueFamilyActions::strengths_entry(const ui::StrengthsRequest& fresh,
|
||||
const ui::StrengthsIdentity& identity) {
|
||||
auto request = fresh;
|
||||
request.identity = identity;
|
||||
request.kind = ui::StrengthsAction::open;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool TransferActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
auto state = session_.g_;
|
||||
const auto game = session_.game_;
|
||||
const auto rand = session_.rand_;
|
||||
auto owner = session_.transfer_offer_editor_;
|
||||
auto poach = session_.poach_;
|
||||
const auto owner_revision = session_.transfer_offer_revision_;
|
||||
auto runtime = session_.club_modal_runtime_;
|
||||
const auto old_revision = revision;
|
||||
const auto restore = [&] {
|
||||
session_.g_ = std::move(state);
|
||||
session_.game_ = game;
|
||||
session_.rand_ = rand;
|
||||
session_.transfer_offer_editor_ = std::move(owner);
|
||||
session_.poach_ = std::move(poach);
|
||||
session_.transfer_offer_revision_ = owner_revision;
|
||||
session_.club_modal_runtime_ = std::move(runtime);
|
||||
revision = old_revision;
|
||||
};
|
||||
try {
|
||||
if (action()) return true;
|
||||
} catch (...) {
|
||||
restore();
|
||||
throw;
|
||||
}
|
||||
restore();
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<TransferActions::MarketDispatch> TransferActions::market(
|
||||
const ui::TransferMarketRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, HumanBuyerMarketEntryPolicy policy,
|
||||
const MarketAccept& acknowledge) {
|
||||
std::optional<MarketDispatch> result;
|
||||
apply(revision, [&] {
|
||||
const auto old_revision = revision;
|
||||
if (policy == HumanBuyerMarketEntryPolicy::normal_interactive) {
|
||||
const auto action = session_.dispatch_transfer_market(request, hooks, revision, error);
|
||||
if (!action) return false;
|
||||
result = MarketDispatch{*action, revision != old_revision};
|
||||
} else {
|
||||
// Preserve the legacy caller's threshold draw even for a low offer.
|
||||
// This path predates the interactive Source sale and has its own
|
||||
// revision semantics; moving it must not merge the two policies.
|
||||
error = rejection(request, revision, policy);
|
||||
if (!error.empty()) return false;
|
||||
if (request.kind != ui::TransferMarketRequestKind::list_player &&
|
||||
request.kind != ui::TransferMarketRequestKind::submit_bid) {
|
||||
error = "Diese Transferaktion ist nicht verfügbar.";
|
||||
return false;
|
||||
}
|
||||
const auto before = save_stream(session_.state());
|
||||
const auto game_calls = session_.game().calls();
|
||||
const auto rand_calls = session_.rand().calls();
|
||||
TransferActionResult action;
|
||||
if (request.kind == ui::TransferMarketRequestKind::list_player) {
|
||||
MinuteReport report;
|
||||
action = list_manager_player(session_.state(), request.manager_slot,
|
||||
request.squad_row, session_.rand(), report);
|
||||
if (report.unsupported) throw FormatError("unsupported transfer listing");
|
||||
} else {
|
||||
action = submit_transfer_bid(session_.state(), request.bid, session_.rand());
|
||||
}
|
||||
const bool changed = session_.game().calls() != game_calls ||
|
||||
session_.rand().calls() != rand_calls || save_stream(session_.state()) != before;
|
||||
if (changed) ++revision;
|
||||
result = MarketDispatch{action, changed};
|
||||
}
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string TransferActions::rejection(const ui::TransferMarketRequest& request,
|
||||
uint64_t revision, HumanBuyerMarketEntryPolicy policy) const {
|
||||
const auto& state = session_.state();
|
||||
if (request.manager_slot < 0 || size_t(request.manager_slot) >= state.manager_teams.size() ||
|
||||
request.manager_slot > 3 || !state.memory.has(::bmh::layout::ActiveManager) ||
|
||||
state.memory.u8(::bmh::layout::ActiveManager) != request.manager_slot ||
|
||||
request.runtime_club != state.manager_teams[size_t(request.manager_slot)] ||
|
||||
request.revision != revision || revision == std::numeric_limits<uint64_t>::max())
|
||||
return "Dieses Transferangebot gehört zu einem veralteten Spielstand.";
|
||||
if (request.kind == ui::TransferMarketRequestKind::submit_bid) {
|
||||
if (request.bid.manager != request.manager_slot || request.squad_row != -1 ||
|
||||
request.expected_player != -1 ||
|
||||
std::any_of(request.bid.bonuses.begin(), request.bid.bonuses.end(), [policy](uint32_t value) {
|
||||
return value > (policy == HumanBuyerMarketEntryPolicy::normal_interactive ? 255u : 100u);
|
||||
})) return "Die Angaben zum Transferangebot sind ungültig.";
|
||||
} else if (request.kind == ui::TransferMarketRequestKind::list_player) {
|
||||
const auto range = squad_range(request.runtime_club);
|
||||
if (request.squad_row < 0 || size_t(request.squad_row) >= range.count ||
|
||||
range.first + size_t(request.squad_row) >= state.squad_slots.size() ||
|
||||
request.expected_player < 0 || request.expected_player >= 0xfff ||
|
||||
(state.squad_slots[range.first + size_t(request.squad_row)] & 0xfff) != request.expected_player)
|
||||
return "Dieser Spieler gehört nicht mehr zur gewählten Kaderposition.";
|
||||
} else if (request.kind != ui::TransferMarketRequestKind::open_offer &&
|
||||
request.kind != ui::TransferMarketRequestKind::preview_quote &&
|
||||
request.kind != ui::TransferMarketRequestKind::open_poach)
|
||||
return "Diese Transferaktion ist nicht verfügbar.";
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::open_offer(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const OfferAccept& acknowledge) {
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_transfer_offer(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> TransferActions::preview(
|
||||
const ui::TransferMarketRequest& request, uint64_t& revision, std::string& error,
|
||||
const PreviewAccept& acknowledge) {
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.preview_transfer_market(request, revision, error);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> TransferActions::offer(
|
||||
const ui::OutgoingTransferRequest& request, const HumanBuyerSaleHooks& hooks,
|
||||
uint64_t& revision, std::string& error, const TransferOfferTeamInfoPresenter& team_info,
|
||||
const TransferOfferPlayerInfoPresenter& player_info, const OfferAccept& acknowledge) {
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.dispatch_transfer_offer(request, hooks, revision, error, team_info, player_info);
|
||||
if (!result) return false;
|
||||
if (acknowledge) acknowledge(*result);
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<CareerSession::PoachDispatch> TransferActions::poach(int manager, int slot,
|
||||
uint64_t& revision, std::string& error) {
|
||||
std::optional<CareerSession::PoachDispatch> result;
|
||||
apply(revision, [&] {
|
||||
result = session_.open_poach(manager, slot, revision, error);
|
||||
return result.has_value();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
ui::TransferMarketRequest TransferActions::listing(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketSquadItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
request.kind = ui::TransferMarketRequestKind::list_player;
|
||||
request.offer_is_loan = loan;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
request.revision = observed.revision;
|
||||
request.squad_row = item.row;
|
||||
request.expected_player = item.player;
|
||||
request.selected_players.push_back({-1, observed.roster.squad_start_offset + item.row,
|
||||
item.player, observed.runtime_club, item.row});
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::TransferMarketRequest TransferActions::opening(const ui::TransferMarketState& observed,
|
||||
const ui::TransferMarketItem& item, bool loan) {
|
||||
ui::TransferMarketRequest request;
|
||||
request.kind = ui::TransferMarketRequestKind::open_offer;
|
||||
request.offer_is_loan = loan;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
request.revision = observed.revision;
|
||||
if (item.own_bid) request.bid = *item.own_bid;
|
||||
request.bid.manager = observed.manager_slot;
|
||||
request.bid.list_entry = item.list_entry;
|
||||
request.bid.player = item.player;
|
||||
request.bid.source_slot = item.source_slot;
|
||||
request.selected_players.push_back({item.list_entry, item.source_slot, item.player, item.seller, -1});
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::OutgoingTransferRequest TransferActions::editor(const ui::OutgoingTransferEditorState& observed,
|
||||
ui::OutgoingTransferRequestKind kind, ui::OutgoingTransferField field, uint32_t value) {
|
||||
ui::OutgoingTransferRequest request;
|
||||
request.kind = kind;
|
||||
request.identity = {observed.manager_slot, observed.runtime_club, observed.revision,
|
||||
observed.list_entry, observed.source_slot, observed.player, observed.seller, observed.bid_slot};
|
||||
request.field = field;
|
||||
request.value = value;
|
||||
request.quote_loan = observed.quote_loan;
|
||||
request.fee = observed.fee;
|
||||
request.monthly_salary = observed.monthly_salary;
|
||||
request.duration_years = observed.duration_years;
|
||||
request.bonuses = observed.bonuses;
|
||||
request.quoted_fee = observed.panel.quoted_fee;
|
||||
request.quoted_monthly_salary = observed.panel.quoted_monthly_salary;
|
||||
request.quoted_years = observed.panel.quoted_years;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool BankActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.bank_checkpoint(),
|
||||
[&](CareerSession::BankCheckpoint before) { session_.restore_bank_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
bool BankActions::dispatch(const ui::BankRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
if (!session_.dispatch_bank(request, revision, error)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
ui::BankRequest BankActions::bind(const ui::BankState& observed, ui::BankRequestKind kind) {
|
||||
ui::BankRequest request;
|
||||
request.kind = kind;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
request.revision = observed.revision;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::BankRequest BankActions::savings(const ui::BankState& observed, int32_t amount) {
|
||||
auto request = bind(observed, ui::BankRequestKind::move_to_deposit);
|
||||
request.amount = amount;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::BankRequest BankActions::investment(const ui::BankState& observed, ui::BankRequestKind kind,
|
||||
int asset, int count) {
|
||||
auto request = bind(observed, kind);
|
||||
request.asset_index = asset;
|
||||
request.count = count;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::BankRequest BankActions::credit(const ui::BankState& observed, const BankCreditContext& context,
|
||||
const BankCreditDraft& draft, bool accept_fees, int counterparty) {
|
||||
auto request = bind(observed, ui::BankRequestKind::bank_credit);
|
||||
request.expected_credit = context.saved;
|
||||
request.credit_edits = draft.edits;
|
||||
request.accept_credit_fees = accept_fees;
|
||||
request.credit_counterparty = counterparty;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool StadiumActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.stadium_checkpoint(),
|
||||
[&](CareerSession::StadiumCheckpoint before) { session_.restore_stadium_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
bool StadiumActions::dispatch(const ui::StadiumRequest& request, uint64_t& revision, std::string& error,
|
||||
const ConstructionNoticeHook& construction, const SeasonTicketCompensationNoticeHook& compensation,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
if (!session_.dispatch_stadium(request, revision, error, construction, compensation)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
ui::StadiumRequest StadiumActions::request(const ui::StadiumState& observed, ui::StadiumRequestKind kind,
|
||||
int object, int option, int32_t price, bool accept_tip) {
|
||||
ui::StadiumRequest request;
|
||||
request.kind = kind;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
request.stable_club_identity = observed.stable_club_identity;
|
||||
request.revision = observed.revision;
|
||||
request.scope = observed.scope;
|
||||
request.sequence = observed.sequence;
|
||||
request.object = object;
|
||||
request.option = option;
|
||||
request.price = price;
|
||||
request.accept_tip = accept_tip;
|
||||
return request;
|
||||
}
|
||||
|
||||
bool DeskActions::ticket_price(const ui::DeskState& observed, int price,
|
||||
uint64_t& revision, std::string& error) {
|
||||
TicketPriceRequest request;
|
||||
request.identity.manager_slot = observed.manager_slot;
|
||||
request.identity.runtime_club = observed.runtime_club;
|
||||
if (observed.runtime_club >= 0 && size_t(observed.runtime_club) < session_.state().club_ids.size())
|
||||
request.identity.stable_club_identity = int(session_.state().club_ids[size_t(observed.runtime_club)]);
|
||||
request.identity.revision = observed.revision;
|
||||
request.price = price;
|
||||
return session_.dispatch_ticket_price(request, revision, error);
|
||||
}
|
||||
|
||||
bool LineupActions::apply(uint64_t& revision, const std::function<bool()>& action) {
|
||||
return apply_window(session_, revision, session_.lineup_checkpoint(),
|
||||
[&](CareerSession::LineupCheckpoint before) { session_.restore_lineup_checkpoint(std::move(before)); }, action);
|
||||
}
|
||||
|
||||
bool LineupActions::lineup(const ui::LineupRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
if (!session_.dispatch_lineup(request, revision, error)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool LineupActions::pitch(const ui::PitchRequest& request, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge) {
|
||||
return apply(revision, [&] {
|
||||
if (!session_.dispatch_pitch(request, revision, error)) return false;
|
||||
if (acknowledge) acknowledge();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool LineupActions::pitch_swap(const ui::PitchRequest& request, uint64_t& revision, std::string& error) {
|
||||
return apply(revision, [&] { return session_.dispatch_pitch_swap(request, revision, error); });
|
||||
}
|
||||
|
||||
bool LineupActions::order(const ui::LineupState& observed, const ui::LineupPlayer& player,
|
||||
int aspect, int value, uint64_t& revision) {
|
||||
return apply(revision, [&] {
|
||||
if (observed.revision != revision || !set_player_order_source(session_.state(), observed.manager_slot,
|
||||
observed.runtime_club, player.row, player.player_id, aspect, value)) return false;
|
||||
++revision;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
LineupActions::PairTarget LineupActions::pair_target(const ui::PitchRequest& request, int second_row) const {
|
||||
auto preview = session_.state();
|
||||
if (!move_pitch_player_source(preview, request.manager_slot, request.runtime_club,
|
||||
request.row, request.player_id, request.slot, request.old_depth, request.old_lane,
|
||||
request.new_depth, request.new_lane)) return PairTarget::invalid;
|
||||
const size_t board = size_t(request.manager_slot) * 0x840;
|
||||
return preview.tactics.at(board + size_t(request.row) * 0x58 + 0x3f) == second_row &&
|
||||
preview.tactics.at(board + size_t(second_row) * 0x58 + 0x3f) == request.row
|
||||
? PairTarget::requested : PairTarget::other_pair;
|
||||
}
|
||||
|
||||
ui::LineupRequest LineupActions::prepare(const ui::LineupState& observed) {
|
||||
ui::LineupRequest request;
|
||||
request.kind = ui::LineupRequestKind::prepare_lineup;
|
||||
request.manager_slot = observed.manager_slot;
|
||||
request.runtime_club = observed.runtime_club;
|
||||
request.revision = observed.revision;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::LineupRequest LineupActions::swap(const ui::LineupState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = prepare(observed);
|
||||
request.kind = ui::LineupRequestKind::swap_players;
|
||||
request.first_row = first.row; request.second_row = second.row;
|
||||
request.first_player = first.player_id; request.second_player = second.player_id;
|
||||
request.first_slot = first.slot; request.second_slot = second.slot;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::PitchRequest LineupActions::bind_pitch(const ui::PreparationState& observed, ui::PitchRequestKind kind) {
|
||||
if (!observed.pitch || !observed.pitch->indoor.has_value())
|
||||
throw FormatError("pitch: missing observed live mode");
|
||||
ui::PitchRequest request;
|
||||
request.kind = kind;
|
||||
request.manager_slot = observed.lineup.manager_slot;
|
||||
request.runtime_club = observed.lineup.runtime_club;
|
||||
request.revision = observed.lineup.revision;
|
||||
request.indoor = observed.pitch->indoor.value();
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::PitchRequest LineupActions::swap_pitch(const ui::PreparationState& observed,
|
||||
const ui::LineupPlayer& first, const ui::LineupPlayer& second) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::swap_players);
|
||||
request.row = first.row; request.player_id = first.player_id; request.slot = first.slot;
|
||||
request.old_depth = int8_t(first.board[0x41]); request.old_lane = int8_t(first.board[0x42]);
|
||||
request.second_row = second.row; request.second_player = second.player_id; request.second_slot = second.slot;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::PitchRequest LineupActions::page(const ui::PreparationState& observed) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::select_pitch_page);
|
||||
request.expected_mode = uint8_t(observed.pitch->mode);
|
||||
request.expected_display_word = observed.pitch->native_display_word;
|
||||
request.expected_set_piece_values = observed.pitch->set_piece_takers;
|
||||
request.expected_set_piece_signature = observed.pitch->set_piece_signature;
|
||||
request.page_control = 1;
|
||||
request.new_display_word = uint16_t(request.expected_display_word ^ 0x000c);
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::PitchRequest LineupActions::formation(const ui::PreparationState& observed,
|
||||
ui::PitchRequestKind kind, int slot) {
|
||||
auto request = bind_pitch(observed, kind);
|
||||
request.old_weights = request.new_weights = observed.pitch->automatic_weights;
|
||||
request.formation = slot;
|
||||
if (kind == ui::PitchRequestKind::save_formation) {
|
||||
for (size_t row = 0; row < 11; ++row) {
|
||||
const auto& player = observed.lineup.players.at(row);
|
||||
request.formation_positions[row] = player.board[0x41];
|
||||
request.formation_positions[11 + row] = player.board[0x42];
|
||||
}
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::PitchRequest LineupActions::move(const ui::PreparationState& observed, const ui::LineupPlayer& player,
|
||||
int depth, int lane) {
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::move_player);
|
||||
request.old_weights = request.new_weights = observed.pitch->automatic_weights;
|
||||
request.row = player.row; request.player_id = player.player_id; request.slot = player.slot;
|
||||
request.old_depth = int8_t(player.board[0x41]); request.old_lane = int8_t(player.board[0x42]);
|
||||
request.new_depth = depth; request.new_lane = lane;
|
||||
return request;
|
||||
}
|
||||
|
||||
ui::PitchRequest LineupActions::weight(const ui::PreparationState& observed, int index) {
|
||||
if (index < 0 || index > 2) throw FormatError("pitch: invalid automatic weight index");
|
||||
auto request = bind_pitch(observed, ui::PitchRequestKind::set_automatic_weight);
|
||||
request.old_weights = request.new_weights = observed.pitch->automatic_weights;
|
||||
request.weight_index = index;
|
||||
const int shift = 2 * index;
|
||||
const int next = (((request.old_weights >> shift) & 3) + 1) & 3;
|
||||
request.new_weights = uint8_t((request.old_weights & ~(3 << shift)) | (next << shift));
|
||||
return request;
|
||||
}
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,122 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
namespace bmh::app {
|
||||
|
||||
// Shared application boundary for Table, Pairings and Strengths. The callback
|
||||
// includes the frontend's acknowledgement; false or an exception rolls back.
|
||||
class LeagueFamilyActions {
|
||||
public:
|
||||
explicit LeagueFamilyActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
std::optional<ui::LeaguePairingsState> open_pairings(const ui::DeskState& observed,
|
||||
uint64_t& revision, std::string& error);
|
||||
std::optional<CareerSession::LeaguePairingsDispatch> pairings(
|
||||
const ui::LeaguePairingsIdentity& observed, LeaguePairingsAction, int value,
|
||||
uint64_t& revision, std::string& error);
|
||||
static ui::DeskRequest pairings_entry(const ui::StrengthsIdentity&, uint64_t revision);
|
||||
static ui::LeaguePairingsRequest pairings_selection(const ui::LeaguePairingsIdentity&, int league);
|
||||
static ui::StrengthsRequest strengths_entry(const ui::StrengthsRequest&, const ui::StrengthsIdentity&);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
// Market, quote and outgoing editor share this boundary, including frontend
|
||||
// acknowledgement and the suspended poaching attempt behind an offer owner.
|
||||
class TransferActions {
|
||||
public:
|
||||
explicit TransferActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
std::string rejection(const ui::TransferMarketRequest&, uint64_t revision,
|
||||
HumanBuyerMarketEntryPolicy) const;
|
||||
struct MarketDispatch { TransferActionResult action; bool changed = false; };
|
||||
using MarketAccept = std::function<void(const MarketDispatch&)>;
|
||||
using OfferAccept = std::function<void(CareerSession::TransferOfferEditorDispatch&)>;
|
||||
using PreviewAccept = std::function<void(CareerSession::TransferMarketPreviewDispatch&)>;
|
||||
std::optional<MarketDispatch> market(const ui::TransferMarketRequest&, const HumanBuyerSaleHooks&,
|
||||
uint64_t& revision, std::string& error,
|
||||
HumanBuyerMarketEntryPolicy = HumanBuyerMarketEntryPolicy::normal_interactive,
|
||||
const MarketAccept& = {});
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> open_offer(const ui::TransferMarketRequest&,
|
||||
uint64_t& revision, std::string& error, const OfferAccept& = {});
|
||||
std::optional<CareerSession::TransferMarketPreviewDispatch> preview(const ui::TransferMarketRequest&,
|
||||
uint64_t& revision, std::string& error, const PreviewAccept& = {});
|
||||
std::optional<CareerSession::TransferOfferEditorDispatch> offer(const ui::OutgoingTransferRequest&,
|
||||
const HumanBuyerSaleHooks&, uint64_t& revision, std::string& error,
|
||||
const TransferOfferTeamInfoPresenter& = {}, const TransferOfferPlayerInfoPresenter& = {},
|
||||
const OfferAccept& = {});
|
||||
std::optional<CareerSession::PoachDispatch> poach(int manager, int squad_slot,
|
||||
uint64_t& revision, std::string& error);
|
||||
static ui::TransferMarketRequest listing(const ui::TransferMarketState&,
|
||||
const ui::TransferMarketSquadItem&, bool loan);
|
||||
static ui::TransferMarketRequest opening(const ui::TransferMarketState&,
|
||||
const ui::TransferMarketItem&, bool loan);
|
||||
static ui::OutgoingTransferRequest editor(const ui::OutgoingTransferEditorState&,
|
||||
ui::OutgoingTransferRequestKind, ui::OutgoingTransferField, uint32_t value);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class BankActions {
|
||||
public:
|
||||
explicit BankActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
bool dispatch(const ui::BankRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
static ui::BankRequest savings(const ui::BankState&, int32_t amount);
|
||||
static ui::BankRequest investment(const ui::BankState&, ui::BankRequestKind, int asset, int count = 0);
|
||||
static ui::BankRequest credit(const ui::BankState&, const BankCreditContext&,
|
||||
const BankCreditDraft&, bool accept_fees, int counterparty);
|
||||
private:
|
||||
static ui::BankRequest bind(const ui::BankState&, ui::BankRequestKind);
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class StadiumActions {
|
||||
public:
|
||||
explicit StadiumActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
bool dispatch(const ui::StadiumRequest&, uint64_t& revision, std::string& error,
|
||||
const ConstructionNoticeHook& = {}, const SeasonTicketCompensationNoticeHook& = {},
|
||||
const std::function<void()>& acknowledge = {});
|
||||
static ui::StadiumRequest request(const ui::StadiumState&, ui::StadiumRequestKind,
|
||||
int object = -1, int option = -1, int32_t price = 0, bool accept_tip = false);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class DeskActions {
|
||||
public:
|
||||
explicit DeskActions(CareerSession& session) : session_(session) {}
|
||||
bool ticket_price(const ui::DeskState& observed, int price, uint64_t& revision, std::string& error);
|
||||
private:
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
class LineupActions {
|
||||
public:
|
||||
explicit LineupActions(CareerSession& session) : session_(session) {}
|
||||
bool apply(uint64_t& revision, const std::function<bool()>& action);
|
||||
bool lineup(const ui::LineupRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
bool pitch(const ui::PitchRequest&, uint64_t& revision, std::string& error,
|
||||
const std::function<void()>& acknowledge = {});
|
||||
bool pitch_swap(const ui::PitchRequest&, uint64_t& revision, std::string& error);
|
||||
bool order(const ui::LineupState&, const ui::LineupPlayer&, int aspect, int value, uint64_t& revision);
|
||||
enum class PairTarget { invalid, other_pair, requested };
|
||||
PairTarget pair_target(const ui::PitchRequest&, int second_row) const;
|
||||
static ui::LineupRequest prepare(const ui::LineupState&);
|
||||
static ui::LineupRequest swap(const ui::LineupState&, const ui::LineupPlayer&, const ui::LineupPlayer&);
|
||||
static ui::PitchRequest swap_pitch(const ui::PreparationState&, const ui::LineupPlayer&, const ui::LineupPlayer&);
|
||||
static ui::PitchRequest page(const ui::PreparationState&);
|
||||
static ui::PitchRequest formation(const ui::PreparationState&, ui::PitchRequestKind, int slot);
|
||||
static ui::PitchRequest move(const ui::PreparationState&, const ui::LineupPlayer&, int depth, int lane);
|
||||
static ui::PitchRequest weight(const ui::PreparationState&, int index);
|
||||
private:
|
||||
static ui::PitchRequest bind_pitch(const ui::PreparationState&, ui::PitchRequestKind);
|
||||
CareerSession& session_;
|
||||
};
|
||||
|
||||
} // namespace bmh::app
|
||||
@@ -0,0 +1,26 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
add_library(openbmh_audio STATIC container.cpp playback.cpp semantic_cues.cpp music_fallback.cpp mixer.cpp
|
||||
original.cpp third_party/nuked-opl3/opl3.c)
|
||||
target_include_directories(openbmh_audio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(openbmh_audio PUBLIC ${BMH_SDL_TARGET})
|
||||
|
||||
add_executable(openbmh_sound sound_driver.cpp)
|
||||
target_link_libraries(openbmh_sound PRIVATE openbmh_audio bmhcore)
|
||||
|
||||
add_executable(openbmh_original_audio_validation original_validation.cpp)
|
||||
target_link_libraries(openbmh_original_audio_validation PRIVATE openbmh_audio bmhcore)
|
||||
bmh_add_data_test(NAME openbmh_original_audio_validation COMMAND openbmh_original_audio_validation "${BMH_DATA}")
|
||||
set_tests_properties(openbmh_original_audio_validation PROPERTIES
|
||||
ENVIRONMENT "SDL_AUDIODRIVER=dummy;SDL_VIDEODRIVER=dummy")
|
||||
|
||||
add_executable(openbmh_audio_validation validation.cpp)
|
||||
target_link_libraries(openbmh_audio_validation PRIVATE openbmh_audio)
|
||||
add_test(NAME openbmh_audio_validation COMMAND openbmh_audio_validation)
|
||||
set_tests_properties(openbmh_audio_validation PROPERTIES ENVIRONMENT "SDL_AUDIODRIVER=dummy;SDL_VIDEODRIVER=dummy")
|
||||
|
||||
# SDL.h renames main to SDL_main on Windows: the two programs need SDL2main for the entry point
|
||||
if(TARGET SDL2::SDL2main)
|
||||
target_link_libraries(openbmh_sound PRIVATE SDL2::SDL2main)
|
||||
target_link_libraries(openbmh_audio_validation PRIVATE SDL2::SDL2main)
|
||||
target_link_libraries(openbmh_original_audio_validation PRIVATE SDL2::SDL2main)
|
||||
endif()
|
||||
@@ -0,0 +1,190 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "container.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
namespace openbmh::audio {
|
||||
namespace {
|
||||
std::uint32_t read_le32(std::span<const std::uint8_t> bytes, std::size_t at) {
|
||||
return static_cast<std::uint32_t>(bytes[at]) |
|
||||
(static_cast<std::uint32_t>(bytes[at + 1]) << 8) |
|
||||
(static_cast<std::uint32_t>(bytes[at + 2]) << 16) |
|
||||
(static_cast<std::uint32_t>(bytes[at + 3]) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
bool parse_container(std::span<const std::uint8_t> bytes, Container& out,
|
||||
std::string& error) {
|
||||
out.chunks.clear();
|
||||
error.clear();
|
||||
if (bytes.size() < 16) {
|
||||
error = "truncated FORM/ALPTRAUM header";
|
||||
return false;
|
||||
}
|
||||
if (bytes[0] != 'F' || bytes[1] != 'O' || bytes[2] != 'R' || bytes[3] != 'M') {
|
||||
error = "missing FORM signature";
|
||||
return false;
|
||||
}
|
||||
if (std::string(bytes.begin() + 8, bytes.begin() + 16) != "ALPTRAUM") {
|
||||
error = "unsupported FORM type (expected ALPTRAUM)";
|
||||
return false;
|
||||
}
|
||||
const auto declared = read_le32(bytes, 4);
|
||||
if (declared != bytes.size() - 8 && declared != bytes.size()) {
|
||||
error = "FORM length does not match either observed ALPTRAUM convention";
|
||||
return false;
|
||||
}
|
||||
// The only observed full-file-size header is S/2003's SEFX variant. Keep
|
||||
// this exception tied to that exact, byte-verified layout; do not silently
|
||||
// accept it for the SONG/TRCK/PART music containers.
|
||||
const bool sefx_variant = declared == bytes.size() && bytes.size() == 65380 &&
|
||||
bytes[16] == 'H' && bytes[17] == 'E' && bytes[18] == 'D' && bytes[19] == 'R' &&
|
||||
bytes[32] == 'S' && bytes[33] == 'E' && bytes[34] == 'F' && bytes[35] == 'X';
|
||||
if (declared == bytes.size() && !sefx_variant) {
|
||||
error = "full-file FORM length is only established for the 2003 SEFX variant";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::size_t at = 16;
|
||||
while (at < bytes.size()) {
|
||||
if (bytes.size() - at < 8) {
|
||||
error = "truncated chunk header";
|
||||
out.chunks.clear();
|
||||
return false;
|
||||
}
|
||||
const std::uint32_t size = read_le32(bytes, at + 4);
|
||||
const std::size_t payload = at + 8;
|
||||
if (size > bytes.size() - payload) {
|
||||
error = "chunk payload exceeds container bounds";
|
||||
out.chunks.clear();
|
||||
return false;
|
||||
}
|
||||
out.chunks.push_back({std::string(bytes.begin() + at, bytes.begin() + at + 4),
|
||||
payload, size});
|
||||
at = payload + size;
|
||||
}
|
||||
if (sefx_variant && (out.chunks.size() != 4 || out.chunks[0].id != "HEDR" ||
|
||||
out.chunks[1].id != "SEFX" || out.chunks[2].id != "INST" ||
|
||||
out.chunks[3].id != "SAMP" || out.chunks[0].payload_size != 8 ||
|
||||
out.chunks[1].payload_size != 212 || out.chunks[2].payload_size != 228 ||
|
||||
out.chunks[3].payload_size != 64884)) {
|
||||
error = "full-file FORM length does not match the observed 2003 SEFX chunk layout";
|
||||
out.chunks.clear();
|
||||
return false;
|
||||
}
|
||||
if (sefx_variant) {
|
||||
const auto& sefx = out.chunks[1];
|
||||
const auto payload = bytes.subspan(sefx.payload_offset, sefx.payload_size);
|
||||
const std::size_t records = (payload.size() - 4) / 16;
|
||||
if (payload[0] != 0 || payload[1] != 0 || payload[2] != 7 || payload[3] != 0 ||
|
||||
(payload.size() - 4) % 16 != 0 || records != 13) {
|
||||
error = "2003 SEFX prefix or fixed-record table is malformed";
|
||||
out.chunks.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_sample(std::span<const std::uint8_t> payload, std::size_t index,
|
||||
PcmSample& out, std::string& error) {
|
||||
out = {};
|
||||
error.clear();
|
||||
if (payload.size() < 4) { error = "truncated SAMP header"; return false; }
|
||||
const std::size_t count = static_cast<std::size_t>(payload[2]) |
|
||||
(static_cast<std::size_t>(payload[3]) << 8);
|
||||
constexpr std::size_t kRecordSize = 16;
|
||||
constexpr std::size_t kMaxSamples = 256;
|
||||
if (count > kMaxSamples || count > (payload.size() - 4) / kRecordSize) {
|
||||
error = "SAMP descriptor table exceeds payload bounds"; return false;
|
||||
}
|
||||
if (index >= count) { error = "sample index is outside the SAMP table"; return false; }
|
||||
const std::size_t data_offset = 4 + count * kRecordSize;
|
||||
const std::size_t record = 4 + index * kRecordSize;
|
||||
const std::uint32_t start = static_cast<std::uint32_t>(payload[record]) |
|
||||
(static_cast<std::uint32_t>(payload[record + 1]) << 8);
|
||||
const std::uint32_t length = static_cast<std::uint32_t>(payload[record + 2]) |
|
||||
(static_cast<std::uint32_t>(payload[record + 3]) << 8);
|
||||
const std::uint32_t rate = static_cast<std::uint32_t>(payload[record + 8]) |
|
||||
(static_cast<std::uint32_t>(payload[record + 9]) << 8);
|
||||
const std::size_t data_size = payload.size() - data_offset;
|
||||
if (length == 0 || start > data_size || length > data_size - start) {
|
||||
error = "SAMP sample span exceeds sample payload"; return false;
|
||||
}
|
||||
if (rate < 4000 || rate > 48000) {
|
||||
error = "unsupported SAMP sample rate"; return false;
|
||||
}
|
||||
out.sample_rate = rate;
|
||||
out.mono.reserve(length);
|
||||
const std::size_t first = data_offset + start;
|
||||
for (std::size_t i = 0; i < length; ++i) {
|
||||
out.mono.push_back(static_cast<std::int16_t>(
|
||||
(static_cast<int>(payload[first + i]) - 128) * 256));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_original_cue(std::span<const std::uint8_t> bytes,
|
||||
std::uint8_t original_id, OriginalCue& out,
|
||||
std::string& error) {
|
||||
out = {};
|
||||
error.clear();
|
||||
if (original_id < 10 || original_id > 22) {
|
||||
error = "original SFX ID is outside the observed 10..22 dispatch range";
|
||||
return false;
|
||||
}
|
||||
Container container;
|
||||
if (!parse_container(bytes, container, error)) return false;
|
||||
const auto declared_form = read_le32(bytes, 4);
|
||||
if (bytes.size() != 65380 || declared_form != bytes.size() || container.chunks.size() != 4 ||
|
||||
container.chunks[0].id != "HEDR" || container.chunks[0].payload_size != 8 ||
|
||||
container.chunks[1].id != "SEFX" || container.chunks[1].payload_size != 212 ||
|
||||
container.chunks[2].id != "INST" || container.chunks[2].payload_size != 228 ||
|
||||
container.chunks[3].id != "SAMP" || container.chunks[3].payload_size != 64884) {
|
||||
error = "original cue decoding is limited to the exact observed 2003 SEFX bank";
|
||||
return false;
|
||||
}
|
||||
const auto find = [&container](const char* id) -> const Chunk* {
|
||||
const auto it = std::find_if(container.chunks.begin(), container.chunks.end(),
|
||||
[id](const Chunk& c) { return c.id == id; });
|
||||
return it == container.chunks.end() ? nullptr : &*it;
|
||||
};
|
||||
const Chunk* sefx = find("SEFX");
|
||||
const Chunk* samp = find("SAMP");
|
||||
if (!sefx || !samp) {
|
||||
error = "original cue needs both SEFX and SAMP chunks";
|
||||
return false;
|
||||
}
|
||||
const auto sefx_data = bytes.subspan(sefx->payload_offset, sefx->payload_size);
|
||||
constexpr std::size_t kPrefixBytes = 4;
|
||||
constexpr std::size_t kRecordBytes = 16;
|
||||
constexpr std::size_t kRecordCount = 13;
|
||||
if (sefx_data.size() != kPrefixBytes + kRecordBytes * kRecordCount ||
|
||||
sefx_data[0] != 0 || sefx_data[1] != 0 || sefx_data[2] != 7 || sefx_data[3] != 0) {
|
||||
error = "unsupported SEFX layout for original-cue lookup";
|
||||
return false;
|
||||
}
|
||||
// PauseMusic subtracts 10 before dispatch. Subspan indexes that
|
||||
// SEFX record; its type-9 records address the loaded sample slots 16..21.
|
||||
const std::size_t sefx_index = static_cast<std::size_t>(original_id - 10);
|
||||
const std::size_t record = kPrefixBytes + sefx_index * kRecordBytes;
|
||||
const std::uint8_t sample_slot = sefx_data[record];
|
||||
if (sefx_data[record + 1] != 9 || sample_slot < 16 || sample_slot > 21) {
|
||||
error = "original cue is not a directly decoded type-9 SAMP effect";
|
||||
return false;
|
||||
}
|
||||
const auto sample_index = static_cast<std::size_t>(sample_slot - 16);
|
||||
const auto samp_data = bytes.subspan(samp->payload_offset, samp->payload_size);
|
||||
if (samp_data[2] != 6 || samp_data[3] != 0) {
|
||||
error = "2003 SAMP table does not have the six observed entries";
|
||||
return false;
|
||||
}
|
||||
if (!decode_sample(samp_data, sample_index, out.pcm, error)) return false;
|
||||
out.original_id = original_id;
|
||||
out.sefx_index = static_cast<std::uint8_t>(sefx_index);
|
||||
out.sample_index = static_cast<std::uint8_t>(sample_index);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openbmh::audio {
|
||||
|
||||
struct Chunk {
|
||||
std::string id;
|
||||
std::size_t payload_offset{};
|
||||
std::size_t payload_size{};
|
||||
};
|
||||
|
||||
struct Container { std::vector<Chunk> chunks; };
|
||||
|
||||
struct PcmSample {
|
||||
std::uint32_t sample_rate{};
|
||||
std::vector<std::int16_t> mono;
|
||||
};
|
||||
|
||||
struct OriginalCue {
|
||||
std::uint8_t original_id{};
|
||||
std::uint8_t sefx_index{};
|
||||
std::uint8_t sample_index{};
|
||||
PcmSample pcm;
|
||||
};
|
||||
|
||||
// Parses the observed FORM/ALPTRAUM wrapper. Chunk lengths are little endian;
|
||||
// chunks are adjacent with no alignment byte. Payloads remain in the caller's buffer.
|
||||
bool parse_container(std::span<const std::uint8_t> bytes, Container& out,
|
||||
std::string& error);
|
||||
|
||||
// Converts one bounded SAMP sample span from unsigned 8-bit DMA data to signed
|
||||
// 16-bit mono PCM, using the rate stored in its 16-byte descriptor.
|
||||
bool decode_sample(std::span<const std::uint8_t> samp_payload, std::size_t index,
|
||||
PcmSample& out, std::string& error);
|
||||
|
||||
// Resolves only the observed PCM-backed SEFX effects (original IDs 17..22).
|
||||
// IDs 10..16 use the separate instrument path and remain unsupported here.
|
||||
bool decode_original_cue(std::span<const std::uint8_t> container_bytes,
|
||||
std::uint8_t original_id, OriginalCue& out,
|
||||
std::string& error);
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,129 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "mixer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
namespace openbmh::audio {
|
||||
namespace {
|
||||
constexpr std::size_t kMaxLoopBytes = 2U * 1024U * 1024U;
|
||||
constexpr std::size_t kMaxVoiceBytes = 2U * 1024U * 1024U;
|
||||
constexpr std::size_t kMaxPerVoiceBytes = kMaxVoiceBytes / 8;
|
||||
|
||||
bool convert_rate(std::span<const std::int16_t> input, std::uint32_t source_rate,
|
||||
std::uint32_t output_rate, std::size_t byte_limit,
|
||||
std::vector<std::int16_t>& output, std::string& error) {
|
||||
output.clear();
|
||||
if (input.empty() || source_rate < 4000 || source_rate > 192000 ||
|
||||
output_rate < 4000 || output_rate > 192000) {
|
||||
error = "invalid PCM rate or empty input";
|
||||
return false;
|
||||
}
|
||||
if (input.size() > (std::numeric_limits<std::uint64_t>::max() - source_rate / 2) /
|
||||
output_rate) {
|
||||
error = "PCM input size overflows sample-rate conversion";
|
||||
return false;
|
||||
}
|
||||
const auto count64 = (static_cast<std::uint64_t>(input.size()) * output_rate + source_rate / 2) /
|
||||
source_rate;
|
||||
if (!count64 || count64 > byte_limit / sizeof(std::int16_t) ||
|
||||
count64 > std::numeric_limits<std::size_t>::max()) {
|
||||
error = "converted PCM exceeds mixer buffer limit";
|
||||
return false;
|
||||
}
|
||||
const auto count = static_cast<std::size_t>(count64);
|
||||
output.resize(count);
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
const auto source_index = std::min(input.size() - 1,
|
||||
static_cast<std::size_t>((static_cast<std::uint64_t>(i) * source_rate + output_rate / 2) /
|
||||
output_rate));
|
||||
output[i] = input[source_index];
|
||||
}
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Mixer::start_music_loop(const PcmSample& loop, std::uint32_t output_rate,
|
||||
std::string& error) {
|
||||
std::vector<std::int16_t> converted;
|
||||
if (!convert_rate(loop.mono, loop.sample_rate, output_rate, kMaxLoopBytes, converted, error))
|
||||
return false;
|
||||
music_ = std::move(converted);
|
||||
music_cursor_ = 0;
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Mixer::stop_music() noexcept {
|
||||
music_.clear();
|
||||
music_cursor_ = 0;
|
||||
}
|
||||
|
||||
bool Mixer::add_voice(std::span<const std::int16_t> samples, std::uint32_t sample_rate,
|
||||
std::uint32_t output_rate, std::string& error) {
|
||||
std::vector<std::int16_t> converted;
|
||||
if (!convert_rate(samples, sample_rate, output_rate, kMaxPerVoiceBytes, converted, error))
|
||||
return false;
|
||||
if (converted.size() * sizeof(std::int16_t) > kMaxVoiceBytes - voice_bytes_) {
|
||||
error = "combined active cue voices exceed mixer buffer limit";
|
||||
return false;
|
||||
}
|
||||
const auto free_voice = std::find_if(voices_.begin(), voices_.end(),
|
||||
[](const Voice& voice) { return voice.cursor >= voice.samples.size(); });
|
||||
if (free_voice == voices_.end()) {
|
||||
error = "all fixed mixer cue voices are active";
|
||||
return false;
|
||||
}
|
||||
voice_bytes_ += converted.size() * sizeof(std::int16_t);
|
||||
free_voice->samples = std::move(converted);
|
||||
free_voice->cursor = 0;
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Mixer::clear() noexcept {
|
||||
stop_music();
|
||||
for (auto& voice : voices_) {
|
||||
voice.samples.clear();
|
||||
voice.cursor = 0;
|
||||
}
|
||||
voice_bytes_ = 0;
|
||||
}
|
||||
|
||||
bool Mixer::active() const noexcept {
|
||||
return !music_.empty() || active_voices() != 0;
|
||||
}
|
||||
|
||||
std::size_t Mixer::active_voices() const noexcept {
|
||||
return static_cast<std::size_t>(std::count_if(voices_.begin(), voices_.end(),
|
||||
[](const Voice& voice) { return voice.cursor < voice.samples.size(); }));
|
||||
}
|
||||
|
||||
bool Mixer::mix_block(std::span<std::int16_t> output, float volume) noexcept {
|
||||
if (!active() || output.empty() || !std::isfinite(volume)) return false;
|
||||
const float bounded_volume = std::clamp(volume, 0.0F, 1.0F);
|
||||
for (auto& dst : output) {
|
||||
std::int32_t mixed = 0;
|
||||
if (!music_.empty()) {
|
||||
mixed += music_[music_cursor_++];
|
||||
if (music_cursor_ == music_.size()) music_cursor_ = 0;
|
||||
}
|
||||
for (auto& voice : voices_) {
|
||||
if (voice.cursor < voice.samples.size()) {
|
||||
mixed += voice.samples[voice.cursor++];
|
||||
if (voice.cursor == voice.samples.size()) {
|
||||
voice_bytes_ -= voice.samples.size() * sizeof(std::int16_t);
|
||||
voice.samples.clear();
|
||||
voice.cursor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto scaled = std::lround(static_cast<float>(mixed) * bounded_volume);
|
||||
dst = static_cast<std::int16_t>(std::clamp<long>(scaled, -32768, 32767));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,38 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openbmh::audio {
|
||||
|
||||
// Small allocation-bounded PCM mixer. Setup/add_voice may allocate; mix_block
|
||||
// only reads its prepared buffers and writes into caller-owned storage.
|
||||
class Mixer {
|
||||
public:
|
||||
bool start_music_loop(const PcmSample& loop, std::uint32_t output_rate,
|
||||
std::string& error);
|
||||
void stop_music() noexcept;
|
||||
bool add_voice(std::span<const std::int16_t> samples, std::uint32_t sample_rate,
|
||||
std::uint32_t output_rate, std::string& error);
|
||||
void clear() noexcept;
|
||||
bool active() const noexcept;
|
||||
bool has_music() const noexcept { return !music_.empty(); }
|
||||
std::size_t active_voices() const noexcept;
|
||||
bool mix_block(std::span<std::int16_t> output, float volume) noexcept;
|
||||
|
||||
private:
|
||||
struct Voice { std::vector<std::int16_t> samples; std::size_t cursor{}; };
|
||||
std::vector<std::int16_t> music_;
|
||||
std::size_t music_cursor_{};
|
||||
std::array<Voice, 8> voices_{};
|
||||
std::size_t voice_bytes_{};
|
||||
};
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,91 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "music_fallback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
namespace openbmh::audio {
|
||||
namespace {
|
||||
constexpr std::uint32_t kRate = 22050;
|
||||
constexpr std::uint32_t kBeatsPerMinute = 108;
|
||||
constexpr std::uint32_t kBars = 8;
|
||||
constexpr std::uint32_t kBeatsPerBar = 4;
|
||||
constexpr double kPi = 3.14159265358979323846;
|
||||
constexpr std::size_t kLoopFrames =
|
||||
static_cast<std::size_t>(kRate) * 60 * kBars * kBeatsPerBar / kBeatsPerMinute;
|
||||
|
||||
constexpr std::array<int, 4> kBassMidi{43, 38, 40, 36}; // G2, D2, E2, C2
|
||||
constexpr std::array<std::array<int, 3>, 4> kChordMidi{{
|
||||
{{55, 59, 62}}, // G major
|
||||
{{50, 54, 57}}, // D major
|
||||
{{52, 55, 59}}, // E minor
|
||||
{{48, 52, 55}}, // C major
|
||||
}};
|
||||
constexpr std::array<int, 16> kLeadMidi{
|
||||
67, 71, 74, 71, 69, 74, 78, 74,
|
||||
71, 76, 79, 76, 67, 72, 76, 72,
|
||||
};
|
||||
|
||||
double midi_hz(int midi) {
|
||||
return 440.0 * std::pow(2.0, static_cast<double>(midi - 69) / 12.0);
|
||||
}
|
||||
|
||||
std::int16_t clamp_sample(double value) {
|
||||
const auto rounded = static_cast<long>(std::lround(value));
|
||||
return static_cast<std::int16_t>(std::clamp(rounded, -32768L, 32767L));
|
||||
}
|
||||
}
|
||||
|
||||
bool synthesize_matchday_music_loop(PcmSample& out, std::string& error) {
|
||||
out = {};
|
||||
error.clear();
|
||||
out.sample_rate = kRate;
|
||||
out.mono.resize(kLoopFrames);
|
||||
|
||||
const double samples_per_beat = static_cast<double>(kRate) * 60.0 / kBeatsPerMinute;
|
||||
const std::size_t lead_gate = static_cast<std::size_t>(samples_per_beat * 0.72);
|
||||
const std::size_t fade_frames = kRate / 200; // 5 ms endpoint ramp for a clean loop seam.
|
||||
|
||||
for (std::size_t frame = 0; frame < kLoopFrames; ++frame) {
|
||||
const double beat_position = static_cast<double>(frame) / samples_per_beat;
|
||||
const auto bar = static_cast<std::size_t>(beat_position / kBeatsPerBar) % kBars;
|
||||
const double beat_fraction = std::fmod(beat_position, 1.0);
|
||||
const double bar_fraction = std::fmod(beat_position / kBeatsPerBar, 1.0);
|
||||
|
||||
const double bass_phase = 2.0 * kPi * midi_hz(kBassMidi[bar % 4]) * frame / kRate;
|
||||
const double bass_envelope = 0.78 + 0.22 * std::cos(kPi * beat_fraction);
|
||||
double mixed = 2600.0 * bass_envelope *
|
||||
(std::sin(bass_phase) + 0.18 * std::sin(2.0 * bass_phase));
|
||||
|
||||
const auto& chord = kChordMidi[bar % 4];
|
||||
const double pad_envelope = 0.58 + 0.16 * std::cos(2.0 * kPi * bar_fraction);
|
||||
for (std::size_t note = 0; note < chord.size(); ++note) {
|
||||
const double phase = 2.0 * kPi * midi_hz(chord[note]) * frame / kRate;
|
||||
mixed += 1350.0 * pad_envelope *
|
||||
(std::sin(phase) + 0.12 * std::sin(2.0 * phase));
|
||||
}
|
||||
|
||||
// A short eighth-note lead gives the loop a recognizable repeated motif.
|
||||
const auto step = static_cast<std::size_t>(beat_position * 2.0) % kLeadMidi.size();
|
||||
const double step_fraction = std::fmod(beat_position * 2.0, 1.0);
|
||||
const auto lead_elapsed = static_cast<std::size_t>(step_fraction * samples_per_beat / 2.0);
|
||||
if (lead_elapsed < lead_gate) {
|
||||
const double phase = 2.0 * kPi * midi_hz(kLeadMidi[step]) * lead_elapsed / kRate;
|
||||
const double attack = std::min(1.0, static_cast<double>(lead_elapsed) / (kRate / 160));
|
||||
const double release = std::min(1.0,
|
||||
static_cast<double>(lead_gate - lead_elapsed) / (kRate / 35));
|
||||
const double envelope = std::min(attack, release);
|
||||
mixed += 3600.0 * envelope *
|
||||
(std::sin(phase) + 0.22 * std::sin(2.0 * phase));
|
||||
}
|
||||
|
||||
const auto edge = std::min(frame, kLoopFrames - 1 - frame);
|
||||
const double seam_envelope = std::min(1.0, static_cast<double>(edge) / fade_frames);
|
||||
out.mono[frame] = clamp_sample(mixed * seam_envelope);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openbmh::audio {
|
||||
|
||||
// Builds an explicitly synthetic, deterministic 8-bar matchday loop. This is
|
||||
// presentation fallback material, not decoded original music or a Sound ID.
|
||||
bool synthesize_matchday_music_loop(PcmSample& out, std::string& error);
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,468 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "original.hpp"
|
||||
#include "container.hpp"
|
||||
#include "third_party/nuked-opl3/opl3.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace openbmh::audio {
|
||||
namespace {
|
||||
using Bytes = std::span<const std::uint8_t>;
|
||||
std::uint16_t word(Bytes b, std::size_t at) {
|
||||
if (at > b.size() || b.size() - at < 2) throw std::runtime_error("truncated audio word");
|
||||
return std::uint16_t(b[at] | (unsigned(b[at + 1]) << 8));
|
||||
}
|
||||
std::uint32_t dword(Bytes b, std::size_t at) {
|
||||
return std::uint32_t(word(b, at)) | (std::uint32_t(word(b, at + 2)) << 16);
|
||||
}
|
||||
Bytes chunk(Bytes bytes, const Container& c, const char* name) {
|
||||
const Chunk* found = nullptr;
|
||||
for (const auto& p : c.chunks) if (p.id == name) {
|
||||
if (found) throw std::runtime_error("duplicate Original audio chunk");
|
||||
found = &p;
|
||||
}
|
||||
if (!found) throw std::runtime_error(std::string("missing Original audio chunk ") + name);
|
||||
return bytes.subspan(found->payload_offset, found->payload_size);
|
||||
}
|
||||
bool room(Bytes b, std::size_t at, std::size_t n) noexcept {
|
||||
return at <= b.size() && n <= b.size() - at;
|
||||
}
|
||||
}
|
||||
|
||||
struct OriginalSynth::State {
|
||||
struct Sample { Bytes data, loop; std::uint8_t time_constant{}; };
|
||||
struct Bank {
|
||||
std::vector<std::array<std::uint8_t, 32>> instruments;
|
||||
std::vector<Sample> samples;
|
||||
};
|
||||
struct Song : Bank {
|
||||
Bytes tracks, parts;
|
||||
std::array<std::size_t, 16> start{}, loop{};
|
||||
std::vector<std::size_t> patterns;
|
||||
std::uint16_t tempo{}, end{}, repeat{};
|
||||
};
|
||||
struct Track {
|
||||
std::size_t next{}, loop{}, cursor{};
|
||||
std::uint8_t tick{}, instrument{}, volume{}, transpose{}, first{}, end{}, channel{};
|
||||
bool active{};
|
||||
};
|
||||
struct Channel {
|
||||
std::uint8_t duration{}, instrument{255}, level{255}, high{}, reserved{}, release{255}, priority{};
|
||||
std::uint8_t modulator{}, carrier{};
|
||||
};
|
||||
OriginalAssets assets;
|
||||
std::array<Song, 3> songs;
|
||||
Bank effects;
|
||||
std::array<std::array<std::uint8_t, 16>, 13> sfx{};
|
||||
std::array<Track, 16> tracks{};
|
||||
std::array<Channel, 9> channels{};
|
||||
opl3_chip chip{};
|
||||
OriginalAudioOptions options;
|
||||
OriginalAudioStats stats;
|
||||
std::uint32_t rate{};
|
||||
std::uint64_t pit_phase{}, dma_phase{};
|
||||
Bytes dma;
|
||||
std::size_t dma_cursor{};
|
||||
std::uint8_t dma_constant{}, dma_priority{}, dma_slot{}, ambient_slot{255};
|
||||
bool dma_loop{}, dma_effect{}, dry{};
|
||||
unsigned tempo_tick{};
|
||||
std::function<void(std::uint8_t, std::uint8_t)> register_observer;
|
||||
std::function<void(std::uint8_t)> sample_observer;
|
||||
|
||||
void write(std::uint8_t reg, std::uint8_t value) noexcept {
|
||||
if (dry) return;
|
||||
++stats.register_writes;
|
||||
OPL3_WriteRegBuffered(&chip, reg, value);
|
||||
if (register_observer) register_observer(reg, value);
|
||||
}
|
||||
void reset_chip() noexcept {
|
||||
OPL3_Reset(&chip, rate);
|
||||
for (const auto [r, v] : std::array<std::pair<std::uint8_t, std::uint8_t>, 7>{{
|
||||
{1, 0x20}, {8, 0}, {2, 0}, {3, 0}, {4, 0x60}, {4, 0x80}, {0xbd, 0}}}) write(r, v);
|
||||
}
|
||||
static Bank read_bank(Bytes raw, const Container& container) {
|
||||
Bank bank;
|
||||
const auto inst = chunk(raw, container, "INST");
|
||||
const auto count = word(inst, 2);
|
||||
if (word(inst, 0) != 0 || count > 128 || inst.size() != 4u + 32u * count)
|
||||
throw std::runtime_error("invalid Original INST table");
|
||||
bank.instruments.resize(count);
|
||||
for (unsigned i = 0; i < count; ++i)
|
||||
std::copy_n(inst.begin() + 4 + i * 32, 32, bank.instruments[i].begin());
|
||||
const auto samp = chunk(raw, container, "SAMP");
|
||||
const auto n = word(samp, 2);
|
||||
if (word(samp, 0) != 0 || n > 16 || !room(samp, 4, std::size_t(n) * 16))
|
||||
throw std::runtime_error("invalid Original SAMP table");
|
||||
const auto data = samp.subspan(4 + n * 16);
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
const auto desc = samp.subspan(4 + i * 16, 16);
|
||||
const auto begin = word(desc, 0), length = word(desc, 2);
|
||||
if (!length || !room(data, begin, length)) throw std::runtime_error("invalid Original sample span");
|
||||
Sample s{data.subspan(begin, length), {}, desc[11]};
|
||||
if (desc[10]) {
|
||||
const auto start = word(desc, 4), size = word(desc, 6);
|
||||
if (!size || !room(data, start, size)) throw std::runtime_error("invalid Original sample loop");
|
||||
s.loop = data.subspan(start, size);
|
||||
}
|
||||
bank.samples.push_back(s);
|
||||
}
|
||||
return bank;
|
||||
}
|
||||
bool parse(std::string& error) {
|
||||
for (unsigned i = 0; i < 4; ++i) {
|
||||
const Bytes raw = assets.containers[i];
|
||||
Container container;
|
||||
if (!parse_container(raw, container, error)) return false;
|
||||
const auto header = chunk(raw, container, "HEDR");
|
||||
if (header.size() != 8 || word(header, 0) != 1 || word(header, 2) != 0 ||
|
||||
word(header, 4) != 1 || word(header, 6) != 1)
|
||||
throw std::runtime_error("unsupported Original sound driver variant");
|
||||
auto bank = read_bank(raw, container);
|
||||
if (i == 3) {
|
||||
effects = std::move(bank);
|
||||
const auto fx = chunk(raw, container, "SEFX");
|
||||
if (fx.size() != 4 + sfx.size() * 16) throw std::runtime_error("invalid Original SEFX table");
|
||||
for (unsigned n = 0; n < sfx.size(); ++n) {
|
||||
std::copy_n(fx.begin() + 4 + n * 16, 16, sfx[n].begin());
|
||||
const auto& f = sfx[n];
|
||||
if (f[1] == 9) {
|
||||
if (f[0] < 16 || f[0] - 16 >= effects.samples.size())
|
||||
throw std::runtime_error("SEFX sample outside bank");
|
||||
} else if (f[1] >= 9 || !(f[0] & 128) || (f[0] & 127) >= effects.instruments.size() ||
|
||||
f[2] >= assets.tables.frequencies.size() || f[4] > 63)
|
||||
throw std::runtime_error("SEFX instrument, channel, note or level outside bank");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Song& song = songs[i];
|
||||
static_cast<Bank&>(song) = std::move(bank);
|
||||
const auto info = chunk(raw, container, "SONG");
|
||||
if (info.size() != 10 || word(info, 0) != 0) throw std::runtime_error("invalid Original SONG header");
|
||||
song.tempo = word(info, 4); song.end = word(info, 6); song.repeat = word(info, 8);
|
||||
if (!song.tempo || song.tempo > 1024 || !song.end || song.end > 8192 || song.repeat > song.end)
|
||||
throw std::runtime_error("invalid Original song timing");
|
||||
const auto tr = chunk(raw, container, "TRCK");
|
||||
if (word(tr, 0) != 0 || word(tr, 2) != 16 || tr.size() < 132)
|
||||
throw std::runtime_error("invalid Original TRCK table");
|
||||
song.tracks = tr.subspan(132);
|
||||
for (unsigned t = 0; t < 16; ++t) {
|
||||
song.start[t] = dword(tr, 4 + 4 * t); song.loop[t] = dword(tr, 68 + 4 * t);
|
||||
if (!room(song.tracks, song.start[t], 8) || !room(song.tracks, song.loop[t], 8))
|
||||
throw std::runtime_error("Original track pointer outside table");
|
||||
}
|
||||
const auto part = chunk(raw, container, "PART");
|
||||
const auto patterns = word(part, 2);
|
||||
if (word(part, 0) != 0 || !patterns || patterns > 256 || !room(part, 4, patterns * 4))
|
||||
throw std::runtime_error("invalid Original PART table");
|
||||
song.parts = part.subspan(4 + patterns * 4);
|
||||
for (unsigned p = 0; p < patterns; ++p) {
|
||||
const auto start = dword(part, 4 + p * 4);
|
||||
if (start >= song.parts.size()) throw std::runtime_error("Original pattern pointer outside table");
|
||||
song.patterns.push_back(start);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void fail() noexcept { stats.failed = true; stats.playing = false; dma = {}; }
|
||||
void level(unsigned c, std::uint8_t value) noexcept {
|
||||
if (c >= 9 || value > 63) { fail(); return; }
|
||||
auto& ch = channels[c];
|
||||
if (ch.level == value) return;
|
||||
ch.level = value;
|
||||
// Uint8T5's 64x64 table, generated there at runtime.
|
||||
const auto scale = [value](std::uint8_t tl) {
|
||||
return std::uint8_t((tl & 0xc0) | (63 - (unsigned(value) * (64 - (tl & 63)) >> 6)));
|
||||
};
|
||||
write(assets.tables.operators[c] + 0x20, scale(ch.modulator));
|
||||
write(assets.tables.operators[c] + 0x23, scale(ch.carrier));
|
||||
}
|
||||
void instrument(unsigned c, std::uint8_t id) noexcept {
|
||||
if (c >= 9) { fail(); return; }
|
||||
const Bank& bank = id & 128 ? effects : songs[stats.song];
|
||||
if ((id & 127) >= bank.instruments.size()) { fail(); return; }
|
||||
auto& ch = channels[c]; ch.instrument = id;
|
||||
const auto& in = bank.instruments[id & 127];
|
||||
ch.modulator = in[2]; ch.carrier = in[3]; ch.level = 255;
|
||||
const unsigned op = assets.tables.operators[c];
|
||||
write(op, in[0]); write(op + 3, in[1]);
|
||||
write(op + 0x40, in[4]); write(op + 0x43, in[5]);
|
||||
write(op + 0x60, in[6]); write(op + 0x63, in[7]);
|
||||
write(op + 0xc0, in[8]); write(op + 0xc3, in[9]);
|
||||
write(0xc0 + c, in[10]);
|
||||
}
|
||||
void note(unsigned c, unsigned pitch, std::uint8_t volume) noexcept {
|
||||
if (c >= 9 || pitch >= assets.tables.frequencies.size()) { fail(); return; }
|
||||
write(0xb0 + c, 0);
|
||||
level(c, volume);
|
||||
const auto frequency = assets.tables.frequencies[pitch];
|
||||
channels[c].high = std::uint8_t(frequency >> 8);
|
||||
write(0xa0 + c, std::uint8_t(frequency)); write(0xb0 + c, std::uint8_t(frequency >> 8));
|
||||
}
|
||||
void start_sample(std::uint8_t slot, bool is_effect, std::uint8_t priority = 0) noexcept {
|
||||
const Bank* bank = nullptr;
|
||||
unsigned index = slot;
|
||||
if (slot >= 16) { bank = &effects; index -= 16; }
|
||||
else if (stats.song < 3) bank = &songs[stats.song];
|
||||
if (!bank || index >= bank->samples.size()) { fail(); return; }
|
||||
const auto& s = bank->samples[index];
|
||||
dma = s.loop.empty() ? s.data : s.loop;
|
||||
dma_loop = !s.loop.empty(); dma_cursor = 0; dma_phase = 0;
|
||||
dma_constant = s.time_constant; dma_effect = is_effect; dma_priority = priority; dma_slot = slot;
|
||||
if (dma_loop && is_effect) ambient_slot = slot;
|
||||
if (!dry) { ++stats.sample_starts; if (sample_observer) sample_observer(slot); }
|
||||
}
|
||||
void stop_effects() noexcept {
|
||||
for (unsigned c = 0; c < 9; ++c) if (channels[c].reserved) {
|
||||
level(c, 0); channels[c].reserved = 0;
|
||||
}
|
||||
dma = {}; dma_effect = false; ambient_slot = 255; stats.ambient = false;
|
||||
}
|
||||
void pause_music() noexcept {
|
||||
for (unsigned c = 0; c < 9; ++c) level(c, 0);
|
||||
stats.playing = false;
|
||||
dma = {};
|
||||
}
|
||||
void start_song(unsigned i, bool restart = false) noexcept {
|
||||
if (i >= 3) return;
|
||||
if (stats.song == i && !restart) { stats.playing = options.music; return; }
|
||||
pause_music(); stop_effects();
|
||||
// Effect resets only OriginalRuntimeField(duration)=0, a5540(instrument)=FF,
|
||||
// a5544(level)=FF and a5546(reserved)=0 at stride16. The cached high
|
||||
// frequency byte, release/priority and instrument levels survive.
|
||||
// Clearing high changes the first pending key-off after a song switch.
|
||||
for (auto& c : channels) {
|
||||
c.duration = 0; c.instrument = 255; c.level = 255; c.reserved = 0;
|
||||
}
|
||||
stats.song = i; stats.bar = 0; stats.step = 0; tempo_tick = 0;
|
||||
for (unsigned t = 0; t < 16; ++t) {
|
||||
tracks[t].active = false; tracks[t].next = songs[i].start[t]; tracks[t].loop = songs[i].loop[t];
|
||||
}
|
||||
stats.playing = options.music;
|
||||
}
|
||||
bool effect(std::uint8_t id) noexcept {
|
||||
if (id < 10 || id > 22 || !options.effects || (id <= 15 && !options.clicks)) return false;
|
||||
const auto& f = sfx[id - 10];
|
||||
if (f[1] == 9) {
|
||||
if (dma_effect && !dma.empty() && f[3] < dma_priority) return true;
|
||||
start_sample(f[0], true, f[3]);
|
||||
} else {
|
||||
auto& c = channels[f[1]];
|
||||
if (c.reserved && f[3] < c.priority) return true;
|
||||
c.reserved = f[5]; c.release = f[6]; c.priority = f[3];
|
||||
instrument(f[1], f[0]); note(f[1], f[2], f[4]);
|
||||
}
|
||||
return !stats.failed;
|
||||
}
|
||||
std::uint8_t song_level(std::uint8_t value) noexcept {
|
||||
// Source OriginalRuntimeField2=0x3f80 selects master127 in the 128x128 table.
|
||||
if (value > 127) { fail(); return 0; }
|
||||
return std::uint8_t((127u * (unsigned(value) + 1) >> 7) >> 1);
|
||||
}
|
||||
void music_step() noexcept {
|
||||
if (!stats.playing || stats.failed) return;
|
||||
const auto& song = songs[stats.song];
|
||||
if (stats.step == 0) {
|
||||
if (stats.bar == song.end) {
|
||||
if (song.end == song.repeat) { stats.playing = false; return; }
|
||||
for (auto& t : tracks) t.next = t.loop;
|
||||
stats.bar = song.repeat;
|
||||
}
|
||||
for (auto& t : tracks) {
|
||||
if (!room(song.tracks, t.next, 8)) { fail(); return; }
|
||||
const auto row = song.tracks.subspan(t.next, 8);
|
||||
const auto bar = unsigned(row[0]) | (unsigned(row[1]) << 8);
|
||||
if (bar != stats.bar) continue;
|
||||
t.active = true; t.tick = 0;
|
||||
if (row[2] != 255) t.instrument = row[2];
|
||||
if (row[3] != 255) t.volume = row[3];
|
||||
t.transpose = row[4]; t.first = row[6]; t.channel = t.first;
|
||||
t.end = std::uint8_t(t.first + row[7]);
|
||||
if (row[5] >= song.patterns.size() || (unsigned(&t - tracks.data()) != 9 &&
|
||||
(t.first >= 9 || t.end > 9 || t.end <= t.first))) { fail(); return; }
|
||||
t.cursor = song.patterns[row[5]]; t.next += 8;
|
||||
}
|
||||
}
|
||||
for (unsigned index = 0; index < tracks.size(); ++index) {
|
||||
auto& t = tracks[index];
|
||||
if (!t.active) continue;
|
||||
if (!room(song.parts, t.cursor, 1)) { fail(); return; }
|
||||
const auto time = song.parts[t.cursor];
|
||||
if (time == 255) { t.active = false; continue; }
|
||||
if (time == t.tick) {
|
||||
if (!room(song.parts, t.cursor, 2)) { fail(); return; }
|
||||
auto cursor = t.cursor + 2;
|
||||
const auto code = song.parts[t.cursor + 1];
|
||||
unsigned count = 1;
|
||||
if (code >= 128) {
|
||||
if (code & 0x40) {
|
||||
if (!room(song.parts, cursor, 1)) { fail(); return; }
|
||||
t.instrument = song.parts[cursor++];
|
||||
}
|
||||
if (code & 0x20) {
|
||||
if (!room(song.parts, cursor, 1)) { fail(); return; }
|
||||
t.volume = song.parts[cursor++];
|
||||
const auto value = song_level(t.volume);
|
||||
for (unsigned c = t.first; c < t.end; ++c) level(c, value);
|
||||
}
|
||||
count = code & 7;
|
||||
}
|
||||
for (unsigned n = 0; n < count; ++n) {
|
||||
if (!room(song.parts, cursor, code < 128 ? 1 : 2)) { fail(); return; }
|
||||
const auto pitch = code < 128 ? code : song.parts[cursor++];
|
||||
const auto duration = song.parts[cursor++];
|
||||
if (index == 9 && code < 128) {
|
||||
if (!dma_effect) start_sample(pitch, false);
|
||||
} else if (t.channel < 9) {
|
||||
auto& c = channels[t.channel];
|
||||
if (!c.reserved) {
|
||||
if (c.instrument != t.instrument) instrument(t.channel, t.instrument);
|
||||
c.duration = duration;
|
||||
note(t.channel, std::uint8_t(pitch + t.transpose), song_level(t.volume));
|
||||
}
|
||||
if (++t.channel == t.end) t.channel = t.first;
|
||||
} else { fail(); return; }
|
||||
}
|
||||
t.cursor = cursor;
|
||||
}
|
||||
++t.tick;
|
||||
}
|
||||
if (++stats.step == 16) { stats.step = 0; ++stats.bar; }
|
||||
}
|
||||
void tick() noexcept {
|
||||
++stats.ticks;
|
||||
if (stats.failed) return;
|
||||
// IRQ0 calls Write2 before Write/Write3.
|
||||
for (unsigned n = 0; n < 9; ++n) {
|
||||
auto& c = channels[n];
|
||||
if (c.reserved) {
|
||||
--c.reserved;
|
||||
if (c.release != 255 && --c.release == 255) write(0xb0 + n, c.high & 31);
|
||||
}
|
||||
}
|
||||
if (!stats.playing) return;
|
||||
if (tempo_tick == 0) {
|
||||
music_step();
|
||||
for (unsigned n = 0; n < 9; ++n) {
|
||||
auto& c = channels[n];
|
||||
if (c.duration != 255 && --c.duration == 255) write(0xb0 + n, c.high & 31);
|
||||
}
|
||||
}
|
||||
if (++tempo_tick == songs[stats.song].tempo) tempo_tick = 0;
|
||||
}
|
||||
};
|
||||
|
||||
OriginalSynth::OriginalSynth() = default;
|
||||
OriginalSynth::~OriginalSynth() = default;
|
||||
bool OriginalSynth::load(OriginalAssets assets, std::uint32_t rate, std::string& error) {
|
||||
error.clear();
|
||||
if (rate < 8000 || rate > 192000) { error = "invalid Original output rate"; return false; }
|
||||
std::array<bool, 256> used{};
|
||||
for (auto op : assets.tables.operators) {
|
||||
const bool valid = (op >= 0x20 && op <= 0x22) || (op >= 0x28 && op <= 0x2a) ||
|
||||
(op >= 0x30 && op <= 0x32);
|
||||
if (!valid || used[op]) { error = "invalid Original OPL operator table"; return false; }
|
||||
used[op] = true;
|
||||
}
|
||||
for (auto frequency : assets.tables.frequencies)
|
||||
if (!(frequency & 0x2000) || (frequency & 0xc000) || !(frequency & 0x3ff)) {
|
||||
error = "invalid Original OPL note table"; return false;
|
||||
}
|
||||
try {
|
||||
auto candidate = std::make_unique<State>();
|
||||
candidate->assets = std::move(assets); candidate->rate = rate;
|
||||
if (!candidate->parse(error)) return false;
|
||||
// Interpret two full passes before making foreign data visible to the
|
||||
// real-time callback. All runtime table accesses remain checked as well.
|
||||
candidate->dry = true;
|
||||
for (unsigned i = 0; i < 3; ++i) {
|
||||
candidate->start_song(i, true);
|
||||
const auto steps = unsigned(candidate->songs[i].end) * 32 + 1;
|
||||
for (unsigned n = 0; n < steps && candidate->stats.playing; ++n) candidate->music_step();
|
||||
if (candidate->stats.failed) throw std::runtime_error("invalid Original track/pattern event");
|
||||
}
|
||||
candidate->dry = false; candidate->stop_effects(); candidate->stats = {};
|
||||
candidate->tracks = {}; candidate->channels = {}; candidate->tempo_tick = 0;
|
||||
candidate->reset_chip();
|
||||
state_ = std::move(candidate);
|
||||
return true;
|
||||
} catch (const std::exception& e) { error = e.what(); return false; }
|
||||
}
|
||||
bool OriginalSynth::ready() const noexcept { return state_ && !state_->stats.failed; }
|
||||
void OriginalSynth::set_options(OriginalAudioOptions options) noexcept {
|
||||
if (!state_) return;
|
||||
auto& s = *state_;
|
||||
if (s.options.music && !options.music && s.stats.playing) s.pause_music();
|
||||
const bool resume = !s.options.music && options.music && s.stats.song < 3 && !s.stats.ambient;
|
||||
if (s.options.effects && !options.effects) s.stop_effects();
|
||||
s.options = options;
|
||||
if (resume) s.stats.playing = true;
|
||||
}
|
||||
bool OriginalSynth::command(std::uint8_t id) noexcept {
|
||||
if (!ready()) return false;
|
||||
auto& s = *state_;
|
||||
if (id < 3) {
|
||||
// PauseMusic -> PauseMusic2 pauses music/effects before either loading a
|
||||
// different song or PauseMusic3's same-song resume. Track cursors and
|
||||
// retained instrument/volume stay intact on the latter path.
|
||||
s.pause_music(); s.stop_effects(); s.start_song(id); return true;
|
||||
}
|
||||
if (id == 3) {
|
||||
if (s.stats.ambient) return true;
|
||||
s.pause_music(); s.stop_effects(); s.stats.ambient = true;
|
||||
if (s.options.effects) s.effect(22);
|
||||
return true;
|
||||
}
|
||||
if (id == 8) { stop(); return true; }
|
||||
if (id < 10 || id > 22) return false;
|
||||
// Source suppresses effects over the title song. The standalone direct
|
||||
// effect entry remains available for isolated decoding and verification.
|
||||
if (s.stats.song == 0) return true;
|
||||
return s.effect(id);
|
||||
}
|
||||
bool OriginalSynth::effect(std::uint8_t id) noexcept { return ready() && state_->effect(id); }
|
||||
void OriginalSynth::stop() noexcept {
|
||||
if (!state_) return;
|
||||
state_->pause_music(); state_->stop_effects();
|
||||
}
|
||||
void OriginalSynth::tick() noexcept { if (state_) state_->tick(); }
|
||||
void OriginalSynth::render(std::span<std::int16_t> output, float volume) noexcept {
|
||||
std::fill(output.begin(), output.end(), 0);
|
||||
if (!state_ || state_->stats.failed) return;
|
||||
auto& s = *state_;
|
||||
const auto gain = std::isfinite(volume) ? std::clamp(volume, 0.0F, 1.0F) : 0.0F;
|
||||
for (auto& value : output) {
|
||||
if (s.stats.failed) break;
|
||||
s.pit_phase += 1193180;
|
||||
const std::uint64_t period = std::uint64_t(s.rate) * 6554;
|
||||
if (s.pit_phase >= period) { s.pit_phase -= period; s.tick(); }
|
||||
std::int16_t pair[2]{};
|
||||
OPL3_GenerateResampled(&s.chip, pair);
|
||||
std::int32_t mixed = (std::int32_t(pair[0]) + pair[1]) / 2;
|
||||
if (!s.dma.empty()) {
|
||||
mixed += (int(s.dma[s.dma_cursor]) - 128) * 256;
|
||||
s.dma_phase += 1000000;
|
||||
const auto divisor = std::uint64_t(s.rate) * (256 - unsigned(s.dma_constant));
|
||||
while (s.dma_phase >= divisor && !s.dma.empty()) {
|
||||
s.dma_phase -= divisor;
|
||||
if (++s.dma_cursor == s.dma.size()) {
|
||||
if (s.dma_loop) s.dma_cursor = 0;
|
||||
else if (s.ambient_slot != 255) s.start_sample(s.ambient_slot, true, 64);
|
||||
else { s.dma = {}; s.dma_effect = false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
value = std::int16_t(std::clamp<long>(std::lround(mixed * gain), -32768, 32767));
|
||||
++s.stats.frames;
|
||||
}
|
||||
}
|
||||
OriginalAudioStats OriginalSynth::stats() const noexcept { return state_ ? state_->stats : OriginalAudioStats{}; }
|
||||
void OriginalSynth::set_register_observer(std::function<void(std::uint8_t, std::uint8_t)> f) {
|
||||
if (state_) state_->register_observer = std::move(f);
|
||||
}
|
||||
void OriginalSynth::set_sample_observer(std::function<void(std::uint8_t)> f) {
|
||||
if (state_) state_->sample_observer = std::move(f);
|
||||
}
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,66 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openbmh::audio {
|
||||
|
||||
// Read from the user's executable by the application. Audio does not know the
|
||||
// game state, filesystem layout, simulation clock, or random generators.
|
||||
struct OriginalTables {
|
||||
std::array<std::uint16_t, 96> frequencies{}; // Audio_OriginalAudioAssets_RuntimeField2, including key-on bits
|
||||
std::array<std::uint8_t, 9> operators{}; // Audio_OriginalAudioAssets_RuntimeField, stride16
|
||||
};
|
||||
struct OriginalAssets {
|
||||
std::array<std::vector<std::uint8_t>, 4> containers; // S/2000..2003
|
||||
OriginalTables tables;
|
||||
};
|
||||
struct OriginalAudioOptions {
|
||||
bool music = true;
|
||||
bool effects = true;
|
||||
bool clicks = true;
|
||||
};
|
||||
struct OriginalAudioStats {
|
||||
std::uint64_t ticks{}, register_writes{}, sample_starts{}, frames{};
|
||||
std::uint32_t bar{}, step{}, song = 255;
|
||||
bool playing{}, ambient{}, failed{};
|
||||
};
|
||||
|
||||
// The Original MIDILINK sequencer and one Sound Blaster PCM channel. IRQ0 uses
|
||||
// PIT divisor0x199a. SONG/TRCK/PART, OPL instruments, SFX priorities/lifetimes,
|
||||
// note durations, sample interruption and the looping crowd are Source-derived.
|
||||
// Loading owns/validates its inputs. render() allocates nothing and never blocks.
|
||||
class OriginalSynth {
|
||||
public:
|
||||
OriginalSynth();
|
||||
~OriginalSynth();
|
||||
OriginalSynth(const OriginalSynth&) = delete;
|
||||
OriginalSynth& operator=(const OriginalSynth&) = delete;
|
||||
bool load(OriginalAssets assets, std::uint32_t output_rate, std::string& error);
|
||||
bool ready() const noexcept;
|
||||
void set_options(OriginalAudioOptions options) noexcept;
|
||||
// Source dispatch IDs:0 title,1 desk,2 intro,3 crowd,8 stop,10..22 effects.
|
||||
bool command(std::uint8_t id) noexcept;
|
||||
// Direct SFX entry, also used by the standalone driver/oracle.
|
||||
bool effect(std::uint8_t id) noexcept;
|
||||
void stop() noexcept;
|
||||
void render(std::span<std::int16_t> output, float volume = 1.0F) noexcept;
|
||||
OriginalAudioStats stats() const noexcept;
|
||||
|
||||
// Deterministic hardware-independent probe: one Original IRQ0, not one game
|
||||
// tick. Optional observers are installed only by offline validation tools.
|
||||
void tick() noexcept;
|
||||
void set_register_observer(std::function<void(std::uint8_t, std::uint8_t)> observer);
|
||||
void set_sample_observer(std::function<void(std::uint8_t)> observer);
|
||||
private:
|
||||
struct State;
|
||||
std::unique_ptr<State> state_;
|
||||
};
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,378 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "original.hpp"
|
||||
#include "playback.hpp"
|
||||
#include "container.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <span>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
using namespace openbmh::audio;
|
||||
constexpr std::uint64_t kFnvOffset = 14695981039346656037ull;
|
||||
void require(bool value, const std::string& reason) {
|
||||
if (!value) throw std::runtime_error(reason);
|
||||
}
|
||||
OriginalAssets assets_from(const std::filesystem::path& data) {
|
||||
OriginalAssets assets;
|
||||
const auto exe = bmh::load_le(data / "BMH.exe");
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
assets.containers[i] = bmh::read_file(data / "S" / std::to_string(2000 + i));
|
||||
for (unsigned i = 0; i < assets.tables.frequencies.size(); ++i)
|
||||
assets.tables.frequencies[i] = exe.u16(::bmh::layout::Audio_OriginalAudioAssets_RuntimeField2 + 2 * i);
|
||||
for (unsigned i = 0; i < assets.tables.operators.size(); ++i)
|
||||
assets.tables.operators[i] = exe.u8(::bmh::layout::Audio_OriginalAudioAssets_RuntimeField + 16 * i);
|
||||
return assets;
|
||||
}
|
||||
void load(OriginalSynth& synth, const OriginalAssets& assets) {
|
||||
std::string error;
|
||||
require(synth.load(assets, 22050, error), "load external Original audio: " + error);
|
||||
}
|
||||
struct TraceHash {
|
||||
std::uint64_t count{}, hash = kFnvOffset;
|
||||
void word(std::uint32_t value) {
|
||||
for (unsigned shift = 0; shift < 32; shift += 8)
|
||||
hash = (hash ^ ((value >> shift) & 255u)) * 1099511628211ull;
|
||||
}
|
||||
void sample(std::uint32_t tick, std::uint8_t slot) { ++count; word(tick); word(slot); }
|
||||
void reg(std::uint32_t tick, std::uint8_t index, std::uint8_t value) {
|
||||
++count; word(tick); word(index); word(value);
|
||||
}
|
||||
};
|
||||
struct Oracle {
|
||||
std::uint8_t id;
|
||||
unsigned ticks;
|
||||
std::uint64_t writes, register_hash, samples, sample_hash;
|
||||
};
|
||||
// Counts and FNV-1a hashes from the executed, unmodified Original x86 driver.
|
||||
// Canonical hash input: each observed column as little-endian u32, in order.
|
||||
// No Original audio bytes or register/sample sequences are embedded here.
|
||||
constexpr std::array<Oracle, 16> kOracle{{
|
||||
{0,60000,32348,0xcbca207bfd99aeb0ull,3266,0xadad438156972aa9ull},
|
||||
{1,70000,12223,0xa0fe3a8b449c366bull,3163,0x31cd0db01f7a3ed2ull},
|
||||
{2,2000,386,0x52ce4acd30052d42ull,21,0xed4a856bd0b5d9bbull},
|
||||
{10,100,15,0xa38ea2831340e69eull,0,kFnvOffset},
|
||||
{11,100,15,0x6842cc45dcb290c5ull,0,kFnvOffset},
|
||||
{12,100,15,0x2ad007b26f4116b8ull,0,kFnvOffset},
|
||||
{13,100,15,0xaa5fff83f44303f5ull,0,kFnvOffset},
|
||||
{14,100,15,0xea8efbf8811746beull,0,kFnvOffset},
|
||||
{15,100,15,0x89a307eb865aa83full,0,kFnvOffset},
|
||||
{16,100,15,0x23a80f34bb743d13ull,0,kFnvOffset},
|
||||
{17,100,0,kFnvOffset,1,0xa91d37acc4be70b5ull},
|
||||
{18,100,0,kFnvOffset,1,0x09228ba46e88b424ull},
|
||||
{19,100,0,kFnvOffset,1,0xe9128fbd7129e9d7ull},
|
||||
{20,100,0,kFnvOffset,1,0x4917e3b51af42d46ull},
|
||||
{21,100,0,kFnvOffset,1,0x2932878b6be77e71ull},
|
||||
{22,100,0,kFnvOffset,1,0x8937db8315b1c1e0ull},
|
||||
}};
|
||||
|
||||
void original_oracle(const OriginalAssets& assets) {
|
||||
for (const auto& expected : kOracle) {
|
||||
OriginalSynth synth; load(synth, assets);
|
||||
const bool song = expected.id < 3;
|
||||
if (song) require(synth.command(expected.id), "Original song command");
|
||||
TraceHash registers, samples;
|
||||
unsigned tick = 0, wraps = 0;
|
||||
auto previous_bar = synth.stats().bar;
|
||||
synth.set_register_observer([&](auto reg, auto value) { registers.reg(tick, reg, value); });
|
||||
synth.set_sample_observer([&](auto slot) { samples.sample(tick, slot); });
|
||||
if (!song) require(synth.effect(expected.id), "Original effect command");
|
||||
for (; tick < expected.ticks; ++tick) {
|
||||
synth.tick();
|
||||
const auto stats = synth.stats();
|
||||
if (stats.bar < previous_bar) ++wraps;
|
||||
previous_bar = stats.bar;
|
||||
}
|
||||
require(!synth.stats().failed && registers.count == expected.writes &&
|
||||
registers.hash == expected.register_hash && samples.count == expected.samples &&
|
||||
samples.hash == expected.sample_hash,
|
||||
"executed Original driver oracle mismatch for ID " + std::to_string(expected.id));
|
||||
if (expected.id < 2) require(wraps > 0, "looping Original song must traverse its repeat boundary");
|
||||
if (expected.id == 2) require(!synth.stats().playing, "finite intro must stop at its Original end");
|
||||
std::cout << (song ? "song " : "effect ") << unsigned(expected.id)
|
||||
<< " ticks=" << expected.ticks << " registers=" << registers.count
|
||||
<< " fnv=" << std::hex << registers.hash << std::dec
|
||||
<< " samples=" << samples.count << " fnv=" << std::hex << samples.hash << std::dec << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void transition_oracle(const OriginalAssets& assets) {
|
||||
// Executed Original x86: warm up 1000 IRQs, start direct effect16, switch
|
||||
// through legacy routine/legacy routine (different song), or legacy routine/721d9/72199
|
||||
// (same song); observe the following5000 IRQs. Only digests are retained.
|
||||
constexpr std::array<std::uint64_t, 9> writes{2469,364,386,1922,446,386,1922,364,0};
|
||||
constexpr std::array<std::uint64_t, 9> hashes{
|
||||
0xe0e4d6a8ce302b09ull,0xa7c86105f1e09e74ull,0x52ce4acd30052d42ull,
|
||||
0x2157ea8cf3b1f61eull,0x4d37e6aa0de33d57ull,0x52ce4acd30052d42ull,
|
||||
0x22ad1211c726b767ull,0x5ebdbbd8e9af9298ull,kFnvOffset};
|
||||
constexpr std::array<std::uint64_t, 9> starts{276,218,21,277,231,21,277,218,0};
|
||||
constexpr std::array<std::uint64_t, 9> sample_hashes{
|
||||
0x781b9195a1b85333ull,0x24d2a97d1a8511f9ull,0xed4a856bd0b5d9bbull,
|
||||
0x23b9f58978f6f974ull,0x7d674e527408da4dull,0xed4a856bd0b5d9bbull,
|
||||
0x23b9f58978f6f974ull,0x24d2a97d1a8511f9ull,kFnvOffset};
|
||||
for (unsigned previous = 0; previous < 3; ++previous) for (unsigned target = 0; target < 3; ++target) {
|
||||
OriginalSynth synth; load(synth, assets);
|
||||
require(synth.command(std::uint8_t(previous)), "transition warmup song");
|
||||
for (unsigned n = 0; n < 1000; ++n) synth.tick();
|
||||
require(synth.effect(16) && synth.command(std::uint8_t(target)), "transition effect and target");
|
||||
TraceHash registers, samples; unsigned tick = 0;
|
||||
synth.set_register_observer([&](auto reg, auto value) { registers.reg(tick, reg, value); });
|
||||
synth.set_sample_observer([&](auto slot) { samples.sample(tick, slot); });
|
||||
for (; tick < 5000; ++tick) synth.tick();
|
||||
const auto index = previous * 3 + target;
|
||||
require(!synth.stats().failed && registers.count == writes[index] && registers.hash == hashes[index] &&
|
||||
samples.count == starts[index] && samples.hash == sample_hashes[index],
|
||||
"Original song transition mismatch " + std::to_string(previous) + "->" + std::to_string(target));
|
||||
}
|
||||
std::cout << "transitions: all9 cross/same-song executed Original digests, including finite intro resume\n";
|
||||
}
|
||||
|
||||
std::size_t payload(const OriginalAssets& assets, unsigned bank, const char* name) {
|
||||
Container container; std::string error;
|
||||
require(parse_container(assets.containers[bank], container, error), "parse external chunk: " + error);
|
||||
for (const auto& chunk : container.chunks) if (chunk.id == name) return chunk.payload_offset;
|
||||
throw std::runtime_error("missing external chunk");
|
||||
}
|
||||
void put16(std::vector<std::uint8_t>& bytes, std::size_t at, unsigned value) {
|
||||
bytes.at(at) = std::uint8_t(value); bytes.at(at + 1) = std::uint8_t(value >> 8);
|
||||
}
|
||||
void malformed_inputs(const OriginalAssets& assets) {
|
||||
unsigned cases = 0;
|
||||
const auto rejected = [&](const std::function<void(OriginalAssets&)>& mutation) {
|
||||
auto malformed = assets; mutation(malformed);
|
||||
OriginalSynth synth; std::string error;
|
||||
require(!synth.load(std::move(malformed), 22050, error) && !error.empty() && !synth.ready(),
|
||||
"malformed Original asset must fail before callback exposure: case " + std::to_string(cases));
|
||||
++cases;
|
||||
};
|
||||
rejected([](auto& a) { a.containers[0].clear(); });
|
||||
rejected([](auto& a) { a.containers[1].pop_back(); });
|
||||
rejected([](auto& a) { a.tables.operators[0] = 255; });
|
||||
rejected([](auto& a) { a.tables.operators[1] = a.tables.operators[0]; });
|
||||
rejected([](auto& a) { a.tables.frequencies[0] = 0; });
|
||||
rejected([](auto& a) { a.tables.frequencies[1] &= ~0x2000u; });
|
||||
const auto song = payload(assets, 0, "SONG"), track = payload(assets, 0, "TRCK");
|
||||
const auto part = payload(assets, 0, "PART"), sample = payload(assets, 3, "SAMP");
|
||||
const auto effect = payload(assets, 3, "SEFX");
|
||||
rejected([&](auto& a) { put16(a.containers[0], song + 4, 0); });
|
||||
rejected([&](auto& a) { put16(a.containers[0], song + 8, 0xffff); });
|
||||
rejected([&](auto& a) { std::fill_n(a.containers[0].begin() + std::ptrdiff_t(track + 4), 4, 255); });
|
||||
rejected([&](auto& a) { std::fill_n(a.containers[0].begin() + std::ptrdiff_t(part + 4), 4, 255); });
|
||||
rejected([&](auto& a) {
|
||||
a.containers[3].at(sample + 4 + 10) = 1;
|
||||
put16(a.containers[3], sample + 4 + 4, 0xffff);
|
||||
put16(a.containers[3], sample + 4 + 6, 0xffff);
|
||||
});
|
||||
rejected([&](auto& a) { a.containers[3].at(effect + 4 + 2) = 255; });
|
||||
rejected([&](auto& a) { a.containers[3].at(effect + 4 + 1) = 10; });
|
||||
OriginalSynth synth; std::string error;
|
||||
require(!synth.load(assets, 7999, error) && !synth.load(assets, 192001, error), "output rate bounds");
|
||||
load(synth, assets);
|
||||
require(synth.command(1), "valid song after malformed cases");
|
||||
const auto before = synth.stats();
|
||||
auto malformed = assets; malformed.containers[0].clear();
|
||||
require(!synth.load(std::move(malformed), 22050, error) && synth.ready() &&
|
||||
synth.stats().register_writes == before.register_writes && synth.stats().song == before.song,
|
||||
"failed reload must retain the previous validated synthesizer");
|
||||
std::cout << "malformed: " << cases << " asset/table/span/loop cases plus rate and failed-reload bounds\n";
|
||||
}
|
||||
|
||||
bool nonzero(std::span<const std::int16_t> samples) {
|
||||
return std::any_of(samples.begin(), samples.end(), [](auto value) { return value != 0; });
|
||||
}
|
||||
void render_and_options(const OriginalAssets& assets) {
|
||||
for (unsigned id = 0; id <= 22; ++id) {
|
||||
if (id > 2 && id < 10) continue;
|
||||
OriginalSynth synth; load(synth, assets);
|
||||
require(id < 3 ? synth.command(std::uint8_t(id)) : synth.effect(std::uint8_t(id)), "render command");
|
||||
std::array<std::int16_t, 8192> pcm{}; synth.render(pcm);
|
||||
require(!synth.stats().failed && synth.stats().frames == pcm.size() && nonzero(pcm),
|
||||
"all Original songs/effects must produce bounded audible PCM: " + std::to_string(id));
|
||||
}
|
||||
OriginalSynth first, second, silent;
|
||||
load(first, assets); load(second, assets); load(silent, assets);
|
||||
require(first.command(1) && second.command(1) && silent.command(1), "streaming song setup");
|
||||
std::array<std::int16_t, 16384> a{}, b{}, zero{};
|
||||
first.render(a);
|
||||
for (std::size_t at = 0; at < b.size(); at += 97)
|
||||
second.render(std::span(b).subspan(at, std::min<std::size_t>(97, b.size() - at)));
|
||||
silent.render(zero, 0);
|
||||
require(a == b && nonzero(a) && !nonzero(zero) &&
|
||||
silent.stats().ticks == first.stats().ticks && silent.stats().frames == a.size(),
|
||||
"PCM continuation is callback-block independent; zero volume preserves sequencing");
|
||||
require(!first.command(255) && !first.effect(9) && !first.effect(23), "invalid command/effect bounds");
|
||||
require(first.command(0) && !first.command(255), "title suppression cannot accept invalid IDs");
|
||||
auto writes = first.stats().register_writes;
|
||||
require(first.command(16) && first.stats().register_writes == writes, "Source title suppresses game effects");
|
||||
first.stop();
|
||||
first.set_options({false, true, false});
|
||||
require(first.command(1) && !first.stats().playing, "music disabled independently");
|
||||
writes = first.stats().register_writes;
|
||||
require(!first.effect(10) && first.stats().register_writes == writes && first.effect(16),
|
||||
"click switch disables click ID10 while retaining non-click ID16");
|
||||
first.set_options({false, false, false});
|
||||
require(!first.effect(17), "effect option independently disabled");
|
||||
first.set_options({false, true, true});
|
||||
require(first.command(3) && first.stats().ambient, "Original crowd command starts loop");
|
||||
const auto starts = first.stats().sample_starts;
|
||||
first.set_options({true, true, true}); first.set_options({false, true, true});
|
||||
require(first.stats().ambient && first.stats().sample_starts == starts,
|
||||
"music option toggles cannot erase the Original crowd");
|
||||
first.render(a); require(nonzero(a) && first.stats().ambient, "bounded crowd render continues");
|
||||
first.stop(); require(!first.stats().playing && !first.stats().ambient, "stop clears all playback owners");
|
||||
std::cout << "render: 3 songs/13 effects, chunk continuity, volume0, switches, title gate and crowd loop\n";
|
||||
}
|
||||
|
||||
void pause_and_crowd_transitions(const OriginalAssets& assets) {
|
||||
OriginalSynth reference, paused; load(reference, assets); load(paused, assets);
|
||||
require(reference.command(1) && paused.command(1), "pause/resume desk setup");
|
||||
for (unsigned n = 0; n < 233; ++n) { reference.tick(); paused.tick(); }
|
||||
const auto cursor = paused.stats();
|
||||
paused.set_options({false, true, true});
|
||||
require(!paused.stats().playing, "music option pauses current song");
|
||||
for (unsigned n = 0; n < 71; ++n) paused.tick();
|
||||
require(paused.stats().bar == cursor.bar && paused.stats().step == cursor.step,
|
||||
"disabled music retains its bar/step cursor");
|
||||
paused.set_options({true, true, true});
|
||||
require(paused.stats().playing, "music option resumes current song");
|
||||
for (unsigned n = 0; n < 257; ++n) { reference.tick(); paused.tick(); }
|
||||
require(paused.stats().bar == reference.stats().bar && paused.stats().step == reference.stats().step,
|
||||
"music option resumes retained tempo phase and cursors");
|
||||
|
||||
OriginalSynth desk, crowd; load(desk, assets); load(crowd, assets);
|
||||
require(desk.command(1) && crowd.command(1), "crowd/desk setup");
|
||||
for (unsigned n = 0; n < 233; ++n) { desk.tick(); crowd.tick(); }
|
||||
require(crowd.command(3) && crowd.stats().ambient && !crowd.stats().playing, "crowd pauses desk");
|
||||
const auto before = crowd.stats();
|
||||
require(crowd.command(3) && crowd.stats().sample_starts == before.sample_starts,
|
||||
"same crowd command retains existing owner without restarting sample");
|
||||
for (unsigned n = 0; n < 71; ++n) crowd.tick();
|
||||
require(crowd.stats().bar == before.bar && crowd.stats().step == before.step,
|
||||
"crowd retains the paused song cursor");
|
||||
require(crowd.command(1) && !crowd.stats().ambient && crowd.stats().playing,
|
||||
"return to same desk song stops crowd and resumes music");
|
||||
for (unsigned n = 0; n < 257; ++n) { desk.tick(); crowd.tick(); }
|
||||
require(crowd.stats().bar == desk.stats().bar && crowd.stats().step == desk.stats().step &&
|
||||
crowd.stats().song == 1 && !crowd.stats().failed,
|
||||
"crowd to desk retains song/tempo cursor rather than restarting");
|
||||
std::cout << "pause/crowd: music off/on and crowd-to-desk retain song and tempo cursors\n";
|
||||
}
|
||||
|
||||
void effect_priorities(const OriginalAssets& assets) {
|
||||
const auto at = payload(assets, 3, "SEFX") + 4;
|
||||
const auto& bytes = assets.containers[3];
|
||||
unsigned pairs = 0;
|
||||
for (unsigned high = 0; high < 13; ++high) for (unsigned low = 0; low < 13; ++low) {
|
||||
const auto h = at + high * 16, l = at + low * 16;
|
||||
if (bytes[h + 1] != bytes[l + 1] || bytes[h + 3] <= bytes[l + 3] ||
|
||||
(bytes[h + 1] != 9 && bytes[h + 5] == 0)) continue;
|
||||
OriginalSynth synth; load(synth, assets);
|
||||
require(synth.effect(std::uint8_t(high + 10)), "start higher-priority Original effect");
|
||||
const auto before = synth.stats();
|
||||
require(synth.effect(std::uint8_t(low + 10)) &&
|
||||
synth.stats().register_writes == before.register_writes &&
|
||||
synth.stats().sample_starts == before.sample_starts,
|
||||
"lower-priority effect must not interrupt the active Original channel");
|
||||
OriginalSynth replacement; load(replacement, assets);
|
||||
require(replacement.effect(std::uint8_t(low + 10)), "start lower-priority Original effect");
|
||||
const auto old = replacement.stats();
|
||||
require(replacement.effect(std::uint8_t(high + 10)) &&
|
||||
(replacement.stats().register_writes > old.register_writes ||
|
||||
replacement.stats().sample_starts > old.sample_starts),
|
||||
"higher-priority effect must replace the active lower-priority channel");
|
||||
++pairs;
|
||||
}
|
||||
require(pairs != 0, "external bank must exercise actual priority pairs");
|
||||
std::cout << "priority: " << pairs << " actual competing high/low pairs retained correctly\n";
|
||||
}
|
||||
|
||||
void callback_and_lifecycle(const OriginalAssets& assets) {
|
||||
std::string error;
|
||||
{
|
||||
Playback playback;
|
||||
require(playback.initialize_original(assets, error), "SDL Original initialization: " + error);
|
||||
require(playback.available() && playback.original_ready() && !playback.needs_pump(), "callback mode owns audio");
|
||||
playback.reset_session(42);
|
||||
require(playback.play_original_id(1, error), "callback desk song");
|
||||
const auto initial = playback.original_stats();
|
||||
SDL_Delay(120); // Deliberately no pump, render, GUI step or simulation callback.
|
||||
const auto advanced = playback.original_stats();
|
||||
require(advanced.frames > initial.frames + 512 && advanced.ticks > initial.ticks &&
|
||||
advanced.playing && !advanced.failed && playback.queued_bytes() == 0,
|
||||
"SDL callback must continue throughout a blocked main thread");
|
||||
playback.set_volume(0);
|
||||
const auto quiet = playback.original_stats().frames; SDL_Delay(40);
|
||||
require(playback.original_stats().frames > quiet && playback.volume() == 0, "zero volume retains callback clock");
|
||||
playback.set_volume(1);
|
||||
playback.set_original_options({false, false, false});
|
||||
require(!playback.original_stats().playing, "saved music option reaches callback");
|
||||
const auto stopped = playback.original_stats().sample_starts;
|
||||
require(playback.play_original_id(17, error) && playback.original_stats().sample_starts == stopped,
|
||||
"disabled effects are a normal consumed refusal");
|
||||
playback.set_original_options({true, true, true});
|
||||
playback.set_muted(true);
|
||||
const auto muted = playback.original_stats().frames; SDL_Delay(40);
|
||||
require(playback.original_stats().frames == muted && !playback.original_stats().playing,
|
||||
"mute stops and freezes Original sequencing");
|
||||
require(playback.submit(CueRequest{42, 1, 17}, error) == CueStatus::muted, "muted event consumed");
|
||||
playback.set_muted(false);
|
||||
require(playback.submit(CueRequest{42, 1, 17}, error) == CueStatus::duplicate,
|
||||
"unmute cannot replay a consumed event");
|
||||
require(playback.submit(CueRequest{41, 2, 17}, error) == CueStatus::invalid, "stale session refused");
|
||||
require(playback.submit(CueRequest{42, 2, 17}, error) == CueStatus::queued, "real effect submitted");
|
||||
require(playback.submit(CueRequest{42, 3, 255}, error) == CueStatus::unsupported &&
|
||||
playback.submit(CueRequest{42, 3, 255}, error) == CueStatus::duplicate,
|
||||
"invalid command is rejected and its envelope remains consumed");
|
||||
playback.stop(); playback.reset_session(43);
|
||||
require(playback.submit(CueRequest{43, 1, 16}, error) == CueStatus::queued, "new session starts independent event sequence");
|
||||
playback.shutdown();
|
||||
require(!playback.available() && playback.submit(CueRequest{43, 2, 16}, error) == CueStatus::disabled,
|
||||
"shutdown closes device and consumes no-device events safely");
|
||||
require(playback.initialize_original(assets, error), "reinitialize after shutdown: " + error);
|
||||
require(playback.play_original_id(2, error), "reinitialized finite song");
|
||||
}
|
||||
const char* old = SDL_getenv("SDL_AUDIODRIVER");
|
||||
const std::string previous = old ? old : "dummy";
|
||||
SDL_setenv("SDL_AUDIODRIVER", "openbmh_intentionally_missing_driver", 1);
|
||||
Playback unavailable;
|
||||
const bool initialized = unavailable.initialize_original(assets, error);
|
||||
SDL_setenv("SDL_AUDIODRIVER", previous.c_str(), 1);
|
||||
require(!initialized && !unavailable.available() && !error.empty(), "unavailable device fails without crashing");
|
||||
require(unavailable.initialize_original(assets, error), "retry after no-device failure: " + error);
|
||||
unavailable.shutdown();
|
||||
std::cout << "callback: blocked-main continuity, volume0/mute/options, dedup, no-device, reinitialize/lifecycle\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) try {
|
||||
if (argc != 2) return 2;
|
||||
if (!*argv[1]) {
|
||||
std::cout << "SKIP: external game audio not configured\n";
|
||||
return 77;
|
||||
}
|
||||
if (!*argv[1]) { std::cout << "SKIP: Original BMH_DATA not configured\n"; return 77; }
|
||||
const auto assets = assets_from(argv[1]);
|
||||
original_oracle(assets);
|
||||
transition_oracle(assets);
|
||||
malformed_inputs(assets);
|
||||
render_and_options(assets);
|
||||
pause_and_crowd_transitions(assets);
|
||||
effect_priorities(assets);
|
||||
callback_and_lifecycle(assets);
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << "Original audio validation: " << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "playback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
namespace openbmh::audio {
|
||||
namespace {
|
||||
struct AudioLock {
|
||||
SDL_AudioDeviceID device;
|
||||
explicit AudioLock(SDL_AudioDeviceID id) : device(id) { if (device) SDL_LockAudioDevice(device); }
|
||||
~AudioLock() { if (device) SDL_UnlockAudioDevice(device); }
|
||||
};
|
||||
constexpr std::uint32_t kQueueLimitBytes = 2U * 1024U * 1024U;
|
||||
constexpr std::uint32_t kOutputRate = 22050;
|
||||
constexpr std::size_t kPumpFrames = kOutputRate / 50; // 20 ms.
|
||||
constexpr std::uint32_t kPumpBlockBytes = static_cast<std::uint32_t>(kPumpFrames * 2);
|
||||
constexpr std::uint32_t kQueueHighWaterBytes = kPumpBlockBytes * 2; // 40 ms.
|
||||
}
|
||||
|
||||
Playback::~Playback() { shutdown(); }
|
||||
|
||||
bool Playback::initialize(std::string& error) {
|
||||
error.clear();
|
||||
if (device_) return true;
|
||||
if (!initialized_audio_ && SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
||||
error = SDL_GetError();
|
||||
return false;
|
||||
}
|
||||
initialized_audio_ = true;
|
||||
SDL_AudioSpec wanted{};
|
||||
wanted.freq = static_cast<int>(kOutputRate);
|
||||
wanted.format = AUDIO_S16SYS;
|
||||
wanted.channels = 1;
|
||||
// 1024 frames at 22050 Hz exceed the entire 40 ms music queue. A small
|
||||
// device block lets the bounded queue cover 17/33 ms app pump intervals.
|
||||
wanted.samples = 256;
|
||||
if (original_mode_) {
|
||||
wanted.callback = original_callback;
|
||||
wanted.userdata = this;
|
||||
}
|
||||
device_ = SDL_OpenAudioDevice(nullptr, 0, &wanted, &obtained_, 0);
|
||||
if (!device_) {
|
||||
error = SDL_GetError();
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
initialized_audio_ = false;
|
||||
return false;
|
||||
}
|
||||
if (obtained_.format != AUDIO_S16SYS || obtained_.channels != 1) {
|
||||
error = "audio device did not provide mono S16 output";
|
||||
SDL_CloseAudioDevice(device_);
|
||||
device_ = 0;
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
initialized_audio_ = false;
|
||||
return false;
|
||||
}
|
||||
SDL_PauseAudioDevice(device_, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Playback::initialize_original(OriginalAssets assets, std::string& error) {
|
||||
// Asset parsing/preflight never runs inside a live audio callback.
|
||||
if (device_) {
|
||||
SDL_CloseAudioDevice(device_);
|
||||
device_ = 0;
|
||||
}
|
||||
mixer_.clear();
|
||||
if (!original_.load(std::move(assets), kOutputRate, error)) return false;
|
||||
original_.set_options(original_options_);
|
||||
original_mode_ = true;
|
||||
return initialize(error);
|
||||
}
|
||||
|
||||
void Playback::original_callback(void* userdata, Uint8* stream, int length) {
|
||||
auto& self = *static_cast<Playback*>(userdata);
|
||||
SDL_memset(stream, 0, size_t(length));
|
||||
if (length <= 0 || self.muted_) return;
|
||||
self.original_.render(std::span<std::int16_t>(reinterpret_cast<std::int16_t*>(stream),
|
||||
size_t(length) / sizeof(std::int16_t)), self.volume_);
|
||||
}
|
||||
|
||||
void Playback::set_original_options(OriginalAudioOptions options) noexcept {
|
||||
if (!original_mode_) return;
|
||||
AudioLock lock(device_);
|
||||
original_options_ = options;
|
||||
original_.set_options(options);
|
||||
}
|
||||
|
||||
bool Playback::original_ready() const noexcept {
|
||||
if (!original_mode_) return false;
|
||||
AudioLock lock(device_);
|
||||
return original_.ready();
|
||||
}
|
||||
|
||||
OriginalAudioStats Playback::original_stats() const noexcept {
|
||||
AudioLock lock(original_mode_ ? device_ : 0);
|
||||
return original_.stats();
|
||||
}
|
||||
|
||||
void Playback::shutdown() {
|
||||
stop();
|
||||
if (device_) {
|
||||
SDL_CloseAudioDevice(device_);
|
||||
device_ = 0;
|
||||
}
|
||||
if (initialized_audio_) {
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
initialized_audio_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Playback::set_volume(float volume) noexcept {
|
||||
AudioLock lock(original_mode_ ? device_ : 0);
|
||||
if (std::isfinite(volume)) volume_ = std::clamp(volume, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
void Playback::set_muted(bool muted) noexcept {
|
||||
if (original_mode_) {
|
||||
AudioLock lock(device_);
|
||||
muted_ = muted;
|
||||
if (muted) original_.stop();
|
||||
return;
|
||||
}
|
||||
muted_ = muted;
|
||||
if (muted_) stop();
|
||||
}
|
||||
|
||||
std::uint32_t Playback::queued_bytes() const noexcept {
|
||||
if (original_mode_) return 0;
|
||||
return device_ ? SDL_GetQueuedAudioSize(device_) : 0;
|
||||
}
|
||||
|
||||
void Playback::stop() {
|
||||
if (original_mode_) {
|
||||
AudioLock lock(device_);
|
||||
original_.stop();
|
||||
return;
|
||||
}
|
||||
if (device_) SDL_ClearQueuedAudio(device_);
|
||||
mixer_.clear();
|
||||
}
|
||||
|
||||
bool Playback::start_music_loop(const PcmSample& loop, std::string& error) {
|
||||
error.clear();
|
||||
if (original_mode_) { error = "Original driver owns music playback"; return false; }
|
||||
if (!device_) { error = "audio device is unavailable"; return false; }
|
||||
if (obtained_.freq != static_cast<int>(kOutputRate) || obtained_.samples > 256) {
|
||||
error = "audio device block does not support the bounded music pump cadence";
|
||||
return false;
|
||||
}
|
||||
if (SDL_GetQueuedAudioSize(device_) > kQueueHighWaterBytes) {
|
||||
error = "cannot start music while the existing cue queue exceeds 40 ms";
|
||||
return false;
|
||||
}
|
||||
return mixer_.start_music_loop(loop, static_cast<std::uint32_t>(obtained_.freq), error);
|
||||
}
|
||||
|
||||
void Playback::stop_music() noexcept {
|
||||
if (original_mode_) {
|
||||
AudioLock lock(device_);
|
||||
original_options_.music = false;
|
||||
original_.set_options(original_options_);
|
||||
return;
|
||||
}
|
||||
mixer_.stop_music();
|
||||
}
|
||||
|
||||
bool Playback::pump(std::string& error) {
|
||||
error.clear();
|
||||
if (original_mode_) return available();
|
||||
if (!device_) { error = "audio device is unavailable"; return false; }
|
||||
if (muted_ || !mixer_.active()) return false;
|
||||
|
||||
std::array<std::int16_t, kPumpFrames> block{};
|
||||
auto enqueue_up_to_20ms = [&]() {
|
||||
const auto queued = SDL_GetQueuedAudioSize(device_);
|
||||
if (queued >= kQueueHighWaterBytes) return false;
|
||||
const auto room_frames = (kQueueHighWaterBytes - queued) / sizeof(std::int16_t);
|
||||
const auto frames = std::min<std::size_t>(kPumpFrames, room_frames);
|
||||
if (!frames || !mixer_.mix_block(std::span<std::int16_t>(block.data(), frames), volume_))
|
||||
return false;
|
||||
const auto bytes = static_cast<std::uint32_t>(frames * sizeof(std::int16_t));
|
||||
if (SDL_QueueAudio(device_, block.data(), bytes) != 0) {
|
||||
error = SDL_GetError();
|
||||
mixer_.clear();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// Fill toward the 40 ms high-water mark. Two fixed, bounded calls let a
|
||||
// 30 Hz main loop catch up without busy waiting or allocating in pump().
|
||||
const bool first = enqueue_up_to_20ms();
|
||||
if (!first || !mixer_.active()) return first;
|
||||
enqueue_up_to_20ms();
|
||||
return error.empty();
|
||||
}
|
||||
|
||||
void Playback::reset_session(std::uint64_t session_id) noexcept {
|
||||
if (session_id == session_id_) return;
|
||||
stop();
|
||||
session_id_ = session_id;
|
||||
last_event_id_ = 0;
|
||||
}
|
||||
|
||||
CueStatus Playback::consume_event(std::uint64_t session_id, std::uint64_t event_id,
|
||||
std::string& detail) {
|
||||
detail.clear();
|
||||
if (!session_id_ || session_id != session_id_ || event_id == 0) {
|
||||
detail = "invalid or stale audio event envelope";
|
||||
return CueStatus::invalid;
|
||||
}
|
||||
if (event_id <= last_event_id_) return CueStatus::duplicate;
|
||||
last_event_id_ = event_id;
|
||||
if (muted_) return CueStatus::muted;
|
||||
if (!device_) return CueStatus::disabled;
|
||||
return CueStatus::queued;
|
||||
}
|
||||
|
||||
CueStatus Playback::submit(CueRequest request, std::string& detail) {
|
||||
const auto gate = consume_event(request.session_id, request.event_id, detail);
|
||||
if (gate != CueStatus::queued) return gate;
|
||||
if (!play_original_id(request.original_id, detail)) return CueStatus::unsupported;
|
||||
return CueStatus::queued;
|
||||
}
|
||||
|
||||
CueStatus Playback::submit(SemanticCueRequest request, std::string& detail) {
|
||||
const auto gate = consume_event(request.session_id, request.event_id, detail);
|
||||
if (gate != CueStatus::queued) return gate;
|
||||
if (!play_semantic_cue(request.cue, detail)) return CueStatus::unsupported;
|
||||
return CueStatus::queued;
|
||||
}
|
||||
|
||||
bool Playback::load_original_bank(std::span<const std::uint8_t> bytes,
|
||||
std::string& error) {
|
||||
std::array<std::optional<PcmSample>, 13> decoded{};
|
||||
for (std::uint8_t id = 17; id <= 22; ++id) {
|
||||
OriginalCue cue;
|
||||
if (!decode_original_cue(bytes, id, cue, error)) return false;
|
||||
decoded[static_cast<std::size_t>(id - 10)] = std::move(cue.pcm);
|
||||
}
|
||||
stop();
|
||||
original_cues_ = std::move(decoded);
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Playback::play_pcm(const std::int16_t* samples, std::size_t count,
|
||||
std::uint32_t sample_rate, std::string& error) {
|
||||
error.clear();
|
||||
if (original_mode_) { error = "Original driver does not queue synthetic PCM"; return false; }
|
||||
if (!device_) { error = "audio device is unavailable"; return false; }
|
||||
if (muted_ || volume_ == 0.0F) return true;
|
||||
if (!samples || !count || sample_rate < 4000 || sample_rate > 192000) {
|
||||
error = "invalid PCM input"; return false;
|
||||
}
|
||||
if (mixer_.active()) {
|
||||
return mixer_.add_voice(std::span<const std::int16_t>(samples, count), sample_rate,
|
||||
static_cast<std::uint32_t>(obtained_.freq), error);
|
||||
}
|
||||
if (count > std::numeric_limits<std::uint32_t>::max() / sizeof(std::int16_t)) {
|
||||
error = "PCM input is too large"; return false;
|
||||
}
|
||||
const std::uint64_t output_count64 =
|
||||
(static_cast<std::uint64_t>(count) * obtained_.freq + sample_rate / 2) / sample_rate;
|
||||
if (output_count64 == 0 || output_count64 > kQueueLimitBytes / sizeof(std::int16_t)) {
|
||||
error = "PCM input exceeds the bounded playback buffer"; return false;
|
||||
}
|
||||
const auto output_count = static_cast<std::size_t>(output_count64);
|
||||
const auto queued = SDL_GetQueuedAudioSize(device_);
|
||||
if (queued > kQueueLimitBytes - output_count * sizeof(std::int16_t)) {
|
||||
error = "playback queue is full"; return false;
|
||||
}
|
||||
std::vector<std::int16_t> converted(output_count);
|
||||
for (std::size_t i = 0; i < output_count; ++i) {
|
||||
const std::uint64_t numerator = static_cast<std::uint64_t>(i) * sample_rate;
|
||||
const auto source_index = std::min<std::size_t>(count - 1,
|
||||
static_cast<std::size_t>((numerator + obtained_.freq / 2) / obtained_.freq));
|
||||
const auto scaled = std::lround(static_cast<float>(samples[source_index]) * volume_);
|
||||
converted[i] = static_cast<std::int16_t>(std::clamp<long>(scaled, -32768, 32767));
|
||||
}
|
||||
const auto bytes = static_cast<std::uint32_t>(converted.size() * sizeof(std::int16_t));
|
||||
if (SDL_QueueAudio(device_, converted.data(), bytes) != 0) {
|
||||
error = SDL_GetError(); return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Playback::play_original_id(std::uint8_t id, std::string& error) {
|
||||
if (original_mode_) {
|
||||
error.clear();
|
||||
if (!device_) { error = "audio device is unavailable"; return false; }
|
||||
AudioLock lock(device_);
|
||||
if (muted_) return true;
|
||||
if (original_.command(id)) return true;
|
||||
// Disabled Original options are normal refusals, not decoder errors.
|
||||
if (id >= 10 && id <= 22 && original_.ready()) return true;
|
||||
error = "invalid Original sound command or failed sound driver";
|
||||
return false;
|
||||
}
|
||||
error.clear();
|
||||
if (id < 10 || id > 22 || !original_cues_[static_cast<std::size_t>(id - 10)]) {
|
||||
error = "original Sound ID has no decoded PCM cue (IDs 10..16 use unsupported instruments)";
|
||||
return false;
|
||||
}
|
||||
const auto& pcm = *original_cues_[static_cast<std::size_t>(id - 10)];
|
||||
return play_pcm(pcm.mono.data(), pcm.mono.size(), pcm.sample_rate, error);
|
||||
}
|
||||
|
||||
bool Playback::play_semantic_cue(SemanticCue cue, std::string& error) {
|
||||
PcmSample pcm;
|
||||
if (!synthesize_semantic_cue(cue, pcm, error)) return false;
|
||||
return play_pcm(pcm.mono.data(), pcm.mono.size(), pcm.sample_rate, error);
|
||||
}
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,100 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
#include "mixer.hpp"
|
||||
#include "semantic_cues.hpp"
|
||||
#include "original.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
namespace openbmh::audio {
|
||||
|
||||
struct CueRequest {
|
||||
std::uint64_t session_id{};
|
||||
std::uint64_t event_id{};
|
||||
std::uint8_t original_id{};
|
||||
};
|
||||
|
||||
struct SemanticCueRequest {
|
||||
std::uint64_t session_id{};
|
||||
std::uint64_t event_id{};
|
||||
SemanticCue cue{};
|
||||
};
|
||||
|
||||
enum class CueStatus { queued, muted, disabled, duplicate, unsupported, invalid };
|
||||
|
||||
class Playback {
|
||||
public:
|
||||
Playback() = default;
|
||||
~Playback();
|
||||
Playback(const Playback&) = delete;
|
||||
Playback& operator=(const Playback&) = delete;
|
||||
|
||||
bool initialize(std::string& error);
|
||||
// Full Original driver, streamed by SDL's audio callback so synchronous
|
||||
// simulation and modal windows cannot starve music or the crowd loop.
|
||||
bool initialize_original(OriginalAssets assets, std::string& error);
|
||||
bool original_ready() const noexcept;
|
||||
void set_original_options(OriginalAudioOptions options) noexcept;
|
||||
OriginalAudioStats original_stats() const noexcept;
|
||||
void shutdown();
|
||||
bool available() const noexcept { return device_ != 0; }
|
||||
void set_muted(bool muted) noexcept;
|
||||
bool muted() const noexcept { return muted_; }
|
||||
std::uint32_t queued_bytes() const noexcept;
|
||||
void set_volume(float volume) noexcept;
|
||||
float volume() const noexcept { return volume_; }
|
||||
void stop();
|
||||
|
||||
// Optional software music. It is off by default. pump() adds at most two
|
||||
// bounded blocks of up to 20 ms; total queued audio stays at or below 40 ms.
|
||||
// Music requires 22050 Hz and a device block no larger than 256 frames.
|
||||
bool start_music_loop(const PcmSample& loop, std::string& error);
|
||||
void stop_music() noexcept;
|
||||
bool music_active() const noexcept { return mixer_.has_music(); }
|
||||
bool needs_pump() const noexcept { return !original_mode_ && mixer_.active(); }
|
||||
bool pump(std::string& error);
|
||||
|
||||
// The controller supplies stable session/event identities. IDs are not
|
||||
// generated by audio; requests are consumed once in increasing event order.
|
||||
void reset_session(std::uint64_t session_id) noexcept;
|
||||
CueStatus submit(CueRequest request, std::string& detail);
|
||||
CueStatus submit(SemanticCueRequest request, std::string& detail);
|
||||
|
||||
// Legacy PCM-only bank loader. initialize_original provides the complete
|
||||
// sequencer and instrument path for songs and all effects 10..22.
|
||||
bool load_original_bank(std::span<const std::uint8_t> bytes, std::string& error);
|
||||
|
||||
// Plays caller-supplied mono S16 native-endian PCM. A 2 MiB queue ceiling
|
||||
// prevents a caller from accumulating unbounded playback. This is a backend
|
||||
// primitive, not an original Sound ID mapping.
|
||||
bool play_pcm(const std::int16_t* samples, std::size_t count,
|
||||
std::uint32_t sample_rate, std::string& error);
|
||||
bool play_original_id(std::uint8_t id, std::string& error);
|
||||
bool play_semantic_cue(SemanticCue cue, std::string& error);
|
||||
|
||||
private:
|
||||
static void original_callback(void* userdata, Uint8* stream, int length);
|
||||
CueStatus consume_event(std::uint64_t session_id, std::uint64_t event_id,
|
||||
std::string& detail);
|
||||
SDL_AudioDeviceID device_{};
|
||||
SDL_AudioSpec obtained_{};
|
||||
bool initialized_audio_{};
|
||||
bool muted_{};
|
||||
float volume_{1.0F};
|
||||
std::uint64_t session_id_{};
|
||||
std::uint64_t last_event_id_{};
|
||||
std::array<std::optional<PcmSample>, 13> original_cues_{};
|
||||
Mixer mixer_;
|
||||
OriginalSynth original_;
|
||||
bool original_mode_{};
|
||||
OriginalAudioOptions original_options_;
|
||||
};
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,78 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "semantic_cues.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
namespace openbmh::audio {
|
||||
namespace {
|
||||
constexpr std::uint32_t kSampleRate = 22050;
|
||||
constexpr double kPi = 3.14159265358979323846;
|
||||
|
||||
std::int16_t clamp_pcm(double value) {
|
||||
const auto rounded = static_cast<long>(std::lround(value));
|
||||
return static_cast<std::int16_t>(std::clamp(rounded, -32768L, 32767L));
|
||||
}
|
||||
|
||||
void append_whistle(std::vector<std::int16_t>& pcm, std::size_t frames,
|
||||
double start_hz, double end_hz) {
|
||||
double phase = 0.0;
|
||||
const std::size_t attack = kSampleRate / 80;
|
||||
const std::size_t release = kSampleRate / 14;
|
||||
for (std::size_t i = 0; i < frames; ++i) {
|
||||
const double t = static_cast<double>(i) / static_cast<double>(frames);
|
||||
const double frequency = start_hz + (end_hz - start_hz) * t;
|
||||
phase += 2.0 * kPi * frequency / kSampleRate;
|
||||
const double in = std::min(1.0, static_cast<double>(i) / attack);
|
||||
const double out = std::min(1.0, static_cast<double>(frames - 1 - i) / release);
|
||||
const double envelope = std::min(in, out);
|
||||
const double tone = std::sin(phase) + 0.16 * std::sin(phase * 2.01);
|
||||
pcm.push_back(clamp_pcm(14500.0 * envelope * tone));
|
||||
}
|
||||
}
|
||||
|
||||
void append_fanfare_note(std::vector<std::int16_t>& pcm, std::size_t frames,
|
||||
double frequency) {
|
||||
double phase = 0.0;
|
||||
const std::size_t attack = kSampleRate / 90;
|
||||
const std::size_t release = kSampleRate / 9;
|
||||
for (std::size_t i = 0; i < frames; ++i) {
|
||||
phase += 2.0 * kPi * frequency / kSampleRate;
|
||||
const double in = std::min(1.0, static_cast<double>(i) / attack);
|
||||
const double out = std::min(1.0, static_cast<double>(frames - 1 - i) / release);
|
||||
const double envelope = std::min(in, out);
|
||||
const double brass = std::sin(phase) + 0.38 * std::sin(phase * 2.0) +
|
||||
0.14 * std::sin(phase * 3.0);
|
||||
pcm.push_back(clamp_pcm(10500.0 * envelope * brass));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool synthesize_semantic_cue(SemanticCue cue, PcmSample& out, std::string& error) {
|
||||
out = {};
|
||||
error.clear();
|
||||
out.sample_rate = kSampleRate;
|
||||
switch (cue) {
|
||||
case SemanticCue::kickoff_whistle:
|
||||
append_whistle(out.mono, kSampleRate * 42 / 100, 2050.0, 1880.0);
|
||||
break;
|
||||
case SemanticCue::goal:
|
||||
append_fanfare_note(out.mono, kSampleRate * 15 / 100, 659.25);
|
||||
append_fanfare_note(out.mono, kSampleRate * 15 / 100, 783.99);
|
||||
append_fanfare_note(out.mono, kSampleRate * 34 / 100, 987.77);
|
||||
break;
|
||||
case SemanticCue::full_time_whistle:
|
||||
append_whistle(out.mono, kSampleRate * 32 / 100, 1940.0, 1840.0);
|
||||
out.mono.insert(out.mono.end(), kSampleRate * 9 / 100, 0);
|
||||
append_whistle(out.mono, kSampleRate * 42 / 100, 2110.0, 1910.0);
|
||||
break;
|
||||
default:
|
||||
out = {};
|
||||
error = "unknown semantic audio cue";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace openbmh::audio {
|
||||
|
||||
// Presentation cues used when no verified original PCM effect is available.
|
||||
// These are intentionally semantic labels, never fabricated original Sound IDs.
|
||||
enum class SemanticCue : std::uint8_t {
|
||||
kickoff_whistle = 1,
|
||||
goal = 2,
|
||||
full_time_whistle = 3,
|
||||
};
|
||||
|
||||
// Generates deterministic mono PCM16 cues at 22050 Hz. The synthesizer has no
|
||||
// game state, random source, or renderer dependency.
|
||||
bool synthesize_semantic_cue(SemanticCue cue, PcmSample& out, std::string& error);
|
||||
|
||||
} // namespace openbmh::audio
|
||||
@@ -0,0 +1,373 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
#include "playback.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <charconv>
|
||||
#include <filesystem>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
|
||||
namespace {
|
||||
bool parse_semantic_cue(const std::string& name, openbmh::audio::SemanticCue& cue) {
|
||||
using openbmh::audio::SemanticCue;
|
||||
if (name == "kickoff_whistle") cue = SemanticCue::kickoff_whistle;
|
||||
else if (name == "goal") cue = SemanticCue::goal;
|
||||
else if (name == "full_time_whistle") cue = SemanticCue::full_time_whistle;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write_wav(const openbmh::audio::PcmSample& decoded, const char* path,
|
||||
std::string& error) {
|
||||
if (decoded.mono.size() > (std::numeric_limits<std::uint32_t>::max() - 36u) / 2u ||
|
||||
decoded.sample_rate == 0 || decoded.sample_rate > 192000) {
|
||||
error = "WAV output exceeds format bounds"; return false;
|
||||
}
|
||||
const std::uint32_t data_bytes = static_cast<std::uint32_t>(decoded.mono.size() * 2);
|
||||
std::ofstream wav(path, std::ios::binary);
|
||||
if (!wav) { error = "cannot create WAV output"; return false; }
|
||||
const auto put16 = [&wav](std::uint16_t v) {
|
||||
const char b[] = {static_cast<char>(v), static_cast<char>(v >> 8)};
|
||||
wav.write(b, 2);
|
||||
};
|
||||
const auto put32 = [&wav](std::uint32_t v) {
|
||||
const char b[] = {static_cast<char>(v), static_cast<char>(v >> 8),
|
||||
static_cast<char>(v >> 16), static_cast<char>(v >> 24)};
|
||||
wav.write(b, 4);
|
||||
};
|
||||
wav.write("RIFF", 4); put32(36 + data_bytes); wav.write("WAVEfmt ", 8);
|
||||
put32(16); put16(1); put16(1); put32(decoded.sample_rate);
|
||||
put32(decoded.sample_rate * 2); put16(2); put16(16); wav.write("data", 4);
|
||||
put32(data_bytes);
|
||||
for (const auto value : decoded.mono) put16(static_cast<std::uint16_t>(value));
|
||||
if (!wav) { error = "failed while writing WAV output"; return false; }
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bounded_number(const char* value, unsigned minimum, unsigned maximum, unsigned& out) {
|
||||
const std::string_view text(value);
|
||||
const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), out);
|
||||
return error == std::errc{} && end == text.data() + text.size() && out >= minimum && out <= maximum;
|
||||
}
|
||||
|
||||
openbmh::audio::OriginalAssets load_original_assets(const std::filesystem::path& directory) {
|
||||
openbmh::audio::OriginalAssets assets;
|
||||
const auto exe = bmh::load_le(directory / "BMH.exe");
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
assets.containers[i] = bmh::read_file(directory / "S" / std::to_string(2000 + i));
|
||||
for (unsigned i = 0; i < assets.tables.frequencies.size(); ++i)
|
||||
assets.tables.frequencies[i] = exe.u16(::bmh::layout::Audio_OriginalAudioAssets_RuntimeField2 + 2 * i);
|
||||
for (unsigned i = 0; i < assets.tables.operators.size(); ++i)
|
||||
assets.tables.operators[i] = exe.u8(::bmh::layout::Audio_OriginalAudioAssets_RuntimeField + 16 * i);
|
||||
return assets;
|
||||
}
|
||||
|
||||
int original_driver(int argc, char** argv) {
|
||||
using namespace openbmh::audio;
|
||||
const auto usage = [] {
|
||||
std::cerr << "usage: openbmh_sound --original DATA_DIR --export-song 0..2 OUTPUT.wav [--seconds 1..600] [--loops 1..16]\n"
|
||||
" openbmh_sound --original DATA_DIR --export-id 10..22 OUTPUT.wav [--seconds 1..600]\n"
|
||||
" openbmh_sound --original DATA_DIR --play-id ID [--seconds 1..600]\n"
|
||||
" openbmh_sound --original DATA_DIR --play-all [--seconds 1..600]\n";
|
||||
return 2;
|
||||
};
|
||||
if (argc < 4) return usage();
|
||||
const std::string action = argv[3];
|
||||
const bool song = action == "--export-song";
|
||||
const bool export_id = action == "--export-id";
|
||||
const bool play = action == "--play-id";
|
||||
const bool all = action == "--play-all";
|
||||
if (!song && !export_id && !play && !all) return usage();
|
||||
const int required = all ? 4 : play ? 5 : 6;
|
||||
if (argc < required) return usage();
|
||||
unsigned id = 0, seconds = song || all ? 10 : 2, loops = 1;
|
||||
if (!all && !bounded_number(argv[4], 0, 255, id)) return usage();
|
||||
if ((song && id > 2) || (export_id && (id < 10 || id > 22)) ||
|
||||
(play && !(id <= 3 || id == 8 || (id >= 10 && id <= 22)))) return usage();
|
||||
for (int at = required; at < argc; at += 2) {
|
||||
if (at + 1 >= argc) return usage();
|
||||
const std::string option = argv[at];
|
||||
if (option == "--seconds") {
|
||||
if (!bounded_number(argv[at + 1], 1, 600, seconds)) return usage();
|
||||
} else if (song && option == "--loops") {
|
||||
if (!bounded_number(argv[at + 1], 1, 16, loops)) return usage();
|
||||
} else return usage();
|
||||
}
|
||||
try {
|
||||
auto assets = load_original_assets(argv[2]);
|
||||
std::string error;
|
||||
if (song || export_id) {
|
||||
OriginalSynth synth;
|
||||
if (!synth.load(std::move(assets), 22050, error)) {
|
||||
std::cerr << "Original audio rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
if (!(song ? synth.command(std::uint8_t(id)) : synth.effect(std::uint8_t(id)))) {
|
||||
std::cerr << "Original command rejected\n"; return 1;
|
||||
}
|
||||
PcmSample pcm; pcm.sample_rate = 22050;
|
||||
const std::size_t limit = std::size_t(seconds) * pcm.sample_rate;
|
||||
pcm.mono.reserve(limit);
|
||||
std::array<std::int16_t, 128> block{};
|
||||
unsigned completed_loops = 0;
|
||||
auto previous_bar = synth.stats().bar;
|
||||
bool completed = false;
|
||||
while (pcm.mono.size() < limit) {
|
||||
const auto count = std::min(block.size(), limit - pcm.mono.size());
|
||||
synth.render(std::span(block).first(count));
|
||||
pcm.mono.insert(pcm.mono.end(), block.begin(), block.begin() + std::ptrdiff_t(count));
|
||||
const auto stats = synth.stats();
|
||||
if (stats.failed) { std::cerr << "Original decoder failed during export\n"; return 1; }
|
||||
if (song) {
|
||||
if (stats.bar < previous_bar) ++completed_loops;
|
||||
previous_bar = stats.bar;
|
||||
if (!stats.playing || completed_loops >= loops) { completed = true; break; }
|
||||
}
|
||||
}
|
||||
if (!write_wav(pcm, argv[5], error)) { std::cerr << error << '\n'; return 1; }
|
||||
const auto stats = synth.stats();
|
||||
std::cout << "exported Original " << (song ? "song=" : "effect=") << id
|
||||
<< " rate=22050 channels=1 bits=16 frames=" << pcm.mono.size()
|
||||
<< " ticks=" << stats.ticks << " loops=" << completed_loops
|
||||
<< " stop=" << (completed ? "song-or-loop-complete" : "duration-bound") << '\n';
|
||||
return 0;
|
||||
}
|
||||
Playback playback;
|
||||
if (!playback.initialize_original(std::move(assets), error)) {
|
||||
std::cerr << "Original playback unavailable: " << error << '\n'; return 1;
|
||||
}
|
||||
const auto audition = [&](unsigned command, unsigned duration) {
|
||||
if (!playback.play_original_id(std::uint8_t(command), error)) return false;
|
||||
// The actual callback must continue while the main thread is blocked.
|
||||
SDL_Delay(duration * 1000);
|
||||
const auto stats = playback.original_stats();
|
||||
std::cout << "played Original command=" << command << " frames=" << stats.frames
|
||||
<< " ticks=" << stats.ticks << " failed=" << stats.failed << '\n';
|
||||
playback.stop();
|
||||
return !stats.failed;
|
||||
};
|
||||
if (all) {
|
||||
for (unsigned command = 0; command < 3; ++command)
|
||||
if (!audition(command, seconds)) { std::cerr << error << '\n'; return 1; }
|
||||
for (unsigned command = 10; command <= 22; ++command)
|
||||
if (!audition(command, seconds)) { std::cerr << error << '\n'; return 1; }
|
||||
return 0;
|
||||
}
|
||||
if (!audition(id, seconds)) { std::cerr << error << '\n'; return 1; }
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << "Original audio input: " << error.what() << '\n'; return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc >= 2 && std::string(argv[1]) == "--original") return original_driver(argc, argv);
|
||||
if (argc < 2) {
|
||||
std::cerr << "usage: openbmh_sound <container-file> [--play-test-tone | --play-sample INDEX | --export-sample INDEX OUTPUT.wav | --play-id ID | --export-id ID OUTPUT.wav]\n"
|
||||
" openbmh_sound --original DATA_DIR --export-song 0..2 OUTPUT.wav [--seconds N] [--loops N]\n"
|
||||
" openbmh_sound --original DATA_DIR --export-id 10..22 OUTPUT.wav [--seconds N]\n"
|
||||
" openbmh_sound --original DATA_DIR --play-id ID | --play-all [--seconds N]\n"
|
||||
" openbmh_sound --play-cue NAME | --export-cue NAME OUTPUT.wav\n"
|
||||
" openbmh_sound --export-music-loop OUTPUT.wav\n";
|
||||
return 2;
|
||||
}
|
||||
if (argc == 4 && std::string(argv[1]) == "--export-cue") {
|
||||
openbmh::audio::SemanticCue cue;
|
||||
const std::string name = argv[2];
|
||||
if (!parse_semantic_cue(name, cue)) {
|
||||
std::cerr << "unknown semantic cue\n"; return 2;
|
||||
}
|
||||
openbmh::audio::PcmSample pcm;
|
||||
std::string error;
|
||||
if (!openbmh::audio::synthesize_semantic_cue(cue, pcm, error) ||
|
||||
!write_wav(pcm, argv[3], error)) {
|
||||
std::cerr << "semantic cue export failed: " << error << '\n'; return 1;
|
||||
}
|
||||
std::cout << "exported synthetic semantic cue=" << name << " rate=" << pcm.sample_rate
|
||||
<< " Hz channels=1 bits=16 frames=" << pcm.mono.size()
|
||||
<< " (not an original Sound ID)\n";
|
||||
return 0;
|
||||
}
|
||||
if (argc == 3 && std::string(argv[1]) == "--export-music-loop") {
|
||||
openbmh::audio::PcmSample pcm;
|
||||
std::string error;
|
||||
if (!openbmh::audio::synthesize_matchday_music_loop(pcm, error) ||
|
||||
!write_wav(pcm, argv[2], error)) {
|
||||
std::cerr << "synthetic music export failed: " << error << '\n'; return 1;
|
||||
}
|
||||
std::cout << "exported synthetic 8-bar matchday loop rate=" << pcm.sample_rate
|
||||
<< " Hz channels=1 bits=16 frames=" << pcm.mono.size()
|
||||
<< " (not original music or a Sound ID)\n";
|
||||
return 0;
|
||||
}
|
||||
if (argc == 3 && std::string(argv[1]) == "--play-cue") {
|
||||
openbmh::audio::SemanticCue cue;
|
||||
std::uint32_t wait_ms;
|
||||
const std::string name = argv[2];
|
||||
if (!parse_semantic_cue(name, cue)) { std::cerr << "unknown semantic cue\n"; return 2; }
|
||||
if (cue == openbmh::audio::SemanticCue::kickoff_whistle) wait_ms = 500;
|
||||
else if (cue == openbmh::audio::SemanticCue::goal) wait_ms = 750;
|
||||
else wait_ms = 1000;
|
||||
openbmh::audio::Playback playback;
|
||||
std::string cue_error;
|
||||
if (!playback.initialize(cue_error)) {
|
||||
std::cerr << "audio unavailable: " << cue_error << '\n'; return 0;
|
||||
}
|
||||
if (!playback.play_semantic_cue(cue, cue_error)) {
|
||||
std::cerr << "semantic cue playback failed: " << cue_error << '\n'; return 1;
|
||||
}
|
||||
SDL_Delay(wait_ms);
|
||||
playback.stop();
|
||||
std::cout << "played synthetic semantic cue=" << name << " (not an original Sound ID)\n";
|
||||
return 0;
|
||||
}
|
||||
std::vector<std::uint8_t> bytes;
|
||||
FILE* f = std::fopen(argv[1], "rb");
|
||||
if (!f) { std::cerr << "cannot open input\n"; return 2; }
|
||||
if (std::fseek(f, 0, SEEK_END) != 0) { std::fclose(f); return 2; }
|
||||
const long n = std::ftell(f);
|
||||
if (n < 0 || n > 64L * 1024 * 1024 || std::fseek(f, 0, SEEK_SET) != 0) {
|
||||
std::fclose(f); std::cerr << "input size rejected\n"; return 2;
|
||||
}
|
||||
bytes.resize(static_cast<std::size_t>(n));
|
||||
const auto got = std::fread(bytes.data(), 1, bytes.size(), f);
|
||||
std::fclose(f);
|
||||
if (got != bytes.size()) { std::cerr << "short read\n"; return 2; }
|
||||
|
||||
openbmh::audio::Container container;
|
||||
std::string error;
|
||||
if (!openbmh::audio::parse_container(bytes, container, error)) {
|
||||
std::cerr << "container rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
for (const auto& c : container.chunks)
|
||||
std::cout << c.id << " offset=" << c.payload_offset << " length=" << c.payload_size << '\n';
|
||||
|
||||
if ((argc >= 4 && std::string(argv[2]) == "--play-id") ||
|
||||
(argc >= 5 && std::string(argv[2]) == "--export-id")) {
|
||||
const bool do_play = std::string(argv[2]) == "--play-id";
|
||||
char* end = nullptr;
|
||||
const unsigned long id = std::strtoul(argv[3], &end, 10);
|
||||
if (!end || *end != '\0' || id > 255) {
|
||||
std::cerr << "invalid original Sound ID\n"; return 2;
|
||||
}
|
||||
openbmh::audio::OriginalCue cue;
|
||||
if (!openbmh::audio::decode_original_cue(bytes, static_cast<std::uint8_t>(id), cue, error)) {
|
||||
std::cerr << "original cue rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
if (do_play) {
|
||||
openbmh::audio::Playback playback;
|
||||
if (!playback.initialize(error)) {
|
||||
std::cerr << "audio unavailable: " << error << '\n'; return 0;
|
||||
}
|
||||
if (!playback.load_original_bank(bytes, error) ||
|
||||
!playback.play_original_id(cue.original_id, error)) {
|
||||
std::cerr << "original cue playback rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
const auto milliseconds = static_cast<std::uint32_t>(
|
||||
cue.pcm.mono.size() * 1000 / cue.pcm.sample_rate);
|
||||
SDL_Delay(milliseconds + 25);
|
||||
playback.stop();
|
||||
std::cout << "played original_id=" << static_cast<unsigned>(cue.original_id)
|
||||
<< " sefx_index=" << static_cast<unsigned>(cue.sefx_index)
|
||||
<< " samp_index=" << static_cast<unsigned>(cue.sample_index)
|
||||
<< " frames=" << cue.pcm.mono.size() << " rate="
|
||||
<< cue.pcm.sample_rate << " Hz\n";
|
||||
} else {
|
||||
if (!write_wav(cue.pcm, argv[4], error)) {
|
||||
std::cerr << error << '\n'; return 2;
|
||||
}
|
||||
std::cout << "original_id=" << static_cast<unsigned>(cue.original_id)
|
||||
<< " sefx_index=" << static_cast<unsigned>(cue.sefx_index)
|
||||
<< " samp_index=" << static_cast<unsigned>(cue.sample_index)
|
||||
<< " rate=" << cue.pcm.sample_rate << " Hz channels=1 bits=16 frames="
|
||||
<< cue.pcm.mono.size() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if ((argc >= 4 && std::string(argv[2]) == "--play-sample") ||
|
||||
(argc >= 5 && std::string(argv[2]) == "--export-sample")) {
|
||||
const bool do_play = std::string(argv[2]) == "--play-sample";
|
||||
char* end = nullptr;
|
||||
const unsigned long index = std::strtoul(argv[3], &end, 10);
|
||||
if (!end || *end != '\0' || index > 255) {
|
||||
std::cerr << "invalid sample index\n"; return 2;
|
||||
}
|
||||
const auto samp = std::find_if(container.chunks.begin(), container.chunks.end(),
|
||||
[](const auto& c) { return c.id == "SAMP"; });
|
||||
if (samp == container.chunks.end()) { std::cerr << "no SAMP chunk\n"; return 1; }
|
||||
openbmh::audio::PcmSample decoded;
|
||||
if (!openbmh::audio::decode_sample(
|
||||
std::span<const std::uint8_t>(bytes).subspan(samp->payload_offset, samp->payload_size),
|
||||
index, decoded, error)) {
|
||||
std::cerr << "sample rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
if (do_play) {
|
||||
openbmh::audio::Playback playback;
|
||||
if (!playback.initialize(error)) {
|
||||
std::cerr << "audio unavailable: " << error << '\n'; return 0;
|
||||
}
|
||||
if (!playback.play_pcm(decoded.mono.data(), decoded.mono.size(), decoded.sample_rate, error)) {
|
||||
std::cerr << "sample playback rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
const auto milliseconds = static_cast<std::uint32_t>(
|
||||
decoded.mono.size() * 1000 / decoded.sample_rate);
|
||||
SDL_Delay(milliseconds + 25);
|
||||
playback.stop();
|
||||
std::cout << "played SAMP sample=" << index << " frames=" << decoded.mono.size()
|
||||
<< " rate=" << decoded.sample_rate << " Hz\n";
|
||||
} else {
|
||||
const std::uint32_t data_bytes = static_cast<std::uint32_t>(decoded.mono.size() * 2);
|
||||
std::ofstream wav(argv[4], std::ios::binary);
|
||||
if (!wav) { std::cerr << "cannot create WAV output\n"; return 2; }
|
||||
const auto put16 = [&wav](std::uint16_t v) {
|
||||
const char b[] = {static_cast<char>(v), static_cast<char>(v >> 8)};
|
||||
wav.write(b, 2);
|
||||
};
|
||||
const auto put32 = [&wav](std::uint32_t v) {
|
||||
const char b[] = {static_cast<char>(v), static_cast<char>(v >> 8),
|
||||
static_cast<char>(v >> 16), static_cast<char>(v >> 24)};
|
||||
wav.write(b, 4);
|
||||
};
|
||||
wav.write("RIFF", 4); put32(36 + data_bytes); wav.write("WAVEfmt ", 8);
|
||||
put32(16); put16(1); put16(1); put32(decoded.sample_rate);
|
||||
put32(decoded.sample_rate * 2); put16(2); put16(16); wav.write("data", 4);
|
||||
put32(data_bytes);
|
||||
for (const auto value : decoded.mono) put16(static_cast<std::uint16_t>(value));
|
||||
if (!wav) { std::cerr << "failed while writing WAV\n"; return 2; }
|
||||
std::cout << "sample=" << index << " rate=" << decoded.sample_rate
|
||||
<< " Hz channels=1 bits=16 frames=" << decoded.mono.size() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (argc >= 3 && std::string(argv[2]) == "--play-test-tone") {
|
||||
openbmh::audio::Playback playback;
|
||||
if (!playback.initialize(error)) {
|
||||
std::cerr << "audio unavailable: " << error << '\n'; return 0;
|
||||
}
|
||||
constexpr std::uint32_t rate = 22050;
|
||||
std::vector<std::int16_t> tone(rate / 5);
|
||||
for (std::size_t i = 0; i < tone.size(); ++i)
|
||||
tone[i] = static_cast<std::int16_t>(6000.0 * std::sin(2.0 * 3.141592653589793 * 440.0 * i / rate));
|
||||
if (!playback.play_pcm(tone.data(), tone.size(), rate, error)) {
|
||||
std::cerr << "test tone rejected: " << error << '\n'; return 1;
|
||||
}
|
||||
SDL_Delay(250);
|
||||
playback.stop();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+504
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random
|
||||
Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
Nuked OPL3 by Nuke.YKT, unmodified upstream source.
|
||||
|
||||
Upstream: https://github.com/nukeykt/Nuked-OPL3
|
||||
Commit: 765ec962e473aeb767e4cba74ffdc8f588ffbfe8
|
||||
License: LGPL-2.1-or-later (see LICENSE and source notices).
|
||||
|
||||
Used in OPL2 compatibility mode for the Original MIDILINK register stream.
|
||||
No Original music, instruments, samples or executable bytes are distributed.
|
||||
+1517
File diff suppressed because it is too large.
Load diff
+175
@@ -0,0 +1,175 @@
|
||||
/* Nuked OPL3
|
||||
* Copyright (C) 2013-2020 Nuke.YKT
|
||||
*
|
||||
* This file is part of Nuked OPL3.
|
||||
*
|
||||
* Nuked OPL3 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* Nuked OPL3 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Nuked OPL3. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
* Nuked OPL3 emulator.
|
||||
* Thanks:
|
||||
* MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh):
|
||||
* Feedback and Rhythm part calculation information.
|
||||
* forums.submarine.org.uk(carbon14, opl3):
|
||||
* Tremolo and phase generator calculation information.
|
||||
* OPLx decapsulated(Matthew Gambrell, Olli Niemitalo):
|
||||
* OPL2 ROMs.
|
||||
* siliconpr0n.org(John McMaster, digshadow):
|
||||
* YMF262 and VRC VII decaps and die shots.
|
||||
*
|
||||
* version: 1.8
|
||||
*/
|
||||
|
||||
#ifndef OPL_OPL3_H
|
||||
#define OPL_OPL3_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef OPL_ENABLE_STEREOEXT
|
||||
#define OPL_ENABLE_STEREOEXT 0
|
||||
#endif
|
||||
|
||||
#define OPL_WRITEBUF_SIZE 1024
|
||||
#define OPL_WRITEBUF_DELAY 2
|
||||
|
||||
typedef struct _opl3_slot opl3_slot;
|
||||
typedef struct _opl3_channel opl3_channel;
|
||||
typedef struct _opl3_chip opl3_chip;
|
||||
|
||||
struct _opl3_slot {
|
||||
opl3_channel *channel;
|
||||
opl3_chip *chip;
|
||||
int16_t out;
|
||||
int16_t fbmod;
|
||||
int16_t *mod;
|
||||
int16_t prout;
|
||||
uint16_t eg_rout;
|
||||
uint16_t eg_out;
|
||||
uint8_t eg_inc;
|
||||
uint8_t eg_gen;
|
||||
uint8_t eg_rate;
|
||||
uint8_t eg_ksl;
|
||||
uint8_t *trem;
|
||||
uint8_t reg_vib;
|
||||
uint8_t reg_type;
|
||||
uint8_t reg_ksr;
|
||||
uint8_t reg_mult;
|
||||
uint8_t reg_ksl;
|
||||
uint8_t reg_tl;
|
||||
uint8_t reg_ar;
|
||||
uint8_t reg_dr;
|
||||
uint8_t reg_sl;
|
||||
uint8_t reg_rr;
|
||||
uint8_t reg_wf;
|
||||
uint8_t key;
|
||||
uint32_t pg_reset;
|
||||
uint32_t pg_phase;
|
||||
uint16_t pg_phase_out;
|
||||
uint8_t slot_num;
|
||||
};
|
||||
|
||||
struct _opl3_channel {
|
||||
opl3_slot *slotz[2];/*Don't use "slots" keyword to avoid conflict with Qt applications*/
|
||||
opl3_channel *pair;
|
||||
opl3_chip *chip;
|
||||
int16_t *out[4];
|
||||
|
||||
#if OPL_ENABLE_STEREOEXT
|
||||
int32_t leftpan;
|
||||
int32_t rightpan;
|
||||
#endif
|
||||
|
||||
uint8_t chtype;
|
||||
uint16_t f_num;
|
||||
uint16_t f_num_reg;
|
||||
uint8_t block;
|
||||
uint8_t block_reg;
|
||||
uint8_t fb;
|
||||
uint8_t con;
|
||||
uint8_t alg;
|
||||
uint8_t ksv;
|
||||
uint16_t cha, chb;
|
||||
uint16_t chc, chd;
|
||||
uint8_t ch_num;
|
||||
};
|
||||
|
||||
typedef struct _opl3_writebuf {
|
||||
uint64_t time;
|
||||
uint16_t reg;
|
||||
uint8_t data;
|
||||
} opl3_writebuf;
|
||||
|
||||
struct _opl3_chip {
|
||||
opl3_channel channel[18];
|
||||
opl3_slot slot[36];
|
||||
uint16_t timer;
|
||||
uint64_t eg_timer;
|
||||
uint8_t eg_timerrem;
|
||||
uint8_t eg_state;
|
||||
uint8_t eg_add;
|
||||
uint8_t eg_timer_lo;
|
||||
uint8_t newm;
|
||||
uint8_t nts;
|
||||
uint8_t rhy;
|
||||
uint8_t vibpos;
|
||||
uint8_t vibshift;
|
||||
uint8_t tremolo;
|
||||
uint8_t tremolopos;
|
||||
uint8_t tremoloshift;
|
||||
uint32_t noise;
|
||||
int16_t zeromod;
|
||||
int32_t mixbuff[4];
|
||||
uint8_t rm_hh_bit2;
|
||||
uint8_t rm_hh_bit3;
|
||||
uint8_t rm_hh_bit7;
|
||||
uint8_t rm_hh_bit8;
|
||||
uint8_t rm_tc_bit3;
|
||||
uint8_t rm_tc_bit5;
|
||||
|
||||
#if OPL_ENABLE_STEREOEXT
|
||||
uint8_t stereoext;
|
||||
#endif
|
||||
|
||||
/* OPL3L */
|
||||
int32_t rateratio;
|
||||
int32_t samplecnt;
|
||||
int16_t oldsamples[4];
|
||||
int16_t samples[4];
|
||||
|
||||
uint64_t writebuf_samplecnt;
|
||||
uint32_t writebuf_cur;
|
||||
uint32_t writebuf_last;
|
||||
uint64_t writebuf_lasttime;
|
||||
opl3_writebuf writebuf[OPL_WRITEBUF_SIZE];
|
||||
};
|
||||
|
||||
void OPL3_Generate(opl3_chip *chip, int16_t *buf);
|
||||
void OPL3_GenerateResampled(opl3_chip *chip, int16_t *buf);
|
||||
void OPL3_Reset(opl3_chip *chip, uint32_t samplerate);
|
||||
void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v);
|
||||
void OPL3_WriteRegBuffered(opl3_chip *chip, uint16_t reg, uint8_t v);
|
||||
void OPL3_GenerateStream(opl3_chip *chip, int16_t *sndptr, uint32_t numsamples);
|
||||
|
||||
void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4);
|
||||
void OPL3_Generate4ChResampled(opl3_chip *chip, int16_t *buf4);
|
||||
void OPL3_Generate4ChStream(opl3_chip *chip, int16_t *sndptr1, int16_t *sndptr2, uint32_t numsamples);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,354 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "container.hpp"
|
||||
#include "music_fallback.hpp"
|
||||
#include "playback.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
#define CHECK(expr) do { if (!(expr)) { \
|
||||
std::cerr << "check failed at line " << __LINE__ << ": " << #expr << '\n'; \
|
||||
return 1; \
|
||||
} } while (false)
|
||||
std::vector<std::uint8_t> fixture() {
|
||||
// Authored format header and payload, not bytes copied from a game asset.
|
||||
return {'F','O','R','M', 17,0,0,0, 'A','L','P','T','R','A','U','M',
|
||||
'H','E','D','R', 1,0,0,0, 42};
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> sfx_fixture() {
|
||||
std::vector<std::uint8_t> bytes(65380, 0);
|
||||
std::copy_n("FORM", 4, bytes.begin());
|
||||
const auto put32 = [&bytes](std::size_t at, std::uint32_t value) {
|
||||
for (unsigned i = 0; i < 4; ++i) bytes[at + i] = static_cast<std::uint8_t>(value >> (i * 8));
|
||||
};
|
||||
const auto put16 = [&bytes](std::size_t at, std::uint16_t value) {
|
||||
bytes[at] = static_cast<std::uint8_t>(value);
|
||||
bytes[at + 1] = static_cast<std::uint8_t>(value >> 8);
|
||||
};
|
||||
put32(4, static_cast<std::uint32_t>(bytes.size()));
|
||||
std::copy_n("ALPTRAUM", 8, bytes.begin() + 8);
|
||||
const auto chunk = [&bytes, &put32](std::size_t at, const char* id, std::uint32_t size) {
|
||||
std::copy_n(id, 4, bytes.begin() + static_cast<std::ptrdiff_t>(at));
|
||||
put32(at + 4, size);
|
||||
};
|
||||
chunk(16, "HEDR", 8);
|
||||
chunk(32, "SEFX", 212);
|
||||
bytes[42] = 7;
|
||||
for (std::size_t i = 7; i < 13; ++i) {
|
||||
const std::size_t row = 44 + i * 16;
|
||||
bytes[row] = static_cast<std::uint8_t>(16 + i - 7);
|
||||
bytes[row + 1] = 9;
|
||||
}
|
||||
chunk(252, "INST", 228);
|
||||
chunk(488, "SAMP", 64884);
|
||||
const std::size_t samp = 496;
|
||||
put16(samp + 2, 6);
|
||||
const std::size_t data_at = samp + 4 + 6 * 16;
|
||||
for (std::size_t i = 0; i < 6; ++i) {
|
||||
const std::size_t row = samp + 4 + i * 16;
|
||||
put16(row, static_cast<std::uint16_t>(i * 2048));
|
||||
put16(row + 2, 2048);
|
||||
put16(row + 8, 11025);
|
||||
std::fill(bytes.begin() + static_cast<std::ptrdiff_t>(data_at + i * 2048),
|
||||
bytes.begin() + static_cast<std::ptrdiff_t>(data_at + (i + 1) * 2048),
|
||||
static_cast<std::uint8_t>(128 + i));
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**) { // (the SDL_main signature: SDL.h renames main on Windows)
|
||||
using namespace openbmh::audio;
|
||||
std::string error;
|
||||
Container c;
|
||||
auto good = fixture();
|
||||
CHECK(parse_container(good, c, error));
|
||||
CHECK(c.chunks.size() == 1 && c.chunks[0].id == "HEDR");
|
||||
CHECK(c.chunks[0].payload_size == 1 && good[c.chunks[0].payload_offset] == 42);
|
||||
|
||||
auto broken = good;
|
||||
broken[20] = 0xff;
|
||||
broken[21] = 0xff;
|
||||
broken[22] = 0xff;
|
||||
broken[23] = 0x7f;
|
||||
CHECK(!parse_container(broken, c, error));
|
||||
CHECK(c.chunks.empty());
|
||||
CHECK(!parse_container(std::span<const std::uint8_t>(good.data(), 15), c, error));
|
||||
|
||||
std::vector<std::uint8_t> sefx(65380, 0);
|
||||
const char form[] = "FORM";
|
||||
std::copy(form, form + 4, sefx.begin());
|
||||
sefx[4] = static_cast<std::uint8_t>(sefx.size());
|
||||
sefx[5] = static_cast<std::uint8_t>(sefx.size() >> 8);
|
||||
const char type[] = "ALPTRAUM";
|
||||
std::copy(type, type + 8, sefx.begin() + 8);
|
||||
std::size_t at = 16;
|
||||
const auto put_chunk = [&](const char* id, std::uint32_t size, std::size_t& cursor) {
|
||||
std::copy(id, id + 4, sefx.begin() + static_cast<std::ptrdiff_t>(cursor));
|
||||
sefx[cursor + 4] = static_cast<std::uint8_t>(size);
|
||||
sefx[cursor + 5] = static_cast<std::uint8_t>(size >> 8);
|
||||
cursor += 8 + size;
|
||||
};
|
||||
put_chunk("HEDR", 8, at);
|
||||
put_chunk("SEFX", 212, at);
|
||||
sefx[42] = 7; // observed 2003 SEFX record-count field
|
||||
put_chunk("INST", 228, at);
|
||||
put_chunk("SAMP", 64884, at);
|
||||
CHECK(at == sefx.size());
|
||||
CHECK(parse_container(sefx, c, error));
|
||||
CHECK(c.chunks.size() == 4 && c.chunks[1].id == "SEFX");
|
||||
auto wrong_exception = sefx;
|
||||
wrong_exception[32] = 'S'; wrong_exception[33] = 'O';
|
||||
wrong_exception[34] = 'N'; wrong_exception[35] = 'G';
|
||||
CHECK(!parse_container(wrong_exception, c, error));
|
||||
auto wrong_type = good;
|
||||
wrong_type[8] = 'X';
|
||||
CHECK(!parse_container(wrong_type, c, error));
|
||||
|
||||
std::vector<std::uint8_t> samp(24, 0);
|
||||
samp[2] = 1;
|
||||
samp[6] = 4;
|
||||
samp[12] = 0x22; samp[13] = 0x56; // 22050 Hz
|
||||
samp[20] = 0; samp[21] = 128; samp[22] = 255; samp[23] = 128;
|
||||
PcmSample pcm;
|
||||
CHECK(decode_sample(samp, 0, pcm, error));
|
||||
CHECK(pcm.sample_rate == 22050 && pcm.mono.size() == 4);
|
||||
CHECK(pcm.mono[0] == -32768 && pcm.mono[1] == 0 && pcm.mono[2] == 32512);
|
||||
samp[6] = 0xff; samp[7] = 0xff;
|
||||
CHECK(!decode_sample(samp, 0, pcm, error));
|
||||
CHECK(!decode_sample(samp, 1, pcm, error));
|
||||
|
||||
auto bank = sfx_fixture();
|
||||
OriginalCue original;
|
||||
CHECK(decode_original_cue(bank, 17, original, error));
|
||||
CHECK(original.original_id == 17 && original.sefx_index == 7 && original.sample_index == 0);
|
||||
CHECK(original.pcm.sample_rate == 11025 && original.pcm.mono.size() == 2048);
|
||||
CHECK(original.pcm.mono.front() == 0);
|
||||
CHECK(decode_original_cue(bank, 22, original, error));
|
||||
CHECK(original.sefx_index == 12 && original.sample_index == 5);
|
||||
CHECK(!decode_original_cue(bank, 16, original, error));
|
||||
|
||||
CHECK(SDL_InitSubSystem(SDL_INIT_VIDEO) == 0);
|
||||
Playback playback;
|
||||
CHECK(playback.initialize(error));
|
||||
CHECK(playback.available());
|
||||
CHECK(!playback.music_active() && !playback.needs_pump());
|
||||
CHECK(!playback.pump(error)); // The optional music path is inactive by default.
|
||||
playback.set_volume(2.0F);
|
||||
CHECK(playback.volume() == 1.0F);
|
||||
playback.set_volume(-1.0F);
|
||||
CHECK(playback.volume() == 0.0F);
|
||||
playback.set_volume(1.0F);
|
||||
playback.set_volume(std::numeric_limits<float>::quiet_NaN());
|
||||
CHECK(playback.volume() == 1.0F);
|
||||
playback.set_volume(std::numeric_limits<float>::infinity());
|
||||
CHECK(playback.volume() == 1.0F);
|
||||
playback.set_muted(true);
|
||||
CHECK(playback.muted());
|
||||
CHECK(playback.play_pcm(nullptr, 0, 22050, error)); // mute drops without queueing
|
||||
playback.set_muted(false);
|
||||
const std::int16_t sample[] = {0, 1000, -1000, 0};
|
||||
CHECK(playback.play_pcm(sample, 4, 22050, error));
|
||||
std::vector<std::int16_t> long_sample(22050, 1000);
|
||||
CHECK(playback.play_pcm(long_sample.data(), long_sample.size(), 22050, error));
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
playback.set_muted(true);
|
||||
CHECK(playback.queued_bytes() == 0);
|
||||
playback.set_muted(false);
|
||||
CHECK(playback.play_pcm(long_sample.data(), long_sample.size(), 22050, error));
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
|
||||
playback.reset_session(7);
|
||||
CHECK(playback.queued_bytes() == 0);
|
||||
playback.reset_session(7); // same session preserves the event watermark
|
||||
CHECK(playback.load_original_bank(bank, error));
|
||||
|
||||
const CueRequest cue_a{7, 1, 17};
|
||||
CHECK(playback.submit(cue_a, error) == CueStatus::queued);
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
CHECK(playback.submit(cue_a, error) == CueStatus::duplicate);
|
||||
CHECK(playback.submit(CueRequest{7, 2, 17}, error) == CueStatus::queued);
|
||||
playback.set_muted(true);
|
||||
const CueRequest muted{7, 3, 17};
|
||||
CHECK(playback.submit(muted, error) == CueStatus::muted);
|
||||
playback.set_muted(false);
|
||||
CHECK(playback.submit(muted, error) == CueStatus::duplicate);
|
||||
playback.stop();
|
||||
CHECK(playback.submit(cue_a, error) == CueStatus::duplicate);
|
||||
playback.reset_session(8);
|
||||
CHECK(playback.submit(CueRequest{8, 1, 17}, error) == CueStatus::queued);
|
||||
CHECK(playback.submit(CueRequest{7, 4, 17}, error) == CueStatus::invalid);
|
||||
CHECK(playback.submit(CueRequest{8, 1, 17}, error) == CueStatus::duplicate);
|
||||
|
||||
PcmSample kickoff_pcm, goal_pcm, final_pcm;
|
||||
CHECK(synthesize_semantic_cue(SemanticCue::kickoff_whistle, kickoff_pcm, error));
|
||||
CHECK(synthesize_semantic_cue(SemanticCue::goal, goal_pcm, error));
|
||||
CHECK(synthesize_semantic_cue(SemanticCue::full_time_whistle, final_pcm, error));
|
||||
CHECK(kickoff_pcm.sample_rate == 22050 && goal_pcm.sample_rate == 22050 &&
|
||||
final_pcm.sample_rate == 22050);
|
||||
CHECK(!kickoff_pcm.mono.empty() && !goal_pcm.mono.empty() && !final_pcm.mono.empty());
|
||||
CHECK(kickoff_pcm.mono != goal_pcm.mono && goal_pcm.mono != final_pcm.mono &&
|
||||
kickoff_pcm.mono != final_pcm.mono);
|
||||
PcmSample matchday_loop, repeated_loop;
|
||||
CHECK(synthesize_matchday_music_loop(matchday_loop, error));
|
||||
CHECK(synthesize_matchday_music_loop(repeated_loop, error));
|
||||
CHECK(matchday_loop.sample_rate == 22050);
|
||||
CHECK(matchday_loop.mono.size() == 392000); // 8 bars, 4 beats, 108 BPM.
|
||||
CHECK(matchday_loop.mono == repeated_loop.mono); // deterministic, no RNG.
|
||||
CHECK(matchday_loop.mono.front() == 0 && matchday_loop.mono.back() == 0);
|
||||
CHECK(std::any_of(matchday_loop.mono.begin(), matchday_loop.mono.end(),
|
||||
[](std::int16_t value) { return value != 0; }));
|
||||
|
||||
Mixer mixer;
|
||||
PcmSample constant_music{22050, std::vector<std::int16_t>(8, 1000)};
|
||||
const std::int16_t voice_samples[] = {2000, 2000, 2000, 2000};
|
||||
CHECK(mixer.start_music_loop(constant_music, 22050, error));
|
||||
CHECK(mixer.add_voice(voice_samples, 22050, 22050, error));
|
||||
CHECK(mixer.active_voices() == 1);
|
||||
std::int16_t mixed_block[2]{};
|
||||
CHECK(mixer.mix_block(mixed_block, 1.0F));
|
||||
CHECK(mixed_block[0] == 3000 && mixed_block[1] == 3000); // Cue overlays the loop.
|
||||
mixer.stop_music();
|
||||
CHECK(!mixer.has_music() && mixer.active_voices() == 1);
|
||||
std::int16_t voice_tail[4]{};
|
||||
CHECK(mixer.mix_block(voice_tail, 1.0F)); // stop_music leaves the cue voice alive.
|
||||
CHECK(voice_tail[0] == 2000 && voice_tail[1] == 2000 &&
|
||||
voice_tail[2] == 0 && voice_tail[3] == 0);
|
||||
CHECK(!mixer.active());
|
||||
mixer.clear();
|
||||
CHECK(mixer.start_music_loop(constant_music, 22050, error));
|
||||
for (int i = 0; i < 8; ++i) CHECK(mixer.add_voice(voice_samples, 22050, 22050, error));
|
||||
CHECK(mixer.active_voices() == 8);
|
||||
CHECK(!mixer.add_voice(voice_samples, 22050, 22050, error));
|
||||
mixer.clear();
|
||||
static_assert(static_cast<std::uint8_t>(SemanticCue::kickoff_whistle) == 1);
|
||||
static_assert(static_cast<std::uint8_t>(SemanticCue::goal) == 2);
|
||||
static_assert(static_cast<std::uint8_t>(SemanticCue::full_time_whistle) == 3);
|
||||
playback.reset_session(9);
|
||||
const SemanticCueRequest kickoff{9, 1, SemanticCue::kickoff_whistle};
|
||||
CHECK(playback.submit(kickoff, error) == CueStatus::queued);
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
CHECK(playback.submit(kickoff, error) == CueStatus::duplicate);
|
||||
CHECK(playback.submit(SemanticCueRequest{9, 2, SemanticCue::kickoff_whistle}, error) == CueStatus::queued);
|
||||
playback.set_muted(true);
|
||||
const SemanticCueRequest muted_goal{9, 3, SemanticCue::goal};
|
||||
CHECK(playback.submit(muted_goal, error) == CueStatus::muted);
|
||||
playback.set_muted(false);
|
||||
CHECK(playback.submit(muted_goal, error) == CueStatus::duplicate);
|
||||
CHECK(playback.submit(SemanticCueRequest{9, 4, SemanticCue::goal}, error) == CueStatus::queued);
|
||||
playback.reset_session(10);
|
||||
CHECK(playback.queued_bytes() == 0);
|
||||
CHECK(playback.submit(SemanticCueRequest{10, 1, SemanticCue::full_time_whistle}, error) == CueStatus::queued);
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
|
||||
playback.reset_session(11);
|
||||
CHECK(playback.submit(CueRequest{11, 1, 17}, error) == CueStatus::queued);
|
||||
CHECK(playback.submit(SemanticCueRequest{11, 1, SemanticCue::goal}, error) == CueStatus::duplicate);
|
||||
CHECK(playback.submit(SemanticCueRequest{11, 2, SemanticCue::goal}, error) == CueStatus::queued);
|
||||
CHECK(playback.submit(CueRequest{11, 2, 17}, error) == CueStatus::duplicate);
|
||||
CHECK(playback.submit(SemanticCueRequest{10, 3, SemanticCue::goal}, error) == CueStatus::invalid);
|
||||
CHECK(playback.submit(CueRequest{11, 0, 17}, error) == CueStatus::invalid);
|
||||
CHECK(playback.submit(SemanticCueRequest{11, 3, SemanticCue::full_time_whistle}, error) == CueStatus::queued);
|
||||
|
||||
// Optional music is explicit. Cues submitted while it is active enter the
|
||||
// mixer immediately; pump emits short mixed blocks, never a whole loop.
|
||||
playback.reset_session(12);
|
||||
CHECK(playback.play_pcm(long_sample.data(), long_sample.size(), 22050, error));
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
CHECK(!playback.start_music_loop(matchday_loop, error)); // Reject >40ms legacy cue backlog.
|
||||
CHECK(!playback.music_active());
|
||||
CHECK(playback.queued_bytes() > 0); // Existing queued cue was not discarded.
|
||||
playback.stop();
|
||||
CHECK(!playback.needs_pump());
|
||||
CHECK(playback.start_music_loop(matchday_loop, error));
|
||||
CHECK(playback.pump(error));
|
||||
CHECK(playback.queued_bytes() <= 40U * 22050U * 2U / 1000U);
|
||||
// Refill after typical 60/30 Hz app ticks. This checks the bounded refill,
|
||||
// not continuous audible output: the dummy backend is not a listening test.
|
||||
for (const unsigned delay : {17U, 33U}) {
|
||||
for (unsigned tick = 0; tick < 12; ++tick) {
|
||||
SDL_Delay(delay);
|
||||
CHECK(playback.pump(error));
|
||||
CHECK(error.empty());
|
||||
CHECK(playback.queued_bytes() > 0);
|
||||
CHECK(playback.queued_bytes() <= 40U * 22050U * 2U / 1000U);
|
||||
}
|
||||
}
|
||||
CHECK(playback.submit(CueRequest{12, 1, 17}, error) == CueStatus::queued);
|
||||
bool cue_pumped = false;
|
||||
for (unsigned attempt = 0; attempt < 5 && !cue_pumped; ++attempt) {
|
||||
cue_pumped = playback.pump(error);
|
||||
if (cue_pumped)
|
||||
CHECK(playback.queued_bytes() <= 40U * 22050U * 2U / 1000U);
|
||||
if (!cue_pumped) SDL_Delay(25);
|
||||
}
|
||||
CHECK(cue_pumped);
|
||||
const SemanticCueRequest music_muted_event{12, 2, SemanticCue::goal};
|
||||
playback.set_muted(true); // Clears music and both queued and active voices.
|
||||
CHECK(!playback.music_active());
|
||||
CHECK(!playback.pump(error));
|
||||
CHECK(playback.submit(music_muted_event, error) == CueStatus::muted);
|
||||
playback.set_muted(false);
|
||||
CHECK(playback.submit(music_muted_event, error) == CueStatus::duplicate);
|
||||
CHECK(!playback.pump(error));
|
||||
|
||||
// A zero master volume still advances an already active voice silently.
|
||||
playback.reset_session(13);
|
||||
CHECK(playback.start_music_loop(matchday_loop, error));
|
||||
const std::int16_t short_voice[] = {1000, 1000, 1000, 1000};
|
||||
CHECK(playback.play_pcm(short_voice, 4, 22050, error));
|
||||
playback.set_volume(0.0F);
|
||||
playback.stop_music();
|
||||
CHECK(playback.needs_pump());
|
||||
CHECK(playback.pump(error));
|
||||
CHECK(!playback.needs_pump());
|
||||
playback.set_volume(1.0F);
|
||||
CHECK(!playback.pump(error)); // No delayed replay after restoring volume.
|
||||
|
||||
playback.reset_session(13);
|
||||
CHECK(!playback.music_active() && !playback.pump(error));
|
||||
CHECK(playback.start_music_loop(matchday_loop, error));
|
||||
CHECK(playback.needs_pump());
|
||||
playback.reset_session(14); // A real session change clears music and queue.
|
||||
CHECK(!playback.music_active() && !playback.needs_pump() && playback.queued_bytes() == 0);
|
||||
CHECK(playback.start_music_loop(matchday_loop, error));
|
||||
CHECK(playback.submit(CueRequest{14, 1, 17}, error) == CueStatus::queued);
|
||||
playback.stop_music();
|
||||
CHECK(!playback.music_active());
|
||||
CHECK(playback.needs_pump());
|
||||
CHECK(playback.pump(error)); // Stopping music alone preserves an active cue.
|
||||
playback.stop();
|
||||
CHECK(!playback.needs_pump());
|
||||
CHECK(!playback.pump(error));
|
||||
|
||||
Playback unavailable;
|
||||
unavailable.reset_session(20);
|
||||
const CueRequest unavailable_event{20, 1, 17};
|
||||
CHECK(!unavailable.available());
|
||||
CHECK(!unavailable.start_music_loop(matchday_loop, error));
|
||||
CHECK(unavailable.submit(unavailable_event, error) == CueStatus::disabled);
|
||||
playback.shutdown();
|
||||
CHECK(unavailable.initialize(error));
|
||||
CHECK(unavailable.submit(unavailable_event, error) == CueStatus::duplicate);
|
||||
CHECK(unavailable.queued_bytes() == 0); // A disabled event is not replayed after device recovery.
|
||||
unavailable.shutdown();
|
||||
CHECK(playback.initialize(error));
|
||||
playback.reset_session(15);
|
||||
CHECK(playback.start_music_loop(matchday_loop, error));
|
||||
CHECK(playback.submit(CueRequest{15, 1, 17}, error) == CueStatus::queued);
|
||||
playback.shutdown(); // Device shutdown clears the optional track and active cue.
|
||||
CHECK(!playback.available() && !playback.music_active());
|
||||
playback.shutdown();
|
||||
CHECK(!playback.available());
|
||||
CHECK((SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO) != 0);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
std::cout << "checks passed: original/semantic shared event ledger; stale and zero IDs; unavailable device and no replay; deterministic eight-bar loop; PCM overlay and stop-music cue tail; fixed voice cap; mute/reset/shutdown clear music; SDL dummy lifecycle; no listening test\n";
|
||||
return 0; // (explicit: main is SDL_main here, no implicit return 0)
|
||||
}
|
||||
@@ -0,0 +1,737 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The console's core: registry, input blocks, argument binding, output and the global
|
||||
// commands (docs/CLI_CONCEPT/01-grundlagen.md). The windows live in windows_*.cpp.
|
||||
|
||||
#include "cli/console/console.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "cli/console/detail.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
|
||||
namespace bmh::cli::console {
|
||||
|
||||
using namespace detail;
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// detail helpers
|
||||
|
||||
namespace detail {
|
||||
|
||||
Param integer(std::string name, long long min, long long max, bool optional) {
|
||||
Param p;
|
||||
p.name = std::move(name);
|
||||
p.type = Param::Type::integer;
|
||||
p.min = min, p.max = max, p.optional = optional;
|
||||
return p;
|
||||
}
|
||||
Param boolean(std::string name, bool optional) {
|
||||
Param p;
|
||||
p.name = std::move(name);
|
||||
p.type = Param::Type::boolean;
|
||||
p.optional = optional;
|
||||
return p;
|
||||
}
|
||||
Param text(std::string name, long long max_length, bool optional) {
|
||||
Param p;
|
||||
p.name = std::move(name);
|
||||
p.type = Param::Type::text;
|
||||
p.max = max_length, p.optional = optional;
|
||||
return p;
|
||||
}
|
||||
Param choice(std::string name, std::vector<std::string> choices, bool optional) {
|
||||
Param p;
|
||||
p.name = std::move(name);
|
||||
p.type = Param::Type::choice;
|
||||
p.choices = std::move(choices);
|
||||
p.optional = optional;
|
||||
return p;
|
||||
}
|
||||
|
||||
std::string on_off(bool v) { return v ? "on" : "off"; }
|
||||
|
||||
std::string lower(std::string s) {
|
||||
for (char& c : s) c = char(std::tolower(static_cast<unsigned char>(c)));
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string utf8(std::string_view text) {
|
||||
for (char c : text)
|
||||
if (static_cast<unsigned char>(c) >= 0x80) return std::string(text);
|
||||
return ui::original_to_utf8(text);
|
||||
}
|
||||
|
||||
std::string fold(std::string s) {
|
||||
s = lower(std::move(s));
|
||||
// UTF-8 Ä Ö Ü (C3 84, C3 96, C3 9C) -> ä ö ü (C3 A4, C3 B6, C3 BC)
|
||||
for (size_t i = 0; i + 1 < s.size(); ++i)
|
||||
if (static_cast<unsigned char>(s[i]) == 0xC3) {
|
||||
unsigned char& c = reinterpret_cast<unsigned char&>(s[i + 1]);
|
||||
if (c == 0x84 || c == 0x96 || c == 0x9C) c = static_cast<unsigned char>(c + 0x20);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// Dates as the concept's `date` type: YYYY-MM-DD (01-grundlagen 1.2).
|
||||
std::string date_text(int day, int month, int year) {
|
||||
char buffer[16];
|
||||
std::snprintf(buffer, sizeof buffer, "%04d-%02d-%02d", year, month, day);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
std::string money(long long value) { return std::to_string(value); }
|
||||
|
||||
size_t resolve_player(const std::string& reference, const std::vector<PlayerRef>& players) {
|
||||
const std::string key = lower(reference);
|
||||
auto number = [&](size_t prefix) {
|
||||
Arg a;
|
||||
a.text = reference.substr(prefix);
|
||||
const auto n = to_int(a);
|
||||
if (!n) fail("E_BAD_ARGUMENT", "\"" + reference + "\" is no player reference (id:<n>, row:<n> or a name)");
|
||||
return int(*n);
|
||||
};
|
||||
if (key.rfind("id:", 0) == 0 || key.rfind("row:", 0) == 0) {
|
||||
const bool by_id = key[0] == 'i';
|
||||
const int n = number(by_id ? 3 : 4);
|
||||
for (size_t i = 0; i < players.size(); ++i)
|
||||
if ((by_id ? players[i].id : players[i].row) == n) return i;
|
||||
fail("E_BAD_ARGUMENT", "no player " + reference + " in this list");
|
||||
}
|
||||
const std::string wanted = fold(reference);
|
||||
std::vector<size_t> exact, partial;
|
||||
for (size_t i = 0; i < players.size(); ++i) {
|
||||
const std::string name = fold(players[i].name);
|
||||
if (name == wanted) exact.push_back(i);
|
||||
else if (name.find(wanted) != std::string::npos) partial.push_back(i);
|
||||
}
|
||||
const auto& found = exact.empty() ? partial : exact;
|
||||
if (found.size() == 1) return found.front();
|
||||
if (found.empty()) fail("E_BAD_ARGUMENT", "no player named \"" + reference + "\" in this list");
|
||||
std::string candidates;
|
||||
for (size_t i = 0; i < found.size() && i < 8; ++i)
|
||||
candidates += (i ? ", " : "") + players[found[i]].name + " = id:" + std::to_string(players[found[i]].id);
|
||||
fail("E_AMBIGUOUS", "\"" + reference + "\" fits several players: " + candidates);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
namespace {
|
||||
|
||||
const char* class_name(char cls) {
|
||||
switch (cls) {
|
||||
case '#': return "status";
|
||||
case '>': return "option";
|
||||
case '|': return "table";
|
||||
case '+': return "ok";
|
||||
case '!': return "error";
|
||||
case '?': return "question";
|
||||
case 'i': return "info";
|
||||
case '~': return "event";
|
||||
case 'c': return "chat";
|
||||
default: return "other";
|
||||
}
|
||||
}
|
||||
|
||||
// The type part of a parameter: "1..5", "bool", "string", "enum(a,b)".
|
||||
std::string param_type(const Param& p) {
|
||||
switch (p.type) {
|
||||
case Param::Type::integer: return std::to_string(p.min) + ".." + std::to_string(p.max);
|
||||
case Param::Type::boolean: return "bool";
|
||||
case Param::Type::text: return p.max > 0 ? "string(max " + std::to_string(p.max) + ")" : "string";
|
||||
case Param::Type::choice: {
|
||||
std::string s = "enum(";
|
||||
for (size_t i = 0; i < p.choices.size(); ++i) s += (i ? "," : "") + p.choices[i];
|
||||
return s + ")";
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// A parameter in a signature: "name:type", optional ones in [brackets].
|
||||
std::string param_text(const Param& p) {
|
||||
if (!p.display.empty()) return p.display;
|
||||
const std::string s = p.name + ":" + (p.type == Param::Type::text ? "string" : param_type(p));
|
||||
return p.optional ? "[" + s + "]" : s;
|
||||
}
|
||||
|
||||
// The index of an enum argument: a name of the list (canonical comparison) or its number.
|
||||
int choice_index(const Param& p, const Arg& a) {
|
||||
for (size_t i = 0; i < p.choices.size(); ++i)
|
||||
if (canonical(p.choices[i]) == canonical(a.text)) return int(i);
|
||||
if (const auto n = to_int(a); n && *n >= 0 && size_t(*n) < p.choices.size()) return int(*n);
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t edit_distance(const std::string& a, const std::string& b) {
|
||||
std::vector<size_t> row(b.size() + 1);
|
||||
for (size_t j = 0; j <= b.size(); ++j) row[j] = j;
|
||||
for (size_t i = 1; i <= a.size(); ++i) {
|
||||
size_t diagonal = row[0];
|
||||
row[0] = i;
|
||||
for (size_t j = 1; j <= b.size(); ++j) {
|
||||
const size_t up = row[j];
|
||||
row[j] = std::min({row[j] + 1, row[j - 1] + 1, diagonal + (a[i - 1] == b[j - 1] ? 0 : 1)});
|
||||
diagonal = up;
|
||||
}
|
||||
}
|
||||
return row[b.size()];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
long long Console::Values::integer(const std::string& name, long long fallback) const {
|
||||
const auto it = args.find(canonical(name));
|
||||
return it == args.end() ? fallback : *to_int(it->second);
|
||||
}
|
||||
bool Console::Values::boolean(const std::string& name, bool fallback) const {
|
||||
const auto it = args.find(canonical(name));
|
||||
return it == args.end() ? fallback : *to_bool(it->second);
|
||||
}
|
||||
std::string Console::Values::text(const std::string& name, std::string fallback) const {
|
||||
const auto it = args.find(canonical(name));
|
||||
return it == args.end() ? fallback : it->second.text;
|
||||
}
|
||||
int Console::Values::choice(const std::string& name) const {
|
||||
const auto it = args.find(canonical(name));
|
||||
if (it == args.end() || !spec) return -1;
|
||||
for (const Param& p : spec->params)
|
||||
if (canonical(p.name) == canonical(name)) return choice_index(p, it->second);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
Console::Console(Options options, std::function<void(const std::string&)> write)
|
||||
: options_(std::move(options)), write_(std::move(write)) {
|
||||
texts_ = load_textd(ui::asset_path(options_.data, "TEXTD.BLK"));
|
||||
exe_ = load_le(ui::asset_path(options_.data, "BMH.exe"));
|
||||
// The program start up to the options dialog (InitializeCareer) - as the SDL app does it.
|
||||
session_ = std::make_unique<app::CareerSession>(options_.data, options_.seed);
|
||||
install_hooks();
|
||||
register_global_commands();
|
||||
register_start_commands();
|
||||
register_file_commands();
|
||||
register_desk_commands();
|
||||
register_table_commands();
|
||||
register_club_commands();
|
||||
register_money_commands();
|
||||
register_office_commands();
|
||||
register_squad_commands();
|
||||
register_transfer_commands();
|
||||
register_info_commands();
|
||||
register_match_commands();
|
||||
register_friendly_commands();
|
||||
register_reschedule_commands();
|
||||
register_balance_commands();
|
||||
register_environment_commands();
|
||||
register_state_commands();
|
||||
register_advice_commands();
|
||||
}
|
||||
|
||||
// ~Console is in windows_match.cpp, where the engine thread (EngineRun) is complete.
|
||||
|
||||
std::string Console::text(int index) const {
|
||||
if (index < 0 || size_t(index) >= texts_.strings.size()) return {};
|
||||
std::string s = utf8(texts_.strings[size_t(index)]);
|
||||
// dialog markers at the start steer the original's dialog mode (09-texte 1.6)
|
||||
while (!s.empty() && (s.rfind("\xC2\xA7", 0) == 0 || s.rfind("\xC2\xBA", 0) == 0)) s.erase(0, 2);
|
||||
// padding for the screen layout is no content
|
||||
while (!s.empty() && s.back() == ' ') s.pop_back();
|
||||
while (!s.empty() && s.front() == ' ') s.erase(0, 1);
|
||||
return s;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// registry
|
||||
|
||||
void Console::add(Spec spec, Handler handler) {
|
||||
handlers_[spec.window + "/" + canonical(spec.name)] = std::move(handler);
|
||||
specs_.push_back(std::move(spec));
|
||||
}
|
||||
|
||||
const Spec* Console::find(std::string_view window, std::string_view key) const {
|
||||
for (const Spec& s : specs_)
|
||||
if (s.window == window && canonical(s.name) == key) return &s;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Console::register_global_commands() {
|
||||
// --- global commands, valid in every window (01-grundlagen 9) ----------------------
|
||||
Param list_param = detail::text("command", 0, true);
|
||||
list_param.display = "[command:string|all]";
|
||||
add({"*", "ListOptions", {list_param}, "commands possible here; ListOptions(all) also shows locked ones", false},
|
||||
[this](const Values& v) {
|
||||
const std::string which = v.text("command");
|
||||
if (!which.empty() && canonical(which) != "all") {
|
||||
const Spec* spec = find(window_, canonical(which));
|
||||
if (!spec) spec = find("*", canonical(which));
|
||||
if (!spec) fail("E_UNKNOWN_COMMAND", which + " is not a command of " + window_);
|
||||
emit('>', option_line(*spec));
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
for (const Param& p : spec->params) rows.push_back({p.name, param_type(p), p.optional ? "optional" : "required"});
|
||||
if (!rows.empty()) emit_table({"Parameter", "Type", "Use"}, rows);
|
||||
return;
|
||||
}
|
||||
const bool all = !which.empty();
|
||||
for (const Spec* spec : window_specs(all)) {
|
||||
std::string line = option_line(*spec);
|
||||
if (canonical(spec->name) == "answer" && !question_) line += " [locked: no open question]";
|
||||
emit('>', line);
|
||||
// the desk's icons: one line per window Open() reaches (02-fenster 4 and 6)
|
||||
if (window_ == "Desktop" && canonical(spec->name) == "open" && career_) {
|
||||
ui::DeskState d = desk();
|
||||
std::sort(d.items.begin(), d.items.end(), [](const auto& a, const auto& b) { return a.kind < b.kind; });
|
||||
for (const auto& item : d.items) {
|
||||
if (item.kind >= 30 || item.kind == 12) continue; // widgets; 12 = Kickoff
|
||||
if (item.disabled && !all) continue;
|
||||
std::string target = " Open(" + menu_window(item.kind) + ")";
|
||||
if (target.size() < 48) target.resize(48, ' ');
|
||||
target += " - menu " + std::to_string(item.kind);
|
||||
if (item.disabled) target += " [locked: mode]";
|
||||
emit('>', target);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
add({"*", "GoBack", {}, "right mouse button: one level back, otherwise nothing", false},
|
||||
[this](const Values& v) {
|
||||
if (question_) {
|
||||
// a question's right mouse button: its default answer (01-grundlagen 2.4) - only
|
||||
// from the player it belongs to, and said aloud (it may decline a sale)
|
||||
if (v.player && v.player != question_->player)
|
||||
fail("E_NOT_YOUR_TURN", "the question belongs to player " + std::to_string(question_->player));
|
||||
Question q = std::move(*question_);
|
||||
question_.reset();
|
||||
emit('+', "Q" + std::to_string(q.id) + " answered: " + q.default_option + " (GoBack = default answer)");
|
||||
q.on_answer(q.default_option);
|
||||
return;
|
||||
}
|
||||
if (window_ == "NewGame") new_game_continue(); // exception: right mouse = next (H1 S. 13)
|
||||
else if (const auto it = closers_.find(window_); it != closers_.end()) it->second();
|
||||
else if (!close_window()) emit('+', "nothing to go back to");
|
||||
});
|
||||
Param chat_to = integer("to", 0, 4, true);
|
||||
add({"*", "Chat", {chat_to, detail::text("text", 200)}, "message to all, or to one player (0 = only the log)", false},
|
||||
[this](const Values& v) {
|
||||
const std::string message = v.text("text");
|
||||
if (message.empty()) fail("E_BAD_ARGUMENT", "text must not be empty");
|
||||
const int from = v.player ? v.player : (player_ ? player_ : 1);
|
||||
const int to = v.has("to") ? int(v.integer("to")) : -1;
|
||||
chat_.push_back({from, to, message});
|
||||
const std::string target = to < 0 ? "All" : to == 0 ? "Log" : "P" + std::to_string(to);
|
||||
emit('c', "[P" + std::to_string(from) + " -> " + target + "] " + message);
|
||||
});
|
||||
add({"*", "ChatLog", {integer("count", 1, 1000, true)}, "the last chat messages", false}, [this](const Values& v) {
|
||||
const size_t count = size_t(v.integer("count", 20));
|
||||
std::vector<std::vector<std::string>> rows;
|
||||
const size_t first = chat_.size() > count ? chat_.size() - count : 0;
|
||||
for (size_t i = first; i < chat_.size(); ++i) {
|
||||
const ChatEntry& e = chat_[i];
|
||||
rows.push_back({std::to_string(i + 1), "P" + std::to_string(e.from),
|
||||
e.to < 0 ? "All" : e.to == 0 ? "Log" : "P" + std::to_string(e.to), e.text});
|
||||
}
|
||||
emit_table({"#", "From", "To", "Text"}, rows);
|
||||
});
|
||||
Param answer_option = detail::text("option");
|
||||
answer_option.display = "option:enum";
|
||||
Param answer_id = detail::text("id");
|
||||
answer_id.display = "id:int"; // 2 or Q2, as the question line shows it
|
||||
add({"*", "Answer", {answer_id, answer_option}, "answer the open question", false},
|
||||
[this](const Values& v) {
|
||||
if (!question_) fail("E_BAD_ARGUMENT", "there is no open question");
|
||||
std::string id_text = v.text("id");
|
||||
if (!id_text.empty() && (id_text[0] == 'Q' || id_text[0] == 'q')) id_text.erase(0, 1);
|
||||
Arg id_arg;
|
||||
id_arg.text = id_text;
|
||||
const auto id = to_int(id_arg);
|
||||
if (!id) fail("E_BAD_ARGUMENT", "id must be the question number, e.g. 2 or Q2");
|
||||
if (*id != question_->id) fail("E_BAD_ARGUMENT", "the open question is Q" + std::to_string(question_->id));
|
||||
if (v.player && v.player != question_->player)
|
||||
fail("E_NOT_YOUR_TURN", "the question belongs to player " + std::to_string(question_->player));
|
||||
Arg arg;
|
||||
arg.text = v.text("option");
|
||||
std::string chosen;
|
||||
for (const std::string& o : question_->options)
|
||||
if (canonical(o) == canonical(arg.text)) chosen = o;
|
||||
if (chosen.empty() && question_->options == std::vector<std::string>{"Yes", "No"})
|
||||
if (const auto b = to_bool(arg)) chosen = *b ? "Yes" : "No";
|
||||
if (chosen.empty())
|
||||
if (const auto n = to_int(arg); n && *n >= 1 && size_t(*n) <= question_->options.size())
|
||||
chosen = question_->options[size_t(*n - 1)];
|
||||
if (chosen.empty()) fail("E_BAD_ARGUMENT", "option must be one of the question's options");
|
||||
Question q = std::move(*question_);
|
||||
question_.reset();
|
||||
emit('+', "Q" + std::to_string(q.id) + " answered: " + chosen); // (some answers print nothing else)
|
||||
q.on_answer(chosen);
|
||||
});
|
||||
add({"*", "Status", {}, "window, player and a short overview", false}, [this](const Values& v) {
|
||||
// a seat not on turn sees the desk of the manager on turn: say so, so it is not read
|
||||
// as its own club
|
||||
if (v.player && player_ && v.player != player_)
|
||||
emit('+', "you are player " + std::to_string(v.player) + "; player " + std::to_string(player_) +
|
||||
" is on turn - the overview below is his");
|
||||
if (run_) {
|
||||
emit('+', match_status());
|
||||
return;
|
||||
}
|
||||
if (!career_) {
|
||||
emit('+', "options: " + options_text());
|
||||
} else {
|
||||
const ui::DeskState d = desk();
|
||||
emit('+', utf8(d.manager_name) + " | " + utf8(d.club_name) + " | " +
|
||||
date_text(d.date.day, d.date.month, d.date.year) + " | balance " + money(d.balance));
|
||||
}
|
||||
if (question_) emit('+', "open question: Q" + std::to_string(question_->id));
|
||||
});
|
||||
add({"*", "Help", {detail::text("command", 0, true)}, "command reference (all windows)", false}, [this](const Values& v) {
|
||||
const std::string which = v.text("command");
|
||||
for (const Spec& spec : specs_) {
|
||||
if (!which.empty() && canonical(spec.name) != canonical(which)) continue;
|
||||
emit('>', "[" + spec.window + "] " + option_line(spec));
|
||||
}
|
||||
if (!which.empty() && std::none_of(specs_.begin(), specs_.end(),
|
||||
[&](const Spec& s) { return canonical(s.name) == canonical(which); }))
|
||||
fail("E_UNKNOWN_COMMAND", which + " is no command");
|
||||
});
|
||||
add({"*", "Quit", {boolean("force", true)}, "end the session (asks first during a game)", false},
|
||||
[this](const Values& v) {
|
||||
auto end = [this] {
|
||||
if (run_) stop_matchday();
|
||||
ended_ = true;
|
||||
emit('+', "session ended");
|
||||
};
|
||||
if (question_ && !v.boolean("force"))
|
||||
fail("E_PENDING_QUESTION", "answer Q" + std::to_string(question_->id) + " first (or Quit(force=true))");
|
||||
if (!career_ || v.boolean("force")) {
|
||||
end();
|
||||
return;
|
||||
}
|
||||
// the plug on the desk asks first (H2 S. 24); the question is the console's own
|
||||
// text: the original asks with a picture, not with a TEXTD text
|
||||
ask("Quit the game? Unsaved progress is lost.", {"Yes", "No"}, "No", [this, end](const std::string& answer) {
|
||||
if (answer == "Yes") end();
|
||||
else emit('+', "quit cancelled");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// input
|
||||
|
||||
void Console::start() {
|
||||
last_block_.clear();
|
||||
last_output_.clear();
|
||||
flush_status();
|
||||
}
|
||||
|
||||
bool Console::feed(std::string_view line) {
|
||||
if (ended_) return false;
|
||||
switch (classify_line(line)) {
|
||||
case LineKind::skip: break;
|
||||
case LineKind::clear: pending_.clear(); break;
|
||||
case LineKind::command: pending_.emplace_back(line); break;
|
||||
case LineKind::go: execute_block(); break;
|
||||
}
|
||||
return !ended_;
|
||||
}
|
||||
|
||||
void Console::execute_block() {
|
||||
last_block_ = std::move(pending_);
|
||||
pending_.clear();
|
||||
last_output_.clear();
|
||||
if (last_block_.empty()) {
|
||||
emit('+', "nothing to do");
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < last_block_.size() && !ended_; ++i) {
|
||||
try {
|
||||
Command cmd;
|
||||
try {
|
||||
cmd = parse_command(last_block_[i]);
|
||||
} catch (const ParseError& e) {
|
||||
fail("E_BAD_ARGUMENT", std::string("syntax: ") + e.what());
|
||||
}
|
||||
try {
|
||||
execute(cmd);
|
||||
} catch (const CliError&) {
|
||||
throw;
|
||||
} catch (const std::exception& e) {
|
||||
// an engine exception is a defect of the program, never of the input
|
||||
fail("E_INTERNAL", e.what());
|
||||
}
|
||||
} catch (const CliError& e) {
|
||||
emit('!', e.code + ": " + e.message + (e.text_key.empty() ? "" : " [textKey: " + e.text_key + "]"));
|
||||
const size_t skipped = last_block_.size() - i - 1;
|
||||
if (skipped) emit('!', "E_BLOCK_ABORTED: " + std::to_string(skipped) + " command" + (skipped == 1 ? "" : "s") + " skipped");
|
||||
break;
|
||||
}
|
||||
}
|
||||
flush_status();
|
||||
}
|
||||
|
||||
void Console::execute(const Command& cmd) {
|
||||
const Spec* spec = find(window_, cmd.key);
|
||||
if (!spec) spec = find("*", cmd.key);
|
||||
if (!spec) {
|
||||
// Run/Step outside a match: with several managers the match day starts only after the
|
||||
// last one's Kickoff (each Kickoff passes the turn) - agents sent Run here again and
|
||||
// again in the learning session, so the error says what to do instead
|
||||
if ((cmd.key == "run" || cmd.key == "step") && window_ != "Match")
|
||||
fail("E_NOT_IN_WINDOW", "no match is running - the match day starts after every manager's Kickoff; "
|
||||
"WaitTurn (or Status) shows when the window is Match");
|
||||
for (const Spec& s : specs_)
|
||||
if (canonical(s.name) == cmd.key) fail("E_NOT_IN_WINDOW", s.name + " is only available in " + s.window);
|
||||
std::string best;
|
||||
size_t best_distance = 1000;
|
||||
for (const Spec& s : specs_) {
|
||||
const size_t d = edit_distance(cmd.key, canonical(s.name));
|
||||
if (d < best_distance) best_distance = d, best = s.name;
|
||||
}
|
||||
fail("E_UNKNOWN_COMMAND", cmd.name + " is unknown" +
|
||||
(best_distance <= std::max<size_t>(2, cmd.key.size() / 3) ? " (did you mean " + best + "?)" : ""));
|
||||
}
|
||||
// An engine question owns the paused kickoff. Some navigation commands are
|
||||
// changes=false yet prepare Native state on entry (notably Open(Lineup)).
|
||||
// Only explicit observers and the current question's answer may run here.
|
||||
const bool engine_question_observer =
|
||||
spec->window == "*" &&
|
||||
(cmd.key == "answer" || cmd.key == "goback" || cmd.key == "status" ||
|
||||
cmd.key == "help" || cmd.key == "listoptions" || cmd.key == "chat" || cmd.key == "chatlog" ||
|
||||
(cmd.key == "quit" && loan_return_modal_active()));
|
||||
const bool engine_question_desk_observer =
|
||||
spec->window == "Desktop" && (cmd.key == "showdate" || cmd.key == "showopponent");
|
||||
if (question_ && (spec->changes ||
|
||||
(run_ && !engine_question_observer && !engine_question_desk_observer)))
|
||||
fail("E_PENDING_QUESTION", "answer Q" + std::to_string(question_->id) + " first");
|
||||
if (loan_return_offer_active() && !engine_question_observer && spec->window != "Transfer.Negotiate")
|
||||
fail("E_MODE_LOCKED", "finish the loan-return negotiation first");
|
||||
if (spec->changes && cmd.player && player_ && cmd.player != player_)
|
||||
fail("E_NOT_YOUR_TURN", "current player is " + std::to_string(player_));
|
||||
if (loan_return_modal_active() && cmd.player && cmd.player != player_ &&
|
||||
(cmd.key == "goback" || cmd.key == "quit"))
|
||||
fail("E_NOT_YOUR_TURN", "the loan-return modal belongs to player " + std::to_string(player_));
|
||||
// A player who is not on turn shares the screen with the active one: he may use the
|
||||
// commands of every window (Status, Help, Chat, Answer ...) but not those of the open
|
||||
// window, which would page or open things under the active player's hands.
|
||||
if (cmd.player && player_ && cmd.player != player_ && spec->window != "*")
|
||||
fail("E_NOT_YOUR_TURN", "current player is " + std::to_string(player_) + " (WaitTurn waits for your turn)");
|
||||
Values values = bind(*spec, cmd);
|
||||
handlers_.at(spec->window + "/" + canonical(spec->name))(values);
|
||||
succeeded_.insert(spec->window + "/" + spec->name);
|
||||
}
|
||||
|
||||
Console::Values Console::bind(const Spec& spec, const Command& cmd) const {
|
||||
Values values;
|
||||
values.spec = &spec;
|
||||
values.player = cmd.player;
|
||||
std::vector<const Arg*> positional;
|
||||
for (const Arg& a : cmd.args)
|
||||
if (a.name.empty()) positional.push_back(&a);
|
||||
const size_t required = size_t(std::count_if(spec.params.begin(), spec.params.end(), [](const Param& p) { return !p.optional; }));
|
||||
if (positional.size() > spec.params.size())
|
||||
fail("E_BAD_ARGUMENT", spec.name + " takes at most " + std::to_string(spec.params.size()) + " arguments");
|
||||
// positional arguments fill the required parameters; the surplus fills optional ones
|
||||
// from the left (Chat("x") = text, Chat(2, "x") = to + text)
|
||||
// "fee:1500000" looks like the name:type of ListOptions but is a positional text; say how
|
||||
// named arguments are written (references like id:7, club:3 go to text parameters)
|
||||
for (const Arg* a : positional) {
|
||||
const size_t colon = a->text.find(':');
|
||||
if (colon == std::string::npos || colon == 0) continue;
|
||||
const std::string head = canonical(a->text.substr(0, colon));
|
||||
if (head == canonical("id") || head == canonical("row")) continue;
|
||||
for (const Param& p : spec.params)
|
||||
if (canonical(p.name) == head && p.type != Param::Type::text) // texts take references like club:3
|
||||
fail("E_BAD_ARGUMENT", "named arguments are written name=value, e.g. " + p.name + "=" + a->text.substr(colon + 1));
|
||||
}
|
||||
size_t optional_slots = positional.size() > required ? positional.size() - required : 0;
|
||||
size_t next = 0;
|
||||
for (const Param& p : spec.params) {
|
||||
if (next >= positional.size()) break;
|
||||
if (p.optional) {
|
||||
if (optional_slots == 0) continue;
|
||||
--optional_slots;
|
||||
}
|
||||
values.args[canonical(p.name)] = *positional[next++];
|
||||
}
|
||||
for (const Arg& a : cmd.args) {
|
||||
if (a.name.empty()) continue;
|
||||
const auto it = std::find_if(spec.params.begin(), spec.params.end(), [&](const Param& p) { return canonical(p.name) == a.name; });
|
||||
if (it == spec.params.end()) fail("E_BAD_ARGUMENT", spec.name + " has no parameter " + a.name);
|
||||
if (values.args.count(a.name)) fail("E_BAD_ARGUMENT", "parameter " + it->name + " given twice");
|
||||
values.args[a.name] = a;
|
||||
}
|
||||
for (const Param& p : spec.params) {
|
||||
const auto it = values.args.find(canonical(p.name));
|
||||
if (it == values.args.end()) {
|
||||
if (!p.optional) fail("E_BAD_ARGUMENT", spec.name + " needs " + param_text(p));
|
||||
continue;
|
||||
}
|
||||
const Arg& a = it->second;
|
||||
switch (p.type) {
|
||||
case Param::Type::integer: {
|
||||
const auto n = to_int(a);
|
||||
if (!n || *n < p.min || *n > p.max)
|
||||
fail("E_BAD_ARGUMENT", p.name + " must be " + std::to_string(p.min) + ".." + std::to_string(p.max));
|
||||
break;
|
||||
}
|
||||
case Param::Type::boolean:
|
||||
if (!to_bool(a)) fail("E_BAD_ARGUMENT", p.name + " must be true or false");
|
||||
break;
|
||||
case Param::Type::text:
|
||||
if (p.max > 0 && a.text.size() > size_t(p.max))
|
||||
fail("E_BAD_ARGUMENT", p.name + " is longer than " + std::to_string(p.max) + " characters");
|
||||
break;
|
||||
case Param::Type::choice:
|
||||
if (choice_index(p, a) < 0) fail("E_BAD_ARGUMENT", p.name + " must be one of " + param_type(p));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// output
|
||||
|
||||
void Console::emit(char cls, const std::string& text, Json data) {
|
||||
if (cls != '#') flush_status();
|
||||
std::string line;
|
||||
if (options_.json) {
|
||||
Json::Object o;
|
||||
o["class"] = class_name(cls);
|
||||
o["window"] = window_;
|
||||
o["player"] = player_ ? Json(player_) : Json("All");
|
||||
o["text"] = text;
|
||||
if (!std::holds_alternative<std::nullptr_t>(data.value)) o["data"] = std::move(data);
|
||||
line = dump_json(Json(std::move(o)));
|
||||
} else {
|
||||
line = std::string(1, cls) + " " + text;
|
||||
}
|
||||
last_output_.push_back(line);
|
||||
if (observer_) observer_({cls, player_, text, line});
|
||||
write_(line);
|
||||
}
|
||||
|
||||
void Console::emit_table(const std::vector<std::string>& header, const std::vector<std::vector<std::string>>& rows) {
|
||||
auto row_text = [](const std::vector<std::string>& cells) {
|
||||
std::string s = "|";
|
||||
for (const std::string& c : cells) s += " " + c + " |";
|
||||
return s.substr(2); // emit adds "| "
|
||||
};
|
||||
auto cells_json = [](const std::vector<std::string>& cells, bool head) {
|
||||
Json::Array a;
|
||||
for (const std::string& c : cells) a.emplace_back(c);
|
||||
return Json(Json::Object{{"header", head}, {"cells", Json(std::move(a))}});
|
||||
};
|
||||
// With --json each row also carries a record keyed by the column names, the cells typed:
|
||||
// whole numbers and the references id:/row:/club: as numbers, "-" and "" as null, the
|
||||
// rest as text - what a graphical client needs without parsing the table (stage 2.5).
|
||||
auto typed = [](const std::string& cell) -> Json {
|
||||
if (cell.empty() || cell == "-") return Json(nullptr);
|
||||
std::string digits = cell;
|
||||
for (const char* prefix : {"id:", "row:", "club:"})
|
||||
if (digits.rfind(prefix, 0) == 0) digits = digits.substr(std::string(prefix).size());
|
||||
const bool negative = !digits.empty() && digits[0] == '-';
|
||||
const size_t from = negative ? 1 : 0;
|
||||
if (digits.size() > from && digits.size() - from <= 18 &&
|
||||
digits.find_first_not_of("0123456789", from) == std::string::npos)
|
||||
return Json(std::int64_t(std::stoll(digits)));
|
||||
return Json(cell);
|
||||
};
|
||||
emit('|', row_text(header), cells_json(header, true));
|
||||
for (const auto& r : rows) {
|
||||
Json data = cells_json(r, false);
|
||||
if (options_.json) {
|
||||
Json::Object record;
|
||||
for (size_t i = 0; i < r.size(); ++i)
|
||||
record[i < header.size() && !header[i].empty() ? header[i] : "c" + std::to_string(i + 1)] = typed(r[i]);
|
||||
data.object()->insert_or_assign("record", Json(std::move(record)));
|
||||
}
|
||||
emit('|', row_text(r), std::move(data));
|
||||
}
|
||||
}
|
||||
|
||||
void Console::flush_status() {
|
||||
if (window_ == printed_window_ && player_ == printed_player_) return;
|
||||
printed_window_ = window_;
|
||||
printed_player_ = player_;
|
||||
emit('#', "Window: " + window_);
|
||||
emit('#', "Player: " + (player_ ? std::to_string(player_) : std::string("All")));
|
||||
}
|
||||
|
||||
std::string Console::option_line(const Spec& spec) const {
|
||||
std::string sig = spec.name + "(";
|
||||
for (size_t i = 0; i < spec.params.size(); ++i) sig += (i ? ", " : "") + param_text(spec.params[i]);
|
||||
sig += ")";
|
||||
if (spec.description.empty()) return sig;
|
||||
if (sig.size() < 48) sig.resize(48, ' ');
|
||||
return sig + " - " + spec.description;
|
||||
}
|
||||
|
||||
std::vector<const Spec*> Console::window_specs(bool include_locked) const {
|
||||
std::vector<const Spec*> result;
|
||||
for (const Spec& s : specs_)
|
||||
if (s.window == window_) result.push_back(&s);
|
||||
for (const Spec& s : specs_) {
|
||||
if (s.window != "*") continue;
|
||||
if (canonical(s.name) == "answer" && !question_ && !include_locked) continue;
|
||||
result.push_back(&s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// windows and questions
|
||||
|
||||
void Console::set_window(std::string window, int player) {
|
||||
window_ = std::move(window);
|
||||
player_ = player;
|
||||
back_.clear();
|
||||
}
|
||||
|
||||
void Console::open_window(std::string window) {
|
||||
back_.push_back(window_);
|
||||
window_ = std::move(window);
|
||||
}
|
||||
|
||||
bool Console::close_window() {
|
||||
if (back_.empty()) {
|
||||
// the start windows have a fixed way back (02-fenster 3)
|
||||
if (window_ == "NewGame.LoadGame" || (window_ == "NewGame.Select" && confirmed_.empty())) {
|
||||
set_window("NewGame", 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
window_ = back_.back();
|
||||
back_.pop_back();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Console::ask(std::string text, std::vector<std::string> options, std::string default_option,
|
||||
std::function<void(const std::string&)> on_answer, std::string text_key) {
|
||||
Question q;
|
||||
q.id = next_question_++;
|
||||
q.player = player_ ? player_ : 1;
|
||||
q.text = std::move(text);
|
||||
q.options = std::move(options);
|
||||
q.default_option = std::move(default_option);
|
||||
q.on_answer = std::move(on_answer);
|
||||
std::string opts;
|
||||
for (size_t i = 0; i < q.options.size(); ++i) opts += (i ? " | " : "") + q.options[i];
|
||||
// --json: the question as data (id, the player it belongs to, the options and the answer
|
||||
// GoBack gives), so a client can show a dialog without parsing the line
|
||||
Json data = nullptr;
|
||||
if (options_.json) {
|
||||
Json::Array options;
|
||||
for (const auto& o : q.options) options.emplace_back(o);
|
||||
data = Json(Json::Object{{"id", q.id}, {"player", q.player}, {"text", q.text}, {"options", Json(std::move(options))},
|
||||
{"default", q.default_option}, {"text_key", text_key}});
|
||||
}
|
||||
emit('?', "Q" + std::to_string(q.id) + " \"" + q.text + "\" options: " + opts +
|
||||
(text_key.empty() ? "" : " [textKey: " + text_key + "]"),
|
||||
std::move(data));
|
||||
question_ = std::move(q);
|
||||
}
|
||||
|
||||
} // namespace bmh::cli::console
|
||||
@@ -0,0 +1,327 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// The console language of openbmh_cli (docs/CLI_CONCEPT):
|
||||
// - input in blocks of command lines, executed by a line "go." (01-grundlagen 1.1)
|
||||
// - output lines with a class character (# status, > option, | table, + ok, ! error,
|
||||
// ? question, i info, ~ event, c chat), the status lines "# Window:" / "# Player:" printed
|
||||
// whenever window or player changed (2.2); --json gives one JSON object per line
|
||||
// - global commands ListOptions, GoBack, Chat, ChatLog, Answer, Status, Help, Quit (9)
|
||||
//
|
||||
// Stage 0 (console.cpp, windows_start.cpp): options screen NewGame, load browser.
|
||||
// Stage 1: manager selection NewGame.Select (+ Confirm), the info sequence after the last
|
||||
// manager, Desktop with its displays, Open/Key, Kickoff (time "instant"), the file windows
|
||||
// LoadGame/SaveGame, Mailbox, LeagueTable and Fixtures (windows_desk.cpp, windows_tables.cpp).
|
||||
//
|
||||
// The console owns no game logic: everything that changes the game goes through
|
||||
// app::CareerSession (including its staged Source modal callbacks), like the SDL app. It never
|
||||
// draws random numbers itself; where the original draws numbers when a window opens (the
|
||||
// fixtures window), the console opens it through the same engine call.
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "app/career_session.hpp"
|
||||
#include "game/balance_plan.hpp"
|
||||
#include "game/bank_credit.hpp"
|
||||
#include "game/desk_actions.hpp"
|
||||
#include "cli/console/parser.hpp"
|
||||
#include "cli/json.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "ui/league_pairings.hpp"
|
||||
#include "ui/club_info.hpp"
|
||||
#include "ui/mailbox_state.hpp"
|
||||
#include "ui/outgoing_transfer.hpp"
|
||||
#include "ui/preparation.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
|
||||
namespace bmh::cli::console {
|
||||
|
||||
// How a matchday runs (01-grundlagen 7, 07-spieltag 3.2): stepped = the clock moves only on
|
||||
// Match.Step / Match.Run and the managers can intervene; instant = the day runs through and
|
||||
// only the results are printed.
|
||||
enum class TimeMode { stepped, instant };
|
||||
|
||||
struct Options {
|
||||
std::filesystem::path data; // the BMH directory (data files)
|
||||
std::filesystem::path save_directory; // where LoadGame/Save look; empty = data
|
||||
std::uint32_t seed = 1; // Watcom seed of the session (determinism)
|
||||
bool json = false; // one JSON object per output line
|
||||
TimeMode time = TimeMode::stepped;
|
||||
};
|
||||
|
||||
// A command's parameter as ListOptions/Help show it and the argument check uses it.
|
||||
struct Param {
|
||||
enum class Type { integer, boolean, text, choice };
|
||||
std::string name;
|
||||
Type type = Type::integer;
|
||||
long long min = 0, max = 0; // integer range; text: max length (0 = none)
|
||||
bool optional = false;
|
||||
std::vector<std::string> choices; // choice: allowed names (index = number)
|
||||
std::string display; // overrides the generated "name:type" text
|
||||
};
|
||||
|
||||
struct Spec {
|
||||
std::string window; // "*" = every window
|
||||
std::string name; // canonical display name, e.g. "ListOptions"
|
||||
std::vector<Param> params;
|
||||
std::string description;
|
||||
bool changes = false; // changes the game: only the active player
|
||||
};
|
||||
|
||||
class Console {
|
||||
public:
|
||||
// `write` receives every finished output line (without the newline).
|
||||
Console(Options options, std::function<void(const std::string&)> write);
|
||||
~Console();
|
||||
|
||||
// Prints the first status lines. Call once before feeding input.
|
||||
void start();
|
||||
// One line of input. Command lines are collected until "go.". Returns false once the
|
||||
// session has ended (Quit); later input is ignored.
|
||||
bool feed(std::string_view line);
|
||||
bool ended() const { return ended_; }
|
||||
// Whose turn it is (1-4, 0 = All during a live match), the open window and the player an
|
||||
// open question belongs to (0 = none): what the multi-seat mailbox (--seats) waits on.
|
||||
int active_player() const { return player_; }
|
||||
const std::string& window() const { return window_; }
|
||||
int question_player() const { return question_ ? question_->player : 0; }
|
||||
// Every finished output line with its meaning, independent of text or JSON format: the
|
||||
// class character (#, |, +, !, ?, i, ~, c, >), the player it belongs to (0 = All), the
|
||||
// plain text and the formatted line as written. The seat hub (several clients in one game)
|
||||
// routes lines by these instead of parsing them.
|
||||
struct LineInfo {
|
||||
char cls = 0;
|
||||
int player = 0;
|
||||
std::string text;
|
||||
std::string line;
|
||||
};
|
||||
void set_line_observer(std::function<void(const LineInfo&)> observer) { observer_ = std::move(observer); }
|
||||
|
||||
// The input lines of the last executed block and its output, for --log / --replay.
|
||||
// After start(): no input, the start output.
|
||||
const std::vector<std::string>& last_block() const { return last_block_; }
|
||||
const std::vector<std::string>& last_output() const { return last_output_; }
|
||||
|
||||
// All registered commands (for tests against docs/CLI_CONCEPT/commands.csv).
|
||||
const std::vector<Spec>& specs() const { return specs_; }
|
||||
// "window/Name" of every command that ran without an error (coverage, 10-agenten 3).
|
||||
const std::set<std::string>& succeeded() const { return succeeded_; }
|
||||
|
||||
// The engine session (tests compare it with season_sim / save files).
|
||||
const app::CareerSession& session() const { return *session_; }
|
||||
|
||||
struct Values; // bound arguments of one call (detail.hpp)
|
||||
|
||||
private:
|
||||
struct Question {
|
||||
int id = 0;
|
||||
int player = 1;
|
||||
std::string text;
|
||||
std::vector<std::string> options;
|
||||
std::string default_option; // the answer GoBack (right mouse button) gives
|
||||
std::function<void(const std::string&)> on_answer;
|
||||
};
|
||||
struct ChatEntry {
|
||||
int from = 0, to = 0;
|
||||
std::string text;
|
||||
};
|
||||
using Handler = std::function<void(const Values&)>;
|
||||
|
||||
// registry (one function per command file)
|
||||
void add(Spec spec, Handler handler);
|
||||
void register_global_commands();
|
||||
void register_start_commands(); // windows_start.cpp
|
||||
void register_file_commands(); // windows_start.cpp: NewGame.LoadGame, LoadGame, SaveGame
|
||||
void register_desk_commands(); // windows_desk.cpp: Desktop, Mailbox
|
||||
void register_table_commands(); // windows_tables.cpp: LeagueTable, Fixtures
|
||||
void register_club_commands(); // windows_club.cpp: Tactics, Training, TrainingCamp
|
||||
void register_money_commands(); // windows_money.cpp: Bank, Stadium, Toto
|
||||
void register_office_commands(); // windows_office.cpp: Advertising, Contracts, Settings
|
||||
void register_squad_commands(); // windows_squad.cpp: Lineup, Lineup.Pitch, PlayerCard
|
||||
void register_transfer_commands(); // windows_transfer.cpp: Transfer, Transfer.Negotiate
|
||||
void register_info_commands(); // windows_info.cpp: TeamInfo, HighScore
|
||||
void register_match_commands(); // windows_match.cpp: Match (stage 4)
|
||||
void register_friendly_commands(); // windows_friendly.cpp: Friendlies (stage 5)
|
||||
void register_reschedule_commands(); // windows_reschedule.cpp: Reschedule (stage 5)
|
||||
void register_balance_commands(); // windows_balance.cpp: Balance (stage 5)
|
||||
void register_environment_commands(); // windows_environment.cpp: Environment (stage 5)
|
||||
void register_state_commands(); // windows_state.cpp: State(view), structured data (stage 2.5)
|
||||
void register_advice_commands(); // windows_state.cpp: Advice, Scoreboard (learning agents)
|
||||
const Spec* find(std::string_view window, std::string_view key) const;
|
||||
|
||||
// execution
|
||||
void execute_block();
|
||||
void execute(const Command& cmd);
|
||||
Values bind(const Spec& spec, const Command& cmd) const;
|
||||
|
||||
// output
|
||||
void emit(char cls, const std::string& text, Json data = nullptr);
|
||||
void emit_table(const std::vector<std::string>& header, const std::vector<std::vector<std::string>>& rows);
|
||||
void flush_status();
|
||||
std::string option_line(const Spec& spec) const;
|
||||
std::vector<const Spec*> window_specs(bool include_locked) const;
|
||||
// A TEXTD text by its index (docs/formats/textd_inventory.csv), as UTF-8.
|
||||
std::string text(int index) const;
|
||||
|
||||
// windows and questions
|
||||
void set_window(std::string window, int player);
|
||||
// Opens a sub window; GoBack returns to the window it was opened from.
|
||||
void open_window(std::string window);
|
||||
// Leaves the current sub window (GoBack). False if there is nothing to go back to.
|
||||
bool close_window();
|
||||
void ask(std::string text, std::vector<std::string> options, std::string default_option,
|
||||
std::function<void(const std::string&)> on_answer, std::string text_key = {});
|
||||
|
||||
// start (windows_start.cpp)
|
||||
std::string options_text() const;
|
||||
void new_game_continue();
|
||||
void begin_selection(int slot);
|
||||
void confirm_selection();
|
||||
void finish_career();
|
||||
void load_game(const std::filesystem::path& path);
|
||||
void save_game(const std::filesystem::path& path, bool overwrite);
|
||||
std::filesystem::path save_directory() const;
|
||||
std::string shown_directory() const;
|
||||
std::filesystem::path browser_file(const std::string& name) const;
|
||||
int resolve_club(const std::string& text) const; // master club index
|
||||
|
||||
// desk (windows_desk.cpp)
|
||||
int active_slot() const;
|
||||
// The desk views (Advice, State) show the manager on turn; a seat that is not on turn
|
||||
// would read another club as its own (learning session, October 2026), so it is refused.
|
||||
void own_view_only(int player, const std::string& command) const;
|
||||
ui::DeskState desk() const;
|
||||
// The views of the action windows (training, bank, ...) of the active manager.
|
||||
ui::PreparationState prep() const;
|
||||
// Runs one engine action of an action window; `ok` is the dispatch result.
|
||||
void require_engine(bool ok, const std::string& what, const std::string& error);
|
||||
void enter_desktop();
|
||||
void open_menu(int menu);
|
||||
void kickoff();
|
||||
void finish_kickoff(const ui::DeskState& before, const TurnAdvanceResult& advanced, const std::string& error);
|
||||
// stage 4 (windows_match.cpp): the kickoff on the engine thread and its pauses
|
||||
void start_matchday(const ui::DeskRequest& request, const ui::DeskState& before);
|
||||
void resume_matchday(); // let the engine run until its next pause or the end
|
||||
void engine_returned(); // the engine waits (minute, question) or has finished
|
||||
void show_match_pause();
|
||||
void stop_matchday(); // abort and join a started day (Quit, destructor)
|
||||
bool loan_return_offer_active() const;
|
||||
bool loan_return_modal_active() const;
|
||||
std::optional<app::CareerSession::TransferOfferEditorDispatch> dispatch_loan_return_offer(
|
||||
const ui::OutgoingTransferRequest&, const HumanBuyerSaleHooks&, std::string&,
|
||||
const app::TransferOfferTeamInfoPresenter&, const app::TransferOfferPlayerInfoPresenter&);
|
||||
void finish_loan_return_offer();
|
||||
std::string match_status() const;
|
||||
struct EngineRun;
|
||||
std::shared_ptr<EngineRun> run_; // shared_ptr: EngineRun is complete only in windows_match.cpp
|
||||
void report_new_mail();
|
||||
void flush_info();
|
||||
// Engine hooks of a new session (cup draws -> Info.CupDraw).
|
||||
void install_hooks();
|
||||
|
||||
// tables (windows_tables.cpp)
|
||||
void show_league_table();
|
||||
void open_fixtures();
|
||||
void show_fixtures();
|
||||
void fixtures_action(LeaguePairingsAction kind, int value = -1);
|
||||
bool quiet_fixtures_ = false; // SetMatchday pages through without printing each page
|
||||
bool squad_view_b_ = false; // Lineup: DATEN-B (age, skills, career numbers) instead of DATEN-A
|
||||
|
||||
Options options_;
|
||||
std::function<void(const std::string&)> write_;
|
||||
std::function<void(const LineInfo&)> observer_;
|
||||
std::vector<Spec> specs_;
|
||||
std::map<std::string, Handler> handlers_; // window + "/" + key
|
||||
// what Open(menu) does for the windows of the command files (menu_kind -> opener)
|
||||
std::map<int, std::function<void()>> openers_;
|
||||
// what GoBack does in windows whose closing is an engine step (Fixtures, Stadium)
|
||||
std::map<std::string, std::function<void()>> closers_;
|
||||
TextDb texts_;
|
||||
LeImage exe_;
|
||||
|
||||
std::unique_ptr<app::CareerSession> session_;
|
||||
uint64_t revision_ = 0; // CareerSession request revision
|
||||
bool career_ = false; // a career is running (after finish or load)
|
||||
ui::SetupOptions setup_;
|
||||
std::string window_ = "NewGame";
|
||||
int player_ = 1; // 1-4, 0 = All
|
||||
std::vector<std::string> back_; // windows GoBack returns to
|
||||
std::string printed_window_;
|
||||
int printed_player_ = -1;
|
||||
std::optional<Question> question_;
|
||||
int next_question_ = 1;
|
||||
std::vector<ChatEntry> chat_;
|
||||
bool ended_ = false;
|
||||
|
||||
// manager selection: the original picker model for the player choosing (tab ranges,
|
||||
// defaults), the confirmed choices and the draft of the current player
|
||||
std::unique_ptr<ui::ManagerScreen> picker_;
|
||||
std::vector<ui::ManagerChoice> confirmed_;
|
||||
ui::ManagerChoice draft_;
|
||||
|
||||
// file windows
|
||||
std::filesystem::path browse_directory_;
|
||||
std::string selected_file_;
|
||||
|
||||
// info windows produced inside engine calls (cup draws), printed after the call
|
||||
std::vector<std::function<void()>> pending_info_;
|
||||
|
||||
// mailbox: the messages of the last ListMessages (msg numbers refer to it) and the
|
||||
// messages every player has already been told about
|
||||
std::vector<ui::MailboxMessage> listed_mail_;
|
||||
std::map<int, std::set<std::string>> seen_mail_;
|
||||
|
||||
// request ids of the engine calls that need increasing ids (advertising, contracts)
|
||||
uint64_t next_request_id_ = 1;
|
||||
// the open contract negotiation (Contracts.Negotiate)
|
||||
struct Negotiation {
|
||||
int row = -1, player_id = -1;
|
||||
std::string name;
|
||||
uint64_t quote_id = 0;
|
||||
std::array<uint32_t, 4> demands{};
|
||||
int years = -1; // offered term, -1 = no salary offer yet
|
||||
uint32_t salary = 0; // offered monthly salary
|
||||
std::array<uint8_t, 7> bonuses{};
|
||||
};
|
||||
std::optional<Negotiation> negotiation_;
|
||||
|
||||
// squad windows (windows_squad.cpp)
|
||||
void show_player_card();
|
||||
void show_player_statistics(int chart, bool absolute);
|
||||
void show_pitch();
|
||||
void show_pairs();
|
||||
// the open offer editor of Transfer.Negotiate
|
||||
std::optional<ui::OutgoingTransferEditorState> offer_editor_;
|
||||
bool offer_submitted_ = false; // a bid of this editor stands (closing does not withdraw it)
|
||||
// the bank's credit editor draft (Bank.Credit)
|
||||
std::optional<BankCreditDraft> credit_draft_;
|
||||
int credit_counterparty_ = 0; // Bank.Credit: 0 the bank, else the lending manager + 1
|
||||
// the friendly offer of the Friendlies window
|
||||
std::optional<FriendlyBookingQuote> friendly_quote_;
|
||||
std::optional<BalancePlanDraft> balance_draft_; // the Balance window (BalanceFromGame2 locals)
|
||||
// the open club information (TeamInfo)
|
||||
std::optional<ui::ClubInfoProjection> team_info_;
|
||||
int card_row_ = -1; // the squad row of the open player card
|
||||
int chart_ = 0; // PlayerCard.Statistics: Value, Form, Strength, Total
|
||||
bool chart_absolute_ = true;
|
||||
|
||||
// tables
|
||||
int table_league_ = -1;
|
||||
std::optional<ui::LeaguePairingsState> pairings_;
|
||||
|
||||
std::set<std::string> succeeded_;
|
||||
std::vector<std::string> pending_; // command lines before "go."
|
||||
std::vector<std::string> last_block_, last_output_;
|
||||
};
|
||||
|
||||
} // namespace bmh::cli::console
|
||||
@@ -0,0 +1,96 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// Helpers shared by the console's command files (console.cpp and windows_*.cpp). Not part of
|
||||
// the console's public interface.
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cli/console/console.hpp"
|
||||
|
||||
namespace bmh::cli::console::detail {
|
||||
|
||||
// A rejected command: "! <code>: <message> [textKey: <key>]" (01-grundlagen 6). A failed
|
||||
// command changes neither the game nor the random sequence: handlers check everything they
|
||||
// can before they call the engine, and engine calls that fail leave the session unchanged.
|
||||
struct CliError {
|
||||
std::string code, message, text_key;
|
||||
};
|
||||
|
||||
// The eight tactic settings (manager record +0xd2..+0xd9) by their place on the original
|
||||
// board KB/11.VGA (hitboxes Tactics_Click_RuntimeField..Tactics_Click_RuntimeField6, src/ui/TACTICS.md) and the manual H2 p. 71.
|
||||
// Item 0 is the attitude the match engine uses for a human side (match_engine.cpp
|
||||
// update_attitude): fixed for the whole match unless the assistant controls it
|
||||
// (SetAutomation(Tactics)); computer sides play 2 at home and 1 away and go up when behind.
|
||||
// Items 1-3 and 5-6: the exact meaning of each diagram is not proven, the names say where.
|
||||
inline constexpr const char* kTacticNames[8] = {
|
||||
"attitude 0 defensive .. 3 offensive",
|
||||
"pass/shot diagram, lower field (lower middle)",
|
||||
"pass/shot diagram, lower field (upper middle)",
|
||||
"pass/shot diagram, lower field (left)",
|
||||
"flat or high balls (stick figures)",
|
||||
"top right diagram, left (wingers hang back / build-up from behind)",
|
||||
"top right diagram, right (wingers hang back / build-up from behind)",
|
||||
"emphasis (EINSATZ!!!) 0..11",
|
||||
};
|
||||
|
||||
[[noreturn]] inline void fail(std::string code, std::string message, std::string text_key = {}) {
|
||||
throw CliError{std::move(code), std::move(message), std::move(text_key)};
|
||||
}
|
||||
|
||||
// Parameter constructors for the registry.
|
||||
Param integer(std::string name, long long min, long long max, bool optional = false);
|
||||
Param boolean(std::string name, bool optional = false);
|
||||
Param text(std::string name, long long max_length = 0, bool optional = false);
|
||||
// enum: the names (case/'.'/'_' ignored) or their index
|
||||
Param choice(std::string name, std::vector<std::string> choices, bool optional = false);
|
||||
|
||||
std::string on_off(bool v);
|
||||
std::string lower(std::string s);
|
||||
// For name comparisons: lower case, also the German capitals Ä Ö Ü in UTF-8.
|
||||
std::string fold(std::string s);
|
||||
// Text from the engine as UTF-8. Most projections keep the original ISO 646-DE bytes
|
||||
// ("M]NCHEN"), some already convert (cup draw names, results). The original encoding has no
|
||||
// bytes above 0x7f, so a string with such bytes is taken as UTF-8 already.
|
||||
std::string utf8(std::string_view text);
|
||||
// "2027-07-01" (the concept's date type)
|
||||
std::string date_text(int day, int month, int year);
|
||||
// Money as whole euros without separators (01-grundlagen 2.1)
|
||||
std::string money(long long value);
|
||||
|
||||
// A player of a list a command can refer to (01-grundlagen 1.3).
|
||||
struct PlayerRef {
|
||||
int row = -1; // row in the window's list (squad slot)
|
||||
int id = -1; // player id of the game state (stable)
|
||||
std::string name; // UTF-8
|
||||
};
|
||||
// Resolves id:<n>, row:<n> or a (unique part of a) name against `players`; returns the
|
||||
// index into `players`. E_BAD_ARGUMENT if nothing fits, E_AMBIGUOUS with candidates.
|
||||
size_t resolve_player(const std::string& reference, const std::vector<PlayerRef>& players);
|
||||
|
||||
// The window a desk menu (menu_kind 0-29) opens, named as in 02-fenster 6; 63 = Mailbox.
|
||||
// Empty for other numbers.
|
||||
std::string menu_window(int menu);
|
||||
// The menu number of a window name (canonical comparison), -1 if none.
|
||||
int menu_of_window(std::string_view name);
|
||||
|
||||
} // namespace bmh::cli::console::detail
|
||||
|
||||
namespace bmh::cli::console {
|
||||
|
||||
// The arguments of one call, bound to the parameter names and already type-checked.
|
||||
struct Console::Values {
|
||||
std::map<std::string, Arg> args; // canonical parameter name -> argument
|
||||
const Spec* spec = nullptr;
|
||||
int player = 0; // the @n of the call (0 = none)
|
||||
|
||||
bool has(const std::string& name) const { return args.count(canonical(name)) != 0; }
|
||||
long long integer(const std::string& name, long long fallback = 0) const;
|
||||
bool boolean(const std::string& name, bool fallback = false) const;
|
||||
std::string text(const std::string& name, std::string fallback = {}) const;
|
||||
// the index of an enum argument in its parameter's choices (-1 = absent)
|
||||
int choice(const std::string& name) const;
|
||||
};
|
||||
|
||||
} // namespace bmh::cli::console
|
||||
Loaded 100 of 613 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user