Some of you have been having trouble between separate Pirate games with the restarting of your AIControllers afresh at the commencement of each new game. Here is some code to add to the files of the application that I hope will solve your problem. It explicitly deletes your AIController after each game.
1) Add this method to the Ship class in ShipBase.cpp
AIController* Ship::getControllerPtr(void)
{ return controller; }
2) Add this line to ShipBase.h within the Ship class
AIController* getControllerPtr(void);
3) Add these lines at the top of the destructor Sea::~Sea(void) in Sea.cpp
for (int a=0; a < numShips; a++)
{
tmpContollerPtr = shipArray[a].getControllerPtr();
delete tmpContollerPtr;
}
4) At the shell prompt type:
make clean
5) at the shell prompt, type:
make
6) See if the code resets the AIController now when you run the game multiple times
...code on! :-)
Monday, April 16, 2012
Subscribe to:
Posts (Atom)