Skip to content

Commit

Permalink
PRINCE: Object, checkMob() update, prepareInventoryToView() fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 29, 2014
1 parent dc40068 commit 7ebcbea
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
12 changes: 6 additions & 6 deletions engines/prince/object.cpp
Expand Up @@ -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)
{
}

Expand All @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions engines/prince/object.h
Expand Up @@ -36,6 +36,8 @@ class Object {
int32 _x;
int32 _y;
int32 _z;
uint16 _width;
uint16 _height;
int32 _mask; // or flags
int32 _zoomInSource;
int32 _zoomInLen;
Expand Down
33 changes: 24 additions & 9 deletions engines/prince/prince.cpp
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
}
}
Expand Down Expand Up @@ -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 = "";
Expand Down

0 comments on commit 7ebcbea

Please sign in to comment.