Build 0.2 native launcher and portable Classic runtime (by Codex)

This commit is contained in:
Codex committed 2026-10-18 11:28:51 +02:00
1 parent 3a021fc160
commit 2552528176
84 files changed
+5004 -197

No files matched your search

+3 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/content.hpp"
#include "formats/executable_layout.hpp"
// Information windows of docs/CLI_CONCEPT/05-information.md that the engine can already
// project: TeamInfo (club information, from LeagueTable / Fixtures), HighScore (menu 26) and
@@ -186,7 +187,8 @@ void Console::register_info_commands() {
const uint16_t signature = g.memory.has(::bmh::layout::CareerSession_FormatError_RuntimeField7) ? g.memory.u16(::bmh::layout::CareerSession_FormatError_RuntimeField7) : 0;
if (signature != 0) {
// the ranked list of this game's level, stored next to the saved games
const auto file = highscore_file(save_directory(), signature, texts_.strings.at(kHighscorePrefix));
const auto file = highscore_file(save_directory(), signature, texts_.strings.at(kHighscorePrefix),
bool(content::find(options_.data)));
HighscoreTable rows{};
std::error_code ec;
if (std::filesystem::exists(file, ec)) rows = load_highscore_table(file);
+7 -3
View File
@@ -5,6 +5,7 @@
#include <algorithm>
#include "formats/content.hpp"
#include "cli/console/console.hpp"
#include "cli/console/detail.hpp"
#include "ui/cup_draw.hpp"
@@ -396,7 +397,8 @@ std::filesystem::path Console::browser_file(const std::string& name) const {
if (name == "." || name == ".." || name.find_first_of("/\\:") != std::string::npos)
fail("E_BAD_ARGUMENT", "not a file name: " + name + " (no directories; use ChangeDirectory)");
std::filesystem::path path = browse_directory_ / name;
if (!path.has_extension()) path += ".FBM";
if (!path.has_extension())
path += content::find(options_.data) ? ".obs" : ".FBM";
return path;
}
@@ -410,7 +412,8 @@ void Console::register_file_commands() {
std::error_code ec;
for (const auto& entry : std::filesystem::directory_iterator(browse_directory_, ec)) {
if (entry.is_directory(ec)) dirs.push_back({entry.path().filename().string(), "dir"});
else if (entry.is_regular_file(ec) && lower(entry.path().extension().string()) == ".fbm")
else if (entry.is_regular_file(ec) && lower(entry.path().extension().string()) ==
(content::find(options_.data) ? ".obs" : ".fbm"))
files.push_back({entry.path().stem().string(), "file"});
}
if (ec) fail("E_IO", "cannot read the directory " + shown_directory());
@@ -463,7 +466,8 @@ void Console::register_file_commands() {
void Console::load_game(const std::filesystem::path& requested) {
std::filesystem::path path = requested;
if (!path.has_extension()) path += ".FBM";
if (!path.has_extension())
path += content::find(options_.data) ? ".obs" : ".FBM";
std::error_code ec;
if (!std::filesystem::is_regular_file(path, ec)) fail("E_IO", "file not found: " + path.filename().string());
std::unique_ptr<app::CareerSession> loaded;
+21 -8
View File
@@ -32,6 +32,8 @@
#include "launch/archive.hpp"
#include "launch/game_data.hpp"
#include "content/package.hpp"
#include "launch/mods.hpp"
#include "version.hpp"
namespace {
@@ -83,7 +85,8 @@ Arguments parse_args(int argc, char** argv) {
std::exit(0);
}
if (arg == "--help" || arg == "-h") args.help = true;
else if (arg == "--data") args.data = bmh::launch::path_from_utf8(next(arg));
else if (arg == "--data" || arg == "--mod")
args.data = bmh::launch::path_from_utf8(next(arg));
else if (arg == "--seed") { args.seed = parse_seed(next(arg)); args.seed_set = true; }
else if (arg == "--text") args.json = false;
else if (arg == "--json") args.json = true;
@@ -710,14 +713,24 @@ int main(int argc, char** argv) {
Arguments args = parse_args(argc, argv);
if (args.help) { print_usage(); return 0; }
if (!args.send.empty()) return run_send(args);
// --data may also name BMH.EXE or a ZIP/7z archive with one game (src/launch); an
// archive is unpacked into the per-user cache and its copy is used
std::shared_ptr<const bmh::content::Classic> contents;
std::unique_ptr<bmh::content::Mount> mount;
if (!args.data.empty()) {
const auto game = bmh::launch::resolve_game(args.data, bmh::launch::default_cache_directory());
if (!game.error.empty() || !game.check.playable)
throw std::runtime_error("the game cannot be used:\n" + bmh::launch::describe(game));
args.data = game.check.directory;
}
if (std::filesystem::is_directory(args.data))
args.data /= "content.obw";
contents = bmh::content::open(args.data);
mount = std::make_unique<bmh::content::Mount>(args.data, contents);
args.data = mount->root();
if (args.saves.empty()) {
bmh::launch::ModLibrary library(
std::filesystem::absolute(bmh::launch::path_from_utf8(argv[0])).parent_path());
bmh::launch::ModEntry mod;
mod.content_id = contents->content_id;
args.saves = library.user_directory(mod);
}
} else
throw std::runtime_error(
"0.2 requires --mod <content.obw>; import installations in OpenBMH first");
if (args.console) {
if (!args.log.empty() && !args.replay.empty()) throw std::runtime_error("--log and --replay cannot be combined");
if (args.listen_port) return run_console_listen(args);