aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2010-02-08 16:13:09 +0000
committerNicola Mettifogo2010-02-08 16:13:09 +0000
commit1fe0facb2447ea62b9b8dcb03a2a879de24fc51f (patch)
tree08c32b7ca6b3a1cb0a3487ef594d472dd29ab8fc
parent0b06fb2a88aa33e6f74b42de84aa3a1f4f9b87ac (diff)
downloadscummvm-rg350-1fe0facb2447ea62b9b8dcb03a2a879de24fc51f.tar.gz
scummvm-rg350-1fe0facb2447ea62b9b8dcb03a2a879de24fc51f.tar.bz2
scummvm-rg350-1fe0facb2447ea62b9b8dcb03a2a879de24fc51f.zip
Pass the input stream to text parser functions.
svn-id: r47992
-rw-r--r--engines/drascula/converse.cpp22
-rw-r--r--engines/drascula/drascula.cpp18
-rw-r--r--engines/drascula/drascula.h6
-rw-r--r--engines/drascula/rooms.cpp72
4 files changed, 60 insertions, 58 deletions
diff --git a/engines/drascula/converse.cpp b/engines/drascula/converse.cpp
index b98e7e8cb4..707ae55b63 100644
--- a/engines/drascula/converse.cpp
+++ b/engines/drascula/converse.cpp
@@ -150,17 +150,17 @@ void DrasculaEngine::converse(int index) {
selectVerb(kVerbNone);
- getStringFromLine(size, phrase1);
- getStringFromLine(size, phrase2);
- getStringFromLine(size, phrase3);
- getStringFromLine(size, phrase4);
- getStringFromLine(size, sound1);
- getStringFromLine(size, sound2);
- getStringFromLine(size, sound3);
- getStringFromLine(size, sound4);
- getIntFromLine(size, &answer1);
- getIntFromLine(size, &answer2);
- getIntFromLine(size, &answer3);
+ getStringFromLine(_arj, size, phrase1);
+ getStringFromLine(_arj, size, phrase2);
+ getStringFromLine(_arj, size, phrase3);
+ getStringFromLine(_arj, size, phrase4);
+ getStringFromLine(_arj, size, sound1);
+ getStringFromLine(_arj, size, sound2);
+ getStringFromLine(_arj, size, sound3);
+ getStringFromLine(_arj, size, sound4);
+ getIntFromLine(_arj, size, &answer1);
+ getIntFromLine(_arj, size, &answer2);
+ getIntFromLine(_arj, size, &answer3);
_arj.close();
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 3920f8a56c..824a5eb2dd 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -604,15 +604,15 @@ bool DrasculaEngine::runCurrentChapter() {
}
}
-char *DrasculaEngine::getLine(char *buf, int len) {
+char *DrasculaEngine::getLine(Common::SeekableReadStream &stream, char *buf, int len) {
byte c;
char *b;
for (;;) {
b = buf;
while (true) {
- c = ~_arj.readByte();
- if (_arj.eos()) break;
+ c = ~stream.readByte();
+ if (stream.eos()) break;
if (c == '\r')
continue;
@@ -621,7 +621,7 @@ char *DrasculaEngine::getLine(char *buf, int len) {
*b++ = c;
}
*b = '\0';
- if (_arj.eos() && b == buf)
+ if (stream.eos() && b == buf)
return NULL;
if (b != buf)
break;
@@ -629,13 +629,15 @@ char *DrasculaEngine::getLine(char *buf, int len) {
return buf;
}
-void DrasculaEngine::getIntFromLine(char *buf, int len, int* result) {
- getLine(buf, len);
+void DrasculaEngine::getIntFromLine(Common::SeekableReadStream &stream, int len, int* result) {
+ char buf[256];
+ getLine(stream, buf, len);
sscanf(buf, "%d", result);
}
-void DrasculaEngine::getStringFromLine(char *buf, int len, char* result) {
- getLine(buf, len);
+void DrasculaEngine::getStringFromLine(Common::SeekableReadStream &stream, int len, char* result) {
+ char buf[256];
+ getLine(stream, buf, len);
sscanf(buf, "%s", result);
}
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index 1b1223ce79..1680fe5311 100644
--- a/engines/drascula/drascula.h
+++ b/engines/drascula/drascula.h
@@ -577,9 +577,9 @@ public:
void MusicFadeout();
void playFile(const char *fname);
- char *getLine(char *buf, int len);
- void getIntFromLine(char *buf, int len, int* result);
- void getStringFromLine(char *buf, int len, char* result);
+ char *getLine(Common::SeekableReadStream &stream, char *buf, int len);
+ void getIntFromLine(Common::SeekableReadStream &stream, int len, int* result);
+ void getStringFromLine(Common::SeekableReadStream &stream, int len, char* result);
void grr();
void updateAnim(int y, int destX, int destY, int width, int height, int count, byte* src, int delayVal = 3, bool copyRectangle = false);
diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp
index ac50a079f2..8019fa9729 100644
--- a/engines/drascula/rooms.cpp
+++ b/engines/drascula/rooms.cpp
@@ -1655,61 +1655,61 @@ void DrasculaEngine::enterRoom(int roomIndex) {
}
int size = _arj.size();
- getIntFromLine(size, &roomNumber);
- getIntFromLine(size, &roomMusic);
- getStringFromLine(size, roomDisk);
- getIntFromLine(size, &palLevel);
+ getIntFromLine(_arj, size, &roomNumber);
+ getIntFromLine(_arj, size, &roomMusic);
+ getStringFromLine(_arj, size, roomDisk);
+ getIntFromLine(_arj, size, &palLevel);
if (currentChapter == 2)
- getIntFromLine(size, &martin);
+ getIntFromLine(_arj, size, &martin);
if (currentChapter == 2 && martin != 0) {
curWidth = martin;
- getIntFromLine(size, &curHeight);
- getIntFromLine(size, &feetHeight);
- getIntFromLine(size, &stepX);
- getIntFromLine(size, &stepY);
+ getIntFromLine(_arj, size, &curHeight);
+ getIntFromLine(_arj, size, &feetHeight);
+ getIntFromLine(_arj, size, &stepX);
+ getIntFromLine(_arj, size, &stepY);
- getStringFromLine(size, pant1);
- getStringFromLine(size, pant2);
- getStringFromLine(size, pant3);
- getStringFromLine(size, pant4);
+ getStringFromLine(_arj, size, pant1);
+ getStringFromLine(_arj, size, pant2);
+ getStringFromLine(_arj, size, pant3);
+ getStringFromLine(_arj, size, pant4);
strcpy(menuBackground, pant4);
}
- getIntFromLine(size, &numRoomObjs);
+ getIntFromLine(_arj, size, &numRoomObjs);
for (l = 0; l < numRoomObjs; l++) {
- getIntFromLine(size, &objectNum[l]);
- getStringFromLine(size, objName[l]);
- getIntFromLine(size, &x1[l]);
- getIntFromLine(size, &y1[l]);
- getIntFromLine(size, &x2[l]);
- getIntFromLine(size, &y2[l]);
- getIntFromLine(size, &roomObjX[l]);
- getIntFromLine(size, &roomObjY[l]);
- getIntFromLine(size, &trackObj[l]);
- getIntFromLine(size, &visible[l]);
- getIntFromLine(size, &isDoor[l]);
+ getIntFromLine(_arj, size, &objectNum[l]);
+ getStringFromLine(_arj, size, objName[l]);
+ getIntFromLine(_arj, size, &x1[l]);
+ getIntFromLine(_arj, size, &y1[l]);
+ getIntFromLine(_arj, size, &x2[l]);
+ getIntFromLine(_arj, size, &y2[l]);
+ getIntFromLine(_arj, size, &roomObjX[l]);
+ getIntFromLine(_arj, size, &roomObjY[l]);
+ getIntFromLine(_arj, size, &trackObj[l]);
+ getIntFromLine(_arj, size, &visible[l]);
+ getIntFromLine(_arj, size, &isDoor[l]);
if (isDoor[l] != 0) {
- getStringFromLine(size, _targetSurface[l]);
- getIntFromLine(size, &_destX[l]);
- getIntFromLine(size, &_destY[l]);
- getIntFromLine(size, &trackCharacter_alkeva[l]);
- getIntFromLine(size, &roomExits[l]);
+ getStringFromLine(_arj, size, _targetSurface[l]);
+ getIntFromLine(_arj, size, &_destX[l]);
+ getIntFromLine(_arj, size, &_destY[l]);
+ getIntFromLine(_arj, size, &trackCharacter_alkeva[l]);
+ getIntFromLine(_arj, size, &roomExits[l]);
updateDoor(l);
}
}
- getIntFromLine(size, &floorX1);
- getIntFromLine(size, &floorY1);
- getIntFromLine(size, &floorX2);
- getIntFromLine(size, &floorY2);
+ getIntFromLine(_arj, size, &floorX1);
+ getIntFromLine(_arj, size, &floorY1);
+ getIntFromLine(_arj, size, &floorX2);
+ getIntFromLine(_arj, size, &floorY2);
if (currentChapter != 2) {
- getIntFromLine(size, &upperLimit);
- getIntFromLine(size, &lowerLimit);
+ getIntFromLine(_arj, size, &upperLimit);
+ getIntFromLine(_arj, size, &lowerLimit);
}
_arj.close();