SHERLOCK: Re-add GCC_PRINTF and fix resulting GCC warnings

This commit is contained in:
Paul Gilbert 2015-05-20 08:28:12 -04:00
parent fe8139b571
commit 30133cef0e
8 changed files with 48 additions and 48 deletions

View File

@ -732,26 +732,26 @@ bool Journal::drawJournal(int direction, int howFar) {
screen.gPrint(Common::Point(53, yp), 15, "%s", lineStart.c_str() + 1);
} else {
width = screen.stringWidth(lineStart.c_str());
screen.gPrint(Common::Point(53, yp), PEN_COLOR, lineStart.c_str());
}
screen.gPrint(Common::Point(53, yp), PEN_COLOR, "%s", lineStart.c_str());
}
// Print out the found keyword
Common::String lineMatch(matchP, matchP + _find.size());
screen.gPrint(Common::Point(53 + width, yp), INV_FOREGROUND, lineMatch.c_str());
screen.gPrint(Common::Point(53 + width, yp), INV_FOREGROUND, "%s", lineMatch.c_str());
width += screen.stringWidth(lineMatch.c_str());
// Print remainder of line
screen.gPrint(Common::Point(53 + width, yp), PEN_COLOR, matchP + _find.size());
screen.gPrint(Common::Point(53 + width, yp), PEN_COLOR, "%s", matchP + _find.size());
} else if (_lines[temp].hasPrefix("@")) {
screen.gPrint(Common::Point(53, yp), 15, _lines[temp].c_str() + 1);
screen.gPrint(Common::Point(53, yp), 15, "%s", _lines[temp].c_str() + 1);
} else {
screen.gPrint(Common::Point(53, yp), PEN_COLOR, _lines[temp].c_str());
screen.gPrint(Common::Point(53, yp), PEN_COLOR, "%s", _lines[temp].c_str());
}
} else {
if (_lines[temp].hasPrefix("@")) {
screen.gPrint(Common::Point(53, yp), 15, _lines[temp].c_str() + 1);
screen.gPrint(Common::Point(53, yp), 15, "%s", _lines[temp].c_str() + 1);
} else {
screen.gPrint(Common::Point(53, yp), PEN_COLOR, _lines[temp].c_str());
screen.gPrint(Common::Point(53, yp), PEN_COLOR, "%s", _lines[temp].c_str());
}
}
@ -1033,7 +1033,7 @@ int Journal::getSearchString(bool printError) {
INV_FOREGROUND, "Text Not Found !");
} else if (!_find.empty()) {
// There's already a search term, display it already
screen.gPrint(Common::Point(15, 185), TALK_FOREGROUND, _find.c_str());
screen.gPrint(Common::Point(15, 185), TALK_FOREGROUND, "%s", _find.c_str());
name = _find;
}
@ -1051,7 +1051,7 @@ int Journal::getSearchString(bool printError) {
screen.fillRect(Common::Rect(13, 186, 306, 195), BUTTON_MIDDLE);
if (!_find.empty()) {
screen.gPrint(Common::Point(15, 185), TALK_FOREGROUND, _find.c_str());
screen.gPrint(Common::Point(15, 185), TALK_FOREGROUND, "%s", _find.c_str());
name = _find;
}

View File

@ -349,9 +349,9 @@ void Map::showPlaceName(int idx, bool highlighted) {
if (highlighted) {
int xp = (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(name)) / 2;
screen.gPrint(Common::Point(xp + 2, 2), 0, name.c_str());
screen.gPrint(Common::Point(xp + 1, 1), 0, name.c_str());
screen.gPrint(Common::Point(xp, 0), 12, name.c_str());
screen.gPrint(Common::Point(xp + 2, 2), 0, "%s", name.c_str());
screen.gPrint(Common::Point(xp + 1, 1), 0, "%s", name.c_str());
screen.gPrint(Common::Point(xp, 0), 12, "%s", name.c_str());
screen.slamArea(xp, 0, width + 2, 15);
}

View File

@ -865,13 +865,13 @@ int Object::checkNameForCodes(const Common::String &name, const char *const mess
int messageNum = atoi(name.c_str() + 1);
ui._infoFlag = true;
ui.clearInfo();
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[messageNum]);
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[messageNum]);
ui._menuCounter = 25;
} else if (name.hasPrefix("@")) {
// Message attached to canimation
ui._infoFlag = true;
ui.clearInfo();
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, name.c_str() + 1);
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", name.c_str() + 1);
printed = true;
ui._menuCounter = 25;
}
@ -955,7 +955,7 @@ int Object::pickUpObject(const char *const messages[]) {
ui._infoFlag = true;
ui.clearInfo();
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[message]);
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[message]);
ui._menuCounter = 30;
} else {
// Pick it up

View File

@ -235,10 +235,10 @@ void Darts::showNames(int playerNum) {
if (playerNum != 0)
screen.print(Common::Point(STATUS_INFO_X + 50, STATUS_INFO_Y), PLAYER_COLOR + 3,
_opponent.c_str());
"%s", _opponent.c_str());
else
screen.print(Common::Point(STATUS_INFO_X + 50, STATUS_INFO_Y), color,
_opponent.c_str());
"%s", _opponent.c_str());
screen._backBuffer1.fillRect(Common::Rect(STATUS_INFO_X + 50, STATUS_INFO_Y + 10,
STATUS_INFO_X + 81, STATUS_INFO_Y + 12), color);

