[fixed]Bug with wchar filesystem

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
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

[fixed]Bug with wchar filesystem

Post by Reiko »

When _IRR_WCHAR_FILESYSTEM is defined, the engine doesn't compile.

The first time I tried to compile, there were tons of errors. This was with the debug build setting. For the cases where it was trying to use ansi functions (like LoadLibraryA), changing the project settings in MSVC to "Use Unicode Character Set" for Character Set under Configuration Properties > General fixed most of them, so that it would for example in that case use LoadLibraryW. The release configuration has the character set setting already set to Multi-Byte, I had to change this to Unicode.

With that aside next there were 3 errors left.

In IAttributeExchangingObject.h:

Code: Select all

//! struct holding data describing options
struct SAttributeReadWriteOptions
{
	//! Constructor
	SAttributeReadWriteOptions()
		: Flags(0), Filename(0)
	{
	}

	//! Combination of E_ATTRIBUTE_READ_WRITE_FLAGS or other, custom ones
	s32 Flags;

	//! Optional filename
	const c8* Filename;
};
For the Filename variable, I changed the type from c8* to fschar_t*.

And in CFileSystem.cpp

in path CFileSystem::getRelativeFilename(const path& filename, const path& directory) const:

These two lines were causing a problem

Code: Select all

path.split(list1, "/\\", 2);
path2.split(list2, "/\\", 2);
I changed it to:

Code: Select all

#ifndef _IRR_WCHAR_FILESYSTEM
		path.split(list1, "/\\", 2);
		path2.split(list2, "/\\", 2);
#else
		path.split(list1, L"/\\", 2);
		path2.split(list2, L"/\\", 2);
#endif
With those adjustments the engine compiles fine. Tried using this dll with the wchar filesystem with my application, and the font and all textures and such loaded fine, so I think it's ok. Haven't tried loading any models since the models in my app are procedurally generated, but I assume they'd be fine too.

edit: forgot to mention, I am using svn revision 3767.

edit 2: actually it was the Unicode setting that worked, not Multi-Byte
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post by Reiko »

for the using wrong LoadLibrary etc functions I decided to change my IrrCompileConfig.h a bit

Code: Select all

//! Define _IRR_WCHAR_FILESYSTEM to enable unicode filesystem support for the engine.
/** This enables the engine to read/write from unicode filesystem. If you
disable this feature, the engine behave as before (ansi). This is currently only supported
for Windows based systems. */
#define _IRR_WCHAR_FILESYSTEM
#ifdef _IRR_WCHAR_FILESYSTEM
#ifndef UNICODE
#define UNICODE
#endif
#endif
#ifdef NO_IRR_WCHAR_FILESYSTEM
#undef _IRR_WCHAR_FILESYSTEM
#undef UNICODE
#endif
Now it will take care of that setting for me depending which filesystem I'm using


I'm not sure which if any of these changes would be suited to the engine, just pointing out what I did and you guys can make the best decision
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

These were fixed in SVN revisions 3775 and 3776.
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post by Reiko »

Thanks for the info, I guess I should update
Post Reply