[Scummvm-cvs-logs] SF.net SVN: scummvm: [27887] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Tue Jul 3 21:44:31 CEST 2007
Revision: 27887
http://scummvm.svn.sourceforge.net/scummvm/?rev=27887&view=rev
Author: peres001
Date: 2007-07-03 12:44:31 -0700 (Tue, 03 Jul 2007)
Log Message:
-----------
Changed Dialogue from a typedef for an implicit n-tree of Questions to a plain-vanilla array. This greatly simplify management and doesn't require obscure flagging of tree leaves.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/dialogue.cpp
scummvm/trunk/engines/parallaction/zone.h
Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp 2007-07-03 19:27:44 UTC (rev 27886)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp 2007-07-03 19:44:31 UTC (rev 27887)
@@ -59,8 +59,9 @@
Dialogue *Parallaction::parseDialogue(Script &script) {
// printf("parseDialogue()\n");
uint16 numQuestions = 0;
- Question *_questions[20];
+ Dialogue *dialogue = new Dialogue;
+
Table forwards(20);
fillBuffers(script, true);
@@ -68,23 +69,23 @@
while (scumm_stricmp(_tokens[0], "enddialogue")) {
if (scumm_stricmp(_tokens[0], "Question")) continue;
- _questions[numQuestions] = new Dialogue;
- Dialogue *dialogue = _questions[numQuestions];
+ Question *question = new Question;
+ dialogue->_questions[numQuestions] = question;
forwards.addData(_tokens[1]);
- dialogue->_text = parseDialogueString(script);
+ question->_text = parseDialogueString(script);
fillBuffers(script, true);
- dialogue->_mood = atoi(_tokens[0]);
+ question->_mood = atoi(_tokens[0]);
uint16 numAnswers = 0;
fillBuffers(script, true);
while (scumm_stricmp(_tokens[0], "endquestion")) { // parse answers
- dialogue->_answers[numAnswers] = new Answer;
- Answer *answer = dialogue->_answers[numAnswers];
+ Answer *answer = new Answer;
+ question->_answers[numAnswers] = answer;
if (_tokens[1][0]) {
@@ -141,7 +142,7 @@
memset(v50, 0, 20);
for (uint16 i = 0; i < numQuestions; i++) {
- Question *question = _questions[i];
+ Question *question = dialogue->_questions[i];
for (uint16 j = 0; j < NUM_ANSWERS; j++) {
Answer *answer = question->_answers[j];
@@ -150,21 +151,16 @@
int16 index = forwards.lookup(answer->_following._name);
free(answer->_following._name);
- if (index == -1) {
+ if (index == -1)
answer->_following._question = 0;
- } else {
- answer->_following._question = _questions[index - 1];
+ else
+ answer->_following._question = dialogue->_questions[index - 1];
- if (v50[index])
- answer->_mood |= 0x10;
-
- v50[index] = 1;
- }
}
}
- return _questions[0];
+ return dialogue;
}
@@ -383,7 +379,7 @@
_askPassword = false;
CommandList *cmdlist = NULL;
- _q = _dialogue;
+ _q = _dialogue->_questions[0];
int16 answer;
while (_q) {
@@ -514,12 +510,8 @@
}
Answer::~Answer() {
- if (_mood & 0x10)
- delete _following._question;
-
if (_text)
free(_text);
-
}
Question::Question() {
Modified: scummvm/trunk/engines/parallaction/zone.h
===================================================================
--- scummvm/trunk/engines/parallaction/zone.h 2007-07-03 19:27:44 UTC (rev 27886)
+++ scummvm/trunk/engines/parallaction/zone.h 2007-07-03 19:44:31 UTC (rev 27887)
@@ -68,7 +68,8 @@
};
-#define NUM_ANSWERS 5
+#define NUM_QUESTIONS 20
+#define NUM_ANSWERS 5
struct Command;
struct Question;
@@ -97,7 +98,9 @@
~Question();
};
-typedef Question Dialogue;
+struct Dialogue {
+ Question *_questions[NUM_QUESTIONS];
+};
struct GetData { // size = 24
uint32 _icon;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list