MADS: Add safeguards in DialogsNebular::show

This commit is contained in:
Strangerke 2015-01-31 12:10:55 +01:00
parent ba330e32be
commit c0b2d47f38

View File

@ -91,6 +91,8 @@ bool DialogsNebular::show(int messageId, int objectId) {
dialog->incNumLines(); dialog->incNumLines();
} }
} else if (commandCheck("ASK", valStr, commandText)) { } else if (commandCheck("ASK", valStr, commandText)) {
if (!dialog)
error("DialogsNebular::show - Uninitialized dialog");
dialog->addInput(); dialog->addInput();
} else if (commandCheck("VERB", valStr, commandText)) { } else if (commandCheck("VERB", valStr, commandText)) {
dialogText += getVocab(action._activeAction._verbId); dialogText += getVocab(action._activeAction._verbId);
@ -114,12 +116,18 @@ bool DialogsNebular::show(int messageId, int objectId) {
} else if (commandCheck("WIDTH", valStr, commandText)) { } else if (commandCheck("WIDTH", valStr, commandText)) {
_dialogWidth = atoi(valStr.c_str()); _dialogWidth = atoi(valStr.c_str());
} else if (commandCheck("BAR", valStr, commandText)) { } else if (commandCheck("BAR", valStr, commandText)) {
if (!dialog)
error("DialogsNebular::show - Uninitialized dialog");
dialog->addBarLine(); dialog->addBarLine();
} else if (commandCheck("UNDER", valStr, commandText)) { } else if (commandCheck("UNDER", valStr, commandText)) {
underlineFlag = true; underlineFlag = true;
} else if (commandCheck("DOWN", valStr, commandText)) { } else if (commandCheck("DOWN", valStr, commandText)) {
if (!dialog)
error("DialogsNebular::show - Uninitialized dialog");
dialog->downPixelLine(); dialog->downPixelLine();
} else if (commandCheck("TAB", valStr, commandText)) { } else if (commandCheck("TAB", valStr, commandText)) {
if (!dialog)
error("DialogsNebular::show - Uninitialized dialog");
int xp = atoi(valStr.c_str()); int xp = atoi(valStr.c_str());
dialog->setLineXp(xp); dialog->setLineXp(xp);
} }
@ -164,6 +172,9 @@ bool DialogsNebular::show(int messageId, int objectId) {
if (!centerFlag) if (!centerFlag)
dialog->incNumLines(); dialog->incNumLines();
if (!dialog)
error("DialogsNebular::show - Uninitialized dialog");
// Show the dialog // Show the dialog
_vm->_events->setCursor(CURSOR_ARROW); _vm->_events->setCursor(CURSOR_ARROW);
dialog->show(); dialog->show();