[Scummvm-cvs-logs] SF.net SVN: scummvm:[51461] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Thu Jul 29 13:04:54 CEST 2010


Revision: 51461
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51461&view=rev
Author:   dreammaster
Date:     2010-07-29 11:04:54 +0000 (Thu, 29 Jul 2010)

Log Message:
-----------
M4: Further work done on the setup and starting of actions

Modified Paths:
--------------
    scummvm/trunk/engines/m4/mads_logic.cpp
    scummvm/trunk/engines/m4/mads_logic.h
    scummvm/trunk/engines/m4/mads_player.cpp
    scummvm/trunk/engines/m4/mads_scene.cpp
    scummvm/trunk/engines/m4/mads_scene.h
    scummvm/trunk/engines/m4/mads_views.cpp
    scummvm/trunk/engines/m4/mads_views.h
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/scene.h

Modified: scummvm/trunk/engines/m4/mads_logic.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_logic.cpp	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_logic.cpp	2010-07-29 11:04:54 UTC (rev 51461)
@@ -425,7 +425,7 @@
 	warning("Still to do actions logic");
 }
 
-void MadsSceneLogic::sceneStep() {
+void MadsSceneLogic::doSceneStep() {
 	// TODO: Sound handling
 	
 	switch (_madsVm->scene()->_abortTimers) {

Modified: scummvm/trunk/engines/m4/mads_logic.h
===================================================================
--- scummvm/trunk/engines/m4/mads_logic.h	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_logic.h	2010-07-29 11:04:54 UTC (rev 51461)
@@ -61,7 +61,7 @@
 	void enterScene();
 	void doPreactions();
 	void doAction();
-	void sceneStep();
+	void doSceneStep();
 };
 
 class MadsGameLogic {

Modified: scummvm/trunk/engines/m4/mads_player.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_player.cpp	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_player.cpp	2010-07-29 11:04:54 UTC (rev 51461)
@@ -591,6 +591,8 @@
 	_destFacing = 5;
 	_newDirection = _direction;
 
+	_madsVm->scene()->_action._startWalkFlag = false;
+	_madsVm->scene()->_action._walkFlag = false;
 	_moving = false;
 	_v844BC = false;
 	_v844C0 = false;

Modified: scummvm/trunk/engines/m4/mads_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.cpp	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_scene.cpp	2010-07-29 11:04:54 UTC (rev 51461)
@@ -252,9 +252,12 @@
 }
 
 void MadsScene::leftClick(int x, int y) {
-	// **DEBUG** - being used for movement testing
-	_madsVm->_player.moveComplete();
-	_madsVm->_player.setDest(x, y, 2);
+	// TODO: figure out the rest of Scene_leftClick, and implements relevant parts in the interface class
+	_action._v86F4C = -1;
+	_action._v86F4E = 0;
+	_customDest = _madsVm->_mouse->currentPos();
+	_action._selectedAction = -1;
+	_action._v86F4A = true;
 }
 
 void MadsScene::rightClick(int x, int y) {
@@ -308,62 +311,74 @@
 }
 
 void MadsScene::updateState() {
-	if ((_action._selectedAction != 0) || !_madsVm->_player._stepEnabled)
-		_action.clear();
-
 	if (!_abortTimers && !_madsVm->_player._unk3) {
 		if (_dynamicHotspots._changed)
 			_dynamicHotspots.refresh();
 
-//		int v = (_madsVm->_player._stepEnabled && !_action._verbNounFlag && !_abortTimers2) ? 1 : 0;
+//		int v = (_madsVm->_player._stepEnabled && !_action._startWalkFlag && !_abortTimers2) ? 1 : 0;
 //		_screenObjects.check(v, false);
 	}
 
 	// Handle starting off any selected action
-	bool lookFlag = false;
+	bool doPreAction = false;
 	if ((_action._selectedAction != 0) && _madsVm->_player._stepEnabled &&
-			!_action._verbNounFlag && !_abortTimers && !_madsVm->_player._unk3) {
+			!_action._startWalkFlag && !_abortTimers && !_madsVm->_player._unk3) {
 		// Start the action
 		_action.startAction();
 
-		lookFlag = (_action._action.verbId == kVerbLookAt) || (_action._action.verbId == kVerbLook);
+		if (_action._action.verbId == kVerbLookAt) {
+			_action._action.verbId = kVerbLook;
+			_action._savedFields.selectedRow = 0;
+		}
+		doPreAction = true;
 	}
-	if (lookFlag || ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_2)))
+	if (doPreAction || ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_2)))
 		doPreactions();
 
 	checkStartWalk();
 
