diff options
| author | Paul Gilbert | 2014-03-02 20:06:21 -0500 | 
|---|---|---|
| committer | Paul Gilbert | 2014-03-02 20:06:21 -0500 | 
| commit | 72163a233f980a385c432fbf66fd6bb21f6acdf2 (patch) | |
| tree | cafcc533c1162425f8741bef6ccf38ebf6275c07 | |
| parent | b816b9990d98633794f42ba49aeb971d6f9d930b (diff) | |
| download | scummvm-rg350-72163a233f980a385c432fbf66fd6bb21f6acdf2.tar.gz scummvm-rg350-72163a233f980a385c432fbf66fd6bb21f6acdf2.tar.bz2 scummvm-rg350-72163a233f980a385c432fbf66fd6bb21f6acdf2.zip | |
MADS: Moved Player class into it's own file
| -rw-r--r-- | engines/mads/action.cpp | 18 | ||||
| -rw-r--r-- | engines/mads/action.h | 19 | ||||
| -rw-r--r-- | engines/mads/game.cpp | 9 | ||||
| -rw-r--r-- | engines/mads/game.h | 3 | ||||
| -rw-r--r-- | engines/mads/game_data.cpp | 11 | ||||
| -rw-r--r-- | engines/mads/game_data.h | 18 | ||||
| -rw-r--r-- | engines/mads/module.mk | 1 | ||||
| -rw-r--r-- | engines/mads/player.cpp | 69 | ||||
| -rw-r--r-- | engines/mads/player.h | 69 | ||||
| -rw-r--r-- | engines/mads/scene.cpp | 2 | ||||
| -rw-r--r-- | engines/mads/scene.h | 1 | 
11 files changed, 169 insertions, 51 deletions
| diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp index d27bd85a45..ce2cf6aba8 100644 --- a/engines/mads/action.cpp +++ b/engines/mads/action.cpp @@ -21,12 +21,13 @@   */  #include "common/scummsys.h" +#include "mads/mads.h"  #include "mads/action.h"  #include "mads/scene.h"  namespace MADS { -MadsAction::MadsAction(Scene *scene) : _scene(scene) { +MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {  	clear();  	_currentAction = VERB_NONE;  	_startWalkFlag = false; @@ -35,7 +36,7 @@ MadsAction::MadsAction(Scene *scene) : _scene(scene) {  	_inProgress = false;  } -void MadsAction::clear() { +void MADSAction::clear() {  	_v83338 = 1;  	_actionMode = ACTMODE_NONE;  	_actionMode2 = ACTMODE2_0; @@ -44,7 +45,6 @@ void MadsAction::clear() {  	_articleNumber = 0;  	_lookFlag = false;  	_v86F4A = 0; -	_statusText[0] = '\0';  	_selectedRow = -1;  	_hotspotId = -1;  	_v86F3A = -1; @@ -56,7 +56,7 @@ void MadsAction::clear() {  	_walkFlag = false;  } -void MadsAction::appendVocab(int vocabId, bool capitalise) { +void MADSAction::appendVocab(int vocabId, bool capitalise) {  	/*  	char *s = _statusText + strlen(_statusText);  	vocabStr = _madsVm->globals()->getVocab(vocabId); @@ -68,7 +68,7 @@ void MadsAction::appendVocab(int vocabId, bool capitalise) {  	*/  } -void MadsAction::set() { +void MADSAction::set() {  	/*  	int hotspotCount = _madsVm->scene()->getSceneResources().hotspots->size();  	bool flag = false; // FIXME: unused @@ -212,7 +212,7 @@ void MadsAction::set() {  	*/  } -void MadsAction::refresh() { +void MADSAction::refresh() {  	/*  	// Exit immediately if nothing has changed  	if (!_textChanged) @@ -249,7 +249,7 @@ void MadsAction::refresh() {  	*/  } -void MadsAction::startAction() { +void MADSAction::startAction() {  	/*  	_madsVm->_player.moveComplete(); @@ -318,14 +318,14 @@ void MadsAction::startAction() {  	*/  } -void MadsAction::checkAction() { +void MADSAction::checkAction() {  	/*  	if (isAction(kVerbLookAt) || isAction(kVerbThrow))  		_startWalkFlag = 0;  	*/  } -bool MadsAction::isAction(int verbId, int objectNameId, int indirectObjectId) { +bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {  	/*  	if (_activeAction.verbId != verbId)  		return false; diff --git a/engines/mads/action.h b/engines/mads/action.h index a29d43baa0..c38b842992 100644 --- a/engines/mads/action.h +++ b/engines/mads/action.h @@ -24,6 +24,7 @@  #define MADS_ACTION_H  #include "common/scummsys.h" +#include "common/str.h"  namespace MADS { @@ -46,7 +47,7 @@ enum {  	VERB_WALKTO = 13  }; -class Scene; +class MADSEngine;  struct ActionDetails {  	int verbId; @@ -54,7 +55,7 @@ struct ActionDetails {  	int indirectObjectId;  }; -struct MadsActionSavedFields { +struct MADSActionSavedFields {  	int articleNumber;  	int actionMode;  	int actionMode2; @@ -62,11 +63,11 @@ struct MadsActionSavedFields {  	int selectedRow;  }; -class MadsAction { +class MADSAction {  private: -	Scene *_scene; -	char _statusText[100]; -	char _dialogTitle[100]; +	MADSEngine *_vm; +	Common::String _statusText; +	Common::String _dialogTitle;  	void appendVocab(int vocabId, bool capitalise = false);  public: @@ -83,7 +84,7 @@ public:  	bool _startWalkFlag;  	int _statusTextIndex;  	int _hotspotId; -	MadsActionSavedFields _savedFields; +	MADSActionSavedFields _savedFields;  	bool _walkFlag;  	// Unknown fields @@ -97,11 +98,11 @@ public:  	AbortTimerMode _v8453A;  public: -	MadsAction(Scene *scene); +	MADSAction(MADSEngine *vm);  	void clear();  	void set(); -	const char *statusText() const { return _statusText; } +	const Common::String &statusText() const { return _statusText; }  	void refresh();  	void startAction();  	void checkAction(); diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index a3351f5a7b..2fa701093e 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -39,8 +39,8 @@ Game *Game::init(MADSEngine *vm) {  	return nullptr;  } -Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), -		_objects(vm), _scene(vm) { +Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),  +		_scene(vm), _player(vm) {  	_sectionNumber = _priorSectionNumber = 0;  	_difficultyLevel = DIFFICULTY_HARD;  	_saveSlot = -1; @@ -176,6 +176,11 @@ void Game::sectionLoop() {  		_scene._v1C = -1;  		_objectHiliteVocabIdx = -1; +		_scene._action.clear(); +		_player.turnToDestFacing(); +		_player._direction = _player._newDirection; +		_player.moveComplete(); +  		// TODO: main section loop logic goes here  		// Clear the scene diff --git a/engines/mads/game.h b/engines/mads/game.h index 562e0b99d0..88c5bebf63 100644 --- a/engines/mads/game.h +++ b/engines/mads/game.h @@ -26,6 +26,7 @@  #include "common/scummsys.h"  #include "mads/scene.h"  #include "mads/game_data.h" +#include "mads/player.h"  namespace MADS { @@ -62,7 +63,6 @@ protected:  	byte *_quotes;  	int _v1;  	int _v3; -	int _v4;  	int _v5;  	int _v6;  	Common::String _aaName; @@ -110,6 +110,7 @@ public:  	InventoryObjects _objects;  	Scene _scene;  	int _v2; +	int _v4;  public:  	virtual ~Game(); diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp index e39b85c9ae..ba24ed9ca1 100644 --- a/engines/mads/game_data.cpp +++ b/engines/mads/game_data.cpp @@ -102,15 +102,4 @@ void InventoryObjects::setRoom(int objectId, int roomNumber) {  	warning("TODO: setObjectRoom");  } -/*------------------------------------------------------------------------*/ - -Player::Player() { -	_direction = 8; -	_newDirection = 8; -	_spritesLoaded = false; -	_spritesStart = _numSprites = 0; -	_stepEnabled = false; -	_visible = false; -} -  } // End of namespace MADS diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h index 2d2badd38b..56ab3665e3 100644 --- a/engines/mads/game_data.h +++ b/engines/mads/game_data.h @@ -91,24 +91,6 @@ public:  	void setRoom(int objectId, int roomNumber);  }; -class Player { -public: -	int _direction; -	int _newDirection; -	bool _spritesLoaded; -	int _spritesStart; -	int _numSprites; -	bool _stepEnabled; -	bool _spritesChanged; -	bool _visible; -public: -	Player(); - -	void loadSprites(const Common::String &prefix) { -		warning("TODO: Player::loadSprites"); -	} -}; -  class SectionHandler {  protected:  	MADSEngine *_vm; diff --git a/engines/mads/module.mk b/engines/mads/module.mk index f27b808099..f715e1a4da 100644 --- a/engines/mads/module.mk +++ b/engines/mads/module.mk @@ -22,6 +22,7 @@ MODULE_OBJS := \  	msprite.o \  	msurface.o \  	palette.o \ +	player.o \  	resources.o \  	scene.o \  	scene_data.o \ diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp new file mode 100644 index 0000000000..d88feea0d8 --- /dev/null +++ b/engines/mads/player.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "mads/mads.h" +#include "mads/player.h" + +namespace MADS { + +Player::Player(MADSEngine *vm): _vm(vm) { +	_action = nullptr; +	_direction = 8; +	_newDirection = 8; +	_destFacing = 0; +	_spritesLoaded = false; +	_spritesStart = _numSprites = 0; +	_stepEnabled = false; +	_visible = false; +} + +void Player::reset() { +	_action = &_vm->_game->_scene._action; +	_destPos = _playerPos; +	_destFacing = 5; +	_newDirection = _direction; +	_moving = false; +	_v844C0 = _v844BE = 0; +	_next = 0; +	_routeCount = 0; + +	_vm->_game->_v4 = 0; +	_action->_startWalkFlag = false; +	_action->_walkFlag = false; +} + +void Player::loadSprites(const Common::String &prefix) { +	warning("TODO: Player::loadSprites"); +} + +void Player::turnToDestFacing() { +	if (_destFacing != 5) +		_newDirection = _destFacing; +} + +void Player::moveComplete() { +	reset(); +	_action->_inProgress = false; +} + +} // End of namespace MADS diff --git a/engines/mads/player.h b/engines/mads/player.h new file mode 100644 index 0000000000..0466f7aeee --- /dev/null +++ b/engines/mads/player.h @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef MADS_PLAYER_H +#define MADS_PLAYER_H + +#include "common/scummsys.h" +#include "common/str.h" + +namespace MADS { + +class MADSEngine; +class Action; + +class Player { +private: +	MADSEngine *_vm; +	MADSAction *_action; + +	void reset(); +public: +	int _direction; +	int _newDirection; +	int _destFacing; +	bool _spritesLoaded; +	int _spritesStart; +	int _numSprites; +	bool _stepEnabled; +	bool _spritesChanged; +	bool _visible; +	Common::Point _playerPos; +	Common::Point _destPos; +	bool _moving; +	int _v844C0, _v844BE; +	int _next; +	int _routeCount; + +public: +	Player(MADSEngine *vm); + +	void loadSprites(const Common::String &prefix); + +	void turnToDestFacing(); + +	void moveComplete(); +}; + +} // End of namespace MADS + +#endif /* MADS_PLAYER_H */ diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 90f5cbd0cf..2f12139246 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,7 +28,7 @@  namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) { +Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) {  	_priorSceneId = 0;  	_nextSceneId = 0;  	_currentSceneId = 0; diff --git a/engines/mads/scene.h b/engines/mads/scene.h index bafe499d09..d3a6aeeb6d 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -97,6 +97,7 @@ public:  	int _spritesCount;  	int _v1A;  	int _v1C; +	MADSAction _action;  	/**  	 * Constructor | 
