[Scummvm-cvs-logs] SF.net SVN: scummvm:[34942] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Nov 9 04:53:07 CET 2008


Revision: 34942
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34942&view=rev
Author:   peres001
Date:     2008-11-09 03:53:06 +0000 (Sun, 09 Nov 2008)

Log Message:
-----------
Better cleanup and handling of mouse when changing location in NS.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-11-09 02:39:28 UTC (rev 34941)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-11-09 03:53:06 UTC (rev 34942)
@@ -411,10 +411,12 @@
 	}
 
 	_input->setMouseState(MOUSE_DISABLED);
+	_intro = true;
 }
 
 void Parallaction_ns::_c_endIntro(void *parm) {
 	startCreditSequence();
+	_intro = false;
 }
 
 void Parallaction_ns::_c_moveSheet(void *parm) {

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-11-09 02:39:28 UTC (rev 34941)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-11-09 03:53:06 UTC (rev 34942)
@@ -869,9 +869,6 @@
 	{  2,  2,  4,  4 }
 };
 
-const char Character::_prefixMini[] = "mini";
-const char Character::_suffixTras[] = "tras";
-const char Character::_empty[] = "\0";
 
 
 Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) {
@@ -882,8 +879,6 @@
 	_direction = WALK_DOWN;
 	_step = 0;
 
-	_dummy = false;
-
 	_ani->setX(150);
 	_ani->setY(100);
 	_ani->setZ(10);
@@ -965,6 +960,49 @@
 }
 
 
+void Character::setName(const char *name) {
+	_name.bind(name);
+}
+
+const char *Character::getName() const {
+	return _name.getName();
+}
+
+const char *Character::getBaseName() const {
+	return _name.getBaseName();
+}
+
+const char *Character::getFullName() const {
+	return _name.getFullName();
+}
+
+bool Character::dummy() const {
+	return _name.dummy();
+}
+
+void Character::updateDirection(const Common::Point& pos, const Common::Point& to) {
+
+	Common::Point dist(to.x - pos.x, to.y - pos.y);
+	WalkFrames *frames = (_ani->getFrameNum() == 20) ? &_char20WalkFrames : &_char24WalkFrames;
+
+	_step++;
+
+	if (dist.x == 0 && dist.y == 0) {
+		_ani->setF(frames->stillFrame[_direction]);
+		return;
+	}
+
+	if (dist.x < 0)
+		dist.x = -dist.x;
+	if (dist.y < 0)
+		dist.y = -dist.y;
+
+	_direction = (dist.x > dist.y) ? ((to.x > pos.x) ? WALK_LEFT : WALK_RIGHT) : ((to.y > pos.y) ? WALK_DOWN : WALK_UP);
+	_ani->setF(frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]);
+}
+
+
+
 // Various ways of detecting character modes used to exist
 // inside the engine, so they have been unified in the two
 // following macros.
@@ -976,7 +1014,26 @@
 #define IS_MINI_CHARACTER(s) (((s)[0] == 'm'))
 #define IS_DUMMY_CHARACTER(s) (((s)[0] == 'D'))
 
