[Scummvm-cvs-logs] scummvm master -> 91e51dc510e4b6d8d6fdcaf53748d4331f801629
bluegr
md5 at scummvm.org
Mon Sep 26 14:37:49 CEST 2011
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
397b4968d9 AGI: Rewrote cmdVersion() to use Common::String
686a328b48 AGI: Fixed the line changing code, and added EOL checks
420c9f5550 AGI: Fixed invalid memory writes in wordWrapString()
91e51dc510 AGI: Removed leftover dead code
Commit: 397b4968d9f16c2ad146bd12cb757e1214f9b3fc
https://github.com/scummvm/scummvm/commit/397b4968d9f16c2ad146bd12cb757e1214f9b3fc
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-09-26T05:15:39-07:00
Commit Message:
AGI: Rewrote cmdVersion() to use Common::String
This simplifies the code and avoids heap corruption because of the long
version string
Changed paths:
engines/agi/op_cmd.cpp
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 15f7ac6..07db0ae 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1259,7 +1259,6 @@ void cmdSetMenuItem(AgiGame *state, uint8 *p) {
}
void cmdVersion(AgiGame *state, uint8 *p) {
- char verMsg[64];
char ver2Msg[] =
"\n"
" \n\n"
@@ -1269,33 +1268,17 @@ void cmdVersion(AgiGame *state, uint8 *p) {
" \n\n"
" Emulating AGI v%x.002.%03x\n";
// no Sierra as it wraps textbox
- char *r, *q;
- int ver, maj, min;
- char msg[256];
- int gap;
- int len;
- sprintf(verMsg, TITLE " v%s", gScummVMVersion);
-
- ver = getVersion();
- maj = (ver >> 12) & 0xf;
- min = ver & 0xfff;
-
- q = maj == 2 ? ver2Msg : ver3Msg;
- r = strchr(q + 1, '\n');
-
- // insert our version into the other version
- len = strlen(verMsg);
- gap = r - q;
+ Common::String verMsg = TITLE " v%s";
+
+ int ver = getVersion();
+ int maj = (ver >> 12) & 0xf;
+ int min = ver & 0xfff;
- if (gap < 0)
- gap = 0;
- else
- gap = (gap - len) / 2;
+ verMsg += (maj == 2 ? ver2Msg : ver3Msg);
+ verMsg = Common::String::format(verMsg.c_str(), gScummVMVersion, maj, min);
- strncpy(q + 1 + gap, verMsg, strlen(verMsg));
- sprintf(msg, q, maj, min);
- state->_vm->messageBox(msg);
+ state->_vm->messageBox(verMsg.c_str());
}
void cmdConfigureScreen(AgiGame *state, uint8 *p) {
Commit: 686a328b48482e157eac4d59057f769de228a2a9
https://github.com/scummvm/scummvm/commit/686a328b48482e157eac4d59057f769de228a2a9
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-09-26T05:21:04-07:00
Commit Message:
AGI: Fixed the line changing code, and added EOL checks
The extra checks make sure that there isn't an extra line added at the
end of the string. They're added as a precautionary measure
Changed paths:
engines/agi/text.cpp
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 9116d5a..6bba90d 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -81,14 +81,17 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
x1++;
- // Change line if we've reached the end of this one
- if (x1 == len && m[len - 1] != '\n') {
+ // Change line if we've reached the end of this one, unless the next
+ // character is a new line itself, or the end of the string
+ if (x1 == len && m[1] != '\n' && m[1] != 0) {
y1++;
x1 = foff = 0;
}
} else {
- y1++;
- x1 = foff = 0;
+ if (m[1] != 0) {
+ y1++;
+ x1 = foff = 0;
+ }
}
}
}
Commit: 420c9f5550aedd89779daeb6c3d8397dc6107720
https://github.com/scummvm/scummvm/commit/420c9f5550aedd89779daeb6c3d8397dc6107720
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-09-26T05:22:48-07:00
Commit Message:
AGI: Fixed invalid memory writes in wordWrapString()
Changed paths:
engines/agi/text.cpp
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 6bba90d..2a159b5 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -225,8 +225,10 @@ char *AgiEngine::wordWrapString(const char *s, int *len) {
const char *pWord;
int lnLen, wLen;
- // FIXME: outStr may end up being longer than s, so this can overflow
- msgBuf = outStr = strdup(s);
+ // Allocate some extra space for the final buffer, as
+ // outStr may end up being longer than s
+ // 26 = 200 (screen height) / 8 (font height) + 1
+ msgBuf = outStr = (char *)malloc(strlen(s) + 26);
int msgWidth = 0;
Commit: 91e51dc510e4b6d8d6fdcaf53748d4331f801629
https://github.com/scummvm/scummvm/commit/91e51dc510e4b6d8d6fdcaf53748d4331f801629
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-09-26T05:27:05-07:00
Commit Message:
AGI: Removed leftover dead code
Changed paths:
engines/agi/text.cpp
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 2a159b5..502db4b 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -62,7 +62,10 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
for (m = (const unsigned char *)msg, x1 = y1 = 0; *m; m++) {
- if (*m >= 0x20 || *m == 1 || *m == 2 || *m == 3) {
+ // Note: there were extra checks for *m being a cursor character
+ // here (1, 2 or 3), which have been removed, as the cursor
+ // character is no longer printed via this function.
+ if (*m >= 0x20) {
int ypos = (y1 * CHAR_LINES) + yoff;
if ((x1 != (len - 1) || x1 == 39) && (ypos <= (GFX_HEIGHT - CHAR_LINES))) {
More information about the Scummvm-git-logs
mailing list