aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'scumm')
-rw-r--r--scumm/actor.cpp4
-rw-r--r--scumm/dialogs.cpp53
-rw-r--r--scumm/dialogs.h7
-rw-r--r--scumm/script_v6.cpp4
-rw-r--r--scumm/script_v6he.cpp24
-rw-r--r--scumm/script_v8.cpp3
-rw-r--r--scumm/scumm.h2
-rw-r--r--scumm/string.cpp51
8 files changed, 70 insertions, 78 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index cc21a49577..6523f67916 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -1147,9 +1147,7 @@ int ScummEngine::getActorFromPos(int x, int y) {
void ScummEngine::actorTalk() {
Actor *a;
- _msgPtrToAdd = _charsetBuffer;
- _messagePtr = addMessageToStack(_messagePtr);
- assert((int)(_msgPtrToAdd - _charsetBuffer) < (int)(sizeof(_charsetBuffer)));
+ _messagePtr = addMessageToStack(_messagePtr, _charsetBuffer, sizeof(_charsetBuffer));
// FIXME: Workaround for bugs #770039 and #770049
if (_gameId == GID_LOOM || _gameId == GID_LOOM256) {
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp
index ce7884eb48..a0992ee8c0 100644
--- a/scumm/dialogs.cpp
+++ b/scumm/dialogs.cpp
@@ -395,10 +395,6 @@ void MainMenuDialog::load() {
#pragma mark -
enum {
- kOKCmd = 'ok '
-};
-
-enum {
kKeysCmd = 'KEYS'
};
@@ -413,12 +409,14 @@ ConfigDialog::ConfigDialog(ScummEngine *scumm)
// Add the buttons
//
#ifdef _WIN32_WCE
- addButton(_w - kButtonWidth - 8, _h - 24 - 4, "OK", GUI::OptionsDialog::kOKCmd, 'O');
- addButton(_w - 2 * kButtonWidth - 12, _h - 24 - 4, "Cancel", kCloseCmd, 'C');
- addButton(_w - 3 * kButtonWidth - 16, _h - 24 - 4, "Keys", kKeysCmd, 'K');
+ addButton(_w - kButtonWidth - 8, _h - 24 - 4, "Save", GUI::OptionsDialog::kSaveCmd, 'S');
+ addButton(_w - 2 * kButtonWidth - 12, _h - 24 - 4, "Apply", GUI::OptionsDialog::kApplyCmd, 'A');
+ addButton(_w - 3 * kButtonWidth - 16, _h - 24 - 4, "Revert", GUI::OptionsDialog::kRevertCmd, 'R');
+ addButton(_w - 4 * kButtonWidth - 16, _h - 24 - 4, "Keys", kKeysCmd, 'K');
#else
- addButton(_w - kButtonWidth-8, _h - 24, "OK", GUI::OptionsDialog::kOKCmd, 'O');
- addButton(_w - 2 * kButtonWidth-12, _h - 24, "Cancel", kCloseCmd, 'C');
+ addButton(_w - kButtonWidth - 8, _h - 24, "Save", GUI::OptionsDialog::kSaveCmd, 'S');
+ addButton(_w - 2 * kButtonWidth - 12, _h - 24, "Apply", GUI::OptionsDialog::kApplyCmd, 'A');
+ addButton(_w - 3 * kButtonWidth - 16, _h - 24, "Revert", GUI::OptionsDialog::kRevertCmd, 'R');
#endif
//
@@ -446,24 +444,8 @@ ConfigDialog::~ConfigDialog() {
#endif
}
-void ConfigDialog::open() {
- GUI_OptionsDialog::open();
-
- // update checkboxes, too
- subtitlesCheckbox->setState(ConfMan.getBool("subtitles"));
-}
-
-void ConfigDialog::close() {
-
- if (getResult()) {
- // Subtitles
- ConfMan.set("subtitles", subtitlesCheckbox->getState(), _domain);
- // Sync with current setting
- if (_vm->_version >= 7)
- _vm->VAR(_vm->VAR_VOICE_MODE) = subtitlesCheckbox->getState();
- }
-
- GUI_OptionsDialog::close();
+void ConfigDialog::applySettings() {
+ ConfigDialog::applySettings();
// Sync the engine with the config manager
int soundVolumeMaster = ConfMan.getInt("master_volume");
@@ -479,8 +461,25 @@ void ConfigDialog::close() {
_vm->_mixer->setVolume(soundVolumeSfx * soundVolumeMaster / 255);
_vm->_mixer->setMusicVolume(soundVolumeMusic);
+
+ // Sync with current setting
+ if (_vm->_version >= 7)
+ _vm->VAR(_vm->VAR_VOICE_MODE) = ConfMan.getBool("subtitles");
}
+void ConfigDialog::loadSettings() {
+ GUI_OptionsDialog::loadSettings();
+
+ // Update subtitles checkbox
+ subtitlesCheckbox->setState(ConfMan.getBool("subtitles"));
+}
+
+void ConfigDialog::saveSettings() {
+ // Subtitles
+ ConfMan.set("subtitles", subtitlesCheckbox->getState(), _domain);
+
+ GUI_OptionsDialog::saveSettings();
+}
void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
diff --git a/scumm/dialogs.h b/scumm/dialogs.h
index 54a260b621..2531f17c7a 100644
--- a/scumm/dialogs.h
+++ b/scumm/dialogs.h
@@ -112,12 +112,15 @@ public:
ConfigDialog(ScummEngine *scumm);
~ConfigDialog();
- virtual void open();
- virtual void close();
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
protected:
GUI::CheckboxWidget *subtitlesCheckbox;
+
+
+ virtual void applySettings();
+ virtual void loadSettings();
+ virtual void saveSettings();
};
class InfoDialog : public ScummDialog {
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index b036184701..42f00c92c5 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -2508,8 +2508,8 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
const byte *message;
byte buf_input[300], buf_output[300];
_messagePtr = getStringAddressVar(VAR_STRING2DRAW);
- message = _msgPtrToAdd = buf_input;
- addMessageToStack(_messagePtr);
+ message = buf_input;
+ addMessageToStack(_messagePtr, buf_input, sizeof(buf_input));
if ((_gameId == GID_DIG) && !(_features & GF_DEMO)) {
byte buf_trans[300];
char *t_ptr = (char *)buf_input;
diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp
index 9a853d072e..e006b05721 100644
--- a/scumm/script_v6he.cpp
+++ b/scumm/script_v6he.cpp
@@ -955,9 +955,8 @@ void ScummEngine_v6he::o6_openFile() {
int mode, len, slot, l, r;
byte filename[100];
- _msgPtrToAdd = filename;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1003,9 +1002,8 @@ void ScummEngine_v6he::o6_deleteFile() {
int len, r;
byte filename[100];
- _msgPtrToAdd = filename;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1022,9 +1020,8 @@ void ScummEngine_v6he::o6_rename() {
int len, r1, r2;
byte filename[100],filename2[100];
- _msgPtrToAdd = filename;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1034,9 +1031,8 @@ void ScummEngine_v6he::o6_rename() {
break;
}
- _msgPtrToAdd = filename2;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename2, sizeof(filename2));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1344,25 +1340,22 @@ void ScummEngine_v6he::o6_unknownF4() {
switch (b) {
case 1:
- _msgPtrToAdd = filename1;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename1, sizeof(filename1));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, _messagePtr);
break;
case 2:
- _msgPtrToAdd = filename1;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename1, sizeof(filename1));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
- _msgPtrToAdd = filename2;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename2, sizeof(filename2));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1378,9 +1371,8 @@ void ScummEngine_v6he::o6_unknownF9() {
int len, r;
byte filename[100];
- _msgPtrToAdd = filename;
_messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index 6096b64cc3..29d49a0213 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -531,8 +531,7 @@ void ScummEngine_v8::decodeParseString(int m, int n) {
break;
case 5:{
byte buffer[256];
- _msgPtrToAdd = buffer;
- addMessageToStack(_messagePtr);
+ addMessageToStack(_messagePtr, buffer, sizeof(buffer));
enqueueText(buffer, _string[m].xpos, _string[m].ypos, _string[m].color, _string[m].charset, _string[m].center);
}
break;
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 34b9183bc3..6a6facc48f 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -1064,7 +1064,7 @@ protected:
void CHARSET_1();
void drawString(int a);
- const byte *addMessageToStack(const byte *msg);
+ const byte *addMessageToStack(const byte *msg, byte *dstBuffer, int dstBufferSize);
void addIntToStack(int var);
void addVerbToStack(int var);
void addNameToStack(int var);
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 88a76c8b01..16115a43fe 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -48,8 +48,7 @@ void ScummEngine::setStringVars(int slot) {
void ScummEngine::unkMessage1() {
byte buffer[100];
- _msgPtrToAdd = buffer;
- _messagePtr = addMessageToStack(_messagePtr);
+ _messagePtr = addMessageToStack(_messagePtr, buffer, sizeof(buffer));
// if ((_gameId == GID_CMI) && _debugMode) { // In CMI, unkMessage1 is used for printDebug output
if ((buffer[0] != 0xFF) && _debugMode) {
@@ -78,8 +77,7 @@ void ScummEngine::unkMessage2() {
byte buf[100];
const byte *tmp;
- _msgPtrToAdd = buf;
- tmp = _messagePtr = addMessageToStack(_messagePtr);
+ tmp = _messagePtr = addMessageToStack(_messagePtr, buf, sizeof(buf));
if (_string[3].color == 0)
_string[3].color = 4;
@@ -348,8 +346,7 @@ void ScummEngine::drawString(int a) {
byte fontHeight = 0;
uint color;
- _msgPtrToAdd = buf;
- _messagePtr = addMessageToStack(_messagePtr);
+ _messagePtr = addMessageToStack(_messagePtr, buf, sizeof(buf));
_charset->_top = _string[a].ypos + _screenTop;
_charset->_startLeft = _charset->_left = _string[a].xpos;
@@ -366,18 +363,18 @@ void ScummEngine::drawString(int a) {
fontHeight = _charset->getFontHeight();
- _msgPtrToAdd = buf;
// trim from the right
+ byte *tmp = buf;
space = NULL;
- while (*_msgPtrToAdd) {
- if (*_msgPtrToAdd == ' ') {
+ while (*tmp) {
+ if (*tmp == ' ') {
if (!space)
- space = _msgPtrToAdd;
+ space = tmp;
} else {
space = NULL;
}
- _msgPtrToAdd++;
+ tmp++;
}
if (space)
*space = '\0';
@@ -472,12 +469,16 @@ void ScummEngine::drawString(int a) {
}
}
-const byte *ScummEngine::addMessageToStack(const byte *msg) {
+const byte *ScummEngine::addMessageToStack(const byte *msg, byte *dstBuffer, int dstBufferSize) {
uint num = 0;
uint32 val;
byte chr;
byte buf[512];
+ if (dstBuffer) {
+ _msgPtrToAdd = dstBuffer;
+ }
+
if (msg == NULL) {
warning("Bad message in addMessageToStack, ignoring");
return NULL;
@@ -563,6 +564,12 @@ const byte *ScummEngine::addMessageToStack(const byte *msg) {
}
*_msgPtrToAdd = 0;
+ if (dstBuffer) {
+ // Check for a buffer overflow
+ if (_msgPtrToAdd >= dstBuffer + dstBufferSize)
+ error("addMessageToStack: buffer overflow!");
+ }
+
return msg;
}
@@ -582,7 +589,7 @@ void ScummEngine::addVerbToStack(int var) {
if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) {
const byte *ptr = getResourceAddress(rtVerb, k);
ptr = translateTextAndPlaySpeech(ptr);
- addMessageToStack(ptr);
+ addMessageToStack(ptr, 0, 0);
break;
}
}
@@ -599,9 +606,9 @@ void ScummEngine::addNameToStack(int var) {
if (ptr) {
if ((_version == 8) && (ptr[0] == '/')) {
translateText(ptr, _transText);
- addMessageToStack(_transText);
+ addMessageToStack(_transText, 0, 0);
} else {
- addMessageToStack(ptr);
+ addMessageToStack(ptr, 0, 0);
}
}
}
@@ -617,9 +624,9 @@ void ScummEngine::addStringToStack(int var) {
if (ptr) {
if ((_version == 8) && (ptr[0] == '/')) {
translateText(ptr, _transText);
- addMessageToStack(_transText);
+ addMessageToStack(_transText, 0, 0);
} else {
- addMessageToStack(ptr);
+ addMessageToStack(ptr, 0, 0);
}
}
}
@@ -728,6 +735,7 @@ int indexCompare(const void *p1, const void *p2) {
return strcmp(i1->tag, i2->tag);
}
+// Create an index of the language file.
void ScummEngine::loadLanguageBundle() {
File file;
int32 size;
@@ -751,23 +759,16 @@ void ScummEngine::loadLanguageBundle() {
file.read(_languageBuffer, size);
file.close();
- // Create an index of the language file.
- // FIXME: Extend this mechanism to also cover The Dig?
-
int32 i;
char *ptr = _languageBuffer;
// Count the number of lines in the language file.
-
- _languageIndexSize = 0;
-
- for (;;) {
+ for (_languageIndexSize = 0; ; _languageIndexSize++) {
ptr = strpbrk(ptr, "\n\r");
if (ptr == NULL)
break;
while (*ptr == '\n' || *ptr == '\r')
ptr++;
- _languageIndexSize++;
}
// Fill the language file index. This is just an array of