getTexture returns wrong texture if ...

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
dehseth
Posts: 130
Joined: Wed Dec 09, 2009 11:05 am
Contact:

getTexture returns wrong texture if ...

Post by dehseth »

hi guys,

I figured out if I add a folder to file system:

Code: Select all

	g_smgr->getFileSystem()->addFileArchive("data", true, false, io::EFAT_FOLDER);
Get texture can return wrong texture, like I request a.png and it returns me b.png:

Code: Select all

ITexture* wrong_one = driver->getTexture("a.png");
And it is I guess because of irrArray binary_search:

Code: Select all

s32 binary_search(const T& element) const
	{
		if (is_sorted)
			return binary_search(element, 0, used-1);
		else
			return linear_search(element);
	}
If I jump to linear_search while debugging system loads the correct texture.. I guess adding a folder does not actually sort files, or it returns unsorted data index.. I overcome this using find file method I wrote:

Code: Select all

stringc full_path;
	IFileSystem* fs =  smgr->getFileSystem();
	
	path p = fs->getWorkingDirectory();
	p += "/";
	p += file;
		
	if (fs->existFile(p))
	{
		full_path = file;
	}
	else
	{
		int index;

		for (int i = 0; i < fs->getFileArchiveCount(); i++)
		{			
			if ((index = fs->getFileArchive(i)->getFileList()->findFile(file)) > -1)
			{	
				full_path = fs->getFileArchive(i)->getFileList()->getPath().c_str();
				full_path += file;
				break;
			}
		}
	}

	return full_path;
till you guys fix this... and I have no idea how my for loop returns correct :shock:
Post Reply