[Scummvm-cvs-logs] scummvm master -> 9d7a2f4e7f044bbde1c25d0853211820553130c3

bluegr bluegr at gmail.com
Wed Dec 23 22:02:22 CET 2015


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
70ec11d260 LAB: Change the direction and map door defines into enums
9d7a2f4e7f LAB: Fix usage of drawMessage() with empty messages


Commit: 70ec11d260d2adcfaaaa12d19213a6f705dde773
    https://github.com/scummvm/scummvm/commit/70ec11d260d2adcfaaaa12d19213a6f705dde773
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T22:59:59+02:00

Commit Message:
LAB: Change the direction and map door defines into enums

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index cbac66e..0b6ac9c 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -401,7 +401,7 @@ void LabEngine::mainGameLoop() {
 
 	_closeDataPtr = nullptr;
 	_roomNum = 1;
-	_direction = NORTH;
+	_direction = kDirectionNorth;
 
 	_resource->readRoomData("LAB:Doors");
 	if (!(_inventory = _resource->readInventory("LAB:Inventor")))
@@ -1105,7 +1105,7 @@ void LabEngine::go() {
 }
 
 int LabEngine::followCrumbs() {
-	// NORTH, SOUTH, EAST, WEST
+	// kDirectionNorth, kDirectionSouth, kDirectionEast, kDirectionWest
 	int movement[4][4] = {
 		{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
 		{ VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW },
@@ -1134,14 +1134,14 @@ int LabEngine::followCrumbs() {
 
 	int exitDir;
 	// which direction is last crumb
-	if (_breadCrumbs[_numCrumbs]._direction == EAST)
-		exitDir = WEST;
-	else if (_breadCrumbs[_numCrumbs]._direction == WEST)
-		exitDir = EAST;
-	else if (_breadCrumbs[_numCrumbs]._direction == NORTH)
-		exitDir = SOUTH;
+	if (_breadCrumbs[_numCrumbs]._direction == kDirectionEast)
+		exitDir = kDirectionWest;
+	else if (_breadCrumbs[_numCrumbs]._direction == kDirectionWest)
+		exitDir = kDirectionEast;
+	else if (_breadCrumbs[_numCrumbs]._direction == kDirectionNorth)
+		exitDir = kDirectionSouth;
 	else
-		exitDir = NORTH;
+		exitDir = kDirectionNorth;
 
 	int moveDir = movement[_direction][exitDir];
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index a1fd4f5..ded0e63 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -56,7 +56,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_roomNum = -1;
 	for (int i = 0; i < MAX_CRUMBS; i++) {
 		_breadCrumbs[i]._roomNum = 0;
-		_breadCrumbs[i]._direction = NORTH;
+		_breadCrumbs[i]._direction = kDirectionNorth;
 	}
 
 	_numCrumbs = 0;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 200dd00..752cbab 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -90,11 +90,12 @@ struct CrumbData {
 typedef CloseData *CloseDataPtr;
 typedef Common::List<Rule> RuleList;
 
-// Direction defines
-#define NORTH   0
-#define SOUTH   1
-#define EAST    2
-#define WEST    3
+enum Direction {
+	kDirectionNorth,
+	kDirectionSouth,
+	kDirectionEast,
+	kDirectionWest
+};
 
 class LabEngine : public Engine {
 private:
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index e06fefd..082925a 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -68,10 +68,10 @@ void LabEngine::loadMapData() {
 	_imgMaze = new Image(mapImages, this);
 	_imgHugeMaze = new Image(mapImages, this);
 
-	_imgMapX[NORTH] = new Image(mapImages, this);
-	_imgMapX[EAST] = new Image(mapImages, this);
-	_imgMapX[SOUTH] = new Image(mapImages, this);
-	_imgMapX[WEST] = new Image(mapImages, this);
+	_imgMapX[kDirectionNorth] = new Image(mapImages, this);
+	_imgMapX[kDirectionEast] = new Image(mapImages, this);
+	_imgMapX[kDirectionSouth] = new Image(mapImages, this);
+	_imgMapX[kDirectionWest] = new Image(mapImages, this);
 	_imgPath = new Image(mapImages, this);
 	_imgBridge = new Image(mapImages, this);
 
@@ -187,18 +187,18 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 
 		offset = (_imgRoom->_width - _imgPath->_width) / 2;
 
-		if ((NORTHDOOR & flags) && (y >= _imgPath->_height))
+		if ((kDoorLeftNorth & flags) && (y >= _imgPath->_height))
 			_imgPath->drawImage(x + offset, y - _imgPath->_height);
 
-		if (SOUTHDOOR & flags)
+		if (kDoorLeftSouth & flags)
 			_imgPath->drawImage(x + offset, y + _imgRoom->_height);
 
 		offset = (_imgRoom->_height - _imgPath->_height) / 2;
 
-		if (EASTDOOR & flags)
+		if (kDoorLeftEast & flags)
 			_imgPath->drawImage(x + _imgRoom->_width, y + offset);
 
-		if (WESTDOOR & flags)
+		if (kDoorLeftWest & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
 		drawX = x + (_imgRoom->_width - _imgMapX[_direction]->_width) / 2;
@@ -219,32 +219,32 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 
 		offset = (_imgVRoom->_width - _imgPath->_width) / 2;
 
-		if (NORTHDOOR & flags)
+		if (kDoorLeftNorth & flags)
 			_imgPath->drawImage(x + offset, y - _imgPath->_height);
 
-		if (SOUTHDOOR & flags)
+		if (kDoorLeftSouth & flags)
 			_imgPath->drawImage(x + offset, y + _imgVRoom->_height);
 
 		offset = (_imgRoom->_height - _imgPath->_height) / 2;
 
-		if (EASTDOOR & flags)
+		if (kDoorLeftEast & flags)
 			_imgPath->drawImage(x + _imgVRoom->_width, y + offset);
 
-		if (WESTDOOR & flags)
+		if (kDoorLeftWest & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
-		if (EASTBDOOR & flags)
+		if (kDoorBottomEast & flags)
 			_imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
-		if (WESTBDOOR & flags)
+		if (kDoorBottomWest & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
 		offset = (_imgVRoom->_height - _imgPath->_height) / 2;
 
-		if (EASTMDOOR & flags)
+		if (kDoorMiddleEast & flags)
 			_imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
-		if (WESTMDOOR & flags)
+		if (kDoorMiddleWest & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
 		drawX = x + (_imgVRoom->_width - _imgMapX[_direction]->_width) / 2;
@@ -257,32 +257,32 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 
 		offset = (_imgRoom->_width - _imgPath->_width) / 2;
 
-		if (NORTHDOOR & flags)
+		if (kDoorLeftNorth & flags)
 			_imgPath->drawImage(x + offset, y - _imgPath->_height);
 
-		if (SOUTHDOOR & flags)
+		if (kDoorLeftSouth & flags)
 			_imgPath->drawImage(x + offset, y + _imgRoom->_height);
 
-		if (NORTHRDOOR & flags)
+		if (kDoorRightNorth & flags)
 			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height);
 
-		if (SOUTHRDOOR & flags)
+		if (kDoorRightSouth & flags)
 			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height);
 
 		offset = (_imgHRoom->_width - _imgPath->_width) / 2;
 
-		if (NORTHMDOOR & flags)
+		if (kDoorMiddleNorth & flags)
 			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height);
 
-		if (SOUTHMDOOR & flags)
+		if (kDoorMiddleSouth & flags)
 			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height);
 
 		offset = (_imgRoom->_height - _imgPath->_height) / 2;
 
-		if (EASTDOOR & flags)
+		if (kDoorLeftEast & flags)
 			_imgPath->drawImage(x + _imgHRoom->_width, y + offset);
 
-		if (WESTDOOR & flags)
+		if (kDoorLeftWest & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
 		drawX = x + (_imgHRoom->_width - _imgMapX[_direction]->_width) / 2;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index ad8db84..7f0c472 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -141,13 +141,13 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
 	if (!_rooms[_roomNum]._roomMsg.empty())
 		message = _rooms[_roomNum]._roomMsg + ", ";
 
-	if (_direction == NORTH)
+	if (_direction == kDirectionNorth)
 		message += _resource->getStaticText(kTextFacingNorth);
-	else if (_direction == EAST)
+	else if (_direction == kDirectionEast)
 		message += _resource->getStaticText(kTextFacingEast);
-	else if (_direction == SOUTH)
+	else if (_direction == kDirectionSouth)
 		message += _resource->getStaticText(kTextFacingSouth);
-	else if (_direction == WEST)
+	else if (_direction == kDirectionWest)
 		message += _resource->getStaticText(kTextFacingWest);
 
 	_graphics->drawMessage(message, false);
@@ -161,23 +161,23 @@ uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
 
 		return curDirection;
 	} else if (arrow == 0) { // Left
-		if (curDirection == NORTH)
-			return WEST;
-		else if (curDirection == WEST)
-			return SOUTH;
-		else if (curDirection == SOUTH)
-			return EAST;
+		if (curDirection == kDirectionNorth)
+			return kDirectionWest;
+		else if (curDirection == kDirectionWest)
+			return kDirectionSouth;
+		else if (curDirection == kDirectionSouth)
+			return kDirectionEast;
 		else
-			return NORTH;
+			return kDirectionNorth;
 	} else if (arrow == 2) { // Right
-		if (curDirection == NORTH)
-			return EAST;
-		else if (curDirection == EAST)
-			return SOUTH;
-		else if (curDirection == SOUTH)
-			return WEST;
+		if (curDirection == kDirectionNorth)
+			return kDirectionEast;
+		else if (curDirection == kDirectionEast)
+			return kDirectionSouth;
+		else if (curDirection == kDirectionSouth)
+			return kDirectionWest;
 		else
-			return NORTH;
+			return kDirectionNorth;
 	}
 
 	// Should never reach here!
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 3726435..66111b3 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -145,22 +145,22 @@ struct InventoryData {
 
 // Map Flags
 
-// Where the doors are; in a corridor, assumed to be left doors
-#define     NORTHDOOR        1
-#define     EASTDOOR         2
-#define     SOUTHDOOR        4
-#define     WESTDOOR         8
-
-// Where the doors are in corridors; M means middle, R means right, B means bottom
-#define     NORTHMDOOR      16
-#define     NORTHRDOOR      32
-#define     SOUTHMDOOR      64
-#define     SOUTHRDOOR     128
-
-#define     EASTMDOOR       16
-#define     EASTBDOOR       32
-#define     WESTMDOOR       64
-#define     WESTBDOOR      128
+enum MapDoors {
+	kDoorLeftNorth = 1,
+	kDoorLeftEast = 2,
+	kDoorLeftSouth = 4,
+	kDoorLeftWest = 8,
+
+	kDoorMiddleNorth = 16,
+	kDoorRightNorth = 32,
+	kDoorMiddleSouth = 64,
+	kDoorRightSouth = 128,
+
+	kDoorMiddleEast = 16,
+	kDoorBottomEast = 32,
+	kDoorMiddleWest = 64,
+	kDoorBottomWest = 128
+};
 
 // Special Map ID's
 #define     NORMAL           0
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index b9239a2..d1c915f 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -104,16 +104,16 @@ void Resource::readRoomData(const Common::String fileName) {
 
 	for (int i = 1; i <= _vm->_manyRooms; i++) {
 		RoomData *curRoom = &_vm->_rooms[i];
-		curRoom->_doors[NORTH] = dataFile->readUint16LE();
-		curRoom->_doors[SOUTH] = dataFile->readUint16LE();
-		curRoom->_doors[EAST] = dataFile->readUint16LE();
-		curRoom->_doors[WEST] = dataFile->readUint16LE();
+		curRoom->_doors[kDirectionNorth] = dataFile->readUint16LE();
+		curRoom->_doors[kDirectionSouth] = dataFile->readUint16LE();
+		curRoom->_doors[kDirectionEast] = dataFile->readUint16LE();
+		curRoom->_doors[kDirectionWest] = dataFile->readUint16LE();
 		curRoom->_transitionType = dataFile->readByte();
 
-		curRoom->_view[NORTH] = nullptr;
-		curRoom->_view[SOUTH] = nullptr;
-		curRoom->_view[EAST] = nullptr;
-		curRoom->_view[WEST] = nullptr;
+		curRoom->_view[kDirectionNorth] = nullptr;
+		curRoom->_view[kDirectionSouth] = nullptr;
+		curRoom->_view[kDirectionEast] = nullptr;
+		curRoom->_view[kDirectionWest] = nullptr;
 		curRoom->_rules = nullptr;
 		curRoom->_roomMsg = "";
 	}
@@ -145,10 +145,10 @@ void Resource::readViews(uint16 roomNum) {
 	RoomData *curRoom = &_vm->_rooms[roomNum];
 
 	curRoom->_roomMsg = readString(dataFile);
-	curRoom->_view[NORTH] = readView(dataFile);
-	curRoom->_view[SOUTH] = readView(dataFile);
-	curRoom->_view[EAST] = readView(dataFile);
-	curRoom->_view[WEST] = readView(dataFile);
+	curRoom->_view[kDirectionNorth] = readView(dataFile);
+	curRoom->_view[kDirectionSouth] = readView(dataFile);
+	curRoom->_view[kDirectionEast] = readView(dataFile);
+	curRoom->_view[kDirectionWest] = readView(dataFile);
 	curRoom->_rules = readRule(dataFile);
 
 	_vm->updateMusicAndEvents();


Commit: 9d7a2f4e7f044bbde1c25d0853211820553130c3
    https://github.com/scummvm/scummvm/commit/9d7a2f4e7f044bbde1c25d0853211820553130c3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T23:01:17+02:00

Commit Message:
LAB: Fix usage of drawMessage() with empty messages

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 0b6ac9c..3167222 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -305,7 +305,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		_closeDataPtr = nullptr;
 		doMap(_roomNum);
 		_graphics->setPalette(initColors, 8);
-		_graphics->drawMessage(nullptr, false);
+		_graphics->drawMessage("", false);
 		_graphics->drawPanel();
 		return true;
 	case kItemJournal:
@@ -316,7 +316,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		_closeDataPtr = nullptr;
 		doJournal();
 		_graphics->drawPanel();
-		_graphics->drawMessage(nullptr, false);
+		_graphics->drawMessage("", false);
 		return true;
 	case kItemLamp:
 		interfaceOff();






More information about the Scummvm-git-logs mailing list