aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/journal.cpp36
-rw-r--r--engines/sherlock/journal.h4
-rw-r--r--engines/sherlock/objects.cpp14
-rw-r--r--engines/sherlock/talk.cpp15
4 files changed, 35 insertions, 34 deletions
diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp
index b05cc03372..2811c463a2 100644
--- a/engines/sherlock/journal.cpp
+++ b/engines/sherlock/journal.cpp
@@ -50,9 +50,6 @@ const int SEARCH_POINTS[3][3] = {
/*----------------------------------------------------------------*/
Journal::Journal(SherlockEngine *vm): _vm(vm) {
- // Allow up to 1000 statements
- _journal.resize(1000);
-
// Initialize fields
_count = 0;
_maxPage = 0;
@@ -70,12 +67,12 @@ Journal::Journal(SherlockEngine *vm): _vm(vm) {
* Records statements that are said, in the order which they are said. The player
* can then read the journal to review them
*/
-void Journal::record(int converseNum, int statementNum) {
+void Journal::record(int converseNum, int statementNum, bool replyOnly) {
int saveIndex = _index;
int saveSub = _sub;
// Record the entry into the list
- _journal.push_back(JournalEntry(converseNum, statementNum));
+ _journal.push_back(JournalEntry(converseNum, statementNum, replyOnly));
_index = _journal.size() - 1;
// Load the text for the new entry to get the number of lines it will have
@@ -108,12 +105,12 @@ void Journal::loadJournalLocations() {
_directory.resize(dir->readUint16LE());
// Read in each entry
+ char buffer[17];
for (uint idx = 0; idx < _directory.size(); ++idx) {
- Common::String line;
- while ((c = dir->readByte()) != 0)
- line += c;
+ dir->read(buffer, 17);
+ buffer[16] = '\0';
- _directory.push_back(line);
+ _directory[idx] = Common::String(buffer);
}
delete dir;
@@ -124,7 +121,7 @@ void Journal::loadJournalLocations() {
_locations.clear();
while (loc->pos() < loc->size()) {
Common::String line;
- while ((c = loc->readByte()) != '\0')
+ while ((c = loc->readByte()) != 0)
line += c;
_locations.push_back(line);
@@ -137,7 +134,7 @@ void Journal::loadJournalLocations() {
* Loads the description for the current display index in the journal, and then
* word wraps the result to prepare it for being displayed
*/
-bool Journal::loadJournalFile(bool alreadyLoaded) {
+int Journal::loadJournalFile(bool alreadyLoaded) {
Inventory &inv = *_vm->_inventory;
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
@@ -147,7 +144,7 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
Common::String dirFilename = _directory[journalEntry._converseNum];
bool replyOnly = journalEntry._replyOnly;
- Common::String locStr(dirFilename.c_str(), dirFilename.c_str() + 4);
+ Common::String locStr(dirFilename.c_str() + 4, dirFilename.c_str() + 6);
int newLocation = atoi(locStr.c_str());
// If not flagged as alrady loaded, load the conversation into script variables
@@ -246,7 +243,7 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
const char *replyP = statement._reply.c_str();
while (*replyP) {
- char c = *replyP;
+ char c = *replyP++;
// Is it a control character?
if (c < 128) {
@@ -264,7 +261,8 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
// a comment (which would have added a line), add a carriage return
if (!startOfReply && ((!commentJustPrinted && c == '{') || c == '}'))
journalString += '"';
-
+ startOfReply = false;
+
// Handle setting or clearing comment state
if (c == '{') {
commentFlag = true;
@@ -290,7 +288,7 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
else
journalString += inv._names[talk._talkTo];
- const char *strP = replyP + 1;
+ const char *strP = replyP;
char v;
do {
v = *strP++;
@@ -307,12 +305,11 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
// Copy text from the place until either the reply ends, a comment
// {} block is started, or a control character is encountered
+ journalString += c;
do {
journalString += *replyP++;
} while (*replyP && *replyP < 128 && *replyP != '{' && *replyP != '}');
- // Move pointer back, since the outer for loop will increment it again
- --replyP;
commentJustPrinted = false;
}
} else if (c == 128) {
@@ -327,7 +324,7 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
}
startOfReply = false;
- c = *++replyP;
+ c = *replyP++;
if ((c - 1) == 0)
journalString += "Holmes";
@@ -338,7 +335,7 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
else
journalString += inv._names[c - 1];
- const char *strP = replyP + 1;
+ const char *strP = replyP;
char v;
do {
v = *strP++;
@@ -350,7 +347,6 @@ bool Journal::loadJournalFile(bool alreadyLoaded) {
journalString += " said, \"";
} else {
// Control code, so move past it and any parameters
- ++replyP;
switch (c) {
case 129: // Run canim
case 130: // Assign side
diff --git a/engines/sherlock/journal.h b/engines/sherlock/journal.h
index a5fe1e8d94..894065759b 100644
--- a/engines/sherlock/journal.h
+++ b/engines/sherlock/journal.h
@@ -60,7 +60,7 @@ private:
void loadJournalLocations();
- bool loadJournalFile(bool alreadyLoaded);
+ int loadJournalFile(bool alreadyLoaded);
void doArrows();
@@ -72,7 +72,7 @@ private:
public:
Journal(SherlockEngine *vm);
- void record(int converseNum, int statementNum);
+ void record(int converseNum, int statementNum, bool replyOnly = false);
void drawInterface();
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index d5d24e72af..e4730ef207 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -191,15 +191,15 @@ void Sprite::checkSprite() {
for (uint idx = 0; idx < scene._bgShapes.size() && !talk._talkToAbort; ++idx) {
Object &obj = scene._bgShapes[idx];
- if (obj._aType > PERSON && _type != INVALID && _type != HIDDEN) {
- if (_type == NO_SHAPE) {
- objBounds = Common::Rect(_position.x, _position.y,
- _position.x + _noShapeSize.x, _position.y + _noShapeSize.y);
+ if (obj._aType > PERSON && obj._type != INVALID && obj._type != HIDDEN) {
+ if (obj._type == NO_SHAPE) {
+ objBounds = Common::Rect(obj._position.x, obj._position.y,
+ obj._position.x + obj._noShapeSize.x, obj._position.y + obj._noShapeSize.y);
} else {
- int xp = _position.x + _imageFrame->_offset.x;
- int yp = _position.y + _imageFrame->_offset.y;
+ int xp = obj._position.x + obj._imageFrame->_offset.x;
+ int yp = obj._position.y + obj._imageFrame->_offset.y;
objBounds = Common::Rect(xp, yp,
- xp + _imageFrame->_frame.w, yp + _imageFrame->_frame.h);
+ xp + obj._imageFrame->_frame.w, yp + obj._imageFrame->_frame.h);
}
}
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 6596431b8b..d284ace8b8 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -37,20 +37,24 @@ void Statement::synchronize(Common::SeekableReadStream &s) {
int length;
length = s.readUint16LE();
- for (int idx = 0; idx < length; ++idx)
+ for (int idx = 0; idx < length - 1; ++idx)
_statement += (char)s.readByte();
+ s.readByte(); // Null ending
length = s.readUint16LE();
- for (int idx = 0; idx < length; ++idx)
+ for (int idx = 0; idx < length - 1; ++idx)
_reply += (char)s.readByte();
+ s.readByte(); // Null ending
length = s.readUint16LE();
- for (int idx = 0; idx < length; ++idx)
+ for (int idx = 0; idx < length - 1; ++idx)
_linkFile += (char)s.readByte();
+ s.readByte(); // Null ending
length = s.readUint16LE();
- for (int idx = 0; idx < length; ++idx)
+ for (int idx = 0; idx < length - 1; ++idx)
_voiceFile += (char)s.readByte();
+ s.readByte(); // Null ending
_required.resize(s.readByte());
_modified.resize(s.readByte());
@@ -280,7 +284,7 @@ void Talk::talkTo(const Common::String &filename) {
// Add the statement into the journal and talk history
if (_talkTo != -1 && !_talkHistory[_converseNum][select])
- journal.record(_converseNum | 2048, select);
+ journal.record(_converseNum, select, true);
_talkHistory[_converseNum][select] = true;
// Check if the talk file is meant to be a non-seen comment
@@ -555,6 +559,7 @@ void Talk::loadTalkFile(const Common::String &filename) {
// Open the talk file for reading
Common::SeekableReadStream *talkStream = res.load(talkFile);
+ _converseNum = res.resourceIndex();
talkStream->skip(2); // Skip talk file version num
_statements.resize(talkStream->readByte());