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,261 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "launch/archive.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#endif
|
||||
|
||||
#include "miniz.h"
|
||||
|
||||
extern "C" {
|
||||
#include "7z.h"
|
||||
#include "7zAlloc.h"
|
||||
#include "7zCrc.h"
|
||||
}
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<uint8_t> read_whole(const std::filesystem::path& file) {
|
||||
std::ifstream in(file, std::ios::binary);
|
||||
if (!in) throw ArchiveError("cannot open " + path_to_utf8(file));
|
||||
in.seekg(0, std::ios::end);
|
||||
const auto size = in.tellg();
|
||||
if (size < 0) throw ArchiveError("cannot read " + path_to_utf8(file));
|
||||
// The largest real package (a box with three editions) has 55 MB; anything far beyond
|
||||
// that is no BMH package.
|
||||
if (uint64_t(size) > 512ull * 1024 * 1024) throw ArchiveError(path_to_utf8(file) + " is too large for a BMH package");
|
||||
std::vector<uint8_t> data(static_cast<size_t>(size));
|
||||
in.seekg(0);
|
||||
in.read(reinterpret_cast<char*>(data.data()), std::streamsize(data.size()));
|
||||
if (!in) throw ArchiveError("cannot read " + path_to_utf8(file));
|
||||
return data;
|
||||
}
|
||||
|
||||
// Code page 437 (the DOS code page old ZIP tools wrote names in) to UTF-8, for names
|
||||
// without the ZIP UTF-8 flag. Only the upper half differs from ASCII.
|
||||
std::string cp437_to_utf8(const std::string& text) {
|
||||
static const char16_t kHigh[128] = {
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0};
|
||||
std::string out;
|
||||
for (unsigned char c : text) {
|
||||
const unsigned u = c < 0x80 ? c : kHigh[c - 0x80];
|
||||
if (u < 0x80) out += char(u);
|
||||
else if (u < 0x800) out += char(0xC0 | (u >> 6)), out += char(0x80 | (u & 0x3F));
|
||||
else out += char(0xE0 | (u >> 12)), out += char(0x80 | ((u >> 6) & 0x3F)), out += char(0x80 | (u & 0x3F));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string utf16_to_utf8(const std::vector<uint16_t>& text) {
|
||||
std::string out;
|
||||
for (size_t i = 0; i < text.size() && text[i] != 0; ++i) {
|
||||
uint32_t u = text[i];
|
||||
if (u >= 0xD800 && u < 0xDC00 && i + 1 < text.size() && text[i + 1] >= 0xDC00 && text[i + 1] < 0xE000)
|
||||
u = 0x10000 + ((u - 0xD800) << 10) + (text[++i] - 0xDC00);
|
||||
if (u < 0x80) out += char(u);
|
||||
else if (u < 0x800) out += char(0xC0 | (u >> 6)), out += char(0x80 | (u & 0x3F));
|
||||
else if (u < 0x10000) out += char(0xE0 | (u >> 12)), out += char(0x80 | ((u >> 6) & 0x3F)), out += char(0x80 | (u & 0x3F));
|
||||
else
|
||||
out += char(0xF0 | (u >> 18)), out += char(0x80 | ((u >> 12) & 0x3F)), out += char(0x80 | ((u >> 6) & 0x3F)),
|
||||
out += char(0x80 | (u & 0x3F));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string normalise(std::string name) {
|
||||
for (char& c : name)
|
||||
if (c == '\\') c = '/';
|
||||
while (!name.empty() && name.front() == '/') name.erase(name.begin());
|
||||
return name;
|
||||
}
|
||||
|
||||
// The LZMA SDK reads through an ISeekInStream; this one serves the archive from memory.
|
||||
struct MemoryStream {
|
||||
ISeekInStream vt; // first member: the SDK passes &vt around
|
||||
const uint8_t* data = nullptr;
|
||||
size_t size = 0, pos = 0;
|
||||
};
|
||||
|
||||
SRes memory_read(ISeekInStreamPtr p, void* buf, size_t* size) {
|
||||
auto* s = reinterpret_cast<MemoryStream*>(const_cast<ISeekInStream*>(p));
|
||||
const size_t n = std::min(*size, s->size - s->pos);
|
||||
std::memcpy(buf, s->data + s->pos, n);
|
||||
s->pos += n;
|
||||
*size = n;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
SRes memory_seek(ISeekInStreamPtr p, Int64* pos, ESzSeek origin) {
|
||||
auto* s = reinterpret_cast<MemoryStream*>(const_cast<ISeekInStream*>(p));
|
||||
Int64 base = origin == SZ_SEEK_SET ? 0 : origin == SZ_SEEK_CUR ? Int64(s->pos) : Int64(s->size);
|
||||
const Int64 target = base + *pos;
|
||||
if (target < 0 || uint64_t(target) > s->size) return SZ_ERROR_PARAM;
|
||||
s->pos = size_t(target);
|
||||
*pos = target;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::filesystem::path path_from_utf8(const std::string& text) {
|
||||
return std::filesystem::path(std::u8string(text.begin(), text.end()));
|
||||
}
|
||||
|
||||
std::string path_to_utf8(const std::filesystem::path& path) {
|
||||
const std::u8string u = path.u8string();
|
||||
return std::string(u.begin(), u.end());
|
||||
}
|
||||
|
||||
std::vector<std::string> utf8_arguments(int argc, char** argv) {
|
||||
std::vector<std::string> out;
|
||||
#ifdef _WIN32
|
||||
int count = 0;
|
||||
if (LPWSTR* wide = CommandLineToArgvW(GetCommandLineW(), &count)) {
|
||||
for (int i = 0; i < count; ++i) out.push_back(path_to_utf8(std::filesystem::path(wide[i])));
|
||||
LocalFree(wide);
|
||||
if (count == argc) return out;
|
||||
out.clear();
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < argc; ++i) out.emplace_back(argv[i]);
|
||||
return out;
|
||||
}
|
||||
|
||||
ArchiveFormat archive_format(const std::filesystem::path& file) {
|
||||
std::ifstream in(file, std::ios::binary);
|
||||
unsigned char head[8] = {};
|
||||
in.read(reinterpret_cast<char*>(head), sizeof head);
|
||||
if (in.gcount() < 4) return ArchiveFormat::none;
|
||||
if (head[0] == 'P' && head[1] == 'K' && (head[2] == 3 || head[2] == 5) && (head[3] == 4 || head[3] == 6))
|
||||
return ArchiveFormat::zip;
|
||||
if (in.gcount() >= 6 && std::memcmp(head, "7z\xBC\xAF\x27\x1C", 6) == 0) return ArchiveFormat::seven_zip;
|
||||
if (head[0] == 0x60 && head[1] == 0xEA) return ArchiveFormat::arj;
|
||||
if (std::memcmp(head, "Rar!", 4) == 0) return ArchiveFormat::rar;
|
||||
return ArchiveFormat::none;
|
||||
}
|
||||
|
||||
struct Archive::Impl {
|
||||
ArchiveFormat format = ArchiveFormat::none;
|
||||
std::vector<uint8_t> bytes;
|
||||
std::vector<ArchiveEntry> entries;
|
||||
std::vector<uint32_t> source_index; // entry -> index in the archive's own list
|
||||
// ZIP
|
||||
mz_zip_archive zip{};
|
||||
bool zip_open = false;
|
||||
// 7z
|
||||
MemoryStream stream;
|
||||
CLookToRead2 look{};
|
||||
CSzArEx db{};
|
||||
ISzAlloc alloc{SzAlloc, SzFree};
|
||||
bool db_open = false;
|
||||
UInt32 block_index = 0xFFFFFFFF; // the solid block cached in out_buffer
|
||||
Byte* out_buffer = nullptr;
|
||||
size_t out_buffer_size = 0;
|
||||
|
||||
~Impl() {
|
||||
if (zip_open) mz_zip_reader_end(&zip);
|
||||
if (db_open) SzArEx_Free(&db, &alloc);
|
||||
if (out_buffer) ISzAlloc_Free(&alloc, out_buffer);
|
||||
if (look.buf) ISzAlloc_Free(&alloc, look.buf);
|
||||
}
|
||||
|
||||
void open_zip() {
|
||||
if (!mz_zip_reader_init_mem(&zip, bytes.data(), bytes.size(), 0))
|
||||
throw ArchiveError(std::string("damaged ZIP archive: ") + mz_zip_get_error_string(mz_zip_get_last_error(&zip)));
|
||||
zip_open = true;
|
||||
const mz_uint count = mz_zip_reader_get_num_files(&zip);
|
||||
for (mz_uint i = 0; i < count; ++i) {
|
||||
mz_zip_archive_file_stat st{};
|
||||
if (!mz_zip_reader_file_stat(&zip, i, &st)) throw ArchiveError("damaged ZIP directory");
|
||||
// bit 11 of the general purpose flags: the name is UTF-8
|
||||
const bool utf8 = (st.m_bit_flag & 0x800) != 0;
|
||||
std::string name = st.m_filename;
|
||||
entries.push_back({normalise(utf8 ? name : cp437_to_utf8(name)), st.m_uncomp_size, st.m_is_directory != 0});
|
||||
source_index.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
void open_7z() {
|
||||
static const bool crc_ready = [] { CrcGenerateTable(); return true; }();
|
||||
(void)crc_ready;
|
||||
stream.vt.Read = memory_read;
|
||||
stream.vt.Seek = memory_seek;
|
||||
stream.data = bytes.data();
|
||||
stream.size = bytes.size();
|
||||
LookToRead2_CreateVTable(&look, False);
|
||||
constexpr size_t kBuffer = size_t(1) << 18;
|
||||
look.buf = static_cast<Byte*>(ISzAlloc_Alloc(&alloc, kBuffer));
|
||||
if (!look.buf) throw ArchiveError("out of memory");
|
||||
look.bufSize = kBuffer;
|
||||
look.realStream = &stream.vt;
|
||||
LookToRead2_INIT(&look);
|
||||
SzArEx_Init(&db);
|
||||
if (SzArEx_Open(&db, &look.vt, &alloc, &alloc) != SZ_OK) throw ArchiveError("damaged 7z archive");
|
||||
db_open = true;
|
||||
for (UInt32 i = 0; i < db.NumFiles; ++i) {
|
||||
const size_t len = SzArEx_GetFileNameUtf16(&db, i, nullptr);
|
||||
std::vector<uint16_t> name(len);
|
||||
SzArEx_GetFileNameUtf16(&db, i, name.data());
|
||||
const bool dir = SzArEx_IsDir(&db, i) != 0;
|
||||
entries.push_back({normalise(utf16_to_utf8(name)), dir ? 0 : SzArEx_GetFileSize(&db, i), dir});
|
||||
source_index.push_back(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Archive::Archive(std::unique_ptr<Impl> impl) : impl_(std::move(impl)) {}
|
||||
Archive::Archive(Archive&&) noexcept = default;
|
||||
Archive& Archive::operator=(Archive&&) noexcept = default;
|
||||
Archive::~Archive() = default;
|
||||
|
||||
Archive Archive::open(const std::filesystem::path& file) {
|
||||
const ArchiveFormat format = archive_format(file);
|
||||
if (format != ArchiveFormat::zip && format != ArchiveFormat::seven_zip)
|
||||
throw ArchiveError(path_to_utf8(file) + " is no ZIP or 7z archive");
|
||||
auto impl = std::make_unique<Impl>();
|
||||
impl->format = format;
|
||||
impl->bytes = read_whole(file);
|
||||
if (format == ArchiveFormat::zip) impl->open_zip();
|
||||
else impl->open_7z();
|
||||
return Archive(std::move(impl));
|
||||
}
|
||||
|
||||
ArchiveFormat Archive::format() const { return impl_->format; }
|
||||
const std::vector<ArchiveEntry>& Archive::entries() const { return impl_->entries; }
|
||||
|
||||
std::vector<uint8_t> Archive::read(size_t index) {
|
||||
Impl& a = *impl_;
|
||||
if (index >= a.entries.size()) throw ArchiveError("no such archive entry");
|
||||
if (a.entries[index].directory) return {};
|
||||
if (a.format == ArchiveFormat::zip) {
|
||||
size_t size = 0;
|
||||
void* p = mz_zip_reader_extract_to_heap(&a.zip, a.source_index[index], &size, 0);
|
||||
if (!p) throw ArchiveError("cannot unpack " + a.entries[index].name);
|
||||
std::vector<uint8_t> out(static_cast<uint8_t*>(p), static_cast<uint8_t*>(p) + size);
|
||||
mz_free(p);
|
||||
return out;
|
||||
}
|
||||
size_t offset = 0, processed = 0;
|
||||
if (SzArEx_Extract(&a.db, &a.look.vt, a.source_index[index], &a.block_index, &a.out_buffer, &a.out_buffer_size,
|
||||
&offset, &processed, &a.alloc, &a.alloc) != SZ_OK)
|
||||
throw ArchiveError("cannot unpack " + a.entries[index].name);
|
||||
return std::vector<uint8_t>(a.out_buffer + offset, a.out_buffer + offset + processed);
|
||||
}
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// Read-only access to the archives a player may hand to OpenBMH instead of an installed
|
||||
// game directory: ZIP (miniz) and 7z (the LZMA SDK's C decoder). The archive is read into
|
||||
// memory once, so paths with characters outside the ANSI code page (the box names contain
|
||||
// an en dash) work on Windows too. ARJ (the 1994 installation disk) and RAR are recognised
|
||||
// only to give a clear message.
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
class ArchiveError : public std::runtime_error {
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
enum class ArchiveFormat { none, zip, seven_zip, arj, rar };
|
||||
|
||||
// The format by the first bytes of the file (none: not an archive we know).
|
||||
ArchiveFormat archive_format(const std::filesystem::path& file);
|
||||
|
||||
struct ArchiveEntry {
|
||||
std::string name; // UTF-8, '/' as separator, no leading '/'
|
||||
uint64_t size = 0; // uncompressed size
|
||||
bool directory = false;
|
||||
};
|
||||
|
||||
class Archive {
|
||||
public:
|
||||
// Opens a ZIP or 7z archive; throws ArchiveError for anything else or a damaged file.
|
||||
static Archive open(const std::filesystem::path& file);
|
||||
Archive(Archive&&) noexcept;
|
||||
Archive& operator=(Archive&&) noexcept;
|
||||
~Archive();
|
||||
|
||||
ArchiveFormat format() const;
|
||||
const std::vector<ArchiveEntry>& entries() const;
|
||||
// The uncompressed bytes of entry `index`.
|
||||
std::vector<uint8_t> read(size_t index);
|
||||
|
||||
struct Impl;
|
||||
|
||||
private:
|
||||
explicit Archive(std::unique_ptr<Impl> impl);
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
// A path from UTF-8 text (std::filesystem::path(std::string) would use the ANSI code page on
|
||||
// Windows).
|
||||
std::filesystem::path path_from_utf8(const std::string& text);
|
||||
std::string path_to_utf8(const std::filesystem::path& path);
|
||||
|
||||
// The program arguments as UTF-8. On Windows `argv` is in the ANSI code page, which cannot
|
||||
// hold every file name (an en dash, other alphabets); there the wide command line is used.
|
||||
std::vector<std::string> utf8_arguments(int argc, char** argv);
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,24 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "launch/file_dialog.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <nfd.hpp>
|
||||
|
||||
#include "launch/archive.hpp"
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
std::optional<std::filesystem::path> choose_game_file(const std::string& title) {
|
||||
(void)title; // (nfd 1.2 has no dialog title parameter; the window title is the system's)
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePathU8 path;
|
||||
// one filter with all accepted kinds; the check after the choice decides
|
||||
const nfdu8filteritem_t filters[] = {{"BMH game (ZIP, 7z, BMH.EXE, FLTD.EXE)", "zip,7z,exe"}};
|
||||
const nfdresult_t result = NFD::OpenDialog(path, filters, 1);
|
||||
if (result == NFD_CANCEL) return std::nullopt;
|
||||
if (result != NFD_OKAY) throw std::runtime_error(std::string("no file dialog: ") + NFD::GetError());
|
||||
return path_from_utf8(path.get());
|
||||
}
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// The system's "open file" dialog for choosing the game when OpenBMH starts without one:
|
||||
// a ZIP/7z archive or the game's EXE. Windows, macOS and Linux (GTK or the desktop portal)
|
||||
// through nativefiledialog-extended.
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
// nullopt when the player cancels; throws std::runtime_error when no dialog can be shown
|
||||
// (e.g. no desktop session on Linux).
|
||||
std::optional<std::filesystem::path> choose_game_file(const std::string& title);
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,159 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "launch/fltd.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <vector>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
namespace {
|
||||
|
||||
// The English image: address = file offset - 0x496d (157 of 165 data strings are referenced
|
||||
// with that offset), initialised data up to Career_CompetitionPointersEnglish_RuntimeField.
|
||||
constexpr uint32_t kEnFileOffset = 0x496d;
|
||||
constexpr uint32_t kEnDataStart = ::bmh::layout::EnDataStart, kEnDataEnd = ::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField;
|
||||
constexpr uint32_t kFltdSize = 507925;
|
||||
// The German image the engine expects: LE objects from layout field, data object GermanDataSegmentBegin-layout field.
|
||||
constexpr uint32_t kDeBase = 0x10000, kDeEnd = ::bmh::layout::GermanImageEnd;
|
||||
// A zero byte in the German BSS: the empty string of empty_pointers entries.
|
||||
constexpr uint32_t kEmptyString = ::bmh::layout::EmptyString;
|
||||
|
||||
enum class Kind { copy, keep, empty_pointers, own_text };
|
||||
|
||||
struct Entry {
|
||||
uint32_t de; // German address
|
||||
uint32_t length; // bytes of the German object (texts: with the closing NUL)
|
||||
Kind kind;
|
||||
uint32_t en; // English address (copy)
|
||||
std::vector<uint8_t> bytes; // the German values (keep)
|
||||
};
|
||||
|
||||
const std::vector<Entry> kMap = {
|
||||
#include "launch/fltd_map.inc"
|
||||
};
|
||||
|
||||
// OpenBMH's English texts for V2.24 texts the English V2.20 does not have. Each must fit the
|
||||
// German text's room (its length including the NUL).
|
||||
struct OwnText {
|
||||
uint32_t de;
|
||||
const char* text;
|
||||
};
|
||||
const OwnText kOwnTexts[] = {
|
||||
{::bmh::layout::Fltd_Layout_TextPointer, ", "},
|
||||
{::bmh::layout::Fltd_Layout_TextPointer2, ": "},
|
||||
{::bmh::layout::Fltd_Layout_TextPointer3, "s"}, // plural ending (German "e")
|
||||
{::bmh::layout::Fltd_Layout_TextPointer4, " #"},
|
||||
{::bmh::layout::Fltd_Layout_TextPointer5, "Competition closed"},
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField, "As not all season ticket holders fit into the stadium, you pay "},
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField2, " compensation."},
|
||||
{::bmh::layout::CareerSession_FormatNumber_TextPointer, "("},
|
||||
{::bmh::layout::CareerSession_FormatNumber_ExecutableField2, "# disc.)"},
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField3, "The sponsor feels exploited. He pays only "},
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField4, " percent of the price."},
|
||||
{::bmh::layout::CurrencySuffixText, " &"}, // the pound sign of the English font
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField5, "AUTO"},
|
||||
{::bmh::layout::BalancePlan_DrawRows_TextPointer, "+)"},
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField6, "-"},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
LeImage translate_fltd(const fs::path& fltd_exe) {
|
||||
const Bytes raw = read_file(fltd_exe);
|
||||
if (raw.size() != kFltdSize || raw[0] != 'M' || raw[1] != 'Z')
|
||||
throw std::runtime_error(path_to_utf8(fltd_exe) + " is not the Football Limited FLTD.EXE");
|
||||
const auto en = [&](uint32_t address) -> uint8_t {
|
||||
const size_t at = size_t(address) + kEnFileOffset;
|
||||
return at < raw.size() ? raw[at] : 0;
|
||||
};
|
||||
Bytes image(kDeEnd - kDeBase, 0);
|
||||
const auto put = [&](uint32_t address, uint8_t value) {
|
||||
if (address < kDeBase || address >= kDeEnd) throw std::runtime_error("FLTD map outside the image");
|
||||
image[address - kDeBase] = value;
|
||||
};
|
||||
// the English data segment at its own addresses (German code addresses: never read as data)
|
||||
for (uint32_t a = kEnDataStart; a < kEnDataEnd; ++a) put(a, en(a));
|
||||
// (the map is sorted by German address; a copy reaches up to the next entry, because the
|
||||
// object extents of the decompiler are sometimes finer than the tables - LeagueSizes/a2bce)
|
||||
// (the German values are written last: a keep-de range such as the competition table
|
||||
// CupTable covers entries inside it)
|
||||
for (int pass = 0; pass < 2; ++pass)
|
||||
for (size_t n = 0; n < kMap.size(); ++n) {
|
||||
const Entry& e = kMap[n];
|
||||
if ((e.kind == Kind::keep) != (pass == 1)) continue;
|
||||
switch (e.kind) {
|
||||
case Kind::copy: {
|
||||
uint32_t length = e.length;
|
||||
if (n + 1 < kMap.size() && kMap[n + 1].de > e.de) length = std::max(length, std::min(kMap[n + 1].de - e.de, 0x800u));
|
||||
for (uint32_t i = 0; i < length; ++i) put(e.de + i, en(e.en + i));
|
||||
break;
|
||||
}
|
||||
case Kind::keep:
|
||||
for (uint32_t i = 0; i < e.length && i < e.bytes.size(); ++i) put(e.de + i, e.bytes[i]);
|
||||
break;
|
||||
case Kind::empty_pointers:
|
||||
for (uint32_t i = 0; i + 4 <= e.length; i += 4)
|
||||
for (uint32_t b = 0; b < 4; ++b) put(e.de + i + b, uint8_t(kEmptyString >> (8 * b)));
|
||||
break;
|
||||
case Kind::own_text: {
|
||||
const OwnText* t = nullptr;
|
||||
for (const OwnText& o : kOwnTexts)
|
||||
if (o.de == e.de) t = &o;
|
||||
const std::string text = t ? t->text : "";
|
||||
if (text.size() + 1 > e.length) throw std::runtime_error("English text does not fit at " + std::to_string(e.de));
|
||||
for (uint32_t i = 0; i < e.length; ++i) put(e.de + i, i < text.size() ? uint8_t(text[i]) : 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||
apply_rule_base(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool prepare_english_game(const fs::path& source, const fs::path& target, std::string& error) {
|
||||
try {
|
||||
std::error_code ec;
|
||||
fs::create_directories(target);
|
||||
const auto copy = [&](const fs::path& from, const fs::path& to) {
|
||||
fs::create_directories(to.parent_path());
|
||||
fs::copy_file(from, to, fs::copy_options::overwrite_existing);
|
||||
};
|
||||
// the shared data files and directories (names as the German game has them)
|
||||
for (const char* name : {"M3.DAT", "M3.MEN", "M3PC.COL"})
|
||||
if (auto f = find_file(source, name)) copy(*f, target / name);
|
||||
for (const char* dir : {"KB", "W", "F", "S"}) {
|
||||
auto d = find_file(source, dir);
|
||||
if (!d) continue;
|
||||
for (const auto& e : fs::directory_iterator(*d)) {
|
||||
std::string name = path_to_utf8(e.path().filename());
|
||||
for (char& c : name) c = char(std::toupper(static_cast<unsigned char>(c)));
|
||||
if (e.is_regular_file()) copy(e.path(), target / dir / path_from_utf8(name));
|
||||
}
|
||||
}
|
||||
if (auto f = find_file(source, "TEXTE.BLK")) copy(*f, target / "TEXTD.BLK");
|
||||
if (auto f = find_file(source, "M3E.MAN")) copy(*f, target / "M3D.MAN");
|
||||
const auto exe = find_file(source, "FLTD.EXE");
|
||||
if (!exe) throw std::runtime_error("FLTD.EXE is missing");
|
||||
save_image(translate_fltd(*exe), target / "BMH.exe");
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
error = e.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// The English "Football Limited" (FLTD.EXE) as data for the one OpenBMH engine.
|
||||
//
|
||||
// The engine reads its data the German way: BMH.EXE tables at German addresses, TEXTD.BLK and
|
||||
// M3D.MAN. prepare_english_game() turns an English installation into such a data directory,
|
||||
// once, in the launcher cache:
|
||||
// - TEXTE.BLK -> TEXTD.BLK and M3E.MAN -> M3D.MAN (same formats, the text slots are the
|
||||
// same variables; docs/formats/TEXTD_INVENTORY.md),
|
||||
// - FLTD.EXE -> "BMH.exe" in the OpenBMH image format (formats/le.hpp): an image in the
|
||||
// German address space. Every German data object the engine reads is filled from its
|
||||
// English counterpart (src/launch/fltd_map.inc, generated by runtime verification), German
|
||||
// numbers keep V2.24 features the English V2.20 lacks, OpenBMH's own English texts
|
||||
// stand in for V2.24 texts, and the whole English data segment also lies at its own
|
||||
// addresses so that English pointers stay valid. Then the rule base is applied.
|
||||
// - the pictures, fonts, sounds and the other data files are copied unchanged.
|
||||
// The English league structure (20 20 20 20 10 + the four international leagues of 12)
|
||||
// arrives through the size table at LeagueSizes and is installed by the career session.
|
||||
// Background: runtime verification
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "formats/le.hpp"
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
// The German-layout image of FLTD.EXE (throws std::runtime_error for another file).
|
||||
LeImage translate_fltd(const std::filesystem::path& fltd_exe);
|
||||
|
||||
// Builds the German-layout data directory `target` from the English game in `source`.
|
||||
// Returns false with `error` set when a file cannot be read or written.
|
||||
bool prepare_english_game(const std::filesystem::path& source, const std::filesystem::path& target, std::string& error);
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,355 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Generated by runtime verification - do not edit. DE data object -> FLTD.EXE (EN address).
|
||||
// {DE address, length, kind, EN address, keep-de bytes}
|
||||
{::bmh::layout::GermanDataSegmentBegin, 4, Kind::keep, 0, {0x01,0x01,0x01,0x00}},
|
||||
{::bmh::layout::DeskDrawers_Recent_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation162, {}},
|
||||
{::bmh::layout::IncomingTransfer_RenderAtElapsed_TextPointer, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation244, {}},
|
||||
{::bmh::layout::TransferMarket_Rect_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation245, {}},
|
||||
{::bmh::layout::TransferMarket_Rect_TextPointer2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation248, {}},
|
||||
{::bmh::layout::TransferMarket_Rect_ExecutableField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation249, {}},
|
||||
{::bmh::layout::TransferMarket_Rect_ExecutableField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation250, {}},
|
||||
{::bmh::layout::Fltd_Layout_TextPointer, 3, Kind::own_text, 0, {}}, // V2.24 format string of the transfer screens (in DE also used by the supported rule profile patch FltdMapOperation; EN pair still to find)
|
||||
{::bmh::layout::Fltd_Layout_TextPointer2, 3, Kind::own_text, 0, {}}, // V2.24 format string of the transfer screens
|
||||
{::bmh::layout::Fltd_Layout_TextPointer3, 2, Kind::own_text, 0, {}}, // V2.24 format string of the transfer screens
|
||||
{::bmh::layout::Fltd_Layout_TextPointer4, 3, Kind::own_text, 0, {}}, // V2.24 format string of the transfer screens
|
||||
{::bmh::layout::Fltd_Layout_TextPointer5, 20, Kind::own_text, 0, {}}, // 'Wettbewerb gesperrt' (V2.24, date text of DeskDate2; EN 677 has none)
|
||||
{::bmh::layout::LeaguePairings_DateString_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation5, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation6, {}},
|
||||
{::bmh::layout::Calendar_Information_ExecutableField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation158, {}},
|
||||
{::bmh::layout::Calendar_Information_TextPointer, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation159, {}},
|
||||
{::bmh::layout::ClubInfo_Raw_ExecutableField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation164, {}},
|
||||
{::bmh::layout::Contracts_RenderRoster_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation165, {}},
|
||||
{::bmh::layout::ClubInfo_Render_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation166, {}},
|
||||
{::bmh::layout::ClubInfo_Render_ExecutableField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation167, {}},
|
||||
{::bmh::layout::ClubInfo_Render_ExecutableField2, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation168, {}},
|
||||
{::bmh::layout::ClubInfo_Render_ExecutableField3, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation169, {}},
|
||||
{::bmh::layout::ClubInfo_Render_ExecutableField4, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation170, {}},
|
||||
{::bmh::layout::ClubInfo_Render_ExecutableField5, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation171, {}},
|
||||
{::bmh::layout::ClubInfo_Raw_ExecutableField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation172, {}},
|
||||
{::bmh::layout::Contracts_RenderRoster_ExecutableField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation173, {}},
|
||||
{::bmh::layout::Contracts_RenderRoster_ExecutableField3, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation174, {}},
|
||||
{::bmh::layout::Contracts_RenderRoster_ExecutableField4, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation175, {}},
|
||||
{::bmh::layout::IncomingTransfer_RenderAtElapsed_ExecutableField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation121, {}},
|
||||
{::bmh::layout::ContractExpiryWarningText, 75, Kind::own_text, 0, {}}, // Contract warnings are read from each edition's own runtime field.
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField, 75, Kind::own_text, 0, {}}, // pending offer notice (Void3, no EN pair)
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField2, 16, Kind::own_text, 0, {}}, // pending offer notice
|
||||
{::bmh::layout::CareerSession_FormatNumber_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation141, {}},
|
||||
{::bmh::layout::Stadium_FormatError_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation142, {}},
|
||||
{::bmh::layout::Stadium_FormatError_ExecutableField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation146, {}},
|
||||
{::bmh::layout::Stadium_Out_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation147, {}},
|
||||
{::bmh::layout::Stadium_RenderBlockExpansion_TextPointer, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation148, {}},
|
||||
{::bmh::layout::CareerSession_FormatNumber_TextPointer, 2, Kind::own_text, 0, {}}, // '(' of '(# Rabatt)', V2.24 stadium discount (ConstructionPricePercent; not in EN 28b6d)
|
||||
{::bmh::layout::CareerSession_FormatNumber_ExecutableField2, 10, Kind::own_text, 0, {}}, // '# Rabatt)' V2.24
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField3, 49, Kind::own_text, 0, {}}, // 'Der Sponsor fuehlt sich ausgenutzt ...' V2.24 (PayConstruction; not in EN 2b38d)
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField4, 26, Kind::own_text, 0, {}}, // ' Prozent der Kaufsumme' V2.24
|
||||
{::bmh::layout::ClubPlayerDetail_Copy_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation302, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_RenderCard_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation303, {}},
|
||||
{::bmh::layout::Contracts_Out_TextPointer, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation148, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_Copy_TextPointer, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation305, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_Copy_TextPointer2, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation306, {}},
|
||||
{::bmh::layout::CurrencySuffixText, 4, Kind::own_text, 0, {}}, // ' EU' currency suffix (FormatNumber; EN FormatAmount formats money without a suffix string)
|
||||
{::bmh::layout::Bank_OriginalToUtf8_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation193, {}},
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField5, 5, Kind::own_text, 0, {}}, // 'AUTO' (NeedsInitialization; not in EN 43100: V2.24 training automation)
|
||||
{::bmh::layout::Bank_FormatError_ExecutableField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation148, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation203, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_ExecutableField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation204, {}},
|
||||
{::bmh::layout::Bank_DrawPropertyCard_TextPointer, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation205, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_ExecutableField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation216, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_ExecutableField4, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation217, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_TextPointer2, 19, Kind::copy, ::bmh::layout::EnglishLayoutTranslation218, {}},
|
||||
{::bmh::layout::GermanLayoutTranslation, 11, Kind::copy, ::bmh::layout::EnglishLayoutTranslation219, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation96, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer3, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation97, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer4, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation98, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer5, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation99, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer6, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation100, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer7, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation101, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer8, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation102, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer9, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation103, {}},
|
||||
{::bmh::layout::LeagueTable_Glyph_TextPointer, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation104, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer10, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation105, {}},
|
||||
{::bmh::layout::CupDraw_DrawGroupOverview_TextPointer11, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation106, {}},
|
||||
{::bmh::layout::CareerSession_FormatError_TextPointer, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation109, {}},
|
||||
{::bmh::layout::LeaguePairings_Fill_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation110, {}},
|
||||
{::bmh::layout::LeaguePairings_FormatError_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation111, {}},
|
||||
{::bmh::layout::LeaguePairings_FormatError_ExecutableField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation112, {}},
|
||||
{::bmh::layout::LeaguePairings_FormatError_TextPointer2, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation219, {}},
|
||||
{::bmh::layout::LeaguePairings_FormatError_TextPointer3, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation149, {}},
|
||||
{::bmh::layout::Strengths_Fill_TextPointer, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation118, {}},
|
||||
{::bmh::layout::SaveLoad_Render_ExecutableField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation300, {}},
|
||||
{::bmh::layout::SaveLoad_Render_TextPointer, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation205, {}},
|
||||
{::bmh::layout::BalancePlan_DrawRows_TextPointer, 3, Kind::own_text, 0, {}}, // balance plan (Redraw, V2.24 balance plan)
|
||||
{::bmh::layout::Advertising_FormatError_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation123, {}},
|
||||
{::bmh::layout::Advertising_FormatError_ExecutableField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation128, {}},
|
||||
{::bmh::layout::Advertising_FormatError_ExecutableField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation129, {}},
|
||||
{::bmh::layout::Advertising_String_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation130, {}},
|
||||
{::bmh::layout::CupDraw_FormatError_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation44, {}},
|
||||
{::bmh::layout::CupDraw_FormatError_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation45, {}},
|
||||
{::bmh::layout::CupDraw_FormatError_ExecutableField2, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation46, {}},
|
||||
{::bmh::layout::CupDraw_FormatError_TextPointer2, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation47, {}},
|
||||
{::bmh::layout::CupDraw_FormatError_TextPointer3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation48, {}},
|
||||
{::bmh::layout::RealityReporter_Font_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation49, {}}, // reporter word separator (DE RealityReporterPanel3 / EN dcb4)
|
||||
{::bmh::layout::Fltd_Layout_ExecutableField6, 2, Kind::own_text, 0, {}}, // '-' (RealityReporterPanel2; EN dc3f only has ' ')
|
||||
{::bmh::layout::SeriesRecords_Render_ExecutableField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation68, {}},
|
||||
{::bmh::layout::DeskRecords_FillRect_ExecutableField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation69, {}},
|
||||
{::bmh::layout::SeriesRecords_Render_ExecutableField4, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation70, {}},
|
||||
{::bmh::layout::TeamStatistics_Render_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation72, {}},
|
||||
{::bmh::layout::DeskDrawers_Curve_ExecutableField, 24, Kind::copy, ::bmh::layout::EnglishLayoutTranslation160, {}},
|
||||
{::bmh::layout::DeskState_FormatError_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation161, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation224, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation225, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField3, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation226, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField4, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation227, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField5, 11, Kind::copy, ::bmh::layout::EnglishLayoutTranslation228, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField6, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation229, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField7, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation230, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField8, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation231, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField9, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation232, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField10, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation233, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField11, 72, Kind::copy, ::bmh::layout::EnglishLayoutTranslation234, {}},
|
||||
{::bmh::layout::Tactics_DrawSetting_RuntimeField12, 71, Kind::copy, ::bmh::layout::EnglishLayoutTranslation235, {}},
|
||||
{::bmh::layout::Tactics_Click_RuntimeField, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation236, {}},
|
||||
{::bmh::layout::Tactics_Click_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation237, {}},
|
||||
{::bmh::layout::Tactics_Click_RuntimeField3, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation238, {}},
|
||||
{::bmh::layout::Tactics_Click_RuntimeField4, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation239, {}},
|
||||
{::bmh::layout::Tactics_Click_RuntimeField5, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation240, {}},
|
||||
{::bmh::layout::CareerSession_DispatchLiveTactic_RuntimeField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation241, {}},
|
||||
{::bmh::layout::Tactics_Click_RuntimeField6, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation242, {}},
|
||||
{::bmh::layout::CareerSession_DispatchLiveTactic_RuntimeField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation243, {}},
|
||||
{::bmh::layout::TransferMarket_Click_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation246, {}},
|
||||
{::bmh::layout::TransferMarket_Click_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation246, {}},
|
||||
{::bmh::layout::TransferMarket_Click_RuntimeField3, 74, Kind::copy, ::bmh::layout::EnglishLayoutTranslation247, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField, 144, Kind::empty_pointers, 0, {}},
|
||||
{::bmh::layout::Analytics_FormatError_ExecutableField, 72, Kind::copy, ::bmh::layout::EnglishLayoutTranslation50, {}}, // EN196f1: graph labels, distinct from fund-name suffixes
|
||||
{::bmh::layout::AdGroupId, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation51, {}},
|
||||
{::bmh::layout::GameEnd_SourceHyphenator_ExecutableField, 18, Kind::copy, ::bmh::layout::EnglishLayoutTranslation52, {}},
|
||||
{::bmh::layout::GameEnd_SourceHyphenator_RuntimeField, 120, Kind::copy, ::bmh::layout::EnglishLayoutTranslation53, {}},
|
||||
{::bmh::layout::CareerSession_DispatchSettings_RuntimeField, 20, Kind::copy, ::bmh::layout::EnglishLayoutTranslation54, {}},
|
||||
{::bmh::layout::SaveLoad_Render_RuntimeField, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation55, {}},
|
||||
{::bmh::layout::SaveLoad_Render_RuntimeField2, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation56, {}},
|
||||
{::bmh::layout::SaveLoad_Render_RuntimeField3, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation57, {}},
|
||||
{::bmh::layout::DeskActions_ConfigureTrainingCampData_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation58, {}},
|
||||
{::bmh::layout::Difficulty, 1, Kind::keep, 0, {0x05}},
|
||||
{::bmh::layout::ManagerAutomation, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation59, {}},
|
||||
{::bmh::layout::DeskState_DeskDate_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation60, {}},
|
||||
{::bmh::layout::CalendarState_CalendarFromGame_ExecutableField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation61, {}},
|
||||
{::bmh::layout::CalendarState_CalendarFromGame_ExecutableField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation62, {}},
|
||||
{::bmh::layout::ManagerCount, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation63, {}},
|
||||
{::bmh::layout::LeaguePresentationOptions, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation64, {}},
|
||||
{::bmh::layout::CareerSession_DispatchLiveTactic_RuntimeField3, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation65, {}},
|
||||
{::bmh::layout::SeasonEntrants_SeasonEntrantsFromGame_TextPointer, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation66, {}},
|
||||
{::bmh::layout::PlainBackground, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation67, {}},
|
||||
{::bmh::layout::ActiveSelectors, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation251, {}},
|
||||
{::bmh::layout::CurrencyMultiplier, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation252, {}},
|
||||
{::bmh::layout::CurrencyDivisor, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation253, {}},
|
||||
{::bmh::layout::CompetitionCalendar, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation254, {}},
|
||||
{::bmh::layout::LeagueCalendarBits, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation255, {}},
|
||||
{::bmh::layout::EventPasses, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation256, {}},
|
||||
{::bmh::layout::CareerSession_BeginFriendlyOpponentTable_RuntimeField, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation257, {}},
|
||||
{::bmh::layout::LeagueSizes, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation258, {}},
|
||||
{::bmh::layout::LeaguePairings_LeaguePairingsConstants_RuntimeField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation259, {}},
|
||||
{::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation260, {}},
|
||||
{::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField2, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation261, {}},
|
||||
{::bmh::layout::DeskDrawers_Curve_RuntimeField, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation262, {}},
|
||||
{::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation264, {}},
|
||||
{::bmh::layout::Manager_FormatError_RuntimeField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation263, {}},
|
||||
{::bmh::layout::CalendarLeagueCounts, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation265, {}},
|
||||
{::bmh::layout::LeaguePairings_SelectorEvent_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation266, {}},
|
||||
{::bmh::layout::CalendarFirstLeague, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation267, {}},
|
||||
{::bmh::layout::CareerSession_FormatError_RuntimeField4, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation268, {}},
|
||||
{::bmh::layout::GermanLayoutTranslation2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation269, {}},
|
||||
{::bmh::layout::GermanLayoutTranslation3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation270, {}},
|
||||
{::bmh::layout::TeamsWithSquads, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation271, {}},
|
||||
{::bmh::layout::CareerSession_DispatchLineup_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation272, {}},
|
||||
{::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation273, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation274, {}},
|
||||
{::bmh::layout::NoTeamSquadStart, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation275, {}},
|
||||
{::bmh::layout::CareerSession_DataDirectory_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation276, {}},
|
||||
{::bmh::layout::CareerSession_DataDirectory_RuntimeField2, 12, Kind::copy, ::bmh::layout::EnglishLayoutTranslation277, {}},
|
||||
{::bmh::layout::CareerSession_DataDirectory_RuntimeField3, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation278, {}},
|
||||
{::bmh::layout::CareerSession_DataDirectory_RuntimeField4, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation279, {}},
|
||||
{::bmh::layout::CupTable, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation280, {}},
|
||||
{::bmh::layout::SeasonPromotion_FormatError_RuntimeField, 26, Kind::copy, ::bmh::layout::EnglishLayoutTranslation281, {}},
|
||||
{::bmh::layout::Advertising_PatternRect_RuntimeField, 256, Kind::copy, ::bmh::layout::EnglishLayoutTranslation282, {}},
|
||||
{::bmh::layout::LiveMatchday_PatternRect_RuntimeField, 497, Kind::copy, ::bmh::layout::EnglishLayoutTranslation283, {}},
|
||||
{::bmh::layout::TextGradientMode, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation28, {}},
|
||||
{::bmh::layout::AlternateEventRoll, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation29, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation30, {}},
|
||||
{::bmh::layout::CompactDialogFrame, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation31, {}},
|
||||
{::bmh::layout::CareerSession_DispatchStadium_RuntimeField, 64, Kind::copy, ::bmh::layout::EnglishLayoutTranslation32, {}},
|
||||
{::bmh::layout::OutgoingTransfer_Line_RuntimeField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation33, {}},
|
||||
{::bmh::layout::OriginalManagerCount, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation34, {}},
|
||||
{::bmh::layout::CoachActive, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation35, {}},
|
||||
{::bmh::layout::Career_BuildStadium_RuntimeField, 115, Kind::copy, ::bmh::layout::EnglishLayoutTranslation36, {}},
|
||||
{::bmh::layout::CareerSession_DispatchStadium_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation37, {}},
|
||||
{::bmh::layout::Career_BuildStadium_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation38, {}},
|
||||
{::bmh::layout::Career_BuildStadium_RuntimeField3, 147, Kind::copy, ::bmh::layout::EnglishLayoutTranslation39, {}},
|
||||
{::bmh::layout::TableFlags, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation40, {}},
|
||||
{::bmh::layout::TeamStatistics_Render_RuntimeField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation41, {}},
|
||||
{::bmh::layout::Savestate_Layout_ExecutableField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation42, {}},
|
||||
{::bmh::layout::Advertising_Text_RuntimeField, 210, Kind::copy, ::bmh::layout::EnglishLayoutTranslation43, {}},
|
||||
{::bmh::layout::SeriesSelector, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation74, {}}, // EN175bf: current/best streak column selectors
|
||||
{::bmh::layout::WorldCupStatistics_FormatError_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation75, {}}, // EN184a8: national-badge bank segment counts
|
||||
{::bmh::layout::WorldCupStatistics_FormatError_RuntimeField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation76, {}},
|
||||
{::bmh::layout::WorldCupStatistics_FormatError_RuntimeField3, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation77, {}},
|
||||
{::bmh::layout::Analytics_FormatError_RuntimeField, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation78, {}},
|
||||
{::bmh::layout::Analytics_Render_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation79, {}},
|
||||
{::bmh::layout::Analytics_Render_RuntimeField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation80, {}},
|
||||
{::bmh::layout::Analytics_FormatError_RuntimeField2, 18, Kind::copy, ::bmh::layout::EnglishLayoutTranslation81, {}}, // graph count classes: EN pads two bytes after its y coordinates
|
||||
{::bmh::layout::Analytics_Render_RuntimeField3, 16, Kind::copy, ::bmh::layout::EnglishLayoutTranslation82, {}},
|
||||
{::bmh::layout::Analytics_FormatError_RuntimeField3, 72, Kind::copy, ::bmh::layout::EnglishLayoutTranslation83, {}},
|
||||
{::bmh::layout::Analytics_FormatError_RuntimeField4, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation84, {}},
|
||||
{::bmh::layout::Opportunities_Render_RuntimeField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation85, {}}, // EN1a334 rank colours
|
||||
{::bmh::layout::Opportunities_Render_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation86, {}},
|
||||
{::bmh::layout::Opportunities_Render_RuntimeField3, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation87, {}},
|
||||
{::bmh::layout::Opportunities_FormatError_RuntimeField, 18, Kind::copy, ::bmh::layout::EnglishLayoutTranslation88, {}}, // EN1a7d9: nine left/right/top/bottom cells; EN pads each table
|
||||
{::bmh::layout::Opportunities_FormatError_RuntimeField2, 18, Kind::copy, ::bmh::layout::EnglishLayoutTranslation89, {}},
|
||||
{::bmh::layout::Opportunities_FormatError_RuntimeField3, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation90, {}},
|
||||
{::bmh::layout::Opportunities_StatisticsWindow_RuntimeField, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation91, {}},
|
||||
{::bmh::layout::Advertising_Text_RuntimeField2, 33, Kind::copy, ::bmh::layout::EnglishLayoutTranslation92, {}},
|
||||
{::bmh::layout::CupDraw_GroupMarker_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation, {}},
|
||||
{::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField10, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation2, {}},
|
||||
{::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField11, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation3, {}},
|
||||
{::bmh::layout::Career_CompetitionPointers_RuntimeField4, 5, Kind::keep, 0, {0x00,0x06,0x0c,0x0e,0x0f}},
|
||||
{::bmh::layout::Career_CompetitionPointers_RuntimeField5, 5, Kind::keep, 0, {0x00,0x04,0x08,0x0c,0x0e}},
|
||||
{::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField12, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation4, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation150, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField2, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation151, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField3, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation152, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField4, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation153, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField5, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation154, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField6, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation155, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_ClubPlayerDetailRedraw_RuntimeField2, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation156, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_DrawPortrait_RuntimeField7, 10, Kind::copy, ::bmh::layout::EnglishLayoutTranslation157, {}},
|
||||
{::bmh::layout::Pitch_Render_RuntimeField, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation163, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation176, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation177, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_ExecutableField3, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation178, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_RuntimeField, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation179, {}},
|
||||
{::bmh::layout::SeasonEntrants_FormatError_TextPointer, 9, Kind::keep, 0, {0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01}},
|
||||
{::bmh::layout::LiveMatchday_Render_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation180, {}},
|
||||
{::bmh::layout::LiveMatchday_Render_RuntimeField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation181, {}},
|
||||
{::bmh::layout::LiveMatchday_Render_RuntimeField3, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation182, {}},
|
||||
{::bmh::layout::IncomingTransfer_OutcomeFrameAt_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation120, {}},
|
||||
{::bmh::layout::IncomingTransfer_RenderAtElapsed_RuntimeField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation122, {}},
|
||||
{::bmh::layout::CareerSession_FormatError_RuntimeField5, 20, Kind::keep, 0, {0x14,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00}},
|
||||
{::bmh::layout::Stadium_Out_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation143, {}},
|
||||
{::bmh::layout::Stadium_Out_RuntimeField2, 30, Kind::copy, ::bmh::layout::EnglishLayoutTranslation144, {}},
|
||||
{::bmh::layout::CareerSession_Invalid_RuntimeField, 11, Kind::copy, ::bmh::layout::EnglishLayoutTranslation145, {}},
|
||||
{::bmh::layout::Contracts_Out_TextPointer2, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation301, {}},
|
||||
{::bmh::layout::PlayerCard_PlayerCardMarketValue_RuntimeField, 10, Kind::copy, ::bmh::layout::EnglishLayoutTranslation304, {}},
|
||||
{::bmh::layout::ClubPlayerDetail_Copy_RuntimeField, 6, Kind::keep, 0, {0x56,0x56,0x76,0x76,0x9e,0x9e}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation307, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation308, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField3, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation309, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField4, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation310, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField5, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation311, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField6, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation312, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField7, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation313, {}},
|
||||
{::bmh::layout::MailboxScreen_Click_RuntimeField8, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation314, {}},
|
||||
{::bmh::layout::MailboxScreen_Render_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation315, {}},
|
||||
{::bmh::layout::MailboxScreen_Render_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation316, {}},
|
||||
{::bmh::layout::MailboxScreen_Render_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation317, {}},
|
||||
{::bmh::layout::MailboxScreen_Render_RuntimeField4, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation318, {}},
|
||||
{::bmh::layout::ProcessTimer_FormatError_RuntimeField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation284, {}},
|
||||
{::bmh::layout::Advertising_Button_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation299, {}},
|
||||
{::bmh::layout::Training_Render_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation183, {}},
|
||||
{::bmh::layout::Training_Render_TextPointer, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation184, {}},
|
||||
{::bmh::layout::Training_Render_TextPointer2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation185, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation186, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField2, 8, Kind::keep, 0, {0x61,0x00,0x9a,0x00,0x24,0x01,0x08,0x01}},
|
||||
{::bmh::layout::Training_Click_RuntimeField3, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation187, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField4, 4, Kind::keep, 0, {0xac,0xac,0xd7,0xd7}},
|
||||
{::bmh::layout::Training_Click_RuntimeField5, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation188, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField6, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation189, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField7, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation190, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField8, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation191, {}},
|
||||
{::bmh::layout::Training_Click_RuntimeField9, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation192, {}},
|
||||
{::bmh::layout::Advertising_Click_RuntimeField, 48, Kind::copy, ::bmh::layout::EnglishLayoutTranslation194, {}},
|
||||
{::bmh::layout::Advertising_Click_RuntimeField2, 24, Kind::copy, ::bmh::layout::EnglishLayoutTranslation195, {}},
|
||||
{::bmh::layout::GameEndAlternate_FormatError_ExecutableField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation196, {}},
|
||||
{::bmh::layout::TrainingCamp_ResortDetails_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation197, {}},
|
||||
{::bmh::layout::TrainingCamp_FocusControls_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation198, {}},
|
||||
{::bmh::layout::TrainingCamp_Click_RuntimeField, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation199, {}},
|
||||
{::bmh::layout::TrainingCamp_Click_RuntimeField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation200, {}},
|
||||
{::bmh::layout::TrainingCamp_FocusControls_RuntimeField2, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation201, {}},
|
||||
{::bmh::layout::TrainingCamp_FocusControls_TextPointer, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation202, {}},
|
||||
{::bmh::layout::Bank_FinishCredit_RuntimeField, 16, Kind::copy, ::bmh::layout::EnglishLayoutTranslation206, {}},
|
||||
{::bmh::layout::Bank_FinishCredit_RuntimeField2, 16, Kind::copy, ::bmh::layout::EnglishLayoutTranslation207, {}},
|
||||
{::bmh::layout::Bank_FinishCredit_RuntimeField3, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation208, {}},
|
||||
{::bmh::layout::Bank_FinishCredit_RuntimeField4, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation209, {}},
|
||||
{::bmh::layout::Bank_FormatError_RuntimeField, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation210, {}},
|
||||
{::bmh::layout::Bank_FormatError_RuntimeField2, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation211, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField2, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation212, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField3, 15, Kind::copy, ::bmh::layout::EnglishLayoutTranslation213, {}},
|
||||
{::bmh::layout::Bank_OriginalToUtf8_RuntimeField4, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation214, {}},
|
||||
{::bmh::layout::Bank_FormatError_RuntimeField14, 52, Kind::copy, ::bmh::layout::EnglishLayoutTranslation215, {}},
|
||||
{::bmh::layout::BankCredit_BankCreditContext_RuntimeField3, 49, Kind::copy, ::bmh::layout::EnglishLayoutTranslation220, {}},
|
||||
{::bmh::layout::Bank_FormatError_RuntimeField15, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation221, {}},
|
||||
{::bmh::layout::Bank_FormatError_RuntimeField16, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation222, {}},
|
||||
{::bmh::layout::Bank_FormatError_RuntimeField17, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation223, {}},
|
||||
{::bmh::layout::LeaguePairings_Fill_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation93, {}},
|
||||
{::bmh::layout::LeaguePairings_Fill_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation94, {}},
|
||||
{::bmh::layout::CareerSession_DispatchLeagueTableControl_RuntimeField, 10, Kind::copy, ::bmh::layout::EnglishLayoutTranslation95, {}},
|
||||
{::bmh::layout::LeaguePairings_SelectorEvent_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation107, {}},
|
||||
{::bmh::layout::LeaguePairings_SelectorEvent_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation108, {}},
|
||||
{::bmh::layout::LeaguePairings_Selector_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation113, {}},
|
||||
{::bmh::layout::LeaguePairings_Selector_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation114, {}},
|
||||
{::bmh::layout::LeaguePairings_Selector_RuntimeField3, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation115, {}},
|
||||
{::bmh::layout::LeaguePairings_Selector_RuntimeField4, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation116, {}},
|
||||
{::bmh::layout::Strengths_PointerDown_RuntimeField, 9, Kind::copy, ::bmh::layout::EnglishLayoutTranslation117, {}},
|
||||
{::bmh::layout::Strengths_Fill_RuntimeField3, 16, Kind::copy, ::bmh::layout::EnglishLayoutTranslation119, {}},
|
||||
{::bmh::layout::Settings_Letter_TextPointer, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation285, {}},
|
||||
{::bmh::layout::Settings_ProjectSettingsAvailability_RuntimeField, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation286, {}},
|
||||
{::bmh::layout::Settings_ProjectSettingsAvailability_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation287, {}},
|
||||
{::bmh::layout::Settings_ProjectSettingsAvailability_RuntimeField3, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation288, {}},
|
||||
{::bmh::layout::Settings_ProjectSettingsAvailability_RuntimeField4, 57, Kind::copy, ::bmh::layout::EnglishLayoutTranslation289, {}},
|
||||
{::bmh::layout::SportschauRating_SportschauRatingTables_RuntimeField, 27, Kind::copy, ::bmh::layout::EnglishLayoutTranslation290, {}}, // Sportschau rating tables (added by hand, see manual.txt)
|
||||
{::bmh::layout::SportschauRating_SportschauRatingTables_RuntimeField7, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation291, {}}, // Sportschau award ends + timeline (EN: one padding byte more)
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation9, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField2, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation10, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField3, 16, Kind::copy, ::bmh::layout::EnglishLayoutTranslation11, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField4, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation12, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField5, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation13, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField6, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation14, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField7, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation15, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField8, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation16, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField9, 3, Kind::copy, ::bmh::layout::EnglishLayoutTranslation17, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField10, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation18, {}},
|
||||
{::bmh::layout::Setup_FormatError_RuntimeField11, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation19, {}},
|
||||
{::bmh::layout::BalancePlan_DrawRows_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation20, {}},
|
||||
{::bmh::layout::BalancePlan_DrawRows_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation21, {}},
|
||||
{::bmh::layout::BalancePlan_DrawRows_TextPointer2, 6, Kind::copy, ::bmh::layout::EnglishLayoutTranslation22, {}},
|
||||
{::bmh::layout::Manager_FormatError_RuntimeField2, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation23, {}},
|
||||
{::bmh::layout::Manager_FormatError_RuntimeField3, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation24, {}},
|
||||
{::bmh::layout::Manager_FormatError_RuntimeField4, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation25, {}},
|
||||
{::bmh::layout::Manager_FormatError_RuntimeField5, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation26, {}},
|
||||
{::bmh::layout::Manager_FormatError_RuntimeField6, 23, Kind::copy, ::bmh::layout::EnglishLayoutTranslation27, {}},
|
||||
{::bmh::layout::Advertising_FormatError_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation124, {}},
|
||||
{::bmh::layout::Advertising_FormatError_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation125, {}},
|
||||
{::bmh::layout::Advertising_FormatError_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation126, {}},
|
||||
{::bmh::layout::Advertising_FormatError_RuntimeField4, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation127, {}},
|
||||
{::bmh::layout::Advertising_Click_RuntimeField3, 28, Kind::copy, ::bmh::layout::EnglishLayoutTranslation131, {}},
|
||||
{::bmh::layout::Advertising_Render_RuntimeField, 12, Kind::copy, ::bmh::layout::EnglishLayoutTranslation132, {}},
|
||||
{::bmh::layout::Advertising_Click_RuntimeField4, 28, Kind::copy, ::bmh::layout::EnglishLayoutTranslation133, {}},
|
||||
{::bmh::layout::Advertising_Render_RuntimeField2, 12, Kind::copy, ::bmh::layout::EnglishLayoutTranslation134, {}},
|
||||
{::bmh::layout::Advertising_Click_RuntimeField5, 28, Kind::copy, ::bmh::layout::EnglishLayoutTranslation135, {}},
|
||||
{::bmh::layout::Advertising_Render_RuntimeField3, 12, Kind::copy, ::bmh::layout::EnglishLayoutTranslation136, {}},
|
||||
{::bmh::layout::Advertising_Click_RuntimeField6, 28, Kind::copy, ::bmh::layout::EnglishLayoutTranslation137, {}},
|
||||
{::bmh::layout::Advertising_Render_RuntimeField4, 12, Kind::copy, ::bmh::layout::EnglishLayoutTranslation138, {}},
|
||||
{::bmh::layout::Advertising_Render_RuntimeField5, 5, Kind::copy, ::bmh::layout::EnglishLayoutTranslation139, {}},
|
||||
{::bmh::layout::Advertising_Render_RuntimeField6, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation140, {}},
|
||||
{::bmh::layout::ForeignPlayerLimitEnabled, 128, Kind::copy, ::bmh::layout::EnglishLayoutTranslation292, {}},
|
||||
{::bmh::layout::ClubInfo_Raw_RuntimeField, 1, Kind::keep, 0, {0x01}},
|
||||
{::bmh::layout::ClubInfo_Raw_RuntimeField2, 96, Kind::copy, ::bmh::layout::EnglishLayoutTranslation293, {}},
|
||||
{::bmh::layout::Desktop_Key_RuntimeField, 30, Kind::copy, ::bmh::layout::EnglishLayoutTranslation294, {}},
|
||||
{::bmh::layout::ClubInfo_Raw_RuntimeField3, 159, Kind::copy, ::bmh::layout::EnglishLayoutTranslation295, {}},
|
||||
{::bmh::layout::MatchEventsDisabled, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation296, {}},
|
||||
{::bmh::layout::CareerSession_FormatError_RuntimeField7, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation297, {}},
|
||||
{::bmh::layout::LiveMatchday_Render_ExecutableField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation298, {}},
|
||||
{::bmh::layout::CupDraw_FormatError_ExecutableField3, 36, Kind::copy, ::bmh::layout::EnglishLayoutTranslation45, {}},
|
||||
{::bmh::layout::Career_BuildStadium_RuntimeField4, 8, Kind::copy, ::bmh::layout::EnglishLayoutTranslation7, {}},
|
||||
{::bmh::layout::Career_CareerAddManager_ExecutableField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation8, {}},
|
||||
{::bmh::layout::TeamStatistics_Render_RuntimeField2, 35, Kind::copy, ::bmh::layout::EnglishLayoutTranslation71, {}},
|
||||
{::bmh::layout::Desktop_Copy_TextPointer, 1, Kind::keep, 0, {0xfb}},
|
||||
{::bmh::layout::Desktop_Copy_TextPointer2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation73, {}},
|
||||
@@ -0,0 +1,470 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "launch/game_data.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <system_error>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/m3d.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/fltd.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string upper(std::string s) {
|
||||
for (char& c : s) c = char(std::toupper(static_cast<unsigned char>(c)));
|
||||
return s;
|
||||
}
|
||||
|
||||
// The data files every version has (the German editions and the English one share the
|
||||
// pictures, fonts and sounds; checked against the CD, the nine edition packages and FTL).
|
||||
constexpr int kPictures[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
|
||||
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
||||
64, 65, 66, 67, 68, 69, 70, 74, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139};
|
||||
constexpr int kBadges[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 18, 19, 20, 44, 45, 46, 47, 48, 49, 50, 51, 52};
|
||||
|
||||
struct Required {
|
||||
const char* name;
|
||||
uint64_t size; // 0: any size above zero
|
||||
};
|
||||
constexpr Required kCommon[] = {{"M3.DAT", 1408}, {"M3.MEN", 864}, {"M3PC.COL", 768}};
|
||||
|
||||
// Game EXEs by family. The German ones all have 602,527 bytes; the hashes differ between
|
||||
// the editions, so only the size is required.
|
||||
struct Family {
|
||||
GameFamily family;
|
||||
const char* exe;
|
||||
uint64_t exe_size;
|
||||
const char* texts;
|
||||
const char* database;
|
||||
};
|
||||
constexpr Family kFamilies[] = {
|
||||
{GameFamily::german, "BMH.EXE", 602527, "TEXTD.BLK", "M3D.MAN"},
|
||||
{GameFamily::english, "FLTD.EXE", 507925, "TEXTE.BLK", "M3E.MAN"},
|
||||
{GameFamily::disk1994, "M3.EXE", 0, "", "M3PC.MAN"},
|
||||
};
|
||||
|
||||
std::optional<Family> family_of_exe(const std::string& file_name) {
|
||||
const std::string u = upper(file_name);
|
||||
for (const Family& f : kFamilies)
|
||||
if (u == f.exe) return f;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Every game EXE directly in `directory`.
|
||||
std::vector<std::pair<Family, fs::path>> game_exes(const fs::path& directory) {
|
||||
std::vector<std::pair<Family, fs::path>> out;
|
||||
std::error_code ec;
|
||||
for (const auto& e : fs::directory_iterator(directory, ec)) {
|
||||
if (!e.is_regular_file(ec)) continue;
|
||||
if (auto f = family_of_exe(path_to_utf8(e.path().filename()))) out.emplace_back(*f, e.path());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void require(GameCheck& c, const fs::path& dir, const std::string& name, uint64_t size, const std::string& shown) {
|
||||
const auto p = find_file(dir, name);
|
||||
if (!p) {
|
||||
c.problems.push_back(shown + " is missing");
|
||||
return;
|
||||
}
|
||||
std::error_code ec;
|
||||
const uint64_t actual = fs::file_size(*p, ec);
|
||||
if (ec || actual == 0) c.problems.push_back(shown + " is empty or unreadable");
|
||||
else if (size != 0 && actual != size)
|
||||
c.problems.push_back(shown + " has " + std::to_string(actual) + " bytes instead of " + std::to_string(size));
|
||||
}
|
||||
|
||||
// The shared picture/font/sound files of the sub directories KB, W, F and S.
|
||||
void require_media(GameCheck& c) {
|
||||
const auto sub = [&](const char* name) -> std::optional<fs::path> {
|
||||
auto p = find_file(c.directory, name);
|
||||
if (!p || !fs::is_directory(*p)) {
|
||||
c.problems.push_back(std::string("the directory ") + name + " is missing");
|
||||
return std::nullopt;
|
||||
}
|
||||
return p;
|
||||
};
|
||||
// (a long list of missing files says less than the count and the first ones)
|
||||
const auto files = [&](const fs::path& dir, const char* shown, const std::vector<std::string>& names) {
|
||||
std::vector<std::string> missing;
|
||||
for (const auto& n : names)
|
||||
if (!find_file(dir, n)) missing.push_back(n);
|
||||
if (missing.empty()) return;
|
||||
std::string text = std::string(shown) + ": " + std::to_string(missing.size()) + " file(s) missing (";
|
||||
for (size_t i = 0; i < missing.size() && i < 5; ++i) text += (i ? ", " : "") + missing[i];
|
||||
c.problems.push_back(text + (missing.size() > 5 ? ", ...)" : ")"));
|
||||
};
|
||||
std::vector<std::string> names;
|
||||
if (auto kb = sub("KB")) {
|
||||
for (int n : kPictures) names.push_back(std::to_string(n) + ".VGA");
|
||||
files(*kb, "KB", names);
|
||||
}
|
||||
names.clear();
|
||||
if (auto w = sub("W")) {
|
||||
for (int n : kBadges) names.push_back(std::to_string(n) + ".VGA");
|
||||
files(*w, "W", names);
|
||||
}
|
||||
if (auto f = sub("F")) files(*f, "F", {"BMH2.FNT", "BMH3.FNT"});
|
||||
if (auto s = sub("S")) files(*s, "S", {"2000", "2001", "2002", "2003"});
|
||||
}
|
||||
|
||||
// A readable title from the text block (ISO 646-DE: the brackets are umlauts).
|
||||
std::string text_title(const std::string& raw) {
|
||||
std::string out;
|
||||
for (unsigned char ch : raw) {
|
||||
switch (ch) {
|
||||
case '[': out += "\xC3\x84"; break;
|
||||
case '\\': out += "\xC3\x96"; break;
|
||||
case ']': out += "\xC3\x9C"; break;
|
||||
case '{': out += "\xC3\xA4"; break;
|
||||
case '|': out += "\xC3\xB6"; break;
|
||||
case '}': out += "\xC3\xBC"; break;
|
||||
case '~': out += "\xC3\x9F"; break;
|
||||
default: out += ch >= 0x20 && ch < 0x7F ? char(ch) : '?';
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void check_german(GameCheck& c) {
|
||||
// (a translated English game has BMH.exe in the OpenBMH image format, launch/fltd.hpp)
|
||||
bool image = false;
|
||||
if (const auto exe = find_file(c.directory, "BMH.EXE")) {
|
||||
std::ifstream in(*exe, std::ios::binary);
|
||||
char head[13] = {};
|
||||
in.read(head, sizeof head);
|
||||
image = std::string(head, sizeof head) == "OPENBMH-IMAGE";
|
||||
}
|
||||
require(c, c.directory, "BMH.EXE", image ? 0 : 602527, "BMH.EXE");
|
||||
require(c, c.directory, "TEXTD.BLK", 0, "TEXTD.BLK");
|
||||
require(c, c.directory, "M3D.MAN", 0, "M3D.MAN");
|
||||
for (const Required& r : kCommon) require(c, c.directory, r.name, r.size, r.name);
|
||||
require_media(c);
|
||||
if (!c.problems.empty()) return;
|
||||
// the files must also load: the engine reads tables from the EXE, the texts and the
|
||||
// database of clubs and players
|
||||
try {
|
||||
load_le(*find_file(c.directory, "BMH.EXE"));
|
||||
} catch (const std::exception& e) {
|
||||
c.problems.push_back(std::string("BMH.EXE cannot be read: ") + e.what());
|
||||
}
|
||||
try {
|
||||
const TextDb texts = load_textd(*find_file(c.directory, "TEXTD.BLK"));
|
||||
// the supported rule profile editions greet with their title as the first mailbox message (text 1001);
|
||||
// the CD version has another greeting there
|
||||
c.title = "Bundesliga Manager Hattrick";
|
||||
if (texts.strings.size() > 1001 && texts.strings[1001].rfind("Bundesliga Manager", 0) == 0)
|
||||
c.title = text_title(texts.strings[1001]);
|
||||
} catch (const std::exception& e) {
|
||||
c.problems.push_back(std::string("TEXTD.BLK cannot be read: ") + e.what());
|
||||
}
|
||||
try {
|
||||
load_database(*find_file(c.directory, "M3D.MAN"));
|
||||
} catch (const std::exception& e) {
|
||||
c.problems.push_back(std::string("M3D.MAN cannot be read: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void check_english(GameCheck& c) {
|
||||
require(c, c.directory, "FLTD.EXE", 507925, "FLTD.EXE");
|
||||
require(c, c.directory, "TEXTE.BLK", 0, "TEXTE.BLK");
|
||||
require(c, c.directory, "M3E.MAN", 0, "M3E.MAN");
|
||||
for (const Required& r : kCommon) require(c, c.directory, r.name, r.size, r.name);
|
||||
require_media(c);
|
||||
c.title = "Football Limited (English)";
|
||||
}
|
||||
|
||||
// A cheap content hash (FNV-1a, 64 bit) that names the cache folder of an archive.
|
||||
std::string content_hash(const fs::path& file) {
|
||||
std::ifstream in(file, std::ios::binary);
|
||||
uint64_t h = 0xcbf29ce484222325ull;
|
||||
char buf[1 << 16];
|
||||
while (in) {
|
||||
in.read(buf, sizeof buf);
|
||||
for (std::streamsize i = 0; i < in.gcount(); ++i) h = (h ^ uint8_t(buf[i])) * 0x100000001b3ull;
|
||||
}
|
||||
char text[17];
|
||||
std::snprintf(text, sizeof text, "%016llx", static_cast<unsigned long long>(h));
|
||||
return text;
|
||||
}
|
||||
|
||||
// Whether an archive file belongs to the game data: the original file kinds, the sounds
|
||||
// (S\2000...) and savegames. Pictures, manuals and other fan extras are left out of the
|
||||
// cache (their long names also overflow the 260 characters of a Windows path).
|
||||
bool is_game_file(const std::string& relative) {
|
||||
const std::string u = upper(relative);
|
||||
const std::string base = u.substr(u.find_last_of('/') + 1);
|
||||
if (u.rfind("S/", 0) == 0 && base.find('.') == std::string::npos) return true; // sounds
|
||||
const size_t dot = base.find_last_of('.');
|
||||
if (dot == std::string::npos) return false;
|
||||
const std::string ext = base.substr(dot + 1);
|
||||
for (const char* e : {"EXE", "BLK", "MAN", "DAT", "MEN", "COL", "VGA", "FNT", "LBM", "EIN", "CFG", "FBM", "WAP"})
|
||||
if (ext == e) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_archive_name(const std::string& name) {
|
||||
const std::string u = upper(name);
|
||||
for (const char* ext : {".ZIP", ".7Z", ".ARJ", ".RAR", ".LZH", ".TAR", ".GZ"})
|
||||
if (u.size() > std::strlen(ext) && u.compare(u.size() - std::strlen(ext), std::string::npos, ext) == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unpacks the one game of an archive into the cache (or finds it there).
|
||||
ResolvedGame unpack(const fs::path& file, const fs::path& cache) {
|
||||
ResolvedGame r;
|
||||
const ArchiveFormat format = archive_format(file);
|
||||
if (format == ArchiveFormat::arj) {
|
||||
r.error = "This is an ARJ archive (the installer format of the 1994 floppy disks). OpenBMH cannot read it; "
|
||||
"please unpack the installed game.";
|
||||
return r;
|
||||
}
|
||||
if (format == ArchiveFormat::rar) {
|
||||
r.error = "RAR archives are not supported; please use ZIP or 7z.";
|
||||
return r;
|
||||
}
|
||||
try {
|
||||
Archive archive = Archive::open(file);
|
||||
const auto& entries = archive.entries();
|
||||
// exactly one game EXE; its directory is the game's root in the archive
|
||||
std::vector<size_t> exes;
|
||||
bool nested = false, installer = false;
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
if (entries[i].directory) continue;
|
||||
const std::string& n = entries[i].name;
|
||||
const std::string base = n.substr(n.find_last_of('/') + 1);
|
||||
if (family_of_exe(base)) exes.push_back(i);
|
||||
if (is_archive_name(base)) nested = true;
|
||||
if (upper(base) == "INSTALL.EXE") installer = true;
|
||||
}
|
||||
if (exes.empty()) {
|
||||
if (installer) r.error = "The archive holds an installer (INSTALL.EXE), not an installed game.";
|
||||
else if (nested) r.error = "The archive contains further archives (a box with several editions). "
|
||||
"Please choose the archive of one edition.";
|
||||
else r.error = "The archive contains no BMH.EXE or FLTD.EXE.";
|
||||
return r;
|
||||
}
|
||||
if (exes.size() > 1) {
|
||||
r.error = "The archive contains " + std::to_string(exes.size()) +
|
||||
" games. Please use an archive with exactly one game.";
|
||||
return r;
|
||||
}
|
||||
const std::string& exe_name = entries[exes[0]].name;
|
||||
const std::string root = exe_name.substr(0, exe_name.find_last_of('/') + 1); // "" or "dir/.../"
|
||||
|
||||
const fs::path target = cache / content_hash(file);
|
||||
const fs::path marker = target / ".openbmh-unpacked";
|
||||
std::error_code ec;
|
||||
if (!fs::exists(marker, ec)) {
|
||||
const fs::path temp = cache / (content_hash(file) + ".partial");
|
||||
fs::remove_all(temp, ec);
|
||||
fs::create_directories(temp);
|
||||
uint64_t total = 0;
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
const ArchiveEntry& e = entries[i];
|
||||
if (e.name.compare(0, root.size(), root) != 0 || e.name.size() == root.size()) continue;
|
||||
const std::string rel = e.name.substr(root.size());
|
||||
// no absolute paths and no way out of the target directory
|
||||
const fs::path relative = path_from_utf8(rel);
|
||||
bool safe = !relative.is_absolute() && !relative.has_root_name();
|
||||
for (const auto& part : relative) safe = safe && part != "..";
|
||||
if (!safe) throw ArchiveError("unsafe path in the archive: " + e.name);
|
||||
if (!e.directory && !is_game_file(rel)) continue;
|
||||
total += e.size;
|
||||
if (total > 256ull * 1024 * 1024) throw ArchiveError("the game in the archive is too large");
|
||||
if (e.directory) {
|
||||
fs::create_directories(temp / relative);
|
||||
continue;
|
||||
}
|
||||
fs::create_directories((temp / relative).parent_path());
|
||||
const std::vector<uint8_t> bytes = archive.read(i);
|
||||
std::ofstream out(temp / relative, std::ios::binary);
|
||||
out.write(reinterpret_cast<const char*>(bytes.data()), std::streamsize(bytes.size()));
|
||||
if (!out) throw ArchiveError("cannot write " + path_to_utf8(temp / relative));
|
||||
}
|
||||
std::ofstream(temp / ".openbmh-unpacked") << path_to_utf8(file) << "\n";
|
||||
fs::remove_all(target, ec);
|
||||
fs::rename(temp, target);
|
||||
}
|
||||
r.check = check_game_directory(target);
|
||||
r.unpacked = true;
|
||||
} catch (const std::exception& e) {
|
||||
r.error = std::string("The archive cannot be used: ") + e.what();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
ResolvedGame resolve_game_unchecked(const fs::path& input, const fs::path& cache);
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<fs::path> find_file(const fs::path& directory, const std::string& name) {
|
||||
std::error_code ec;
|
||||
const fs::path exact = directory / path_from_utf8(name);
|
||||
if (fs::exists(exact, ec)) return exact;
|
||||
const std::string wanted = upper(name);
|
||||
for (const auto& e : fs::directory_iterator(directory, ec))
|
||||
if (upper(path_to_utf8(e.path().filename())) == wanted) return e.path();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
GameCheck check_game_directory(const fs::path& path) {
|
||||
GameCheck c;
|
||||
std::error_code ec;
|
||||
fs::path dir = fs::is_directory(path, ec) ? path : path.parent_path();
|
||||
auto exes = game_exes(dir);
|
||||
if (exes.empty()) {
|
||||
// an edition folder with the game one level below (e.g. "BMH 2026-27 supported rule profile\BMH")
|
||||
std::vector<fs::path> candidates;
|
||||
for (const auto& e : fs::directory_iterator(dir, ec))
|
||||
if (e.is_directory(ec) && !game_exes(e.path()).empty()) candidates.push_back(e.path());
|
||||
if (candidates.size() == 1) {
|
||||
dir = candidates[0];
|
||||
exes = game_exes(dir);
|
||||
}
|
||||
}
|
||||
c.directory = dir;
|
||||
if (exes.empty()) {
|
||||
c.problems.push_back("no BMH.EXE or FLTD.EXE in " + path_to_utf8(dir));
|
||||
return c;
|
||||
}
|
||||
// a named EXE decides; otherwise the German game before the English one
|
||||
std::sort(exes.begin(), exes.end(), [](const auto& a, const auto& b) { return int(a.first.family) < int(b.first.family); });
|
||||
auto chosen = exes.front();
|
||||
if (!fs::is_directory(path, ec))
|
||||
for (const auto& e : exes)
|
||||
if (upper(path_to_utf8(e.second.filename())) == upper(path_to_utf8(path.filename()))) chosen = e;
|
||||
c.family = chosen.first.family;
|
||||
c.exe = chosen.second;
|
||||
switch (c.family) {
|
||||
case GameFamily::german:
|
||||
check_german(c);
|
||||
c.playable = c.problems.empty();
|
||||
break;
|
||||
case GameFamily::english:
|
||||
check_english(c);
|
||||
// complete English data is translated for the engine when the game is resolved
|
||||
// (resolve_game -> prepare_english_game); the check itself stays on the original
|
||||
break;
|
||||
case GameFamily::disk1994:
|
||||
c.title = "Bundesliga Manager Hattrick (1994 floppy version)";
|
||||
c.unsupported = "The 1994 floppy version (M3.EXE) is not supported; please use the CD version or a later edition.";
|
||||
break;
|
||||
case GameFamily::unknown: break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
|
||||
try {
|
||||
ResolvedGame game = resolve_game_unchecked(input, cache);
|
||||
// The English Football Limited runs on the same engine through a German-layout data
|
||||
// directory, built once in the cache (launch/fltd.hpp); its name follows FLTD.EXE.
|
||||
if (game.error.empty() && game.check.family == GameFamily::english && game.check.problems.empty()) {
|
||||
const fs::path prepared = cache / ("en-" + content_hash(game.check.exe));
|
||||
const fs::path marker = prepared / ".openbmh-english";
|
||||
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
|
||||
// by another version is built again
|
||||
constexpr const char* kTranslation = "english translation 12"; // 12: contract warning ContractExpiryWarningText; 11: statistics windows, graph labels/count classes, streaks and national-badge banks
|
||||
std::string built;
|
||||
{
|
||||
std::ifstream in(marker);
|
||||
std::getline(in, built);
|
||||
}
|
||||
std::error_code ec;
|
||||
if (built != kTranslation) {
|
||||
fs::remove_all(prepared, ec);
|
||||
std::string error;
|
||||
if (!prepare_english_game(game.check.directory, prepared, error)) {
|
||||
game.error = "The English version cannot be prepared: " + error;
|
||||
return game;
|
||||
}
|
||||
std::ofstream(marker) << kTranslation << "\n" << path_to_utf8(game.check.directory) << "\n";
|
||||
}
|
||||
game.check.directory = prepared;
|
||||
game.check.playable = true;
|
||||
game.unpacked = true;
|
||||
}
|
||||
return game;
|
||||
} catch (const std::exception& e) {
|
||||
// (file system errors, names that cannot be converted)
|
||||
ResolvedGame r;
|
||||
r.error = std::string("The game cannot be opened: ") + e.what();
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
ResolvedGame resolve_game_unchecked(const fs::path& input, const fs::path& cache) {
|
||||
std::error_code ec;
|
||||
if (!fs::exists(input, ec)) {
|
||||
ResolvedGame r;
|
||||
r.error = "not found: " + path_to_utf8(input);
|
||||
return r;
|
||||
}
|
||||
if (fs::is_directory(input, ec)) return {check_game_directory(input), {}, false};
|
||||
if (family_of_exe(path_to_utf8(input.filename()))) return {check_game_directory(input), {}, false};
|
||||
if (archive_format(input) != ArchiveFormat::none) return unpack(input, cache);
|
||||
ResolvedGame r;
|
||||
r.error = path_to_utf8(input.filename()) + " is neither a game directory, BMH.EXE/FLTD.EXE nor a ZIP/7z archive.";
|
||||
return r;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
fs::path default_cache_directory() {
|
||||
const auto env = [](const char* name) -> std::optional<fs::path> {
|
||||
#ifdef _WIN32
|
||||
// (the wide environment: the profile path may hold characters outside the code page)
|
||||
std::wstring wname(name, name + std::strlen(name));
|
||||
wchar_t* v = nullptr;
|
||||
size_t length = 0;
|
||||
if (_wdupenv_s(&v, &length, wname.c_str()) == 0 && v) {
|
||||
const fs::path value = *v ? fs::path(v) : fs::path();
|
||||
std::free(v);
|
||||
if (!value.empty()) return value;
|
||||
}
|
||||
#else
|
||||
if (const char* v = std::getenv(name); v && *v) return fs::path(v);
|
||||
#endif
|
||||
return std::nullopt;
|
||||
};
|
||||
#if defined(_WIN32)
|
||||
if (auto base = env("LOCALAPPDATA")) return *base / "OpenBMH" / "games";
|
||||
return fs::temp_directory_path() / "OpenBMH" / "games";
|
||||
#elif defined(__APPLE__)
|
||||
if (auto home = env("HOME")) return *home / "Library" / "Application Support" / "OpenBMH" / "games";
|
||||
return fs::temp_directory_path() / "OpenBMH" / "games";
|
||||
#else
|
||||
if (auto data = env("XDG_DATA_HOME")) return *data / "openbmh" / "games";
|
||||
if (auto home = env("HOME")) return *home / ".local" / "share" / "openbmh" / "games";
|
||||
return fs::temp_directory_path() / "openbmh" / "games";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string describe(const ResolvedGame& game) {
|
||||
if (!game.error.empty()) return game.error;
|
||||
const GameCheck& c = game.check;
|
||||
std::string text;
|
||||
if (!c.title.empty()) text += c.title + "\n";
|
||||
text += path_to_utf8(c.directory) + "\n";
|
||||
for (const auto& p : c.problems) text += "- " + p + "\n";
|
||||
if (!c.unsupported.empty()) text += c.unsupported + "\n";
|
||||
if (c.playable) text += "The game data is complete.\n";
|
||||
return text;
|
||||
}
|
||||
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,67 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// Finding and checking the original game data OpenBMH runs on.
|
||||
//
|
||||
// The player names one of: an installed game directory, the game's EXE in it (BMH.EXE of
|
||||
// the German versions, FLTD.EXE of the English "Football Limited"), or a ZIP/7z archive
|
||||
// holding exactly one such game. An archive is unpacked once into the cache directory (a
|
||||
// folder per archive content hash) and reused on the next start.
|
||||
//
|
||||
// OpenBMH has one game and match engine (the supported rule profile rules); the original files are only
|
||||
// data. The check therefore asks whether the data is complete and readable, not which
|
||||
// edition it is. Fan extras next to the files (pictures, manuals) are ignored.
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh::launch {
|
||||
|
||||
enum class GameFamily {
|
||||
unknown,
|
||||
german, // BMH.EXE + TEXTD.BLK + M3D.MAN (CD 1996, CLASSIC/UNLIMITED/supported rule profile editions)
|
||||
english, // FLTD.EXE + TEXTE.BLK + M3E.MAN (Football Limited)
|
||||
disk1994, // M3.EXE + M3PC.* (the 1994 floppy version): recognised, not supported
|
||||
};
|
||||
|
||||
struct GameCheck {
|
||||
GameFamily family = GameFamily::unknown;
|
||||
std::filesystem::path directory; // the game directory (where the EXE is)
|
||||
std::filesystem::path exe; // the EXE as found (its case may differ)
|
||||
std::string title; // e.g. "Bundesliga Manager Hattrick 2026-27 (supported rule profile)"
|
||||
std::vector<std::string> problems; // missing or unreadable files; empty = data complete
|
||||
// Data complete and the engine can run it. False also for complete data the engine does
|
||||
// not run yet (`unsupported` says why).
|
||||
bool playable = false;
|
||||
std::string unsupported;
|
||||
};
|
||||
|
||||
// The file `name` in `directory`, matched without regard to case (the packages mix
|
||||
// "BMH.exe", "BMH.EXE" and "20.vga"); nullopt if there is none.
|
||||
std::optional<std::filesystem::path> find_file(const std::filesystem::path& directory, const std::string& name);
|
||||
|
||||
// Checks an installed game directory (or the directory of a named EXE). A directory without
|
||||
// a game EXE but with exactly one sub directory holding one (an edition folder with BMH\
|
||||
// inside) is followed.
|
||||
GameCheck check_game_directory(const std::filesystem::path& path);
|
||||
|
||||
struct ResolvedGame {
|
||||
GameCheck check;
|
||||
std::string error; // why no game directory could be found (empty: check is valid)
|
||||
bool unpacked = false; // the directory comes from the archive cache
|
||||
};
|
||||
|
||||
// Resolves what the player gave: a directory, an EXE or an archive. `cache` is where
|
||||
// archives are unpacked (see default_cache_directory()).
|
||||
ResolvedGame resolve_game(const std::filesystem::path& input, const std::filesystem::path& cache);
|
||||
|
||||
// The per-user cache for unpacked archives: %LOCALAPPDATA%\OpenBMH\games,
|
||||
// ~/Library/Application Support/OpenBMH/games, $XDG_DATA_HOME/openbmh/games.
|
||||
std::filesystem::path default_cache_directory();
|
||||
|
||||
// One line per problem, for message boxes and the console.
|
||||
std::string describe(const ResolvedGame& game);
|
||||
|
||||
} // namespace bmh::launch
|
||||
Reference in new issue
Block a user