Skip to content

Commit

Permalink
Fix infinte loop bug when trying to render multi-line text in a small…
Browse files Browse the repository at this point in the history
… area
  • Loading branch information
dorkster committed Jul 18, 2018
1 parent cb2bb35 commit 5718d02
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Engine fixes:
* Fixed GetText bug where strings weren't being sanitized.
* Fix locked left/right keys when loading a cutscene from the dev console.
* Using the --mods command line flag doesn't overwrite the user's mod configuration.
* Fix infinte loop bug when trying to render multi-line text in a small area.
* Lots of code cleanup.

New translations:
Expand Down
14 changes: 13 additions & 1 deletion src/FontEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ Point FontEngine::calc_size(const std::string& text_with_newlines, int width) {

next_word = long_token;
long_token = popTokenByWidth(next_word, width);

if (long_token == next_word)
break;
}
}

Expand All @@ -180,7 +183,10 @@ Point FontEngine::calc_size(const std::string& text_with_newlines, int width) {
builder_prev.str(builder.str());
}

next_word = getNextToken(fulltext, cursor, space); // get next word
std::string old_word = next_word;
next_word = getNextToken(fulltext, cursor, space); // next word
if (old_word == next_word)
break;
}

builder.str(Parse::trim(builder.str())); //removes whitespace that shouldn't be included in the size
Expand Down Expand Up @@ -267,6 +273,9 @@ void FontEngine::render(const std::string& text, int x, int y, int justify, Imag

next_word = long_token;
long_token = popTokenByWidth(next_word, width);

if (long_token == next_word)
break;
}
}

Expand All @@ -278,7 +287,10 @@ void FontEngine::render(const std::string& text, int x, int y, int justify, Imag
builder_prev.str(builder.str());
}

std::string old_word = next_word;
next_word = getNextToken(fulltext, cursor, space); // next word
if (old_word == next_word)
break;
}

renderInternal(builder.str(), x, cursor_y, justify, target, color);
Expand Down
2 changes: 1 addition & 1 deletion src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLARE. If not, see http:https://www.gnu.org/licenses/

#include <SDL.h>

Version VersionInfo::ENGINE(1, 6, 18);
Version VersionInfo::ENGINE(1, 6, 19);
Version VersionInfo::MIN(0, 0, 0);
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);

Expand Down

0 comments on commit 5718d02

Please sign in to comment.