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>
This commit is contained in:
1 parent
32b08e3799
commit
f1f5fa523c
6 files changed
+62
-21
No files matched your search
@@ -15,10 +15,9 @@ This is an independent community project, with no affiliation with or endorsemen
|
||||
|
||||
Check the [releases page](https://github.com/Weyoune/openbmh/releases) for available packages and their platform notes. A Windows package uses the name `OpenBMH-<version>-windows-x64.zip`. Availability and native validation are stated for each release; source build instructions do not establish platform support on their own.
|
||||
|
||||
1. Have your own supported game installation available. OpenBMH needs its asset files (texts, master database, pictures, fonts, sounds); neither `BMH.EXE` nor `FLTD.EXE` is required: the numbers of the Diamond 3.7 executable and of the English Football Limited are built in, and their game texts (live commentary, messages) are in `openbmh.dat`, which ships next to the programs in the release package (without that file those texts are empty).
|
||||
1. Have your own supported game installation available. OpenBMH needs its asset files (texts, master database, pictures, fonts, sounds) and **either** `BMH.EXE` (`FLTD.EXE` for the English game) **or** `openbmh.dat`, which ships next to the programs in the release package and holds the game texts of the original executables; the numbers of those executables are built into OpenBMH. If both are there, the executable is used. If neither is there, OpenBMH asks for the game directory or for `BMH.EXE`.
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory (or `BMH.EXE`) when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
4. A BMH.EXE (or FLTD.EXE) that stays in the game directory is used as before; it carries its own edition's numbers and texts.
|
||||
|
||||
From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
|
||||
@@ -6,21 +6,23 @@ selling of a listed player, and corrects the asking price shown in the market.
|
||||
Extended development remains separate in
|
||||
[OpenBMH-Extended](https://github.com/Weyoune/OpenBMH-extended).
|
||||
|
||||
## No BMH.EXE or FLTD.EXE needed
|
||||
## BMH.EXE or openbmh.dat
|
||||
|
||||
- A game needs its asset files and **either** the executable (`BMH.EXE`, or
|
||||
`FLTD.EXE` for the English game) **or** the file **openbmh.dat**. If both are
|
||||
there, the executable is used as before. If neither is there, OpenBMH asks for
|
||||
a game directory or for `BMH.EXE`.
|
||||
- The numbers of the Diamond 3.7 executable (tables, rates, positions, prices) and
|
||||
of the English Football Limited are built into the program. A game folder, ZIP
|
||||
or 7z with only the asset files (`TEXTD.BLK` and `M3D.MAN`, or `TEXTE.BLK`
|
||||
and `M3E.MAN`, plus the picture, font and sound folders) is a complete game.
|
||||
A `BMH.EXE` or `FLTD.EXE` that is there is used as before.
|
||||
- The game texts of the original executables (live commentary, some messages) are
|
||||
in the file **openbmh.dat**, which ships next to `OpenBMH` and `openbmh_cli`
|
||||
in the release package. The game looks for it in the game folder, in the
|
||||
program folder and in the current folder (or where `OPENBMH_DAT` points to).
|
||||
Without the file those texts are empty and the game still runs.
|
||||
of the English Football Limited are built into the program. `openbmh.dat` holds
|
||||
the game texts of those executables (live commentary, messages). It ships next
|
||||
to `OpenBMH` and `openbmh_cli` in the release package and is found in the
|
||||
game folder, in the program folder and in the current folder (or where
|
||||
`OPENBMH_DAT` points to). A folder, ZIP or 7z with only the asset files
|
||||
(`TEXTD.BLK` and `M3D.MAN`, or `TEXTE.BLK` and `M3E.MAN`, plus the
|
||||
picture, font and sound folders) is a complete game when `openbmh.dat` is
|
||||
found.
|
||||
- The default manager name is "OpenBMH" instead of "Nobody".
|
||||
- A recorded session gives the same output as with the real `BMH.EXE`.
|
||||
|
||||
## Changes since 1.0.9 (1.0.10 was never published; its changes are part of this release)
|
||||
|
||||
- **Suchen and Vorschlag in the transfer market.** Both buttons did nothing.
|
||||
@@ -73,7 +75,7 @@ Extended development remains separate in
|
||||
the original and cannot be reproduced exactly (documented in the source).
|
||||
- Only one matchday and the days after it were recorded from the real 3.7; the
|
||||
weekly processing, month changes and transfers are not yet compared.
|
||||
- The graphical client has not yet been tried with asset files only.
|
||||
- The graphical client has not yet been tried with `openbmh.dat` and asset files only.
|
||||
- Earlier open points remain: "player card: original atlas bounds" (#77), sporadic
|
||||
double clicks (#58) and the macOS match scene speed (#70).
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -98,6 +99,7 @@ void add_texts(LeImage& image, int edition, const std::filesystem::path& game_di
|
||||
|
||||
std::filesystem::path find_texts_file(const std::filesystem::path& game_directory) {
|
||||
if (const char* env = std::getenv("OPENBMH_DAT"); env && *env) {
|
||||
if (std::string_view(env) == "-") return {}; // "no texts file at all" (tests of the launcher)
|
||||
std::error_code ec;
|
||||
if (std::filesystem::is_regular_file(env, ec)) return env;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace bmh {
|
||||
// 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, the folder of the game data, the folder of the
|
||||
// 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);
|
||||
|
||||
|
||||
@@ -72,20 +72,24 @@ std::optional<Family> family_of_exe(const std::string& file_name) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Whether `directory` holds the asset files of the English game (FLTD.EXE is not needed: its numbers and texts are built in).
|
||||
// Whether `directory` holds the asset files of the English game and the built-in numbers have their texts (openbmh.dat):
|
||||
// then FLTD.EXE is not needed. Without openbmh.dat the game needs the executable.
|
||||
bool has_english_assets(const fs::path& directory) {
|
||||
std::error_code ec;
|
||||
if (!fs::is_directory(directory, ec)) return false;
|
||||
const auto kb = find_file(directory, "KB");
|
||||
return find_file(directory, "TEXTE.BLK") && find_file(directory, "M3E.MAN") && kb && fs::is_directory(*kb, ec);
|
||||
return find_file(directory, "TEXTE.BLK") && find_file(directory, "M3E.MAN") && kb && fs::is_directory(*kb, ec) &&
|
||||
!find_texts_file(directory).empty();
|
||||
}
|
||||
|
||||
// Whether `directory` holds the asset files of the German game (the executable is not needed: its numbers are built in).
|
||||
// Whether `directory` holds the asset files of the German game and the built-in numbers have their texts (openbmh.dat):
|
||||
// then BMH.EXE is not needed. Without openbmh.dat the game needs the executable.
|
||||
bool has_german_assets(const fs::path& directory) {
|
||||
std::error_code ec;
|
||||
if (!fs::is_directory(directory, ec)) return false;
|
||||
const auto kb = find_file(directory, "KB");
|
||||
return find_file(directory, "TEXTD.BLK") && find_file(directory, "M3D.MAN") && kb && fs::is_directory(*kb, ec);
|
||||
return find_file(directory, "TEXTD.BLK") && find_file(directory, "M3D.MAN") && kb && fs::is_directory(*kb, ec) &&
|
||||
!find_texts_file(directory).empty();
|
||||
}
|
||||
|
||||
// Every game EXE directly in `directory`.
|
||||
@@ -386,7 +390,7 @@ GameCheck check_game_directory(const fs::path& path) {
|
||||
return c;
|
||||
}
|
||||
if (exes.empty()) {
|
||||
c.problems.push_back("no BMH.EXE or FLTD.EXE in " + path_to_utf8(dir) + ", and no game asset files (TEXTD.BLK, M3D.MAN) or the English ones (TEXTE.BLK, M3E.MAN)");
|
||||
c.problems.push_back("no BMH.EXE or FLTD.EXE in " + path_to_utf8(dir) + ". The game needs either BMH.EXE (FLTD.EXE for the English game) and the asset files, or openbmh.dat (from the release package) and the asset files.");
|
||||
return c;
|
||||
}
|
||||
// a named EXE decides; otherwise the German game before the English one
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
#include "miniz.h"
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh::launch;
|
||||
|
||||
namespace {
|
||||
void set_environment(const char* name, const char* value) {
|
||||
#ifdef _WIN32
|
||||
_putenv_s(name, value);
|
||||
#else
|
||||
if (*value) setenv(name, value, 1); else unsetenv(name);
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() try {
|
||||
const std::string unicode = "Unit-Ä-测试 folder/archive.zip";
|
||||
if (path_to_utf8(path_from_utf8(unicode)) != unicode)
|
||||
@@ -36,7 +49,28 @@ int main() try {
|
||||
const auto read = archive.read(0);
|
||||
if (std::string(read.begin(), read.end()) != payload) throw std::runtime_error("ZIP payload mismatch");
|
||||
std::filesystem::remove(path);
|
||||
std::cout << "Synthetic ZIP and Unicode path checks passed\n";
|
||||
|
||||
// A game folder is either BMH.EXE + assets or openbmh.dat + assets; without both the launcher asks for an executable.
|
||||
// (synthetic empty files: only the choice of the way is checked, not the game data)
|
||||
const auto folder = std::filesystem::temp_directory_path() /
|
||||
("openbmh-unit-game-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
std::filesystem::create_directories(folder / "KB");
|
||||
for (const char* name : {"TEXTD.BLK", "M3D.MAN"}) std::ofstream(folder / name).put('x');
|
||||
set_environment("OPENBMH_DAT", "-"); // no texts file anywhere (the program folder of the test may hold one)
|
||||
const auto without_dat = check_game_directory(folder);
|
||||
const auto mentions_dat = [](const GameCheck& c) {
|
||||
for (const auto& problem : c.problems) if (problem.find("openbmh.dat") != std::string::npos) return true;
|
||||
return false;
|
||||
};
|
||||
if (without_dat.playable || !mentions_dat(without_dat))
|
||||
throw std::runtime_error("assets without BMH.EXE and without openbmh.dat must ask for an executable");
|
||||
set_environment("OPENBMH_DAT", "");
|
||||
std::ofstream(folder / "openbmh.dat").put('x');
|
||||
const auto with_dat = check_game_directory(folder);
|
||||
if (with_dat.family != GameFamily::german || mentions_dat(with_dat))
|
||||
throw std::runtime_error("assets with openbmh.dat are a game without executable");
|
||||
std::filesystem::remove_all(folder);
|
||||
std::cout << "Synthetic ZIP, Unicode path and game folder checks passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
|
||||
Reference in new issue
Block a user