-	// Update the player
-	_madsVm->_player.update();
+	if (_action._inProgress && !_madsVm->_player._moving && !_action._startWalkFlag &&
+		(_madsVm->_player._newDirection == _madsVm->_player._direction)) {
+		// Reached the end of action movement, so ready to actually do action
+			doAction();
+	} else if ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_0))
+		// Do an action designated by scripts
+		doAction();
 
-	// Handle refreshing the mouse position display
-	if (_mouseMsgIndex != -1)
-		_madsVm->scene()->_kernelMessages.remove(_mouseMsgIndex);
-	if (_showMousePos) {
-		char buffer[20];
-		sprintf(buffer, "(%d,%d)", _madsVm->_mouse->currentPos().x, _madsVm->_mouse->currentPos().y);
+	bool freeFlag = false;
+	if (_currentScene != _nextScene)
+		freeFlag = true;
+	else {
+		doSceneStep();
 
-		_mouseMsgIndex = _madsVm->scene()->_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, buffer);
+		if (_currentScene != _nextScene)
+			freeFlag = true;
+		else {
+			// Update the player
+			_madsVm->_player.nextFrame();
+
+			// Handle updating the animation
+			if (!_abortTimers && (_activeAnimation))
+				_activeAnimation->update();
+
+			// Handle refreshing the mouse position display
+			if (_mouseMsgIndex != -1)
+				_madsVm->scene()->_kernelMessages.remove(_mouseMsgIndex);
+			if (_showMousePos) {
+				char buffer[20];
+				sprintf(buffer, "(%d,%d)", _madsVm->_mouse->currentPos().x, _madsVm->_mouse->currentPos().y);
+
+				_mouseMsgIndex = _madsVm->scene()->_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, buffer);
+			}
+		}
 	}
 
 	if (_madsVm->globals()->_config.easyMouse)
 		_action.refresh();
-
-	// Step through the scene
-	_sceneLogic.sceneStep();
-
-	_madsVm->_player.step();
-	_madsVm->_player._unk3 = 0;
-
-	if (_abortTimersMode == ABORTMODE_1)
-		_abortTimers = 0;
-
-	// Handle updating the player frame
-	_madsVm->_player.nextFrame();
 	
 	if ((_activeAnimation) && !_abortTimers) {
 		_activeAnimation->update();
-		if (((MadsAnimation *) _activeAnimation)->freeFlag()) {
+		if (((MadsAnimation *) _activeAnimation)->freeFlag() || freeFlag) {
 			delete _activeAnimation;
 			_activeAnimation = NULL;
 		}
@@ -374,12 +389,17 @@
 	// Remove the animation if it's been completed
 	if ((_activeAnimation) && ((MadsAnimation *)_activeAnimation)->freeFlag())
 		freeAnimation();
+
+	if ((_action._selectedAction != 0) || !_madsVm->_player._stepEnabled) {
+		_action.clear();
+		_action._selectedAction = 0;
+	}
 }
 
 void MadsScene::checkStartWalk() {
-	if (_action._verbNounFlag && _action._walkFlag) {
+	if (_action._startWalkFlag && _action._walkFlag) {
 		_madsVm->_player.setDest(_destPos.x, _destPos.y, _destFacing);
-		_action._verbNounFlag = false;
+		_action._startWalkFlag = false;
 	}
 }
 
@@ -395,6 +415,22 @@
 	}
 }
 
+void MadsScene::doSceneStep() {
+	// Step through the scene
+	_sceneLogic.doSceneStep();
+
+	_madsVm->_player.step();
+	_madsVm->_player._unk3 = 0;
+
+	if (_abortTimersMode == ABORTMODE_1)
+		_abortTimers = 0;
+}
+
+void MadsScene::doAction() {
+	warning("TODO MadsScene::doAction");
+}
+
+
 /**
  * Does extra work at cleaning up the animation, and then deletes it
  */

Modified: scummvm/trunk/engines/m4/mads_scene.h
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.h	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_scene.h	2010-07-29 11:04:54 UTC (rev 51461)
@@ -100,11 +100,14 @@
 	void setAction();
 	void checkStartWalk();
 	void doPreactions();
+	void doSceneStep();
+	void doAction();
 public:
 	char _aaName[100];
 	bool _showMousePos;
 	Common::Point _destPos;
 	int _destFacing;
+	Common::Point _customDest;
 public:
 	MadsScene(MadsEngine *vm);
 	virtual ~MadsScene();

