From 0aebac9174f935e535b8e133efde43bd94be5b27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 May 2015 23:23:37 +0200 Subject: SHERLOCK: Fix some issues pointed by LordHoto --- engines/sherlock/objects.h | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 4068973e58..7a1ef1aebe 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -164,6 +164,7 @@ struct UseType { void load(Common::SeekableReadStream &s); }; +enum { TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 }; class Object { private: static SherlockEngine *_vm; -- cgit v1.2.3 From 46293735c4e10d654d6195fce7781782f1024b26 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 18:52:20 -0400 Subject: SHERLOCK: Remove some redundant fields from UseType --- engines/sherlock/objects.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 7a1ef1aebe..4e7b006844 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -156,8 +156,6 @@ struct UseType { int _cAnimSpeed; Common::String _names[4]; int _useFlag; // Which flag USE will set (if any) - int _dFlag[1]; - int _lFlag[2]; Common::String _target; UseType(); -- cgit v1.2.3 From 59993fdc74afad7b210da7849f8ce25631153201 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 19:15:17 -0400 Subject: SHERLOCK: Replace magic numbers with enums and constants --- engines/sherlock/objects.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 4e7b006844..0b3a26f1f9 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -142,11 +142,12 @@ public: }; enum { REVERSE_DIRECTION = 0x80 }; +#define NAMES_COUNT 4 struct ActionType { int _cAnimNum; int _cAnimSpeed; - Common::String _names[4]; + Common::String _names[NAMES_COUNT]; void load(Common::SeekableReadStream &s); }; @@ -154,7 +155,7 @@ struct ActionType { struct UseType { int _cAnimNum; int _cAnimSpeed; - Common::String _names[4]; + Common::String _names[NAMES_COUNT]; int _useFlag; // Which flag USE will set (if any) Common::String _target; @@ -163,6 +164,8 @@ struct UseType { }; enum { TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 }; +#define USE_COUNT 4 + class Object { private: static SherlockEngine *_vm; @@ -217,7 +220,7 @@ public: int _seqCounter2; // Counter of calling frame sequence uint _seqSize; // Tells where description starts ActionType _aMove; - UseType _use[4]; + UseType _use[USE_COUNT]; Object(); -- cgit v1.2.3 From 7c3ac25ac153a2934ee94c8aa83b72843bd56351 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 23:44:59 -0400 Subject: SHERLOCK: Further syntactic fixes --- engines/sherlock/objects.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 0b3a26f1f9..e3e07d89b7 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -102,8 +102,8 @@ class Sprite { private: static SherlockEngine *_vm; public: - Common::String _name; // Name - Common::String _description; // Description + Common::String _name; + Common::String _description; Common::StringArray _examine; // Examine in-depth description Common::String _pickUp; // Message for if you can't pick up object -- cgit v1.2.3 From 1df183ffcb08a69ed414afd69284a0596fee4e82 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 07:37:55 -0400 Subject: SHERLOCK: Move method comments from cpp to headers --- engines/sherlock/objects.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index e3e07d89b7..53752a7351 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -129,15 +129,34 @@ public: Sprite() { clear(); } static void setVm(SherlockEngine *vm) { _vm = vm; } + /** + * Reset the data for the sprite + */ void clear(); + /** + * Updates the image frame poiner for the sprite + */ 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(); + /** + * Return frame width + */ int frameWidth() const { return _imageFrame ? _imageFrame->_frame.w : 0; } + + /** + * Return frame height + */ int frameHeight() const { return _imageFrame ? _imageFrame->_frame.h : 0; } }; @@ -149,6 +168,9 @@ struct ActionType { int _cAnimSpeed; Common::String _names[NAMES_COUNT]; + /** + * Load the data for the action + */ void load(Common::SeekableReadStream &s); }; @@ -160,6 +182,10 @@ struct UseType { Common::String _target; UseType(); + + /** + * Load the data for the UseType + */ void load(Common::SeekableReadStream &s); }; @@ -170,8 +196,17 @@ class Object { private: static SherlockEngine *_vm; + /** + * This will check to see if the object has reached the end of a sequence. + * If it has, it switch to whichever next sequence should be started. + * @returns true if the end of a sequence was reached + */ bool checkEndOfSequence(); + /** + * Scans through the sequences array and finds the designated sequence. + * It then sets the frame number of the start of that sequence + */ void setObjSequence(int seq, bool wait); public: static bool _countCAnimFrames; @@ -224,24 +259,69 @@ public: Object(); + /** + * Load the data for the object + */ void load(Common::SeekableReadStream &s); + /** + * Toggle the type of an object between hidden and active + */ void toggleHidden(); + /** + * Check the state of the object + */ void checkObject(); + /** + * Checks for codes + * @param name The name to check for codes + * @param messages Provides a lookup list of messages that can be printed + * @returns 0 if no codes are found, 1 if codes were found + */ int checkNameForCodes(const Common::String &name, const char *const messages[]); + /** + * Handle setting any flags associated with the object + */ void setFlagsAndToggles(); + /** + * Adjusts the sprite's position and animation sequence, advancing by 1 frame. + * If the end of the sequence is reached, the appropriate action is taken. + */ void adjustObject(); + /** + * Handles trying to pick up an object. If allowed, plays an y necessary animation for picking + * up the item, and then adds it to the player's inventory + */ int pickUpObject(const char *const messages[]); + /** + * Return the frame width + */ int frameWidth() const { return _imageFrame ? _imageFrame->_frame.w : 0; } + + /** + * Return the frame height + */ int frameHeight() const { return _imageFrame ? _imageFrame->_frame.h : 0; } + + /** + * Returns the current bounds for the sprite + */ const Common::Rect getNewBounds() const; + + /** + * Returns the bounds for a sprite without a shape + */ const Common::Rect getNoShapeBounds() const; + + /** + * Returns the old bounsd for the sprite from the previous frame + */ const Common::Rect getOldBounds() const; }; @@ -257,6 +337,9 @@ struct CAnim { Common::Point _teleportPos; // Location Holmes shoul teleport to after int _teleportDir; // playing canim + /** + * Load the data for the animation + */ void load(Common::SeekableReadStream &s); }; -- cgit v1.2.3 From 1c395b4de91f3edb0ad7109da016eb42a32b434b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 08:13:46 -0400 Subject: SHERLOCK: Add extra constants for object bit-flags --- engines/sherlock/objects.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 53752a7351..6dbe645d4b 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -189,7 +189,7 @@ struct UseType { void load(Common::SeekableReadStream &s); }; -enum { TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 }; +enum { OBJ_BEHIND = 1, OBJ_FLIPPED = 2, OBJ_FORWARD = 4, TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 }; #define USE_COUNT 4 class Object { -- cgit v1.2.3 From 9a58e485bfeb97c2a282f809386350e697790db5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 22 May 2015 19:52:00 +0200 Subject: SHERLOCK: Fix some uninitialized values and unused variables --- engines/sherlock/objects.h | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/sherlock/objects.h') diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 6dbe645d4b..bbd068eef7 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -120,7 +120,6 @@ public: Common::Point _oldSize; // Image's old size Common::Point _goto; // Walk destination SpriteType _type; // Type of object - int _pickup; Common::Point _noShapeSize; // Size of a NO_SHAPE int _status; // Status: open/closed, moved/not moved int8 _misc; // Miscellaneous use -- cgit v1.2.3