2013-06-20 19:34:29 +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 "fullpipe/objects.h"
|
2013-06-20 20:39:05 +00:00
|
|
|
#include "fullpipe/ngiarchive.h"
|
2013-06-22 02:04:17 +00:00
|
|
|
#include "fullpipe/statics.h"
|
2013-07-26 12:42:11 +00:00
|
|
|
#include "fullpipe/messages.h"
|
2013-08-24 18:07:16 +00:00
|
|
|
#include "fullpipe/gameloader.h"
|
2013-07-20 13:08:05 +00:00
|
|
|
|
2013-07-30 09:36:33 +00:00
|
|
|
#include "fullpipe/constants.h"
|
2013-06-20 19:34:29 +00:00
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
#include "common/algorithm.h"
|
|
|
|
|
2013-06-20 19:34:29 +00:00
|
|
|
namespace Fullpipe {
|
|
|
|
|
2013-06-20 20:39:05 +00:00
|
|
|
Scene *FullpipeEngine::accessScene(int sceneId) {
|
|
|
|
SceneTag *t = 0;
|
|
|
|
|
|
|
|
for (SceneTagList::iterator s = _gameProject->_sceneTagList->begin(); s != _gameProject->_sceneTagList->end(); ++s) {
|
|
|
|
if (s->_sceneId == sceneId) {
|
|
|
|
t = &(*s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!t)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!t->_scene) {
|
|
|
|
t->loadScene();
|
|
|
|
}
|
|
|
|
|
|
|
|
return t->_scene;
|
2013-06-20 19:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SceneTagList::load(MfcArchive &file) {
|
2013-07-12 06:03:02 +00:00
|
|
|
debug(5, "SceneTagList::load()");
|
|
|
|
|
2013-06-20 19:34:29 +00:00
|
|
|
int numEntries = file.readUint16LE();
|
|
|
|
|
|
|
|
for (int i = 0; i < numEntries; i++) {
|
|
|
|
SceneTag *t = new SceneTag();
|
|
|
|
t->load(file);
|
|
|
|
push_back(*t);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SceneTag::SceneTag() {
|
|
|
|
_field_4 = 0;
|
|
|
|
_scene = 0;
|
2013-08-14 18:11:12 +00:00
|
|
|
_tag = 0;
|
2013-09-20 19:03:36 +00:00
|
|
|
_sceneId = 0;
|
2013-06-20 19:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SceneTag::load(MfcArchive &file) {
|
2013-07-12 06:03:02 +00:00
|
|
|
debug(5, "SceneTag::load()");
|
|
|
|
|
2013-06-20 19:34:29 +00:00
|
|
|
_field_4 = 0;
|
|
|
|
_scene = 0;
|
|
|
|
|
|
|
|
_sceneId = file.readUint16LE();
|
|
|
|
|
|
|
|
_tag = file.readPascalString();
|
|
|
|
|
|
|
|
debug(6, "sceneId: %d tag: %s", _sceneId, _tag);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SceneTag::~SceneTag() {
|
|
|
|
free(_tag);
|
|
|
|
}
|
|
|
|
|
2013-06-20 20:39:05 +00:00
|
|
|
void SceneTag::loadScene() {
|
|
|
|
char *archname = genFileName(0, _sceneId, "nl");
|
|
|
|
|
|
|
|
Common::Archive *arch = makeNGIArchive(archname);
|
|
|
|
|
|
|
|
char *fname = genFileName(0, _sceneId, "sc");
|
|
|
|
|
|
|
|
Common::SeekableReadStream *file = arch->createReadStreamForMember(fname);
|
|
|
|
|
|
|
|
_scene = new Scene();
|
|
|
|
|
2013-06-20 21:21:37 +00:00
|
|
|
MfcArchive archive(file);
|
|
|
|
|
|
|
|
_scene->load(archive);
|
2013-06-20 20:39:05 +00:00
|
|
|
|
2013-07-25 21:14:47 +00:00
|
|
|
if (_scene->_shadows)
|
|
|
|
_scene->_shadows->init();
|
|
|
|
|
2013-06-20 20:39:05 +00:00
|
|
|
delete file;
|
|
|
|
|
2013-06-22 01:30:38 +00:00
|
|
|
g_fullpipe->_currArchive = 0;
|
|
|
|
|
2013-06-20 20:39:05 +00:00
|
|
|
free(fname);
|
|
|
|
free(archname);
|
|
|
|
}
|
|
|
|
|
|
|
|
Scene::Scene() {
|
2013-06-20 22:13:18 +00:00
|
|
|
_sceneId = 0;
|
|
|
|
_field_BC = 0;
|
|
|
|
_shadows = 0;
|
|
|
|
_soundList = 0;
|
2013-07-29 11:28:47 +00:00
|
|
|
_libHandle = 0;
|
2013-08-14 18:11:12 +00:00
|
|
|
_sceneName = 0;
|
2013-06-20 20:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Scene::load(MfcArchive &file) {
|
2013-07-12 06:03:02 +00:00
|
|
|
debug(5, "Scene::load()");
|
|
|
|
|
2013-06-24 03:32:51 +00:00
|
|
|
Background::load(file);
|
2013-06-20 21:21:37 +00:00
|
|
|
|
2013-06-22 02:04:17 +00:00
|
|
|
_sceneId = file.readUint16LE();
|
|
|
|
|
2013-07-19 15:13:00 +00:00
|
|
|
_sceneName = file.readPascalString();
|
|
|
|
debug(0, "scene: <%s> %d", transCyrillic((byte *)_sceneName), _sceneId);
|
2013-06-22 02:04:17 +00:00
|
|
|
|
|
|
|
int count = file.readUint16LE();
|
2013-06-24 03:32:51 +00:00
|
|
|
debug(7, "scene.ani: %d", count);
|
2013-06-22 02:04:17 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
int aniNum = file.readUint16LE();
|
|
|
|
char *aniname = genFileName(0, aniNum, "ani");
|
|
|
|
|
|
|
|
Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(aniname);
|
|
|
|
|
|
|
|
StaticANIObject *ani = new StaticANIObject();
|
|
|
|
|
|
|
|
MfcArchive archive(f);
|
|
|
|
|
|
|
|
ani->load(archive);
|
|
|
|
ani->_sceneId = _sceneId;
|
|
|
|
|
|
|
|
_staticANIObjectList1.push_back(ani);
|
|
|
|
|
|
|
|
delete f;
|
|
|
|
free(aniname);
|
2013-06-22 17:26:49 +00:00
|
|
|
}
|
2013-06-22 02:04:17 +00:00
|
|
|
|
2013-06-24 03:32:51 +00:00
|
|
|
count = file.readUint16LE();
|
|
|
|
debug(7, "scene.mq: %d", count);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
int qNum = file.readUint16LE();
|
|
|
|
char *qname = genFileName(0, qNum, "qu");
|
|
|
|
|
|
|
|
Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(qname);
|
|
|
|
MfcArchive archive(f);
|
|
|
|
|
2013-06-26 19:39:46 +00:00
|
|
|
archive.readUint16LE(); // Skip 2 bytes
|
|
|
|
|
2013-06-24 03:32:51 +00:00
|
|
|
MessageQueue *mq = new MessageQueue();
|
|
|
|
|
|
|
|
mq->load(archive);
|
|
|
|
|
|
|
|
_messageQueueList.push_back(mq);
|
|
|
|
|
|
|
|
delete f;
|
|
|
|
free(qname);
|
|
|
|
}
|
|
|
|
|
|
|
|
count = file.readUint16LE();
|
|
|
|
debug(7, "scene.fa: %d", count);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
// There are no .FA files
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
_libHandle = g_fullpipe->_currArchive;
|
|
|
|
|
2013-07-19 14:59:03 +00:00
|
|
|
if (_picObjList.size() > 0 && _bgname && strlen(_bgname) > 1) {
|
2013-06-24 03:32:51 +00:00
|
|
|
char fname[260];
|
|
|
|
|
2013-07-19 14:59:03 +00:00
|
|
|
strcpy(fname, _bgname);
|
2013-06-24 03:32:51 +00:00
|
|
|
strcpy(strrchr(fname, '.') + 1, "col");
|
|
|
|
|
2013-07-06 19:56:11 +00:00
|
|
|
MemoryObject *col = new MemoryObject();
|
2013-06-24 03:32:51 +00:00
|
|
|
col->loadFile(fname);
|
|
|
|
|
2013-07-19 14:59:03 +00:00
|
|
|
_palette = col;
|
2013-06-24 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *shdname = genFileName(0, _sceneId, "shd");
|
|
|
|
|
2013-06-24 12:28:07 +00:00
|
|
|
Shadows *shd = new Shadows();
|
|
|
|
|
|
|
|
if (shd->loadFile(shdname))
|
|
|
|
_shadows = shd;
|
|
|
|
|
2013-06-24 20:22:26 +00:00
|
|
|
free(shdname);
|
|
|
|
|
|
|
|
char *slsname = genFileName(0, _sceneId, "sls");
|
|
|
|
|
|
|
|
if (g_fullpipe->_soundEnabled) {
|
|
|
|
_soundList = new SoundList();
|
|
|
|
|
|
|
|
if (g_fullpipe->_flgSoundList) {
|
|
|
|
char *nlname = genFileName(17, _sceneId, "nl");
|
2013-07-06 19:56:11 +00:00
|
|
|
|
2013-06-24 20:22:26 +00:00
|
|
|
_soundList->loadFile(slsname, nlname);
|
|
|
|
|
|
|
|
free(nlname);
|
|
|
|
} else {
|
|
|
|
_soundList->loadFile(slsname, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(slsname);
|
|
|
|
|
|
|
|
initStaticANIObjects();
|
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
if (file.size() - file.pos() > 0)
|
|
|
|
error("Scene::load (%d bytes left)", file.size() - file.pos());
|
2013-06-22 02:04:17 +00:00
|
|
|
|
2013-06-20 20:39:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-24 20:22:26 +00:00
|
|
|
void Scene::initStaticANIObjects() {
|
2013-07-29 11:28:47 +00:00
|
|
|
for (uint i = 0; i < _staticANIObjectList1.size(); i++)
|
|
|
|
((StaticANIObject *)_staticANIObjectList1[i])->initMovements();
|
2013-06-24 20:22:26 +00:00
|
|
|
}
|
|
|
|
|
2013-07-13 08:51:36 +00:00
|
|
|
void Scene::init() {
|
2013-07-24 21:34:15 +00:00
|
|
|
_x = 0;
|
|
|
|
_y = 0;
|
|
|
|
|
|
|
|
g_fullpipe->_sceneRect.moveTo(0, 0);
|
|
|
|
|
|
|
|
for (uint i = 0; i < _picObjList.size(); i++)
|
|
|
|
((PictureObject *)_picObjList[i])->clearFlags();
|
|
|
|
|
|
|
|
for (uint i = 0; i < _staticANIObjectList1.size(); i++)
|
2013-07-29 11:28:47 +00:00
|
|
|
((StaticANIObject *)_staticANIObjectList1[i])->clearFlags();
|
2013-07-24 21:34:15 +00:00
|
|
|
|
|
|
|
if (_staticANIObjectList2.size() != _staticANIObjectList1.size()) {
|
|
|
|
_staticANIObjectList2.clear();
|
|
|
|
|
2013-09-18 15:20:53 +00:00
|
|
|
for (PtrList::iterator s = _staticANIObjectList1.begin(); s != _staticANIObjectList1.end(); ++s)
|
2013-07-24 21:34:15 +00:00
|
|
|
_staticANIObjectList2.push_back(*s);
|
|
|
|
}
|
2013-07-13 08:51:36 +00:00
|
|
|
}
|
|
|
|
|
2013-07-20 13:08:05 +00:00
|
|
|
StaticANIObject *Scene::getAniMan() {
|
|
|
|
StaticANIObject *aniMan = getStaticANIObject1ById(ANI_MAN, -1);
|
|
|
|
|
|
|
|
deleteStaticANIObject(aniMan);
|
|
|
|
|
|
|
|
return aniMan;
|
|
|
|
}
|
|
|
|
|
|
|
|
StaticANIObject *Scene::getStaticANIObject1ById(int obj, int a3) {
|
2013-09-18 15:20:53 +00:00
|
|
|
for (PtrList::iterator s = _staticANIObjectList1.begin(); s != _staticANIObjectList1.end(); ++s) {
|
2013-07-25 12:43:10 +00:00
|
|
|
StaticANIObject *o = (StaticANIObject *)*s;
|
2013-08-12 09:32:49 +00:00
|
|
|
if (o->_id == obj && (a3 == -1 || o->_okeyCode == a3))
|
2013-07-20 13:08:05 +00:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-22 22:42:22 +00:00
|
|
|
StaticANIObject *Scene::getStaticANIObject1ByName(char *name, int a3) {
|
2013-08-14 09:52:59 +00:00
|
|
|
for (uint n = 0; n < _staticANIObjectList1.size(); n++) {
|
|
|
|
StaticANIObject *o = (StaticANIObject *)_staticANIObjectList1[n];
|
2013-08-12 09:32:49 +00:00
|
|
|
if (!strcmp(o->_objectName, name) && (a3 == -1 || o->_okeyCode == a3))
|
2013-07-22 22:42:22 +00:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-20 13:08:05 +00:00
|
|
|
void Scene::deleteStaticANIObject(StaticANIObject *obj) {
|
|
|
|
for (uint n = 0; n < _staticANIObjectList1.size(); n++)
|
|
|
|
if ((StaticANIObject *)_staticANIObjectList1[n] == obj) {
|
|
|
|
_staticANIObjectList1.remove_at(n);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint n = 0; n < _staticANIObjectList2.size(); n++)
|
|
|
|
if ((StaticANIObject *)_staticANIObjectList2[n] == obj) {
|
|
|
|
_staticANIObjectList2.remove_at(n);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 20:55:04 +00:00
|
|
|
void Scene::addStaticANIObject(StaticANIObject *obj, bool addList2) {
|
2013-08-12 09:32:49 +00:00
|
|
|
if (obj->_okeyCode)
|
2013-07-20 20:55:04 +00:00
|
|
|
obj->renumPictures(&_staticANIObjectList1);
|
|
|
|
|
|
|
|
_staticANIObjectList1.push_back(obj);
|
|
|
|
|
|
|
|
if (addList2) {
|
2013-08-12 09:32:49 +00:00
|
|
|
if (!obj->_okeyCode)
|
2013-07-20 20:55:04 +00:00
|
|
|
obj->clearFlags();
|
|
|
|
|
|
|
|
_staticANIObjectList2.push_back(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-22 19:46:08 +00:00
|
|
|
void Scene::setPictureObjectsFlag4() {
|
|
|
|
for (uint i = 0; i < _picObjList.size(); i++) {
|
|
|
|
((PictureObject *)_picObjList[i])->_flags |= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PictureObject *Scene::getPictureObjectById(int objId, int flags) {
|
2013-10-29 22:54:58 +00:00
|
|
|
for (uint i = 0; i < _picObjList.size(); i++) {
|
2013-08-12 09:32:49 +00:00
|
|
|
if (((PictureObject *)_picObjList[i])->_id == objId && ((PictureObject *)_picObjList[i])->_okeyCode == flags)
|
2013-07-22 19:46:08 +00:00
|
|
|
return (PictureObject *)_picObjList[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-24 18:07:16 +00:00
|
|
|
PictureObject *Scene::getPictureObjectByName(const char *objName, int flags) {
|
|
|
|
for (uint i = 0; i < _picObjList.size(); i++) {
|
2013-08-31 06:47:51 +00:00
|
|
|
if (!strcmp(((PictureObject *)_picObjList[i])->_objectName, objName) && (((PictureObject *)_picObjList[i])->_okeyCode == flags || flags == -1))
|
2013-08-24 18:07:16 +00:00
|
|
|
return (PictureObject *)_picObjList[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-24 13:27:09 +00:00
|
|
|
void Scene::deletePictureObject(PictureObject *obj) {
|
|
|
|
for (uint i = 0; i < _picObjList.size(); i++) {
|
|
|
|
if (((PictureObject *)_picObjList[i]) == obj) {
|
|
|
|
_picObjList.remove_at(i);
|
|
|
|
delete obj;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-29 19:16:14 +00:00
|
|
|
MessageQueue *Scene::getMessageQueueById(int messageId) {
|
|
|
|
for (uint i = 0; i < _messageQueueList.size(); i++)
|
|
|
|
if (((MessageQueue *)_messageQueueList[i])->_dataId == messageId)
|
|
|
|
return (MessageQueue *)_messageQueueList[i];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-14 09:52:59 +00:00
|
|
|
MessageQueue *Scene::getMessageQueueByName(char *name) {
|
|
|
|
for (uint i = 0; i < _messageQueueList.size(); i++)
|
|
|
|
if (!strcmp(((MessageQueue *)_messageQueueList[i])->_queueName, name))
|
|
|
|
return (MessageQueue *)_messageQueueList[i];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:37:07 +00:00
|
|
|
void Scene::preloadMovements(GameVar *var) {
|
|
|
|
GameVar *preload = var->getSubVarByName("PRELOAD");
|
2013-07-22 22:42:22 +00:00
|
|
|
if (!preload)
|
|
|
|
return;
|
|
|
|
|
2013-09-18 15:37:07 +00:00
|
|
|
for (GameVar *i = preload->_subVars; i; i = i->_nextVarObj) {
|
2013-07-22 22:42:22 +00:00
|
|
|
StaticANIObject *ani = getStaticANIObject1ByName(i->_varName, -1);
|
|
|
|
|
|
|
|
if (ani) {
|
2013-09-18 15:37:07 +00:00
|
|
|
GameVar *subVars = i->_subVars;
|
2013-07-22 22:42:22 +00:00
|
|
|
|
|
|
|
if (subVars) {
|
|
|
|
for (;subVars; subVars = subVars->_nextVarObj) {
|
|
|
|
Movement *mov = ani->getMovementByName(subVars->_varName);
|
|
|
|
|
|
|
|
if (mov)
|
|
|
|
mov->loadPixelData();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ani->loadMovementsPixelData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-24 18:07:16 +00:00
|
|
|
void Scene::initObjectCursors(const char *varname) {
|
2013-09-18 15:37:07 +00:00
|
|
|
GameVar *cursorsVar = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("CURSORS");
|
2013-08-24 18:07:16 +00:00
|
|
|
|
|
|
|
if (!cursorsVar || !cursorsVar->_subVars)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int maxId = 0;
|
|
|
|
int minId = 0xffff;
|
|
|
|
|
2013-09-18 15:37:07 +00:00
|
|
|
for (GameVar *sub = cursorsVar->_subVars; sub; sub = sub->_nextVarObj) {
|
2013-08-24 18:07:16 +00:00
|
|
|
GameObject *obj = getPictureObjectByName(sub->_varName, -1);
|
|
|
|
|
|
|
|
if (obj || (obj = getStaticANIObject1ByName(sub->_varName, -1)) != 0) {
|
|
|
|
if (obj->_id < minId)
|
|
|
|
minId = obj->_id;
|
|
|
|
if (obj->_id > maxId)
|
|
|
|
maxId = obj->_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_fullpipe->_minCursorId = minId;
|
2013-08-24 19:12:00 +00:00
|
|
|
g_fullpipe->_maxCursorId = maxId;
|
2013-08-24 18:07:16 +00:00
|
|
|
|
|
|
|
g_fullpipe->_objectIdCursors.resize(maxId - minId + 1);
|
|
|
|
|
2013-09-18 15:37:07 +00:00
|
|
|
for (GameVar *sub = cursorsVar->_subVars; sub; sub = sub->_nextVarObj) {
|
2013-08-24 18:07:16 +00:00
|
|
|
GameObject *obj = getPictureObjectByName(sub->_varName, -1);
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
obj = getStaticANIObject1ByName(sub->_varName, -1);
|
|
|
|
|
|
|
|
PictureObject *pic = getGameLoaderInventory()->getScene()->getPictureObjectByName(sub->_value.stringValue, -1);
|
|
|
|
|
|
|
|
if (obj && pic)
|
|
|
|
g_fullpipe->_objectIdCursors[obj->_id - minId] = pic->_id;
|
|
|
|
}
|
2013-07-22 22:42:22 +00:00
|
|
|
}
|
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
bool Scene::compareObjPriority(const void *p1, const void *p2) {
|
2013-09-06 12:51:36 +00:00
|
|
|
if (((const StaticANIObject *)p1)->_priority > ((const StaticANIObject *)p2)->_priority)
|
2013-07-24 21:34:15 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:20:53 +00:00
|
|
|
void Scene::objectList_sortByPriority(PtrList &list) {
|
2013-07-24 21:34:15 +00:00
|
|
|
Common::sort(list.begin(), list.end(), Scene::compareObjPriority);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::draw() {
|
2013-08-10 22:19:23 +00:00
|
|
|
debug(0, ">>>>> Scene::draw()");
|
2013-07-24 21:34:15 +00:00
|
|
|
updateScrolling();
|
2013-07-12 19:35:51 +00:00
|
|
|
|
|
|
|
drawContent(60000, 0, true);
|
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
objectList_sortByPriority(_staticANIObjectList2);
|
2013-07-12 19:35:51 +00:00
|
|
|
|
2013-09-18 15:20:53 +00:00
|
|
|
for (PtrList::iterator s = _staticANIObjectList2.begin(); s != _staticANIObjectList2.end(); ++s) {
|
2013-07-25 12:43:10 +00:00
|
|
|
((StaticANIObject *)*s)->draw2();
|
2013-07-12 19:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int priority = -1;
|
2013-09-18 15:20:53 +00:00
|
|
|
for (PtrList::iterator s = _staticANIObjectList2.begin(); s != _staticANIObjectList2.end(); ++s) {
|
2013-07-25 13:42:44 +00:00
|
|
|
drawContent(((StaticANIObject *)*s)->_priority, priority, false);
|
2013-07-25 12:43:10 +00:00
|
|
|
((StaticANIObject *)*s)->draw();
|
2013-07-12 19:35:51 +00:00
|
|
|
|
2013-07-25 12:43:10 +00:00
|
|
|
priority = ((StaticANIObject *)*s)->_priority;
|
2013-07-12 19:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drawContent(-1, priority, false);
|
|
|
|
}
|
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
void Scene::updateScrolling() {
|
2013-08-28 21:40:14 +00:00
|
|
|
debug(0, "STUB Scene::updateScrolling()");
|
2013-07-12 19:35:51 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 19:47:46 +00:00
|
|
|
void Scene::updateScrolling2() {
|
|
|
|
warning("STUB Scene::updateScrolling2()");
|
|
|
|
}
|
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
StaticANIObject *Scene::getStaticANIObjectAtPos(int x, int y) {
|
2013-08-28 07:50:03 +00:00
|
|
|
StaticANIObject *res = 0;
|
2013-08-24 19:12:00 +00:00
|
|
|
|
2013-08-28 07:50:03 +00:00
|
|
|
for (uint i = 0; i < _staticANIObjectList1.size(); i++) {
|
|
|
|
StaticANIObject *p = (StaticANIObject *)_staticANIObjectList1[i];
|
|
|
|
int pixel;
|
|
|
|
|
2013-09-04 19:13:55 +00:00
|
|
|
if ((p->_field_8 & 0x100) && (p->_flags & 4) &&
|
2013-08-28 07:50:03 +00:00
|
|
|
p->getPixelAtPos(x, y, &pixel) &&
|
|
|
|
(!res || res->_priority >= p->_priority))
|
|
|
|
res = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2013-08-24 19:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PictureObject *Scene::getPictureObjectAtPos(int x, int y) {
|
2013-08-27 21:11:17 +00:00
|
|
|
PictureObject *res = 0;
|
2013-08-24 19:12:00 +00:00
|
|
|
|
2013-08-27 21:11:17 +00:00
|
|
|
for (uint i = 0; i < _picObjList.size(); i++) {
|
|
|
|
PictureObject *p = (PictureObject *)_picObjList[i];
|
2013-09-04 19:13:55 +00:00
|
|
|
if ((p->_field_8 & 0x100) && (p->_flags & 4) &&
|
2013-08-27 21:11:17 +00:00
|
|
|
p->isPixelHitAtPos(x, y) &&
|
|
|
|
(!res || res->_priority >= p->_priority))
|
|
|
|
res = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2013-08-24 19:12:00 +00:00
|
|
|
}
|
|
|
|
|
2013-08-26 19:17:20 +00:00
|
|
|
int Scene::getPictureObjectIdAtPos(int x, int y) {
|
2013-08-27 21:11:17 +00:00
|
|
|
PictureObject *resp = 0;
|
|
|
|
int res = 0;
|
2013-08-26 19:17:20 +00:00
|
|
|
|
2013-08-27 21:11:17 +00:00
|
|
|
for (uint i = 0; i < _picObjList.size(); i++) {
|
|
|
|
PictureObject *p = (PictureObject *)_picObjList[i];
|
2013-09-04 19:13:55 +00:00
|
|
|
if ((p->_field_8 & 0x100) && (p->_flags & 4) &&
|
2013-08-27 21:11:17 +00:00
|
|
|
p->isPixelHitAtPos(x, y) &&
|
|
|
|
(!res || resp->_priority >= p->_priority)) {
|
|
|
|
resp = p;
|
|
|
|
res = p->_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2013-08-26 19:17:20 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 17:06:13 +00:00
|
|
|
void Scene::update(int counterdiff) {
|
2013-08-09 23:32:00 +00:00
|
|
|
debug(0, "Scene::update(%d)", counterdiff);
|
|
|
|
|
2013-09-18 15:20:53 +00:00
|
|
|
for (PtrList::iterator s = _staticANIObjectList2.begin(); s != _staticANIObjectList2.end(); ++s)
|
2013-07-31 17:06:13 +00:00
|
|
|
((StaticANIObject *)*s)->update(counterdiff);
|
|
|
|
}
|
|
|
|
|
2013-07-20 13:08:05 +00:00
|
|
|
void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
|
2013-07-19 14:59:03 +00:00
|
|
|
if (!_picObjList.size() && !_bigPictureArray1Count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_palette) {
|
2013-08-07 17:52:23 +00:00
|
|
|
g_fullpipe->_globalPalette = _palette->_data;
|
2013-07-19 14:59:03 +00:00
|
|
|
}
|
2013-07-19 22:00:26 +00:00
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg);
|
2013-07-25 13:42:44 +00:00
|
|
|
|
2013-07-19 22:00:26 +00:00
|
|
|
if (_picObjList.size() > 2) { // We need to z-sort them
|
2013-07-24 21:34:15 +00:00
|
|
|
objectList_sortByPriority(_picObjList);
|
2013-07-19 22:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (minPri == -1 && _picObjList.size())
|
|
|
|
minPri = ((PictureObject *)_picObjList.back())->_priority - 1;
|
|
|
|
|
|
|
|
if (maxPri == -1)
|
|
|
|
maxPri = 60000;
|
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "-> Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg);
|
2013-07-25 13:42:44 +00:00
|
|
|
|
|
|
|
Common::Point point;
|
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "_bigPict: %d objlist: %d", _bigPictureArray1Count, _picObjList.size());
|
2013-07-19 22:00:26 +00:00
|
|
|
if (drawBg && _bigPictureArray1Count && _picObjList.size()) {
|
2013-07-24 21:34:15 +00:00
|
|
|
|
|
|
|
_bigPictureArray[0][0]->getDimensions(&point);
|
|
|
|
|
|
|
|
int width = point.x;
|
|
|
|
int height = point.y;
|
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "w: %d h:%d", width, height);
|
2013-07-25 12:43:10 +00:00
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
((PictureObject *)_picObjList[0])->getDimensions(&point);
|
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "w2: %d h2:%d", point.x, point.y);
|
2013-07-25 12:43:10 +00:00
|
|
|
|
2013-07-24 21:34:15 +00:00
|
|
|
int bgStX = g_fullpipe->_sceneRect.left % point.x;
|
|
|
|
|
|
|
|
if (bgStX < 0)
|
|
|
|
bgStX += point.x;
|
|
|
|
|
|
|
|
int bgNumX = bgStX / width;
|
|
|
|
int bgOffsetX = bgStX % width;
|
|
|
|
|
|
|
|
int bgStY = g_fullpipe->_sceneRect.top % point.y;
|
|
|
|
|
|
|
|
if (bgStY < 0)
|
|
|
|
bgStY += point.y;
|
|
|
|
|
|
|
|
int bgNumY = bgStY / height;
|
|
|
|
int bgOffsetY = bgStY % height;
|
|
|
|
|
|
|
|
int bgPosX = g_fullpipe->_sceneRect.left - bgOffsetX;
|
|
|
|
|
|
|
|
if (bgPosX < g_fullpipe->_sceneRect.right - 1) {
|
|
|
|
while (1) {
|
|
|
|
int v25 = bgNumY;
|
2013-07-25 13:42:44 +00:00
|
|
|
for (int y = g_fullpipe->_sceneRect.top - bgOffsetY; y < g_fullpipe->_sceneRect.bottom - 1;) {
|
2013-07-24 21:34:15 +00:00
|
|
|
BigPicture *v27 = _bigPictureArray[bgNumX][v25];
|
|
|
|
v27->draw(bgPosX, y, 0, 0);
|
|
|
|
y += v27->getDimensions(&point)->y;
|
|
|
|
v25++;
|
|
|
|
|
|
|
|
if (v25 >= _bigPictureArray2Count) {
|
2013-09-11 18:35:07 +00:00
|
|
|
if (!(((PictureObject *)_picObjList[0])->_flags & 0x20))
|
2013-07-24 21:34:15 +00:00
|
|
|
break;
|
|
|
|
v25 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_bigPictureArray[bgNumX][0]->getDimensions(&point);
|
|
|
|
int v32 = point.x + bgPosX;
|
|
|
|
bgPosX += point.x;
|
|
|
|
bgNumX++;
|
|
|
|
|
|
|
|
if (bgNumX >= _bigPictureArray1Count) {
|
2013-08-19 21:34:15 +00:00
|
|
|
if (!(((PictureObject *)_picObjList[0])->_flags & 0x2))
|
2013-07-24 21:34:15 +00:00
|
|
|
break;
|
|
|
|
bgNumX = 0;
|
|
|
|
}
|
|
|
|
if (v32 >= g_fullpipe->_sceneRect.right - 1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-25 13:42:44 +00:00
|
|
|
|
|
|
|
for (uint i = 1; i < _picObjList.size(); i++) {
|
|
|
|
PictureObject *obj = (PictureObject *)_picObjList[i];
|
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "pri: %d", obj->_priority);
|
2013-07-25 13:42:44 +00:00
|
|
|
if (obj->_priority < minPri || obj->_priority >= maxPri)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int objX = obj->_ox;
|
|
|
|
int objY = obj->_oy;
|
|
|
|
|
2013-08-07 22:14:24 +00:00
|
|
|
debug(8, "obj: %d %d", objX, objY);
|
2013-07-25 13:42:44 +00:00
|
|
|
|
|
|
|
obj->getDimensions(&point);
|
|
|
|
|
|
|
|
int width = point.x;
|
|
|
|
int height = point.y;
|
|
|
|
|
|
|
|
if (obj->_flags & 8) {
|
|
|
|
while (objX > g_fullpipe->_sceneRect.right) {
|
|
|
|
objX -= width;
|
|
|
|
obj->setOXY(objX, objY);
|
|
|
|
}
|
|
|
|
for (int j = width + objX; width + objX < g_fullpipe->_sceneRect.left; j = width + objX) {
|
|
|
|
objX = j;
|
|
|
|
obj->setOXY(j, objY);
|
2013-07-24 21:34:15 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-25 13:42:44 +00:00
|
|
|
|
|
|
|
if (obj->_flags & 0x10) {
|
|
|
|
while (objY > g_fullpipe->_sceneRect.bottom) {
|
|
|
|
objY -= height;
|
|
|
|
obj->setOXY(objX, objY);
|
|
|
|
}
|
|
|
|
for (int j = objY + height; objY + height < g_fullpipe->_sceneRect.top; j = objY + height) {
|
|
|
|
objY = j;
|
|
|
|
obj->setOXY(objX, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (obj->_flags & 4)
|
|
|
|
obj->draw();
|
|
|
|
|
|
|
|
if (obj->_flags & 2) {
|
|
|
|
if (objX > g_fullpipe->_sceneRect.left) {
|
|
|
|
obj->setOXY(objX - width, objY);
|
|
|
|
obj->draw();
|
|
|
|
obj->setOXY(objX, objY);
|
|
|
|
}
|
|
|
|
if (width + objX < g_fullpipe->_sceneRect.right) {
|
|
|
|
obj->setOXY(width + objX, objY);
|
|
|
|
obj->draw();
|
|
|
|
obj->setOXY(objX, objY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj->_flags & 0x20) {
|
|
|
|
if (objY > g_fullpipe->_sceneRect.top) {
|
|
|
|
obj->setOXY(objX, objY - height);
|
|
|
|
obj->draw();
|
|
|
|
obj->setOXY(objX, objY);
|
|
|
|
}
|
|
|
|
if (height + objY < g_fullpipe->_sceneRect.bottom) {
|
|
|
|
obj->setOXY(objX, height + objY);
|
|
|
|
obj->draw();
|
|
|
|
obj->setOXY(objX, objY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-12 19:35:51 +00:00
|
|
|
}
|
|
|
|
|
2013-06-20 19:34:29 +00:00
|
|
|
} // End of namespace Fullpipe
|