aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/object.cpp12
-rw-r--r--engines/prince/object.h2
-rw-r--r--engines/prince/prince.cpp33
3 files changed, 32 insertions, 15 deletions
diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp
index 94d55b5716..86d4238bc0 100644
--- a/engines/prince/object.cpp
+++ b/engines/prince/object.cpp
@@ -32,8 +32,8 @@
namespace Prince {
-Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _mask(0),
- _zoomInSource(0), _zoomInLen(0), _zoomInAddr(0), _zoomInTime(0)
+Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _mask(0), _width(0),
+ _height(0), _zoomInSource(0), _zoomInLen(0), _zoomInAddr(0), _zoomInTime(0)
{
}
@@ -47,12 +47,12 @@ Object::~Object() {
void Object::loadSurface(Common::SeekableReadStream &stream) {
stream.skip(4);
- int width = stream.readUint16LE();
- int height = stream.readUint16LE();
+ _width = stream.readUint16LE();
+ _height = stream.readUint16LE();
_surface = new Graphics::Surface();
- _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+ _surface->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
- for (int h = 0; h < _surface->h; ++h) {
+ for (int h = 0; h < _surface->h; h++) {
stream.read(_surface->getBasePtr(0, h), _surface->w);
}
}
diff --git a/engines/prince/object.h b/engines/prince/object.h
index ea1ad9dc0d..1fb7465a0d 100644
--- a/engines/prince/object.h
+++ b/engines/prince/object.h
@@ -36,6 +36,8 @@ public:
int32 _x;
int32 _y;
int32 _z;
+ uint16 _width;
+ uint16 _height;
int32 _mask; // or flags
int32 _zoomInSource;
int32 _zoomInLen;
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 80e6177987..83a471a6ed 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -815,7 +815,7 @@ int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobLis
const Mob& mob = *it;
mobNumber++;
- if (mob._visible != 0) { // 0 is for visible
+ if (mob._visible) {
continue;
}
@@ -830,18 +830,35 @@ int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobLis
break;
case 3:
//mob_obj
+ if (mob._mask < _objList.size()) {
+ Object &obj = *_objList[mob._mask];
+ Common::Rect objectRect(obj._x, obj._y, obj._x + obj._width, obj._y + obj._height);
+ if (objectRect.contains(mousePosCamera)) {
+ Graphics::Surface *objSurface = obj.getSurface();
+ byte *pixel = (byte *)objSurface->getBasePtr(mousePosCamera.x - obj._x, mousePosCamera.y - obj._y);
+ if (*pixel != 255) {
+ break;
+ }
+ }
+ }
continue;
break;
case 2:
case 5:
//check_ba_mob
- if (_backAnimList[mob._mask]._seq._current != 0) {
+ if (mob._mask < _backAnimList.size()) {
int currentAnim = _backAnimList[mob._mask]._seq._currRelative;
Anim &backAnim = _backAnimList[mob._mask].backAnims[currentAnim];
- if (backAnim._state == 0) {
+ if (!backAnim._state) {
Common::Rect backAnimRect(backAnim._currX, backAnim._currY, backAnim._currX + backAnim._currW, backAnim._currY + backAnim._currH);
if (backAnimRect.contains(mousePosCamera)) {
- break;
+ int phase = backAnim._showFrame;
+ int phaseFrameIndex = backAnim._animData->getPhaseFrameIndex(phase);
+ Graphics::Surface *backAnimSurface = backAnim._animData->getFrame(phaseFrameIndex);
+ byte *pixel = (byte *)backAnimSurface->getBasePtr(mousePosCamera.x - backAnim._currX, mousePosCamera.y - backAnim._currY);
+ if (*pixel != 255) {
+ break;
+ }
}
}
}
@@ -1661,11 +1678,9 @@ void PrinceEngine::prepareInventoryToView() {
if (item < _mainHero->_inventory.size()) {
int itemNr = _mainHero->_inventory[item];
tempMobItem._visible = 0;
- tempMobItem._mask = itemNr; // itemNr - 1??
- tempMobItem._rect.left = currInvX + _picWindowX; //picWindowX2 ?
- tempMobItem._rect.right = currInvX + _picWindowX + _invLineW - 1; // picWindowX2 ?
- tempMobItem._rect.top = currInvY;
- tempMobItem._rect.bottom = currInvY + _invLineH - 1;
+ tempMobItem._mask = itemNr;
+ tempMobItem._rect = Common::Rect(currInvX + _picWindowX, currInvY, currInvX + _picWindowX + _invLineW - 1, currInvY + _invLineH - 1);
+ tempMobItem._type = 0; // to work with checkMob()
tempMobItem._name = "";
tempMobItem._examText = "";