Hey there. First of, I'm not exactly sure if this should be in this forum or the Linux version. I'm doing a university assignment (due in a couple of weeks) developing a game with PS2 linux. With the PS2, I have no real debugger, just printing to the console and crashes.
I have a problem with pointers. I have a mainly virtual controller class, with two sub classes. One for AI and one for a Player.
Both the subclasses have similar (in some cases, identical) methods however, the AI one is giving me issues.
Both classes have a pawn variable (basePawn* pawn) initially set to NULL. In their respawn method, they call
pawn = new basePawn
. In their removePawn method, they call
if (pawn != NULL)
pawn = NULL;
This works fine being repeatedly called on the Player method, however it crashes on the delete call within the AI class. I have followed the 'Rule of Three' to the best of my knowledge.
If I close the program as soon as it's running, both classes will call removePawn in their destructor and work fine. However, if I allow the AI to kill the player, and then close the program, I get a segmentation fault from the AI.
If the Player kills the AI, the program crashes on the delete call.
I can share more code if required, however I'm at a dead loss and would rather leave minimal information here so I don't overload anyone with code.
I'd like to thank anyone that takes the time to read this and all feedback is appreciated.