aboutsummaryrefslogtreecommitdiff
path: root/engines/dm
diff options
context:
space:
mode:
authorStrangerke2016-09-12 20:52:04 +0200
committerStrangerke2016-09-12 20:52:04 +0200
commit3be1c24af88db19eee5d76ae88d51aaefdc0ec13 (patch)
tree6cc09216ffbc8663bdcff2d11ecfc3485f377b7d /engines/dm
parentc4e362bf04caed73e06e964b4faa1715dd235a6d (diff)
downloadscummvm-rg350-3be1c24af88db19eee5d76ae88d51aaefdc0ec13.tar.gz
scummvm-rg350-3be1c24af88db19eee5d76ae88d51aaefdc0ec13.tar.bz2
scummvm-rg350-3be1c24af88db19eee5d76ae88d51aaefdc0ec13.zip
DM: Fix a couple of string manipulations into fix-sized buffer
Diffstat (limited to 'engines/dm')
-rw-r--r--engines/dm/dm.cpp7
-rw-r--r--engines/dm/objectman.cpp16
-rw-r--r--engines/dm/text.cpp2
-rw-r--r--engines/dm/text.h2
4 files changed, 12 insertions, 15 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 10d20aef68..b8c1a80645 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -640,11 +640,8 @@ void DMEngine::endGame(bool doNotDrawCreditsOnly) {
if (skillLevel == 1)
continue;
- char displStr[20];
- strcpy(displStr, _inventoryMan->_skillLevelNames[skillLevel - 2]);
- strcat(displStr, " ");
- strcat(displStr, _championMan->_baseSkillName[idx]);
- _textMan->printEndGameString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr);
+ Common::String displStr = Common::String::format("%s %s", _inventoryMan->_skillLevelNames[skillLevel - 2], _championMan->_baseSkillName[idx]);
+ _textMan->printEndGameString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr.c_str());
}
championMirrorBox._y1 += 48;
championMirrorBox._y2 += 48;
diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp
index 7e403be6fe..ffab2392c3 100644
--- a/engines/dm/objectman.cpp
+++ b/engines/dm/objectman.cpp
@@ -235,29 +235,29 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) {
}
void ObjectMan::drawLeaderObjectName(Thing thing) {
- char *objectName = nullptr;
+ Common::String objectName;
int16 iconIndex = getIconIndex(thing);
if (iconIndex == kDMIconIndiceJunkChampionBones) {
Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
- char champBonesName[16];
+ Common::String champBonesName;
switch (_vm->getGameLanguage()) { // localized
case Common::FR_FRA:
// Fix original bug: strcpy was coming after strcat
- strcpy(champBonesName, _objectNames[iconIndex]);
- strcat(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
+ champBonesName = Common::String(_objectNames[iconIndex]);
+ champBonesName += Common::String(_vm->_championMan->_champions[junk->getChargeCount()]._name);
break;
default: // English and German version are the same
- strcpy(champBonesName, _vm->_championMan->_champions[junk->getChargeCount()]._name);
- strcat(champBonesName, _objectNames[iconIndex]);
+ champBonesName = Common::String(_vm->_championMan->_champions[junk->getChargeCount()]._name);
+ champBonesName += Common::String(_objectNames[iconIndex]);
break;
}
objectName = champBonesName;
} else
- objectName = _objectNames[iconIndex];
+ objectName = Common::String(_objectNames[iconIndex]);
- _vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen);
+ _vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName.c_str(), k14_ObjectNameMaximumLength, k200_heightScreen);
}
IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) {
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index b92b43477d..dcf7e27a8e 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -205,7 +205,7 @@ void TextMan::clearExpiredRows() {
}
}
-void TextMan::printEndGameString(int16 x, int16 y, Color textColor, char* text) {
+void TextMan::printEndGameString(int16 x, int16 y, Color textColor, const char* text) {
char modifiedString[50];
char *wrkStringPtr = modifiedString;
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 6a934247d8..ab40925447 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -70,7 +70,7 @@ public:
void initialize(); // @ F0054_TEXT_Initialize
void moveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor
void clearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows
- void printEndGameString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString
+ void printEndGameString(int16 x, int16 y, Color textColor, const char *text); // @ F0443_STARTEND_EndgamePrintString
bool isTextScrolling(TextScroller *scroller, bool waitEndOfScrolling) { return false; } // @ F0561_SCROLLER_IsTextScrolling
void setScrollerCommand(TextScroller *scroller, int16 command) { } // @ F0560_SCROLLER_SetCommand
void clearAllRows(); // @ F0043_TEXT_MESSAGEAREA_ClearAllRows