diff options
author | Paul Gilbert | 2015-05-18 19:37:54 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-05-18 19:37:54 -0400 |
commit | b760c7d360d206d39391875e26271098c63acdd3 (patch) | |
tree | b63b02bf7c77d63403c60f5267285abaa7009d9d /engines | |
parent | 59993fdc74afad7b210da7849f8ce25631153201 (diff) | |
download | scummvm-rg350-b760c7d360d206d39391875e26271098c63acdd3.tar.gz scummvm-rg350-b760c7d360d206d39391875e26271098c63acdd3.tar.bz2 scummvm-rg350-b760c7d360d206d39391875e26271098c63acdd3.zip |
SHERLOCK: More replacing numbers with constants
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/journal.cpp | 28 | ||||
-rw-r--r-- | engines/sherlock/journal.h | 3 | ||||
-rw-r--r-- | engines/sherlock/scene.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/talk.cpp | 40 |
4 files changed, 40 insertions, 33 deletions
diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp index f288b43650..71d104e3f7 100644 --- a/engines/sherlock/journal.cpp +++ b/engines/sherlock/journal.cpp @@ -29,7 +29,7 @@ namespace Sherlock { #define LINES_PER_PAGE 11 // Positioning of buttons in the journal view -const int JOURNAL_POINTS[9][3] = { +static const int JOURNAL_POINTS[9][3] = { { 6, 68, 37 }, { 69, 131, 100 }, { 132, 192, 162 }, @@ -41,7 +41,7 @@ const int JOURNAL_POINTS[9][3] = { { 237, 313, 275 } }; -const int SEARCH_POINTS[3][3] = { +static const int SEARCH_POINTS[3][3] = { { 51, 123, 86 }, { 124, 196, 159 }, { 197, 269, 232 } @@ -146,6 +146,8 @@ void Journal::loadJournalFile(bool alreadyLoaded) { Common::String dirFilename = _directory[journalEntry._converseNum]; bool replyOnly = journalEntry._replyOnly; + + // Get the location number from within the filename Common::String locStr(dirFilename.c_str() + 4, dirFilename.c_str() + 6); int newLocation = atoi(locStr.c_str()); @@ -195,11 +197,11 @@ void Journal::loadJournalFile(bool alreadyLoaded) { // See if title can fit into a single line, or requires splitting on 2 lines int width = screen.stringWidth(journalString.c_str() + 1); - if (width > 230) { + if (width > JOURNAL_MAX_WIDTH) { // Scan backwards from end of title to find a space between a word // where the width is less than the maximum allowed for the line const char *lineP = journalString.c_str() + journalString.size() - 1; - while (width > 230 || *lineP != ' ') + while (width > JOURNAL_MAX_WIDTH || *lineP != ' ') width -= screen.charWidth(*lineP--); // Split the header into two lines, and add a '@' prefix @@ -249,7 +251,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) { byte c = *replyP++; // Is it a control character? - if (c < 128) { + if (c < SWITCH_SPEAKER) { // Nope. Set flag for allowing control codes to insert spaces ctrlSpace = true; assert(c >= ' '); @@ -296,7 +298,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) { byte v; do { v = *strP++; - } while (v && (v < 128) && (v != '.') && (v != '!') && (v != '?')); + } while (v && (v < SWITCH_SPEAKER) && (v != '.') && (v != '!') && (v != '?')); if (v == '?') journalString += " asked, \""; @@ -312,11 +314,11 @@ void Journal::loadJournalFile(bool alreadyLoaded) { journalString += c; do { journalString += *replyP++; - } while (*replyP && *replyP < 128 && *replyP != '{' && *replyP != '}'); + } while (*replyP && *replyP < SWITCH_SPEAKER && *replyP != '{' && *replyP != '}'); commentJustPrinted = false; } - } else if (c == 128) { + } else if (c == SWITCH_SPEAKER) { if (!startOfReply) { if (!commentFlag && !commentJustPrinted) journalString += "\"\n"; @@ -343,7 +345,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) { byte v; do { v = *strP++; - } while (v && v < 128 && v != '.' && v != '!' && v != '?'); + } while (v && v < SWITCH_SPEAKER && v != '.' && v != '!' && v != '?'); if (v == '?') journalString += " asked, \""; @@ -403,7 +405,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) { // Put a space in the output for a control character, unless it's // immediately coming after another control character - if (ctrlSpace && c != 130 && c != 161 && !commentJustPrinted) { + if (ctrlSpace && c != ASSIGN_PORTRAIT_LOCATION && c != CARRIAGE_RETURN && !commentJustPrinted) { journalString += " "; ctrlSpace = false; } @@ -429,11 +431,11 @@ void Journal::loadJournalFile(bool alreadyLoaded) { // Build up chacters until a full line is found int width = 0; const char *endP = startP; - while (width < 230 && *endP && *endP != '\n' && (endP - startP) < 79) + while (width < JOURNAL_MAX_WIDTH && *endP && *endP != '\n' && (endP - startP) < (JOURNAL_MAX_CHARS - 1)) width += screen.charWidth(*endP++); // If word wrapping, move back to end of prior word - if (width >= 230 || (endP - startP) >= 79) { + if (width >= JOURNAL_MAX_WIDTH || (endP - startP) >= (JOURNAL_MAX_CHARS - 1)) { while (*--endP != ' ') ; } @@ -518,7 +520,7 @@ void Journal::drawInterface() { drawJournalFrame(); - if (_journal.size() == 0) { + if (_journal.empty()) { _up = _down = 0; } else { drawJournal(0, 0); diff --git a/engines/sherlock/journal.h b/engines/sherlock/journal.h index be5c4d77c3..97696ef74f 100644 --- a/engines/sherlock/journal.h +++ b/engines/sherlock/journal.h @@ -31,6 +31,9 @@ namespace Sherlock { +#define JOURNAL_MAX_WIDTH 230 +#define JOURNAL_MAX_CHARS 80 + struct JournalEntry { int _converseNum; bool _replyOnly; diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index b092bbce65..78858bc284 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -1364,7 +1364,7 @@ void Scene::doBgAnim() { _animating = 0; screen.slamRect(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCENE_HEIGHT)); } else { - if (people[AL]._type != INVALID && ((_goToScene == -1 || _canimShapes.size() == 0))) { + if (people[AL]._type != INVALID && ((_goToScene == -1 || _canimShapes.empty()))) { if (people[AL]._type == REMOVE) { screen.slamRect(Common::Rect( people[AL]._oldPosition.x, people[AL]._oldPosition.y, diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index dc5b9c5ba7..78b52bc7a5 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -26,6 +26,8 @@ namespace Sherlock { +#define SPEAKER_REMOVE 0x80 + SequenceEntry::SequenceEntry() { _objNum = 0; _frameNumber = 0; @@ -221,7 +223,7 @@ void Talk::talkTo(const Common::String &filename) { break; case TALK_MODE: - if (_speaker < 128) + if (_speaker < SPEAKER_REMOVE) people.clearTalking(); if (_talkCounter) return; @@ -464,7 +466,7 @@ void Talk::talk(int objNum) { ui._windowBounds.top = CONTROLS_Y; ui._infoFlag = true; - _speaker = 128; + _speaker = SPEAKER_REMOVE; loadTalkFile(scene._bgShapes[objNum]._name); // Find the first statement with the correct flags @@ -769,11 +771,11 @@ int Talk::talkLine(int lineNum, int stateNum, byte color, int lineY, bool slamIt bool numberFlag = false; // Get the statement to display as well as optional number prefix - if (idx < 128) { + if (idx < SPEAKER_REMOVE) { number = Common::String::format("%d.", stateNum + 1); numberFlag = true; } else { - idx -= 128; + idx -= SPEAKER_REMOVE; } msg = _statements[idx]._statement; @@ -1019,7 +1021,7 @@ void Talk::doScript(const Common::String &script) { // Check if the script begins with a Stealh Mode Active command if (str[0] == STEALTH_MODE_ACTIVE || _talkStealth) { _talkStealth = 2; - _speaker |= 128; + _speaker |= SPEAKER_REMOVE; } else { pushSequence(_speaker); ui.clearWindow(); @@ -1077,11 +1079,11 @@ void Talk::doScript(const Common::String &script) { // Start of comment, so skip over it while (*str++ != '}') ; - } else if (c >= 128) { + } else if (c >= SWITCH_SPEAKER) { // Handle control code switch (c) { case SWITCH_SPEAKER: - if (!(_speaker & 128)) + if (!(_speaker & SPEAKER_REMOVE)) people.clearTalking(); if (_talkToAbort) return; @@ -1099,7 +1101,7 @@ void Talk::doScript(const Common::String &script) { case RUN_CANIMATION: ++str; - scene.startCAnim((str[0] - 1) & 127, (str[0] & 128) ? -1 : 1); + scene.startCAnim((str[0] - 1) & 127, (str[0] & 0x80) ? -1 : 1); if (_talkToAbort) return; @@ -1135,13 +1137,13 @@ void Talk::doScript(const Common::String &script) { break; case REMOVE_PORTRAIT: - if (_speaker >= 0 && _speaker < 128) + if (_speaker >= 0 && _speaker < SPEAKER_REMOVE) people.clearTalking(); pullSequence(); if (_talkToAbort) return; - _speaker |= 128; + _speaker |= SPEAKER_REMOVE; break; case CLEAR_WINDOW: @@ -1167,7 +1169,7 @@ void Talk::doScript(const Common::String &script) { error("Could not find object %s to change", tempString.c_str()); // Should the script be overwritten? - if (str[0] > 128) { + if (str[0] > 0x80) { // Save the current sequence _savedSequences.push(SequenceEntry()); SequenceEntry &seqEntry = _savedSequences.top(); @@ -1216,14 +1218,14 @@ void Talk::doScript(const Common::String &script) { break; case BANISH_WINDOW: - if (!(_speaker & 128)) + if (!(_speaker & SPEAKER_REMOVE)) people.clearTalking(); pullSequence(); if (_talkToAbort) return; - _speaker |= 128; + _speaker |= SPEAKER_REMOVE; ui.banishWindow(); ui._menuMode = TALK_MODE; noTextYet = true; @@ -1367,7 +1369,7 @@ void Talk::doScript(const Common::String &script) { tempString += str[idx + 1]; // Set comparison state according to if we want to hide or unhide - bool state = (str[0] >= 128); + bool state = (str[0] >= SPEAKER_REMOVE); str += str[0] & 127; for (uint idx = 0; idx < scene._bgShapes.size(); ++idx) { @@ -1501,10 +1503,10 @@ void Talk::doScript(const Common::String &script) { width += screen.charWidth(str[idx]); ++idx; ++charCount; - } while (width < 298 && str[idx] && str[idx] != '{' && str[idx] < 128); + } while (width < 298 && str[idx] && str[idx] != '{' && str[idx] < SWITCH_SPEAKER); if (str[idx] || width >= 298) { - if (str[idx] < 128 && str[idx] != '{') { + if (str[idx] < SWITCH_SPEAKER && str[idx] != '{') { --idx; --charCount; } @@ -1544,7 +1546,7 @@ void Talk::doScript(const Common::String &script) { str += idx; // If line wrap occurred, then move to after the separating space between the words - if (str[0] < 128 && str[0] != '{') + if (str[0] < SWITCH_SPEAKER && str[0] != '{') ++str; yp += 9; @@ -1574,7 +1576,7 @@ void Talk::doScript(const Common::String &script) { } // Open window if it wasn't already open, and text has already been printed - if ((openTalkWindow && wait) || (openTalkWindow && str[0] >= 128 && str[0] != CARRIAGE_RETURN)) { + if ((openTalkWindow && wait) || (openTalkWindow && str[0] >= SWITCH_SPEAKER && str[0] != CARRIAGE_RETURN)) { if (!ui._windowStyle) { screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); } else { @@ -1624,7 +1626,7 @@ void Talk::doScript(const Common::String &script) { } pullSequence(); - if (_speaker >= 0 && _speaker < 128) + if (_speaker >= 0 && _speaker < SPEAKER_REMOVE) people.clearTalking(); } } |