Modified: scummvm/trunk/engines/m4/mads_views.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_views.cpp	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_views.cpp	2010-07-29 11:04:54 UTC (rev 51461)
@@ -40,9 +40,10 @@
 MadsAction::MadsAction(MadsView &owner): _owner(owner) {
 	clear();
 	_currentAction = kVerbNone;
-	_verbNounFlag = false;
+	_startWalkFlag = false;
 	_statusTextIndex = -1;
 	_selectedAction = 0;
+	_inProgress = false;
 }
 
 void MadsAction::clear() {
@@ -256,7 +257,7 @@
 void MadsAction::startAction() {
 	_madsVm->_player.moveComplete();
 
-	_v84538 = -1;
+	_inProgress = true;
 	_v8453A = 0;
 	_savedFields.selectedRow = _selectedRow;
 	_savedFields.articleNumber = _articleNumber;
@@ -274,7 +275,7 @@
 	if ((_savedFields.actionMode2 == ACTMODE2_4) && (savedV86F42 == 0))
 		_v8453A = true;
 
-	_verbNounFlag = false;
+	_startWalkFlag = false;
 	int hotspotId = -1;
 	HotSpotList &dynHotspots = *_madsVm->scene()->getSceneResources().dynamicHotspots;
 	HotSpotList &hotspots = *_madsVm->scene()->getSceneResources().hotspots;
@@ -289,11 +290,11 @@
 			HotSpot &hs = dynHotspots[hotspotId - hotspots.size()];
 			if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
 				if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
-					_verbNounFlag = true;
-					_madsVm->scene()->_destPos = _customDest;
+					_startWalkFlag = true;
+					_madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
 				}
 			} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
-				_verbNounFlag = true;
+				_startWalkFlag = true;
 				_madsVm->scene()->_destPos.x = hs.getFeetX();
 				_madsVm->scene()->_destPos.y = hs.getFeetY();
 			}
@@ -306,21 +307,23 @@
 		HotSpot &hs = hotspots[hotspotId];
 		if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
 			if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
-				_verbNounFlag = true;
-				_madsVm->scene()->_destPos = _customDest;
+				_startWalkFlag = true;
+				_madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
 			}
 		} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
-			_verbNounFlag = true;
+			_startWalkFlag = true;
 			_madsVm->scene()->_destPos.x = hs.getFeetX();
 			_madsVm->scene()->_destPos.y = hs.getFeetY();
 		}
 		_madsVm->scene()->_destFacing = hs.getFacing();
 	}
+
+	_walkFlag = _startWalkFlag;
 }
 
 void MadsAction::checkAction() {
 	if (isAction(kVerbLookAt) || isAction(kVerbThrow))
-		_verbNounFlag = 0;
+		_startWalkFlag = 0;
 }
 
 bool MadsAction::isAction(int verbId, int objectNameId, int indirectObjectId) {

Modified: scummvm/trunk/engines/m4/mads_views.h
===================================================================
--- scummvm/trunk/engines/m4/mads_views.h	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/mads_views.h	2010-07-29 11:04:54 UTC (rev 51461)
@@ -71,12 +71,11 @@
 	int _selectedRow;
 	bool _textChanged;
 	int _selectedAction;
-	bool _verbNounFlag;
+	bool _startWalkFlag;
 	int _statusTextIndex;
 	int _hotspotId;
 	MadsActionSavedFields _savedFields;
 	bool _walkFlag;
-	Common::Point _customDest;
 
 	// Unknown fields
 	int16 _v86F3A;
@@ -85,7 +84,7 @@
 	bool _v86F4A;
 	int16 _v86F4C;
 	int _v83338;
-	int _v84538;
+	bool _inProgress;
 	bool _v8453A;
 
 public:

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/scene.cpp	2010-07-29 11:04:54 UTC (rev 51461)
@@ -61,6 +61,7 @@
 void Scene::loadScene(int sceneNumber) {
 	_previousScene = _currentScene;
 	_currentScene = sceneNumber;
+	_nextScene = sceneNumber;
 }
 
 void Scene::leaveScene() {

Modified: scummvm/trunk/engines/m4/scene.h
===================================================================
--- scummvm/trunk/engines/m4/scene.h	2010-07-29 10:58:01 UTC (rev 51460)
+++ scummvm/trunk/engines/m4/scene.h	2010-07-29 11:04:54 UTC (rev 51461)
@@ -79,6 +79,7 @@
 protected:
 	int _currentScene;
 	int _previousScene;
+	int _nextScene;
 	GameInterfaceView *_interfaceSurface;
 	M4Surface *_backgroundSurface;
 	M4Surface *_walkSurface;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list