Skip to content

Commit

Permalink
SHERLOCK: Fixes for talk setup and portrait loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Apr 14, 2015
1 parent 3be28b4 commit 38b6aa7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
1 change: 0 additions & 1 deletion engines/sherlock/objects.cpp
Expand Up @@ -962,7 +962,6 @@ int Object::pickUpObject(const char *const messages[]) {
bool printed = false;
bool takeFlag = true;
int numObjects = 0;
int message;

if (pickup == 99) {
for (int idx = 0; idx < 4 && !talk._talkToAbort; ++idx) {
Expand Down
8 changes: 6 additions & 2 deletions engines/sherlock/people.cpp
Expand Up @@ -196,20 +196,23 @@ People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) {
_oldWalkSequence = -1;
_allowWalkAbort = false;
_portraitLoaded = false;
_portraitsOn = false;
_portraitsOn = true;
_clearingThePortrait = false;
_srcZone = _destZone = 0;
_talkPics = nullptr;
_portraitSide = 0;
_speakerFlip = false;
_holmesFlip = false;
_homesQuotient = 0;

_portrait._sequences = new byte[32];
}

People::~People() {
if (_walkLoaded)
delete _data[PLAYER]._images;
delete _talkPics;
delete[] _portrait._sequences;
}

void People::reset() {
Expand Down Expand Up @@ -646,7 +649,8 @@ void People::setTalking(int speaker) {

if (_portraitsOn) {
delete _talkPics;
_talkPics = new ImageFile("portrait.lib");
Common::String filename = Common::String::format("%s.vgs", PORTRAITS[speaker]);
_talkPics = new ImageFile(filename);

// Load portrait sequences
Common::SeekableReadStream *stream = res.load("sequence.txt");
Expand Down
3 changes: 3 additions & 0 deletions engines/sherlock/people.h
Expand Up @@ -51,6 +51,9 @@ 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];

class SherlockEngine;

class Person: public Sprite {
Expand Down
6 changes: 3 additions & 3 deletions engines/sherlock/sound.cpp
Expand Up @@ -25,9 +25,9 @@
namespace Sherlock {

Sound::Sound(SherlockEngine *vm): _vm(vm) {
_soundOn = true;
_musicOn = true;
_speechOn = true;
_soundOn = false;
_musicOn = false;
_speechOn = false;
_voices = 0;
_playingEpilogue = false;
_music = false;
Expand Down
35 changes: 18 additions & 17 deletions engines/sherlock/talk.cpp
Expand Up @@ -96,9 +96,9 @@ void Statement::synchronize(Common::SeekableReadStream &s) {

// Read in flag required/modified data
for (uint idx = 0; idx < _required.size(); ++idx)
_required[idx] = s.readUint16LE();
_required[idx] = s.readSint16LE();
for (uint idx = 0; idx < _modified.size(); ++idx)
_modified[idx] = s.readUint16LE();
_modified[idx] = s.readSint16LE();

_portraitSide = s.readByte();
_quotient = s.readUint16LE();
Expand Down Expand Up @@ -583,8 +583,8 @@ void Talk::loadTalkFile(const Common::String &filename) {

// Check for an existing person being talked to
_talkTo = -1;
for (int idx = 0; idx < NUM_OF_PEOPLE; ++idx) {
if (!scumm_strnicmp(filename.c_str(), people[(PeopleId)idx]._portrait.c_str(), 4)) {
for (int idx = 0; idx < MAX_PEOPLE; ++idx) {
if (!scumm_strnicmp(filename.c_str(), PORTRAITS[idx], 4)) {
_talkTo = idx;
break;
}
Expand Down Expand Up @@ -1036,7 +1036,7 @@ void Talk::doScript(const Common::String &script) {
ui.clearWindow();

// Need to switch speakers?
if (str[0] == SWITCH_SPEAKER) {
if ((byte)str[0] == SWITCH_SPEAKER) {
_speaker = str[1] - 1;
str += 2;
pullSequence();
Expand All @@ -1048,7 +1048,7 @@ void Talk::doScript(const Common::String &script) {
}

// Assign portrait location?
if (str[0] == ASSIGN_PORTRAIT_LOCATION) {
if ((byte)str[0] == ASSIGN_PORTRAIT_LOCATION) {
switch (str[1] & 15) {
case 1:
people._portraitSide = 20;
Expand Down Expand Up @@ -1083,15 +1083,16 @@ void Talk::doScript(const Common::String &script) {
Common::String tempString;
wait = 0;

if (!str[0]) {
byte c = (byte)str[0];
if (!c) {
endStr = true;
} else if (str[0] == '{') {
} else if (c == '{') {
// Start of comment, so skip over it
while (*str++ != '}')
;
} else if (str[0] >= 128) {
} else if (c >= 128) {
// Handle control code
switch (str[0]) {
switch (c) {
case SWITCH_SPEAKER:
// Save the current point in the script, since it might be intterupted by
// doing bg anims in the next call, so we need to know where to return to
Expand Down Expand Up @@ -1157,7 +1158,7 @@ void Talk::doScript(const Common::String &script) {
// doing bg anims in the next call, so we need to know where to return to
_scriptCurrentIndex = str - script.c_str();

if (_speaker < 128)
if (_speaker >= 0 && _speaker < 128)
people.clearTalking();
pullSequence();
if (_talkToAbort)
Expand Down Expand Up @@ -1508,9 +1509,9 @@ 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, inv._names[_speaker & 127].c_str());
screen.print(Common::Point(16, yp), TALK_FOREGROUND, NAMES[_speaker & 127]);
} else {
screen.gPrint(Common::Point(16, yp - 1), TALK_FOREGROUND, inv._names[_speaker & 127].c_str());
screen.gPrint(Common::Point(16, yp - 1), TALK_FOREGROUND, NAMES[_speaker & 127]);
openTalkWindow = true;
}

Expand All @@ -1523,10 +1524,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] != '{' && (byte)str[idx] < 128);

if (str[idx] || width >= 298) {
if (str[idx] < 128 && str[idx] != '{') {
if ((byte)str[idx] < 128 && str[idx] != '{') {
--idx;
--charCount;
}
Expand Down Expand Up @@ -1565,7 +1566,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 ((byte)str[0] < 128 && str[0] != '{')
++str;

yp += 9;
Expand All @@ -1578,7 +1579,7 @@ void Talk::doScript(const Common::String &script) {
wait = 1;
}

switch (str[0]) {
switch ((byte)str[0]) {
case SWITCH_SPEAKER:
case ASSIGN_PORTRAIT_LOCATION:
case BANISH_WINDOW:
Expand Down
3 changes: 1 addition & 2 deletions engines/sherlock/user_interface.cpp
Expand Up @@ -2200,7 +2200,6 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv
if (targetNum != -1) {
// Found a target, so do the action
const UseType &action = use[targetNum];
int messageNum = action._cAnimNum;

events.setCursor(WAIT);

Expand Down Expand Up @@ -2318,7 +2317,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[]
people[AL]._sequenceNumber = dir;
people.gotoStand(people[AL]);

talk.talkTo(action._names[nameIdx] + 2);
talk.talkTo(action._names[nameIdx].c_str() + 2);
if (ch == 'T')
doCAnim = false;
}
Expand Down

0 comments on commit 38b6aa7

Please sign in to comment.