[fixed]Phail with removeFileArchive

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

[fixed]Phail with removeFileArchive

Post by B@z »

Hi
Tried out the new irrlicht version, and found a problem.

here is the code:

Code: Select all

	char path[256];
	sprintf(path,"data\\npc\\%i.foo",temp.modelID);
	if (!device->getFileSystem()->addFileArchive(path, true, false, EFAT_ZIP))
		printf("Phail on loading zip archive of npc!\n");

// do something with it

	if (!dev->getFileSystem()->removeFileArchive(dev->getFileSystem()->getAbsolutePath(path)))
	{
		for (int i = 0; i < dev->getFileSystem()->getFileArchiveCount(); i++)
		{
			printf("%s\n", dev->getFileSystem()->getFileArchive(i)->getFileList()->getPath().c_str());
		}
		printf("Didn't found archive: %s\n", dev->getFileSystem()->getAbsolutePath(path).c_str());
	}

the output is:

Code: Select all

c:/Documents and Settings/Honya/Dokumentumok/Visual Studio 2008/Projects/FooServer/FooClient/data/npc/1.foo
Didn!t found archive: c:\Documents and Settings\Honya\Dokumentumok\Visual Studio 2008\Projects\FooServer\FooClient\data\npc\1.foo
focus on the \ / character ;)
looks like the getAbsolutePath use \ and the fileArchive use /

after looking into the code, found another possible bug:

Code: Select all

	for (i = 0; i < FileArchives.size(); ++i)
	{
		if (filename == FileArchives[i]->getFileList()->getPath())
			return true;
	}
but it looks like the getPath() returns absolute path (see the prev. example), but we give the filename relative. so it wont find the same archive (didn't try out, just guessing)

and, it would be good, if it wouldnt return bool, but the index of the loaded archive, and -1 if couldnt load. because on removeFileArchive you can use the index, but from where do you know it!? :D
yes we can walkaround if we get the count of the fileArchives, coz it uses push_back, but what if found same archive? you wont get the right index.
Image
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

ok here is a testcase (but isnt hard to test -w- )

just copy it to the Quake3Map when loading the map.

Code: Select all

	int foo = device->getFileSystem()->getFileArchiveCount();
	printf("before loading: %i\n", foo);
	device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
	foo = device->getFileSystem()->getFileArchiveCount();
	printf("after loading the zip: %i\n", foo);
	device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
	foo = device->getFileSystem()->getFileArchiveCount();
	printf("after loading the same zip (should be the same as before): %i\n", foo);
	if (!device->getFileSystem()->removeFileArchive("../../media/map-20kdm2.pk3"))
		printf("failed on remove");
	foo = device->getFileSystem()->getFileArchiveCount();
	printf("after removing: %i\n", foo);
before loading: 0
after loading the zip: 1
after loading the same zip (should be the same as before): 2
failed on remove
after removing: 2
as i thought, the checking for same zip failed, same to removing.
Image
Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks for bumping this thread and adding more Info. I've seen it first time but forgot about it by now. You can also help keeping such bugs visible by adding them to the bugtracker.

Not sure when I'll find time to investigate this (I'm not too often on Windows these days) but maybe someone else in the team figures it out. But I've put it on my todo and hope I find some time for it before next release.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thank you for answer :3

i hope youll fix it soon
Image
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This seems to be a general file archive problem. The paths are not stored with absolute names, but only relative ones. Which means, that they neither match when loading, nor when removing.
Post Reply