aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/converse.cpp41
-rw-r--r--engines/m4/globals.cpp14
-rw-r--r--engines/m4/mads_anim.cpp14
3 files changed, 46 insertions, 23 deletions
diff --git a/engines/m4/converse.cpp b/engines/m4/converse.cpp
index 47d84f6a28..11131783e2 100644
--- a/engines/m4/converse.cpp
+++ b/engines/m4/converse.cpp
@@ -406,10 +406,12 @@ void Converse::loadConversation(const char *convName) {
convS->read(buffer, 8);
if (debugFlag) printf("Conversation name: %s\n", buffer);
- while(!convS->eos()) {
+ while(true) {
chunkPos = convS->pos();
- if (debugFlag) printf("***** Pos: %i -> ", chunkPos);
chunk = convS->readUint32LE(); // read chunk
+ if (convS->eos()) break;
+
+ if (debugFlag) printf("***** Pos: %i -> ", chunkPos);
switch(chunk) {
case CHUNK_DECL: // Declare
if (debugFlag) printf("DECL chunk\n");
@@ -714,7 +716,7 @@ void Converse::loadConversationMads(const char *convName) {
printf("Chunk 0\n");
printf("Conv stream size: %i\n", convS->size());
- while(!convS->eos()) {
+ while(!convS->eos()) { // FIXME (eos changed)
printf("%i ", convS->readByte());
}
printf("\n");
@@ -725,7 +727,7 @@ void Converse::loadConversationMads(const char *convName) {
printf("Chunk 1\n");
printf("Conv stream size: %i\n", convS->size());
- while(!convS->eos()) {
+ while(!convS->eos()) { // FIXME (eos changed)
printf("%i ", convS->readByte());
}
printf("\n");
@@ -736,7 +738,7 @@ void Converse::loadConversationMads(const char *convName) {
printf("Chunk 2\n");
printf("Conv stream size: %i\n", convS->size());
- while(!convS->eos()) {
+ while(!convS->eos()) { // FIXME (eos changed)
printf("%i ", convS->readByte());
}
printf("\n");
@@ -790,7 +792,7 @@ void Converse::loadConversationMads(const char *convName) {
convS->read(buffer, 14); // speech file
printf("Speech file: %s\n", buffer);
- while(!convS->eos()) {
+ while(!convS->eos()) { // FIXME: eos changed
printf("%i ", convS->readByte());
}
printf("\n");
@@ -803,9 +805,12 @@ void Converse::loadConversationMads(const char *convName) {
printf("Chunk 1: conversation nodes\n");
printf("Conv stream size: %i\n", convS->size());
- while(!convS->eos()) {
+ while(true) {
+ uint16 id = convS->readUint16LE();
+ if (convS->eos()) break;
+
curEntry = new ConvEntry();
- curEntry->id = convS->readUint16LE();
+ curEntry->id = id;
curEntry->entryCount = convS->readUint16LE();
curEntry->flags = convS->readUint16LE();
if (curEntry->entryCount == 1 && curEntry->flags != 65535) {
@@ -839,10 +844,13 @@ void Converse::loadConversationMads(const char *convName) {
*buffer = 0;
- while(!convS->eos()) {
+ while(true) {
//if (curPos == 0)
// printf("%i: Offset %i: ", _convStrings.size(), convS->pos());
- buffer[curPos++] = convS->readByte();
+ uint8 b = convS->readByte();
+ if (convS->eos()) break;
+
+ buffer[curPos++] = b;
if (buffer[curPos - 1] == '~') { // filter out special characters
curPos--;
continue;
@@ -892,9 +900,12 @@ void Converse::loadConversationMads(const char *convName) {
//printf("Chunk 3 - MESG chunk data\n");
//printf("Conv stream size: %i\n", convS->size());
- while(!convS->eos()) {
+ while(true) {
+ uint16 index = convS->readUint16LE();
+ if (convS->eos()) break;
+
curMessage = new MessageEntry();
- stringIndex = convS->readUint16LE();
+ stringIndex = index;
stringCount = convS->readUint16LE();
*buffer = 0;
//printf("Message: %i\n", _madsMessageList.size());
@@ -915,7 +926,7 @@ void Converse::loadConversationMads(const char *convName) {
convS = convData.getItemStream(6);
printf("Chunk 6\n");
printf("Conv stream size: %i\n", convS->size());
- /*while(!convS->eos()) {
+ /*while(!convS->eos()) { // FIXME (eos changed)
printf("%i ", convS->readByte());
printf("%i ", convS->readByte());
printf("%i ", convS->readByte());
@@ -954,8 +965,10 @@ void Converse::readConvEntryActions(Common::SubReadStream *convS, ConvEntry *cur
int messageIndex = 0;
int unk = 0;
- while(!convS->eos()) {
+ while(true) {
chunk = convS->readByte();
+ if (convS->eos()) break;
+
type = convS->readByte();
switch (chunk) {
diff --git a/engines/m4/globals.cpp b/engines/m4/globals.cpp
index 58c68979d1..98d007f67e 100644
--- a/engines/m4/globals.cpp
+++ b/engines/m4/globals.cpp
@@ -295,8 +295,11 @@ void Globals::loadMadsVocab() {
char buffer[30];
strcpy(buffer, "");
- while(!vocabS->eos()) {
- buffer[curPos++] = vocabS->readByte();
+ while(true) {
+ uint8 b = vocabS->readByte();
+ if (vocabS->eos()) break;
+
+ buffer[curPos++] = b;
if (buffer[curPos - 1] == '\0') {
// end of string, add it to the strings list
_madsVocab.push_back(strdup(buffer));
@@ -315,8 +318,11 @@ void Globals::loadMadsQuotes() {
char buffer[128];
strcpy(buffer, "");
- while(!quoteS->eos()) {
- buffer[curPos++] = quoteS->readByte();
+ while(true) {
+ uint8 b = quoteS->readByte();
+ if (quoteS->eos()) break;
+
+ buffer[curPos++] = b;
if (buffer[curPos - 1] == '\0') {
// end of string, add it to the strings list
_madsQuotes.push_back(strdup(buffer));
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index e028f5e0f1..71b45ca77c 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -247,15 +247,16 @@ void TextviewView::scriptDone() {
}
void TextviewView::processLines() {
+ _script->readLine_OLD(_currentLine, 79);
if (_script->eos())
error("Attempted to read past end of response file");
while (!_script->eos()) {
- _script->readLine_OLD(_currentLine, 79);
-
// Commented out line, so go loop for another
- if (_currentLine[0] == '#')
+ if (_currentLine[0] == '#') {
+ _script->readLine_OLD(_currentLine, 79);
continue;
+ }
// Process the line
char *cStart = strchr(_currentLine, '[');
@@ -284,6 +285,8 @@ void TextviewView::processLines() {
processText();
break;
}
+
+ _script->readLine_OLD(_currentLine, 79);
}
}
@@ -594,6 +597,7 @@ void AnimviewView::scriptDone() {
}
void AnimviewView::processLines() {
+ _script->readLine_OLD(_currentLine, 79);
if (_script->eos()) {
// end of script, end animation
scriptDone();
@@ -601,8 +605,6 @@ void AnimviewView::processLines() {
}
while (!_script->eos()) {
- _script->readLine_OLD(_currentLine, 79);
-
// Process the line
char *cStart = strchr(_currentLine, '-');
if (cStart) {
@@ -635,6 +637,8 @@ void AnimviewView::processLines() {
//printf("File: %s\n", _currentLine);
break;
}
+
+ _script->readLine_OLD(_currentLine, 79);
}
}