Skip to content

Commit 631fadd

Browse files
author
Pavel Kovalenko
committed
Fix bug related to removing inactual statics in CUIGameCustom::OnFrame.
1 parent 9b7945d commit 631fadd

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/xrGame/UIGameCustom.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020

2121
EGameIDs ParseStringToGameType(const char* str);
2222

23-
bool predicate_sort_stat(const SDrawStaticStruct* s1, const SDrawStaticStruct* s2)
24-
{
25-
return s1->IsActual() > s2->IsActual();
26-
}
27-
2823
struct predicate_find_stat
2924
{
3025
const char* id;
@@ -58,12 +53,13 @@ CUIGameCustom::~CUIGameCustom()
5853
void CUIGameCustom::OnFrame()
5954
{
6055
CDialogHolder::OnFrame();
61-
auto it = CustomStatics.begin();
62-
auto it_e = CustomStatics.end();
63-
for (; it != it_e; ++it)
64-
(*it)->Update();
65-
// BUG: sort is never performed here, so not all inactual items will be deleted
66-
std::sort(it, it_e, predicate_sort_stat);
56+
for (auto item : CustomStatics)
57+
item->Update();
58+
auto comparer = [](const SDrawStaticStruct* s1, const SDrawStaticStruct* s2)
59+
{
60+
return s1->IsActual() > s2->IsActual();
61+
};
62+
std::sort(CustomStatics.begin(), CustomStatics.end(), comparer);
6763
while (!CustomStatics.empty() && !CustomStatics.back()->IsActual())
6864
{
6965
delete_data(CustomStatics.back());

0 commit comments

Comments
 (0)