[Scummvm-cvs-logs] SF.net SVN: scummvm:[45640] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Tue Nov 3 22:05:26 CET 2009


Revision: 45640
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45640&view=rev
Author:   spalek
Date:     2009-11-03 21:05:26 +0000 (Tue, 03 Nov 2009)

Log Message:
-----------
Let setPath() store path with pixel precision, and update the map sprite when reloaded

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/walking.cpp
    scummvm/trunk/engines/draci/walking.h

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-11-03 20:50:23 UTC (rev 45639)
+++ scummvm/trunk/engines/draci/game.cpp	2009-11-03 21:05:26 UTC (rev 45640)
@@ -980,7 +980,7 @@
 		redrawWalkingPath(kWalkingObliquePathOverlay, kWalkingObliquePathOverlayColour, obliquePath);
 	}
 
-	_walkingState.setPath(obliquePath);
+	_walkingState.setPath(_hero, target, _walkingMap.getDelta(), obliquePath);
 
 	// FIXME: Need to add proper walking (this only warps the dragon to position)
 	_hero = target;
@@ -1097,22 +1097,21 @@
 		_currentRoom._gates.push_back(roomReader.readSint16LE());
 	}
 
-	// Load the walking map
-	loadWalkingMap(getMapID());
-
 	// Add overlays for the walking map and shortest/obliqued paths.
 	Animation *map = _vm->_anims->addAnimation(kWalkingMapOverlay, 256, _vm->_showWalkingMap);
-	Sprite *ov = _walkingMap.newOverlayFromMap(kWalkingMapOverlayColour);
-	map->addFrame(ov, NULL);
+	map->addFrame(NULL, NULL);	// rewritten below by loadWalkingMap()
 
 	Animation *sPath = _vm->_anims->addAnimation(kWalkingShortestPathOverlay, 257, _vm->_showWalkingMap);
 	Animation *oPath = _vm->_anims->addAnimation(kWalkingObliquePathOverlay, 258, _vm->_showWalkingMap);
 	WalkingPath emptyPath;
-	ov = _walkingMap.newOverlayFromPath(emptyPath, 0);
+	Sprite *ov = _walkingMap.newOverlayFromPath(emptyPath, 0);
 	sPath->addFrame(ov, NULL);
 	ov = _walkingMap.newOverlayFromPath(emptyPath, 0);
 	oPath->addFrame(ov, NULL);
 
+	// Load the walking map
+	loadWalkingMap(getMapID());
+
 	// Load the room's objects
 	for (uint i = 0; i < _info._numObjects; ++i) {
 		debugC(7, kDraciLogicDebugLevel,
@@ -1254,6 +1253,12 @@
 	const BAFile *f;
 	f = _vm->_walkingMapsArchive->getFile(mapID);
 	_walkingMap.load(f->_data, f->_length);
+
+	Animation *anim = _vm->_anims->getAnimation(kWalkingMapOverlay);
+	Sprite *ov = _walkingMap.newOverlayFromMap(kWalkingMapOverlayColour);
+	delete anim->getFrame(0);
+	anim->replaceFrame(0, ov, NULL);
+	anim->markDirtyRect(_vm->_screen->getSurface());
 }
 
 void Game::loadOverlays() {

Modified: scummvm/trunk/engines/draci/walking.cpp
===================================================================
--- scummvm/trunk/engines/draci/walking.cpp	2009-11-03 20:50:23 UTC (rev 45639)
+++ scummvm/trunk/engines/draci/walking.cpp	2009-11-03 21:05:26 UTC (rev 45640)
@@ -420,4 +420,27 @@
 	return improved;
 }
 
+void WalkingState::setPath(const Common::Point &p1, const Common::Point &p2, const Common::Point &delta, const WalkingPath& path) {
+	_path = path;
+	if (!_path.size()) {
+		return;
+	}
+	if (_path.size() == 1 && p2 != p1) {
+		// Although the first and last point belong to the same
+		// rectangle and therefore the computed path is of length 1,
+		// they are different pixels.
+		_path.push_back(p2);
+	}
+
+	// The first and last point are available with pixel accurracy.
+	_path[0] = p1;
+	_path[_path.size() - 1] = p2;
+	// The intermediate points are given with map granularity; convert them
+	// to pixels.
+	for (uint i = 1; i < _path.size() - 1; ++i) {
+		_path[i].x *= delta.x;
+		_path[i].y *= delta.y;
+	}
 }
+
+}

Modified: scummvm/trunk/engines/draci/walking.h
===================================================================
--- scummvm/trunk/engines/draci/walking.h	2009-11-03 20:50:23 UTC (rev 45639)
+++ scummvm/trunk/engines/draci/walking.h	2009-11-03 21:05:26 UTC (rev 45640)
@@ -51,6 +51,7 @@
 	bool findShortestPath(Common::Point p1, Common::Point p2, WalkingPath *path) const;
 	void obliquePath(const WalkingPath& path, WalkingPath *obliquedPath);
 	Sprite *newOverlayFromPath(const WalkingPath &path, byte colour) const;
+	Common::Point getDelta() const { return Common::Point(_deltaX, _deltaY); }
 
 private:
 	int _realWidth, _realHeight;
@@ -98,7 +99,7 @@
 	WalkingState() : _path() {}
 	~WalkingState() {}
 
-	void setPath(const WalkingPath& path) { _path = path; }
+	void setPath(const Common::Point &p1, const Common::Point &p2, const Common::Point &delta, const WalkingPath& path);
 	const WalkingPath& getPath() const { return _path; }
 
 private:


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