View File

@ -369,16 +369,16 @@ void Screen::buttonPrint(const Common::Point &pt, byte color, bool slamIt,
if (slamIt) {
print(Common::Point(xStart, pt.y + 1), COMMAND_HIGHLIGHTED, "%c", str[0]);
print(Common::Point(xStart + charWidth(str[0]), pt.y + 1),
COMMAND_FOREGROUND, str.c_str() + 1);
COMMAND_FOREGROUND, "%s", str.c_str() + 1);
} else {
gPrint(Common::Point(xStart, pt.y), COMMAND_HIGHLIGHTED, "%c", str[0]);
gPrint(Common::Point(xStart + charWidth(str[0]), pt.y),
COMMAND_FOREGROUND, str.c_str() + 1);
COMMAND_FOREGROUND, "%s", str.c_str() + 1);
}
} else if (slamIt) {
print(Common::Point(xStart, pt.y + 1), color, str.c_str());
print(Common::Point(xStart, pt.y + 1), color, "%s", str.c_str());
} else {
gPrint(Common::Point(xStart, pt.y), color, str.c_str());
gPrint(Common::Point(xStart, pt.y), color, "%s", str.c_str());
}
}

View File

@ -145,12 +145,12 @@ public:
* Prints the text passed onto the back buffer at the given position and color.
* The string is then blitted to the screen
*/
void print(const Common::Point &pt, byte color, const char *formatStr, ...);
void print(const Common::Point &pt, byte color, const char *formatStr, ...) GCC_PRINTF(4, 5);
/**
* Print a strings onto the back buffer without blitting it to the screen
*/
void gPrint(const Common::Point &pt, byte color, const char *formatStr, ...);
void gPrint(const Common::Point &pt, byte color, const char *formatStr, ...) GCC_PRINTF(4, 5);
/**
* Copies a section of the second back buffer into the main back buffer

View File

@ -772,23 +772,23 @@ int Talk::talkLine(int lineNum, int stateNum, byte color, int lineY, bool slamIt
// Are we drawing the first line?
if (lineStartP == msg.c_str()) {
// We are, so print the number and then the text
screen.print(Common::Point(16, lineY), color, number.c_str());
screen.print(Common::Point(16, lineY), color, "%s", number.c_str());
}
// Draw the line with an indent
screen.print(Common::Point(30, lineY), color, sLine.c_str());
screen.print(Common::Point(30, lineY), color, "%s", sLine.c_str());
} else {
screen.print(Common::Point(16, lineY), color, sLine.c_str());
screen.print(Common::Point(16, lineY), color, "%s", sLine.c_str());
}
} else {
if (numberFlag) {
if (lineStartP == msg.c_str()) {
screen.gPrint(Common::Point(16, lineY - 1), color, number.c_str());
screen.gPrint(Common::Point(16, lineY - 1), color, "%s", number.c_str());
}
screen.gPrint(Common::Point(30, lineY - 1), color, sLine.c_str());
screen.gPrint(Common::Point(30, lineY - 1), color, "%s", sLine.c_str());
} else {
screen.gPrint(Common::Point(16, lineY - 1), color, sLine.c_str());
screen.gPrint(Common::Point(16, lineY - 1), color, "%s", sLine.c_str());
}
}
@ -1367,7 +1367,7 @@ void Talk::doScript(const Common::String &script) {
tempString += str[idx + 1];
str += str[0];
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, tempString.c_str());
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", tempString.c_str());
ui._menuCounter = 30;
break;
@ -1426,9 +1426,9 @@ void Talk::doScript(const Common::String &script) {
// If the window is open, display the name directly on-screen.
// Otherwise, simply draw it on the back buffer
if (ui._windowOpen) {
screen.print(Common::Point(16, yp), TALK_FOREGROUND, NAMES[_speaker & 127]);
screen.print(Common::Point(16, yp), TALK_FOREGROUND, "%s", NAMES[_speaker & 127]);
} else {
screen.gPrint(Common::Point(16, yp - 1), TALK_FOREGROUND, NAMES[_speaker & 127]);
screen.gPrint(Common::Point(16, yp - 1), TALK_FOREGROUND, "%s", NAMES[_speaker & 127]);
openTalkWindow = true;
}
@ -1466,16 +1466,16 @@ void Talk::doScript(const Common::String &script) {
// If the speaker indicates a description file, print it in yellow
if (_speaker != -1) {
if (ui._windowOpen) {
screen.print(Common::Point(16, yp), COMMAND_FOREGROUND, lineStr.c_str());
screen.print(Common::Point(16, yp), COMMAND_FOREGROUND, "%s", lineStr.c_str());
} else {
screen.gPrint(Common::Point(16, yp - 1), COMMAND_FOREGROUND, lineStr.c_str());
screen.gPrint(Common::Point(16, yp - 1), COMMAND_FOREGROUND, "%s", lineStr.c_str());
openTalkWindow = true;
}
} else {
if (ui._windowOpen) {
screen.print(Common::Point(16, yp), COMMAND_FOREGROUND, lineStr.c_str());
screen.print(Common::Point(16, yp), COMMAND_FOREGROUND, "%s", lineStr.c_str());
} else {
screen.gPrint(Common::Point(16, yp - 1), COMMAND_FOREGROUND, lineStr.c_str());
screen.gPrint(Common::Point(16, yp - 1), COMMAND_FOREGROUND, "%s", lineStr.c_str());
openTalkWindow = true;
}
}

View File

@ -230,7 +230,7 @@ void UserInterface::handleInput() {
if (_help != -1 && !scene._bgShapes[_bgFound]._description.empty()
&& scene._bgShapes[_bgFound]._description[0] != ' ')
screen.print(Common::Point(0, INFO_LINE + 1),
INFO_FOREGROUND, scene._bgShapes[_bgFound]._description.c_str());
INFO_FOREGROUND, "%s", scene._bgShapes[_bgFound]._description.c_str());
_oldBgFound = _bgFound;
}
@ -603,14 +603,14 @@ void UserInterface::lookScreen(const Common::Point &pt) {
if (_selector != -1) {
screen.print(Common::Point(xStart + width, INFO_LINE + 1),
TALK_FOREGROUND, inv[_selector]._name.c_str());
TALK_FOREGROUND, "%s", inv[_selector]._name.c_str());
screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1),
INFO_FOREGROUND, " on ");
screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1),
INFO_FOREGROUND, tempStr.c_str());
INFO_FOREGROUND, "%s", tempStr.c_str());
} else {
screen.print(Common::Point(xStart + width, INFO_LINE + 1),
INFO_FOREGROUND, tempStr.c_str());
INFO_FOREGROUND, "%s", tempStr.c_str());
}
} else if (temp >= 0 && temp < 1000 && _selector != -1 &&
scene._bgShapes[temp]._aType == PERSON) {
@ -632,14 +632,14 @@ void UserInterface::lookScreen(const Common::Point &pt) {
screen.print(Common::Point(xStart, INFO_LINE + 1),
INFO_FOREGROUND, "Give ");
screen.print(Common::Point(xStart + width, INFO_LINE + 1),
TALK_FOREGROUND, inv[_selector]._name.c_str());
TALK_FOREGROUND, "%s", inv[_selector]._name.c_str());
screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1),
INFO_FOREGROUND, " to ");
screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1),
INFO_FOREGROUND, tempStr.c_str());
INFO_FOREGROUND, "%s", tempStr.c_str());
}
} else {
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, tempStr.c_str());
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", tempStr.c_str());
}
_infoFlag = true;
@ -664,7 +664,7 @@ void UserInterface::lookInv() {
if (temp < inv._holdings) {
clearInfo();
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND,
inv[temp]._description.c_str());
"%s", inv[temp]._description.c_str());
_infoFlag = true;
_oldLook = temp;
}
@ -1896,7 +1896,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
// Print out the line
Common::String line(lineStartP, msgP);
screen.gPrint(Common::Point(16, CONTROLS_Y + 12 + lineNum * 9),
INV_FOREGROUND, line.c_str());
INV_FOREGROUND, "%s", line.c_str());
if (!endOfStr)
// Start next line at start of the nxet word after space
@ -2148,7 +2148,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv
} else if (messages == nullptr) {
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that.");
} else {
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[0]);
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[0]);
}
_infoFlag = true;
@ -2174,7 +2174,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[]
// Invalid action, to print error message
_infoFlag = true;
clearInfo();
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]);
screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[action._cAnimNum]);
_infoFlag = true;
// Set how long to show the message