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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Aug 31 11:30:18 CEST 2008


Revision: 34222
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34222&view=rev
Author:   peres001
Date:     2008-08-31 09:30:16 +0000 (Sun, 31 Aug 2008)

Log Message:
-----------
Cleanup.

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

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-08-31 08:27:40 UTC (rev 34221)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-08-31 09:30:16 UTC (rev 34222)
@@ -247,32 +247,6 @@
 	_vm->updateDoor(_ctxt.cmd->u._zone, true);
 }
 
-void Parallaction::showZone(ZonePtr z, bool visible) {
-	if (!z) {
-		return;
-	}
-
-	if (visible) {
-		z->_flags &= ~kFlagsRemove;
-		z->_flags |= kFlagsActive;
-	} else {
-		z->_flags |= kFlagsRemove;
-	}
-
-	if ((z->_type & 0xFFFF) == kZoneGet) {
-		_gfx->showGfxObj(z->u.get->gfxobj, visible);
-
-		GetData *data = z->u.get;
-		if (data->hasMask && _gfx->_backgroundInfo->hasMask) {
-			if (visible) {
-				_gfx->_backgroundInfo->mask.bltOr(data->gfxobj->x, data->gfxobj->y, data->_mask[0], 0, 0, data->_mask->w, data->_mask->h);
-			} else {
-				_gfx->_backgroundInfo->mask.bltCopy(data->gfxobj->x, data->gfxobj->y, data->_mask[1], 0, 0, data->_mask->w, data->_mask->h);
-			}
-		}
-	}
-}
-
 DECLARE_COMMAND_OPCODE(on) {
 	_vm->showZone(_ctxt.cmd->u._zone, true);
 }
@@ -318,79 +292,6 @@
 }
 
 
-void Parallaction::drawAnimations() {
-	debugC(9, kDebugExec, "Parallaction_ns::drawAnimations()\n");
-
-	uint16 layer = 0, scale = 100;
-
-	for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) {
-
-		AnimationPtr anim = *it;
-		GfxObj *obj = anim->gfxobj;
-
-		// Validation is performed here, so that every animation is affected, instead that only the ones
-		// who *own* a script. In fact, some scripts can change values in other animations.
-		// The right way to do this would be to enforce validation when any variable is modified from
-		// a script.
-		anim->validateScriptVars();
-
-		if ((anim->_flags & kFlagsActive) && ((anim->_flags & kFlagsRemove) == 0))   {
-
-			if (anim->_flags & kFlagsNoMasked)
-				layer = LAYER_FOREGROUND;
-			else {
-				if (getGameType() == GType_Nippon) {
-					// Layer in NS depends on where the animation is on the screen, for each animation.
-					layer = _gfx->_backgroundInfo->getLayer(anim->getFrameY() + anim->height());
-				} else {
-					// Layer in BRA is calculated from Z value. For characters it is the same as NS,
-					// but other animations can have Z set from scripts independently from their
-					// position on the screen.
-					layer = _gfx->_backgroundInfo->getLayer(anim->getZ());
-				}
-			}
-
-			if (getGameType() == GType_BRA) {
-				if (anim->_flags & (kFlagsScaled | kFlagsCharacter)) {
-					if (anim->getZ() <= _location._zeta0) {
-						if (anim->getZ() >= _location._zeta1) {
-							scale = ((anim->getZ() - _location._zeta1) * (100 - _location._zeta2)) / (_location._zeta0 - _location._zeta1) + _location._zeta2;
-						} else {
-							scale = _location._zeta2;
-						}
-					}
-				}
-			}
-
-			if (obj) {
-				_gfx->showGfxObj(obj, true);
-				obj->frame = anim->getF();
-				obj->x = anim->getX();
-				obj->y = anim->getY();
-				obj->z = anim->getZ();
-				obj->layer = layer;
-				obj->scale = scale;
-			}
-		}
-
-		if (((anim->_flags & kFlagsActive) == 0) && (anim->_flags & kFlagsRemove))   {
-			anim->_flags &= ~kFlagsRemove;
-		}
-
-		if ((anim->_flags & kFlagsActive) && (anim->_flags & kFlagsRemove))	{
-			anim->_flags &= ~kFlagsActive;
-			anim->_flags |= kFlagsRemove;
-			if (obj) {
-				_gfx->showGfxObj(obj, false);
-			}
-		}
-	}
-
-	debugC(9, kDebugExec, "Parallaction_ns::drawAnimations done()\n");
-
-	return;
-}
-
 void ProgramExec::runScript(ProgramPtr script, AnimationPtr a) {
 	debugC(9, kDebugExec, "runScript(Animation = %s)", a->_name);
 
@@ -545,287 +446,6 @@
 
 }
 
