Decoupled password request from actual rendering of the dialogue screen, thus making it possible to fix bug #1765300. This bug was present in the original game, causing garbled text to appear when asking for password (only in the English version).

svn-id: r29213
This commit is contained in:
Nicola Mettifogo 2007-10-13 21:49:38 +00:00
parent 16175cf368
commit 1c52ea0562
4 changed files with 45 additions and 28 deletions

View File

@ -103,14 +103,13 @@ protected:
uint16 DialogueManager::askPassword() {
debugC(3, kDebugExec, "checkDialoguePassword()");
char password[100];
uint16 passwordLen;
while (true) {
clear();
passwordLen = 0;
strcpy(password, ".......");
_password[0] = '\0';
Common::Rect r(_answerBalloonW[0], _answerBalloonH[0]);
r.moveTo(_answerBalloonX[0], _answerBalloonY[0]);
@ -118,7 +117,6 @@ uint16 DialogueManager::askPassword() {
_vm->_gfx->drawBalloon(r, 1);
_vm->_gfx->displayWrappedString(_q->_answers[0]->_text, _answerBalloonX[0], _answerBalloonY[0], 3, MAX_BALLOON_WIDTH);
_vm->_gfx->flatBlitCnv(_answerer, 0, ANSWER_CHARACTER_X, ANSWER_CHARACTER_Y, Gfx::kBitFront);
_vm->_gfx->displayString(_answerBalloonX[0] + 5, _answerBalloonY[0] + _answerBalloonH[0] - 15, "> ", 0);
_vm->_gfx->updateScreen();
Common::Event e;
@ -132,19 +130,21 @@ uint16 DialogueManager::askPassword() {
if (e.type != Common::EVENT_KEYDOWN) continue;
if (!isdigit(e.kbd.ascii)) continue;
password[passwordLen] = e.kbd.ascii;
_password[passwordLen] = e.kbd.ascii;
passwordLen++;
password[passwordLen] = '\0';
_password[passwordLen] = '\0';
_vm->_gfx->displayString(_answerBalloonX[0] + 10, _answerBalloonY[0] + _answerBalloonH[0] - 15, password, 0);
_vm->_gfx->drawBalloon(r, 1);
_vm->_gfx->displayWrappedString(_q->_answers[0]->_text, _answerBalloonX[0], _answerBalloonY[0], 3, MAX_BALLOON_WIDTH);
_vm->_gfx->updateScreen();
g_system->delayMillis(20);
}
if ((!scumm_stricmp(_vm->_char.getBaseName(), _doughName) && !scumm_strnicmp(password, "1732461", 7)) ||
(!scumm_stricmp(_vm->_char.getBaseName(), _donnaName) && !scumm_strnicmp(password, "1622", 4)) ||
(!scumm_stricmp(_vm->_char.getBaseName(), _dinoName) && !scumm_strnicmp(password, "179", 3))) {
if ((!scumm_stricmp(_vm->_char.getBaseName(), _doughName) && !scumm_strnicmp(_password, "1732461", 7)) ||
(!scumm_stricmp(_vm->_char.getBaseName(), _donnaName) && !scumm_strnicmp(_password, "1622", 4)) ||
(!scumm_stricmp(_vm->_char.getBaseName(), _dinoName) && !scumm_strnicmp(_password, "179", 3))) {
break;

View File

@ -556,23 +556,34 @@ bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16
while (strlen(text) > 0) {
text = parseNextToken(text, token, 40, " ", true);
linewidth += getStringWidth(token);
if (linewidth > wrapwidth) {
// wrap line
lines++;
rx = x + 10; // x
ry = y + 4 + lines*10; // y
linewidth = getStringWidth(token);
}
if (!scumm_stricmp(token, "%s")) {
sprintf(token, "%d", _score);
}
if (!scumm_stricmp(token, "%p")) {
lines++;
rx = x + 10;
ry = y + 4 + lines*10; // y
strcpy(token, "> .......");
strncpy(token+2, _password, strlen(_password));
rv = true;
} else
displayString(rx, ry, token, color);
} else {
linewidth += getStringWidth(token);
if (linewidth > wrapwidth) {
// wrap line
lines++;
rx = x + 10; // x
ry = y + 4 + lines*10; // y
linewidth = getStringWidth(token);
}
if (!scumm_stricmp(token, "%s")) {
sprintf(token, "%d", _score);
}
}
displayString(rx, ry, token, color);
rx += getStringWidth(token) + getStringWidth(" ");
linewidth += getStringWidth(" ");
@ -601,13 +612,17 @@ void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* heig
text = parseNextToken(text, token, 40, " ", true);
w += getStringWidth(token);
if (w > maxwidth) {
w -= getStringWidth(token);
if (!scumm_stricmp(token, "%p")) {
lines++;
if (w > *width)
*width = w;
} else {
if (w > maxwidth) {
w -= getStringWidth(token);
lines++;
if (w > *width)
*width = w;
w = getStringWidth(token);
w = getStringWidth(token);
}
}
w += getStringWidth(" ");

View File

@ -53,6 +53,7 @@ char _slideText[2][40];
uint32 _engineFlags = 0;
uint16 _score = 1;
char _password[8];
Command * _forwardedCommands[20] = {
NULL,

View File

@ -155,6 +155,7 @@ public:
extern uint16 _mouseButtons;
extern char _password[8];
extern uint16 _score;
extern uint16 _language;
extern uint32 _engineFlags;