}
FGAIManager::~FGAIManager() {
- ai_list.clear();
+ ai_list_itr = ai_list.begin();
+ while(ai_list_itr != ai_list.end()) {
+ delete (*ai_list_itr);
+ ++ai_list_itr;
+ }
+ ai_list.clear();
}
void FGAIManager::init() {
}
#endif
- ai_list_itr = ai_list.begin();
- while(ai_list_itr != ai_list.end()) {
+ ai_list_itr = ai_list.begin();
+ while(ai_list_itr != ai_list.end()) {
if ((*ai_list_itr)->getDie()) {
+ // FIXME: delete object itself before removing it from the list.
+ // delete (*ai_list_itr);
ai_list.erase(ai_list_itr, ai_list_itr);
} else {
- (*ai_list_itr)->update(dt);
- }
+ (*ai_list_itr)->update(dt);
+ }
++ai_list_itr;
- }
+ }
}