diff --git a/CHANGELOG.md b/CHANGELOG.md
index b75a179b1..e557c7bcb 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 75bf8a342..156dc5b0d 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 d56351414..12a3d46ca 100644
--- a/apps/openmw/mwgui/formatting.hpp
+++ b/apps/openmw/mwgui/formatting.hpp
@@ -73,6 +73,8 @@ namespace MWGui
bool mClosingTag;
std::map