2013-06-16 12:11:18 +00: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 "common/file.h"
|
|
|
|
#include "common/array.h"
|
|
|
|
#include "common/list.h"
|
|
|
|
|
|
|
|
#include "fullpipe/objects.h"
|
2013-09-28 11:15:46 +00:00
|
|
|
#include "fullpipe/statics.h"
|
2013-12-05 20:41:02 +00:00
|
|
|
#include "fullpipe/gameloader.h"
|
2013-06-16 12:11:18 +00:00
|
|
|
#include "fullpipe/motion.h"
|
2013-09-17 20:00:33 +00:00
|
|
|
#include "fullpipe/messages.h"
|
2013-06-16 12:11:18 +00:00
|
|
|
|
|
|
|
namespace Fullpipe {
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool MotionController::load(MfcArchive &file) {
|
2013-06-16 12:11:18 +00:00
|
|
|
// Is originally empty file.readClass();
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
debug(5, "MotionController::load()");
|
2013-06-16 12:11:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-18 21:23:32 +00:00
|
|
|
void MotionController::enableLinks(const char *linkName, bool enable) {
|
|
|
|
warning("STUB: MotionController::enableLinks()");
|
|
|
|
}
|
|
|
|
|
2013-12-19 21:00:23 +00:00
|
|
|
MovGraphLink *MotionController::getLinkByName(const char *name) {
|
2013-12-29 21:50:15 +00:00
|
|
|
if (_objtype == kObjTypeMctlCompound) {
|
|
|
|
MctlCompound *obj = (MctlCompound *)this;
|
|
|
|
|
|
|
|
for (uint i = 0; i < obj->getMotionControllerCount(); i++) {
|
|
|
|
MotionController *con = obj->getMotionController(i);
|
|
|
|
|
|
|
|
if (con->_objtype == kObjTypeMovGraph) {
|
|
|
|
MovGraph *gr = (MovGraph *)con;
|
|
|
|
|
|
|
|
for (ObList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
|
|
|
|
assert(((CObject *)*l)->_objtype == kObjTypeMovGraphLink);
|
|
|
|
|
|
|
|
MovGraphLink *lnk = (MovGraphLink *)*l;
|
|
|
|
|
|
|
|
if (!strcmp(lnk->_name, name))
|
|
|
|
return lnk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_objtype == kObjTypeMovGraph) {
|
|
|
|
MovGraph *gr = (MovGraph *)this;
|
|
|
|
|
|
|
|
for (ObList::iterator l = gr->_links.begin(); l != gr->_links.end(); ++l) {
|
|
|
|
assert(((CObject *)*l)->_objtype == kObjTypeMovGraphLink);
|
|
|
|
|
|
|
|
MovGraphLink *lnk = (MovGraphLink *)*l;
|
|
|
|
|
|
|
|
if (!strcmp(lnk->_name, name))
|
|
|
|
return lnk;
|
|
|
|
}
|
|
|
|
}
|
2013-12-19 21:00:23 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool MctlCompound::load(MfcArchive &file) {
|
|
|
|
debug(5, "MctlCompound::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2013-06-16 12:11:18 +00:00
|
|
|
int count = file.readUint32LE();
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
debug(6, "MctlCompound::count = %d", count);
|
2013-06-16 12:11:18 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2013-07-06 19:56:11 +00:00
|
|
|
debug(6, "CompoundArray[%d]", i);
|
2013-09-28 08:21:13 +00:00
|
|
|
MctlCompoundArrayItem *obj = new MctlCompoundArrayItem();
|
|
|
|
|
|
|
|
obj->_motionControllerObj = (MotionController *)file.readClass();
|
2013-06-16 12:11:18 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
int count1 = file.readUint32LE();
|
2013-06-18 21:07:28 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
debug(6, "ConnectionPoint::count: %d", count1);
|
|
|
|
for (int j = 0; j < count1; j++) {
|
|
|
|
debug(6, "ConnectionPoint[%d]", j);
|
2013-09-18 15:04:36 +00:00
|
|
|
MctlConnectionPoint *obj1 = (MctlConnectionPoint *)file.readClass();
|
2013-06-18 21:07:28 +00:00
|
|
|
|
2013-10-04 20:14:09 +00:00
|
|
|
obj->_connectionPoints.push_back(obj1);
|
2013-07-06 19:56:11 +00:00
|
|
|
}
|
2013-06-18 21:07:28 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
obj->_field_20 = file.readUint32LE();
|
|
|
|
obj->_field_24 = file.readUint32LE();
|
2013-06-18 21:07:28 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
debug(6, "graphReact");
|
2013-09-18 15:04:36 +00:00
|
|
|
obj->_movGraphReactObj = (MovGraphReact *)file.readClass();
|
2013-06-18 21:07:28 +00:00
|
|
|
|
2013-09-27 19:16:15 +00:00
|
|
|
_motionControllers.push_back(obj);
|
2013-06-16 12:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-28 10:06:06 +00:00
|
|
|
void MctlCompound::addObject(StaticANIObject *obj) {
|
|
|
|
for (uint i = 0; i < _motionControllers.size(); i++)
|
|
|
|
_motionControllers[i]->_motionControllerObj->addObject(obj);
|
2013-09-24 20:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int MctlCompound::removeObject(StaticANIObject *obj) {
|
|
|
|
warning("STUB: MctlCompound::removeObject()");
|
|
|
|
|
|
|
|
return 0;
|
2013-07-22 15:46:03 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
void MctlCompound::initMovGraph2() {
|
2013-09-25 21:07:31 +00:00
|
|
|
if (_objtype != kObjTypeMctlCompound)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (uint i = 0; i < _motionControllers.size(); i++) {
|
|
|
|
if (_motionControllers[i]->_motionControllerObj->_objtype != kObjTypeMovGraph)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
MovGraph *gr = (MovGraph *)_motionControllers[i]->_motionControllerObj;
|
|
|
|
|
2013-09-27 19:16:15 +00:00
|
|
|
MovGraph2 *newgr = new MovGraph2();
|
2013-09-25 21:07:31 +00:00
|
|
|
|
2013-09-27 19:16:15 +00:00
|
|
|
newgr->_links = gr->_links;
|
|
|
|
newgr->_nodes = gr->_nodes;
|
2013-09-25 21:07:31 +00:00
|
|
|
|
|
|
|
gr->_links.clear();
|
|
|
|
gr->_nodes.clear();
|
|
|
|
|
|
|
|
delete gr;
|
|
|
|
|
|
|
|
_motionControllers[i]->_motionControllerObj = newgr;
|
|
|
|
}
|
2013-07-24 21:34:15 +00:00
|
|
|
}
|
|
|
|
|
2013-09-24 20:24:33 +00:00
|
|
|
void MctlCompound::freeItems() {
|
2013-10-30 20:24:37 +00:00
|
|
|
for (uint i = 0; i < _motionControllers.size(); i++)
|
|
|
|
_motionControllers[i]->_motionControllerObj->freeItems();
|
2013-09-24 20:24:33 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
MessageQueue *MctlCompound::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
2013-09-18 15:04:36 +00:00
|
|
|
warning("STUB: MctlCompound::method34()");
|
2013-09-08 20:53:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-16 21:37:04 +00:00
|
|
|
MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
2013-10-03 22:25:22 +00:00
|
|
|
int match1 = -1;
|
|
|
|
int match2 = -1;
|
|
|
|
|
|
|
|
if (!subj)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (uint i = 0; i < _motionControllers.size(); i++) {
|
|
|
|
if (_motionControllers[i]->_movGraphReactObj) {
|
|
|
|
if (_motionControllers[i]->_movGraphReactObj->pointInRegion(subj->_ox, subj->_oy)) {
|
|
|
|
match1 = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match1 == -1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (uint i = 0; i < _motionControllers.size(); i++) {
|
|
|
|
if (_motionControllers[i]->_movGraphReactObj) {
|
|
|
|
if (_motionControllers[i]->_movGraphReactObj->pointInRegion(xpos, ypos)) {
|
|
|
|
match2 = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match2 == -1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (match1 == match2)
|
2013-10-16 21:37:04 +00:00
|
|
|
return _motionControllers[match1]->_motionControllerObj->doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId);
|
2013-10-03 22:25:22 +00:00
|
|
|
|
|
|
|
MctlConnectionPoint *closestP = findClosestConnectionPoint(subj->_ox, subj->_oy, match1, xpos, ypos, match2, &match2);
|
|
|
|
|
|
|
|
if (!closestP)
|
|
|
|
return 0;
|
|
|
|
|
2013-10-16 21:37:04 +00:00
|
|
|
MessageQueue *mq = _motionControllers[match1]->_motionControllerObj->doWalkTo(subj, closestP->_connectionX, closestP->_connectionY, 1, closestP->_field_14);
|
2013-10-03 22:25:22 +00:00
|
|
|
|
|
|
|
ExCommand *ex;
|
|
|
|
|
2013-10-04 20:14:09 +00:00
|
|
|
if (mq) {
|
2013-10-03 22:25:22 +00:00
|
|
|
for (uint i = 0; i < closestP->_messageQueueObj->getCount(); i++) {
|
2014-01-04 15:28:17 +00:00
|
|
|
ex = closestP->_messageQueueObj->getExCommandByIndex(i)->createClone();
|
2013-10-04 20:14:09 +00:00
|
|
|
ex->_excFlags |= 2;
|
2013-12-11 20:51:49 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-10-03 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ex = new ExCommand(subj->_id, 51, 0, xpos, ypos, 0, 1, 0, 0, 0);
|
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
ex->_field_20 = fuzzyMatch;
|
2013-10-03 22:25:22 +00:00
|
|
|
ex->_keyCode = subj->_okeyCode;
|
|
|
|
ex->_excFlags |= 2;
|
|
|
|
|
2013-12-11 20:51:49 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-10-03 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
2013-10-04 20:14:09 +00:00
|
|
|
return mq;
|
|
|
|
}
|
|
|
|
|
2013-12-15 00:46:22 +00:00
|
|
|
MctlCompoundArrayItem::~MctlCompoundArrayItem() {
|
|
|
|
delete _movGraphReactObj;
|
|
|
|
delete _motionControllerObj;
|
|
|
|
}
|
|
|
|
|
2013-12-05 20:41:02 +00:00
|
|
|
MctlLadder::MctlLadder() {
|
2013-12-14 12:53:15 +00:00
|
|
|
_width = 0;
|
|
|
|
_ladderX = 0;
|
2013-12-08 13:25:47 +00:00
|
|
|
_height = 0;
|
|
|
|
_ladderY = 0;
|
2013-12-05 20:41:02 +00:00
|
|
|
_ladder_field_14 = 0;
|
|
|
|
|
|
|
|
_ladder_field_20 = 0;
|
|
|
|
_ladder_field_24 = 0;
|
|
|
|
}
|
|
|
|
|
2013-12-06 21:36:31 +00:00
|
|
|
MctlLadder::~MctlLadder() {
|
|
|
|
freeItems();
|
|
|
|
}
|
|
|
|
|
2013-12-05 20:44:32 +00:00
|
|
|
int MctlLadder::collisionDetection(StaticANIObject *man) {
|
2013-12-08 13:11:41 +00:00
|
|
|
if (findObjectPos(man) < 0)
|
|
|
|
return 0;
|
2013-12-05 20:44:32 +00:00
|
|
|
|
2013-12-08 13:11:41 +00:00
|
|
|
double delta;
|
|
|
|
|
2013-12-08 13:25:47 +00:00
|
|
|
if ((double)(man->_oy - _ladderY) / (double)_height < 0.0)
|
2013-12-08 13:11:41 +00:00
|
|
|
delta = -0.5;
|
|
|
|
else
|
|
|
|
delta = 0.5;
|
|
|
|
|
2013-12-08 13:25:47 +00:00
|
|
|
int res = (int)((double)(man->_oy - _ladderY) / (double)_height + delta);
|
2013-12-08 13:11:41 +00:00
|
|
|
|
|
|
|
if (res < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return res;
|
2013-12-05 20:44:32 +00:00
|
|
|
}
|
|
|
|
|
2013-12-06 20:59:42 +00:00
|
|
|
void MctlLadder::addObject(StaticANIObject *obj) {
|
2013-12-06 21:22:28 +00:00
|
|
|
if (findObjectPos(obj) < 0) {
|
|
|
|
MctlLadderMovement *movement = new MctlLadderMovement;
|
|
|
|
|
|
|
|
if (initMovement(obj, movement)) {
|
|
|
|
_mgm.addItem(obj->_id);
|
|
|
|
_movements.push_back(movement);
|
|
|
|
} else {
|
|
|
|
delete movement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int MctlLadder::findObjectPos(StaticANIObject *obj) {
|
|
|
|
int res = -1;
|
|
|
|
|
|
|
|
for (Common::List<MctlLadderMovement *>::iterator it = _movements.begin(); it != _movements.end(); ++it, ++res)
|
|
|
|
if ((*it)->objId == obj->_id)
|
|
|
|
break;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement) {
|
2013-12-20 14:08:02 +00:00
|
|
|
GameVar *v = g_fp->getGameLoaderGameVar()->getSubVarByName(ani->getName());
|
2013-12-06 21:22:28 +00:00
|
|
|
|
|
|
|
if (!v)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
v = v->getSubVarByName("Test_Ladder");
|
|
|
|
|
|
|
|
if (!v)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
movement->staticIdsSize = 6;
|
|
|
|
movement->movVars = new MctlLadderMovementVars;
|
|
|
|
movement->staticIds = new int[movement->staticIdsSize];
|
|
|
|
|
|
|
|
v = v->getSubVarByName("Up");
|
|
|
|
|
|
|
|
if (!v)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
movement->movVars->varUpStart = v->getSubVarAsInt("Start");
|
|
|
|
movement->movVars->varUpGo = v->getSubVarAsInt("Go");
|
|
|
|
movement->movVars->varUpStop = v->getSubVarAsInt("Stop");
|
|
|
|
|
|
|
|
movement->staticIds[0] = ani->getMovementById(movement->movVars->varUpStart)->_staticsObj1->_staticsId;
|
|
|
|
movement->staticIds[2] = ani->getMovementById(movement->movVars->varUpGo)->_staticsObj1->_staticsId;
|
|
|
|
|
|
|
|
v = v->getSubVarByName("Down");
|
|
|
|
|
|
|
|
if (!v)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
movement->movVars->varDownStart = v->getSubVarAsInt("Start");
|
|
|
|
movement->movVars->varDownGo = v->getSubVarAsInt("Go");
|
|
|
|
movement->movVars->varDownStop = v->getSubVarAsInt("Stop");
|
|
|
|
|
|
|
|
movement->staticIds[1] = ani->getMovementById(movement->movVars->varDownStart)->_staticsObj1->_staticsId;
|
|
|
|
movement->staticIds[3] = ani->getMovementById(movement->movVars->varDownGo)->_staticsObj1->_staticsId;
|
|
|
|
|
|
|
|
movement->objId = ani->_id;
|
|
|
|
|
|
|
|
return true;
|
2013-12-06 20:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MctlLadder::freeItems() {
|
2013-12-06 21:36:31 +00:00
|
|
|
_mgm.clear();
|
|
|
|
|
|
|
|
for (Common::List<MctlLadderMovement *>::iterator it = _movements.begin(); it != _movements.end(); ++it) {
|
|
|
|
delete (*it)->movVars;
|
|
|
|
delete [] (*it)->staticIds;
|
|
|
|
}
|
|
|
|
|
|
|
|
_movements.clear();
|
2013-12-06 20:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueue *MctlLadder::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
2013-12-15 11:50:35 +00:00
|
|
|
MessageQueue *mq = doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId);
|
|
|
|
|
|
|
|
if (mq) {
|
|
|
|
if (mq->chain(subj))
|
|
|
|
return mq;
|
|
|
|
}
|
2013-12-06 20:59:42 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueue *MctlLadder::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
|
|
|
warning("STUB: MctlLadder::doWalkTo()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-14 12:49:59 +00:00
|
|
|
MessageQueue *MctlLadder::controllerWalkTo(StaticANIObject *ani, int off) {
|
2013-12-14 12:53:15 +00:00
|
|
|
return doWalkTo(ani, _ladderX + off * _width, _ladderY + off * _height, 1, 0);
|
2013-12-14 12:49:59 +00:00
|
|
|
}
|
|
|
|
|
2013-10-04 20:14:09 +00:00
|
|
|
MctlConnectionPoint *MctlCompound::findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIndex, int *minDistancePtr) {
|
|
|
|
warning("STUB: MctlCompound::findClosestConnectionPoint()");
|
|
|
|
|
|
|
|
return 0;
|
2013-09-08 20:53:02 +00:00
|
|
|
}
|
|
|
|
|
2013-12-23 22:08:18 +00:00
|
|
|
void MctlCompound::replaceNodeX(int from, int to) {
|
|
|
|
warning("STUB: MctlCompound::replaceNodeX()");
|
|
|
|
}
|
|
|
|
|
2013-12-15 00:46:22 +00:00
|
|
|
MctlConnectionPoint::MctlConnectionPoint() {
|
|
|
|
_connectionX = 0;
|
|
|
|
_connectionY = 0;
|
|
|
|
_field_C = 0;
|
|
|
|
_field_10 = 0;
|
|
|
|
_field_14 = 0;
|
|
|
|
_field_16 = 0;
|
|
|
|
_messageQueueObj = 0;
|
|
|
|
_motionControllerObj = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MctlConnectionPoint::~MctlConnectionPoint() {
|
|
|
|
delete _messageQueueObj;
|
|
|
|
}
|
|
|
|
|
2013-12-21 20:36:19 +00:00
|
|
|
MovInfo1::MovInfo1(MovInfo1 *src) {
|
2014-01-04 21:16:56 +00:00
|
|
|
index = src->index;
|
2013-12-21 20:36:19 +00:00
|
|
|
pt1 = src->pt1;
|
|
|
|
pt2 = src->pt2;
|
|
|
|
distance1 = src->distance1;
|
|
|
|
distance2 = src->distance2;
|
|
|
|
subIndex = src->subIndex;
|
|
|
|
item1Index = src->item1Index;
|
|
|
|
items = src->items;
|
|
|
|
itemsCount = src->itemsCount;
|
|
|
|
flags = src->flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MovInfo1::clear() {
|
2014-01-04 21:16:56 +00:00
|
|
|
index = 0;
|
2013-12-21 20:36:19 +00:00
|
|
|
pt1.x = pt1.y = 0;
|
|
|
|
pt2.x = pt2.y = 0;
|
|
|
|
distance1 = 0;
|
|
|
|
distance2 = 0;
|
|
|
|
subIndex = 0;
|
|
|
|
item1Index = 0;
|
|
|
|
items.clear();
|
|
|
|
itemsCount = 0;
|
|
|
|
flags = 0;
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool MctlCompoundArray::load(MfcArchive &file) {
|
|
|
|
debug(5, "MctlCompoundArray::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2013-06-16 12:11:18 +00:00
|
|
|
int count = file.readUint32LE();
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
debug(0, "MctlCompoundArray::count = %d", count);
|
2013-06-16 12:11:18 +00:00
|
|
|
|
2013-06-18 21:27:17 +00:00
|
|
|
assert(0);
|
|
|
|
|
2013-06-16 12:11:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-01 19:56:50 +00:00
|
|
|
MovGraphItem::MovGraphItem() {
|
|
|
|
ani = 0;
|
|
|
|
field_4 = 0;
|
|
|
|
field_8 = 0;
|
|
|
|
field_C = 0;
|
|
|
|
field_10 = 0;
|
|
|
|
field_14 = 0;
|
|
|
|
field_18 = 0;
|
|
|
|
field_1C = 0;
|
|
|
|
field_20 = 0;
|
|
|
|
field_24 = 0;
|
|
|
|
items = 0;
|
|
|
|
count = 0;
|
|
|
|
field_30 = 0;
|
|
|
|
field_34 = 0;
|
|
|
|
field_38 = 0;
|
|
|
|
field_3C = 0;
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
int MovGraph_messageHandler(ExCommand *cmd);
|
2013-09-17 20:00:33 +00:00
|
|
|
|
2013-09-18 18:19:37 +00:00
|
|
|
int MovGraphCallback(int a1, int a2, int a3) {
|
|
|
|
warning("STUB: MovgraphCallback");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
MovGraph::MovGraph() {
|
2013-09-18 18:19:37 +00:00
|
|
|
_callback1 = MovGraphCallback;
|
2013-07-06 19:56:11 +00:00
|
|
|
_field_44 = 0;
|
2013-09-18 15:04:36 +00:00
|
|
|
insertMessageHandler(MovGraph_messageHandler, getMessageHandlersCount() - 1, 129);
|
2013-09-17 20:00:33 +00:00
|
|
|
|
|
|
|
_objtype = kObjTypeMovGraph;
|
2013-06-16 12:11:18 +00:00
|
|
|
}
|
|
|
|
|
2014-01-08 16:48:34 +00:00
|
|
|
MovGraph::~MovGraph() {
|
|
|
|
warning("STUB: MovGraph::~MovGraph()");
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool MovGraph::load(MfcArchive &file) {
|
|
|
|
debug(5, "MovGraph::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_links.load(file);
|
|
|
|
_nodes.load(file);
|
2013-06-16 12:11:18 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
return true;
|
2013-06-16 12:11:18 +00:00
|
|
|
}
|
|
|
|
|
2013-09-28 10:06:06 +00:00
|
|
|
void MovGraph::addObject(StaticANIObject *obj) {
|
2013-10-01 19:56:50 +00:00
|
|
|
_mgm.clear();
|
|
|
|
_mgm.addItem(obj->_id);
|
|
|
|
|
|
|
|
for (uint i = 0; i < _items.size(); i++)
|
|
|
|
if (_items[i]->ani == obj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
MovGraphItem *item = new MovGraphItem();
|
|
|
|
|
|
|
|
item->ani = obj;
|
|
|
|
|
|
|
|
_items.push_back(item);
|
|
|
|
|
|
|
|
_mgm.addItem(obj->_id); // FIXME: Is it really needed?
|
2013-07-22 15:46:03 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 19:16:15 +00:00
|
|
|
int MovGraph::removeObject(StaticANIObject *obj) {
|
|
|
|
warning("STUB: MovGraph::removeObject()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MovGraph::freeItems() {
|
|
|
|
warning("STUB: MovGraph::freeItems()");
|
|
|
|
}
|
|
|
|
|
|
|
|
int MovGraph::method28() {
|
|
|
|
warning("STUB: MovGraph::method28()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-18 22:43:19 +00:00
|
|
|
int MovGraph::method2C(StaticANIObject *obj, int x, int y) {
|
|
|
|
obj->setOXY(x, y);
|
|
|
|
return method3C(obj, 1);
|
2013-09-27 19:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
MessageQueue *MovGraph::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
2013-09-27 19:16:15 +00:00
|
|
|
warning("STUB: MovGraph::method34()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MovGraph::changeCallback() {
|
|
|
|
warning("STUB: MovGraph::changeCallback()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-18 22:43:19 +00:00
|
|
|
int MovGraph::method3C(StaticANIObject *ani, int flag) {
|
2013-09-27 19:16:15 +00:00
|
|
|
warning("STUB: MovGraph::method3C()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MovGraph::method44() {
|
|
|
|
warning("STUB: MovGraph::method44()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-16 21:37:04 +00:00
|
|
|
MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
|
|
|
warning("STUB: MovGraph::doWalkTo()");
|
2013-09-27 19:16:15 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MovGraph::method50() {
|
|
|
|
warning("STUB: MovGraph::method50()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzzyMatch) {
|
2013-09-29 20:08:45 +00:00
|
|
|
int n1x = link->_movGraphNode1->_x;
|
|
|
|
int n1y = link->_movGraphNode1->_y;
|
|
|
|
int n2x = link->_movGraphNode2->_x;
|
|
|
|
int n2y = link->_movGraphNode2->_y;
|
|
|
|
double dist1x = (double)(point->x - n1x);
|
|
|
|
double dist1y = (double)(n1y - point->y);
|
|
|
|
double dist2x = (double)(n2x - n1x);
|
|
|
|
double dist2y = (double)(n2y - n1y);
|
|
|
|
double dist1 = sqrt(dist1y * dist1y + dist1x * dist1x);
|
|
|
|
double dist2 = ((double)(n1y - n2y) * dist1y + dist2x * dist1x) / link->_distance / dist1;
|
|
|
|
double distm = dist2 * dist1;
|
|
|
|
double res = sqrt(1.0 - dist2 * dist2) * dist1;
|
|
|
|
|
|
|
|
if (dist2 <= 0.0 || distm >= link->_distance) {
|
2013-10-15 06:10:57 +00:00
|
|
|
if (fuzzyMatch) {
|
2013-09-29 20:08:45 +00:00
|
|
|
if (dist2 > 0.0) {
|
|
|
|
if (distm >= link->_distance) {
|
|
|
|
point->x = n2x;
|
|
|
|
point->y = n2y;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
point->x = n1x;
|
|
|
|
point->y = n1y;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return -1.0;
|
|
|
|
}
|
|
|
|
} else {
|
2013-12-18 08:16:19 +00:00
|
|
|
point->x = (int)(n1x + (dist2x * distm / link->_distance));
|
|
|
|
point->y = (int)(n1y + (dist2y * distm / link->_distance));
|
2013-09-29 20:08:45 +00:00
|
|
|
}
|
2013-09-17 20:00:33 +00:00
|
|
|
|
2013-09-29 20:08:45 +00:00
|
|
|
return res;
|
2013-09-17 20:00:33 +00:00
|
|
|
}
|
|
|
|
|
2013-10-22 21:49:55 +00:00
|
|
|
void MovGraph::calcNodeDistancesAndAngles() {
|
|
|
|
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
|
|
|
|
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
|
|
|
|
|
|
|
|
MovGraphLink *lnk = (MovGraphLink *)*i;
|
|
|
|
|
|
|
|
lnk->_flags &= 0x7FFFFFFF;
|
|
|
|
|
|
|
|
lnk->calcNodeDistanceAndAngle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-28 11:15:46 +00:00
|
|
|
int MovGraph2::getItemIndexByGameObjectId(int objectId) {
|
2013-11-17 03:04:42 +00:00
|
|
|
for (uint i = 0; i < _items2.size(); i++)
|
|
|
|
if (_items2[i]->_objectId == objectId)
|
2013-09-28 11:15:46 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-14 21:48:49 +00:00
|
|
|
int MovGraph2::getItemSubIndexByStaticsId(int idx, int staticsId) {
|
|
|
|
for (int i = 0; i < 4; i++)
|
2013-11-17 03:04:42 +00:00
|
|
|
if (_items2[idx]->_subItems[i]._staticsId1 == staticsId || _items2[idx]->_subItems[i]._staticsId2 == staticsId)
|
2013-10-14 21:48:49 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MovGraph2::getItemSubIndexByMovementId(int idx, int movId) {
|
|
|
|
for (int i = 0; i < 4; i++)
|
2013-11-17 03:04:42 +00:00
|
|
|
if (_items2[idx]->_subItems[i]._walk[0]._movementId == movId || _items2[idx]->_subItems[i]._turn[0]._movementId == movId ||
|
|
|
|
_items2[idx]->_subItems[i]._turnS[0]._movementId == movId)
|
2013-10-14 21:48:49 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MovGraph2::getItemSubIndexByMGM(int idx, StaticANIObject *ani) {
|
|
|
|
warning("STUB: MovGraph2::getItemSubIndexByMGM()");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-09-28 11:15:46 +00:00
|
|
|
bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) {
|
2013-09-28 12:59:46 +00:00
|
|
|
item->_obj = obj;
|
|
|
|
item->_objectId = obj->_id;
|
|
|
|
|
2013-12-20 14:08:02 +00:00
|
|
|
GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName(obj->_objectName);
|
2013-09-28 12:59:46 +00:00
|
|
|
if (!var)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var = var->getSubVarByName("Test_walk");
|
|
|
|
|
|
|
|
if (!var)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
GameVar *varD = 0;
|
|
|
|
Common::Point point;
|
|
|
|
|
|
|
|
for (int dir = 0; dir < 4; dir++) {
|
|
|
|
switch (dir) {
|
|
|
|
case 0:
|
|
|
|
varD = var->getSubVarByName("Right");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
varD = var->getSubVarByName("Left");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
varD = var->getSubVarByName("Up");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
varD = var->getSubVarByName("Down");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!varD)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (int act = 0; act < 3; act++) {
|
2013-10-05 18:32:16 +00:00
|
|
|
int idx = 0;
|
2013-09-28 12:59:46 +00:00
|
|
|
|
|
|
|
switch(act) {
|
|
|
|
case 0:
|
|
|
|
idx = varD->getSubVarAsInt("Start");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
idx = varD->getSubVarAsInt("Go");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
idx = varD->getSubVarAsInt("Stop");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->_subItems[dir]._walk[act]._movementId = idx;
|
|
|
|
|
|
|
|
Movement *mov = obj->getMovementById(idx);
|
|
|
|
|
|
|
|
item->_subItems[dir]._walk[act]._mov = mov;
|
|
|
|
if (mov) {
|
|
|
|
mov->calcSomeXY(point, 0);
|
|
|
|
item->_subItems[dir]._walk[act]._mx = point.x;
|
|
|
|
item->_subItems[dir]._walk[act]._my = point.y;
|
|
|
|
}
|
|
|
|
}
|
2013-09-28 11:15:46 +00:00
|
|
|
|
2013-09-28 12:59:46 +00:00
|
|
|
for (int act = 0; act < 4; act++) {
|
2013-10-05 18:32:16 +00:00
|
|
|
int idx = 0;
|
2013-09-28 12:59:46 +00:00
|
|
|
|
|
|
|
switch(act) {
|
|
|
|
case 0:
|
|
|
|
idx = varD->getSubVarAsInt("TurnR");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
idx = varD->getSubVarAsInt("TurnL");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
idx = varD->getSubVarAsInt("TurnU");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
idx = varD->getSubVarAsInt("TurnD");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->_subItems[dir]._turn[act]._movementId = idx;
|
|
|
|
|
|
|
|
Movement *mov = obj->getMovementById(idx);
|
|
|
|
|
|
|
|
item->_subItems[dir]._turn[act]._mov = mov;
|
|
|
|
if (mov) {
|
|
|
|
mov->calcSomeXY(point, 0);
|
|
|
|
item->_subItems[dir]._turn[act]._mx = point.x;
|
|
|
|
item->_subItems[dir]._turn[act]._my = point.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int act = 0; act < 4; act++) {
|
2013-10-05 18:32:16 +00:00
|
|
|
int idx = 0;
|
2013-09-28 12:59:46 +00:00
|
|
|
|
|
|
|
switch(act) {
|
|
|
|
case 0:
|
|
|
|
idx = varD->getSubVarAsInt("TurnSR");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
idx = varD->getSubVarAsInt("TurnSL");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
idx = varD->getSubVarAsInt("TurnSU");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
idx = varD->getSubVarAsInt("TurnSD");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->_subItems[dir]._turnS[act]._movementId = idx;
|
|
|
|
|
|
|
|
Movement *mov = obj->getMovementById(idx);
|
|
|
|
|
|
|
|
item->_subItems[dir]._turnS[act]._mov = mov;
|
|
|
|
if (mov) {
|
|
|
|
mov->calcSomeXY(point, 0);
|
|
|
|
item->_subItems[dir]._turnS[act]._mx = point.x;
|
|
|
|
item->_subItems[dir]._turnS[act]._my = point.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item->_subItems[dir]._staticsId1 = item->_subItems[dir]._walk[0]._mov->_staticsObj1->_staticsId;
|
|
|
|
item->_subItems[dir]._staticsId2 = item->_subItems[dir]._walk[0]._mov->_staticsObj2->_staticsId;
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
2013-09-28 11:15:46 +00:00
|
|
|
}
|
|
|
|
|
2013-09-28 10:06:06 +00:00
|
|
|
void MovGraph2::addObject(StaticANIObject *obj) {
|
2013-09-28 11:15:46 +00:00
|
|
|
MovGraph::addObject(obj);
|
|
|
|
|
|
|
|
int id = getItemIndexByGameObjectId(obj->_id);
|
|
|
|
|
|
|
|
if (id >= 0) {
|
2013-11-17 03:04:42 +00:00
|
|
|
_items2[id]->_obj = obj;
|
2013-09-28 11:15:46 +00:00
|
|
|
} else {
|
|
|
|
MovGraph2Item *item = new MovGraph2Item;
|
|
|
|
|
|
|
|
if (initDirections(obj, item)) {
|
2013-11-17 03:04:42 +00:00
|
|
|
_items2.push_back(item);
|
2013-09-28 11:15:46 +00:00
|
|
|
} else {
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
}
|
2013-09-27 19:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-16 21:35:02 +00:00
|
|
|
void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst) {
|
2013-10-19 12:54:17 +00:00
|
|
|
MovInfo1Sub *elem;
|
|
|
|
Common::Point point;
|
|
|
|
Common::Rect rect;
|
|
|
|
|
|
|
|
int subIndex = movinfo->subIndex;
|
|
|
|
|
|
|
|
movinfo->items.clear();
|
|
|
|
|
|
|
|
elem = new MovInfo1Sub;
|
|
|
|
elem->subIndex = subIndex;
|
|
|
|
elem->x = movinfo->pt1.x;
|
|
|
|
elem->y = movinfo->pt1.y;
|
|
|
|
elem->distance = -1;
|
|
|
|
|
|
|
|
movinfo->items.push_back(elem);
|
|
|
|
|
|
|
|
int prevSubIndex = movinfo->subIndex;
|
|
|
|
|
2013-10-19 14:30:57 +00:00
|
|
|
for (uint i = 0; i < linkList->size(); i++) {
|
2013-10-19 12:54:17 +00:00
|
|
|
int idx1;
|
|
|
|
|
|
|
|
if (linkList->size() <= 1) {
|
|
|
|
if (linkList->size() == 1)
|
|
|
|
idx1 = getShortSide((*linkList)[0], movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y);
|
|
|
|
else
|
|
|
|
idx1 = getShortSide(0, movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y);
|
|
|
|
|
|
|
|
point.y = -1;
|
|
|
|
rect.bottom = -1;
|
|
|
|
rect.right = -1;
|
|
|
|
rect.top = -1;
|
|
|
|
rect.left = -1;
|
|
|
|
} else {
|
2013-10-19 14:30:57 +00:00
|
|
|
idx1 = findLink(linkList, i, &rect, &point);
|
2013-10-19 12:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (idx1 != prevSubIndex) {
|
|
|
|
prevSubIndex = idx1;
|
|
|
|
subIndex = idx1;
|
|
|
|
|
|
|
|
elem = new MovInfo1Sub;
|
|
|
|
elem->subIndex = subIndex;
|
|
|
|
elem->x = rect.left;
|
|
|
|
elem->y = rect.top;
|
|
|
|
elem->distance = -1;
|
|
|
|
|
|
|
|
movinfo->items.push_back(elem);
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:45:30 +00:00
|
|
|
if (i != linkList->size() - 1) {
|
2013-10-19 12:54:17 +00:00
|
|
|
while (1) {
|
2013-10-19 14:30:57 +00:00
|
|
|
i++;
|
|
|
|
if (findLink(linkList, i, &rect, 0) != prevSubIndex) {
|
|
|
|
i--;
|
|
|
|
findLink(linkList, i, &rect, &point);
|
2013-10-19 12:54:17 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-19 19:45:30 +00:00
|
|
|
if (i == linkList->size() - 1)
|
2013-10-19 12:54:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (movinfo->items.back()->subIndex != 10) {
|
|
|
|
subIndex = prevSubIndex;
|
|
|
|
|
|
|
|
elem = new MovInfo1Sub;
|
|
|
|
elem->subIndex = 10;
|
|
|
|
elem->x = -1;
|
|
|
|
elem->y = -1;
|
|
|
|
elem->distance = -1;
|
|
|
|
|
|
|
|
movinfo->items.push_back(elem);
|
|
|
|
|
2013-10-19 14:30:57 +00:00
|
|
|
if (i == linkList->size()) {
|
2013-10-19 12:54:17 +00:00
|
|
|
elem = new MovInfo1Sub;
|
|
|
|
elem->subIndex = prevSubIndex;
|
|
|
|
elem->x = movinfo->pt2.x;
|
|
|
|
elem->y = movinfo->pt2.y;
|
|
|
|
elem->distance = movinfo->distance2;
|
|
|
|
|
|
|
|
movinfo->items.push_back(elem);
|
|
|
|
} else {
|
|
|
|
elem = new MovInfo1Sub;
|
|
|
|
elem->subIndex = prevSubIndex;
|
|
|
|
elem->x = rect.right;
|
|
|
|
elem->y = rect.bottom;
|
|
|
|
elem->distance = point.y;
|
|
|
|
|
|
|
|
movinfo->items.push_back(elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subIndex != movinfo->item1Index) {
|
|
|
|
elem = new MovInfo1Sub;
|
|
|
|
elem->subIndex = movinfo->item1Index;
|
|
|
|
elem->x = movinfo->pt2.x;
|
|
|
|
elem->y = movinfo->pt2.y;
|
|
|
|
elem->distance = movinfo->distance2;
|
|
|
|
|
|
|
|
movinfo->items.push_back(elem);
|
|
|
|
}
|
|
|
|
|
|
|
|
movinfo->itemsCount = movinfo->items.size();
|
2013-10-16 21:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) {
|
2013-12-21 20:36:19 +00:00
|
|
|
MovInfo1 movinfo(movInfo);
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
int curX = movInfo->pt1.x;
|
|
|
|
int curY = movInfo->pt1.y;
|
|
|
|
int curDistance = movInfo->distance1;
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-12-20 14:08:02 +00:00
|
|
|
MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact());
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
for (int i = 0; i < movInfo->itemsCount - 1; i++) {
|
|
|
|
if (movInfo->items[i + 1]->subIndex != 10) {
|
|
|
|
MG2I *mg2i;
|
2013-11-16 18:58:47 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
if (i >= movInfo->itemsCount - 2 || movInfo->items[i + 2]->subIndex != 10) {
|
|
|
|
movinfo.flags = 0;
|
2014-01-04 21:16:56 +00:00
|
|
|
mg2i = &_items2[movInfo->index]->_subItems[movInfo->items[i]->subIndex]._turnS[movInfo->items[i + 1]->subIndex];
|
2013-11-07 20:47:48 +00:00
|
|
|
} else {
|
|
|
|
movinfo.flags = 2;
|
2014-01-04 21:16:56 +00:00
|
|
|
mg2i = &_items2[movInfo->index]->_subItems[movInfo->items[i]->subIndex]._turn[movInfo->items[i + 1]->subIndex];
|
2013-11-07 20:47:48 +00:00
|
|
|
}
|
2013-11-13 21:37:50 +00:00
|
|
|
if (i < movInfo->itemsCount - 2
|
2013-11-17 10:19:25 +00:00
|
|
|
|| (movInfo->items[i]->x == movInfo->items[i + 1]->x
|
|
|
|
&& movInfo->items[i]->y == movInfo->items[i + 1]->y)
|
|
|
|
|| movInfo->items[i]->x == -1
|
|
|
|
|| movInfo->items[i]->y == -1
|
|
|
|
|| movInfo->items[i + 1]->x == -1
|
|
|
|
|| movInfo->items[i + 1]->y == -1) {
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
ExCommand *ex = new ExCommand(_items2[movInfo->index]->_objectId, 1, mg2i->_movementId, 0, 0, 0, 1, 0, 0, 0);
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-14 21:57:01 +00:00
|
|
|
ex->_excFlags |= 2;
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[movInfo->index]->_obj->_okeyCode;
|
2013-11-08 23:45:31 +00:00
|
|
|
ex->_field_24 = 1;
|
|
|
|
ex->_field_14 = -1;
|
2013-12-11 20:51:49 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
curX += mg2i->_mx;
|
|
|
|
curY += mg2i->_my;
|
2013-11-07 20:47:48 +00:00
|
|
|
} else {
|
2013-11-17 10:19:25 +00:00
|
|
|
MGMInfo mgminfo;
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
memset(&mgminfo, 0, sizeof(mgminfo));
|
2013-11-13 21:37:50 +00:00
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
mgminfo.ani = _items2[movInfo->index]->_obj;
|
2013-11-17 10:19:25 +00:00
|
|
|
mgminfo.staticsId2 = mg2i->_mov->_staticsObj2->_staticsId;
|
|
|
|
mgminfo.x1 = movInfo->items[i + 1]->x;
|
|
|
|
mgminfo.y1 = movInfo->items[i + 1]->y;
|
|
|
|
mgminfo.field_1C = movInfo->items[i + 1]->distance;
|
|
|
|
mgminfo.staticsId1 = mg2i->_mov->_staticsObj1->_staticsId;
|
|
|
|
|
|
|
|
mgminfo.x2 = movInfo->items[i]->x;
|
|
|
|
mgminfo.y2 = movInfo->items[i]->y;
|
2013-11-07 20:47:48 +00:00
|
|
|
mgminfo.field_10 = 1;
|
2013-11-13 21:37:50 +00:00
|
|
|
mgminfo.flags = 0x7f;
|
2013-11-17 10:19:25 +00:00
|
|
|
mgminfo.movementId = mg2i->_movementId;
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
MessageQueue *mq2 = _mgm.genMovement(&mgminfo);
|
2013-11-15 22:44:42 +00:00
|
|
|
mq->transferExCommands(mq2);
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-15 22:44:42 +00:00
|
|
|
delete mq2;
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
curX = movInfo->items[i + 1]->x;
|
|
|
|
curY = movInfo->items[i + 1]->y;
|
2013-11-07 20:47:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-11-17 10:19:25 +00:00
|
|
|
movinfo.item1Index = movInfo->items[i]->subIndex;
|
2013-11-07 20:47:48 +00:00
|
|
|
movinfo.subIndex = movinfo.item1Index;
|
|
|
|
movinfo.pt1.y = curY;
|
|
|
|
movinfo.pt1.x = curX;
|
2013-11-13 21:37:50 +00:00
|
|
|
|
2013-11-07 20:47:48 +00:00
|
|
|
movinfo.distance1 = curDistance;
|
2013-11-17 10:19:25 +00:00
|
|
|
movinfo.pt2.x = movInfo->items[i + 2]->x;
|
|
|
|
movinfo.pt2.y = movInfo->items[i + 2]->y;
|
|
|
|
movinfo.distance2 = movInfo->items[i + 2]->distance;
|
2013-11-13 21:37:50 +00:00
|
|
|
|
|
|
|
if (i >= movInfo->itemsCount - 4
|
2013-11-17 10:19:25 +00:00
|
|
|
|| movInfo->items[i + 2]->subIndex == 10
|
|
|
|
|| movInfo->items[i + 3]->subIndex == 10
|
|
|
|
|| movInfo->items[i + 2]->subIndex == movInfo->items[i + 3]->subIndex
|
|
|
|
|| movInfo->items[i + 4]->subIndex != 10) {
|
2013-11-11 23:42:07 +00:00
|
|
|
if (i >= movInfo->itemsCount - 3
|
2013-11-17 10:19:25 +00:00
|
|
|
|| movInfo->items[i + 2]->subIndex == 10
|
|
|
|
|| movInfo->items[i + 3]->subIndex == 10
|
|
|
|
|| movInfo->items[i + 2]->subIndex == movInfo->items[i + 3]->subIndex) {
|
2013-11-11 23:42:07 +00:00
|
|
|
movinfo.flags &= 3;
|
2013-11-07 20:47:48 +00:00
|
|
|
} else {
|
2014-01-04 21:16:56 +00:00
|
|
|
MG2I *m = &_items2[movInfo->index]->_subItems[movInfo->items[i + 2]->subIndex]._turnS[movInfo->items[i + 3]->subIndex];
|
2013-11-17 10:19:25 +00:00
|
|
|
movinfo.pt2.x -= m->_mx;
|
|
|
|
movinfo.pt2.y -= m->_my;
|
2013-11-11 23:42:07 +00:00
|
|
|
movinfo.flags &= 3;
|
2013-11-07 20:47:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-01-04 21:16:56 +00:00
|
|
|
MG2I *m = &_items2[movInfo->index]->_subItems[movInfo->items[i + 2]->subIndex]._turn[movInfo->items[i + 3]->subIndex];
|
2013-11-07 20:47:48 +00:00
|
|
|
|
|
|
|
if (movinfo.item1Index && movinfo.item1Index != 1) {
|
2013-11-17 10:19:25 +00:00
|
|
|
movinfo.pt2.y -= m->_my;
|
2013-11-12 22:12:04 +00:00
|
|
|
movinfo.flags = (movinfo.flags & 2) | 1;
|
2013-11-07 20:47:48 +00:00
|
|
|
} else {
|
2013-11-17 10:19:25 +00:00
|
|
|
movinfo.pt2.x -= m->_mx;
|
2013-11-12 22:12:04 +00:00
|
|
|
movinfo.flags = (movinfo.flags & 2) | 1;
|
2013-11-07 20:47:48 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-11 23:42:07 +00:00
|
|
|
i++; // intentional
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
MessageQueue *mq2 = genMovement(&movinfo);
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-30 22:45:14 +00:00
|
|
|
if (!mq2) {
|
2013-11-07 20:47:48 +00:00
|
|
|
delete mq;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-12 22:12:04 +00:00
|
|
|
|
2013-11-15 22:44:42 +00:00
|
|
|
mq->transferExCommands(mq2);
|
2013-11-07 20:47:48 +00:00
|
|
|
|
2013-11-15 22:44:42 +00:00
|
|
|
delete mq2;
|
2013-11-07 20:47:48 +00:00
|
|
|
|
|
|
|
curX = movinfo.pt2.x;
|
|
|
|
curY = movinfo.pt2.y;
|
|
|
|
curDistance = movinfo.distance2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
movInfo->pt2.x = movinfo.pt2.x;
|
|
|
|
movInfo->pt2.y = movinfo.pt2.y;
|
|
|
|
|
|
|
|
return mq;
|
2013-10-16 21:35:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 19:16:15 +00:00
|
|
|
int MovGraph2::removeObject(StaticANIObject *obj) {
|
|
|
|
warning("STUB: MovGraph2::removeObject()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MovGraph2::freeItems() {
|
|
|
|
warning("STUB: MovGraph2::freeItems()");
|
|
|
|
}
|
|
|
|
|
2013-10-25 21:20:58 +00:00
|
|
|
MessageQueue *MovGraph2::method34(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
|
|
|
if (!ani->isIdle())
|
|
|
|
return 0;
|
2013-09-27 19:16:15 +00:00
|
|
|
|
2013-10-25 21:20:58 +00:00
|
|
|
if (ani->_flags & 0x100)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
MessageQueue *mq = doWalkTo(ani, xpos, ypos, fuzzyMatch, staticsId);
|
|
|
|
|
|
|
|
if (!mq)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (ani->_movement) {
|
|
|
|
if (mq->getCount() <= 1 || mq->getExCommandByIndex(0)->_messageKind != 22) {
|
|
|
|
PicAniInfo picAniInfo;
|
|
|
|
|
|
|
|
ani->getPicAniInfo(&picAniInfo);
|
|
|
|
ani->updateStepPos();
|
|
|
|
MessageQueue *mq1 = doWalkTo(ani, xpos, ypos, fuzzyMatch, staticsId);
|
|
|
|
|
|
|
|
ani->setPicAniInfo(&picAniInfo);
|
|
|
|
|
|
|
|
if (mq1) {
|
|
|
|
delete mq;
|
|
|
|
|
|
|
|
mq = mq1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ani->_movement = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mq->chain(ani)) {
|
|
|
|
delete mq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mq;
|
2013-09-27 19:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-16 21:37:04 +00:00
|
|
|
MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
|
2013-10-06 20:39:49 +00:00
|
|
|
LinkInfo linkInfoDest;
|
|
|
|
LinkInfo linkInfoSource;
|
|
|
|
MovInfo1 movInfo1;
|
|
|
|
PicAniInfo picAniInfo;
|
2013-10-14 21:48:49 +00:00
|
|
|
Common::Point point;
|
2013-10-06 20:39:49 +00:00
|
|
|
|
|
|
|
int idx = getItemIndexByGameObjectId(obj->_id);
|
|
|
|
|
|
|
|
if (idx < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
linkInfoSource.link = 0;
|
|
|
|
linkInfoSource.node = 0;
|
|
|
|
|
|
|
|
linkInfoDest.link = 0;
|
|
|
|
linkInfoDest.node = 0;
|
|
|
|
|
2013-10-08 20:16:51 +00:00
|
|
|
point.x = 0;
|
|
|
|
|
2013-10-14 21:48:49 +00:00
|
|
|
obj->getPicAniInfo(&picAniInfo);
|
2013-10-06 20:39:49 +00:00
|
|
|
|
|
|
|
int idxsub;
|
|
|
|
|
|
|
|
if (obj->_movement)
|
|
|
|
idxsub = getItemSubIndexByMovementId(idx, obj->_movement->_id);
|
|
|
|
else
|
|
|
|
idxsub = getItemSubIndexByStaticsId(idx, obj->_statics->_staticsId);
|
|
|
|
|
|
|
|
bool subMgm = false;
|
|
|
|
|
|
|
|
if (idxsub == -1) {
|
|
|
|
idxsub = getItemSubIndexByMGM(idx, obj);
|
|
|
|
subMgm = true;
|
|
|
|
|
|
|
|
if (idxsub == -1)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj->_movement) {
|
2013-10-10 20:41:04 +00:00
|
|
|
int newx, newy;
|
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
if (subMgm) {
|
|
|
|
obj->_messageQueueId = 0;
|
2013-11-17 03:04:42 +00:00
|
|
|
obj->changeStatics2(_items2[idx]->_subItems[idxsub]._staticsId1);
|
2013-10-10 20:41:04 +00:00
|
|
|
newx = obj->_ox;
|
|
|
|
newy = obj->_oy;
|
2013-10-06 20:39:49 +00:00
|
|
|
} else {
|
2013-10-10 20:41:04 +00:00
|
|
|
obj->_movement->calcSomeXY(point, 0);
|
|
|
|
newx = obj->_movement->_ox - point.x;
|
|
|
|
newy = obj->_movement->_oy - point.y;
|
2013-10-06 20:39:49 +00:00
|
|
|
if (idxsub != 1 && idxsub) {
|
|
|
|
if (idxsub == 2 || idxsub == 3) {
|
2013-10-10 20:41:04 +00:00
|
|
|
newy = obj->_movement->_oy;
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-10-10 20:41:04 +00:00
|
|
|
newx = obj->_movement->_ox;
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-10 20:41:04 +00:00
|
|
|
|
|
|
|
obj->_movement = 0;
|
|
|
|
obj->setOXY(newx, newy);
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
2013-10-10 20:41:04 +00:00
|
|
|
|
|
|
|
if (obj->_ox == xpos && obj->_oy == ypos) {
|
2013-12-20 14:08:02 +00:00
|
|
|
g_fp->_globalMessageQueueList->compact();
|
2013-10-14 21:48:49 +00:00
|
|
|
|
|
|
|
MessageQueue *mq = new MessageQueue();
|
2013-10-10 20:41:04 +00:00
|
|
|
|
|
|
|
if (staticsId && obj->_statics->_staticsId != staticsId) {
|
2013-10-14 21:48:49 +00:00
|
|
|
int idxwalk = getItemSubIndexByStaticsId(idx, staticsId);
|
|
|
|
if (idxwalk == -1) {
|
|
|
|
obj->setPicAniInfo(&picAniInfo);
|
|
|
|
|
2013-10-18 12:54:59 +00:00
|
|
|
delete mq;
|
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2013-10-14 21:48:49 +00:00
|
|
|
|
2013-11-17 03:04:42 +00:00
|
|
|
ExCommand *ex = new ExCommand(picAniInfo.objectId, 1, _items2[idx]->_subItems[idxsub]._walk[idxwalk]._movementId, 0, 0, 0, 1, 0, 0, 0);
|
2013-10-14 21:48:49 +00:00
|
|
|
|
|
|
|
ex->_field_24 = 1;
|
|
|
|
ex->_keyCode = picAniInfo.field_8;
|
|
|
|
ex->_excFlags |= 2;
|
|
|
|
|
2013-12-11 20:51:49 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-10-06 20:39:49 +00:00
|
|
|
} else {
|
2013-10-14 21:48:49 +00:00
|
|
|
ExCommand *ex = new ExCommand(picAniInfo.objectId, 22, obj->_statics->_staticsId, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
|
|
|
|
ex->_keyCode = picAniInfo.field_8;
|
|
|
|
ex->_excFlags |= 3;
|
2013-12-11 20:51:49 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-10-14 21:48:49 +00:00
|
|
|
|
|
|
|
ex = new ExCommand(picAniInfo.objectId, 5, -1, obj->_ox, obj->_oy, 0, 1, 0, 0, 0);
|
|
|
|
|
|
|
|
ex->_field_14 = -1;
|
|
|
|
ex->_keyCode = picAniInfo.field_8;
|
|
|
|
ex->_excFlags |= 3;
|
2013-12-11 20:51:49 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
2013-10-14 21:48:49 +00:00
|
|
|
|
|
|
|
obj->setPicAniInfo(&picAniInfo);
|
|
|
|
|
|
|
|
return mq;
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
2013-10-14 21:48:49 +00:00
|
|
|
|
2013-10-10 20:41:04 +00:00
|
|
|
linkInfoSource.node = findNode(obj->_ox, obj->_oy, 0);
|
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
if (!linkInfoSource.node) {
|
2013-10-10 20:41:04 +00:00
|
|
|
linkInfoSource.link = findLink1(obj->_ox, obj->_oy, idxsub, 0);
|
|
|
|
|
|
|
|
if (!linkInfoSource.link) {
|
|
|
|
linkInfoSource.link = findLink2(obj->_ox, obj->_oy);
|
|
|
|
|
|
|
|
if (!linkInfoSource.link) {
|
2013-10-15 06:10:57 +00:00
|
|
|
obj->setPicAniInfo(&picAniInfo);
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-10 20:41:04 +00:00
|
|
|
|
|
|
|
linkInfoDest.node = findNode(xpos, ypos, fuzzyMatch);
|
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
if (!linkInfoDest.node) {
|
2013-10-10 20:41:04 +00:00
|
|
|
linkInfoDest.link = findLink1(xpos, ypos, idxsub, fuzzyMatch);
|
2013-10-17 19:44:30 +00:00
|
|
|
|
2013-10-10 20:41:04 +00:00
|
|
|
if (!linkInfoDest.link) {
|
2013-10-15 06:10:57 +00:00
|
|
|
obj->setPicAniInfo(&picAniInfo);
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
Common::Array<MovGraphLink *> tempLinkList;
|
2013-10-18 21:44:10 +00:00
|
|
|
double minPath = findMinPath(&linkInfoSource, &linkInfoDest, &tempLinkList);
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-11-02 23:55:58 +00:00
|
|
|
debug(0, "MovGraph2::doWalkTo(): path: %g parts: %d", minPath, tempLinkList.size());
|
2013-10-18 21:44:10 +00:00
|
|
|
|
|
|
|
if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size()))
|
2013-10-06 20:39:49 +00:00
|
|
|
return 0;
|
2013-10-15 06:10:57 +00:00
|
|
|
|
2013-12-21 20:36:19 +00:00
|
|
|
movInfo1.clear();
|
2013-11-27 04:14:30 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
movInfo1.subIndex = idxsub;
|
2013-10-15 06:10:57 +00:00
|
|
|
movInfo1.pt1.x = obj->_ox;
|
|
|
|
movInfo1.pt1.y = obj->_oy;
|
|
|
|
|
|
|
|
int dx1 = obj->_ox;
|
|
|
|
int dy1 = obj->_oy;
|
|
|
|
int dx2, dy2;
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
if (linkInfoSource.node)
|
2013-10-15 06:10:57 +00:00
|
|
|
movInfo1.distance1 = linkInfoSource.node->_distance;
|
2013-10-06 20:39:49 +00:00
|
|
|
else
|
2013-10-15 06:10:57 +00:00
|
|
|
movInfo1.distance1 = linkInfoSource.link->_movGraphNode1->_distance;
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
if (linkInfoDest.node) {
|
2013-10-15 06:10:57 +00:00
|
|
|
dx2 = linkInfoDest.node->_x;
|
|
|
|
dy2 = linkInfoDest.node->_y;
|
|
|
|
|
|
|
|
movInfo1.pt2.x = linkInfoDest.node->_x;
|
|
|
|
movInfo1.pt2.y = linkInfoDest.node->_y;
|
|
|
|
|
|
|
|
movInfo1.distance2 = linkInfoDest.node->_distance;
|
2013-10-06 20:39:49 +00:00
|
|
|
} else {
|
|
|
|
movInfo1.pt2.x = xpos;
|
|
|
|
movInfo1.pt2.y = ypos;
|
2013-10-15 06:10:57 +00:00
|
|
|
|
|
|
|
MovGraphNode *nod = linkInfoDest.link->_movGraphNode1;
|
2013-10-16 22:08:42 +00:00
|
|
|
double dst1 = sqrt((double)((ypos - nod->_y) * (ypos - nod->_y) + (xpos - nod->_x) * (xpos - nod->_x)));
|
2013-10-15 06:10:57 +00:00
|
|
|
int dst = linkInfoDest.link->_movGraphNode2->_distance - nod->_distance;
|
|
|
|
|
2013-12-18 08:16:19 +00:00
|
|
|
movInfo1.distance2 = (int)(nod->_distance + (dst1 * (double)dst / linkInfoDest.link->_distance));
|
2013-10-15 06:10:57 +00:00
|
|
|
|
|
|
|
calcDistance(&movInfo1.pt2, linkInfoDest.link, 1);
|
|
|
|
|
|
|
|
dx1 = movInfo1.pt1.x;
|
|
|
|
dy1 = movInfo1.pt1.y;
|
|
|
|
dx2 = movInfo1.pt2.x;
|
|
|
|
dy2 = movInfo1.pt2.y;
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
2013-10-10 20:41:04 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
if (staticsId) {
|
2013-10-16 21:35:02 +00:00
|
|
|
movInfo1.item1Index = getItemSubIndexByStaticsId(idx, staticsId);
|
|
|
|
} else if (tempLinkList.size() <= 1) {
|
|
|
|
if (tempLinkList.size() == 1)
|
|
|
|
movInfo1.item1Index = getShortSide(tempLinkList[0], dx2 - dx1, dy2 - dy1);
|
2013-10-06 20:39:49 +00:00
|
|
|
else
|
2013-10-16 21:35:02 +00:00
|
|
|
movInfo1.item1Index = getShortSide(0, dx2 - dx1, dy2 - dy1);
|
2013-10-06 20:39:49 +00:00
|
|
|
} else {
|
2013-10-19 14:30:57 +00:00
|
|
|
movInfo1.item1Index = findLink(&tempLinkList, tempLinkList.size() - 1, 0, 0);
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
2013-10-16 21:35:02 +00:00
|
|
|
|
2013-10-06 20:39:49 +00:00
|
|
|
movInfo1.flags = fuzzyMatch != 0;
|
2013-10-16 21:35:02 +00:00
|
|
|
|
2013-11-17 03:04:42 +00:00
|
|
|
if (_items2[idx]->_subItems[idxsub]._staticsId1 != obj->_statics->_staticsId)
|
2013-10-16 21:35:02 +00:00
|
|
|
movInfo1.flags |= 2;
|
|
|
|
|
|
|
|
buildMovInfo1SubItems(&movInfo1, &tempLinkList, &linkInfoSource, &linkInfoDest);
|
|
|
|
|
|
|
|
MessageQueue *mq = buildMovInfo1MessageQueue(&movInfo1);
|
|
|
|
|
|
|
|
linkInfoDest.node = findNode(movInfo1.pt2.x, movInfo1.pt2.y, fuzzyMatch);
|
|
|
|
|
|
|
|
if (!linkInfoDest.node)
|
|
|
|
linkInfoDest.link = findLink1(movInfo1.pt2.x, movInfo1.pt2.y, movInfo1.item1Index, fuzzyMatch);
|
|
|
|
|
|
|
|
if (fuzzyMatch || linkInfoDest.link || linkInfoDest.node) {
|
|
|
|
if (mq && mq->getCount() > 0 && picAniInfo.movementId) {
|
|
|
|
ExCommand *ex = mq->getExCommandByIndex(0);
|
|
|
|
|
|
|
|
if (ex && (ex->_messageKind == 1 || ex->_messageKind == 20)
|
|
|
|
&& picAniInfo.movementId == ex->_messageNum
|
|
|
|
&& picAniInfo.someDynamicPhaseIndex == ex->_field_14) {
|
|
|
|
mq->deleteExCommandByIndex(0, 1);
|
2013-10-06 20:39:49 +00:00
|
|
|
} else {
|
2013-10-16 21:35:02 +00:00
|
|
|
ex = new ExCommand(picAniInfo.objectId, 5, ex->_messageNum, obj->_ox, obj->_oy, 0, 1, 0, 0, 0);
|
2013-10-16 06:03:43 +00:00
|
|
|
ex->_field_14 = -1;
|
|
|
|
ex->_keyCode = picAniInfo.field_8;
|
|
|
|
ex->_excFlags |= 2;
|
2013-10-16 21:35:02 +00:00
|
|
|
mq->addExCommand(ex);
|
|
|
|
|
2013-11-17 03:04:42 +00:00
|
|
|
ex = new ExCommand(picAniInfo.objectId, 22, _items2[idx]->_subItems[idxsub]._staticsId1, 0, 0, 0, 1, 0, 0, 0);
|
2013-10-16 21:35:02 +00:00
|
|
|
|
|
|
|
ex->_keyCode = picAniInfo.field_8;
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommand(ex);
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2013-10-16 21:35:02 +00:00
|
|
|
if (mq)
|
|
|
|
delete mq;
|
|
|
|
mq = 0;
|
2013-10-06 20:39:49 +00:00
|
|
|
}
|
2013-09-27 19:16:15 +00:00
|
|
|
|
2013-10-16 21:35:02 +00:00
|
|
|
obj->setPicAniInfo(&picAniInfo);
|
|
|
|
|
|
|
|
return mq;
|
2013-09-27 19:16:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
MovGraphNode *MovGraph2::findNode(int x, int y, int fuzzyMatch) {
|
2013-10-16 21:55:34 +00:00
|
|
|
for (ObList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
|
|
|
|
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphNode);
|
|
|
|
|
|
|
|
MovGraphNode *node = (MovGraphNode *)*i;
|
|
|
|
|
|
|
|
if (fuzzyMatch) {
|
|
|
|
if (abs(node->_x - x) < 15 && abs(node->_y - y) < 15)
|
|
|
|
return node;
|
|
|
|
} else {
|
|
|
|
if (node->_x == x && node->_y == y)
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
2013-10-15 06:10:57 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-16 21:35:02 +00:00
|
|
|
int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) {
|
2013-10-21 21:22:19 +00:00
|
|
|
bool cond;
|
2013-10-16 21:35:02 +00:00
|
|
|
|
2013-10-21 21:22:19 +00:00
|
|
|
if (lnk)
|
|
|
|
cond = abs(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) > abs(lnk->_movGraphNode2->_y - lnk->_movGraphNode1->_y);
|
|
|
|
else
|
|
|
|
cond = abs(x) > abs(y);
|
|
|
|
|
|
|
|
if (cond)
|
|
|
|
return x <= 0;
|
|
|
|
else
|
|
|
|
return ((y > 0) + 2);
|
2013-10-16 21:35:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-19 14:30:57 +00:00
|
|
|
int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *rect, Common::Point *point) {
|
|
|
|
MovGraphNode *node1 = (*linkList)[idx]->_movGraphNode1;
|
|
|
|
MovGraphNode *node2 = (*linkList)[idx]->_movGraphNode2;
|
|
|
|
MovGraphNode *node3 = node1;
|
2013-10-16 21:35:02 +00:00
|
|
|
|
2013-10-19 14:30:57 +00:00
|
|
|
if (idx != 0) {
|
|
|
|
MovGraphLink *lnk = (*linkList)[idx - 1];
|
|
|
|
|
|
|
|
if (lnk->_movGraphNode2 != node1) {
|
|
|
|
if (lnk->_movGraphNode1 != node1) {
|
|
|
|
if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) {
|
|
|
|
node3 = node2;
|
|
|
|
node2 = node1;
|
|
|
|
}
|
|
|
|
goto LABEL_7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
node3 = node1;
|
2013-11-02 23:55:58 +00:00
|
|
|
} else if (idx != (int)(linkList->size() - 1)) {
|
2013-10-19 14:30:57 +00:00
|
|
|
MovGraphLink *lnk = (*linkList)[idx + 1];
|
|
|
|
|
2013-11-10 09:17:33 +00:00
|
|
|
if (lnk->_movGraphNode2 == node1 || lnk->_movGraphNode1 == node1) {
|
2013-10-19 14:30:57 +00:00
|
|
|
node3 = node2;
|
|
|
|
node2 = node1;
|
|
|
|
} else if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) {
|
|
|
|
node3 = node1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LABEL_7:
|
|
|
|
if (rect) {
|
|
|
|
rect->left = node3->_x;
|
|
|
|
rect->top = node3->_y;
|
|
|
|
rect->right = node2->_x;
|
|
|
|
rect->bottom = node2->_y;
|
|
|
|
}
|
|
|
|
if (point) {
|
|
|
|
point->x = node3->_distance;
|
|
|
|
point->y = node2->_distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (abs(node3->_x - node2->_x) <= abs(node3->_y - node2->_y))
|
|
|
|
return (node3->_y < node2->_x) + 2;
|
|
|
|
else
|
|
|
|
return node3->_x >= node2->_x;
|
2013-10-16 21:35:02 +00:00
|
|
|
}
|
|
|
|
|
2013-12-30 20:56:04 +00:00
|
|
|
MessageQueue *MovGraph2::genMovement(MovInfo1 *info) {
|
2014-01-03 07:19:48 +00:00
|
|
|
int mx1 = 0;
|
|
|
|
int my1 = 0;
|
2013-12-30 20:56:04 +00:00
|
|
|
|
2014-01-04 12:23:55 +00:00
|
|
|
if (!(info->flags & 2)) {
|
2014-01-04 21:16:56 +00:00
|
|
|
mx1 = _items2[info->index]->_subItems[info->subIndex]._walk[0]._mx;
|
|
|
|
my1 = _items2[info->index]->_subItems[info->subIndex]._walk[0]._my;
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-03 07:19:48 +00:00
|
|
|
|
|
|
|
int mx2 = 0;
|
|
|
|
int my2 = 0;
|
|
|
|
|
2014-01-04 12:23:55 +00:00
|
|
|
if (!(info->flags & 4)) {
|
2014-01-04 21:16:56 +00:00
|
|
|
mx2 = _items2[info->index]->_subItems[info->subIndex]._walk[2]._mx;
|
|
|
|
my2 = _items2[info->index]->_subItems[info->subIndex]._walk[2]._my;
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-03 07:19:48 +00:00
|
|
|
|
2014-01-03 18:57:06 +00:00
|
|
|
Common::Point point;
|
|
|
|
|
2014-01-04 00:01:40 +00:00
|
|
|
int y = info->pt2.y - info->pt1.y - my2 - my1;
|
|
|
|
int x = info->pt2.x - info->pt1.x - mx2 - mx1;
|
|
|
|
int a2;
|
2014-01-04 12:23:55 +00:00
|
|
|
int mgmLen;
|
2014-01-04 00:01:40 +00:00
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
_mgm.calcLength(&point, _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov, x, y, &mgmLen, &a2, info->flags & 1);
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
int x1 = point.x;
|
|
|
|
int y1 = point.y;
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
if (!(info->flags & 1)) {
|
|
|
|
if (info->subIndex == 1 || info->subIndex == 0) {
|
2013-12-30 20:56:04 +00:00
|
|
|
a2 = -1;
|
2014-01-04 21:16:56 +00:00
|
|
|
x1 = mgmLen * _items2[info->index]->_subItems[info->subIndex]._walk[1]._mx;
|
2014-01-04 00:01:40 +00:00
|
|
|
x = x1;
|
|
|
|
info->pt2.x = x1 + info->pt1.x + mx1 + mx2;
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
if (!(info->flags & 1)) {
|
|
|
|
if (info->subIndex == 2 || info->subIndex == 3) {
|
2013-12-30 20:56:04 +00:00
|
|
|
a2 = -1;
|
2014-01-04 21:16:56 +00:00
|
|
|
y1 = mgmLen * _items2[info->index]->_subItems[info->subIndex]._walk[1]._my;
|
2014-01-04 00:01:40 +00:00
|
|
|
y = y1;
|
|
|
|
info->pt2.y = y1 + info->pt1.y + my1 + my2;
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
int cntX = 0;
|
|
|
|
int cntY = 0;
|
|
|
|
|
2013-12-30 20:56:04 +00:00
|
|
|
if (!(info->flags & 2)) {
|
2014-01-04 21:16:56 +00:00
|
|
|
cntX = _items2[info->index]->_subItems[info->subIndex]._walk[0]._mov->countPhasesWithFlag(-1, 1);
|
|
|
|
cntY = _items2[info->index]->_subItems[info->subIndex]._walk[0]._mov->countPhasesWithFlag(-1, 2);
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
if (mgmLen > 1) {
|
2014-01-04 21:16:56 +00:00
|
|
|
cntX += (mgmLen - 1) * _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov->countPhasesWithFlag(-1, 1);
|
|
|
|
cntY += (mgmLen - 1) * _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov->countPhasesWithFlag(-1, 2);
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
if (mgmLen > 0) {
|
2014-01-04 21:16:56 +00:00
|
|
|
cntX += _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov->countPhasesWithFlag(a2, 1);
|
|
|
|
cntY += _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov->countPhasesWithFlag(a2, 2);
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-04 00:01:40 +00:00
|
|
|
|
2013-12-30 20:56:04 +00:00
|
|
|
if (!(info->flags & 4)) {
|
2014-01-04 21:16:56 +00:00
|
|
|
cntX += _items2[info->index]->_subItems[info->subIndex]._walk[2]._mov->countPhasesWithFlag(-1, 1);
|
|
|
|
cntY += _items2[info->index]->_subItems[info->subIndex]._walk[2]._mov->countPhasesWithFlag(-1, 2);
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
int dx1 = x - x1;
|
|
|
|
int dy1 = y - y1;
|
|
|
|
|
|
|
|
if (cntX)
|
|
|
|
x1 = (int)((double)dx1 / (double)cntX);
|
2013-12-30 20:56:04 +00:00
|
|
|
else
|
|
|
|
x1 = 0;
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
if (cntY)
|
|
|
|
y1 = (int)((double)dy1 / (double)cntY);
|
2013-12-30 20:56:04 +00:00
|
|
|
else
|
|
|
|
y1 = 0;
|
2014-01-04 00:01:40 +00:00
|
|
|
|
|
|
|
int v34 = dx1 - cntX * x1;
|
|
|
|
int v35 = dy1 - cntY * y1;
|
2014-01-04 20:16:53 +00:00
|
|
|
Common::Point x2;
|
|
|
|
Common::Point y2(v34, v35);
|
2014-01-04 00:01:40 +00:00
|
|
|
|
2013-12-30 20:56:04 +00:00
|
|
|
if (v34)
|
2014-01-04 20:16:53 +00:00
|
|
|
x2.x = v34 / abs(v34);
|
2013-12-30 20:56:04 +00:00
|
|
|
else
|
2014-01-04 20:16:53 +00:00
|
|
|
x2.x = 0;
|
|
|
|
|
2013-12-30 20:56:04 +00:00
|
|
|
if (v35)
|
2014-01-04 20:16:53 +00:00
|
|
|
x2.y = v35 / abs(v35);
|
2013-12-30 20:56:04 +00:00
|
|
|
else
|
2014-01-04 20:16:53 +00:00
|
|
|
x2.y = 0;
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact());
|
|
|
|
ExCommand *ex;
|
|
|
|
|
|
|
|
if (info->flags & 2) {
|
|
|
|
ex = new ExCommand(
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_objectId,
|
2013-12-30 20:56:04 +00:00
|
|
|
5,
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_subItems[info->subIndex]._walk[1]._movementId,
|
2013-12-30 20:56:04 +00:00
|
|
|
info->pt1.x,
|
|
|
|
info->pt1.y,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0);
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
ex->_field_14 = info->distance1;
|
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[info->index]->_obj->_okeyCode;
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_field_24 = 1;
|
|
|
|
ex->_excFlags |= 2;
|
2013-12-30 20:56:04 +00:00
|
|
|
} else {
|
2014-01-04 00:01:40 +00:00
|
|
|
ex = new ExCommand(
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_objectId,
|
2013-12-30 20:56:04 +00:00
|
|
|
5,
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_subItems[info->subIndex]._walk[0]._movementId,
|
2013-12-30 20:56:04 +00:00
|
|
|
info->pt1.x,
|
|
|
|
info->pt1.y,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0);
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
ex->_field_14 = info->distance1;
|
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[info->index]->_obj->_okeyCode;
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_field_24 = 1;
|
|
|
|
ex->_excFlags |= 2;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
2014-01-04 12:23:55 +00:00
|
|
|
ex = _mgm.buildExCommand2(
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_subItems[info->subIndex]._walk[0]._mov,
|
|
|
|
_items2[info->index]->_objectId,
|
2013-12-30 20:56:04 +00:00
|
|
|
x1,
|
|
|
|
y1,
|
|
|
|
&x2,
|
|
|
|
&y2,
|
|
|
|
-1);
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_parId = mq->_id;
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[info->index]->_obj->_okeyCode;
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
2014-01-04 00:01:40 +00:00
|
|
|
|
2014-01-04 12:23:55 +00:00
|
|
|
for (int i = 0; i < mgmLen; ++i) {
|
2014-01-04 00:01:40 +00:00
|
|
|
int par;
|
|
|
|
|
|
|
|
if (i == mgmLen - 1)
|
|
|
|
par = a2;
|
2013-12-30 20:56:04 +00:00
|
|
|
else
|
2014-01-04 00:01:40 +00:00
|
|
|
par = -1;
|
|
|
|
|
2014-01-04 12:23:55 +00:00
|
|
|
ex = _mgm.buildExCommand2(
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_subItems[info->subIndex]._walk[1]._mov,
|
|
|
|
_items2[info->index]->_objectId,
|
2013-12-30 20:56:04 +00:00
|
|
|
x1,
|
|
|
|
y1,
|
|
|
|
&x2,
|
|
|
|
&y2,
|
2014-01-04 00:01:40 +00:00
|
|
|
par);
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_parId = mq->_id;
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[info->index]->_obj->_okeyCode;
|
2014-01-03 18:57:06 +00:00
|
|
|
mq->addExCommandToEnd(ex);
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-03 18:57:06 +00:00
|
|
|
|
2013-12-30 20:56:04 +00:00
|
|
|
if (!(info->flags & 4)) {
|
2014-01-04 12:23:55 +00:00
|
|
|
ex = _mgm.buildExCommand2(
|
2014-01-04 21:16:56 +00:00
|
|
|
_items2[info->index]->_subItems[info->subIndex]._walk[2]._mov,
|
|
|
|
_items2[info->index]->_objectId,
|
2013-12-30 20:56:04 +00:00
|
|
|
x1,
|
|
|
|
y1,
|
|
|
|
&x2,
|
|
|
|
&y2,
|
|
|
|
-1);
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_parId = mq->_id;
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[info->index]->_obj->_okeyCode;
|
2014-01-03 18:57:06 +00:00
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
2013-12-30 20:56:04 +00:00
|
|
|
}
|
2014-01-03 18:57:06 +00:00
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
ex = new ExCommand(_items2[info->index]->_objectId, 5, -1, info->pt2.x, info->pt2.y, 0, 1, 0, 0, 0);
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_field_14 = info->distance2;
|
|
|
|
|
2014-01-04 21:16:56 +00:00
|
|
|
ex->_keyCode = _items2[info->index]->_obj->_okeyCode;
|
2014-01-03 18:57:06 +00:00
|
|
|
ex->_field_24 = 0;
|
|
|
|
ex->_excFlags |= 2;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
return mq;
|
2013-11-17 10:19:25 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 06:10:57 +00:00
|
|
|
MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) {
|
2013-10-17 19:44:30 +00:00
|
|
|
Common::Point point;
|
|
|
|
MovGraphLink *res = 0;
|
2013-10-15 06:10:57 +00:00
|
|
|
|
2013-10-17 19:44:30 +00:00
|
|
|
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
|
|
|
|
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
|
|
|
|
|
|
|
|
MovGraphLink *lnk = (MovGraphLink *)*i;
|
|
|
|
|
|
|
|
if (fuzzyMatch) {
|
|
|
|
point.x = x;
|
|
|
|
point.y = y;
|
|
|
|
double dst = calcDistance(&point, lnk, 0);
|
|
|
|
|
|
|
|
if (dst >= 0.0 && dst < 2.0)
|
|
|
|
return lnk;
|
|
|
|
} else if (!(lnk->_flags & 0x20000000)) {
|
|
|
|
if (lnk->_movGraphReact->pointInRegion(x, y)) {
|
|
|
|
if (abs(lnk->_movGraphNode1->_x - lnk->_movGraphNode2->_x) <= abs(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y)) {
|
|
|
|
if (idx == 2 || idx == 3)
|
|
|
|
return lnk;
|
|
|
|
res = lnk;
|
|
|
|
} else {
|
|
|
|
if (idx == 1 || !idx)
|
|
|
|
return lnk;
|
|
|
|
res = lnk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2013-10-15 06:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MovGraphLink *MovGraph2::findLink2(int x, int y) {
|
2013-10-17 20:09:26 +00:00
|
|
|
double mindist = 1.0e20;
|
2013-11-02 23:15:49 +00:00
|
|
|
MovGraphLink *res = 0;
|
2013-10-15 06:10:57 +00:00
|
|
|
|
2013-10-17 20:09:26 +00:00
|
|
|
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
|
|
|
|
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
|
|
|
|
|
|
|
|
MovGraphLink *lnk = (MovGraphLink *)*i;
|
|
|
|
|
|
|
|
if (!(lnk->_flags & 0x20000000)) {
|
|
|
|
double n1x = lnk->_movGraphNode1->_x;
|
|
|
|
double n1y = lnk->_movGraphNode1->_y;
|
|
|
|
double n2x = lnk->_movGraphNode2->_x;
|
|
|
|
double n2y = lnk->_movGraphNode2->_y;
|
|
|
|
double n1dx = n1x - x;
|
|
|
|
double n1dy = n1y - y;
|
|
|
|
double dst1 = sqrt(n1dy * n1dy + n1dx * n1dx);
|
|
|
|
double coeff1 = ((n1y - n2y) * n1dy + (n2x - n1x) * n1dx) / lnk->_distance / dst1;
|
|
|
|
double dst3 = coeff1 * dst1;
|
|
|
|
double dst2 = sqrt(1.0 - coeff1 * coeff1) * dst1;
|
|
|
|
|
|
|
|
if (coeff1 * dst1 < 0.0) {
|
|
|
|
dst3 = 0.0;
|
|
|
|
dst2 = sqrt(n1dy * n1dy + n1dx * n1dx);
|
|
|
|
}
|
|
|
|
if (dst3 > lnk->_distance) {
|
|
|
|
dst3 = lnk->_distance;
|
|
|
|
dst2 = sqrt((n2x - x) * (n2x - x) + (n2y - y) * (n2y - y));
|
|
|
|
}
|
|
|
|
if (dst3 >= 0.0 && dst3 <= lnk->_distance && dst2 < mindist) {
|
|
|
|
mindist = dst2;
|
|
|
|
res = lnk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mindist < 1.0e20)
|
|
|
|
return res;
|
|
|
|
else
|
|
|
|
return 0;
|
2013-10-15 06:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj) {
|
2013-10-18 21:44:10 +00:00
|
|
|
LinkInfo linkInfoWorkSource;
|
|
|
|
|
|
|
|
if (linkInfoSource->link != linkInfoDest->link || linkInfoSource->node != linkInfoDest->node) {
|
|
|
|
double minDistance = -1.0;
|
|
|
|
|
|
|
|
if (linkInfoSource->node) {
|
|
|
|
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
|
|
|
|
MovGraphLink *lnk = (MovGraphLink *)*i;
|
|
|
|
|
|
|
|
if ((lnk->_movGraphNode1 == linkInfoSource->node || lnk->_movGraphNode2 == linkInfoSource->node) && !(lnk->_flags & 0xA0000000)) {
|
|
|
|
linkInfoWorkSource.node = 0;
|
|
|
|
linkInfoWorkSource.link = lnk;
|
|
|
|
|
|
|
|
Common::Array<MovGraphLink *> tmpList;
|
|
|
|
|
|
|
|
lnk->_flags |= 0x80000000;
|
|
|
|
|
|
|
|
double newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList);
|
|
|
|
|
|
|
|
if (newDistance >= 0.0 && (minDistance < 0.0 || newDistance + lnk->_distance < minDistance)) {
|
|
|
|
listObj->clear();
|
|
|
|
listObj->push_back(tmpList);
|
|
|
|
|
|
|
|
minDistance = newDistance + lnk->_distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
lnk->_flags &= 0x7FFFFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (linkInfoSource->link) {
|
|
|
|
linkInfoWorkSource.node = linkInfoSource->link->_movGraphNode1;
|
|
|
|
linkInfoWorkSource.link = 0;
|
|
|
|
|
|
|
|
Common::Array<MovGraphLink *> tmpList;
|
|
|
|
|
|
|
|
double newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList);
|
2013-10-15 06:10:57 +00:00
|
|
|
|
2013-10-18 21:44:10 +00:00
|
|
|
if (newDistance >= 0.0) {
|
|
|
|
listObj->clear();
|
|
|
|
|
|
|
|
listObj->push_back(linkInfoSource->link);
|
|
|
|
listObj->push_back(tmpList);
|
|
|
|
|
|
|
|
minDistance = newDistance;
|
|
|
|
}
|
|
|
|
|
|
|
|
linkInfoWorkSource.link = 0;
|
|
|
|
linkInfoWorkSource.node = linkInfoSource->link->_movGraphNode2;
|
|
|
|
|
|
|
|
tmpList.clear();
|
|
|
|
|
|
|
|
newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList);
|
|
|
|
|
|
|
|
if (newDistance >= 0 && (minDistance < 0.0 || newDistance < minDistance)) {
|
|
|
|
listObj->push_back(linkInfoSource->link);
|
|
|
|
listObj->push_back(tmpList);
|
|
|
|
|
|
|
|
minDistance = newDistance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return minDistance;
|
|
|
|
} else {
|
|
|
|
if (linkInfoSource->link)
|
|
|
|
listObj->push_back(linkInfoSource->link);
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
}
|
2013-10-15 06:10:57 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
MovGraphNode *MovGraph::calcOffset(int ox, int oy) {
|
2013-10-22 21:36:43 +00:00
|
|
|
MovGraphNode *res = 0;
|
|
|
|
double mindist = 1.0e10;
|
2013-09-17 20:00:33 +00:00
|
|
|
|
2013-10-22 21:36:43 +00:00
|
|
|
for (ObList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
|
|
|
|
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphNode);
|
|
|
|
|
|
|
|
MovGraphNode *node = (MovGraphNode *)*i;
|
|
|
|
|
|
|
|
double dist = sqrt((double)((node->_x - oy) * (node->_x - oy) + (node->_x - ox) * (node->_x - ox)));
|
|
|
|
if (dist < mindist) {
|
|
|
|
mindist = dist;
|
|
|
|
res = node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2013-09-17 20:00:33 +00:00
|
|
|
}
|
|
|
|
|
2013-10-01 19:56:50 +00:00
|
|
|
void MGM::clear() {
|
2013-10-02 06:03:08 +00:00
|
|
|
_items.clear();
|
2013-10-01 19:56:50 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:20:04 +00:00
|
|
|
MGMItem::MGMItem() {
|
|
|
|
objId = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-02 06:24:23 +00:00
|
|
|
MGMSubItem::MGMSubItem() {
|
|
|
|
movement = 0;
|
|
|
|
staticsIndex = 0;
|
|
|
|
field_8 = 0;
|
|
|
|
field_C = 0;
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-01 19:56:50 +00:00
|
|
|
void MGM::addItem(int objId) {
|
2013-10-02 05:20:04 +00:00
|
|
|
if (getItemIndexById(objId) == -1) {
|
|
|
|
MGMItem *item = new MGMItem();
|
|
|
|
|
|
|
|
item->objId = objId;
|
|
|
|
_items.push_back(item);
|
|
|
|
}
|
|
|
|
rebuildTables(objId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MGM::rebuildTables(int objId) {
|
2013-10-02 06:24:23 +00:00
|
|
|
int idx = getItemIndexById(objId);
|
|
|
|
|
|
|
|
if (idx == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_items[idx]->subItems.clear();
|
|
|
|
_items[idx]->statics.clear();
|
|
|
|
_items[idx]->movements1.clear();
|
|
|
|
_items[idx]->movements2.clear();
|
|
|
|
|
2013-12-20 14:08:02 +00:00
|
|
|
StaticANIObject *obj = g_fp->_currentScene->getStaticANIObject1ById(objId, -1);
|
2013-10-02 06:24:23 +00:00
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
|
2013-10-02 19:39:11 +00:00
|
|
|
for (uint i = 0; i < obj->_staticsList.size(); i++)
|
|
|
|
_items[idx]->statics.push_back((Statics *)obj->_staticsList[i]);
|
|
|
|
|
|
|
|
for (uint i = 0; i < obj->_movements.size(); i++)
|
|
|
|
_items[idx]->movements1.push_back((Movement *)obj->_movements[i]);
|
|
|
|
|
|
|
|
_items[idx]->subItems.clear();
|
2013-10-02 05:20:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int MGM::getItemIndexById(int objId) {
|
2013-10-02 05:55:07 +00:00
|
|
|
for (uint i = 0; i < _items.size(); i++)
|
|
|
|
if (_items[i]->objId == objId)
|
|
|
|
return i;
|
2013-10-02 05:20:04 +00:00
|
|
|
|
|
|
|
return -1;
|
2013-10-01 19:56:50 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 10:19:25 +00:00
|
|
|
MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
|
|
|
|
warning("STUB: MGM::genMovement()");
|
|
|
|
|
|
|
|
return 0;
|
2014-01-31 13:21:46 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (!mgminfo->ani)
|
|
|
|
return 0;
|
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
mov = mgminfo->ani->_movement;
|
2014-01-31 13:21:46 +00:00
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
if (!mov && !mgminfo->ani->_statics)
|
2014-01-31 13:21:46 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(mgminfo->flags & 1)) {
|
|
|
|
if (mov)
|
2014-01-31 13:34:37 +00:00
|
|
|
mgminfo->staticsId1 = mov->_staticsObj2->_staticsId;
|
2014-01-31 13:21:46 +00:00
|
|
|
else
|
2014-01-31 13:34:37 +00:00
|
|
|
mgminfo->staticsId1 = mgminfo->ani->_statics->_staticsId;
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
if (!(mgminfo->flags & 0x10) || !(mgminfo->flags & 0x20)) {
|
2014-01-31 20:16:52 +00:00
|
|
|
int nx = mgminfo->ani->_ox;
|
|
|
|
int ny = mgminfo->ani->_oy;
|
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
if (mgminfo->ani->_movement) {
|
2014-01-31 20:16:52 +00:00
|
|
|
mgminfo->ani->calcNextStep(&point2);
|
|
|
|
nx += point2.x;
|
|
|
|
ny += point2.y;
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
2014-01-31 20:16:52 +00:00
|
|
|
|
2014-01-31 13:21:46 +00:00
|
|
|
if (!(mgminfo->flags & 0x10))
|
2014-01-31 20:16:52 +00:00
|
|
|
mgminfo->x2 = nx;
|
|
|
|
|
|
|
|
if (!(mgminfo->flags & 0x20))
|
|
|
|
mgminfo->y2 = ny;
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 20:16:52 +00:00
|
|
|
mov = mgminfo->ani->getMovementById(mgminfo->movementId);
|
2014-01-31 13:21:46 +00:00
|
|
|
|
|
|
|
if (!mov)
|
|
|
|
return 0;
|
|
|
|
|
2014-01-31 20:16:52 +00:00
|
|
|
itemIdx = getItemIndexById(mgminfo->ani->_id);
|
|
|
|
subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1);
|
|
|
|
st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId);
|
|
|
|
st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId);
|
|
|
|
subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2);
|
|
|
|
|
|
|
|
clearMovements2(itemIdx);
|
|
|
|
recalcOffsets(itemIdx, subIdx, st2idx, 0, 1);
|
|
|
|
clearMovements2(itemIdx);
|
|
|
|
recalcOffsets(itemIdx, st1idx, subOffset, 0, 1);
|
|
|
|
|
|
|
|
v71 = (Message *)(28 * itemIdx);
|
|
|
|
v16 = items[itemIdx].objId;
|
2014-01-31 13:21:46 +00:00
|
|
|
v17 = *(_DWORD *)(v16 + offsetof(MGMItem, staticsListCount));
|
2014-01-31 21:35:14 +00:00
|
|
|
off = *(_DWORD *)(v16 + offsetof(MGMItem, subItems));
|
|
|
|
v18 = (MGMSubItem *)(off + 24 * (subIdx + st2idx * v17));
|
2014-01-31 13:21:46 +00:00
|
|
|
x1 = (int)&v18->movement->go.CObject.vmt;
|
2014-01-31 21:35:14 +00:00
|
|
|
v19 = (MGMSubItem *)(off + 24 * (st1idx + subOffset * v17));
|
2014-01-31 13:21:46 +00:00
|
|
|
v69 = (LONG)&v19->movement->go.CObject.vmt;
|
|
|
|
|
2014-01-31 20:16:52 +00:00
|
|
|
if (subIdx != st2idx && !x1)
|
2014-01-31 13:21:46 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (st1idx != subOffset && !v69)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
point2.x = v18->x;
|
|
|
|
point2.y = v18->y;
|
|
|
|
point3.x = v19->x;
|
|
|
|
point3.y = v19->y;
|
2014-02-01 08:19:05 +00:00
|
|
|
v24 = mgminfo->y1 - mgminfo->y2 - v18->y - v19->y;
|
|
|
|
v99 = mgminfo->x1 - mgminfo->x2 - v18->x - v19->x;
|
2014-01-31 21:35:14 +00:00
|
|
|
v75 = v99;
|
2014-01-31 13:21:46 +00:00
|
|
|
v76 = v24;
|
2014-01-31 20:16:52 +00:00
|
|
|
|
|
|
|
mov->calcSomeXY(&point1, 0);
|
|
|
|
v26 = point1.x;
|
|
|
|
v27 = point1.y;
|
2014-01-31 13:21:46 +00:00
|
|
|
|
|
|
|
if (mgminfo->flags & 0x40) {
|
|
|
|
v62 = mgminfo->field_10;
|
|
|
|
a2 = -1;
|
|
|
|
point1.x = v62 * v26;
|
|
|
|
point1.y = v62 * v27;
|
|
|
|
} else {
|
2014-01-31 21:35:14 +00:00
|
|
|
calcLength(&point, mov, v99, v24, &v62, &a2, 1);
|
|
|
|
point1.x = point.x;
|
|
|
|
point1.y = point.y;
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(mgminfo->flags & 2)) {
|
|
|
|
v32 = point3.x + mgminfo->x2;
|
|
|
|
a2 = -1;
|
2014-01-31 21:35:14 +00:00
|
|
|
point1.x = v62 * v26;
|
|
|
|
v75 = v62 * v26;
|
|
|
|
mgminfo->x1 = v62 * v26 + point2.x + v32;
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 20:16:52 +00:00
|
|
|
if (!(mgminfo->flags & 4)) {
|
2014-01-31 21:35:14 +00:00
|
|
|
point1.y = v62 * v27;
|
|
|
|
v76 = v62 * v27;
|
2014-01-31 13:21:46 +00:00
|
|
|
a2 = -1;
|
2014-01-31 21:35:14 +00:00
|
|
|
mgminfo->y1 = mgminfo->y2 + v62 * v27 + point2.y + point3.y;
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
int px = 0;
|
|
|
|
int py = 0;
|
2014-01-31 13:21:46 +00:00
|
|
|
|
|
|
|
if (x1) {
|
2014-01-31 21:35:14 +00:00
|
|
|
px = countPhases(itemIdx, subIdx, st2idx, 1);
|
|
|
|
py = countPhases(itemIdx, subIdx, st2idx, 2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
if (v62 > 1) {
|
|
|
|
px += (v62 - 1) * mov->countPhasesWithFlag(-1, 1);
|
|
|
|
py += (v62 - 1) * mov->countPhasesWithFlag(-1, 2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
if (v62 > 0) {
|
|
|
|
px += mov->countPhasesWithFlag(a2, 1);
|
|
|
|
py += mov->countPhasesWithFlag(a2, 2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (v69) {
|
2014-01-31 21:35:14 +00:00
|
|
|
px += countPhases(itemIdx, st1idx, subOffset, 1);
|
|
|
|
py += countPhases(itemIdx, st1idx, subOffset, 2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v69 = v75 - point1.x;
|
|
|
|
v38 = v76 - point1.y;
|
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
if (px) {
|
|
|
|
x1 = (signed __int64)((double)v69 / (double)px);
|
2014-01-31 13:21:46 +00:00
|
|
|
} else {
|
|
|
|
x1 = 0;
|
|
|
|
}
|
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
if (py) {
|
|
|
|
y1 = (signed __int64)((double)v38 / (double)py);
|
2014-01-31 13:21:46 +00:00
|
|
|
} else {
|
|
|
|
y1 = 0;
|
|
|
|
}
|
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
y2 = v75 - point1.x - px * x1;
|
|
|
|
v78 = v38 - py * y1;
|
2014-01-31 13:21:46 +00:00
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
if (v75 - point1.x == px * x1)
|
2014-01-31 13:21:46 +00:00
|
|
|
x2 = 0;
|
|
|
|
else
|
2014-01-31 21:35:14 +00:00
|
|
|
x2 = (v75 - point1.x - px * x1) / abs(v75 - point1.x - px * x1);
|
2014-01-31 13:21:46 +00:00
|
|
|
|
2014-01-31 21:35:14 +00:00
|
|
|
if (v38 == py * y1)
|
2014-01-31 13:21:46 +00:00
|
|
|
v74 = 0;
|
|
|
|
else
|
2014-01-31 21:35:14 +00:00
|
|
|
v74 = (v38 - py * y1) / abs(v38 - py * y1);
|
2014-01-31 13:21:46 +00:00
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact());
|
|
|
|
ExCommand2 *ex2;
|
2014-01-31 13:21:46 +00:00
|
|
|
|
|
|
|
for (v42 = subIdx; v42 != st2idx; v42 = v43->staticsIndex) {
|
|
|
|
v43 = &(*(MGMSubItem **)((char *)&this->items->subItems + (unsigned int)v71))[v42 + st2idx * *(int *)((char *)&this->items->staticsListCount + (unsigned int)v71)];
|
2014-01-31 13:34:37 +00:00
|
|
|
ex2 = buildExCommand2(v43->movement, mgminfo->ani->go._id, x1, y1, (POINT *)&x2, (POINT *)&y2, -1);
|
|
|
|
ex2->_parId = mq->_id;
|
|
|
|
ex2->_keyCode = mgminfo->ani->_okeyCode;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < v62; ++i) {
|
2014-01-31 13:34:37 +00:00
|
|
|
if (i == v62 - 1)
|
2014-01-31 13:21:46 +00:00
|
|
|
v47 = a2;
|
|
|
|
else
|
|
|
|
v47 = -1;
|
2014-01-31 13:34:37 +00:00
|
|
|
|
|
|
|
ex2 = buildExCommand2(mov, mgminfo->ani->_id, x1, y1, (POINT *)&x2, (POINT *)&y2, v47);
|
|
|
|
ex2->_parId = mq->_id;
|
|
|
|
ex2->_keyCode = mgminfo->ani->_okeyCode;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (j = st1idx; j != subOffset; j = v50->staticsIndex) {
|
|
|
|
v50 = &(*(MGMSubItem **)((char *)&this->items->subItems + (unsigned int)v71))[j + subOffset * *(int *)((char *)&this->items->staticsListCount + (unsigned int)v71)];
|
2014-01-31 13:34:37 +00:00
|
|
|
|
|
|
|
ex2 = buildExCommand2(v50->movement, mgminfo->ani->_id, x1, y1, (POINT *)&x2, (POINT *)&y2, -1);
|
|
|
|
ex2->_parId = mq->_id;
|
|
|
|
ex2->_keyCode = mgminfo->ani->_okeyCode;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex2);
|
2014-01-31 13:21:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
ExCommand *ex = new ExCommand(mgminfo->ani->_id, 5, -1, mgminfo->x1, mgminfo->y1, 0, 1, 0, 0, 0);
|
2014-01-31 13:21:46 +00:00
|
|
|
|
2014-01-31 13:34:37 +00:00
|
|
|
ex->_field_14 = mgminfo->field_1C;
|
|
|
|
ex->_keyCode = mgminfo->ani->_okeyCode;
|
|
|
|
ex->_field_24 = 0;
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
2014-01-31 13:21:46 +00:00
|
|
|
|
|
|
|
return mq;
|
|
|
|
#endif
|
2013-11-17 10:19:25 +00:00
|
|
|
}
|
|
|
|
|
2013-12-11 20:54:15 +00:00
|
|
|
void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) {
|
2013-12-11 21:03:51 +00:00
|
|
|
if (getItemIndexById(ani->_id) == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ani->_movement) {
|
|
|
|
ani->queueMessageQueue(0);
|
|
|
|
ani->_movement->gotoLastFrame();
|
|
|
|
ani->_statics = ani->_movement->_staticsObj2;
|
2013-12-19 21:34:26 +00:00
|
|
|
|
|
|
|
int x = ani->_movement->_ox;
|
|
|
|
int y = ani->_movement->_oy;
|
|
|
|
|
2013-12-11 21:03:51 +00:00
|
|
|
ani->_movement = 0;
|
|
|
|
|
2013-12-19 21:34:26 +00:00
|
|
|
ani->setOXY(x, y);
|
2013-12-11 21:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ani->_statics) {
|
|
|
|
Common::Point point;
|
|
|
|
|
|
|
|
getPoint(&point, ani->_id, ani->_statics->_staticsId, staticsId);
|
|
|
|
|
|
|
|
ani->setOXY(ani->_ox + point.x, ani->_oy + point.y);
|
|
|
|
|
|
|
|
ani->_statics = ani->getStaticsById(staticsId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-15 12:20:13 +00:00
|
|
|
Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, int staticsId2) {
|
|
|
|
int idx = getItemIndexById(objectId);
|
|
|
|
|
|
|
|
if (idx == -1) {
|
|
|
|
point->x = -1;
|
|
|
|
point->y = -1;
|
|
|
|
} else {
|
|
|
|
int st1idx = getStaticsIndexById(idx, staticsId1);
|
|
|
|
int st2idx = getStaticsIndexById(idx, staticsId2);
|
|
|
|
|
|
|
|
if (st1idx == st2idx) {
|
|
|
|
point->x = 0;
|
|
|
|
point->y = 0;
|
|
|
|
} else {
|
|
|
|
int subidx = st1idx + st2idx * _items[idx]->statics.size();
|
|
|
|
|
|
|
|
if (!_items[idx]->subItems[subidx]->movement) {
|
|
|
|
clearMovements2(idx);
|
|
|
|
recalcOffsets(idx, st1idx, st2idx, false, true);
|
|
|
|
|
|
|
|
if (!_items[idx]->subItems[subidx]->movement) {
|
|
|
|
clearMovements2(idx);
|
|
|
|
recalcOffsets(idx, st1idx, st2idx, true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MGMSubItem *sub = _items[idx]->subItems[subidx];
|
|
|
|
|
|
|
|
if (sub->movement) {
|
|
|
|
point->x = sub->x;
|
|
|
|
point->y = sub->y;
|
|
|
|
} else {
|
|
|
|
point->x = 0;
|
|
|
|
point->y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-11 21:03:51 +00:00
|
|
|
|
|
|
|
return point;
|
2013-12-11 20:54:15 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 12:20:13 +00:00
|
|
|
int MGM::getStaticsIndexById(int idx, int16 id) {
|
2014-01-08 08:58:26 +00:00
|
|
|
if (!_items[idx]->statics.size())
|
|
|
|
return -1;
|
|
|
|
|
2013-12-15 12:20:13 +00:00
|
|
|
for (uint i = 0; i < _items[idx]->statics.size(); i++) {
|
|
|
|
if (_items[idx]->statics[i]->_staticsId == id)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-08 08:58:26 +00:00
|
|
|
int MGM::getStaticsIndex(int idx, Statics *st) {
|
|
|
|
if (!_items[idx]->statics.size())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (uint i = 0; i < _items[idx]->statics.size(); i++) {
|
|
|
|
if (_items[idx]->statics[i] == st)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-15 12:20:13 +00:00
|
|
|
void MGM::clearMovements2(int idx) {
|
|
|
|
_items[idx]->movements2.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
|
|
|
|
warning("STUB: MGM::recalcOffsets()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, int *x1, int *y1, int flag) {
|
|
|
|
Common::Point point;
|
|
|
|
|
|
|
|
mov->calcSomeXY(point, 0);
|
|
|
|
int p1x = point.x;
|
|
|
|
int p1y = point.y;
|
|
|
|
|
|
|
|
int newx1 = 0;
|
|
|
|
int oldy1 = *y1;
|
|
|
|
|
|
|
|
if (abs(p1y) > abs(p1x)) {
|
|
|
|
if (mov->calcSomeXY(point, 0)->y)
|
|
|
|
newx1 = (int)((double)y / point.y);
|
|
|
|
} else if (mov->calcSomeXY(point, 0)->x) {
|
|
|
|
newx1 = (int)((double)x / point.y);
|
2014-01-11 00:18:53 +00:00
|
|
|
}
|
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
if (newx1 < 0)
|
|
|
|
newx1 = 0;
|
|
|
|
|
|
|
|
*x1 = newx1;
|
|
|
|
|
|
|
|
int phase = 1;
|
|
|
|
int sz;
|
2014-01-11 00:18:53 +00:00
|
|
|
|
|
|
|
if (flag) {
|
2014-01-11 09:29:00 +00:00
|
|
|
if (abs(p1y) > abs(p1x)) {
|
|
|
|
while (abs(p1y * newx1 + mov->calcSomeXY(point, 0)->y) < abs(y)) {
|
|
|
|
sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
|
|
|
|
|
|
|
|
if (phase >= sz) {
|
|
|
|
phase--;
|
|
|
|
|
|
|
|
break;
|
2014-01-11 00:18:53 +00:00
|
|
|
}
|
2014-01-11 09:29:00 +00:00
|
|
|
|
|
|
|
phase++;
|
2014-01-11 00:18:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-01-11 09:29:00 +00:00
|
|
|
while (abs(p1x * newx1 + mov->calcSomeXY(point, 0)->x) < abs(x)) {
|
|
|
|
sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
|
|
|
|
|
|
|
|
if (phase >= sz) {
|
|
|
|
phase--;
|
|
|
|
|
|
|
|
break;
|
2014-01-11 00:18:53 +00:00
|
|
|
}
|
2014-01-11 09:29:00 +00:00
|
|
|
|
|
|
|
phase++;
|
2014-01-11 00:18:53 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-11 09:29:00 +00:00
|
|
|
|
|
|
|
*y1 = phase - 1;
|
2014-01-11 00:18:53 +00:00
|
|
|
} else {
|
|
|
|
*y1 = -1;
|
|
|
|
}
|
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
int p2x = 0;
|
|
|
|
int p2y = 0;
|
2014-01-11 00:18:53 +00:00
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
if (!oldy1)
|
|
|
|
oldy1 = -1;
|
2014-01-11 00:18:53 +00:00
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
if (oldy1 > 0) {
|
2014-01-11 00:18:53 +00:00
|
|
|
++*x1;
|
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
mov->calcSomeXY(point, 0);
|
|
|
|
p2x = point.x;
|
|
|
|
p2y = point.y;
|
|
|
|
|
|
|
|
if (abs(p1y) > abs(p1x))
|
|
|
|
p2x = p1x;
|
2014-01-11 00:18:53 +00:00
|
|
|
else
|
2014-01-11 09:29:00 +00:00
|
|
|
p2y = p1y;
|
2014-01-11 00:18:53 +00:00
|
|
|
}
|
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
pRes->x = p2x + p1x * newx1;
|
|
|
|
pRes->y = p2y + p1y * newx1;
|
2014-01-04 12:23:55 +00:00
|
|
|
|
2014-01-11 09:29:00 +00:00
|
|
|
return pRes;
|
2014-01-04 12:23:55 +00:00
|
|
|
}
|
|
|
|
|
2014-01-04 20:16:53 +00:00
|
|
|
ExCommand2 *MGM::buildExCommand2(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len) {
|
|
|
|
uint cnt;
|
|
|
|
|
|
|
|
if (mov->_currMovement)
|
|
|
|
cnt = mov->_currMovement->_dynamicPhases.size();
|
|
|
|
else
|
|
|
|
cnt = mov->_dynamicPhases.size();
|
|
|
|
|
2014-01-04 23:04:39 +00:00
|
|
|
if (len > 0 && cnt > (uint)len)
|
2014-01-04 20:16:53 +00:00
|
|
|
cnt = len;
|
|
|
|
|
|
|
|
Common::Point **points = (Common::Point **)malloc(sizeof(Common::Point *) * cnt);
|
|
|
|
|
|
|
|
for (uint i = 0; i < cnt; i++) {
|
|
|
|
int flags = mov->getDynamicPhaseByIndex(i)->getDynFlags();
|
|
|
|
|
|
|
|
points[i] = new Common::Point;
|
|
|
|
|
|
|
|
if (flags & 1) {
|
|
|
|
points[i]->x = x1 + x2->x;
|
|
|
|
|
|
|
|
y2->x -= x2->x;
|
|
|
|
|
|
|
|
if (!y2->x)
|
|
|
|
x2->x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & 2) {
|
|
|
|
points[i]->y = y1 + x2->y;
|
|
|
|
|
|
|
|
y2->y -= x2->y;
|
|
|
|
|
2014-01-11 00:18:53 +00:00
|
|
|
if (!y2->y)
|
2014-01-04 20:16:53 +00:00
|
|
|
x2->y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ExCommand2 *ex = new ExCommand2(20, objId, points, cnt);
|
|
|
|
ex->_excFlags = 2;
|
|
|
|
ex->_messageNum = mov->_id;
|
|
|
|
ex->_field_14 = len;
|
|
|
|
ex->_field_24 = 1;
|
|
|
|
ex->_keyCode = -1;
|
|
|
|
|
2014-01-04 23:04:39 +00:00
|
|
|
for (uint i = 0; i < cnt; i++)
|
2014-01-04 20:16:53 +00:00
|
|
|
delete points[i];
|
2014-01-04 12:23:55 +00:00
|
|
|
|
2014-01-04 20:16:53 +00:00
|
|
|
free(points);
|
2014-01-04 12:23:55 +00:00
|
|
|
|
2014-01-04 20:16:53 +00:00
|
|
|
return ex;
|
2014-01-04 12:23:55 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
MovGraphLink::MovGraphLink() {
|
2013-07-06 19:56:11 +00:00
|
|
|
_distance = 0;
|
|
|
|
_angle = 0;
|
|
|
|
_flags = 0x10000000;
|
|
|
|
_movGraphNode2 = 0;
|
|
|
|
_movGraphNode1 = 0;
|
|
|
|
_field_3C = 0;
|
|
|
|
_field_38 = 0;
|
|
|
|
_movGraphReact = 0;
|
2013-08-14 18:11:12 +00:00
|
|
|
_name = 0;
|
2013-10-17 19:44:30 +00:00
|
|
|
|
|
|
|
_objtype = kObjTypeMovGraphLink;
|
2013-06-16 13:10:46 +00:00
|
|
|
}
|
|
|
|
|
2014-01-09 20:24:14 +00:00
|
|
|
MovGraphLink::~MovGraphLink() {
|
|
|
|
warning("STUB: MovGraphLink::~MovGraphLink()");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool MovGraphLink::load(MfcArchive &file) {
|
|
|
|
debug(5, "MovGraphLink::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_dwordArray1.load(file);
|
|
|
|
_dwordArray2.load(file);
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_flags = file.readUint32LE();
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
debug(8, "GraphNode1");
|
2013-09-18 15:04:36 +00:00
|
|
|
_movGraphNode1 = (MovGraphNode *)file.readClass();
|
2013-07-06 19:56:11 +00:00
|
|
|
debug(8, "GraphNode2");
|
2013-09-18 15:04:36 +00:00
|
|
|
_movGraphNode2 = (MovGraphNode *)file.readClass();
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_distance = file.readDouble();
|
|
|
|
_angle = file.readDouble();
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
debug(8, "distance: %g, angle: %g", _distance, _angle);
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
_movGraphReact = (MovGraphReact *)file.readClass();
|
2013-07-06 19:56:11 +00:00
|
|
|
_name = file.readPascalString();
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
return true;
|
2013-06-16 13:10:46 +00:00
|
|
|
}
|
|
|
|
|
2013-10-22 21:49:55 +00:00
|
|
|
void MovGraphLink::calcNodeDistanceAndAngle() {
|
|
|
|
if (_movGraphNode1) {
|
|
|
|
double dx = _movGraphNode2->_x - _movGraphNode1->_x;
|
|
|
|
double dy = _movGraphNode2->_y - _movGraphNode1->_y;
|
|
|
|
|
|
|
|
_distance = sqrt(dy * dy + dx * dx);
|
|
|
|
_angle = atan2(dx, dy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool MovGraphNode::load(MfcArchive &file) {
|
|
|
|
debug(5, "MovGraphNode::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_field_14 = file.readUint32LE();
|
|
|
|
_x = file.readUint32LE();
|
|
|
|
_y = file.readUint32LE();
|
|
|
|
_distance = file.readUint32LE();
|
2013-06-16 13:10:46 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
return true;
|
2013-06-16 13:10:46 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
ReactParallel::ReactParallel() {
|
2013-07-06 19:56:11 +00:00
|
|
|
_x1 = 0;
|
|
|
|
_x2 = 0;
|
|
|
|
_dy = 0;
|
|
|
|
_dx = 0;
|
|
|
|
_y1 = 0;
|
|
|
|
_y2 = 0;
|
2013-06-18 14:04:29 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool ReactParallel::load(MfcArchive &file) {
|
|
|
|
debug(5, "ReactParallel::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_x1 = file.readUint32LE();
|
|
|
|
_y1 = file.readUint32LE();
|
|
|
|
_x2 = file.readUint32LE();
|
|
|
|
_y2 = file.readUint32LE();
|
|
|
|
_dx = file.readUint32LE();
|
|
|
|
_dy = file.readUint32LE();
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
createRegion();
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
return true;
|
2013-06-18 14:04:29 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
void ReactParallel::createRegion() {
|
2013-07-06 19:56:11 +00:00
|
|
|
_points = (Common::Point **)malloc(sizeof(Common::Point *) * 4);
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
_points[i] = new Common::Point;
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-12-30 23:35:40 +00:00
|
|
|
double at = atan2((double)(_x1 - _x2), (double)(_y1 - _y2)) + 1.570796; // pi/2
|
2013-07-06 19:56:11 +00:00
|
|
|
double sn = sin(at);
|
|
|
|
double cs = cos(at);
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_points[0]->x = (int16)(_x1 - _dx * cs);
|
|
|
|
_points[0]->y = (int16)(_y1 - _dx * sn);
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_points[1]->x = (int16)(_x2 - _dx * cs);
|
|
|
|
_points[1]->y = (int16)(_y2 - _dx * sn);
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-10-05 08:52:50 +00:00
|
|
|
_points[2]->x = (int16)(_x2 + _dy * cs);
|
2013-07-06 19:56:11 +00:00
|
|
|
_points[2]->y = (int16)(_y2 + _dy * sn);
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_points[3]->x = (int16)(_x1 + _dy * cs);
|
|
|
|
_points[3]->y = (int16)(_y1 + _dy * sn);
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2013-10-05 08:52:50 +00:00
|
|
|
_pointCount = 4;
|
2013-07-06 19:56:11 +00:00
|
|
|
// GdiObject::Attach(_rgn, CreatePolygonRgn(_points, 4, 2);
|
2013-06-18 14:04:29 +00:00
|
|
|
}
|
|
|
|
|
2014-01-03 20:54:51 +00:00
|
|
|
void ReactParallel::setCenter(int x1, int y1, int x2, int y2) {
|
|
|
|
_x1 = x1;
|
|
|
|
_y1 = y1;
|
|
|
|
_x2 = x2;
|
|
|
|
_y2 = y2;
|
2013-10-04 20:14:09 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
ReactPolygonal::ReactPolygonal() {
|
2014-01-03 20:43:46 +00:00
|
|
|
_centerX = 0;
|
|
|
|
_centerY = 0;
|
2014-01-03 23:02:12 +00:00
|
|
|
_bbox = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactPolygonal::~ReactPolygonal() {
|
|
|
|
delete _bbox;
|
2013-06-18 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
bool ReactPolygonal::load(MfcArchive &file) {
|
|
|
|
debug(5, "ReactPolygonal::load()");
|
2013-07-12 06:03:02 +00:00
|
|
|
|
2014-01-03 20:43:46 +00:00
|
|
|
_centerX = file.readUint32LE();
|
|
|
|
_centerY = file.readUint32LE();
|
2013-07-06 19:56:11 +00:00
|
|
|
_pointCount = file.readUint32LE();
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
if (_pointCount > 0) {
|
|
|
|
_points = (Common::Point **)malloc(sizeof(Common::Point *) * _pointCount);
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
for (int i = 0; i < _pointCount; i++) {
|
|
|
|
_points[i] = new Common::Point;
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
_points[i]->x = file.readUint32LE();
|
|
|
|
_points[i]->y = file.readUint32LE();
|
|
|
|
}
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
}
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
createRegion();
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
return true;
|
2013-06-18 14:23:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 15:04:36 +00:00
|
|
|
void ReactPolygonal::createRegion() {
|
2013-07-06 19:56:11 +00:00
|
|
|
if (_points) {
|
2013-06-18 14:23:49 +00:00
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
// GdiObject::Attach(_rgn, CreatePolygonRgn(_points, _pointCount, 2);
|
|
|
|
}
|
2013-06-18 14:23:49 +00:00
|
|
|
}
|
2013-06-18 14:04:29 +00:00
|
|
|
|
2014-01-03 20:54:51 +00:00
|
|
|
void ReactPolygonal::setCenter(int x1, int y1, int x2, int y2) {
|
|
|
|
int cX = (x2 + x1) / 2;
|
|
|
|
int cY = (y2 + y1) / 2;
|
|
|
|
|
|
|
|
if (_points) {
|
|
|
|
for (int i = 0; i < _pointCount; i++) {
|
|
|
|
_points[i]->x += cX - _centerX;
|
|
|
|
_points[i]->y += cY - _centerY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_centerX = cX;
|
|
|
|
_centerY = cY;
|
2013-10-04 20:14:09 +00:00
|
|
|
}
|
|
|
|
|
2014-01-03 23:02:12 +00:00
|
|
|
void ReactPolygonal::getBBox(Common::Rect *rect) {
|
|
|
|
if (!_pointCount)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_bbox) {
|
|
|
|
*rect = *_bbox;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect->left = _points[0]->x;
|
|
|
|
rect->top = _points[0]->y;
|
|
|
|
rect->right = _points[0]->x;
|
|
|
|
rect->bottom = _points[0]->y;
|
|
|
|
|
|
|
|
for (int i = 1; i < _pointCount; i++) {
|
|
|
|
if (rect->left > _points[i]->x)
|
|
|
|
rect->left = _points[i]->x;
|
|
|
|
|
|
|
|
if (rect->top < _points[i]->y)
|
|
|
|
rect->top = _points[i]->y;
|
|
|
|
|
|
|
|
if (rect->right < _points[i]->x)
|
|
|
|
rect->right = _points[i]->x;
|
|
|
|
|
|
|
|
if (rect->bottom > _points[i]->y)
|
|
|
|
rect->bottom = _points[i]->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
_bbox = new Common::Rect;
|
|
|
|
*_bbox = *rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-05 08:52:50 +00:00
|
|
|
bool MovGraphReact::pointInRegion(int x, int y) {
|
|
|
|
if (_pointCount < 3) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
double xinters;
|
|
|
|
Common::Point p, p1, p2;
|
|
|
|
|
2013-12-18 08:16:19 +00:00
|
|
|
p.x = x;
|
|
|
|
p.y = y;
|
2013-10-05 08:52:50 +00:00
|
|
|
|
2013-12-18 08:16:19 +00:00
|
|
|
p1.x = _points[0]->x;
|
|
|
|
p1.y = _points[0]->y;
|
2013-10-05 08:52:50 +00:00
|
|
|
|
2013-10-06 05:11:09 +00:00
|
|
|
for (int i = 1; i <= _pointCount; i++) {
|
2013-12-18 08:16:19 +00:00
|
|
|
p2.x = _points[i % _pointCount]->x;
|
|
|
|
p2.y = _points[i % _pointCount]->y;
|
2013-10-05 08:52:50 +00:00
|
|
|
|
|
|
|
if (p.y > MIN(p1.y, p2.y)) {
|
|
|
|
if (p.y <= MAX(p1.y, p2.y)) {
|
|
|
|
if (p.x <= MAX(p1.x, p2.x)) {
|
|
|
|
if (p1.y != p2.y) {
|
|
|
|
xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
|
|
|
|
if (p1.x == p2.x || p.x <= xinters) {
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p1 = p2;
|
|
|
|
}
|
2013-10-04 20:14:09 +00:00
|
|
|
|
2013-10-05 08:52:50 +00:00
|
|
|
if (counter % 2 == 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
2013-10-04 20:14:09 +00:00
|
|
|
}
|
|
|
|
|
2013-08-26 19:17:20 +00:00
|
|
|
int startWalkTo(int objId, int objKey, int x, int y, int a5) {
|
2013-12-20 14:08:02 +00:00
|
|
|
MctlCompound *mc = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId);
|
2013-09-18 18:30:06 +00:00
|
|
|
|
|
|
|
if (mc)
|
2013-12-20 14:08:02 +00:00
|
|
|
return (mc->method34(g_fp->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, a5, 0) != 0);
|
2013-08-26 19:17:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int doSomeAnimation(int objId, int objKey, int a3) {
|
2014-01-04 20:54:50 +00:00
|
|
|
StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(objId, objKey);
|
|
|
|
MctlCompound *cmp = getCurrSceneSc2MotionController();
|
|
|
|
|
|
|
|
if (ani && cmp)
|
|
|
|
return cmp->method3C(ani, a3);
|
2013-08-26 19:17:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int doSomeAnimation2(int objId, int objKey) {
|
|
|
|
return doSomeAnimation(objId, objKey, 0);
|
|
|
|
}
|
|
|
|
|
2013-06-16 12:11:18 +00:00
|
|
|
} // End of namespace Fullpipe
|