Skip to content

Commit

Permalink
Don't use unordered maps for ProfilerGraph (fixes flickering)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Oct 12, 2016
1 parent 4f684b5 commit 0b27a70
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/game.cpp
Expand Up @@ -605,7 +605,9 @@ class ProfilerGraph
void draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver,
gui::IGUIFont *font) const
{
UNORDERED_MAP<std::string, Meta> m_meta;
// Do *not* use UNORDERED_MAP here as the order needs
// to be the same for each call to prevent flickering
std::map<std::string, Meta> m_meta;

for (std::deque<Piece>::const_iterator k = m_log.begin();
k != m_log.end(); ++k) {
Expand All @@ -615,7 +617,7 @@ class ProfilerGraph
i != piece.values.end(); ++i) {
const std::string &id = i->first;
const float &value = i->second;
UNORDERED_MAP<std::string, Meta>::iterator j = m_meta.find(id);
std::map<std::string, Meta>::iterator j = m_meta.find(id);

if (j == m_meta.end()) {
m_meta[id] = Meta(value);
Expand All @@ -642,7 +644,7 @@ class ProfilerGraph
sizeof(usable_colors) / sizeof(*usable_colors);
u32 next_color_i = 0;

for (UNORDERED_MAP<std::string, Meta>::iterator i = m_meta.begin();
for (std::map<std::string, Meta>::iterator i = m_meta.begin();
i != m_meta.end(); ++i) {
Meta &meta = i->second;
video::SColor color(255, 200, 200, 200);
Expand All @@ -658,7 +660,7 @@ class ProfilerGraph
s32 textx2 = textx + 200 - 15;
s32 meta_i = 0;

for (UNORDERED_MAP<std::string, Meta>::const_iterator i = m_meta.begin();
for (std::map<std::string, Meta>::const_iterator i = m_meta.begin();
i != m_meta.end(); ++i) {
const std::string &id = i->first;
const Meta &meta = i->second;
Expand Down

0 comments on commit 0b27a70

Please sign in to comment.