2013-08-11 13:39:05 +03:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fullpipe/fullpipe.h"
|
|
|
|
|
|
|
|
#include "fullpipe/interaction.h"
|
|
|
|
#include "fullpipe/gameloader.h"
|
2013-09-05 22:59:39 +03:00
|
|
|
#include "fullpipe/statics.h"
|
2013-08-11 13:39:05 +03:00
|
|
|
|
|
|
|
namespace Fullpipe {
|
|
|
|
|
|
|
|
int handleObjectInteraction(GameObject *subject, GameObject *object, int invId) {
|
|
|
|
return getGameLoaderInteractionController()->handleInteraction(subject, object, invId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CInteractionController::load(MfcArchive &file) {
|
|
|
|
debug(5, "CInteractionController::load()");
|
|
|
|
|
|
|
|
return _interactions.load(file);
|
|
|
|
}
|
|
|
|
|
2013-09-05 00:13:16 +03:00
|
|
|
int static_compSceneId = 0;
|
|
|
|
|
|
|
|
bool CInteractionController::compareInteractions(const void *p1, const void *p2) {
|
2013-09-06 15:50:49 +03:00
|
|
|
const CInteraction *i1 = (const CInteraction *)p1;
|
|
|
|
const CInteraction *i2 = (const CInteraction *)p2;
|
2013-09-05 00:13:16 +03:00
|
|
|
|
2013-09-06 15:58:05 +03:00
|
|
|
if (i2->_sceneId < i1->_sceneId) {
|
|
|
|
if (i1->_sceneId != static_compSceneId)
|
2013-09-05 00:13:16 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (i2->_sceneId != i1->_sceneId) {
|
|
|
|
if (i1->_sceneId > 0 && i2->_sceneId == static_compSceneId)
|
|
|
|
return false;
|
|
|
|
if (i2->_sceneId != i1->_sceneId)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (i2->_objectId3 == -1)
|
2013-09-06 16:17:37 +03:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (i1->_objectId3 == i2->_objectId3)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (i1->_objectId3 == -1 || i1->_objectId3 == -2)
|
|
|
|
return false;
|
2013-09-05 00:13:16 +03:00
|
|
|
|
2013-09-06 16:17:37 +03:00
|
|
|
return true;
|
2013-09-05 00:13:16 +03:00
|
|
|
}
|
|
|
|
|
2013-08-11 13:39:05 +03:00
|
|
|
void CInteractionController::sortInteractions(int sceneId) {
|
2013-09-05 00:13:16 +03:00
|
|
|
static_compSceneId = sceneId;
|
|
|
|
|
|
|
|
Common::sort(_interactions.begin(), _interactions.end(), CInteractionController::compareInteractions);
|
2013-08-11 13:39:05 +03:00
|
|
|
}
|
|
|
|
|
2013-09-07 22:57:56 +03:00
|
|
|
bool CInteractionController::handleInteraction(GameObject *subj, GameObject *obj, int invId) {
|
|
|
|
return true;
|
2013-08-11 13:39:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CInteraction::CInteraction() {
|
|
|
|
_objectId1 = 0;
|
|
|
|
_objectId2 = 0;
|
|
|
|
_staticsId1 = 0;
|
|
|
|
_objectId3 = 0;
|
|
|
|
_objectState2 = 0;
|
|
|
|
_objectState1 = 0;
|
|
|
|
_messageQueue = 0;
|
|
|
|
_flags = 0;
|
|
|
|
_yOffs = 0;
|
|
|
|
_xOffs = 0;
|
|
|
|
_staticsId2 = 0;
|
|
|
|
_field_28 = 0;
|
|
|
|
_sceneId = -1;
|
2013-08-14 21:11:12 +03:00
|
|
|
_actionName = 0;
|
2013-08-11 13:39:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CInteraction::load(MfcArchive &file) {
|
|
|
|
debug(5, "CInteraction::load()");
|
|
|
|
|
|
|
|
_objectId1 = file.readUint16LE();
|
|
|
|
_objectId2 = file.readUint16LE();
|
|
|
|
_staticsId1 = file.readUint16LE();
|
|
|
|
_staticsId2 = file.readUint16LE();
|
|
|
|
_objectId3 = file.readUint16LE();
|
|
|
|
_objectState2 = file.readUint32LE();
|
|
|
|
_objectState1 = file.readUint32LE();
|
|
|
|
_xOffs = file.readUint32LE();
|
|
|
|
_yOffs = file.readUint32LE();
|
|
|
|
_sceneId = file.readUint32LE();
|
|
|
|
_flags = file.readUint32LE();
|
|
|
|
_actionName = file.readPascalString();
|
|
|
|
|
|
|
|
_messageQueue = (MessageQueue *)file.readClass();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-05 00:13:16 +03:00
|
|
|
bool CInteraction::canInteract(GameObject *obj1, GameObject *obj2, int invId) {
|
2013-09-05 22:59:39 +03:00
|
|
|
if (_sceneId > 0 && g_fullpipe->_currentScene && g_fullpipe->_currentScene->_sceneId != _sceneId)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (_flags & 0x20000)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!obj2)
|
|
|
|
return false;
|
|
|
|
if (obj2->_id != _objectId1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ((_flags & 8) && (_flags & 1)) {
|
|
|
|
if (!obj2->_objtype != kObjTypeStaticANIObject)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
StaticANIObject *st = (StaticANIObject *)obj2;
|
|
|
|
|
|
|
|
if (!st->_statics)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (st->_statics->_staticsId != _staticsId1) {
|
|
|
|
if (_staticsId1)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_objectId3 != invId && _objectId3 != -1 && _objectId3 != -2) || (!invId && _objectId3 == -2))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (_objectState1) {
|
|
|
|
if (_flags & 0x10) {
|
|
|
|
if ((g_fullpipe->getObjectState(obj1->getName()) & _objectState1) == 0)
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (g_fullpipe->getObjectState(obj1->getName()) != _objectState1)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_objectState2) {
|
|
|
|
if (_flags & 0x10) {
|
|
|
|
if ((g_fullpipe->getObjectState(obj2->getName()) & _objectState2) == 0)
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (g_fullpipe->getObjectState(obj2->getName()) != _objectState2)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_objectId2 && (!obj1 || _objectId2 != obj1->_id))
|
|
|
|
return false;
|
|
|
|
|
2013-09-05 00:13:16 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-07 22:57:56 +03:00
|
|
|
bool CInteraction::isOverlapping(StaticANIObject *subj, StaticANIObject *obj) {
|
|
|
|
if (abs(_xOffs + obj->_ox - subj->_ox) <= 1
|
|
|
|
&& abs(obj->_oy + _yOffs - subj->_oy) <= 1) {
|
|
|
|
if (!this->_staticsId2 || subj->_statics != 0 && subj->_statics->_staticsId == _staticsId2) {
|
|
|
|
if (!_staticsId1 || !(_flags & 1) || obj->_statics != 0 && obj->_statics->_staticsId == _staticsId1)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-11 13:39:05 +03:00
|
|
|
bool EntranceInfo::load(MfcArchive &file) {
|
|
|
|
debug(5, "EntranceInfo::load()");
|
|
|
|
|
|
|
|
_sceneId = file.readUint32LE();
|
|
|
|
_field_4 = file.readUint32LE();
|
|
|
|
_messageQueueId = file.readUint32LE();
|
|
|
|
file.read(_gap_C, 292); // FIXME, Ugh
|
|
|
|
_field_130 = file.readUint32LE();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Fullpipe
|