-void Character::setName(const char *name) {
+const char CharacterName::_prefixMini[] = "mini";
+const char CharacterName::_suffixTras[] = "tras";
+const char CharacterName::_empty[] = "\0";
+
+void CharacterName::dummify() {
+	_dummy = true;
+	_baseName[0] = '\0';
+	_name[0] = '\0';
+	_fullName[0] = '\0';
+}
+
+CharacterName::CharacterName() {
+	dummify();
+}
+
+CharacterName::CharacterName(const char *name) {
+	bind(name);
+}
+
+void CharacterName::bind(const char *name) {
 	const char *begin = name;
 	const char *end = begin + strlen(name);
 
@@ -1011,22 +1068,23 @@
 	sprintf(_fullName, "%s%s%s", _prefix, _baseName, _suffix);
 }
 
-const char *Character::getName() const {
+const char *CharacterName::getName() const {
 	return _name;
 }
 
-const char *Character::getBaseName() const {
+const char *CharacterName::getBaseName() const {
 	return _baseName;
 }
 
-const char *Character::getFullName() const {
+const char *CharacterName::getFullName() const {
 	return _fullName;
 }
 
-bool Character::dummy() const {
+bool CharacterName::dummy() const {
 	return _dummy;
 }
 
+
 void Parallaction::beep() {
 	_soundMan->playSfx("beep", 3, false);
 }
@@ -1038,29 +1096,4 @@
 }
 
 
-
-
-
-void Character::updateDirection(const Common::Point& pos, const Common::Point& to) {
-
-	Common::Point dist(to.x - pos.x, to.y - pos.y);
-	WalkFrames *frames = (_ani->getFrameNum() == 20) ? &_char20WalkFrames : &_char24WalkFrames;
-
-	_step++;
-
-	if (dist.x == 0 && dist.y == 0) {
-		_ani->setF(frames->stillFrame[_direction]);
-		return;
-	}
-
-	if (dist.x < 0)
-		dist.x = -dist.x;
-	if (dist.y < 0)
-		dist.y = -dist.y;
-
-	_direction = (dist.x > dist.y) ? ((to.x > pos.x) ? WALK_LEFT : WALK_RIGHT) : ((to.y > pos.y) ? WALK_DOWN : WALK_UP);
-	_ani->setF(frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]);
-}
-
-
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-11-09 02:39:28 UTC (rev 34941)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-11-09 03:53:06 UTC (rev 34942)
@@ -166,6 +166,26 @@
 };
 
 
+class CharacterName {
+	const char *_prefix;
+	const char *_suffix;
+	bool _dummy;
+	char _name[30];
+	char _baseName[30];
+	char _fullName[30];
+	static const char _prefixMini[];
+	static const char _suffixTras[];
+	static const char _empty[];
+	void dummify();
+public:
+	CharacterName();
+	CharacterName(const char *name);
+	void bind(const char *name);
+	const char *getName() const;
+	const char *getBaseName() const;
+	const char *getFullName() const;
+	bool dummy() const;
+};
 
 
 struct Character {
@@ -190,18 +210,8 @@
 	void free();
 
 protected:
-	const char *_prefix;
-	const char *_suffix;
+	CharacterName	_name;
 
-	bool _dummy;
-
-	char _name[30];
-	char _baseName[30];
-	char _fullName[30];
-	static const char _prefixMini[];
-	static const char _suffixTras[];
-	static const char _empty[];
-
 	int16		_direction, _step;
 
 public:
@@ -408,6 +418,7 @@
 	ZonePtr _moveSarcZones[5];
 	ZonePtr _moveSarcExaZones[5];
 	AnimationPtr _rightHandAnim;
+	bool _intro;
 	static const Callable _dosCallables[25];
 	static const Callable _amigaCallables[25];
 

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-11-09 02:39:28 UTC (rev 34941)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-11-09 03:53:06 UTC (rev 34942)
@@ -202,6 +202,8 @@
 void Parallaction_br::changeLocation(char *location) {
 	char *partStr = strrchr(location, '.');
 	if (partStr) {
+		cleanupGame();
+
 		int n = partStr - location;
 		strncpy(_location._name, location, n);
 		_location._name[n] = '\0';

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-11-09 02:39:28 UTC (rev 34941)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-11-09 03:53:06 UTC (rev 34942)
@@ -186,6 +186,7 @@
 
 	num_foglie = 0;
 
+	_intro = false;
 	_inTestResult = false;
 
 	_location._animations.push_front(_char._ani);
@@ -296,11 +297,22 @@
 
 	_gfx->showGfxObj(_char._ani->gfxobj, false);
 
-	freeLocation(false);
-
 	LocationName locname;
 	locname.bind(location);
 
+	bool fullCleanup = false;
+	if (locname.hasCharacter()) {
+		CharacterName newName(locname.character());
+		fullCleanup = (strcmp(newName.getBaseName(), _char.getBaseName()));
+	}
+
+	if (fullCleanup) {
+		cleanupGame();
+	} else {
+		freeLocation(false);
+	}
+
+
 	if (locname.hasSlide()) {
 		showSlide(locname.slide());
 		uint id = _gfx->createLabel(_menuFont, _location._slideText[0], 1);
@@ -346,7 +358,9 @@
 	if (_location._hasSound)
 		_soundMan->playSfx(_location._soundFile, 0, true);
 
-	_input->setMouseState(oldMouseState);
+	if (!_intro) {
+		_input->setMouseState(oldMouseState);
+	}
 
 	debugC(1, kDebugExec, "changeLocation() done");
 }


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