Fix NON_PORTABLE build. Ship::Context needs to be initialized first. (#618)

* Fix NON_PORTABLE build. Ship::Context needs to be initialized before resolving files. Move offending calls inside functions where they are used. Those will always be called after GameEngine() which runs Ship::Context::CreateUninitializedInstance() early.

* Replace hardcoded string mk64.o2r and spaghetti.o2r with variables game_asset_file and engine_asset_file.
This commit is contained in:
Fabien Romano
2026-01-09 19:13:37 +01:00
committed by GitHub
parent e71c422afb
commit aaae77f3bc
3 changed files with 14 additions and 8 deletions
+5 -2
View File
@@ -19,8 +19,6 @@ void DetectOutdatedDependencies();
void SortModsByDependencies();
std::vector<std::tuple<ModMetadata, std::shared_ptr<Ship::Archive>>> Mods = {};
const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("mk64.o2r");
const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs("spaghetti.o2r");
void InitModsSystem() {
CheckMK64O2RExists();
@@ -65,6 +63,9 @@ void GenerateAssetsMods() {
}
std::vector<std::string> ListMods() {
const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory(game_asset_file);
const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs(engine_asset_file);
std::vector<std::string> archiveFiles;
if (std::filesystem::exists(main_path)) {
archiveFiles.push_back(main_path);
@@ -202,6 +203,8 @@ void AddCoreDependencies() {
}
void CheckMK64O2RExists() {
const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory(game_asset_file);
if (!std::filesystem::exists(main_path)) {
GenerateAssetsMods();
}
+1 -1
View File
@@ -166,7 +166,7 @@ GameEngine::GameEngine() {
{ BTN_DDOWN, "DDown" },
});
auto controlDeck = std::make_shared<LUS::ControlDeck>(std::vector<CONTROLLERBUTTONS_T>(), defaultMappings, buttonNames);
const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs("spaghetti.o2r");
const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs(engine_asset_file);
this->context->InitResourceManager({assets_path}, {}, 3); // without this line InitWindow fails in Gui::Init()
this->context->InitConsole(); // without this line the GuiWindow constructor fails in ConsoleWindow::InitElement()
+8 -5
View File
@@ -2,14 +2,17 @@
#include "port/audio/HMAS.h"
static const char game_asset_file[] = "mk64.o2r";
static const char engine_asset_file[] = "spaghetti.o2r";
#define LOAD_ASSET(path) \
(path == NULL ? NULL \
: (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path))
#define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path)
#ifdef __cplusplus
#include <vector>
#include <SDL2/SDL.h>
#define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path)
#ifdef __cplusplus
#include <vector>
#include <SDL2/SDL.h>
#include <fast/Fast3dWindow.h>
#include <fast/interpreter.h>
#include "ship/Context.h"