From fd77ef6b0113a30997cc594d1ef3440ad4daad91 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Wed, 23 Dec 2020 03:33:34 +0300 Subject: [PATCH] Only ignore plain text after the last EOL tag (#5627) --- CHANGELOG.md | 1 + apps/openmw/mwgui/formatting.cpp | 23 ++++++++++++++--------- apps/openmw/mwgui/formatting.hpp | 2 ++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b75a179b1d..e557c7bcb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Bug #5604: Only one valid NIF root node is loaded from a single file Bug #5611: Usable items with "0 Uses" should be used only once Bug #5622: Can't properly interact with the console when in pause menu + Bug #5627: Bookart not shown if it isn't followed by
statement Bug #5633: Damage Spells in effect before god mode is enabled continue to hurt the player character and can kill them Bug #5639: Tooltips cover Messageboxes Bug #5644: Summon effects running on the player during game initialization cause crashes diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 75bf8a3426..156dc5b0d6 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -30,14 +30,18 @@ namespace MWGui // vanilla game does not show any text after the last EOL tag. const std::string lowerText = Misc::StringUtils::lowerCase(mText); - int brIndex = lowerText.rfind("
"); - int pIndex = lowerText.rfind("

"); - if (brIndex == pIndex) - mText = ""; - else if (brIndex > pIndex) - mText = mText.substr(0, brIndex+4); - else - mText = mText.substr(0, pIndex+3); + size_t brIndex = lowerText.rfind("
"); + size_t pIndex = lowerText.rfind("

"); + mPlainTextEnd = 0; + if (brIndex != pIndex) + { + if (brIndex != std::string::npos && pIndex != std::string::npos) + mPlainTextEnd = std::max(brIndex, pIndex); + else if (brIndex != std::string::npos) + mPlainTextEnd = brIndex; + else + mPlainTextEnd = pIndex; + } registerTag("br", Event_BrTag); registerTag("p", Event_PTag); @@ -103,7 +107,8 @@ namespace MWGui { if (!mIgnoreLineEndings || ch != '\n') { - mBuffer.push_back(ch); + if (mIndex < mPlainTextEnd) + mBuffer.push_back(ch); mIgnoreLineEndings = false; mIgnoreNewlineTags = false; } diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index d563514148..12a3d46caa 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -73,6 +73,8 @@ namespace MWGui bool mClosingTag; std::map mTagTypes; std::string mBuffer; + + size_t mPlainTextEnd; }; class Paginator