void DThinker::DestroyMostThinkersInList (FThinkerList &list, int stat) { if (stat != STAT_PLAYER) { DestroyThinkersInList (list); } else if (list.Sentinel != NULL) { // If it's a voodoo doll, destroy it. Otherwise, simply remove // it from the list. G_FinishTravel() will find it later from // a players[].mo link and destroy it then, after copying various // information to a new player. for (DThinker *probe = list.Sentinel->NextThinker, *next; probe != list.Sentinel; probe = next) { next = probe->NextThinker; if (!probe->IsKindOf(RUNTIME_CLASS(APlayerPawn)) || // <- should not happen static_cast<AActor *>(probe)->player == NULL || static_cast<AActor *>(probe)->player->mo != probe) { probe->Destroy(); } else { probe->Remove(); // Technically, this doesn't need to be in any list now, since // it's only going to be found later and destroyed before ever // needing to tick again, but by moving it to a separate list, // I can keep my debug assertions that all thinkers are either // euthanizing or in a list. Thinkers[MAX_STATNUM+1].AddTail(probe); } } } }
void DThinker::DestroyThinkersInList (FThinkerList &list) { if (list.Sentinel != NULL) { DThinker *node = list.Sentinel->NextThinker; while (node != list.Sentinel) { DThinker *next = node->NextThinker; node->Destroy(); node = next; } list.Sentinel->Destroy(); list.Sentinel = NULL; } }
// Destroy all thinkers except for player-controlled actors void DThinker::DestroyMostThinkers () { DThinker *thinker = FirstThinker; while (thinker) { DThinker *next = thinker->m_Next; if (!thinker->IsKindOf (RUNTIME_CLASS (AActor)) || static_cast<AActor *>(thinker)->player == NULL || static_cast<AActor *>(thinker)->player->mo != static_cast<AActor *>(thinker)) { thinker->Destroy (); } thinker = next; } DObject::EndFrame (); }
// Destroy every thinker void DThinker::DestroyAllThinkers () { DThinker *currentthinker = FirstThinker; while (currentthinker) { DThinker *next = currentthinker->m_Next; currentthinker->Destroy (); currentthinker = next; } DObject::EndFrame (); size_t l = LingerDestroy.size(); for(size_t i = 0; i < l; i++) { DThinker *obj = LingerDestroy[i]; // if(!obj->refCount) { obj->ObjectFlags |= OF_Cleanup; delete obj; } } LingerDestroy.clear(); }