[Scummvm-cvs-logs] scummvm master -> d314257968837f6c1e26a8465e91cc263017e4bf

dreammaster dreammaster at scummvm.org
Sat Jun 13 21:49:48 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d314257968 SHERLOCK: Simplify UseType to derive from ActionType


Commit: d314257968837f6c1e26a8465e91cc263017e4bf
    https://github.com/scummvm/scummvm/commit/d314257968837f6c1e26a8465e91cc263017e4bf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-06-13T15:48:02-04:00

Commit Message:
SHERLOCK: Simplify UseType to derive from ActionType

Changed paths:
    engines/sherlock/objects.cpp
    engines/sherlock/objects.h
    engines/sherlock/scalpel/scalpel_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h
    engines/sherlock/user_interface.cpp
    engines/sherlock/user_interface.h



diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index 9005235..0409295 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -533,6 +533,10 @@ WalkSequences &WalkSequences::operator=(const WalkSequences &src) {
 
 /*----------------------------------------------------------------*/
 
+ActionType::ActionType() {
+	_cAnimNum = _cAnimSpeed = 0;
+}
+
 void ActionType::load(Common::SeekableReadStream &s) {
 	char buffer[12];
 
@@ -549,8 +553,7 @@ void ActionType::load(Common::SeekableReadStream &s) {
 
 /*----------------------------------------------------------------*/
 
-UseType::UseType() {
-	_cAnimNum = _cAnimSpeed = 0;
+UseType::UseType(): ActionType() {
 	_useFlag = 0;
 }
 
@@ -562,15 +565,7 @@ void UseType::load(Common::SeekableReadStream &s, bool isRoseTattoo) {
 		_verb = Common::String(buffer);
 	}
 
-	_cAnimNum = s.readByte();
-	_cAnimSpeed = s.readByte();
-	if (_cAnimSpeed & 0x80)
-		_cAnimSpeed = -(_cAnimSpeed & 0x7f);
-
-	for (int idx = 0; idx < NAMES_COUNT; ++idx) {
-		s.read(buffer, 12);
-		_names[idx] = Common::String(buffer);
-	}
+	ActionType::load(s);
 
 	_useFlag = s.readSint16LE();
 
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index 6a71166..a219484 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -144,16 +144,15 @@ struct ActionType {
 	int _cAnimSpeed;
 	Common::String _names[NAMES_COUNT];
 
+	ActionType();
+
 	/**
 	 * Load the data for the action
 	 */
 	void load(Common::SeekableReadStream &s);
 };
 
-struct UseType {
-	int _cAnimNum;
-	int _cAnimSpeed;
-	Common::String _names[NAMES_COUNT];
+struct UseType: public ActionType {
 	int _useFlag;					// Which flag USE will set (if any)
 	Common::String _target;
 	Common::String _verb;
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp
index 302e958..3345ef4 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.cpp
+++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp
@@ -1419,7 +1419,7 @@ void ScalpelUserInterface::doMiscControl(int allowed) {
 
 				switch (allowed) {
 				case ALLOW_OPEN:
-					checkAction(obj._aOpen, MOPEN, _temp);
+					checkAction(obj._aOpen, _temp, MOPEN);
 					if (_menuMode != TALK_MODE && !talk._talkToAbort) {
 						_menuMode = STD_MODE;
 						restoreButton(OPEN_MODE - 1);
@@ -1428,7 +1428,7 @@ void ScalpelUserInterface::doMiscControl(int allowed) {
 					break;
 
 				case ALLOW_CLOSE:
-					checkAction(obj._aClose, MCLOSE, _temp);
+					checkAction(obj._aClose, _temp, MCLOSE);
 					if (_menuMode != TALK_MODE && !talk._talkToAbort) {
 						_menuMode = STD_MODE;
 						restoreButton(CLOSE_MODE - 1);
@@ -1437,7 +1437,7 @@ void ScalpelUserInterface::doMiscControl(int allowed) {
 					break;
 
 				case ALLOW_MOVE:
-					checkAction(obj._aMove, MMOVE, _temp);
+					checkAction(obj._aMove, _temp, MMOVE);
 					if (_menuMode != TALK_MODE && !talk._talkToAbort) {
 						_menuMode = STD_MODE;
 						restoreButton(MOVE_MODE - 1);
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index ef56e59..644b20a 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -182,11 +182,6 @@ public:
 	 * Draw the user interface onto the screen's back buffers
 	 */	
 	virtual void drawInterface(int bufferNum = 3);
-
-
-	void checkAction(UseType &use, int objNum) {
-		// TODO: Get rid of this stub, and properly use the UserInterface method
-	}
 };
 
 } // End of namespace Tattoo
diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp
index 8ab26ac..ba94d53 100644
--- a/engines/sherlock/user_interface.cpp
+++ b/engines/sherlock/user_interface.cpp
@@ -54,7 +54,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
 }
 
 
-void UserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) {
+void UserInterface::checkAction(ActionType &action, int objNum, const char *const messages[]) {
 	Events &events = *_vm->_events;
 	People &people = *_vm->_people;
 	Scene &scene = *_vm->_scene;
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index b416fd4..1692ff7 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -64,7 +64,7 @@ protected:
 	/**
 	 * Called for OPEN, CLOSE, and MOVE actions are being done
 	 */
-	void checkAction(ActionType &action, const char *const messages[], int objNum);
+	void checkAction(ActionType &action, int objNum, const char *const messages[] = nullptr);
 public:
 	MenuMode _menuMode;
 	int _menuCounter;






More information about the Scummvm-git-logs mailing list