| 459 | //========================================================================== |
| 460 | |
| 461 | void InitSpriteLists() |
| 462 | { |
| 463 | // Do not mass-destroy from the iterator. This may fail if destroying one actor results in further destructions. |
| 464 | TArray<DCoreActor*> allActors; |
| 465 | TSpriteIterator<DCoreActor> it; |
| 466 | while (auto actor = it.Next()) |
| 467 | allActors.Push(actor); |
| 468 | |
| 469 | // clear all lists manually before doing any mass destruction. |
| 470 | // This may also be called in error situations where the list has become corrupted, |
| 471 | // so we should not depend on its consistency anymore. |
| 472 | for (auto& stat : statList) |
| 473 | { |
| 474 | stat.firstEntry = stat.lastEntry = nullptr; |
| 475 | } |
| 476 | for (auto& sect: sector) |
| 477 | { |
| 478 | sect.firstEntry = sect.lastEntry = nullptr; |
| 479 | } |
| 480 | |
| 481 | for (auto& act : allActors) |
| 482 | { |
| 483 | if (!(act->ObjectFlags & OF_EuthanizeMe)) |
| 484 | { |
| 485 | act->link_stat = INT_MAX; |
| 486 | act->prevStat = act->nextStat = act->prevSect = act->nextSect = nullptr; |
| 487 | act->Destroy(); |
| 488 | } |
| 489 | } |
| 490 | Numsprites = 0; |
| 491 | } |
| 492 | |
| 493 | //========================================================================== |
| 494 | // |
no test coverage detected