Game Development Community

New Player class weirdness

by Bill Vee · in Torque Game Engine Advanced · 11/09/2009 (1:26 pm) · 4 replies

I have created a new player class to use as a testbed for some new ideas and I discovered a very weird crash in the engine.

It is simply a copy of the Player class just renamed to NewPlayer.
All of the class functions and methods have been correctly changed.
The NewPlayer can be used exactly like the old.
I changed the GameConnection::createPlayer function to load the NewPlayer as the default player like so..

%player = new NewPlayer() {
      dataBlock = NewPlayerDB;
      client = %this;
   };
   MissionCleanup.add(%player);

This works perfectly ok with no problems at all. The NewPlayer acts exactly like the Player class.
I was in the process of adding AI controlled NewPlayers when a very odd thing happened.
I accidentally added and AIPlayer which is derived from the Player class and the game hit a hard crash.
Debugging appears to be very difficult because a debugBreak is being called outside of TGEA from ntdll.dll.
I tried to step thru the code all the way to the debugBreak but everything appears to be ok.

The other odd thing is I can have a Player and a AIPlayer at the same time or have a NewPlayer and a NewAIPlayer at the same time but I cannot have a Player and either a NewPlayer or a NewAIPlayer at the same time nor can I have a NewPlayer and either a Player or a AIPlayer at the same time without triggering the crash.

Not that I really need to have the old Player class working but my intent was to create a couple of different Player classes that did very different things.

Anyone have any idea whats going on here?

#1
11/09/2009 (2:01 pm)
Just so we're singing from the same hymn sheet ...
New Player Class as in copy/renaming Player.cpp/h files - yes?

Did you do all the includes for this new class in the other files that include the old class? (not that I know which ones there are, but I bet that there are some).
#2
11/09/2009 (2:10 pm)
No.

I started with the Player.cpp/h files copied it to NewPlayer.cpp/h and then changed every reference of Player and PlayerData to NewPlayer and NewPlayerData. It is in essence a copy of the player class with a different name.

It compiles as NewPlayer class.
#3
11/09/2009 (3:22 pm)
Actually, that was what I meant...

And you did alter/copy and alter the relevant cs files (eg player.cs) and exec the new ones in the correct places (if I remember correctly scripts/client/init.cs also needs various player related datablocks to be execed their, as well as in their normal places).
#4
11/09/2009 (4:08 pm)
Yes.
I created the relevant cs files and execed them in order to use the NewPlayer class.
I can start a game as a player or newplayer but can't have both in the game at the same time without it crashing.

As far as TGEA is concerned Player and NewPlayer are different classes derived from the ShapeBase class just like WheeledVehicle and FlyingVehicle are derived from the Vehicle class.