Godot: Load function breaks on filesystem paths that contain the full res:// path

Created on 4 Jan 2019  路  4Comments  路  Source: godotengine/godot

Godot version:
latest Godot 3.1 alpha 5

OS/device including version:
Window 10 64 bit
GeForce GTX 1050 Ti

Issue description:
I am loading external tres mesh files and I have noticed when using unix pathing with / it does not properly load the resource because the full path is mangled.

Here is the test run using "D:\\DEV\\godot\\DBdata\\mods/db/models/wall/block.tres"
image

However "D:/DEV/godot/DBdata/mods/db/models/wall/block.tres" the object is null
image
And in fact gives an error
image

The error is

E 0:00:00:0530   Failed loading resource: res:/data/mods/db/models/wall/block.tres
  <C Source>     core/io/resource_loader.cpp:279 @ _load()
  <Stack Trace>  preload.gd:76 @ _ready()

If you look closer you notice the path that is looking for somehow has become res:/data/mods/db/models/wall/block.tres

The local path of the project is D:/DEV/godot/DB

I believe what is going on is when using Unix type pathing the local path is cut out of the load path and the final load path becomes "res://" + original path - local path (pseudocode)

Steps to reproduce:

Minimal reproduction project:

bug core

Most helpful comment

You are not supposed to load stuff outside the res:// path.

This means you can, right? Just that it's a poor practice to load files outside of the res:// folder since not all OS's and computers store things in the same place, doing so also means files outside of the resource folders are not be packed into your game and thus may not be available in your game when shared.

Correct me if i'm wrong.

All 4 comments

You are not supposed to load stuff outside the res:// path. If you could, automatic packaging and exporting of the game would be impossible.

Why we are not supposed to load stuff outside of res:// path? Seems forced. For my game I need to load external data because I am doing modding and I need to generate all my game data at load time.

You are not supposed to load stuff outside the res:// path.

This means you can, right? Just that it's a poor practice to load files outside of the res:// folder since not all OS's and computers store things in the same place, doing so also means files outside of the resource folders are not be packed into your game and thus may not be available in your game when shared.

Correct me if i'm wrong.

To be clear, as documented by @volzhs in #24772, this issue is just a corner case due to trying to load data from a folder whose path contains the full res:// path, without being in res:// (here res:// is D:\DEV\godot\DB and @CarlGustavAlbertDwarfsteinYung tries to load content from D:\DEV\godot\DBdata, which ends up converted to res://data.

Was this page helpful?
0 / 5 - 0 ratings