[no bug] getFileSystem()->addZipFileArchive() slight bug

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
yaten
Posts: 41
Joined: Tue Nov 16, 2010 4:57 pm
Location: /home/yaten on a server somewhere East of Asia
Contact:

[no bug] getFileSystem()->addZipFileArchive() slight bug

Post by yaten »

EDIT: NOT BUG, see 2nd post of sir hybrid below.

hi sirs,

I think there is a slight bug on device->getFileSystem()->addZipFileArchive(); but it isn't really that critical. In fact, the condition is rare and can easily be avoided with a simple workaround. I just reported this for documentation purposes only. ^_^

The bug can be described as follows:
If you have 2 identical filenames on 2 different directories, one of them is always loaded even if you specify the directory of the second. So far, I've been able to recreate the conditions always and on both windows and linux.

The code below describes it better, also found below are the links to my test case which contains the test source code and the test zip file.

The zip file contains 3 files and 1 folder in this format:

Code: Select all

vfs.zip
  - vfs
    - dir1
      - 1.jpg
    - 1.jpg
    - 2.jpg
note that :
dir1/1.jpg contains image of 1s
1.jpg contains images of 2s despite the filename
2.jpg contains images of 2s
in other words, both 1.jpg and 2.jpg outside of dir1 contains image of 2s,
while the image at dir1/1.jpg contains image of 1s.

Viewing the source code, I created 3 cubes
cube 1 uses vfs/1.jpg as texture
cube 2 uses vfs/dir1/1.jpg as texture
cube 3 uses vfs/2.jpg as texture

The expected output should be cubes with textures 2s, 1s and 2s respectively. However, upon running, the output is different.
Image

The workaround is simple, don't use exactly the same filename even across different folders.

Following is the link to the test case.
source code and assets
It contains the zip file, the source codes, and binary for windows 32bit and linux 64bit.

If i'm done with my projects, i'll probably try looking at the source code and see if i can manage to create a patch for it. For now, all I can do is report for documentation. ^_^

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
	IrrlichtDevice *device =
		createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
			false, false, false, 0);
	if (!device)
		return 1;
	device->setWindowCaption(L"Irrlicht Engine Test");
	device->getFileSystem()->addZipFileArchive("vfs.zip");
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	// 1st cube
	ISceneNode* cube1 = smgr->addCubeSceneNode(10.0f);
	if (!cube1)
	{
		device->drop();
		return 1;
	}
	cube1->setMaterialTexture( 0, driver->getTexture("vfs/1.jpg") ); // an image with 2s
	cube1->setMaterialFlag(EMF_LIGHTING, false);
	// 2nd cube
	ISceneNode* cube2 = smgr->addCubeSceneNode(10.0f);
	if (!cube2)
	{
		device->drop();
		return 1;
	}
	cube2->setPosition(vector3df(12,0,0));
	cube2->setMaterialTexture( 0, driver->getTexture("vfs/dir1/1.jpg") ); // an image with 1s
	cube2->setMaterialFlag(EMF_LIGHTING, false);
	// 3rd cube
	ISceneNode* cube3 = smgr->addCubeSceneNode(10.0f);
	if (!cube3)
	{
		device->drop();
		return 1;
	}
	cube3->setPosition(vector3df(24,0,0));
	cube3->setMaterialTexture( 0, driver->getTexture("vfs/2.jpg") ); // an image with 2s
	cube3->setMaterialFlag(EMF_LIGHTING, false);

	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));
		smgr->drawAll();
		driver->endScene();
	}
	device->drop();
	return 0;
}
Last edited by yaten on Wed Jan 05, 2011 6:50 pm, edited 2 times in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, this is actually a severe bug, because in many situations one cannot get around this. I think we have the same problem with folder archives, maybe in all others as well. Guess it's time for another test case. Thanks for reporting.
yaten
Posts: 41
Joined: Tue Nov 16, 2010 4:57 pm
Location: /home/yaten on a server somewhere East of Asia
Contact:

Post by yaten »

hybrid wrote:Well, this is actually a severe bug, because in many situations one cannot get around this. I think we have the same problem with folder archives, maybe in all others as well. Guess it's time for another test case. Thanks for reporting.
hi sir hybird, let me know if i can be of help specially on test cases. Sorry for late reply, i just woke up (10:30am here, i was in-charge of preventive maintenance early dawn a few hours ago ^_^)
Brainsaw
Posts: 1183
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I did run into this one as well. I use an archive for some basic files, i.e. the background scene of my menues, and I saved one of the configuration files into that archive by accident. Bad thing was: it did always load the configuration file from the archive and saved it to the uncompressed folder, so that all settings were lost. Took me a few hours to figure out.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh, could it be that you did load the archive with 'ignorePaths==true'? In that case, only one file will obviously exist for a given name. Please re-check with correct addArchive parameters.
yaten
Posts: 41
Joined: Tue Nov 16, 2010 4:57 pm
Location: /home/yaten on a server somewhere East of Asia
Contact:

Post by yaten »

hybrid wrote:Oh, could it be that you did load the archive with 'ignorePaths==true'? In that case, only one file will obviously exist for a given name. Please re-check with correct addArchive parameters.
you are right sir, it isn't a bug after all but just my noobishness hahaha

Code: Select all

device->getFileSystem()->addZipFileArchive("vfs.zip", false, false);
instantly solved the problem. I'm very sorry for wasting your precious time sir, next time i'll research extensively before reporting. ^_^
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

hybrid wrote:Oh, could it be that you did load the archive with 'ignorePaths==true'? In that case, only one file will obviously exist for a given name. Please re-check with correct addArchive parameters.
That's what I was thinking, how can it possibly get them [the files] confused if they should have different path variables.
Post Reply