aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/objects.cpp109
-rw-r--r--engines/sherlock/objects.h17
-rw-r--r--engines/sherlock/people.cpp193
-rw-r--r--engines/sherlock/people.h18
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp18
-rw-r--r--engines/sherlock/scalpel/scalpel_map.cpp44
-rw-r--r--engines/sherlock/scalpel/scalpel_people.cpp121
-rw-r--r--engines/sherlock/scalpel/scalpel_people.h13
-rw-r--r--engines/sherlock/scalpel/scalpel_scene.cpp72
-rw-r--r--engines/sherlock/scalpel/scalpel_user_interface.cpp6
-rw-r--r--engines/sherlock/scene.cpp8
-rw-r--r--engines/sherlock/talk.cpp4
-rw-r--r--engines/sherlock/tattoo/tattoo_people.cpp24
-rw-r--r--engines/sherlock/tattoo/tattoo_people.h13
-rw-r--r--engines/sherlock/tattoo/tattoo_scene.cpp2
15 files changed, 349 insertions, 313 deletions
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index 80712cfe59..6a0aa5b9ad 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -32,10 +32,6 @@ namespace Sherlock {
#define START_FRAME 0
-#define UPPER_LIMIT 0
-#define LOWER_LIMIT (IS_SERRATED_SCALPEL ? CONTROLS_Y : SHERLOCK_SCREEN_HEIGHT)
-#define LEFT_LIMIT 0
-#define RIGHT_LIMIT SHERLOCK_SCREEN_WIDTH
#define NUM_ADJUSTED_WALKS 21
// Distance to walk around WALK_AROUND boxes
@@ -207,107 +203,6 @@ void Sprite::setImageFrame() {
_imageFrame = &(*images)[imageNumber];
}
-void Sprite::adjustSprite() {
- Map &map = *_vm->_map;
- People &people = *_vm->_people;
- Scene &scene = *_vm->_scene;
- Talk &talk = *_vm->_talk;
-
- if (_type == INVALID || (_type == CHARACTER && scene._animating))
- return;
-
- if (!talk._talkCounter && _type == CHARACTER && _walkCount) {
- // Handle active movement for the sprite
- _position += _delta;
- --_walkCount;
-
- if (!_walkCount) {
- // If there any points left for the character to walk to along the
- // route to a destination, then move to the next point
- if (!people._walkTo.empty()) {
- people._walkDest = people._walkTo.pop();
- people.setWalking();
- } else {
- people.gotoStand(*this);
- }
- }
- }
-
- if (_type == CHARACTER && !map._active) {
- if ((_position.y / FIXED_INT_MULTIPLIER) > LOWER_LIMIT) {
- _position.y = LOWER_LIMIT * FIXED_INT_MULTIPLIER;
- people.gotoStand(*this);
- }
-
- if ((_position.y / FIXED_INT_MULTIPLIER) < UPPER_LIMIT) {
- _position.y = UPPER_LIMIT * FIXED_INT_MULTIPLIER;
- people.gotoStand(*this);
- }
-
- if ((_position.x / FIXED_INT_MULTIPLIER) < LEFT_LIMIT) {
- _position.x = LEFT_LIMIT * FIXED_INT_MULTIPLIER;
- people.gotoStand(*this);
- }
-
- if ((_position.x / FIXED_INT_MULTIPLIER) > RIGHT_LIMIT) {
- _position.x = RIGHT_LIMIT * FIXED_INT_MULTIPLIER;
- people.gotoStand(*this);
- }
- } else if (!map._active) {
- _position.y = CLIP((int)_position.y, (int)UPPER_LIMIT, (int)LOWER_LIMIT);
- _position.x = CLIP((int)_position.x, (int)LEFT_LIMIT, (int)RIGHT_LIMIT);
- }
-
- if (!map._active || (map._frameChangeFlag = !map._frameChangeFlag))
- ++_frameNumber;
-
- if (_frameNumber >= (int)_walkSequences[_sequenceNumber]._sequences.size() ||
- _walkSequences[_sequenceNumber][_frameNumber] == 0) {
- switch (_sequenceNumber) {
- case Scalpel::STOP_UP:
- case Scalpel::STOP_DOWN:
- case Scalpel::STOP_LEFT:
- case Scalpel::STOP_RIGHT:
- case Scalpel::STOP_UPRIGHT:
- case Scalpel::STOP_UPLEFT:
- case Scalpel::STOP_DOWNRIGHT:
- case Scalpel::STOP_DOWNLEFT:
- // We're in a stop sequence, so reset back to the last frame, so
- // the character is shown as standing still
- --_frameNumber;
- break;
-
- default:
- // Move 1 past the first frame - we need to compensate, since we
- // already passed the frame increment
- _frameNumber = 1;
- break;
- }
- }
-
- // Update the _imageFrame to point to the new frame's image
- setImageFrame();
-
- // Check to see if character has entered an exit zone
- if (!_walkCount && scene._walkedInScene && scene._goToScene == -1) {
- Common::Rect charRect(_position.x / FIXED_INT_MULTIPLIER - 5, _position.y / FIXED_INT_MULTIPLIER - 2,
- _position.x / FIXED_INT_MULTIPLIER + 5, _position.y / FIXED_INT_MULTIPLIER + 2);
- Exit *exit = scene.checkForExit(charRect);
-
- if (exit) {
- scene._goToScene = exit->_scene;
-
- if (exit->_people.x != 0) {
- people._hSavedPos = exit->_people;
- people._hSavedFacing = exit->_peopleDir;
-
- if (people._hSavedFacing > 100 && people._hSavedPos.x < 1)
- people._hSavedPos.x = 100;
- }
- }
- }
-}
-
void Sprite::checkSprite() {
Events &events = *_vm->_events;
People &people = *_vm->_people;
@@ -472,7 +367,7 @@ void Sprite::checkSprite() {
objBounds.right + CLEAR_DIST_X;
}
- walkPos.x += people[AL]._imageFrame->_frame.w / 2;
+ walkPos.x += people[PLAYER]._imageFrame->_frame.w / 2;
people._walkDest = walkPos;
people._walkTo.push(walkPos);
people.setWalking();
@@ -1400,7 +1295,7 @@ int Object::checkNameForCodes(const Common::String &name, const char *const mess
scene._goToScene = 100;
}
- people[AL]._position = Point32(0, 0);
+ people[PLAYER]._position = Point32(0, 0);
break;
}
} else if (name.hasPrefix("!")) {
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index 6561a370fa..3c690e960f 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -92,6 +92,11 @@ enum {
#define TALK_LISTEN_CODE 251 // Code specifying start of talk listen frames in a Sequence
#define ALLOW_TALK_CODE 250
+#define UPPER_LIMIT 0
+#define LOWER_LIMIT (IS_SERRATED_SCALPEL ? CONTROLS_Y : SHERLOCK_SCREEN_HEIGHT)
+#define LEFT_LIMIT 0
+#define RIGHT_LIMIT SHERLOCK_SCREEN_WIDTH
+
class Point32 {
public:
int x;
@@ -217,7 +222,7 @@ public:
};
class Sprite: public BaseObject {
-private:
+protected:
static SherlockEngine *_vm;
/**
@@ -261,11 +266,6 @@ public:
void setImageFrame();
/**
- * This adjusts the sprites position, as well as it's animation sequence:
- */
- void adjustSprite();
-
- /**
* Checks the sprite's position to see if it's collided with any special objects
*/
void checkSprite();
@@ -299,6 +299,11 @@ public:
* in the sequence number uses alternate graphics, and if so if they need to be loaded
*/
void checkWalkGraphics();
+
+ /**
+ * This adjusts the sprites position, as well as it's animation sequence:
+ */
+ virtual void adjustSprite() = 0;
};
enum { OBJ_BEHIND = 1, OBJ_FLIPPED = 2, OBJ_FORWARD = 4, TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 };
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index e4892b787a..a7434ae3b7 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -101,7 +101,7 @@ People *People::init(SherlockEngine *vm) {
return new Tattoo::TattooPeople(vm);
}
-People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) {
+People::People(SherlockEngine *vm) : _vm(vm) {
_holmesOn = true;
_oldWalkSequence = -1;
_allowWalkAbort = false;
@@ -124,9 +124,10 @@ People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) {
}
People::~People() {
- for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
- if (_data[idx]._walkLoaded)
- delete _data[PLAYER]._images;
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ if (_data[idx]->_walkLoaded)
+ delete _data[idx]->_images;
+ delete _data[idx];
}
delete _talkPics;
@@ -134,12 +135,12 @@ People::~People() {
}
void People::reset() {
- _data[0]._description = "Sherlock Holmes!";
+ _data[PLAYER]->_description = "Sherlock Holmes!";
// Note: Serrated Scalpel only uses a single Person slot for Sherlock.. Watson is handled by scene sprites
int count = IS_SERRATED_SCALPEL ? 1 : MAX_CHARACTERS;
for (int idx = 0; idx < count; ++idx) {
- Sprite &p = _data[idx];
+ Sprite &p = *_data[idx];
p._type = (idx == 0) ? CHARACTER : INVALID;
if (IS_SERRATED_SCALPEL)
@@ -196,71 +197,71 @@ bool People::loadWalk() {
bool result = false;
if (IS_SERRATED_SCALPEL) {
- if (_data[PLAYER]._walkLoaded) {
+ if (_data[PLAYER]->_walkLoaded) {
return false;
} else {
if (_vm->getPlatform() != Common::kPlatform3DO) {
- _data[PLAYER]._images = new ImageFile("walk.vgs");
+ _data[PLAYER]->_images = new ImageFile("walk.vgs");
} else {
// Load walk.anim on 3DO, which is a cel animation file
- _data[PLAYER]._images = new ImageFile3DO("walk.anim");
+ _data[PLAYER]->_images = new ImageFile3DO("walk.anim");
}
- _data[PLAYER].setImageFrame();
- _data[PLAYER]._walkLoaded = true;
+ _data[PLAYER]->setImageFrame();
+ _data[PLAYER]->_walkLoaded = true;
result = true;
}
} else {
for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
- if (!_data[idx]._walkLoaded && (_data[idx]._type == CHARACTER || _data[idx]._type == HIDDEN_CHARACTER)) {
- if (_data[idx]._type == HIDDEN_CHARACTER)
- _data[idx]._type = INVALID;
+ if (!_data[idx]->_walkLoaded && (_data[idx]->_type == CHARACTER || _data[idx]->_type == HIDDEN_CHARACTER)) {
+ if (_data[idx]->_type == HIDDEN_CHARACTER)
+ _data[idx]->_type = INVALID;
// See if this is one of the more used Walk Graphics stored in WALK.LIB
for (int libNum = 0; libNum < NUM_IN_WALK_LIB; ++libNum) {
- if (!_data[idx]._walkVGSName.compareToIgnoreCase(WALK_LIB_NAMES[libNum])) {
+ if (!_data[idx]->_walkVGSName.compareToIgnoreCase(WALK_LIB_NAMES[libNum])) {
_useWalkLib = true;
break;
}
}
// Load the images for the character
- _data[idx]._images = new ImageFile(_data[idx]._walkVGSName, false);
- _data[idx]._numFrames = _data[idx]._images->size();
+ _data[idx]->_images = new ImageFile(_data[idx]->_walkVGSName, false);
+ _data[idx]->_numFrames = _data[idx]->_images->size();
// Load walk sequence data
- Common::String fname = Common::String(_data[idx]._walkVGSName.c_str(), strchr(_data[idx]._walkVGSName.c_str(), '.'));
+ Common::String fname = Common::String(_data[idx]->_walkVGSName.c_str(), strchr(_data[idx]->_walkVGSName.c_str(), '.'));
fname += ".SEQ";
// Load the walk sequence data
Common::SeekableReadStream *stream = res.load(fname, _useWalkLib ? "walk.lib" : "vgs.lib");
- _data[idx]._walkSequences.resize(stream->readByte());
+ _data[idx]->_walkSequences.resize(stream->readByte());
- for (uint seqNum = 0; seqNum < _data[idx]._walkSequences.size(); ++seqNum)
- _data[idx]._walkSequences[seqNum].load(*stream);
+ for (uint seqNum = 0; seqNum < _data[idx]->_walkSequences.size(); ++seqNum)
+ _data[idx]->_walkSequences[seqNum].load(*stream);
// Close the sequences resource
delete stream;
_useWalkLib = false;
- _data[idx]._frameNumber = 0;
- _data[idx].setImageFrame();
+ _data[idx]->_frameNumber = 0;
+ _data[idx]->setImageFrame();
// Set the stop Frames pointers
for (int dirNum = 0; dirNum < 8; ++dirNum) {
int count = 0;
- while (_data[idx]._walkSequences[dirNum + 8][count] != 0)
+ while (_data[idx]->_walkSequences[dirNum + 8][count] != 0)
++count;
count += 2;
- count = _data[idx]._walkSequences[dirNum + 8][count] - 1;
- _data[idx]._stopFrames[dirNum] = &(*_data[idx]._images)[count];
+ count = _data[idx]->_walkSequences[dirNum + 8][count] - 1;
+ _data[idx]->_stopFrames[dirNum] = &(*_data[idx]->_images)[count];
}
result = true;
- _data[idx]._walkLoaded = true;
- } else if (_data[idx]._type != CHARACTER) {
- _data[idx]._walkLoaded = false;
+ _data[idx]->_walkLoaded = true;
+ } else if (_data[idx]->_type != CHARACTER) {
+ _data[idx]->_walkLoaded = false;
}
}
}
@@ -273,11 +274,11 @@ bool People::freeWalk() {
bool result = false;
for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
- if (_data[idx]._walkLoaded) {
- delete _data[idx]._images;
- _data[idx]._images = nullptr;
+ if (_data[idx]->_walkLoaded) {
+ delete _data[idx]->_images;
+ _data[idx]->_images = nullptr;
- _data[idx]._walkLoaded = false;
+ _data[idx]->_walkLoaded = false;
result = true;
}
}
@@ -295,9 +296,9 @@ void People::setWalking() {
scene._walkedInScene = true;
// Stop any previous walking, since a new dest is being set
- _player._walkCount = 0;
- oldDirection = _player._sequenceNumber;
- oldFrame = _player._frameNumber;
+ _data[PLAYER]->_walkCount = 0;
+ oldDirection = _data[PLAYER]->_sequenceNumber;
+ oldFrame = _data[PLAYER]->_frameNumber;
// Set speed to use horizontal and vertical movement
if (map._active) {
@@ -314,12 +315,12 @@ void People::setWalking() {
// clicked, but characters draw positions start at their left, move
// the destination half the character width to draw him centered
int temp;
- if (_walkDest.x >= (temp = _player._imageFrame->_frame.w / 2))
+ if (_walkDest.x >= (temp = _data[PLAYER]->_imageFrame->_frame.w / 2))
_walkDest.x -= temp;
delta = Common::Point(
- ABS(_player._position.x / FIXED_INT_MULTIPLIER - _walkDest.x),
- ABS(_player._position.y / FIXED_INT_MULTIPLIER - _walkDest.y)
+ ABS(_data[PLAYER]->_position.x / FIXED_INT_MULTIPLIER - _walkDest.x),
+ ABS(_data[PLAYER]->_position.y / FIXED_INT_MULTIPLIER - _walkDest.y)
);
// If we're ready to move a sufficient distance, that's it. Otherwise,
@@ -337,53 +338,53 @@ void People::setWalking() {
if (delta.x >= delta.y) {
// Set the initial frame sequence for the left and right, as well
// as setting the delta x depending on direction
- if (_walkDest.x < (_player._position.x / FIXED_INT_MULTIPLIER)) {
- _player._sequenceNumber = (map._active ? (int)MAP_LEFT : (int)Scalpel::WALK_LEFT);
- _player._delta.x = speed.x * -FIXED_INT_MULTIPLIER;
+ if (_walkDest.x < (_data[PLAYER]->_position.x / FIXED_INT_MULTIPLIER)) {
+ _data[PLAYER]->_sequenceNumber = (map._active ? (int)MAP_LEFT : (int)Scalpel::WALK_LEFT);
+ _data[PLAYER]->_delta.x = speed.x * -FIXED_INT_MULTIPLIER;
} else {
- _player._sequenceNumber = (map._active ? (int)MAP_RIGHT : (int)Scalpel::WALK_RIGHT);
- _player._delta.x = speed.x * FIXED_INT_MULTIPLIER;
+ _data[PLAYER]->_sequenceNumber = (map._active ? (int)MAP_RIGHT : (int)Scalpel::WALK_RIGHT);
+ _data[PLAYER]->_delta.x = speed.x * FIXED_INT_MULTIPLIER;
}
// See if the x delta is too small to be divided by the speed, since
// this would cause a divide by zero error
if (delta.x >= speed.x) {
// Det the delta y
- _player._delta.y = (delta.y * FIXED_INT_MULTIPLIER) / (delta.x / speed.x);
- if (_walkDest.y < (_player._position.y / FIXED_INT_MULTIPLIER))
- _player._delta.y = -_player._delta.y;
+ _data[PLAYER]->_delta.y = (delta.y * FIXED_INT_MULTIPLIER) / (delta.x / speed.x);
+ if (_walkDest.y < (_data[PLAYER]->_position.y / FIXED_INT_MULTIPLIER))
+ _data[PLAYER]->_delta.y = -_data[PLAYER]->_delta.y;
// Set how many times we should add the delta to the player's position
- _player._walkCount = delta.x / speed.x;
+ _data[PLAYER]->_walkCount = delta.x / speed.x;
} else {
// The delta x was less than the speed (ie. we're really close to
// the destination). So set delta to 0 so the player won't move
- _player._delta = Point32(0, 0);
- _player._position = Point32(_walkDest.x * FIXED_INT_MULTIPLIER, _walkDest.y * FIXED_INT_MULTIPLIER);
-assert(_player._position.y >= 10000);/***DEBUG****/
- _player._walkCount = 1;
+ _data[PLAYER]->_delta = Point32(0, 0);
+ _data[PLAYER]->_position = Point32(_walkDest.x * FIXED_INT_MULTIPLIER, _walkDest.y * FIXED_INT_MULTIPLIER);
+assert(_data[PLAYER]->_position.y >= 10000);/***DEBUG****/
+ _data[PLAYER]->_walkCount = 1;
}
// See if the sequence needs to be changed for diagonal walking
- if (_player._delta.y > 150) {
+ if (_data[PLAYER]->_delta.y > 150) {
if (!map._active) {
- switch (_player._sequenceNumber) {
+ switch (_data[PLAYER]->_sequenceNumber) {
case Scalpel::WALK_LEFT:
- _player._sequenceNumber = Scalpel::WALK_DOWNLEFT;
+ _data[PLAYER]->_sequenceNumber = Scalpel::WALK_DOWNLEFT;
break;
case Scalpel::WALK_RIGHT:
- _player._sequenceNumber = Scalpel::WALK_DOWNRIGHT;
+ _data[PLAYER]->_sequenceNumber = Scalpel::WALK_DOWNRIGHT;
break;
}
}
- } else if (_player._delta.y < -150) {
+ } else if (_data[PLAYER]->_delta.y < -150) {
if (!map._active) {
- switch (_player._sequenceNumber) {
+ switch (_data[PLAYER]->_sequenceNumber) {
case Scalpel::WALK_LEFT:
- _player._sequenceNumber = Scalpel::WALK_UPLEFT;
+ _data[PLAYER]->_sequenceNumber = Scalpel::WALK_UPLEFT;
break;
case Scalpel::WALK_RIGHT:
- _player._sequenceNumber = Scalpel::WALK_UPRIGHT;
+ _data[PLAYER]->_sequenceNumber = Scalpel::WALK_UPRIGHT;
break;
}
}
@@ -391,25 +392,25 @@ assert(_player._position.y >= 10000);/***DEBUG****/
} else {
// Major movement is vertical, so set the sequence for up and down,
// and set the delta Y depending on the direction
- if (_walkDest.y < (_player._position.y / FIXED_INT_MULTIPLIER)) {
- _player._sequenceNumber = Scalpel::WALK_UP;
- _player._delta.y = speed.y * -FIXED_INT_MULTIPLIER;
+ if (_walkDest.y < (_data[PLAYER]->_position.y / FIXED_INT_MULTIPLIER)) {
+ _data[PLAYER]->_sequenceNumber = Scalpel::WALK_UP;
+ _data[PLAYER]->_delta.y = speed.y * -FIXED_INT_MULTIPLIER;
} else {
- _player._sequenceNumber = Scalpel::WALK_DOWN;
- _player._delta.y = speed.y * FIXED_INT_MULTIPLIER;
+ _data[PLAYER]->_sequenceNumber = Scalpel::WALK_DOWN;
+ _data[PLAYER]->_delta.y = speed.y * FIXED_INT_MULTIPLIER;
}
// If we're on the overhead map, set the sequence so we keep moving
// in the same direction
if (map._active)
- _player._sequenceNumber = (oldDirection == -1) ? MAP_RIGHT : oldDirection;
+ _data[PLAYER]->_sequenceNumber = (oldDirection == -1) ? MAP_RIGHT : oldDirection;
// Set the delta x
- _player._delta.x = (delta.x * FIXED_INT_MULTIPLIER) / (delta.y / speed.y);
- if (_walkDest.x < (_player._position.x / FIXED_INT_MULTIPLIER))
- _player._delta.x = -_player._delta.x;
+ _data[PLAYER]->_delta.x = (delta.x * FIXED_INT_MULTIPLIER) / (delta.y / speed.y);
+ if (_walkDest.x < (_data[PLAYER]->_position.x / FIXED_INT_MULTIPLIER))
+ _data[PLAYER]->_delta.x = -_data[PLAYER]->_delta.x;
- _player._walkCount = delta.y / speed.y;
+ _data[PLAYER]->_walkCount = delta.y / speed.y;
}
}
@@ -417,18 +418,18 @@ assert(_player._position.y >= 10000);/***DEBUG****/
// we need to reset the frame number to zero so it's animation starts at
// it's beginning. Otherwise, if it's the same sequence, we can leave it
// as is, so it keeps the animation going at wherever it was up to
- if (_player._sequenceNumber != _oldWalkSequence)
- _player._frameNumber = 0;
- _oldWalkSequence = _player._sequenceNumber;
+ if (_data[PLAYER]->_sequenceNumber != _oldWalkSequence)
+ _data[PLAYER]->_frameNumber = 0;
+ _oldWalkSequence = _data[PLAYER]->_sequenceNumber;
- if (!_player._walkCount)
- gotoStand(_player);
+ if (!_data[PLAYER]->_walkCount)
+ gotoStand(*_data[PLAYER]);
// If the sequence is the same as when we started, then Holmes was
// standing still and we're trying to re-stand him, so reset Holmes'
// rame to the old frame number from before it was reset to 0
- if (_player._sequenceNumber == oldDirection)
- _player._frameNumber = oldFrame;
+ if (_data[PLAYER]->_sequenceNumber == oldDirection)
+ _data[PLAYER]->_frameNumber = oldFrame;
}
void People::walkToCoords(const Point32 &destPos, int destDir) {
@@ -447,15 +448,15 @@ void People::walkToCoords(const Point32 &destPos, int destDir) {
do {
events.pollEventsAndWait();
scene.doBgAnim();
- } while (!_vm->shouldQuit() && _player._walkCount);
+ } while (!_vm->shouldQuit() && _data[PLAYER]->_walkCount);
if (!talk._talkToAbort) {
// Put player exactly on destination position, and set direction
- _player._position = destPos;
-assert(_player._position.y >= 10000);/***DEBUG****/
+ _data[PLAYER]->_position = destPos;
+assert(_data[PLAYER]->_position.y >= 10000);/***DEBUG****/
- _player._sequenceNumber = destDir;
- gotoStand(_player);
+ _data[PLAYER]->_sequenceNumber = destDir;
+ gotoStand(*_data[PLAYER]);
// Draw Holmes facing the new direction
scene.doBgAnim();
@@ -467,8 +468,8 @@ assert(_player._position.y >= 10000);/***DEBUG****/
void People::goAllTheWay() {
Scene &scene = *_vm->_scene;
- Common::Point srcPt(_player._position.x / FIXED_INT_MULTIPLIER + _player.frameWidth() / 2,
- _player._position.y / FIXED_INT_MULTIPLIER);
+ Common::Point srcPt(_data[PLAYER]->_position.x / FIXED_INT_MULTIPLIER + _data[PLAYER]->frameWidth() / 2,
+ _data[PLAYER]->_position.y / FIXED_INT_MULTIPLIER);
// Get the zone the player is currently in
_srcZone = scene.whichZone(srcPt);
@@ -572,14 +573,14 @@ int People::findSpeaker(int speaker) {
if (IS_ROSE_TATTOO) {
bool flag = _vm->readFlags(76);
- if (_data[0]._type == CHARACTER && ((speaker == 0 && flag) || (speaker == 1 && !flag)))
+ if (_data[PLAYER]->_type == CHARACTER && ((speaker == 0 && flag) || (speaker == 1 && !flag)))
return -1;
- for (uint idx = 1; idx < MAX_CHARACTERS; ++idx) {
- if (_data[idx]._type == CHARACTER) {
- Common::String name(_data[idx]._name.c_str(), _data[idx]._name.c_str() + 4);
+ for (uint idx = 1; idx < _data.size(); ++idx) {
+ if (_data[idx]->_type == CHARACTER) {
+ Common::String name(_data[idx]->_name.c_str(), _data[idx]->_name.c_str() + 4);
- if (name.equalsIgnoreCase(portrait) && _data[idx]._npcName[4] >= '0' && _data[idx]._npcName[4] <= '9')
+ if (name.equalsIgnoreCase(portrait) && _data[idx]->_npcName[4] >= '0' && _data[idx]->_npcName[4] <= '9')
return idx + 256;
}
}
@@ -622,12 +623,12 @@ void People::synchronize(Serializer &s) {
s.syncAsByte(_holmesOn);
if (IS_SERRATED_SCALPEL) {
- s.syncAsSint16LE(_player._position.x);
- s.syncAsSint16LE(_player._position.y);
- s.syncAsSint16LE(_player._sequenceNumber);
+ s.syncAsSint16LE(_data[PLAYER]->_position.x);
+ s.syncAsSint16LE(_data[PLAYER]->_position.y);
+ s.syncAsSint16LE(_data[PLAYER]->_sequenceNumber);
} else {
- for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
- Person &p = _data[idx];
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ Person &p = *_data[idx];
s.syncAsSint16LE(p._position.x);
s.syncAsSint16LE(p._position.y);
s.syncAsSint16LE(p._sequenceNumber);
@@ -641,8 +642,8 @@ void People::synchronize(Serializer &s) {
s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) {
- _hSavedPos = _player._position;
- _hSavedFacing = _player._sequenceNumber;
+ _hSavedPos = _data[PLAYER]->_position;
+ _hSavedFacing = _data[PLAYER]->_sequenceNumber;
}
}
diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h
index cd790ead5c..b45f7b4929 100644
--- a/engines/sherlock/people.h
+++ b/engines/sherlock/people.h
@@ -32,9 +32,6 @@ namespace Sherlock {
enum PeopleId {
PLAYER = 0,
- AL = 0,
- PEG = 1,
- MAX_CHARACTERS = 6,
MAX_NPC = 5,
MAX_NPC_PATH = 200
};
@@ -47,6 +44,7 @@ enum {
#define NUM_IN_WALK_LIB 10
extern const char *const WALK_LIB_NAMES[10];
+#define MAX_CHARACTERS (IS_SERRATED_SCALPEL ? 1 : 6)
struct PersonData {
const char *_name;
@@ -81,6 +79,7 @@ public:
Common::String _walkVGSName; // Name of walk library person is using
public:
Person();
+ virtual ~Person() {}
/**
* Clear the NPC related data
@@ -98,7 +97,7 @@ class SherlockEngine;
class People {
protected:
SherlockEngine *_vm;
- Person _data[MAX_CHARACTERS];
+ Common::Array<Person *> _data;
int _oldWalkSequence;
int _srcZone, _destZone;
@@ -110,7 +109,6 @@ public:
Point32 _hSavedPos;
int _hSavedFacing;
Common::Queue<Common::Point> _walkTo;
- Person &_player;
bool _holmesOn;
bool _portraitLoaded;
bool _portraitsOn;
@@ -129,14 +127,8 @@ public:
static People *init(SherlockEngine *vm);
virtual ~People();
- Person &operator[](PeopleId id) {
- assert(id < MAX_CHARACTERS);
- return _data[id];
- }
- Person &operator[](int idx) {
- assert(idx < MAX_CHARACTERS);
- return _data[idx];
- }
+ Person &operator[](PeopleId id) { return *_data[id]; }
+ Person &operator[](int idx) { return *_data[idx]; }
/**
* Reset the player data
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index e0c91ee7c5..a3ada427ad 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -961,7 +961,7 @@ void ScalpelEngine::startScene() {
}
void ScalpelEngine::eraseMirror12() {
- Common::Point pt((*_people)[AL]._position.x / FIXED_INT_MULTIPLIER, (*_people)[AL]._position.y / FIXED_INT_MULTIPLIER);
+ Common::Point pt((*_people)[PLAYER]._position.x / FIXED_INT_MULTIPLIER, (*_people)[PLAYER]._position.y / FIXED_INT_MULTIPLIER);
// If player is in range of the mirror, then restore background from the secondary back buffer
if (Common::Rect(70, 100, 200, 200).contains(pt)) {
@@ -972,13 +972,13 @@ void ScalpelEngine::eraseMirror12() {
void ScalpelEngine::doMirror12() {
People &people = *_people;
- Person &player = people._player;
+ Person &player = people[PLAYER];
- Common::Point pt((*_people)[AL]._position.x / FIXED_INT_MULTIPLIER, (*_people)[AL]._position.y / FIXED_INT_MULTIPLIER);
+ Common::Point pt((*_people)[PLAYER]._position.x / FIXED_INT_MULTIPLIER, (*_people)[PLAYER]._position.y / FIXED_INT_MULTIPLIER);
int frameNum = player._walkSequences[player._sequenceNumber][player._frameNumber] +
player._walkSequences[player._sequenceNumber][0] - 2;
- switch ((*_people)[AL]._sequenceNumber) {
+ switch ((*_people)[PLAYER]._sequenceNumber) {
case WALK_DOWN:
frameNum -= 7;
break;
@@ -1021,12 +1021,12 @@ void ScalpelEngine::doMirror12() {
if (Common::Rect(80, 100, 145, 138).contains(pt)) {
// Get the frame of Sherlock to draw
- ImageFrame &imageFrame = (*people[AL]._images)[frameNum];
+ ImageFrame &imageFrame = (*people[PLAYER]._images)[frameNum];
// Draw the mirror image of Holmes
- bool flipped = people[AL]._sequenceNumber == WALK_LEFT || people[AL]._sequenceNumber == STOP_LEFT
- || people[AL]._sequenceNumber == WALK_UPRIGHT || people[AL]._sequenceNumber == STOP_UPRIGHT
- || people[AL]._sequenceNumber == WALK_DOWNLEFT || people[AL]._sequenceNumber == STOP_DOWNLEFT;
+ bool flipped = people[PLAYER]._sequenceNumber == WALK_LEFT || people[PLAYER]._sequenceNumber == STOP_LEFT
+ || people[PLAYER]._sequenceNumber == WALK_UPRIGHT || people[PLAYER]._sequenceNumber == STOP_UPRIGHT
+ || people[PLAYER]._sequenceNumber == WALK_DOWNLEFT || people[PLAYER]._sequenceNumber == STOP_DOWNLEFT;
_screen->_backBuffer1.transBlitFrom(imageFrame, pt + Common::Point(38, -imageFrame._frame.h - 25), flipped);
// Redraw the mirror borders to prevent the drawn image of Holmes from appearing outside of the mirror
@@ -1046,7 +1046,7 @@ void ScalpelEngine::doMirror12() {
}
void ScalpelEngine::flushMirror12() {
- Common::Point pt((*_people)[AL]._position.x / FIXED_INT_MULTIPLIER, (*_people)[AL]._position.y / FIXED_INT_MULTIPLIER);
+ Common::Point pt((*_people)[PLAYER]._position.x / FIXED_INT_MULTIPLIER, (*_people)[PLAYER]._position.y / FIXED_INT_MULTIPLIER);
// If player is in range of the mirror, then draw the entire mirror area to the screen
if (Common::Rect(70, 100, 200, 200).contains(pt))
diff --git a/engines/sherlock/scalpel/scalpel_map.cpp b/engines/sherlock/scalpel/scalpel_map.cpp
index bcb41abe73..3957f27457 100644
--- a/engines/sherlock/scalpel/scalpel_map.cpp
+++ b/engines/sherlock/scalpel/scalpel_map.cpp
@@ -155,7 +155,7 @@ int ScalpelMap::show() {
_drawMap = true;
_charPoint = -1;
_point = -1;
- people[AL]._position = _lDrawnPos = _overPos;
+ people[PLAYER]._position = _lDrawnPos = _overPos;
// Show place icons
showPlaces();
@@ -233,7 +233,7 @@ int ScalpelMap::show() {
}
if ((events._released || events._rightReleased) && _point != -1) {
- if (people[AL]._walkCount == 0) {
+ if (people[PLAYER]._walkCount == 0) {
people._walkDest = _points[_point] + Common::Point(4, 9);
_charPoint = _point;
@@ -247,7 +247,7 @@ int ScalpelMap::show() {
}
// Check if a scene has beeen selected and we've finished "moving" to it
- if (people[AL]._walkCount == 0) {
+ if (people[PLAYER]._walkCount == 0) {
if (_charPoint >= 1 && _charPoint < (int)_points.size())
exitFlag = true;
}
@@ -266,7 +266,7 @@ int ScalpelMap::show() {
}
freeSprites();
- _overPos = people[AL]._position;
+ _overPos = people[PLAYER]._position;
// Reset font
screen.setFont(oldFont);
@@ -288,7 +288,7 @@ void ScalpelMap::setupSprites() {
_shapes = new ImageFile("mapicon.vgs");
_iconShapes = new ImageFile("overicon.vgs");
_iconSave.create((*_shapes)[4]._width, (*_shapes)[4]._height, _vm->getPlatform());
- Person &p = people[AL];
+ Person &p = people[PLAYER];
p._description = " ";
p._type = CHARACTER;
p._position = Common::Point(12400, 5000);
@@ -353,11 +353,11 @@ void ScalpelMap::showPlaceName(int idx, bool highlighted) {
int width = screen.stringWidth(name);
if (!_cursorIndex) {
- saveIcon(people[AL]._imageFrame, _lDrawnPos);
+ saveIcon(people[PLAYER]._imageFrame, _lDrawnPos);
- bool flipped = people[AL]._sequenceNumber == MAP_DOWNLEFT || people[AL]._sequenceNumber == MAP_LEFT
- || people[AL]._sequenceNumber == MAP_UPLEFT;
- screen._backBuffer1.transBlitFrom(*people[AL]._imageFrame, _lDrawnPos, flipped);
+ bool flipped = people[PLAYER]._sequenceNumber == MAP_DOWNLEFT || people[PLAYER]._sequenceNumber == MAP_LEFT
+ || people[PLAYER]._sequenceNumber == MAP_UPLEFT;
+ screen._backBuffer1.transBlitFrom(*people[PLAYER]._imageFrame, _lDrawnPos, flipped);
}
if (highlighted) {
@@ -390,26 +390,26 @@ void ScalpelMap::updateMap(bool flushScreen) {
else
_savedPos.x = -1;
- people[AL].adjustSprite();
+ people[PLAYER].adjustSprite();
- _lDrawnPos.x = hPos.x = people[AL]._position.x / FIXED_INT_MULTIPLIER - _bigPos.x;
- _lDrawnPos.y = hPos.y = people[AL]._position.y / FIXED_INT_MULTIPLIER - people[AL].frameHeight() - _bigPos.y;
+ _lDrawnPos.x = hPos.x = people[PLAYER]._position.x / FIXED_INT_MULTIPLIER - _bigPos.x;
+ _lDrawnPos.y = hPos.y = people[PLAYER]._position.y / FIXED_INT_MULTIPLIER - people[PLAYER].frameHeight() - _bigPos.y;
// Draw the person icon
- saveIcon(people[AL]._imageFrame, hPos);
- if (people[AL]._sequenceNumber == MAP_DOWNLEFT || people[AL]._sequenceNumber == MAP_LEFT
- || people[AL]._sequenceNumber == MAP_UPLEFT)
- screen._backBuffer1.transBlitFrom(*people[AL]._imageFrame, hPos, true);
+ saveIcon(people[PLAYER]._imageFrame, hPos);
+ if (people[PLAYER]._sequenceNumber == MAP_DOWNLEFT || people[PLAYER]._sequenceNumber == MAP_LEFT
+ || people[PLAYER]._sequenceNumber == MAP_UPLEFT)
+ screen._backBuffer1.transBlitFrom(*people[PLAYER]._imageFrame, hPos, true);
else
- screen._backBuffer1.transBlitFrom(*people[AL]._imageFrame, hPos, false);
+ screen._backBuffer1.transBlitFrom(*people[PLAYER]._imageFrame, hPos, false);
if (flushScreen) {
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
} else if (!_drawMap) {
if (hPos.x > 0 && hPos.y >= 0 && hPos.x < SHERLOCK_SCREEN_WIDTH && hPos.y < SHERLOCK_SCREEN_HEIGHT)
- screen.flushImage(people[AL]._imageFrame, Common::Point(people[AL]._position.x / FIXED_INT_MULTIPLIER - _bigPos.x,
- people[AL]._position.y / FIXED_INT_MULTIPLIER - people[AL].frameHeight() - _bigPos.y),
- &people[AL]._oldPosition.x, &people[AL]._oldPosition.y, &people[AL]._oldSize.x, &people[AL]._oldSize.y);
+ screen.flushImage(people[PLAYER]._imageFrame, Common::Point(people[PLAYER]._position.x / FIXED_INT_MULTIPLIER - _bigPos.x,
+ people[PLAYER]._position.y / FIXED_INT_MULTIPLIER - people[PLAYER].frameHeight() - _bigPos.y),
+ &people[PLAYER]._oldPosition.x, &people[PLAYER]._oldPosition.y, &people[PLAYER]._oldSize.x, &people[PLAYER]._oldSize.y);
if (osPos.x != -1)
screen.slamArea(osPos.x, osPos.y, osSize.x, osSize.y);
@@ -433,7 +433,7 @@ void ScalpelMap::walkTheStreets() {
// Check for any intermediate points between the two locations
if (path[0] || _charPoint > 50 || _oldCharPoint > 50) {
- people[AL]._sequenceNumber = -1;
+ people[PLAYER]._sequenceNumber = -1;
if (_charPoint == 51 || _oldCharPoint == 51) {
people.setWalking();
@@ -467,7 +467,7 @@ void ScalpelMap::walkTheStreets() {
people.setWalking();
}
} else {
- people[AL]._walkCount = 0;
+ people[PLAYER]._walkCount = 0;
}
// Store the final destination icon position
diff --git a/engines/sherlock/scalpel/scalpel_people.cpp b/engines/sherlock/scalpel/scalpel_people.cpp
index 80e6061e8b..e0abd72842 100644
--- a/engines/sherlock/scalpel/scalpel_people.cpp
+++ b/engines/sherlock/scalpel/scalpel_people.cpp
@@ -28,6 +28,113 @@ namespace Sherlock {
namespace Scalpel {
+void ScalpelPerson::adjustSprite() {
+ Map &map = *_vm->_map;
+ People &people = *_vm->_people;
+ Scene &scene = *_vm->_scene;
+ Talk &talk = *_vm->_talk;
+
+ if (_type == INVALID || (_type == CHARACTER && scene._animating))
+ return;
+
+ if (!talk._talkCounter && _type == CHARACTER && _walkCount) {
+ // Handle active movement for the sprite
+ _position += _delta;
+ --_walkCount;
+
+ if (!_walkCount) {
+ // If there any points left for the character to walk to along the
+ // route to a destination, then move to the next point
+ if (!people._walkTo.empty()) {
+ people._walkDest = people._walkTo.pop();
+ people.setWalking();
+ } else {
+ people.gotoStand(*this);
+ }
+ }
+ }
+
+ if (_type == CHARACTER && !map._active) {
+ if ((_position.y / FIXED_INT_MULTIPLIER) > LOWER_LIMIT) {
+ _position.y = LOWER_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+
+ if ((_position.y / FIXED_INT_MULTIPLIER) < UPPER_LIMIT) {
+ _position.y = UPPER_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+
+ if ((_position.x / FIXED_INT_MULTIPLIER) < LEFT_LIMIT) {
+ _position.x = LEFT_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+
+ if ((_position.x / FIXED_INT_MULTIPLIER) > RIGHT_LIMIT) {
+ _position.x = RIGHT_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+ } else if (!map._active) {
+ _position.y = CLIP((int)_position.y, (int)UPPER_LIMIT, (int)LOWER_LIMIT);
+ _position.x = CLIP((int)_position.x, (int)LEFT_LIMIT, (int)RIGHT_LIMIT);
+ }
+
+ if (!map._active || (map._frameChangeFlag = !map._frameChangeFlag))
+ ++_frameNumber;
+
+ if (_frameNumber >= (int)_walkSequences[_sequenceNumber]._sequences.size() ||
+ _walkSequences[_sequenceNumber][_frameNumber] == 0) {
+ switch (_sequenceNumber) {
+ case Scalpel::STOP_UP:
+ case Scalpel::STOP_DOWN:
+ case Scalpel::STOP_LEFT:
+ case Scalpel::STOP_RIGHT:
+ case Scalpel::STOP_UPRIGHT:
+ case Scalpel::STOP_UPLEFT:
+ case Scalpel::STOP_DOWNRIGHT:
+ case Scalpel::STOP_DOWNLEFT:
+ // We're in a stop sequence, so reset back to the last frame, so
+ // the character is shown as standing still
+ --_frameNumber;
+ break;
+
+ default:
+ // Move 1 past the first frame - we need to compensate, since we
+ // already passed the frame increment
+ _frameNumber = 1;
+ break;
+ }
+ }
+
+ // Update the _imageFrame to point to the new frame's image
+ setImageFrame();
+
+ // Check to see if character has entered an exit zone
+ if (!_walkCount && scene._walkedInScene && scene._goToScene == -1) {
+ Common::Rect charRect(_position.x / FIXED_INT_MULTIPLIER - 5, _position.y / FIXED_INT_MULTIPLIER - 2,
+ _position.x / FIXED_INT_MULTIPLIER + 5, _position.y / FIXED_INT_MULTIPLIER + 2);
+ Exit *exit = scene.checkForExit(charRect);
+
+ if (exit) {
+ scene._goToScene = exit->_scene;
+
+ if (exit->_people.x != 0) {
+ people._hSavedPos = exit->_people;
+ people._hSavedFacing = exit->_peopleDir;
+
+ if (people._hSavedFacing > 100 && people._hSavedPos.x < 1)
+ people._hSavedPos.x = 100;
+ }
+ }
+ }
+}
+
+/*----------------------------------------------------------------*/
+
+ScalpelPeople::ScalpelPeople(SherlockEngine *vm) : People(vm) {
+ _data.push_back(new ScalpelPerson());
+}
+
void ScalpelPeople::setTalking(int speaker) {
Resources &res = *_vm->_res;
@@ -89,14 +196,14 @@ void ScalpelPeople::setTalking(int speaker) {
void ScalpelPeople::synchronize(Serializer &s) {
s.syncAsByte(_holmesOn);
- s.syncAsSint32LE(_player._position.x);
- s.syncAsSint32LE(_player._position.y);
- s.syncAsSint16LE(_player._sequenceNumber);
+ s.syncAsSint32LE(_data[PLAYER]->_position.x);
+ s.syncAsSint32LE(_data[PLAYER]->_position.y);
+ s.syncAsSint16LE(_data[PLAYER]->_sequenceNumber);
s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) {
- _hSavedPos = _player._position;
- _hSavedFacing = _player._sequenceNumber;
+ _hSavedPos = _data[PLAYER]->_position;
+ _hSavedFacing = _data[PLAYER]->_sequenceNumber;
}
}
@@ -172,8 +279,8 @@ void ScalpelPeople::gotoStand(Sprite &sprite) {
if (map._active) {
sprite._sequenceNumber = 0;
- _player._position.x = (map[map._charPoint].x - 6) * FIXED_INT_MULTIPLIER;
- _player._position.y = (map[map._charPoint].y + 10) * FIXED_INT_MULTIPLIER;
+ _data[PLAYER]->_position.x = (map[map._charPoint].x - 6) * FIXED_INT_MULTIPLIER;
+ _data[PLAYER]->_position.y = (map[map._charPoint].y + 10) * FIXED_INT_MULTIPLIER;
}
_oldWalkSequence = -1;
diff --git a/engines/sherlock/scalpel/scalpel_people.h b/engines/sherlock/scalpel/scalpel_people.h
index 1f14ceee0e..dac685b26c 100644
--- a/engines/sherlock/scalpel/scalpel_people.h
+++ b/engines/sherlock/scalpel/scalpel_people.h
@@ -41,9 +41,20 @@ enum ScalpelSequences {
STOP_DOWNLEFT = 15, TALK_RIGHT = 6, TALK_LEFT = 4
};
+class ScalpelPerson : public Person {
+public:
+ ScalpelPerson() : Person() {}
+ virtual ~ScalpelPerson() {}
+
+ /**
+ * This adjusts the sprites position, as well as it's animation sequence:
+ */
+ virtual void adjustSprite();
+};
+
class ScalpelPeople : public People {
public:
- ScalpelPeople(SherlockEngine *vm) : People(vm) {}
+ ScalpelPeople(SherlockEngine *vm);
virtual ~ScalpelPeople() {}
/**
diff --git a/engines/sherlock/scalpel/scalpel_scene.cpp b/engines/sherlock/scalpel/scalpel_scene.cpp
index 95a58be99d..e3bc6483eb 100644
--- a/engines/sherlock/scalpel/scalpel_scene.cpp
+++ b/engines/sherlock/scalpel/scalpel_scene.cpp
@@ -138,7 +138,7 @@ void ScalpelScene::drawAllShapes() {
void ScalpelScene::checkBgShapes() {
People &people = *_vm->_people;
- Person &holmes = people._player;
+ Person &holmes = people[PLAYER];
Common::Point pt(holmes._position.x / FIXED_INT_MULTIPLIER, holmes._position.y / FIXED_INT_MULTIPLIER);
// Call the base scene method to handle bg shapes
@@ -229,14 +229,14 @@ void ScalpelScene::doBgAnim() {
vm.eraseMirror12();
// Restore the back buffer from the back buffer 2 in the changed area
- Common::Rect bounds(people[AL]._oldPosition.x, people[AL]._oldPosition.y,
- people[AL]._oldPosition.x + people[AL]._oldSize.x,
- people[AL]._oldPosition.y + people[AL]._oldSize.y);
+ Common::Rect bounds(people[PLAYER]._oldPosition.x, people[PLAYER]._oldPosition.y,
+ people[PLAYER]._oldPosition.x + people[PLAYER]._oldSize.x,
+ people[PLAYER]._oldPosition.y + people[PLAYER]._oldSize.y);
Common::Point pt(bounds.left, bounds.top);
- if (people[AL]._type == CHARACTER)
+ if (people[PLAYER]._type == CHARACTER)
screen.restoreBackground(bounds);
- else if (people[AL]._type == REMOVE)
+ else if (people[PLAYER]._type == REMOVE)
screen._backBuffer->blitFrom(screen._backBuffer2, pt, bounds);
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
@@ -291,8 +291,8 @@ void ScalpelScene::doBgAnim() {
_canimShapes[idx].adjustObject();
}
- if (people[AL]._type == CHARACTER && people._holmesOn)
- people[AL].adjustSprite();
+ if (people[PLAYER]._type == CHARACTER && people._holmesOn)
+ people[PLAYER].adjustSprite();
// Flag the bg shapes which need to be redrawn
checkBgShapes();
@@ -331,16 +331,16 @@ void ScalpelScene::doBgAnim() {
}
// Draw the person if not animating
- if (people[AL]._type == CHARACTER && people[AL]._walkLoaded) {
+ if (people[PLAYER]._type == CHARACTER && people[PLAYER]._walkLoaded) {
// If Holmes is too far to the right, move him back so he's on-screen
- int xRight = SHERLOCK_SCREEN_WIDTH - 2 - people[AL]._imageFrame->_frame.w;
- int tempX = MIN(people[AL]._position.x / FIXED_INT_MULTIPLIER, xRight);
+ int xRight = SHERLOCK_SCREEN_WIDTH - 2 - people[PLAYER]._imageFrame->_frame.w;
+ int tempX = MIN(people[PLAYER]._position.x / FIXED_INT_MULTIPLIER, xRight);
- bool flipped = people[AL]._sequenceNumber == WALK_LEFT || people[AL]._sequenceNumber == STOP_LEFT ||
- people[AL]._sequenceNumber == WALK_UPLEFT || people[AL]._sequenceNumber == STOP_UPLEFT ||
- people[AL]._sequenceNumber == WALK_DOWNRIGHT || people[AL]._sequenceNumber == STOP_DOWNRIGHT;
- screen._backBuffer->transBlitFrom(*people[AL]._imageFrame,
- Common::Point(tempX, people[AL]._position.y / FIXED_INT_MULTIPLIER - people[AL]._imageFrame->_frame.h), flipped);
+ bool flipped = people[PLAYER]._sequenceNumber == WALK_LEFT || people[PLAYER]._sequenceNumber == STOP_LEFT ||
+ people[PLAYER]._sequenceNumber == WALK_UPLEFT || people[PLAYER]._sequenceNumber == STOP_UPLEFT ||
+ people[PLAYER]._sequenceNumber == WALK_DOWNRIGHT || people[PLAYER]._sequenceNumber == STOP_DOWNRIGHT;
+ screen._backBuffer->transBlitFrom(*people[PLAYER]._imageFrame,
+ Common::Point(tempX, people[PLAYER]._position.y / FIXED_INT_MULTIPLIER - people[PLAYER]._imageFrame->_frame.h), flipped);
}
// Draw all static and active shapes are NORMAL and are in front of the person
@@ -390,20 +390,20 @@ void ScalpelScene::doBgAnim() {
_animating = 0;
screen.slamRect(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCENE_HEIGHT));
} else {
- if (people[AL]._type != INVALID && ((_goToScene == -1 || _canimShapes.empty()))) {
- if (people[AL]._type == REMOVE) {
+ if (people[PLAYER]._type != INVALID && ((_goToScene == -1 || _canimShapes.empty()))) {
+ if (people[PLAYER]._type == REMOVE) {
screen.slamRect(Common::Rect(
- people[AL]._oldPosition.x, people[AL]._oldPosition.y,
- people[AL]._oldPosition.x + people[AL]._oldSize.x,
- people[AL]._oldPosition.y + people[AL]._oldSize.y
+ people[PLAYER]._oldPosition.x, people[PLAYER]._oldPosition.y,
+ people[PLAYER]._oldPosition.x + people[PLAYER]._oldSize.x,
+ people[PLAYER]._oldPosition.y + people[PLAYER]._oldSize.y
));
- people[AL]._type = INVALID;
+ people[PLAYER]._type = INVALID;
} else {
- screen.flushImage(people[AL]._imageFrame,
- Common::Point(people[AL]._position.x / FIXED_INT_MULTIPLIER,
- people[AL]._position.y / FIXED_INT_MULTIPLIER - people[AL].frameHeight()),
- &people[AL]._oldPosition.x, &people[AL]._oldPosition.y,
- &people[AL]._oldSize.x, &people[AL]._oldSize.y);
+ screen.flushImage(people[PLAYER]._imageFrame,
+ Common::Point(people[PLAYER]._position.x / FIXED_INT_MULTIPLIER,
+ people[PLAYER]._position.y / FIXED_INT_MULTIPLIER - people[PLAYER].frameHeight()),
+ &people[PLAYER]._oldPosition.x, &people[PLAYER]._oldPosition.y,
+ &people[PLAYER]._oldSize.x, &people[PLAYER]._oldSize.y);
}
}
@@ -525,7 +525,7 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) {
if (walkPos.x != -1) {
// Holmes must walk to the walk point before the cAnimation is started
- if (people[AL]._position != walkPos)
+ if (people[PLAYER]._position != walkPos)
people.walkToCoords(walkPos, walkDir);
}
@@ -563,7 +563,7 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) {
if (cAnim._name.size() > 0 && cAnim._type != NO_SHAPE) {
if (tpPos.x != -1)
- people[AL]._type = REMOVE;
+ people[PLAYER]._type = REMOVE;
Common::String fname = cAnim._name + ".vgs";
if (!res.isInCache(fname)) {
@@ -653,14 +653,14 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) {
cObj._frameNumber += dir;
}
- people[AL]._type = CHARACTER;
+ people[PLAYER]._type = CHARACTER;
}
// Teleport to ending coordinates if necessary
if (tpPos.x != -1) {
- people[AL]._position = tpPos; // Place the player
- people[AL]._sequenceNumber = tpDir;
- people.gotoStand(people[AL]);
+ people[PLAYER]._position = tpPos; // Place the player
+ people[PLAYER]._sequenceNumber = tpDir;
+ people.gotoStand(people[PLAYER]);
}
if (playRate < 0)
@@ -686,10 +686,10 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) {
if (tpPos.x != -1 && !talk._talkToAbort) {
// Teleport to ending coordinates
- people[AL]._position = tpPos;
- people[AL]._sequenceNumber = tpDir;
+ people[PLAYER]._position = tpPos;
+ people[PLAYER]._sequenceNumber = tpDir;
- people.gotoStand(people[AL]);
+ people.gotoStand(people[PLAYER]);
}
events.setCursor(oldCursor);
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp
index a89ebb61fc..31399b0ad9 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.cpp
+++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp
@@ -2230,9 +2230,9 @@ void ScalpelUserInterface::checkAction(ActionType &action, const char *const mes
if (!talk._talkToAbort) {
// Ensure Holmes is on the exact intended location
- people[AL]._position = pt;
- people[AL]._sequenceNumber = dir;
- people.gotoStand(people[AL]);
+ people[PLAYER]._position = pt;
+ people[PLAYER]._sequenceNumber = dir;
+ people.gotoStand(people[PLAYER]);
talk.talkTo(action._names[nameIdx].c_str() + 2);
if (ch == 'T')
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 441862c30b..b52dfc172a 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -239,8 +239,8 @@ void Scene::selectScene() {
_tempFadeStyle = 0;
}
- people._walkDest = Common::Point(people[AL]._position.x / FIXED_INT_MULTIPLIER,
- people[AL]._position.y / FIXED_INT_MULTIPLIER);
+ people._walkDest = Common::Point(people[PLAYER]._position.x / FIXED_INT_MULTIPLIER,
+ people[PLAYER]._position.y / FIXED_INT_MULTIPLIER);
_restoreFlag = true;
events.clearEvents();
@@ -1065,7 +1065,7 @@ void Scene::transitionToScene() {
Common::Point pt = c._goto;
c._goto = Common::Point(-1, -1);
- people[AL]._position = Common::Point(0, 0);
+ people[PLAYER]._position = Common::Point(0, 0);
startCAnim(cAnimNum, 1);
c._goto = pt;
@@ -1218,7 +1218,7 @@ void Scene::setNPCPath(int npc) {
void Scene::checkBgShapes() {
People &people = *_vm->_people;
- Person &holmes = people._player;
+ Person &holmes = people[PLAYER];
Common::Point pt(holmes._position.x / FIXED_INT_MULTIPLIER, holmes._position.y / FIXED_INT_MULTIPLIER);
// Iterate through the shapes
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index db4bcd8d2e..a968f9fea6 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -167,13 +167,13 @@ void Talk::talkTo(const Common::String &filename) {
// Turn on the Exit option
ui._endKeyActive = true;
- if (people[AL]._walkCount || people._walkTo.size() > 0) {
+ if (people[PLAYER]._walkCount || people._walkTo.size() > 0) {
// Only interrupt if an action if trying to do an action, and not just
// if the player is walking around the scene
if (people._allowWalkAbort)
abortFlag = true;
- people.gotoStand(people._player);
+ people.gotoStand(people[PLAYER]);
}
if (_talkToAbort)
diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp
index 61f79c471c..cc50a32b7b 100644
--- a/engines/sherlock/tattoo/tattoo_people.cpp
+++ b/engines/sherlock/tattoo/tattoo_people.cpp
@@ -28,6 +28,20 @@ namespace Sherlock {
namespace Tattoo {
+void TattooPerson::adjustSprite() {
+ // TODO
+ warning("TODO: TattooPerson::adjustSprite");
+}
+
+/*----------------------------------------------------------------*/
+
+TattooPeople::TattooPeople(SherlockEngine *vm) : People(vm) {
+ for (int idx = 0; idx < 6; ++idx)
+ _data.push_back(new TattooPerson());
+}
+
+
+
void TattooPeople::setListenSequence(int speaker, int sequenceNum) {
Scene &scene = *_vm->_scene;
@@ -45,7 +59,7 @@ void TattooPeople::setListenSequence(int speaker, int sequenceNum) {
obj.setObjTalkSequence(sequenceNum);
} else if (objNum != -1) {
objNum -= 256;
- Person &person = _data[objNum];
+ Person &person = *_data[objNum];
int newDir = person._sequenceNumber;
switch (person._sequenceNumber) {
@@ -203,8 +217,8 @@ void TattooPeople::setTalkSequence(int speaker, int sequenceNum) {
void TattooPeople::synchronize(Serializer &s) {
s.syncAsByte(_holmesOn);
- for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
- Person &p = _data[idx];
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ Person &p = *_data[idx];
s.syncAsSint32LE(p._position.x);
s.syncAsSint32LE(p._position.y);
s.syncAsSint16LE(p._sequenceNumber);
@@ -217,8 +231,8 @@ void TattooPeople::synchronize(Serializer &s) {
s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) {
- _hSavedPos = _player._position;
- _hSavedFacing = _player._sequenceNumber;
+ _hSavedPos = _data[PLAYER]->_position;
+ _hSavedFacing = _data[PLAYER]->_sequenceNumber;
}
}
diff --git a/engines/sherlock/tattoo/tattoo_people.h b/engines/sherlock/tattoo/tattoo_people.h
index e4216d080e..455b9489e4 100644
--- a/engines/sherlock/tattoo/tattoo_people.h
+++ b/engines/sherlock/tattoo/tattoo_people.h
@@ -71,9 +71,20 @@ enum TattooSequences {
LISTEN_UPLEFT = 27
};
+class TattooPerson: public Person {
+public:
+ TattooPerson() : Person() {}
+ virtual ~TattooPerson() {}
+
+ /**
+ * This adjusts the sprites position, as well as it's animation sequence:
+ */
+ virtual void adjustSprite();
+};
+
class TattooPeople : public People {
public:
- TattooPeople(SherlockEngine *vm) : People(vm) {}
+ TattooPeople(SherlockEngine *vm);
virtual ~TattooPeople() {}
/**
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index fa37f67f66..20b690f016 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -572,7 +572,7 @@ void TattooScene::updateBackground() {
screen._flushScreen = true;
- for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
+ for (uint idx = 0; idx < MAX_CHARACTERS; ++idx) {
Person &p = people[idx];
if (p._type != INVALID) {