-//
-//	ZONE TYPE: EXAMINE
-//
-
-void Parallaction::enterCommentMode(ZonePtr z) {
-	if (!z) {
-		return;
-	}
-
-	_commentZone = z;
-
-	ExamineData *data = _commentZone->u.examine;
-
-	if (!data->_description) {
-		return;
-	}
-
-	// TODO: move this balloons stuff into DialogueManager and BalloonManager
-	if (getGameType() == GType_Nippon) {
-		int id;
-		if (data->_filename) {
-			if (data->_cnv == 0) {
-				data->_cnv = _disk->loadStatic(data->_filename);
-			}
-
-			_gfx->setHalfbriteMode(true);
-			_balloonMan->setSingleBalloon(data->_description, 0, 90, 0, BalloonManager::kNormalColor);
-			Common::Rect r;
-			data->_cnv->getRect(0, r);
-			id = _gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
-			_gfx->setItemFrame(id, 0);
-			id = _gfx->setItem(_char._head, 100, 152);
-			_gfx->setItemFrame(id, 0);
-		} else {
-			_balloonMan->setSingleBalloon(data->_description, 140, 10, 0, BalloonManager::kNormalColor);
-			id = _gfx->setItem(_char._talk, 190, 80);
-			_gfx->setItemFrame(id, 0);
-		}
-	} else
-	if (getGameType() == GType_BRA) {
-		_balloonMan->setSingleBalloon(data->_description, 0, 0, 1, BalloonManager::kNormalColor);
-		int id = _gfx->setItem(_char._talk, 10, 80);
-		_gfx->setItemFrame(id, 0);
-	}
-
-	_input->_inputMode = Input::kInputModeComment;
-}
-
-void Parallaction::exitCommentMode() {
-	_input->_inputMode = Input::kInputModeGame;
-
-	hideDialogueStuff();
-	_gfx->setHalfbriteMode(false);
-
-	_cmdExec->run(_commentZone->_commands, _commentZone);
-	_commentZone = nullZonePtr;
-}
-
-void Parallaction::runCommentFrame() {
-	if (_input->_inputMode != Input::kInputModeComment) {
-		return;
-	}
-
-	if (_input->getLastButtonEvent() == kMouseLeftUp) {
-		exitCommentMode();
-	}
-}
-
-
-void Parallaction::runZone(ZonePtr z) {
-	debugC(3, kDebugExec, "runZone (%s)", z->_name);
-
-	uint16 subtype = z->_type & 0xFFFF;
-
-	debugC(3, kDebugExec, "type = %x, object = %x", subtype, (z->_type & 0xFFFF0000) >> 16);
-	switch(subtype) {
-
-	case kZoneExamine:
-		enterCommentMode(z);
-		return;
-
-	case kZoneGet:
-		pickupItem(z);
-		break;
-
-	case kZoneDoor:
-		if (z->_flags & kFlagsLocked) break;
-		updateDoor(z, !(z->_flags & kFlagsClosed));
-		break;
-
-	case kZoneHear:
-		_soundMan->playSfx(z->u.hear->_name, z->u.hear->_channel, (z->_flags & kFlagsLooping) == kFlagsLooping, 60);
-		break;
-
-	case kZoneSpeak:
-		enterDialogueMode(z);
-		return;
-	}
-
-	debugC(3, kDebugExec, "runZone completed");
-
-	_cmdExec->run(z->_commands, z);
-
-	return;
-}
-
-//
-//	ZONE TYPE: DOOR
-//
-void Parallaction::updateDoor(ZonePtr z, bool close) {
-	z->_flags = close ? (z->_flags |= kFlagsClosed) : (z->_flags &= ~kFlagsClosed);
-
-	if (z->u.door->gfxobj) {
-		uint frame = (close ? 0 : 1);
-//		z->u.door->gfxobj->setFrame(frame);
-		z->u.door->gfxobj->frame = frame;
-	}
-
-	return;
-}
-
-
-
-//
-//	ZONE TYPE: GET
-//
-
-bool Parallaction::pickupItem(ZonePtr z) {
-	if (z->_flags & kFlagsFixed) {
-		return false;
-	}
-
-	int slot = addInventoryItem(z->u.get->_icon);
-	if (slot != -1) {
-		showZone(z, false);
-	}
-
-	return (slot != -1);
-}
-
-// FIXME: input coordinates must be offseted to handle scrolling!
-bool Parallaction::checkSpecialZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
-	// not a special zone
-	if ((z->getX() != -2) && (z->getX() != -3)) {
-		return false;
-	}
-
-	// WORKAROUND: this huge condition is needed because we made TypeData a collection of structs
-	// instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine,
-	// but we need to check it separately here. The same workaround is applied in freeZones.
-	if ((((z->_type & 0xFFFF) == kZoneMerge) && (((x == z->u.merge->_obj1) && (y == z->u.merge->_obj2)) || ((x == z->u.merge->_obj2) && (y == z->u.merge->_obj1)))) ||
-		(((z->_type & 0xFFFF) == kZoneGet) && ((x == z->u.get->_icon) || (y == z->u.get->_icon)))) {
-
-		// WORKAROUND for bug 2070751: special zones are only used in NS, to allow the
-		// the EXAMINE/USE action to be applied on some particular item in the inventory.
-		// The usage a verb requires at least an item match, so type can't be 0, as it
-		// was in the original code. This bug has been here since the beginning, and was
-		// hidden by label code, which filtered the bogus matches produced here.
-
-		// look for action + item match
-		if (z->_type == type)
-			return true;
-		// look for item match, but don't accept 0 types
-		if (((z->_type & 0xFFFF0000) == type) && (type))
-			return true;
-	}
-
-	return false;
-}
-
-// FIXME: input coordinates must be offseted to handle scrolling!
-bool Parallaction::checkZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
-	if (z->_flags & kFlagsRemove)
-		return false;
-
-	debugC(5, kDebugExec, "checkZoneBox for %s (type = %x, x = %i, y = %i)", z->_name, type, x, y);
-
-	Common::Rect r;
-	z->getBox(r);
-	r.right++;		// adjust border because Common::Rect doesn't include bottom-right edge
-	r.bottom++;
-
-	r.grow(-1);		// allows some tolerance for mouse click
-
-	if (!r.contains(x, y)) {
-
-		// check for special zones (items defined in common.loc)
-		if (checkSpecialZoneBox(z, type, x, y))
-			return true;
-
-		if (z->getX() != -1)
-			return false;
-		if ((int)x < _char._ani->getFrameX())
-			return false;
-		if ((int)x > (_char._ani->getFrameX() + _char._ani->width()))
-			return false;
-		if ((int)y < _char._ani->getFrameY())
-			return false;
-		if ((int)y > (_char._ani->getFrameY() + _char._ani->height()))
-			return false;
-	}
-
-	// normal Zone
-	if ((type == 0) && ((z->_type & 0xFFFF0000) == 0))
-		return true;
-	if (z->_type == type)
-		return true;
-	if ((z->_type & 0xFFFF0000) == type)
-		return true;
-
-	return false;
-}
-
-// FIXME: input coordinates must be offseted to handle scrolling!
-bool Parallaction::checkLinkedAnimBox(ZonePtr z, uint32 type, uint x, uint y) {
-	if (z->_flags & kFlagsRemove)
-		return false;
-
-	if ((z->_flags & kFlagsAnimLinked) == 0)
-		return false;
-
-	debugC(5, kDebugExec, "checkLinkedAnimBox for %s (type = %x, x = %i, y = %i)", z->_name, type, x, y);
-
-	AnimationPtr anim = z->_linkedAnim;
-	Common::Rect r(anim->getFrameX(), anim->getFrameY(), anim->getFrameX() + anim->width() + 1, anim->getFrameY() + anim->height() + 1);
-
-	if (!r.contains(x, y)) {
-		return false;
-	}
-
-	// NOTE: the implementation of the following lines is a different in the
-	// original... it is working so far, though
-	if ((type == 0) && ((z->_type & 0xFFFF0000) == 0))
-		return true;
-	if (z->_type == type)
-		return true;
-	if ((z->_type & 0xFFFF0000) == type)
-		return true;
-
-	return false;
-}
-
-ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
-	uint16 _di = y;
-	uint16 _si = x;
-
-	for (ZoneList::iterator it = _location._zones.begin(); it != _location._zones.end(); it++) {
-		if (checkLinkedAnimBox(*it, type, x, y)) {
-			return *it;
-		}
-		if (checkZoneBox(*it, type, x, y)) {
-			return *it;
-		}
-	}
-
-
-	int16 _a, _b, _c, _d, _e, _f;
-	for (AnimationList::iterator ait = _location._animations.begin(); ait != _location._animations.end(); ait++) {
-
-		AnimationPtr a = *ait;
-
-		_a = (a->_flags & kFlagsActive) ? 1 : 0;															   // _a: active Animation
-		_e = ((_si >= a->getFrameX() + a->width()) || (_si <= a->getFrameX())) ? 0 : 1;		// _e: horizontal range
-		_f = ((_di >= a->getFrameY() + a->height()) || (_di <= a->getFrameY())) ? 0 : 1;		// _f: vertical range
-
-		_b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1;										 // _b: (no type specified) AND (Animation is not the character)
-		_c = (a->_type & 0xFFFF0000) ? 0 : 1;															// _c: Animation is not an object
-		_d = ((a->_type & 0xFFFF0000) != type) ? 0 : 1;													// _d: Animation is an object of the same type
-
-		if ((_a != 0 && _e != 0 && _f != 0) && ((_b != 0 && _c != 0) || (a->_type == type) || (_d != 0))) {
-
-			return a;
-
-		}
-
-	}
-
-	return nullZonePtr;
-}
-
-
 void CommandExec_ns::init() {
 	Common::Array<const Opcode*> *table = 0;
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-08-31 08:27:40 UTC (rev 34221)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-08-31 09:30:16 UTC (rev 34222)
@@ -428,7 +428,388 @@
 
 
 
+void Parallaction::drawAnimations() {
+	debugC(9, kDebugExec, "Parallaction_ns::drawAnimations()\n");
 
+	uint16 layer = 0, scale = 100;
+
+	for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) {
+
+		AnimationPtr anim = *it;
+		GfxObj *obj = anim->gfxobj;
+
+		// Validation is performed here, so that every animation is affected, instead that only the ones
+		// who *own* a script. In fact, some scripts can change values in other animations.
+		// The right way to do this would be to enforce validation when any variable is modified from
+		// a script.
+		anim->validateScriptVars();
+
+		if ((anim->_flags & kFlagsActive) && ((anim->_flags & kFlagsRemove) == 0))   {
+
+			if (anim->_flags & kFlagsNoMasked)
+				layer = LAYER_FOREGROUND;
+			else {
+				if (getGameType() == GType_Nippon) {
+					// Layer in NS depends on where the animation is on the screen, for each animation.
+					layer = _gfx->_backgroundInfo->getLayer(anim->getFrameY() + anim->height());
+				} else {
+					// Layer in BRA is calculated from Z value. For characters it is the same as NS,
+					// but other animations can have Z set from scripts independently from their
+					// position on the screen.
+					layer = _gfx->_backgroundInfo->getLayer(anim->getZ());
+				}
+			}
+
+			if (getGameType() == GType_BRA) {
+				if (anim->_flags & (kFlagsScaled | kFlagsCharacter)) {
+					if (anim->getZ() <= _location._zeta0) {
+						if (anim->getZ() >= _location._zeta1) {
+							scale = ((anim->getZ() - _location._zeta1) * (100 - _location._zeta2)) / (_location._zeta0 - _location._zeta1) + _location._zeta2;
+						} else {
+							scale = _location._zeta2;
+						}
+					}
+				}
+			}
+
+			if (obj) {
+				_gfx->showGfxObj(obj, true);
+				obj->frame = anim->getF();
+				obj->x = anim->getX();
+				obj->y = anim->getY();
+				obj->z = anim->getZ();
+				obj->layer = layer;
+				obj->scale = scale;
+			}
+		}
+
+		if (((anim->_flags & kFlagsActive) == 0) && (anim->_flags & kFlagsRemove))   {
+			anim->_flags &= ~kFlagsRemove;
+		}
+
+		if ((anim->_flags & kFlagsActive) && (anim->_flags & kFlagsRemove))	{
+			anim->_flags &= ~kFlagsActive;
+			anim->_flags |= kFlagsRemove;
+			if (obj) {
+				_gfx->showGfxObj(obj, false);
+			}
+		}
+	}
+
+	debugC(9, kDebugExec, "Parallaction_ns::drawAnimations done()\n");
+
+	return;
+}
+
+
+void Parallaction::showZone(ZonePtr z, bool visible) {
+	if (!z) {
+		return;
+	}
+
+	if (visible) {
+		z->_flags &= ~kFlagsRemove;
+		z->_flags |= kFlagsActive;
+	} else {
+		z->_flags |= kFlagsRemove;
+	}
+
+	if ((z->_type & 0xFFFF) == kZoneGet) {
+		_gfx->showGfxObj(z->u.get->gfxobj, visible);
+
+		GetData *data = z->u.get;
+		if (data->hasMask && _gfx->_backgroundInfo->hasMask) {
+			if (visible) {
+				_gfx->_backgroundInfo->mask.bltOr(data->gfxobj->x, data->gfxobj->y, data->_mask[0], 0, 0, data->_mask->w, data->_mask->h);
+			} else {
+				_gfx->_backgroundInfo->mask.bltCopy(data->gfxobj->x, data->gfxobj->y, data->_mask[1], 0, 0, data->_mask->w, data->_mask->h);
+			}
+		}
+	}
+}
+
+
+//
+//	ZONE TYPE: EXAMINE
+//
+
+void Parallaction::enterCommentMode(ZonePtr z) {
+	if (!z) {
+		return;
+	}
+
+	_commentZone = z;
+
+	ExamineData *data = _commentZone->u.examine;
+
+	if (!data->_description) {
+		return;
+	}
+
+	// TODO: move this balloons stuff into DialogueManager and BalloonManager
+	if (getGameType() == GType_Nippon) {
+		int id;
+		if (data->_filename) {
+			if (data->_cnv == 0) {
+				data->_cnv = _disk->loadStatic(data->_filename);
+			}
+
+			_gfx->setHalfbriteMode(true);
+			_balloonMan->setSingleBalloon(data->_description, 0, 90, 0, BalloonManager::kNormalColor);
+			Common::Rect r;
+			data->_cnv->getRect(0, r);
+			id = _gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
+			_gfx->setItemFrame(id, 0);
+			id = _gfx->setItem(_char._head, 100, 152);
+			_gfx->setItemFrame(id, 0);
+		} else {
+			_balloonMan->setSingleBalloon(data->_description, 140, 10, 0, BalloonManager::kNormalColor);
+			id = _gfx->setItem(_char._talk, 190, 80);
+			_gfx->setItemFrame(id, 0);
+		}
+	} else
+	if (getGameType() == GType_BRA) {
+		_balloonMan->setSingleBalloon(data->_description, 0, 0, 1, BalloonManager::kNormalColor);
+		int id = _gfx->setItem(_char._talk, 10, 80);
+		_gfx->setItemFrame(id, 0);
+	}
+
+	_input->_inputMode = Input::kInputModeComment;
+}
+
+void Parallaction::exitCommentMode() {
+	_input->_inputMode = Input::kInputModeGame;
+
+	hideDialogueStuff();
+	_gfx->setHalfbriteMode(false);
+
+	_cmdExec->run(_commentZone->_commands, _commentZone);
+	_commentZone = nullZonePtr;
+}
+
+void Parallaction::runCommentFrame() {
+	if (_input->_inputMode != Input::kInputModeComment) {
+		return;
+	}
+
+	if (_input->getLastButtonEvent() == kMouseLeftUp) {
+		exitCommentMode();
+	}
+}
+
+
+void Parallaction::runZone(ZonePtr z) {
+	debugC(3, kDebugExec, "runZone (%s)", z->_name);
+
+	uint16 subtype = z->_type & 0xFFFF;
+
+	debugC(3, kDebugExec, "type = %x, object = %x", subtype, (z->_type & 0xFFFF0000) >> 16);
+	switch(subtype) {
+
+	case kZoneExamine:
+		enterCommentMode(z);
+		return;
+
+	case kZoneGet:
+		pickupItem(z);
+		break;
+
+	case kZoneDoor:
+		if (z->_flags & kFlagsLocked) break;
+		updateDoor(z, !(z->_flags & kFlagsClosed));
+		break;
+
+	case kZoneHear:
+		_soundMan->playSfx(z->u.hear->_name, z->u.hear->_channel, (z->_flags & kFlagsLooping) == kFlagsLooping, 60);
+		break;
+
+	case kZoneSpeak:
+		enterDialogueMode(z);
+		return;
+	}
+
+	debugC(3, kDebugExec, "runZone completed");
+
+	_cmdExec->run(z->_commands, z);
+
+	return;
+}
+
+//
+//	ZONE TYPE: DOOR
+//
+void Parallaction::updateDoor(ZonePtr z, bool close) {
+	z->_flags = close ? (z->_flags |= kFlagsClosed) : (z->_flags &= ~kFlagsClosed);
+
+	if (z->u.door->gfxobj) {
+		uint frame = (close ? 0 : 1);
+//		z->u.door->gfxobj->setFrame(frame);
+		z->u.door->gfxobj->frame = frame;
+	}
+
+	return;
+}
+
+
+
+//
+//	ZONE TYPE: GET
+//
+
+bool Parallaction::pickupItem(ZonePtr z) {
+	if (z->_flags & kFlagsFixed) {
+		return false;
+	}
+
+	int slot = addInventoryItem(z->u.get->_icon);
+	if (slot != -1) {
+		showZone(z, false);
+	}
+
+	return (slot != -1);
+}
+
+// FIXME: input coordinates must be offseted to handle scrolling!
+bool Parallaction::checkSpecialZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
+	// not a special zone
+	if ((z->getX() != -2) && (z->getX() != -3)) {
+		return false;
+	}
+
+	// WORKAROUND: this huge condition is needed because we made TypeData a collection of structs
+	// instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine,
+	// but we need to check it separately here. The same workaround is applied in freeZones.
+	if ((((z->_type & 0xFFFF) == kZoneMerge) && (((x == z->u.merge->_obj1) && (y == z->u.merge->_obj2)) || ((x == z->u.merge->_obj2) && (y == z->u.merge->_obj1)))) ||
+		(((z->_type & 0xFFFF) == kZoneGet) && ((x == z->u.get->_icon) || (y == z->u.get->_icon)))) {
+
+		// WORKAROUND for bug 2070751: special zones are only used in NS, to allow the
+		// the EXAMINE/USE action to be applied on some particular item in the inventory.
+		// The usage a verb requires at least an item match, so type can't be 0, as it
+		// was in the original code. This bug has been here since the beginning, and was
+		// hidden by label code, which filtered the bogus matches produced here.
+
+		// look for action + item match
+		if (z->_type == type)
+			return true;
+		// look for item match, but don't accept 0 types
+		if (((z->_type & 0xFFFF0000) == type) && (type))
+			return true;
+	}
+
+	return false;
+}
+
+// FIXME: input coordinates must be offseted to handle scrolling!
+bool Parallaction::checkZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
+	if (z->_flags & kFlagsRemove)
+		return false;
+
+	debugC(5, kDebugExec, "checkZoneBox for %s (type = %x, x = %i, y = %i)", z->_name, type, x, y);
+
+	Common::Rect r;
+	z->getBox(r);
+	r.right++;		// adjust border because Common::Rect doesn't include bottom-right edge
+	r.bottom++;
+
+	r.grow(-1);		// allows some tolerance for mouse click
+
+	if (!r.contains(x, y)) {
+
+		// check for special zones (items defined in common.loc)
+		if (checkSpecialZoneBox(z, type, x, y))
+			return true;
+
+		if (z->getX() != -1)
+			return false;
+		if ((int)x < _char._ani->getFrameX())
+			return false;
+		if ((int)x > (_char._ani->getFrameX() + _char._ani->width()))
+			return false;
+		if ((int)y < _char._ani->getFrameY())
+			return false;
+		if ((int)y > (_char._ani->getFrameY() + _char._ani->height()))
+			return false;
+	}
+
+	// normal Zone
+	if ((type == 0) && ((z->_type & 0xFFFF0000) == 0))
+		return true;
+	if (z->_type == type)
+		return true;
+	if ((z->_type & 0xFFFF0000) == type)
+		return true;
+
+	return false;
+}
+
+// FIXME: input coordinates must be offseted to handle scrolling!
+bool Parallaction::checkLinkedAnimBox(ZonePtr z, uint32 type, uint x, uint y) {
+	if (z->_flags & kFlagsRemove)
+		return false;
+
+	if ((z->_flags & kFlagsAnimLinked) == 0)
+		return false;
+
+	debugC(5, kDebugExec, "checkLinkedAnimBox for %s (type = %x, x = %i, y = %i)", z->_name, type, x, y);
+
+	AnimationPtr anim = z->_linkedAnim;
+	Common::Rect r(anim->getFrameX(), anim->getFrameY(), anim->getFrameX() + anim->width() + 1, anim->getFrameY() + anim->height() + 1);
+
+	if (!r.contains(x, y)) {
+		return false;
+	}
+
+	// NOTE: the implementation of the following lines is a different in the
+	// original... it is working so far, though
+	if ((type == 0) && ((z->_type & 0xFFFF0000) == 0))
+		return true;
+	if (z->_type == type)
+		return true;
+	if ((z->_type & 0xFFFF0000) == type)
+		return true;
+
+	return false;
+}
+
+ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
+	uint16 _di = y;
+	uint16 _si = x;
+
+	for (ZoneList::iterator it = _location._zones.begin(); it != _location._zones.end(); it++) {
+		if (checkLinkedAnimBox(*it, type, x, y)) {
+			return *it;
+		}
+		if (checkZoneBox(*it, type, x, y)) {
+			return *it;
+		}
+	}
+
+
+	int16 _a, _b, _c, _d, _e, _f;
+	for (AnimationList::iterator ait = _location._animations.begin(); ait != _location._animations.end(); ait++) {
+
+		AnimationPtr a = *ait;
+
+		_a = (a->_flags & kFlagsActive) ? 1 : 0;															   // _a: active Animation
+		_e = ((_si >= a->getFrameX() + a->width()) || (_si <= a->getFrameX())) ? 0 : 1;		// _e: horizontal range
+		_f = ((_di >= a->getFrameY() + a->height()) || (_di <= a->getFrameY())) ? 0 : 1;		// _f: vertical range
+
+		_b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1;										 // _b: (no type specified) AND (Animation is not the character)
+		_c = (a->_type & 0xFFFF0000) ? 0 : 1;															// _c: Animation is not an object
+		_d = ((a->_type & 0xFFFF0000) != type) ? 0 : 1;													// _d: Animation is an object of the same type
+
+		if ((_a != 0 && _e != 0 && _f != 0) && ((_b != 0 && _c != 0) || (a->_type == type) || (_d != 0))) {
+
+			return a;
+
+		}
+
+	}
+
+	return nullZonePtr;
+}
+
+
 ZonePtr Parallaction::findZone(const char *name) {
 
 	for (ZoneList::iterator it = _location._zones.begin(); it != _location._zones.end(); it++) {

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-08-31 08:27:40 UTC (rev 34221)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-08-31 09:30:16 UTC (rev 34222)
@@ -572,8 +572,6 @@
 	void		changeLocation(char *location);
 	void 		runPendingZones();
 
-	void		initPart();
-	void		freePart();
 	void		freeLocation();
 
 
@@ -594,6 +592,8 @@
 
 	void parseLocation(const char* name);
 	void loadProgram(AnimationPtr a, const char *filename);
+
+	void cleanupGame();
 };
 
 // FIXME: remove global

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-08-31 08:27:40 UTC (rev 34221)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-08-31 09:30:16 UTC (rev 34222)
@@ -122,8 +122,7 @@
 		}
 		_engineFlags &= ~kEngineReturn;
 
