aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-05-21 20:07:54 -0400
committerPaul Gilbert2015-05-21 20:07:54 -0400
commit5c30a2c5772049702e1c65d10ae32dec8e6f1cdc (patch)
tree1fc16720436d8fd9fd182e4ebdc3a17cb177e062
parent87fe6a14a069dd5cd02276c2e8e85d25117680d2 (diff)
downloadscummvm-rg350-5c30a2c5772049702e1c65d10ae32dec8e6f1cdc.tar.gz
scummvm-rg350-5c30a2c5772049702e1c65d10ae32dec8e6f1cdc.tar.bz2
scummvm-rg350-5c30a2c5772049702e1c65d10ae32dec8e6f1cdc.zip
SHERLOCK: Clean up initialization and handling of NPC data
-rw-r--r--engines/sherlock/journal.cpp9
-rw-r--r--engines/sherlock/people.cpp142
-rw-r--r--engines/sherlock/people.h12
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp148
-rw-r--r--engines/sherlock/talk.cpp27
-rw-r--r--engines/sherlock/talk.h8
6 files changed, 173 insertions, 173 deletions
diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp
index 7ff4272b82..50802f1625 100644
--- a/engines/sherlock/journal.cpp
+++ b/engines/sherlock/journal.cpp
@@ -131,6 +131,7 @@ void Journal::loadJournalLocations() {
}
void Journal::loadJournalFile(bool alreadyLoaded) {
+ People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
JournalEntry &journalEntry = _journal[_index];
@@ -152,7 +153,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) {
// Find the person being referred to
talk._talkTo = -1;
for (int idx = 0; idx < MAX_PEOPLE; ++idx) {
- Common::String portrait = PORTRAITS[idx];
+ Common::String portrait = people[idx]._portrait;
Common::String numStr(portrait.c_str(), portrait.c_str() + 4);
if (locStr == numStr) {
@@ -222,7 +223,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) {
journalString += "the Inspector";
break;
default:
- journalString += NAMES[talk._talkTo];
+ journalString += people._characters[talk._talkTo]._name;
break;
}
journalString += ", \"";
@@ -283,7 +284,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) {
else if (talk._talkTo == 2)
journalString += "The Inspector";
else
- journalString += NAMES[talk._talkTo];
+ journalString += people._characters[talk._talkTo]._name;
const byte *strP = replyP + 1;
byte v;
@@ -330,7 +331,7 @@ void Journal::loadJournalFile(bool alreadyLoaded) {
else if (c == 2)
journalString += "the Inspector";
else
- journalString += NAMES[c];
+ journalString += people._characters[c]._name;
const byte *strP = replyP;
byte v;
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index 3a169fa99c..3a630fdd99 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -50,144 +50,6 @@ static const uint8 CHARACTER_SEQUENCES[MAX_HOLMES_SEQUENCE][MAX_FRAME] = {
{ 52, 1, 2, 3, 4, 0 } // Goto Stand Down Left
};
-const char PORTRAITS[MAX_PEOPLE][5] = {
- { "HOLM" }, // Sherlock Holmes
- { "WATS" }, // Dr. Watson
- { "LEST" }, // Inspector Lestrade
- { "CON1" }, // Constable O'Brien
- { "CON2" }, // Constable Lewis
- { "SHEI" }, // Sheila Parker
- { "HENR" }, // Henry Carruthers
- { "LESL" }, // Lesley (flower girl)
- { "USH1" }, // Usher #1
- { "USH2" }, // Usher #2
- { "FRED" }, // Fredrick Epstein
- { "WORT" }, // Mrs. Worthington
- { "COAC" }, // Coach
- { "PLAY" }, // Player
- { "WBOY" }, // Tim (Waterboy)
- { "JAME" }, // James Sanders
- { "BELL" }, // Belle (perfumerie)
- { "GIRL" }, // Cleaning Girl (perfumerie)
- { "EPST" }, // Epstien in the Opera Balcony
- { "WIGG" }, // Wiggins
- { "PAUL" }, // Paul (Brumwell / Carroway)
- { "BART" }, // Bartender
- { "DIRT" }, // Dirty Drunk
- { "SHOU" }, // Shouting Drunk
- { "STAG" }, // Staggering Drunk
- { "BOUN" }, // Bouncer
- { "SAND" }, // James Sanders - At Home
- { "CORO" }, // The Coroner
- { "EQUE" }, // The Equestrian Shop Keeper
- { "GEOR" }, // George Blackwood
- { "LARS" }, // Lars
- { "PARK" }, // Sheila Parker (happy)
- { "CHEM" }, // Chemist
- { "GREG" }, // Inspector Gregson
- { "LAWY" }, // Jacob Farthington Lawyer
- { "MYCR" }, // Mycroft
- { "SHER" }, // Old Sherman
- { "CHMB" }, // Richard Chemist Stock boy
- { "BARM" }, // Barman
- { "DAND" }, // Dandy Player
- { "ROUG" }, // Rough-looking Player
- { "SPEC" }, // Spectator
- { "HUNT" }, // Robert Hunt
- { "VIOL" }, // Violet Secretary
- { "PETT" }, // Pettigrew
- { "APPL" }, // Augie (apple seller)
- { "ANNA" }, // Anna Carroway
- { "GUAR" }, // Guard
- { "ANTO" }, // Antonio Caruso
- { "TOBY" }, // Toby the Dog
- { "KING" }, // Simon Kingsley
- { "ALFR" }, // Alfred Tobacco Clerk
- { "LADY" }, // Lady Brumwell
- { "ROSA" }, // Madame Rosa
- { "LADB" }, // Lady Brumwell
- { "MOOR" }, // Joseph Moorehead
- { "BEAL" }, // Mrs. Beale
- { "LION" }, // Felix the Lion
- { "HOLL" }, // Hollingston
- { "CALL" }, // Constable Callaghan
- { "JERE" }, // Sergeant Jeremy Duncan
- { "LORD" }, // Lord Brumwell
- { "NIGE" }, // Nigel Jameson
- { "JONA" }, // Jonas (newspaper seller)
- { "DUGA" }, // Constable Dugan
- { "INSP" } // Inspector Lestrade (Scotland Yard)
-};
-
-const char *const NAMES[MAX_PEOPLE] = {
- "Sherlock Holmes",
- "Dr. Watson",
- "Inspector Lestrade",
- "Constable O'Brien",
- "Constable Lewis",
- "Sheila Parker",
- "Henry Carruthers",
- "Lesley",
- "An Usher",
- "An Usher",
- "Fredrick Epstein",
- "Mrs. Worthington",
- "The Coach",
- "A Player",
- "Tim",
- "James Sanders",
- "Belle",
- "Cleaning Girl",
- "Fredrick Epstein",
- "Wiggins",
- "Paul",
- "The Bartender",
- "A Dirty Drunk",
- "A Shouting Drunk",
- "A Staggering Drunk",
- "The Bouncer",
- "James Sanders",
- "The Coroner",
- "Reginald Snipes",
- "George Blackwood",
- "Lars",
- "Sheila Parker",
- "The Chemist",
- "Inspector Gregson",
- "Jacob Farthington",
- "Mycroft",
- "Old Sherman",
- "Richard",
- "The Barman",
- "A Dandy Player",
- "A Rough-looking Player",
- "A Spectator",
- "Robert Hunt",
- "Violet",
- "Pettigrew",
- "Augie",
- "Anna Carroway",
- "A Guard",
- "Antonio Caruso",
- "Toby the Dog",
- "Simon Kingsley",
- "Alfred",
- "Lady Brumwell",
- "Madame Rosa",
- "Lady Brumwell",
- "Joseph Moorehead",
- "Mrs. Beale",
- "Felix",
- "Hollingston",
- "Constable Callaghan",
- "Sergeant Duncan",
- "Lord Brumwell",
- "Nigel Jaimeson",
- "Jonas",
- "Constable Dugan",
- "Inspector Lestrade"
-};
-
/*----------------------------------------------------------------*/
People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) {
@@ -591,7 +453,7 @@ int People::findSpeaker(int speaker) {
if (obj._type == ACTIVE_BG_SHAPE) {
Common::String name(obj._name.c_str(), obj._name.c_str() + 4);
- if (name.equalsIgnoreCase(PORTRAITS[speaker])
+ if (name.equalsIgnoreCase(_characters[speaker]._portrait)
&& obj._name[4] >= '0' && obj._name[4] <= '9')
return idx;
}
@@ -639,7 +501,7 @@ void People::setTalking(int speaker) {
if (_portraitsOn) {
delete _talkPics;
- Common::String filename = Common::String::format("%s.vgs", PORTRAITS[speaker]);
+ Common::String filename = Common::String::format("%s.vgs", _characters[speaker]._portrait);
_talkPics = new ImageFile(filename);
// Load portrait sequences
diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h
index f22070f5f9..74c057e542 100644
--- a/engines/sherlock/people.h
+++ b/engines/sherlock/people.h
@@ -53,8 +53,15 @@ enum {
MAP_DOWN = 5, MAP_DOWNLEFT = 6, MAP_LEFT = 2, MAP_UPLEFT = 8
};
-extern const char *const NAMES[MAX_PEOPLE];
-extern const char PORTRAITS[MAX_PEOPLE][5];
+struct PersonData {
+ const char *_name;
+ const char *_portrait;
+ const byte *_stillSequences;
+ const byte *_talkSequences;
+
+ PersonData(const char *name, const char *portrait, const byte *stillSequences, const byte *talkSequences) :
+ _name(name), _portrait(portrait), _stillSequences(stillSequences), _talkSequences(talkSequences) {}
+};
class SherlockEngine;
@@ -73,6 +80,7 @@ private:
int _oldWalkSequence;
int _srcZone, _destZone;
public:
+ Common::Array<PersonData> _characters;
ImageFile *_talkPics;
Common::Point _walkDest;
Common::Point _hSavedPos;
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index 56c1e28dbe..d55517cdc3 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -89,7 +89,145 @@ static const byte MAP_SEQUENCES[3][MAX_FRAME] = {
#define MAX_PEOPLE 66
-static const byte STILL_SEQUENCES[MAX_PEOPLE][MAX_TALK_SEQUENCES] = {
+const char PEOPLE_PORTRAITS[MAX_PEOPLE][5] = {
+ { "HOLM" }, // Sherlock Holmes
+ { "WATS" }, // Dr. Watson
+ { "LEST" }, // Inspector Lestrade
+ { "CON1" }, // Constable O'Brien
+ { "CON2" }, // Constable Lewis
+ { "SHEI" }, // Sheila Parker
+ { "HENR" }, // Henry Carruthers
+ { "LESL" }, // Lesley (flower girl)
+ { "USH1" }, // Usher #1
+ { "USH2" }, // Usher #2
+ { "FRED" }, // Fredrick Epstein
+ { "WORT" }, // Mrs. Worthington
+ { "COAC" }, // Coach
+ { "PLAY" }, // Player
+ { "WBOY" }, // Tim (Waterboy)
+ { "JAME" }, // James Sanders
+ { "BELL" }, // Belle (perfumerie)
+ { "GIRL" }, // Cleaning Girl (perfumerie)
+ { "EPST" }, // Epstien in the Opera Balcony
+ { "WIGG" }, // Wiggins
+ { "PAUL" }, // Paul (Brumwell / Carroway)
+ { "BART" }, // Bartender
+ { "DIRT" }, // Dirty Drunk
+ { "SHOU" }, // Shouting Drunk
+ { "STAG" }, // Staggering Drunk
+ { "BOUN" }, // Bouncer
+ { "SAND" }, // James Sanders - At Home
+ { "CORO" }, // The Coroner
+ { "EQUE" }, // The Equestrian Shop Keeper
+ { "GEOR" }, // George Blackwood
+ { "LARS" }, // Lars
+ { "PARK" }, // Sheila Parker (happy)
+ { "CHEM" }, // Chemist
+ { "GREG" }, // Inspector Gregson
+ { "LAWY" }, // Jacob Farthington Lawyer
+ { "MYCR" }, // Mycroft
+ { "SHER" }, // Old Sherman
+ { "CHMB" }, // Richard Chemist Stock boy
+ { "BARM" }, // Barman
+ { "DAND" }, // Dandy Player
+ { "ROUG" }, // Rough-looking Player
+ { "SPEC" }, // Spectator
+ { "HUNT" }, // Robert Hunt
+ { "VIOL" }, // Violet Secretary
+ { "PETT" }, // Pettigrew
+ { "APPL" }, // Augie (apple seller)
+ { "ANNA" }, // Anna Carroway
+ { "GUAR" }, // Guard
+ { "ANTO" }, // Antonio Caruso
+ { "TOBY" }, // Toby the Dog
+ { "KING" }, // Simon Kingsley
+ { "ALFR" }, // Alfred Tobacco Clerk
+ { "LADY" }, // Lady Brumwell
+ { "ROSA" }, // Madame Rosa
+ { "LADB" }, // Lady Brumwell
+ { "MOOR" }, // Joseph Moorehead
+ { "BEAL" }, // Mrs. Beale
+ { "LION" }, // Felix the Lion
+ { "HOLL" }, // Hollingston
+ { "CALL" }, // Constable Callaghan
+ { "JERE" }, // Sergeant Jeremy Duncan
+ { "LORD" }, // Lord Brumwell
+ { "NIGE" }, // Nigel Jameson
+ { "JONA" }, // Jonas (newspaper seller)
+ { "DUGA" }, // Constable Dugan
+ { "INSP" } // Inspector Lestrade (Scotland Yard)
+};
+
+const char *const PEOPLE_NAMES[MAX_PEOPLE] = {
+ "Sherlock Holmes",
+ "Dr. Watson",
+ "Inspector Lestrade",
+ "Constable O'Brien",
+ "Constable Lewis",
+ "Sheila Parker",
+ "Henry Carruthers",
+ "Lesley",
+ "An Usher",
+ "An Usher",
+ "Fredrick Epstein",
+ "Mrs. Worthington",
+ "The Coach",
+ "A Player",
+ "Tim",
+ "James Sanders",
+ "Belle",
+ "Cleaning Girl",
+ "Fredrick Epstein",
+ "Wiggins",
+ "Paul",
+ "The Bartender",
+ "A Dirty Drunk",
+ "A Shouting Drunk",
+ "A Staggering Drunk",
+ "The Bouncer",
+ "James Sanders",
+ "The Coroner",
+ "Reginald Snipes",
+ "George Blackwood",
+ "Lars",
+ "Sheila Parker",
+ "The Chemist",
+ "Inspector Gregson",
+ "Jacob Farthington",
+ "Mycroft",
+ "Old Sherman",
+ "Richard",
+ "The Barman",
+ "A Dandy Player",
+ "A Rough-looking Player",
+ "A Spectator",
+ "Robert Hunt",
+ "Violet",
+ "Pettigrew",
+ "Augie",
+ "Anna Carroway",
+ "A Guard",
+ "Antonio Caruso",
+ "Toby the Dog",
+ "Simon Kingsley",
+ "Alfred",
+ "Lady Brumwell",
+ "Madame Rosa",
+ "Lady Brumwell",
+ "Joseph Moorehead",
+ "Mrs. Beale",
+ "Felix",
+ "Hollingston",
+ "Constable Callaghan",
+ "Sergeant Duncan",
+ "Lord Brumwell",
+ "Nigel Jaimeson",
+ "Jonas",
+ "Constable Dugan",
+ "Inspector Lestrade"
+};
+
+static const byte PEOPLE_STILL_SEQUENCES[MAX_PEOPLE][MAX_TALK_SEQUENCES] = {
{ 1, 0, 0 }, // Sherlock Holmes
{ 6, 0, 0 }, // Dr. Watson
{ 4, 0, 0 }, // Inspector Lestrade
@@ -158,7 +296,7 @@ static const byte STILL_SEQUENCES[MAX_PEOPLE][MAX_TALK_SEQUENCES] = {
{ 4, 0, 0 } // Inspector Lestrade (Yard)
};
-static const byte TALK_SEQUENCES[MAX_PEOPLE][MAX_TALK_SEQUENCES] = {
+static const byte PEOPLE_TALK_SEQUENCES[MAX_PEOPLE][MAX_TALK_SEQUENCES] = {
{ 1, 0, 0 }, // Sherlock Holmes
{ 5, 5, 6, 7, 8, 7, 8, 6, 0, 0 }, // Dr. Watson
{ 2, 0, 0 }, // Inspector Lestrade
@@ -258,8 +396,10 @@ void ScalpelEngine::initialize() {
// Load the inventory
loadInventory();
- // Set up constants used by the talk system
- _talk->setSequences(&TALK_SEQUENCES[0][0], &STILL_SEQUENCES[0][0], MAX_PEOPLE);
+ // Set up list of people
+ for (int idx = 0; idx < MAX_PEOPLE; ++idx)
+ _people->_characters.push_back(PersonData(PEOPLE_NAMES[idx], PEOPLE_PORTRAITS[idx],
+ PEOPLE_STILL_SEQUENCES[idx], PEOPLE_TALK_SEQUENCES[idx]));
_animation->setPrologueNames(&PROLOGUE_NAMES[0], PROLOGUE_NAMES_COUNT);
_animation->setPrologueFrames(&PROLOGUE_FRAMES[0][0], 6, 9);
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 5fbf7cc185..6bac16c9bf 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -105,15 +105,6 @@ Talk::Talk(SherlockEngine *vm) : _vm(vm) {
_scriptSaveIndex = -1;
}
-void Talk::setSequences(const byte *talkSequences, const byte *stillSequences, int maxPeople) {
- for (int idx = 0; idx < maxPeople; ++idx) {
- STILL_SEQUENCES.push_back(TalkSequences(stillSequences));
- TALK_SEQUENCES.push_back(TalkSequences(talkSequences));
- stillSequences += MAX_TALK_SEQUENCES;
- talkSequences += MAX_TALK_SEQUENCES;
- }
-}
-
void Talk::talkTo(const Common::String &filename) {
Events &events = *_vm->_events;
Inventory &inv = *_vm->_inventory;
@@ -537,6 +528,7 @@ void Talk::freeTalkVars() {
}
void Talk::loadTalkFile(const Common::String &filename) {
+ People &people = *_vm->_people;
Resources &res = *_vm->_res;
Sound &sound = *_vm->_sound;
@@ -546,7 +538,7 @@ void Talk::loadTalkFile(const Common::String &filename) {
// Check for an existing person being talked to
_talkTo = -1;
for (int idx = 0; idx < MAX_PEOPLE; ++idx) {
- if (!scumm_strnicmp(filename.c_str(), PORTRAITS[idx], 4)) {
+ if (!scumm_strnicmp(filename.c_str(), people._characters[idx]._portrait, 4)) {
_talkTo = idx;
break;
}
@@ -884,8 +876,8 @@ void Talk::setSequence(int speaker) {
warning("Tried to copy too many talk frames");
} else {
for (int idx = 0; idx < MAX_TALK_SEQUENCES; ++idx) {
- obj._sequences[idx] = TALK_SEQUENCES[speaker][idx];
- if (idx > 0 && !TALK_SEQUENCES[speaker][idx] && !TALK_SEQUENCES[speaker][idx - 1])
+ obj._sequences[idx] = people._characters[speaker]._talkSequences[idx];
+ if (idx > 0 && !obj._sequences[idx] && !obj._sequences[idx - 1])
return;
obj._frameNumber = 0;
@@ -913,8 +905,9 @@ void Talk::setStillSeq(int speaker) {
warning("Tried to copy too few still frames");
} else {
for (uint idx = 0; idx < MAX_TALK_SEQUENCES; ++idx) {
- obj._sequences[idx] = STILL_SEQUENCES[speaker][idx];
- if (idx > 0 && !TALK_SEQUENCES[speaker][idx] && !TALK_SEQUENCES[speaker][idx - 1])
+ obj._sequences[idx] = people._characters[speaker]._stillSequences[idx];
+ if (idx > 0 && !people._characters[speaker]._talkSequences[idx] &&
+ !people._characters[speaker]._talkSequences[idx - 1])
break;
}
@@ -1426,9 +1419,11 @@ void Talk::doScript(const Common::String &script) {
// If the window is open, display the name directly on-screen.
// Otherwise, simply draw it on the back buffer
if (ui._windowOpen) {
- screen.print(Common::Point(16, yp), TALK_FOREGROUND, "%s", NAMES[_speaker & 127]);
+ screen.print(Common::Point(16, yp), TALK_FOREGROUND, "%s",
+ people._characters[_speaker & 127]._name);
} else {
- screen.gPrint(Common::Point(16, yp - 1), TALK_FOREGROUND, "%s", NAMES[_speaker & 127]);
+ screen.gPrint(Common::Point(16, yp - 1), TALK_FOREGROUND, "%s",
+ people._characters[_speaker & 127]._name);
openTalkWindow = true;
}
diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h
index 71f093f66a..d26259dbfd 100644
--- a/engines/sherlock/talk.h
+++ b/engines/sherlock/talk.h
@@ -128,9 +128,6 @@ class UserInterface;
class Talk {
friend class UserInterface;
private:
- Common::Array<TalkSequences> STILL_SEQUENCES;
- Common::Array<TalkSequences> TALK_SEQUENCES;
-private:
SherlockEngine *_vm;
Common::Stack<SequenceEntry> _savedSequences;
Common::Stack<SequenceEntry> _sequenceStack;
@@ -188,11 +185,8 @@ public:
Talk(SherlockEngine *vm);
/**
- * Sets talk sequences
+ * Return a given talk statement
*/
- void setSequences(const byte *talkSequences, const byte *stillSequences,
- int maxPeople);
-
Statement &operator[](int idx) { return _statements[idx]; }
/**