Code error, please help!

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
lisacvuk
Posts: 21
Joined: Thu Apr 17, 2014 4:50 pm

Code error, please help!

Post by lisacvuk »

I asked on IRC, no answers so I'm asking here. How to convert from wchar_t to irr::io:IReadFile? Or, if there isn't a way, how to get this work? I have loadMap(wchar_t mapName) function in which I load map, add camera and set up collision. I call it from main function like loadMap('map01.bsp'). I get error:

Code: Select all

 
||=== Build: Debug in TMIP (compiler: GNU GCC Compiler) ===|
/home/lisacvuk/TMIP/TMIP/loadMap.cpp||In function ‘int loadMap(wchar_t)’:|
/home/lisacvuk/TMIP/TMIP/loadMap.cpp|39|error: invalid conversion from ‘wchar_t’ to ‘irr::io::IReadFile*’ [-fpermissive]|
../../../../media/lisacvuk/baaf8f3b-56ee-41e4-957c-13dc7ce32ad1/Irrlicht/irrlicht-1.8.1/include/ISceneManager.h|408|note: initializing argument 1 of ‘virtual irr::scene::IAnimatedMesh* irr::scene::ISceneManager::getMesh(irr::io::IReadFile*)’|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
 
Add IQ3LevelMesh code:

Code: Select all

 
 IQ3LevelMesh* map_mesh = (IQ3LevelMesh*) smgr->getMesh(mapName);
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Code error, please help!

Post by CuteAlien »

If you have "wchar_t mapName" it means you pass a single wchar_t character. You likely wanted "wchar_t* mapName" which can be used to pass a string. Or use "const irr::io::path& mapName" instead, then no conversions are needed.
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
lisacvuk
Posts: 21
Joined: Thu Apr 17, 2014 4:50 pm

Re: Code error, please help!

Post by lisacvuk »

Thank you, but I found other solution.I set wchar_t mapName to stringw mapName.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Code error, please help!

Post by CuteAlien »

Yeah, that works also, although using io::path would be better (as it's a path and not just any string - but no difference for you probably). And always better to use a const reference in such cases (to avoid extra string copying), like "const stringw& mapName".
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
Post Reply