Game Development Community

AIClient crashes app

by Andrea Barolo · in Torque Game Engine Advanced · 06/08/2009 (4:55 am) · 3 replies

Hello, I think I found a bug!

Try this !
1) Run the T3D Demo.
2) press Alt+C so you can fly and watch your avatar.
3) Activate the console and type AIconnect("new");
- an ai client connects (exemple with id 2222) and a new player appears over the avatar.
4) Then use the mission editor (press F11) to retrive the player ID (es. I 've 2215).
5) Type on console : 2222.setTargetObject(2215);
6) CRASH !!!

I don't know if this is a correct use of setTargetObject .... :(

#1
06/08/2009 (5:20 am)
Hi Andrea,

I'm pretty sure AIClient isn't supported and is just left in there to be useful for learning. Is there a specific reason that you want to use AIClient and not AIPlayer?

With that said, it could be that you're passing a client Ghost ID (2215) and passing it to a server function (setTargetObject). Try to resolve the Ghost ID before you pass it to setTarget and see if that works.

NetObject *NetConnection::resolveObjectFromGhostIndex(S32 id)
S32 NetConnection::getGhostIndex(NetObject *obj)
NetObject *NetConnection::resolveGhost(S32 id)

Edit: Parallel edit with Rene. :)

/Stefan
#2
06/08/2009 (5:21 am)
AIconnect creates an AIConnection rather than an AIClient (a derived class). Use aiAddPlayer instead. Otherwise it simply casts the object to AIClient and then accesses invalid memory.

There seems to be some confusion in aiClient.cpp where a whole host of console methods get to be added to AIConnection rather than AIClient whereas they only work with AIClients. Basically, any of the ConsoleMethods in that file should be changed to use AIClient instead of AIConnection.

//Edit: parallel post with Stefan
#3
06/08/2009 (6:04 am)
Thank you all !! Im experimenting with ai objects here and thare !
My objective is to create a ai controlled flying vehicle !! I'll search for a resource for this !!
Thank again ! :)