-		freePart();
-//		freeCharacter();
+		cleanupGame();
 	}
 
 	return 0;
@@ -140,35 +139,6 @@
 }
 
 
-void Parallaction_br::initPart() {
-
-	memset(_counters, 0, ARRAYSIZE(_counters));
-
-	_globalFlagsNames = _disk->loadTable("global");
-	_objectsNames = _disk->loadTable("objects");
-	_countersNames = _disk->loadTable("counters");
-
-	// TODO: maybe handle this into Disk
-	if (getPlatform() == Common::kPlatformPC) {
-		_char._objs = _disk->loadObjects("icone.ico");
-	} else {
-		_char._objs = _disk->loadObjects("icons.ico");
-	}
-
-}
-
-void Parallaction_br::freePart() {
-	freeLocation();
-
-	delete _globalFlagsNames;
-	delete _objectsNames;
-	delete _countersNames;
-
-	_globalFlagsNames = 0;
-	_objectsNames = 0;
-	_countersNames = 0;
-}
-
 void Parallaction_br::runPendingZones() {
 	ZonePtr z;
 
@@ -220,8 +190,21 @@
 
 }
 
+void Parallaction_br::cleanupGame() {
+	freeLocation();
 
+//		freeCharacter();
 
+	delete _globalFlagsNames;
+	delete _objectsNames;
+	delete _countersNames;
+
+	_globalFlagsNames = 0;
+	_objectsNames = 0;
+	_countersNames = 0;
+}
+
+
 void Parallaction_br::changeLocation(char *location) {
 	char *partStr = strrchr(location, '.');
 	if (partStr) {
@@ -237,7 +220,20 @@
 		}
 
 		_disk->selectArchive(_partNames[_part]);
-		initPart();
+
+		memset(_counters, 0, ARRAYSIZE(_counters));
+
+		_globalFlagsNames = _disk->loadTable("global");
+		_objectsNames = _disk->loadTable("objects");
+		_countersNames = _disk->loadTable("counters");
+
+		// TODO: maybe handle this into Disk
+		if (getPlatform() == Common::kPlatformPC) {
+			_char._objs = _disk->loadObjects("icone.ico");
+		} else {
+			_char._objs = _disk->loadObjects("icons.ico");
+		}
+
 		parseLocation("common");
 	}
 


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