Files
Dreierpack-Manager/src/formats/diamond_image.hpp
T
ClaudeandClaude Sonnet 5.5 f1f5fa523c A game needs the executable or openbmh.dat, the executable wins
Assets with openbmh.dat are a complete game; without that file the launcher asks
for BMH.EXE (FLTD.EXE) as before. With both present the executable is used.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 15:26:42 +01:00

49 lines
2.8 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// The game without BMH.exe and FLTD.EXE: OpenBMH carries the numbers of the Diamond 3.7 executable (tables, rates,
// positions, prices; the generated formats/diamond_constants.inc) and of the English Football Limited
// (formats/fltd_constants.inc) and needs only the asset files of the game. The game texts that live in the executables
// (live commentary, messages) are not part of the source: they are in the data file openbmh.dat, which ships with the
// release next to the programs (tools/diamond_constants/generate.py makes it). Without that file those texts are empty.
//
// load_le() returns diamond_constants_image() for a BMH.exe that does not exist, so every reader of the executable image
// works unchanged. A BMH.exe that is there is used as before (it carries its own edition's numbers and texts). For an
// English installation the launcher (launch/fltd.cpp) writes english_constants_image() as the image of the game
// directory when FLTD.EXE is missing.
#pragma once
#include <filesystem>
#include <string>
#include "formats/binary.hpp"
#include "formats/le.hpp"
namespace bmh {
// openbmh.dat: "OPENBMH-DAT" NUL, u32 set count, then per set u32 edition (1 German, 2 English), u32 range count, count
// times (u32 address, u32 length), then the bytes of all ranges. A range must be one of the edition's text ranges, so
// the file can never change a number of the image.
//
// The file is looked for in: the environment variable OPENBMH_DAT ("-" = none at all), the folder of the game data, the folder of the
// running program, the current folder. Returns an empty path when there is none.
std::filesystem::path find_texts_file(const std::filesystem::path& game_directory);
// A short text that changes when the texts file changes (empty without a file): used to rebuild cached English games.
std::string texts_signature(const std::filesystem::path& game_directory);
// The German (Diamond 3.7) image built from the embedded numbers plus the texts of openbmh.dat (found for
// `game_directory`).
LeImage diamond_constants_image(const std::filesystem::path& game_directory = {});
// The English Football Limited image in the German address space (what launch::translate_fltd() makes from
// FLTD.EXE), built from the embedded numbers plus the texts of openbmh.dat.
LeImage english_constants_image(const std::filesystem::path& game_directory = {});
// Puts the texts of an openbmh.dat file (edition 1 or 2) into `image`. Throws FormatError for malformed data or for a
// range that is not a text range of that edition. Returns false when the file has no set of that edition.
bool apply_texts(LeImage& image, int edition, const Bytes& file);
// Whether `file_name` is the name of the executable (BMH.exe in any case).
bool is_executable_name(const std::filesystem::path& file_name);
} // namespace bmh