mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
fix: assets access attempts in headless mode leading to segfaults
This commit is contained in:
parent
41c414db19
commit
a92efe581f
3 changed files with 16 additions and 1 deletions
|
|
@ -420,7 +420,7 @@ EngineSettings& Engine::getSettings() {
|
|||
}
|
||||
|
||||
Assets* Engine::getAssets() {
|
||||
return assets->getStorage();
|
||||
return assets ? assets->getStorage() : nullptr;
|
||||
}
|
||||
|
||||
AssetsLoader& Engine::acquireBackgroundLoader() {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ static void load_texture(
|
|||
}
|
||||
|
||||
static int l_request_texture(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
throw std::runtime_error("not available in headless mode");
|
||||
}
|
||||
std::string filename = lua::require_string(L, 1);
|
||||
std::string alias = lua::require_string(L, 2);
|
||||
auto& loader = engine->acquireBackgroundLoader();
|
||||
|
|
@ -34,6 +37,9 @@ static int l_request_texture(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_load_texture(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
throw std::runtime_error("not available in headless mode");
|
||||
}
|
||||
if (lua::isstring(L, 3) && lua::require_lstring(L, 3) != "png") {
|
||||
throw std::runtime_error("unsupportd image format");
|
||||
}
|
||||
|
|
@ -61,6 +67,9 @@ static int l_load_texture(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_parse_model(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
throw std::runtime_error("not available in headless mode");
|
||||
}
|
||||
auto format = lua::require_lstring(L, 1);
|
||||
auto string = lua::require_lstring(L, 2);
|
||||
auto name = lua::require_string(L, 3);
|
||||
|
|
@ -79,6 +88,9 @@ static int l_parse_model(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_to_canvas(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
throw std::runtime_error("not available in headless mode");
|
||||
}
|
||||
auto& assets = *engine->getAssets();
|
||||
|
||||
auto alias = lua::require_lstring(L, 1);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ using namespace scripting;
|
|||
static DocumentNode get_document_node_impl(
|
||||
lua::State*, const std::string& name, const std::string& nodeName, bool throwable=true
|
||||
) {
|
||||
if (engine->isHeadless()) {
|
||||
throw std::runtime_error("not available in headless mode");
|
||||
}
|
||||
auto doc = engine->getAssets()->get<UiDocument>(name);
|
||||
if (doc == nullptr) {
|
||||
if (throwable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue