[Scummvm-cvs-logs] scummvm master -> 20f9028d9d75af0f73933728a35d70b6305a1687

tramboi bertrand_augereau at yahoo.fr
Sat Sep 3 13:13:12 CEST 2011


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:
20f9028d9d DREAMWEB: Refining of the pathfinding structures


Commit: 20f9028d9d75af0f73933728a35d70b6305a1687
    https://github.com/scummvm/scummvm/commit/20f9028d9d75af0f73933728a35d70b6305a1687
Author: Bertrand Augereau (bertrand_augereau at yahoo.fr)
Date: 2011-09-03T06:09:21-07:00

Commit Message:
DREAMWEB: Refining of the pathfinding structures

Changed paths:
    engines/dreamweb/pathfind.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.h



diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 873fe79..ef07199 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -33,7 +33,7 @@ void DreamGenContext::turnpathon() {
 
 void DreamGenContext::turnpathon(uint8 param) {
 	findormake(param, 0xff, data.byte(kRoomnum) + 100);
-	Path *roomsPaths = getroomspathsCPP();
+	PathNode *roomsPaths = getroomspathsCPP()->nodes;
 	if (param == 0xff)
 		return;
 	roomsPaths[param].b6 = 0xff;
@@ -45,7 +45,7 @@ void DreamGenContext::turnpathoff() {
 
 void DreamGenContext::turnpathoff(uint8 param) {
 	findormake(param, 0x00, data.byte(kRoomnum) + 100);
-	Path *roomsPaths = getroomspathsCPP();
+	PathNode *roomsPaths = getroomspathsCPP()->nodes;
 	if (param == 0xff)
 		return;
 	roomsPaths[param].b6 = 0x00;
@@ -53,7 +53,7 @@ void DreamGenContext::turnpathoff(uint8 param) {
 
 void DreamGenContext::turnanypathon(uint8 param, uint8 room) {
 	findormake(param, 0xff, room + 100);
-	Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0);
+	PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0);
 	paths[param].b6 = 0xff;
 }
 
@@ -64,7 +64,7 @@ void DreamGenContext::turnanypathon() {
 
 void DreamGenContext::turnanypathoff(uint8 param, uint8 room) {
 	findormake(param, 0x00, room + 100);
-	Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0);
+	PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0);
 	paths[param].b6 = 0x00;
 }
 
@@ -77,21 +77,21 @@ void DreamGenContext::getroomspaths() {
 	bx = data.byte(kRoomnum) * 144;
 }
 
-Path *DreamGenContext::getroomspathsCPP() {
+RoomPaths *DreamGenContext::getroomspathsCPP() {
 	void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144);
-	return (Path *)result;
+	return (RoomPaths *)result;
 }
 
 void DreamGenContext::autosetwalk() {
 	al = data.byte(kManspath);
 	if (data.byte(kFinaldest) == al)
 		return;
-	const Path *roomsPaths = getroomspathsCPP();
+	const RoomPaths *roomsPaths = getroomspathsCPP();
 	checkdest(roomsPaths);
-	data.word(kLinestartx) = roomsPaths[data.byte(kManspath)].x - 12;
-	data.word(kLinestarty) = roomsPaths[data.byte(kManspath)].y - 12;
-	data.word(kLineendx) = roomsPaths[data.byte(kDestination)].x - 12;
-	data.word(kLineendy) = roomsPaths[data.byte(kDestination)].y - 12;
+	data.word(kLinestartx) = roomsPaths->nodes[data.byte(kManspath)].x - 12;
+	data.word(kLinestarty) = roomsPaths->nodes[data.byte(kManspath)].y - 12;
+	data.word(kLineendx) = roomsPaths->nodes[data.byte(kDestination)].x - 12;
+	data.word(kLineendy) = roomsPaths->nodes[data.byte(kDestination)].y - 12;
 	bresenhams();
 	if (data.byte(kLinedirection) != 0) {
 		data.byte(kLinepointer) = data.byte(kLinelength) - 1;
@@ -101,30 +101,29 @@ void DreamGenContext::autosetwalk() {
 	data.byte(kLinepointer) = 0;
 }
 
-void DreamGenContext::checkdest(const Path *roomsPaths) {
-	const uint8 *p = (const uint8 *)roomsPaths + 12 * 8;
+void DreamGenContext::checkdest(const RoomPaths *roomsPaths) {
+	const PathSegment *segments = roomsPaths->segments;
 	ah = data.byte(kManspath) << 4;
 	al = data.byte(kDestination);
 	uint8 destination = data.byte(kDestination);
 	for (size_t i = 0; i < 24; ++i) {
-		dh = p[0] & 0xf0;
-		dl = p[0] & 0x0f;
+		dh = segments[i].b0 & 0xf0;
+		dl = segments[i].b0 & 0x0f;
 		if (ax == dx) {
-			data.byte(kDestination) = p[1] & 0x0f;
+			data.byte(kDestination) = segments[i].b1 & 0x0f;
 			return;
 		}
-		dl = (p[0] & 0xf0) >> 4;
-		dh = (p[0] & 0x0f) << 4;
+		dl = (segments[i].b0 & 0xf0) >> 4;
+		dh = (segments[i].b0 & 0x0f) << 4;
 		if (ax == dx) {
-			destination = p[1] & 0x0f;
+			destination = segments[i].b1 & 0x0f;
 		}
-		p += 2;
 	}
 	data.byte(kDestination) = destination;
 }
 
 void DreamGenContext::findxyfrompath() {
-	const Path *roomsPaths = getroomspathsCPP();
+	const PathNode *roomsPaths = getroomspathsCPP()->nodes;
 	data.byte(kRyanx) = roomsPaths[data.byte(kManspath)].x - 12;
 	data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12;
 }
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 8de829a..e938f86 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -501,8 +501,8 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) {
 }
 
 void DreamGenContext::facerightway() {
-	Path *paths = getroomspathsCPP();
-	uint8 dir = paths[data.byte(kManspath)].b7;
+	PathNode *paths = getroomspathsCPP()->nodes;
+	uint8 dir = paths[data.byte(kManspath)].dir;
 	data.byte(kTurntoface) = dir;
 	data.byte(kLeavedirection) = dir;
 }
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index c0d5636..7c9d9a5 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -228,7 +228,7 @@ struct Change {
 	uint8 type;
 };
 
-struct Path {
+struct PathNode {
 	uint8 x;
 	uint8 y;
 	uint8 b2;
@@ -236,6 +236,16 @@ struct Path {
 	uint8 b4;
 	uint8 b5;
 	uint8 b6;
-	uint8 b7;
+	uint8 dir;
+};
+
+struct PathSegment {
+	uint8 b0;
+	uint8 b1;
+};
+
+struct RoomPaths {
+	PathNode    nodes[12];
+	PathSegment segments[24];
 };
 
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 2602f11..15ff2ee 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -84,7 +84,7 @@
 	void facerightway();
 	void walking(Sprite *sprite);
 	void autosetwalk();
-	void checkdest(const Path *roomsPaths);
+	void checkdest(const RoomPaths *roomsPaths);
 	void aboutturn(Sprite *sprite);
 	void backobject(Sprite *sprite);
 	void constant(Sprite *sprite, SetObject *objData);
@@ -112,7 +112,7 @@
 	void turnanypathon();
 	void turnanypathoff();
 	void getroomspaths();
-	Path *getroomspathsCPP();
+	RoomPaths *getroomspathsCPP();
 	void makebackob(SetObject *objData);
 	void modifychar();
 	void lockmon();






More information about the Scummvm-git-logs mailing list