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:
ClaudeandClaude Sonnet 5.5 committed 2026-11-08 15:26:42 +01:00
1 parent 32b08e3799
commit f1f5fa523c
6 files changed
+62 -21

No files matched your search

+35 -1
View File
@@ -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';