diff --git a/src/common/utility/tarray.h b/src/common/utility/tarray.h index a1829e79e..b6e852fe5 100644 --- a/src/common/utility/tarray.h +++ b/src/common/utility/tarray.h @@ -664,6 +664,15 @@ public: Insert (SortedFind (item, std::forward(lt), false), item); } + void SortedInsertUnique(const T &item) + { + int foundIndex = SortedFind (item, false); + if (foundIndex >= Count || Array[foundIndex] != item) + { + Insert (foundIndex, item); + } + } + void ShrinkToFit () { if (Most > Count) diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index fdd95b1be..84a4800f7 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -876,7 +876,7 @@ void HWSprite::Process(HWDrawInfo *di, FRenderState& state, AActor* thing, secto if (thing->IsKindOf(NAME_Corona)) { - Coronas.Push(thing); + Coronas.SortedInsertUnique(thing); return; }