Finish Classic 0.2 portability and release preparation (by Codex)

This commit is contained in:
Codex committed 2026-10-18 20:51:39 +02:00
1 parent 74ca973111
commit 6e5fa72ed5
13 files changed
+186 -25

No files matched your search

+34 -8
View File
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <RmlUi/Core.h>
#include "launch/rml_path.hpp"
#include <chrono>
#include <filesystem>
#include <fstream>
#include <iostream>
@@ -27,11 +29,15 @@ struct Renderer : Rml::RenderInterface {
void EnableScissorRegion(bool) override {}
void SetScissorRegion(Rml::Rectanglei) override {}
Rml::TextureHandle LoadTexture(Rml::Vector2i &dimensions, const Rml::String &name) override {
std::ifstream input(name, std::ios::binary);
auto *files = Rml::GetFileInterface();
const auto input = files->Open(name);
if (!input)
throw std::runtime_error("Stadium asset unavailable: " + name);
unsigned char header[18]{};
input.read(reinterpret_cast<char *>(header), sizeof(header));
if (!input || header[2] != 2 || header[16] != 24)
throw std::runtime_error("Stadium asset unavailable");
const auto read = files->Read(header, sizeof(header), input);
files->Close(input);
if (read != sizeof(header) || header[2] != 2 || header[16] != 24)
throw std::runtime_error("Invalid stadium asset: " + name);
dimensions = {header[12] + 256 * header[13], header[14] + 256 * header[15]};
return 1;
}
@@ -44,21 +50,41 @@ void require(bool value, const std::string &error) {
}
} // namespace
int main(int argc, char **argv) try {
require(argc == 2, "launcher asset directory required");
require(argc == 2 || (argc == 3 && std::string(argv[2]) == "unicode"), "launcher asset directory required");
std::filesystem::path assets(argv[1]);
struct Cleanup {
std::filesystem::path path;
~Cleanup() {
if (!path.empty()) {
std::error_code error;
std::filesystem::remove_all(path, error);
}
}
} cleanup;
if (argc == 3) {
cleanup.path = std::filesystem::temp_directory_path() /
("openbmh-rml-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
std::filesystem::create_directory(cleanup.path);
const auto unicode = cleanup.path / std::filesystem::path(u8"Fußball 日本語") / "launcher";
std::filesystem::create_directories(unicode);
std::filesystem::copy(assets, unicode, std::filesystem::copy_options::recursive);
assets = unicode;
}
System system;
Renderer renderer;
bmh::rml::AssetFiles files;
Rml::SetSystemInterface(&system);
Rml::SetRenderInterface(&renderer);
Rml::SetFileInterface(&files);
require(Rml::Initialise(), "RmlUI initialization");
struct Shutdown {
~Shutdown() { Rml::Shutdown(); }
} shutdown;
const std::filesystem::path assets(argv[1]);
for (const auto *weight : {"Regular", "Bold"})
require(Rml::LoadFontFace((assets / (std::string("LatoLatin-") + weight + ".ttf")).string()),
require(Rml::LoadFontFace(bmh::rml::asset_path(assets / (std::string("LatoLatin-") + weight + ".ttf"))),
"font load");
auto *context = Rml::CreateContext("test", {1100, 688});
auto *document = context->LoadDocument((assets / "launcher.rml").string());
auto *document = context->LoadDocument(bmh::rml::asset_path(assets / "launcher.rml"));
require(document != nullptr, "launcher document load");
document->Show();
for (const auto size : {Rml::Vector2i(1100, 688), Rml::Vector2i(800, 540), Rml::Vector2i(2200, 1376)}) {
+5
View File
@@ -120,6 +120,11 @@ int main(int argc, char **argv) try {
const auto archive = root / "sample.obs";
content::write_archive(docs, archive);
check(content::read_archive(archive) == docs, "binary native archive round-trip");
{
content::Mount mount(archive, std::make_shared<content::Classic>());
check(content::read_archive(archive) == docs,
"archive reads bypass the mounted virtual resource namespace");
}
rejects([&] { content::write_archive({{"../outside", "x"}}, root / "unsafe.obs"); },
"archive traversal rejected");
rejects([&] { content::write_archive({}, archive); }, "existing saves require explicit overwrite");
+2
View File
@@ -41,6 +41,8 @@ int main(int argc, char **argv) try {
const auto package = result.mod.directory / "content.obw";
auto content = content::open(package);
content::Mount mount(package, content);
check(content::open(package)->content_id == content->content_id,
"mounted container can be reopened without resolving it as an asset");
openbmh::audio::OriginalAssets sound;
for (size_t i = 0; i < 4; ++i)
sound.containers[i] = read_file(mount.root() / "S" / std::to_string(2000 + i));
+1 -1
View File
@@ -25,7 +25,7 @@ class PackageAllowlistTests(unittest.TestCase):
for name in ['OpenBMH', 'openbmh_cli', 'openbmh_import', 'README.md', 'LICENSE',
'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md']:
(root / name).write_text('synthetic')
notes = root / 'docs/release/0.1/RELEASE_NOTES.md'
notes = root / 'docs/release/0.2/RELEASE_NOTES.md'
notes.parent.mkdir(parents=True)
notes.write_text('synthetic release notes')
for name in ['launcher.rml', 'theme.rcss', 'stadium.tga', 'LatoLatin-Regular.ttf', 'LatoLatin-Bold.ttf']: