aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2
diff options
context:
space:
mode:
authorColin Snover2017-12-05 12:07:25 -0600
committerEugene Sandulenko2018-08-18 16:30:05 +0200
commit2f872168647e0dc4d87f449ed283b830716ad78e (patch)
tree03c52f38de39b9196f08905b2f196d197b8ce725 /engines/sword2
parent072a52a9d25dfcc59ba7d18049cc29cd17acaffa (diff)
downloadscummvm-rg350-2f872168647e0dc4d87f449ed283b830716ad78e.tar.gz
scummvm-rg350-2f872168647e0dc4d87f449ed283b830716ad78e.tar.bz2
scummvm-rg350-2f872168647e0dc4d87f449ed283b830716ad78e.zip
SWORD2: Replace use of strdup with Common::String
Diffstat (limited to 'engines/sword2')
-rw-r--r--engines/sword2/maketext.cpp6
-rw-r--r--engines/sword2/maketext.h6
-rw-r--r--engines/sword2/screen.cpp18
3 files changed, 13 insertions, 17 deletions
diff --git a/engines/sword2/maketext.cpp b/engines/sword2/maketext.cpp
index e279284d76..765ff0eaeb 100644
--- a/engines/sword2/maketext.cpp
+++ b/engines/sword2/maketext.cpp
@@ -83,7 +83,7 @@ namespace Sword2 {
* error-signal character (chequered flag)
*/
-byte *FontRenderer::makeTextSprite(byte *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes, uint8 border) {
+byte *FontRenderer::makeTextSprite(const byte *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes, uint8 border) {
debug(5, "makeTextSprite(\"%s\", maxWidth=%u)", sentence, maxWidth);
_borderPen = border;
@@ -123,7 +123,7 @@ byte *FontRenderer::makeTextSprite(byte *sentence, uint16 maxWidth, uint8 pen, u
return textSprite;
}
-uint16 FontRenderer::analyzeSentence(byte *sentence, uint16 maxWidth, uint32 fontRes, LineInfo *line) {
+uint16 FontRenderer::analyzeSentence(const byte *sentence, uint16 maxWidth, uint32 fontRes, LineInfo *line) {
// joinWidth = how much extra space is needed to append a word to a
// line. NB. SPACE requires TWICE the '_charSpacing' to join a word
// to line
@@ -207,7 +207,7 @@ uint16 FontRenderer::analyzeSentence(byte *sentence, uint16 maxWidth, uint32 fon
* error-signal character (chequered flag)
*/
-byte *FontRenderer::buildTextSprite(byte *sentence, uint32 fontRes, uint8 pen, LineInfo *line, uint16 noOfLines) {
+byte *FontRenderer::buildTextSprite(const byte *sentence, uint32 fontRes, uint8 pen, LineInfo *line, uint16 noOfLines) {
uint16 i;
// Find the width of the widest line in the output text
diff --git a/engines/sword2/maketext.h b/engines/sword2/maketext.h
index 726c23a5f9..64024f8db3 100644
--- a/engines/sword2/maketext.h
+++ b/engines/sword2/maketext.h
@@ -91,8 +91,8 @@ private:
// each line - negative for overlap
uint8 _borderPen; // output pen color of character borders
- uint16 analyzeSentence(byte *sentence, uint16 maxWidth, uint32 fontRes, LineInfo *line);
- byte *buildTextSprite(byte *sentence, uint32 fontRes, uint8 pen, LineInfo *line, uint16 noOfLines);
+ uint16 analyzeSentence(const byte *sentence, uint16 maxWidth, uint32 fontRes, LineInfo *line);
+ byte *buildTextSprite(const byte *sentence, uint32 fontRes, uint8 pen, LineInfo *line, uint16 noOfLines);
uint16 charWidth(byte ch, uint32 fontRes);
uint16 charHeight(uint32 fontRes);
byte *findChar(byte ch, byte *charSet);
@@ -109,7 +109,7 @@ public:
free(_blocList[i].text_mem);
}
- byte *makeTextSprite(byte *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes, uint8 border = BORDER_PEN);
+ byte *makeTextSprite(const byte *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes, uint8 border = BORDER_PEN);
void killTextBloc(uint32 bloc_number);
void printTextBlocs();
diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp
index 40baf67e46..f3363df45f 100644
--- a/engines/sword2/screen.cpp
+++ b/engines/sword2/screen.cpp
@@ -845,22 +845,18 @@ enum {
};
struct CreditsLine {
- char *str;
+ Common::String str;
byte type;
int top;
int height;
byte *sprite;
CreditsLine() {
- str = NULL;
sprite = NULL;
}
~CreditsLine() {
- free(str);
free(sprite);
- str = NULL;
- sprite = NULL;
}
};
@@ -1036,7 +1032,7 @@ void Screen::rollCredits() {
creditsLines[lineCount]->top = lineTop;
creditsLines[lineCount]->height = CREDITS_FONT_HEIGHT;
creditsLines[lineCount]->type = LINE_LEFT;
- creditsLines[lineCount]->str = strdup(line);
+ creditsLines[lineCount]->str = line;
lineCount++;
*center_mark = '^';
@@ -1063,7 +1059,7 @@ void Screen::rollCredits() {
lineTop += CREDITS_LINE_SPACING;
}
- creditsLines[lineCount]->str = strdup(line);
+ creditsLines[lineCount]->str = line;
lineCount++;
}
@@ -1113,7 +1109,7 @@ void Screen::rollCredits() {
// Free any sprites that have scrolled off the screen
if (creditsLines[i]->top + creditsLines[i]->height < scrollPos) {
- debug(2, "Freeing line %d: '%s'", i, creditsLines[i]->str);
+ debug(2, "Freeing line %d: '%s'", i, creditsLines[i]->str.c_str());
delete creditsLines[i];
creditsLines[i] = NULL;
@@ -1121,8 +1117,8 @@ void Screen::rollCredits() {
startLine = i + 1;
} else if (creditsLines[i]->top < scrollPos + 400) {
if (!creditsLines[i]->sprite) {
- debug(2, "Creating line %d: '%s'", i, creditsLines[i]->str);
- creditsLines[i]->sprite = _vm->_fontRenderer->makeTextSprite((byte *)creditsLines[i]->str, 600, 14, _vm->_speechFontId, 0);
+ debug(2, "Creating line %d: '%s'", i, creditsLines[i]->str.c_str());
+ creditsLines[i]->sprite = _vm->_fontRenderer->makeTextSprite((byte *)creditsLines[i]->str.c_str(), 600, 14, _vm->_speechFontId, 0);
}
FrameHeader frame;
@@ -1143,7 +1139,7 @@ void Screen::rollCredits() {
spriteInfo.x = RENDERWIDE / 2 + 5;
break;
case LINE_CENTER:
- if (strcmp(creditsLines[i]->str, "@") == 0) {
+ if (strcmp(creditsLines[i]->str.c_str(), "@") == 0) {
spriteInfo.data = logoData;
spriteInfo.x = (RENDERWIDE - logoWidth) / 2;
spriteInfo.w = logoWidth;