Skip to content

Commit

Permalink
Fix bug related to removing inactual statics in CUIGameCustom::OnFrame.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 4, 2014
1 parent 9b7945d commit 631fadd
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/xrGame/UIGameCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

EGameIDs ParseStringToGameType(const char* str);

bool predicate_sort_stat(const SDrawStaticStruct* s1, const SDrawStaticStruct* s2)
{
return s1->IsActual() > s2->IsActual();
}

struct predicate_find_stat
{
const char* id;
Expand Down Expand Up @@ -58,12 +53,13 @@ CUIGameCustom::~CUIGameCustom()
void CUIGameCustom::OnFrame()
{
CDialogHolder::OnFrame();
auto it = CustomStatics.begin();
auto it_e = CustomStatics.end();
for (; it != it_e; ++it)
(*it)->Update();
// BUG: sort is never performed here, so not all inactual items will be deleted
std::sort(it, it_e, predicate_sort_stat);
for (auto item : CustomStatics)
item->Update();
auto comparer = [](const SDrawStaticStruct* s1, const SDrawStaticStruct* s2)
{
return s1->IsActual() > s2->IsActual();
};
std::sort(CustomStatics.begin(), CustomStatics.end(), comparer);
while (!CustomStatics.empty() && !CustomStatics.back()->IsActual())
{
delete_data(CustomStatics.back());
Expand Down

0 comments on commit 631fadd

Please sign in to comment.