Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is currently impossible to test external package loading from within the editor #16798

Open
EIREXE opened this issue Feb 18, 2018 · 11 comments · May be fixed by #90425
Open

It is currently impossible to test external package loading from within the editor #16798

EIREXE opened this issue Feb 18, 2018 · 11 comments · May be fixed by #90425

Comments

@EIREXE
Copy link
Contributor

EIREXE commented Feb 18, 2018

Godot version: 3.0 Release

OS/device including version: Windows

Issue description:
When loading resource packs using ProjectSettings.load_resource_pack one would assume the content from the resource pack is added to the virtual filesystem, this does work but it also breaks other things, I now present three cases.

In each of the following cases the pck has a folder structure of Content/ModTest and two files in that folder, modtest.png and project.json, modtest.png is a picture of Godette and project.json is some text data.

The game itself has two folders inside the Content folder, BaseContent and TestContent.

1st case: Directly loading resource using load(): This works exactly as expected, no issues about it.

imagen

2nd case: Iterating a directory using Directory.list_dir: It doesn't work, only the files and folders from the newly loaded pck file seem to be found, this is my method:


func test_pck_issue():
	var dir = Directory.new()
	if dir.open("res://Content") == OK:
		dir.list_dir_begin(true)
		var directory_name = dir.get_next()
		while (directory_name != ""):
			if dir.current_is_dir():
				print(directory_name)
				file_name = dir.get_next()

In this case only ModTest is found, this doesn't seem right to me.

Output when ProjectSettings.load_resource_pack is used:
ModTest

Output when it's not used:

BaseContent
TestContent

3rd case: trying to find files using the file browser: This only seems to find the game's base content, but none of the newly loaded pck content.

imagen

I have also tried removing the project configuration from the package, it doesn't change anything.

@vonflyhighace2
Copy link

vonflyhighace2 commented Feb 18, 2018

I've actually ran into this issue. It seems there is a issue with the way the .pck file packs the assets. it will give free access to files but locks folders. check this #15801

@EIREXE
Copy link
Contributor Author

EIREXE commented Feb 19, 2018

PetePete1984 said in the discord that while load_resource_pack is undocumented it uses PackedData::add_path which is supposed to be additive, so it seems like it is indeed a bug, maybe in PackedData::add_path?

@EIREXE
Copy link
Contributor Author

EIREXE commented Feb 22, 2018

I figured out what's causing this, the problem is that the ProjectSettings singleton sets DirAccess::make_default<DirAccessPack>(DirAccess::ACCESS_RESOURCES);

Because it makes all newly created DirAccess instances be DirAccessPack it only loads from resource packs, and since we are running in the editor we don't really have a resource pack.

load() doesn't use DirAccess, that's why it has no issues loading from both

I am not sure how this can be tackled, if it even can, if I knew I would fix it myself.

@PetePete1984
Copy link
Contributor

Might be useful to add that it works in export mode, where all access to files is through Packs; where it breaks is if you try to use both Packs and the filesystem, ie. in the editor.

@EIREXE
Copy link
Contributor Author

EIREXE commented Feb 22, 2018

I originally proposed to use a hybrid of all three if we are using a mix, but I am not sure if there's a better way.

@eon-s
Copy link
Contributor

eon-s commented Feb 23, 2018

If load work with pck on debug mode it can be used for testing while the other is used on release with conditionals, or make load_resource_pack optionally behave differently on debug mode.

@EIREXE
Copy link
Contributor Author

EIREXE commented Feb 23, 2018

@eon-s load actually works with multiple sources regardless of being in debug or in release mode, because load does not use DirAccess, it does it directly instead, so even if you mix fileystem resources and packages it still works, as long as you supply it the proper path.

The problem comes when mixing them both, once a package is loaded Directory can't find any resource that was outside the pck because Directory stops using DirAccess and starts using DirAccessPack, which only looks at files in pcks.

RandomShaper added a commit to RandomShaper/godot that referenced this issue Mar 18, 2018
When adding a directory path to the inventory of the pack, an empty file name was being added to the file list. That made `Directory.get_ntext()` signal end-of-list too early so that files in a subdirectory were missed.

Fixes godotengine#15801.
Helps with godotengine#16798.
@EIREXE EIREXE changed the title ProjectSettings.load_resource_pack odd behavior (breaks virtual filesystem a bit) It is currently impossible to test external package loading from withing the editor Mar 29, 2018
@EIREXE
Copy link
Contributor Author

EIREXE commented Mar 29, 2018

I have changed the title to a more descriptive one

hpvb pushed a commit that referenced this issue Apr 28, 2018
When adding a directory path to the inventory of the pack, an empty file name was being added to the file list. That made `Directory.get_ntext()` signal end-of-list too early so that files in a subdirectory were missed.

Fixes #15801.
Helps with #16798.

(cherry picked from commit 5366117)
NikodemL pushed a commit to NikodemL/godot that referenced this issue Nov 6, 2019
When adding a directory path to the inventory of the pack, an empty file name was being added to the file list. That made `Directory.get_ntext()` signal end-of-list too early so that files in a subdirectory were missed.

Fixes godotengine#15801.
Helps with godotengine#16798.
@Calinou
Copy link
Member

Calinou commented Jun 7, 2020

@EIREXE Can you still reproduce this bug in Godot 3.2.1 or 3.2.2beta4?

@EIREXE
Copy link
Contributor Author

EIREXE commented Jun 7, 2020

Yes, this is still an issue, the engine's design still has this problem.

DirAccess still doesn't allow for mixed loading from PCK and editor FS.

@akien-mga akien-mga changed the title It is currently impossible to test external package loading from withing the editor It is currently impossible to test external package loading from within the editor Jul 26, 2020
@cloewen8
Copy link

cloewen8 commented Nov 3, 2020

Still a problem with Godot 3.2.3 and 3.2.2 from what I found. I made a minimal test case to report it as bug, before I found this issue.

func _ready():
	var packer = PCKPacker.new();
	packer.pck_start("res://pack.pck");
	packer.flush(true);
	ProjectSettings.load_resource_pack("pack.pck")
	var dir = Directory.new()
	assert(dir.open("res://dir") == OK, "Could not open the folder 'dir'.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants