error: invalid conversion from 'int' to 'const wchar_t*'

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

hmm... what on earth caused this?

Code: Select all

 
//Logical parent for the bullets!
 
                                                                                                            BulletParent=smgr->addEmptySceneNode();
                                                                                                            if (BulletParent)
                                                                                                                        BulletParent->setName("Bullet Container");
 
                                                                                                                        Q3ShaderFactory(Game->loadParam, Game->Device, Mesh,E_Q3_MESH_ITEMS,ShaderParent,Meta,false);
                                                                                                                        Q3ShaderFactory(Game->loadParam, Game->Device, Mesh,E_Q3_MESH_FOG,FogParent,0,false);
                                                                                                                        Q3ShaderFactory(Game->loadParam, Game->Device, Mesh,E_Q3_MESH_UNRESOLVED,UnresolvedParent,Meta,true);
 
                                                                                                                        Q3ModelFactory(Game->loadParam,Game->Device,Mesh,ItemParent,false);
 
}
                                                                                                                        void CQuake3EventHandler::addSceneTreeItem(ISceneNode *parent,IGUITreeViewNode*nodeParent)
                                                                                                                        {
                                                                                                                            IGUITreeViewNode*node;
                                                                                                                            wchar_t msg[128];
 
                                                                                                                            s32 imageIndex;
                                                                                                                            list<ISceneNode*>::ConstIterator it=parent->getChildren().begin();
                                                                                                                            for(;it!=parent->getChildren().end();++it)
                                                                                                                            {
                                                                                                                                switch ((*it)->getType())
                                                                                                                                {
                                                                                                                                    case ESNT_Q3SHADER_SCENE_NODE: imageIndex=0;break;
                                                                                                                                    case ESNT_CAMERA:imageIndex=1;break;
                                                                                                                                    case ESNT_EMPTY:imageIndex=2;break;
                                                                                                                                    case ESNT_MESH:imageIndex=3;break;
                                                                                                                                    case ESNT_OCTREE:imageIndex=3;break;
                                                                                                                                    case ESNT_ANIMATED_MESH:imageIndex=4;break;
                                                                                                                                    case ESNT_SKY_BOX:imageIndex=5;break;
                                                                                                                                    case ESNT_BILLBOARD:imageIndex=6;break;
                                                                                                                                    case ESNT_PARTICLE_SYSTEM:imageIndex=7;break;
                                                                                                                                    case ESNT_TEXT:imageIndex=8;break;
                                                                                                                                    default:imageIndex=-1;break;
                                                                                                                                }
 
                                                                                                                                if(imageIndex<0)
                                                                                                                                {
                                                                                                                                    swprintf(msg,128,L"%hs,%hs",
                                                                                                                                             Game->Device->getSceneManager()->getSceneNodeTypeName((*it)->getType()),
                                                                                                                                             (*it)->getName() );  <----compiler says the error is here.....
 
                                                                                                                                }
                                                                                                                                else
                                                                                                                                {
                                                                                                                                swprintf(msg,128,L"%hs",(*it)->getName());
                                                                                                                                }
 
                                                                                                                                node=nodeParent->addChildBack(msg,0,imageIndex);
 
                                                                                                                                //adding all teh anim8ors
 
                                                                                                                                list<ISceneNodeAnimator*>::ConstIterator ait=(*it)->getAnimators().begin();
                                                                                                                                for(;ait!=(*it)->getAnimators().end();++ait)
                                                                                                                                {
                                                                                                                                    imageIndex=-1;
                                                                                                                                    swprintf(msg,128,L"%hs",
                                                                                                                                             Game->Device->getSceneManager()-getAnimatorTypeName((*ait)->getType())
                                                                                                                                                                                                 );
 
 
                                                                                                                        switch ((*ait)->getType())
                                                                                                                        {
                                                                                                                            case ESNAT_FLY_CIRCLE:
                                                                                                                            case ESNAT_FLY_STRAIGHT:
                                                                                                                            case ESNAT_FOLLOW_SPLINE:
                                                                                                                            case ESNAT_ROTATION:
                                                                                                                            case ESNAT_TEXTURE:
                                                                                                                            case ESNAT_DELETION:
                                                                                                                            case ESNAT_COLLISION_RESPONSE:
                                                                                                                            case ESNAT_CAMERA_FPS:
                                                                                                                            case ESNAT_CAMERA_MAYA:
                                                                                                                            default:
                                                                                                                                break;
                                                                                                                        }
                                                            
 
compiler g++
IDE Code::Blocks
"this is not the bottleneck you are looking for"
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Radikalizm »

The error occurs in your swprintf
First of all, the function expects a string while you're passing an integer
Second of all the h prefix tells the function you want to pass a short integer, which doesn't make sense at all in your context since %s indicates you're passing a string
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

no I agree it doesn't make sense, but why on earth?
I literally tried fixing it by copy pasting from tut21 (after ripping my hair in frustration)

It gives the same result

COPY/PASTE from tutorial 21

Code: Select all

 
void CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent)
{
        IGUITreeViewNode* node;
        wchar_t msg[128];
 
        s32 imageIndex;
        list<ISceneNode*>::ConstIterator it = parent->getChildren().begin();
        for (; it != parent->getChildren().end(); ++it)
        {
                switch ( (*it)->getType () )
                {
                        case ESNT_Q3SHADER_SCENE_NODE: imageIndex = 0; break;
                        case ESNT_CAMERA: imageIndex = 1; break;
                        case ESNT_EMPTY: imageIndex = 2; break;
                        case ESNT_MESH: imageIndex = 3; break;
                        case ESNT_OCTREE: imageIndex = 3; break;
                        case ESNT_ANIMATED_MESH: imageIndex = 4; break;
                        case ESNT_SKY_BOX: imageIndex = 5; break;
                        case ESNT_BILLBOARD: imageIndex = 6; break;
                        case ESNT_PARTICLE_SYSTEM: imageIndex = 7; break;
                        case ESNT_TEXT: imageIndex = 8; break;
                        default:imageIndex = -1; break;
                }
 
                if ( imageIndex < 0 )
                {
                        swprintf ( msg, 128, L"%hs,%hs",
                                Game->Device->getSceneManager ()->getSceneNodeTypeName ( (*it)->getType () ),
                                (*it)->getName()
                                );
                }
                else
                {
                        swprintf ( msg, 128, L"%hs",(*it)->getName() );
                }
 
                node = nodeParent->addChildBack( msg, 0, imageIndex );
 
                // Add all Animators
                list<ISceneNodeAnimator*>::ConstIterator ait = (*it)->getAnimators().begin();
                for (; ait != (*it)->getAnimators().end(); ++ait)
                {
                        imageIndex = -1;
                        swprintf ( msg, 128, L"%hs",
                                Game->Device->getSceneManager ()->getAnimatorTypeName ( (*ait)->getType () )
                                );
 
                        switch ( (*ait)->getType () )
                        {
                                case ESNAT_FLY_CIRCLE:
                                case ESNAT_FLY_STRAIGHT:
                                case ESNAT_FOLLOW_SPLINE:
                                case ESNAT_ROTATION:
                                case ESNAT_TEXTURE:
                                case ESNAT_DELETION:
                                case ESNAT_COLLISION_RESPONSE:
                                case ESNAT_CAMERA_FPS:
                                case ESNAT_CAMERA_MAYA:
                                default:
                                        break;
                        }
                        node->addChildBack( msg, 0, imageIndex );
                }
 
                addSceneTreeItem ( *it, node );
        }
}
 
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9645
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

Please reduce code-examples always to the minimum necessary to reproduce the problem. And if you have trouble in one line don't write you have trouble in one line but in _which_ line.

Anyway - assuming it's the swprintf causing troubles - there's different implementations of that. Irrlicht has defines for that in irrTypes.h.
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
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

ok, I wasn't sure how much might be necessary for replicating the problem, too much is better than too little, eh?
Please reduce code-examples always to the minimum necessary to reproduce the problem. And if you have trouble in one line don't write you have trouble in one line but in _which_ line.

Anyway - assuming it's the swprintf causing troubles - there's different implementations of that. Irrlicht has defines for that in irrTypes.h.

I did, look in the first post (I am going to be nice and place it here as well....)

Code: Select all

{
swprintf(msg,128,L"%hs,%hs",
Game->Device->getSceneManager()->getSceneNodeTypeName((*it)->getType()),
(*it)->getName() );  <----compiler says the error is here.....
 
}
"this is not the bottleneck you are looking for"
Post Reply