aboutsummaryrefslogtreecommitdiff
path: root/engines/access/data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/access/data.cpp')
-rw-r--r--engines/access/data.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 36797b62ea..90f712af3b 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -22,6 +22,8 @@
#include "common/algorithm.h"
#include "access/data.h"
+#include "graphics/palette.h"
+#include "common/system.h"
namespace Access {
@@ -127,9 +129,13 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
if (width < maxWidth)
continue;
- // Reached maximum allowed. Work backwards to find space at the
- // start of the current word as a point to split the line on
- --src;
+ // Reached maximum allowed size
+ // If this was the last character of the string, let it go
+ if (*src == '\0')
+ break;
+
+ // Work backwards to find space at the start of the current word
+ // as a point to split the line on
while (src >= s.c_str() && *src != ' ') {
width -= charWidth(*src);
--src;
@@ -138,7 +144,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
error("Could not fit line");
// Split the line around the space
- line = Common::String(s.c_str(), src - 1);
+ line = Common::String(s.c_str(), src);
s = Common::String(src + 1);
return false;
}