aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe
diff options
context:
space:
mode:
Diffstat (limited to 'engines/fullpipe')
-rw-r--r--engines/fullpipe/behavior.cpp124
-rw-r--r--engines/fullpipe/behavior.h24
-rw-r--r--engines/fullpipe/fullpipe.cpp10
-rw-r--r--engines/fullpipe/fullpipe.h9
-rw-r--r--engines/fullpipe/gameloader.cpp28
-rw-r--r--engines/fullpipe/gfx.cpp38
-rw-r--r--engines/fullpipe/interaction.cpp7
-rw-r--r--engines/fullpipe/inventory.cpp2
-rw-r--r--engines/fullpipe/messagehandlers.cpp13
-rw-r--r--engines/fullpipe/messages.cpp6
-rw-r--r--engines/fullpipe/mgm.cpp132
-rw-r--r--engines/fullpipe/motion.cpp320
-rw-r--r--engines/fullpipe/motion.h16
-rw-r--r--engines/fullpipe/ngiarchive.cpp4
-rw-r--r--engines/fullpipe/scene.cpp30
-rw-r--r--engines/fullpipe/scenes.h8
-rw-r--r--engines/fullpipe/scenes/scene06.cpp4
-rw-r--r--engines/fullpipe/scenes/scene07.cpp4
-rw-r--r--engines/fullpipe/scenes/scene13.cpp16
-rw-r--r--engines/fullpipe/scenes/scene14.cpp8
-rw-r--r--engines/fullpipe/sound.cpp6
-rw-r--r--engines/fullpipe/stateloader.cpp24
-rw-r--r--engines/fullpipe/statics.cpp47
-rw-r--r--engines/fullpipe/utils.cpp48
24 files changed, 536 insertions, 392 deletions
diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp
index 14e9c33bdf..75b1c78143 100644
--- a/engines/fullpipe/behavior.cpp
+++ b/engines/fullpipe/behavior.cpp
@@ -40,8 +40,8 @@ BehaviorManager::~BehaviorManager() {
void BehaviorManager::clear() {
for (uint i = 0; i < _behaviors.size(); i++) {
- for (int j = 0; j < _behaviors[i]->_itemsCount; j++)
- delete _behaviors[i]->_bheItems[j];
+ for (int j = 0; j < _behaviors[i]->_animsCount; j++)
+ delete _behaviors[i]->_behaviorAnims[j];
delete _behaviors[i];
}
@@ -83,14 +83,14 @@ void BehaviorManager::updateBehaviors() {
if (!_isActive)
return;
- debug(4, "BehaviorManager::updateBehaviors()");
+ debugC(4, kDebugAnimation, "BehaviorManager::updateBehaviors()");
for (uint i = 0; i < _behaviors.size(); i++) {
BehaviorInfo *beh = _behaviors[i];
if (!beh->_ani) {
beh->_counter++;
if (beh->_counter >= beh->_counterMax)
- updateBehavior(beh, beh->_bheItems[0]);
+ updateBehavior(beh, beh->_behaviorAnims[0]);
continue;
}
@@ -104,15 +104,15 @@ void BehaviorManager::updateBehaviors() {
beh->_counter++;
if (beh->_counter >= beh->_counterMax) {
if (beh->_subIndex >= 0 && !(beh->_flags & 1) && beh->_ani->_messageQueueId <= 0)
- updateStaticAniBehavior(beh->_ani, beh->_counter, beh->_bheItems[beh->_subIndex]);
+ updateStaticAniBehavior(beh->_ani, beh->_counter, beh->_behaviorAnims[beh->_subIndex]);
}
} else {
beh->_staticsId = beh->_ani->_statics->_staticsId;
beh->_counter = 0;
beh->_subIndex = -1;
- for (int j = 0; j < beh->_itemsCount; j++)
- if (beh->_bheItems[j]->_staticsId == beh->_staticsId) {
+ for (int j = 0; j < beh->_animsCount; j++)
+ if (beh->_behaviorAnims[j]->_staticsId == beh->_staticsId) {
beh->_subIndex = j;
break;
}
@@ -121,10 +121,10 @@ void BehaviorManager::updateBehaviors() {
}
}
-void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry *entry) {
- debug(4, "BehaviorManager::updateBehavior() %d", entry->_itemsCount);
- for (int i = 0; i < entry->_itemsCount; i++) {
- BehaviorEntryInfo *bhi = entry->_items[i];
+void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorAnim *entry) {
+ debugC(4, kDebugAnimation, "BehaviorManager::updateBehavior() %d", entry->_movesCount);
+ for (int i = 0; i < entry->_movesCount; i++) {
+ BehaviorMove *bhi = entry->_behaviorMoves[i];
if (!(bhi->_flags & 1)) {
if (bhi->_flags & 2) {
MessageQueue *mq = new MessageQueue(bhi->_messageQueue, 0, 1);
@@ -132,7 +132,7 @@ void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry *
mq->sendNextCommand();
bhi->_flags &= 0xFFFFFFFD;
- } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fp->_rnd->getRandomNumber(32767) <= entry->_items[i]->_percent) {
+ } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fp->_rnd->getRandomNumber(32767) <= entry->_behaviorMoves[i]->_percent) {
MessageQueue *mq = new MessageQueue(bhi->_messageQueue, 0, 1);
mq->sendNextCommand();
@@ -143,29 +143,29 @@ void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry *
}
}
-void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, BehaviorEntry *bhe) {
- debug(4, "BehaviorManager::updateStaticAniBehavior(%s)", transCyrillic((byte *)ani->_objectName));
+void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, BehaviorAnim *bhe) {
+ debugC(4, kDebugAnimation, "BehaviorManager::updateStaticAniBehavior(%s)", transCyrillic((byte *)ani->_objectName));
MessageQueue *mq = 0;
if (bhe->_flags & 1) {
uint rnd = g_fp->_rnd->getRandomNumber(32767);
uint runPercent = 0;
- for (int i = 0; i < bhe->_itemsCount; i++) {
- if (!(bhe->_items[i]->_flags & 1) && bhe->_items[i]->_percent) {
- if ((rnd >= runPercent && rnd <= runPercent + bhe->_items[i]->_percent) || i == bhe->_itemsCount - 1) {
- mq = new MessageQueue(bhe->_items[i]->_messageQueue, 0, 1);
+ for (int i = 0; i < bhe->_movesCount; i++) {
+ if (!(bhe->_behaviorMoves[i]->_flags & 1) && bhe->_behaviorMoves[i]->_percent) {
+ if ((rnd >= runPercent && rnd <= runPercent + bhe->_behaviorMoves[i]->_percent) || i == bhe->_movesCount - 1) {
+ mq = new MessageQueue(bhe->_behaviorMoves[i]->_messageQueue, 0, 1);
break;
}
- runPercent += bhe->_items[i]->_percent;
+ runPercent += bhe->_behaviorMoves[i]->_percent;
}
}
} else {
- for (int i = 0; i < bhe->_itemsCount; i++) {
- if (!(bhe->_items[i]->_flags & 1) && delay >= bhe->_items[i]->_delay) {
- if (bhe->_items[i]->_percent) {
- if (g_fp->_rnd->getRandomNumber(32767) <= bhe->_items[i]->_percent) {
- mq = new MessageQueue(bhe->_items[i]->_messageQueue, 0, 1);
+ for (int i = 0; i < bhe->_movesCount; i++) {
+ if (!(bhe->_behaviorMoves[i]->_flags & 1) && delay >= bhe->_behaviorMoves[i]->_delay) {
+ if (bhe->_behaviorMoves[i]->_percent) {
+ if (g_fp->_rnd->getRandomNumber(32767) <= bhe->_behaviorMoves[i]->_percent) {
+ mq = new MessageQueue(bhe->_behaviorMoves[i]->_messageQueue, 0, 1);
break;
}
}
@@ -180,7 +180,7 @@ void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, B
}
bool BehaviorManager::setBehaviorEnabled(StaticANIObject *obj, int aniId, int quId, int flag) {
- BehaviorEntryInfo *entry = getBehaviorEntryInfoByMessageQueueDataId(obj, aniId, quId);
+ BehaviorMove *entry = getBehaviorMoveByMessageQueueDataId(obj, aniId, quId);
if (entry) {
if (flag)
@@ -206,14 +206,14 @@ void BehaviorManager::setFlagByStaticAniObject(StaticANIObject *ani, int flag) {
}
}
-BehaviorEntryInfo *BehaviorManager::getBehaviorEntryInfoByMessageQueueDataId(StaticANIObject *ani, int id1, int id2) {
+BehaviorMove *BehaviorManager::getBehaviorMoveByMessageQueueDataId(StaticANIObject *ani, int id1, int id2) {
for (uint i = 0; i < _behaviors.size(); i++) {
if (_behaviors[i]->_ani == ani) {
- for (uint j = 0; j < _behaviors[i]->_bheItems.size(); j++) {
- if (_behaviors[i]->_bheItems[j]->_staticsId == id1) {
- for (int k = 0; k < _behaviors[i]->_bheItems[j]->_itemsCount; k++) {
- if (_behaviors[i]->_bheItems[j]->_items[k]->_messageQueue->_dataId == id2)
- return _behaviors[i]->_bheItems[j]->_items[k];
+ for (uint j = 0; j < _behaviors[i]->_behaviorAnims.size(); j++) {
+ if (_behaviors[i]->_behaviorAnims[j]->_staticsId == id1) {
+ for (int k = 0; k < _behaviors[i]->_behaviorAnims[j]->_movesCount; k++) {
+ if (_behaviors[i]->_behaviorAnims[j]->_behaviorMoves[k]->_messageQueue->_dataId == id2)
+ return _behaviors[i]->_behaviorAnims[j]->_behaviorMoves[k];
}
}
}
@@ -230,41 +230,41 @@ void BehaviorInfo::clear() {
_counterMax = 0;
_flags = 0;
_subIndex = 0;
- _itemsCount = 0;
+ _animsCount = 0;
- _bheItems.clear();
+ _behaviorAnims.clear();
}
void BehaviorInfo::initAmbientBehavior(GameVar *var, Scene *sc) {
- debug(4, "BehaviorInfo::initAmbientBehavior(%s)", transCyrillic((byte *)var->_varName));
+ debugC(4, kDebugAnimation, "BehaviorInfo::initAmbientBehavior(%s)", transCyrillic((byte *)var->_varName));
clear();
- _itemsCount = 1;
+ _animsCount = 1;
_counterMax = -1;
- BehaviorEntry *bi = new BehaviorEntry();
+ BehaviorAnim *bi = new BehaviorAnim();
- _bheItems.push_back(bi);
+ _behaviorAnims.push_back(bi);
- bi->_itemsCount = var->getSubVarsCount();
+ bi->_movesCount = var->getSubVarsCount();
- bi->_items = (BehaviorEntryInfo**)calloc(bi->_itemsCount, sizeof(BehaviorEntryInfo *));
+ bi->_behaviorMoves = (BehaviorMove **)calloc(bi->_movesCount, sizeof(BehaviorMove *));
- for (int i = 0; i < bi->_itemsCount; i++) {
+ for (int i = 0; i < bi->_movesCount; i++) {
int delay;
- bi->_items[i] = new BehaviorEntryInfo(var->getSubVarByIndex(i), sc, &delay);
+ bi->_behaviorMoves[i] = new BehaviorMove(var->getSubVarByIndex(i), sc, &delay);
- if (bi->_items[i]->_delay <_counterMax)
- _counterMax = bi->_items[i]->_delay;
+ if (bi->_behaviorMoves[i]->_delay <_counterMax)
+ _counterMax = bi->_behaviorMoves[i]->_delay;
}
}
void BehaviorInfo::initObjectBehavior(GameVar *var, Scene *sc, StaticANIObject *ani) {
- debug(4, "BehaviorInfo::initObjectBehavior(%s)", transCyrillic((byte *)var->_varName));
+ debugC(4, kDebugAnimation, "BehaviorInfo::initObjectBehavior(%s)", transCyrillic((byte *)var->_varName));
clear();
- _itemsCount = var->getSubVarsCount();
+ _animsCount = var->getSubVarsCount();
_counterMax = -1;
while (var->_varType == 2) {
@@ -278,54 +278,54 @@ void BehaviorInfo::initObjectBehavior(GameVar *var, Scene *sc, StaticANIObject *
sc = g_fp->accessScene(ani->_sceneId);
clear();
var = v1;
- _itemsCount = var->getSubVarsCount();
+ _animsCount = var->getSubVarsCount();
_counterMax = -1;
}
- for (int i = 0; i < _itemsCount; i++) {
+ for (int i = 0; i < _animsCount; i++) {
int maxDelay = 0;
- _bheItems.push_back(new BehaviorEntry(var->getSubVarByIndex(i), sc, ani, &maxDelay));
+ _behaviorAnims.push_back(new BehaviorAnim(var->getSubVarByIndex(i), sc, ani, &maxDelay));
if (maxDelay < _counterMax)
_counterMax = maxDelay;
}
}
-BehaviorEntry::BehaviorEntry() {
+BehaviorAnim::BehaviorAnim() {
_staticsId = 0;
- _itemsCount = 0;
+ _movesCount = 0;
_flags = 0;
- _items = 0;
+ _behaviorMoves = NULL;
}
-BehaviorEntry::BehaviorEntry(GameVar *var, Scene *sc, StaticANIObject *ani, int *minDelay) {
+BehaviorAnim::BehaviorAnim(GameVar *var, Scene *sc, StaticANIObject *ani, int *minDelay) {
_staticsId = 0;
- _itemsCount = 0;
+ _movesCount = 0;
*minDelay = 100000000;
int totalPercent = 0;
_flags = 0;
- _items = 0;
+ _behaviorMoves = 0;
Statics *st = ani->getStaticsByName(var->_varName);
if (st)
_staticsId = st->_staticsId;
- _itemsCount = var->getSubVarsCount();
- if (_itemsCount) {
- _items = (BehaviorEntryInfo**)calloc(_itemsCount, sizeof(BehaviorEntryInfo *));
+ _movesCount = var->getSubVarsCount();
+ if (_movesCount) {
+ _behaviorMoves = (BehaviorMove **)calloc(_movesCount, sizeof(BehaviorMove *));
- for (int i = 0; i < _itemsCount; i++) {
+ for (int i = 0; i < _movesCount; i++) {
GameVar *subvar = var->getSubVarByIndex(i);
int delay = 0;
- _items[i] = new BehaviorEntryInfo(subvar, sc, &delay);
+ _behaviorMoves[i] = new BehaviorMove(subvar, sc, &delay);
totalPercent += delay;
- if (_items[i]->_delay < *minDelay)
- *minDelay = _items[i]->_delay;
+ if (_behaviorMoves[i]->_delay < *minDelay)
+ *minDelay = _behaviorMoves[i]->_delay;
}
if (!*minDelay && totalPercent == 1000)
@@ -333,7 +333,7 @@ BehaviorEntry::BehaviorEntry(GameVar *var, Scene *sc, StaticANIObject *ani, int
}
}
-BehaviorEntryInfo::BehaviorEntryInfo(GameVar *subvar, Scene *sc, int *delay) {
+BehaviorMove::BehaviorMove(GameVar *subvar, Scene *sc, int *delay) {
_messageQueue = 0;
_delay = 0;
_percent = 0;
diff --git a/engines/fullpipe/behavior.h b/engines/fullpipe/behavior.h
index 1ec98d5bf2..e534371442 100644
--- a/engines/fullpipe/behavior.h
+++ b/engines/fullpipe/behavior.h
@@ -25,23 +25,23 @@
namespace Fullpipe {
-struct BehaviorEntryInfo {
+struct BehaviorMove {
MessageQueue *_messageQueue;
int _delay;
uint32 _percent;
int _flags;
- BehaviorEntryInfo(GameVar *subvar, Scene *sc, int *delay);
+ BehaviorMove(GameVar *subvar, Scene *sc, int *delay);
};
-struct BehaviorEntry {
+struct BehaviorAnim {
int _staticsId;
- int _itemsCount;
+ int _movesCount;
int _flags;
- BehaviorEntryInfo **_items;
+ BehaviorMove **_behaviorMoves;
- BehaviorEntry();
- BehaviorEntry(GameVar *var, Scene *sc, StaticANIObject *ani, int *minDelay);
+ BehaviorAnim();
+ BehaviorAnim(GameVar *var, Scene *sc, StaticANIObject *ani, int *minDelay);
};
struct BehaviorInfo {
@@ -51,8 +51,8 @@ struct BehaviorInfo {
int _counterMax;
int _flags;
int _subIndex;
- int _itemsCount;
- Common::Array<BehaviorEntry *> _bheItems;
+ int _animsCount;
+ Common::Array<BehaviorAnim *> _behaviorAnims;
BehaviorInfo() { clear(); }
@@ -75,14 +75,14 @@ class BehaviorManager : public CObject {
void initBehavior(Scene *scene, GameVar *var);
void updateBehaviors();
- void updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry *entry);
- void updateStaticAniBehavior(StaticANIObject *ani, int delay, BehaviorEntry *beh);
+ void updateBehavior(BehaviorInfo *behaviorInfo, BehaviorAnim *entry);
+ void updateStaticAniBehavior(StaticANIObject *ani, int delay, BehaviorAnim *beh);
bool setBehaviorEnabled(StaticANIObject *obj, int aniId, int quId, int flag);
void setFlagByStaticAniObject(StaticANIObject *ani, int flag);
- BehaviorEntryInfo *getBehaviorEntryInfoByMessageQueueDataId(StaticANIObject *ani, int id1, int id2);
+ BehaviorMove *getBehaviorMoveByMessageQueueDataId(StaticANIObject *ani, int id1, int id2);
};
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp
index c2aae9ba88..5f06d8ad79 100644
--- a/engines/fullpipe/fullpipe.cpp
+++ b/engines/fullpipe/fullpipe.cpp
@@ -24,6 +24,7 @@
#include "common/archive.h"
#include "common/config-manager.h"
+#include "common/debug-channels.h"
#include "audio/mixer.h"
#include "engines/util.h"
@@ -47,6 +48,13 @@ FullpipeEngine *g_fp = 0;
Vars *g_vars = 0;
FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+ DebugMan.addDebugChannel(kDebugPathfinding, "path", "Pathfinding");
+ DebugMan.addDebugChannel(kDebugDrawing, "drawing", "Drawing");
+ DebugMan.addDebugChannel(kDebugLoading, "loading", "Scene loading");
+ DebugMan.addDebugChannel(kDebugAnimation, "animation", "Animation");
+ DebugMan.addDebugChannel(kDebugMemory, "memory", "Memory management");
+ DebugMan.addDebugChannel(kDebugEvents, "events", "Event handling");
+
// Setup mixer
if (!_mixer->isReady()) {
warning("Sound initialization failed.");
@@ -452,7 +460,7 @@ void FullpipeEngine::cleanup() {
}
void FullpipeEngine::updateScreen() {
- debug(4, "FullpipeEngine::updateScreen()");
+ debugC(4, kDebugDrawing, "FullpipeEngine::updateScreen()");
_mouseVirtX = _mouseScreenPos.x + _sceneRect.left;
_mouseVirtY = _mouseScreenPos.y + _sceneRect.top;
diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h
index fba61aa13b..1c85536a9a 100644
--- a/engines/fullpipe/fullpipe.h
+++ b/engines/fullpipe/fullpipe.h
@@ -48,6 +48,15 @@ namespace Fullpipe {
enum FullpipeGameFeatures {
};
+enum AccessDebugChannels {
+ kDebugPathfinding = 1 << 0,
+ kDebugDrawing = 1 << 1,
+ kDebugLoading = 1 << 2,
+ kDebugAnimation = 1 << 3,
+ kDebugMemory = 1 << 4,
+ kDebugEvents = 1 << 5
+};
+
class BehaviorManager;
class BaseModalObject;
class GameLoader;
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index 68b63d398a..1cd51036d0 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -110,10 +110,10 @@ GameLoader::~GameLoader() {
}
bool GameLoader::load(MfcArchive &file) {
- debug(5, "GameLoader::load()");
+ debugC(1, kDebugLoading, "GameLoader::load()");
_gameName = file.readPascalString();
- debug(6, "_gameName: %s", _gameName);
+ debugC(1, kDebugLoading, "_gameName: %s", _gameName);
_gameProject = new GameProject();
@@ -126,13 +126,13 @@ bool GameLoader::load(MfcArchive &file) {
}
_gameName = file.readPascalString();
- debug(6, "_gameName: %s", _gameName);
+ debugC(1, kDebugLoading, "_gameName: %s", _gameName);
_inventory.load(file);
_interactionController->load(file);
- debug(6, "sceneTag count: %d", _gameProject->_sceneTagList->size());
+ debugC(1, kDebugLoading, "sceneTag count: %d", _gameProject->_sceneTagList->size());
_sc2array.resize(_gameProject->_sceneTagList->size());
@@ -142,7 +142,7 @@ bool GameLoader::load(MfcArchive &file) {
snprintf(tmp, 11, "%04d.sc2", it->_sceneId);
- debug(2, "sc: %s", tmp);
+ debugC(1, kDebugLoading, "sc: %s", tmp);
_sc2array[i].loadFile((const char *)tmp);
}
@@ -152,6 +152,8 @@ bool GameLoader::load(MfcArchive &file) {
_field_FA = file.readUint16LE();
_field_F8 = file.readUint16LE();
+ debugC(1, kDebugLoading, "_field_FA: %d\n_field_F8: %d", _field_FA, _field_F8);
+
_gameVar = (GameVar *)file.readClass();
return true;
@@ -355,7 +357,7 @@ bool preloadCallback(PreloadItem &pre, int flag) {
}
bool GameLoader::preloadScene(int sceneId, int entranceId) {
- debug(0, "preloadScene(%d, %d), ", sceneId, entranceId);
+ debugC(0, kDebugLoading, "preloadScene(%d, %d), ", sceneId, entranceId);
if (_preloadSceneId != sceneId || _preloadEntranceId != entranceId) {
_preloadSceneId = sceneId;
@@ -453,13 +455,13 @@ void GameLoader::applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAni
if (picAniInfoCount <= 0)
return;
- debug(0, "GameLoader::applyPicAniInfos(sc, ptr, %d)", picAniInfoCount);
+ debugC(0, kDebugAnimation, "GameLoader::applyPicAniInfos(sc, ptr, %d)", picAniInfoCount);
PictureObject *pict;
StaticANIObject *ani;
for (int i = 0; i < picAniInfoCount; i++) {
- debug(7, "PicAniInfo: id: %d type: %d", picAniInfo[i]->objectId, picAniInfo[i]->type);
+ debugC(7, kDebugAnimation, "PicAniInfo: id: %d type: %d", picAniInfo[i]->objectId, picAniInfo[i]->type);
if (picAniInfo[i]->type & 2) {
pict = sc->getPictureObjectById(picAniInfo[i]->objectId, picAniInfo[i]->field_8);
if (pict) {
@@ -549,14 +551,14 @@ Sc2::Sc2() {
}
bool Sc2::load(MfcArchive &file) {
- debug(5, "Sc2::load()");
+ debugC(5, kDebugLoading, "Sc2::load()");
_sceneId = file.readUint16LE();
_motionController = (MotionController *)file.readClass();
_count1 = file.readUint32LE();
- debug(4, "count1: %d", _count1);
+ debugC(4, kDebugLoading, "count1: %d", _count1);
if (_count1 > 0) {
_data1 = (int32 *)malloc(_count1 * sizeof(int32));
@@ -568,7 +570,7 @@ bool Sc2::load(MfcArchive &file) {
}
_defPicAniInfosCount = file.readUint32LE();
- debug(4, "defPicAniInfos: %d", _defPicAniInfosCount);
+ debugC(4, kDebugLoading, "defPicAniInfos: %d", _defPicAniInfosCount);
if (_defPicAniInfosCount > 0) {
_defPicAniInfos = (PicAniInfo **)malloc(_defPicAniInfosCount * sizeof(PicAniInfo *));
@@ -585,7 +587,7 @@ bool Sc2::load(MfcArchive &file) {
_picAniInfosCount = 0;
_entranceDataCount = file.readUint32LE();
- debug(4, "_entranceData: %d", _entranceDataCount);
+ debugC(4, kDebugLoading, "_entranceData: %d", _entranceDataCount);
if (_entranceDataCount > 0) {
_entranceData = (EntranceInfo **)malloc(_entranceDataCount * sizeof(EntranceInfo *));
@@ -605,7 +607,7 @@ bool Sc2::load(MfcArchive &file) {
}
bool PreloadItems::load(MfcArchive &file) {
- debug(5, "PreloadItems::load()");
+ debugC(5, kDebugLoading, "PreloadItems::load()");
int count = file.readCount();
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 42846850ca..dcd5c33740 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -58,7 +58,7 @@ Background::~Background() {
}
bool Background::load(MfcArchive &file) {
- debug(5, "Background::load()");
+ debugC(5, kDebugLoading, "Background::load()");
_bgname = file.readPascalString();
int count = file.readUint16LE();
@@ -80,7 +80,7 @@ bool Background::load(MfcArchive &file) {
_bigPictureArray = (BigPicture ***)calloc(_bigPictureArray1Count, sizeof(BigPicture **));
- debug(6, "bigPictureArray[%d][%d]", _bigPictureArray1Count, _bigPictureArray2Count);
+ debugC(6, kDebugLoading, "bigPictureArray[%d][%d]", _bigPictureArray1Count, _bigPictureArray2Count);
for (int i = 0; i < _bigPictureArray1Count; i++) {
_bigPictureArray[i] = (BigPicture **)calloc(_bigPictureArray2Count, sizeof(BigPicture *));
@@ -137,7 +137,7 @@ PictureObject::PictureObject(PictureObject *src) : GameObject(src) {
}
bool PictureObject::load(MfcArchive &file, bool bigPicture) {
- debug(5, "PictureObject::load()");
+ debugC(5, kDebugLoading, "PictureObject::load()");
GameObject::load(file);
if (bigPicture)
@@ -282,7 +282,7 @@ GameObject::~GameObject() {
}
bool GameObject::load(MfcArchive &file) {
- debug(5, "GameObject::load()");
+ debugC(5, kDebugLoading, "GameObject::load()");
_okeyCode = 0;
_flags = 0;
_field_20 = 0;
@@ -464,7 +464,7 @@ Picture::~Picture() {
}
void Picture::freePicture() {
- debug(5, "Picture::freePicture(): file: %s", _memfilename);
+ debugC(5, kDebugMemory, "Picture::freePicture(): file: %s", _memfilename);
if (_bitmap) {
if (testFlags() && !_field_54) {
@@ -492,7 +492,7 @@ void Picture::freePixelData() {
}
bool Picture::load(MfcArchive &file) {
- debug(5, "Picture::load()");
+ debugC(5, kDebugLoading, "Picture::load()");
MemoryObject::load(file);
_x = file.readUint32LE();
@@ -526,7 +526,7 @@ bool Picture::load(MfcArchive &file) {
getData();
- debug(5, "Picture::load: loaded <%s>", _memfilename);
+ debugC(5, kDebugLoading, "Picture::load: loaded <%s>", _memfilename);
return true;
}
@@ -546,7 +546,7 @@ void Picture::setAOIDs() {
}
void Picture::init() {
- debug(5, "Picture::init(), %s", _memfilename);
+ debugC(5, kDebugLoading, "Picture::init(), %s", _memfilename);
MemoryObject::getData();
@@ -567,7 +567,7 @@ Common::Point *Picture::getDimensions(Common::Point *p) {
void Picture::getDibInfo() {
int off = _dataSize & ~0xf;
- debug(9, "Picture::getDibInfo: _dataSize: %d", _dataSize);
+ debugC(9, kDebugLoading, "Picture::getDibInfo: _dataSize: %d", _dataSize);
if (!_dataSize) {
warning("Picture::getDibInfo(): Empty data size");
@@ -605,7 +605,7 @@ void Picture::draw(int x, int y, int style, int angle) {
int x1 = x;
int y1 = y;
- debug(7, "Picture::draw(%d, %d, %d, %d) (%s)", x, y, style, angle, _memfilename);
+ debugC(7, kDebugDrawing, "Picture::draw(%d, %d, %d, %d) (%s)", x, y, style, angle, _memfilename);
if (x != -1)
x1 = x;
@@ -620,7 +620,7 @@ void Picture::draw(int x, int y, int style, int angle) {
return;
if ((_alpha & 0xff) < 0xff) {
- debug(7, "Picture:draw: alpha = %0x", _alpha);
+ debugC(7, kDebugDrawing, "Picture:draw: alpha = %0x", _alpha);
}
byte *pal = _paletteData;
@@ -784,7 +784,7 @@ Bitmap::~Bitmap() {
}
void Bitmap::load(Common::ReadStream *s) {
- debug(5, "Bitmap::load()");
+ debugC(5, kDebugLoading, "Bitmap::load()");
_x = s->readUint32LE();
_y = s->readUint32LE();
@@ -795,8 +795,8 @@ void Bitmap::load(Common::ReadStream *s) {
_dataSize = s->readUint32LE();
_flags = s->readUint32LE();
- debug(8, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize);
- debug(8, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags);
+ debugC(8, kDebugLoading, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize);
+ debugC(8, kDebugLoading, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags);
}
bool Bitmap::isPixelHitAtPos(int x, int y) {
@@ -821,7 +821,7 @@ void Bitmap::decode(int32 *palette) {
}
void Bitmap::putDib(int x, int y, int32 *palette, int alpha) {
- debug(7, "Bitmap::putDib(%d, %d)", x, y);
+ debugC(7, kDebugDrawing, "Bitmap::putDib(%d, %d)", x, y);
int x1 = x - g_fp->_sceneRect.left;
int y1 = y - g_fp->_sceneRect.top;
@@ -868,11 +868,11 @@ bool Bitmap::putDibRB(int32 *palette) {
uint16 *srcPtr;
if (!palette) {
- debug(2, "Bitmap::putDibRB(): Both global and local palettes are empty");
+ debugC(2, kDebugDrawing, "Bitmap::putDibRB(): Both global and local palettes are empty");
return false;
}
- debug(8, "Bitmap::putDibRB()");
+ debugC(8, kDebugDrawing, "Bitmap::putDibRB()");
endy = _height - 1;
@@ -1149,7 +1149,7 @@ void Bitmap::drawRotated(int x, int y, int angle, byte *palette, int alpha) {
}
bool BigPicture::load(MfcArchive &file) {
- debug(5, "BigPicture::load()");
+ debugC(5, kDebugLoading, "BigPicture::load()");
Picture::load(file);
return true;
@@ -1190,7 +1190,7 @@ Shadows::Shadows() {
}
bool Shadows::load(MfcArchive &file) {
- debug(5, "Shadows::load()");
+ debugC(5, kDebugLoading, "Shadows::load()");
_sceneId = file.readUint32LE();
_staticAniObjectId = file.readUint32LE();
_movementId = file.readUint32LE();
diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp
index 4aac3485f4..484b1e150e 100644
--- a/engines/fullpipe/interaction.cpp
+++ b/engines/fullpipe/interaction.cpp
@@ -62,7 +62,7 @@ InteractionController::~InteractionController() {
}
bool InteractionController::load(MfcArchive &file) {
- debug(5, "InteractionController::load()");
+ debugC(5, kDebugLoading, "InteractionController::load()");
return _interactions.load(file);
}
@@ -143,6 +143,7 @@ bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject
obj->setPicAniInfo(&aniInfo);
if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1) {
+ debugC(0, kDebugPathfinding, "Calling doWalkTo() at [%d, %d]", xpos, ypos);
mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2);
if (mq) {
dur = mq->calcDuration(subj);
@@ -440,7 +441,7 @@ Interaction::~Interaction() {
}
bool Interaction::load(MfcArchive &file) {
- debug(5, "Interaction::load()");
+ debugC(5, kDebugLoading, "Interaction::load()");
_objectId1 = file.readUint16LE();
_objectId2 = file.readUint16LE();
@@ -531,7 +532,7 @@ bool Interaction::isOverlapping(StaticANIObject *subj, GameObject *obj) {
}
bool EntranceInfo::load(MfcArchive &file) {
- debug(5, "EntranceInfo::load()");
+ debugC(5, kDebugLoading, "EntranceInfo::load()");
_sceneId = file.readUint32LE();
_field_4 = file.readUint32LE();
diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp
index f9b507c50b..aa229d55d7 100644
--- a/engines/fullpipe/inventory.cpp
+++ b/engines/fullpipe/inventory.cpp
@@ -35,7 +35,7 @@ Inventory::~Inventory() {
}
bool Inventory::load(MfcArchive &file) {
- debug(5, "Inventory::load()");
+ debugC(5, kDebugLoading, "Inventory::load()");
_sceneId = file.readUint16LE();
int numInvs = file.readUint32LE();
diff --git a/engines/fullpipe/messagehandlers.cpp b/engines/fullpipe/messagehandlers.cpp
index 94754ad22a..c40af3b062 100644
--- a/engines/fullpipe/messagehandlers.cpp
+++ b/engines/fullpipe/messagehandlers.cpp
@@ -100,7 +100,7 @@ void global_messageHandler_KickMetal() {
}
int global_messageHandler1(ExCommand *cmd) {
- debug(5, "global_messageHandler1: %d %d", cmd->_messageKind, cmd->_messageNum);
+ debugC(5, kDebugEvents, "global_messageHandler1: %d %d", cmd->_messageKind, cmd->_messageNum);
if (cmd->_excFlags & 0x10000) {
if (cmd->_messageNum == MV_MAN_TOLADDER)
@@ -364,7 +364,7 @@ int global_messageHandler3(ExCommand *cmd) {
case 17:
switch (cmd->_messageNum) {
case 61:
- debug(0, "preload: { %d, %d },", cmd->_parentId, cmd->_keyCode);
+ debugC(0, kDebugEvents, "preload: { %d, %d },", cmd->_parentId, cmd->_keyCode);
return g_fp->_gameLoader->preloadScene(cmd->_parentId, cmd->_keyCode);
case 62:
return g_fp->_gameLoader->gotoScene(cmd->_parentId, cmd->_keyCode);
@@ -425,6 +425,7 @@ int global_messageHandler3(ExCommand *cmd) {
if (g_fp->_msgX != cmd->_sceneClickX || g_fp->_msgY != cmd->_sceneClickY) {
ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1);
if (!ani || (ani->isIdle() && !(ani->_flags & 0x80) && !(ani->_flags & 0x100))) {
+ debugC(0, kDebugPathfinding, "WWW 1");
result = startWalkTo(g_fp->_gameLoader->_field_FA, -1, cmd->_sceneClickX, cmd->_sceneClickY, 0);
if (result) {
ExCommand *ex = new ExCommand(g_fp->_gameLoader->_field_FA, 17, 64, 0, 0, 0, 1, 0, 0, 0);
@@ -765,7 +766,7 @@ int MovGraph_messageHandler(ExCommand *cmd) {
point.x = ani->_ox;
point.y = ani->_oy;
- double dst = gr->calcDistance(&point, (MovGraphLink *)(*i), 0);
+ double dst = gr->putToLink(&point, (MovGraphLink *)(*i), 0);
if (dst >= 0.0 && dst < mindistance) {
mindistance = dst;
link = (MovGraphLink *)(*i);
@@ -775,13 +776,13 @@ int MovGraph_messageHandler(ExCommand *cmd) {
int top;
if (link) {
- MovGraphNode *node = link->_movGraphNode1;
+ MovGraphNode *node = link->_graphSrc;
double sq = (ani->_oy - node->_y) * (ani->_oy - node->_y) + (ani->_ox - node->_x) * (ani->_ox - node->_x);
int off = (node->_field_14 >> 16) & 0xFF;
- double off2 = ((link->_movGraphNode2->_field_14 >> 8) & 0xff) - off;
+ double off2 = ((link->_graphDst->_field_14 >> 8) & 0xff) - off;
- top = off + (int)(sqrt(sq) * off2 / link->_z);
+ top = off + (int)(sqrt(sq) * off2 / link->_length);
} else {
top = (gr->calcOffset(ani->_ox, ani->_oy)->_field_14 >> 8) & 0xff;
}
diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp
index a7337b98ed..8652223ed1 100644
--- a/engines/fullpipe/messages.cpp
+++ b/engines/fullpipe/messages.cpp
@@ -57,7 +57,7 @@ ExCommand::ExCommand(int16 parentId, int messageKind, int messageNum, int x, int
}
bool ExCommand::load(MfcArchive &file) {
- debug(5, "ExCommand::load()");
+ debugC(5, kDebugLoading, "ExCommand::load()");
_parentId = file.readUint16LE();
_messageKind = file.readUint32LE();
@@ -247,7 +247,7 @@ ObjstateCommand::~ObjstateCommand() {
}
bool ObjstateCommand::load(MfcArchive &file) {
- debug(5, "ObjStateCommand::load()");
+ debugC(5, kDebugLoading, "ObjStateCommand::load()");
_objtype = kObjTypeObjstateCommand;
@@ -341,7 +341,7 @@ MessageQueue::~MessageQueue() {
}
bool MessageQueue::load(MfcArchive &file) {
- debug(5, "MessageQueue::load()");
+ debugC(5, kDebugLoading, "MessageQueue::load()");
_dataId = file.readUint16LE();
diff --git a/engines/fullpipe/mgm.cpp b/engines/fullpipe/mgm.cpp
index 1c8ca2a7b1..c9eeebb224 100644
--- a/engines/fullpipe/mgm.cpp
+++ b/engines/fullpipe/mgm.cpp
@@ -34,6 +34,8 @@ void MGM::clear() {
}
MessageQueue *MGM::genMQ(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr) {
+ debugC(4, kDebugPathfinding, "MGM::genMQ(*%d, %d, %d, res, point)", ani->_id, staticsIndex, staticsId);
+
int idx = getItemIndexById(ani->_id);
if (idx == -1)
@@ -130,6 +132,8 @@ MGMSubItem::MGMSubItem() {
}
void MGM::addItem(int objId) {
+ debugC(4, kDebugPathfinding, "MGM::addItem(%d)", objId);
+
if (getItemIndexById(objId) == -1) {
MGMItem *item = new MGMItem();
@@ -145,6 +149,8 @@ void MGM::rebuildTables(int objId) {
if (idx == -1)
return;
+ debugC(3, kDebugPathfinding, "MGM::rebuildTables. (1) movements1 sz: %d movements2 sz: %d", _items[idx]->movements1.size(), _items[idx]->movements2.size());
+
_items[idx]->subItems.clear();
_items[idx]->statics.clear();
_items[idx]->movements1.clear();
@@ -155,14 +161,20 @@ void MGM::rebuildTables(int objId) {
if (!obj)
return;
+ debugC(1, kDebugPathfinding, "WWW rebuild. idx: %d, size: %d", idx, obj->_staticsList.size() * obj->_staticsList.size());
for (uint i = 0; i < obj->_staticsList.size(); i++) {
_items[idx]->statics.push_back((Statics *)obj->_staticsList[i]);
- _items[idx]->subItems.push_back(new MGMSubItem);
+ for (uint j = 0; j < obj->_staticsList.size(); j++) // Yes, square
+ _items[idx]->subItems.push_back(new MGMSubItem);
}
- for (uint i = 0; i < obj->_movements.size(); i++)
+ for (uint i = 0; i < obj->_movements.size(); i++) {
_items[idx]->movements1.push_back((Movement *)obj->_movements[i]);
+ _items[idx]->movements2.push_back(0);
+ }
+
+ debugC(3, kDebugPathfinding, "MGM::rebuildTables. (2) movements1 sz: %d movements2 sz: %d", _items[idx]->movements1.size(), _items[idx]->movements2.size());
}
int MGM::getItemIndexById(int objId) {
@@ -174,6 +186,8 @@ int MGM::getItemIndexById(int objId) {
}
MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
+ debugC(4, kDebugPathfinding, "MGM::genMovement(*%d)", mgminfo->ani ? mgminfo->ani->_id : -1);
+
if (!mgminfo->ani)
return 0;
@@ -214,12 +228,15 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
if (!mov)
return 0;
+
int itemIdx = getItemIndexById(mgminfo->ani->_id);
int subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1);
int st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId);
int st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId);
int subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2);
+ debugC(3, kDebugPathfinding, "MGM::genMovement. (1) movements1 sz: %d movements2 sz: %d", _items[itemIdx]->movements1.size(), _items[itemIdx]->movements2.size());
+
clearMovements2(itemIdx);
recalcOffsets(itemIdx, subIdx, st2idx, 0, 1);
clearMovements2(itemIdx);
@@ -376,6 +393,8 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) {
mq->addExCommandToEnd(ex);
+ debugC(3, kDebugPathfinding, "MGM::genMovement. (2) movements1 sz: %d movements2 sz: %d", _items[itemIdx]->movements1.size(), _items[itemIdx]->movements2.size());
+
return mq;
}
@@ -389,14 +408,16 @@ int MGM::countPhases(int idx, int subIdx, int endIdx, int flag) {
if (subIdx < 0)
break;
- res += _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->movement->countPhasesWithFlag(-1, flag);
+ res += _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->movement->countPhasesWithFlag(0xffffffff, flag);
- subIdx = _items[idx]->subItems[subIdx + 6 * endIdx * _items[idx]->statics.size()]->staticsIndex;
+ subIdx = _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->staticsIndex;
}
return res;
}
void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) {
+ debugC(4, kDebugPathfinding, "MGM::updateAnimStatics(*%d, %d)", ani->_id, staticsId);
+
if (getItemIndexById(ani->_id) == -1)
return;
@@ -425,6 +446,8 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) {
}
Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, int staticsId2) {
+ debugC(4, kDebugPathfinding, "MGM::getPoint([%d, %d], %d, %d, %d)", point->x, point->y, objectId, staticsId1, staticsId2);
+
int idx = getItemIndexById(objectId);
if (idx == -1) {
@@ -474,7 +497,7 @@ int MGM::getStaticsIndexById(int idx, int16 id) {
return i;
}
- return 0;
+ return -1;
}
int MGM::getStaticsIndex(int idx, Statics *st) {
@@ -486,79 +509,95 @@ int MGM::getStaticsIndex(int idx, Statics *st) {
return i;
}
- return 0;
+ return -1;
}
void MGM::clearMovements2(int idx) {
- _items[idx]->movements2.clear();
+ debugC(2, kDebugPathfinding, "MGM::clearMovements2(%d)", idx);
+
+ for (uint i = 0; i < _items[idx]->movements2.size(); i++)
+ _items[idx]->movements2[i] = 0;
+
+ debugC(3, kDebugPathfinding, "MGM::clearMovements2. movements1 sz: %d movements2 sz: %d", _items[idx]->movements1.size(), _items[idx]->movements2.size());
}
int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
MGMItem *item = _items[idx];
int subIdx = st1idx + st2idx * item->statics.size();
+ debugC(2, kDebugPathfinding, "MGM::recalcOffsets(%d, %d, %d, %d, %d)", idx, st1idx, st2idx, flip, flop);
+
if (st1idx == st2idx) {
memset(&item->subItems[subIdx], 0, sizeof(item->subItems[subIdx]));
return 0;
}
- if (item->subItems[subIdx])
+ if (item->subItems[subIdx]->movement)
return item->subItems[subIdx]->field_8;
Common::Point point;
+ debugC(3, kDebugPathfinding, "MGM::recalcOffsets. movements1 sz: %d movements2 sz: %d", item->movements1.size(), item->movements2.size());
+
for (uint i = 0; i < item->movements1.size(); i++) {
Movement *mov = item->movements1[i];
if (mov->_staticsObj1 == item->statics[st1idx]) {
- if (!item->movements2[i] && (!flop || mov->_field_50)) {
- item->movements2[i] = 1;
+ if (item->movements2[i] || (flop && !mov->_field_50))
+ continue;
- int stidx = getStaticsIndex(idx, item->movements1[i]->_staticsObj2);
- int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
- int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
- int newsz = sz + item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->field_C;
+ item->movements2[i] = 1;
- if (recalc >= 0) {
- if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1 ||
- (item->subItems[subIdx]->field_8 == recalc + 1 && item->subItems[subIdx]->field_C > newsz)) {
- item->subItems[subIdx]->movement = mov;
- item->subItems[subIdx]->staticsIndex = stidx;
- item->subItems[subIdx]->field_8 = recalc + 1;
- item->subItems[subIdx]->field_C = newsz;
+ int stidx = getStaticsIndex(idx, mov->_staticsObj2);
+ int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
+ int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ debugC(1, kDebugPathfinding, "MGM::recalcOffsets, want idx: %d, off: %d (%d + %d), sz: %d", idx, stidx + st2idx * _items[idx]->statics.size(), stidx, st2idx, item->subItems.size());
- mov->calcSomeXY(point, 0, -1);
+ int newsz = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C;
- item->subItems[subIdx]->x = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->x + point.x;
- item->subItems[subIdx]->y = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->y + point.y;
- }
- }
+ if (recalc < 0)
+ continue;
+
+ if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1 ||
+ (item->subItems[subIdx]->field_8 == recalc + 1 && item->subItems[subIdx]->field_C > newsz)) {
+ item->subItems[subIdx]->movement = mov;
+ item->subItems[subIdx]->staticsIndex = stidx;
+ item->subItems[subIdx]->field_8 = recalc + 1;
+ item->subItems[subIdx]->field_C = newsz;
+
+ mov->calcSomeXY(point, 0, -1);
+
+ item->subItems[subIdx]->x = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->x + point.x;
+ item->subItems[subIdx]->y = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->y + point.y;
}
} else if (flip) {
- if (mov->_staticsObj2 == item->statics[st1idx]) {
- if (!item->movements2[i] && (!flop || mov->_field_50)) {
- item->movements2[i] = 1;
+ if (mov->_staticsObj2 != item->statics[st1idx])
+ continue;
- int stidx = getStaticsIndex(idx, mov->_staticsObj1);
- int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
+ if (item->movements2[i] || (flop && !mov->_field_50))
+ continue;
- if (recalc >= 0) {
- if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1) {
- item->subItems[subIdx]->movement = mov;
- item->subItems[subIdx]->staticsIndex = stidx;
- item->subItems[subIdx]->field_8 = recalc + 1;
+ item->movements2[i] = 1;
- int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ int stidx = getStaticsIndex(idx, mov->_staticsObj1);
+ int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
- item->subItems[subIdx]->field_C = sz + item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->field_C;
+ if (recalc < 0)
+ continue;
- mov->calcSomeXY(point, 0, -1);
+ if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1) {
+ item->subItems[subIdx]->movement = mov;
+ item->subItems[subIdx]->staticsIndex = stidx;
+ item->subItems[subIdx]->field_8 = recalc + 1;
- item->subItems[subIdx]->x = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->x - point.x;
- item->subItems[subIdx]->y = item->subItems[stidx + 6 * st2idx * _items[idx]->statics.size()]->y - point.y;
- }
- }
- }
+ int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+
+ item->subItems[subIdx]->field_C = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C;
+
+ mov->calcSomeXY(point, 0, -1);
+
+ item->subItems[subIdx]->x = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->x - point.x;
+ item->subItems[subIdx]->y = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->y - point.y;
}
}
}
@@ -570,12 +609,15 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
}
int MGM::refreshOffsets(int objectId, int idx1, int idx2) {
+ debugC(4, kDebugPathfinding, "MGM::refreshOffsets(%d, %d, %d)", objectId, idx1, idx2);
+
int idx = getItemIndexById(objectId);
if (idx != -1) {
int from = getStaticsIndexById(idx, idx1);
int to = getStaticsIndexById(idx, idx2);
+ debugC(1, kDebugPathfinding, "WWW 6, want idx: %d, off: %d", idx, from + to * _items[idx]->statics.size());
MGMSubItem *sub = _items[idx]->subItems[from + to * _items[idx]->statics.size()];
if (sub->movement) {
@@ -666,6 +708,8 @@ Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y,
}
ExCommand2 *MGM::buildExCommand2(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len) {
+ debugC(2, kDebugPathfinding, "MGM::buildExCommand2(mov, %d, %d, %d, [%d, %d], [%d, %d], %d)", objId, x1, y1, x2->x, x2->y, y2->x, y2->y, len);
+
uint cnt;
if (mov->_currMovement)
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 1a61cb742a..fbfa602e62 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -32,7 +32,7 @@ namespace Fullpipe {
bool MotionController::load(MfcArchive &file) {
// Is originally empty file.readClass();
- debug(5, "MotionController::load()");
+ debugC(5, kDebugLoading, "MotionController::load()");
return true;
}
@@ -42,6 +42,8 @@ void MotionController::enableLinks(const char *linkName, bool enable) {
}
MovGraphLink *MotionController::getLinkByName(const char *name) {
+ debugC(4, kDebugPathfinding, "MotionController::getLinkByName(%s)", name);
+
if (_objtype == kObjTypeMctlCompound) {
MctlCompound *obj = (MctlCompound *)this;
@@ -80,23 +82,23 @@ MovGraphLink *MotionController::getLinkByName(const char *name) {
}
bool MctlCompound::load(MfcArchive &file) {
- debug(5, "MctlCompound::load()");
+ debugC(5, kDebugLoading, "MctlCompound::load()");
int count = file.readUint32LE();
- debug(6, "MctlCompound::count = %d", count);
+ debugC(6, kDebugLoading, "MctlCompound::count = %d", count);
for (int i = 0; i < count; i++) {
- debug(6, "CompoundArray[%d]", i);
+ debugC(6, kDebugLoading, "CompoundArray[%d]", i);
MctlItem *obj = new MctlItem();
obj->_motionControllerObj = (MotionController *)file.readClass();
int count1 = file.readUint32LE();
- debug(6, "ConnectionPoint::count: %d", count1);
+ debugC(6, kDebugLoading, "ConnectionPoint::count: %d", count1);
for (int j = 0; j < count1; j++) {
- debug(6, "ConnectionPoint[%d]", j);
+ debugC(6, kDebugLoading, "ConnectionPoint[%d]", j);
MctlConnectionPoint *obj1 = (MctlConnectionPoint *)file.readClass();
obj->_connectionPoints.push_back(obj1);
@@ -105,7 +107,7 @@ bool MctlCompound::load(MfcArchive &file) {
obj->_field_20 = file.readUint32LE();
obj->_field_24 = file.readUint32LE();
- debug(6, "graphReact");
+ debugC(6, kDebugLoading, "graphReact");
obj->_movGraphReactObj = (MovGraphReact *)file.readClass();
_motionControllers.push_back(obj);
@@ -115,11 +117,15 @@ bool MctlCompound::load(MfcArchive &file) {
}
void MctlCompound::attachObject(StaticANIObject *obj) {
+ debugC(4, kDebugPathfinding, "MctlCompound::attachObject(*%d)", obj->_id);
+
for (uint i = 0; i < _motionControllers.size(); i++)
_motionControllers[i]->_motionControllerObj->attachObject(obj);
}
int MctlCompound::detachObject(StaticANIObject *obj) {
+ debugC(4, kDebugPathfinding, "MctlCompound::detachObject(*%d)", obj->_id);
+
for (uint i = 0; i < _motionControllers.size(); i++)
_motionControllers[i]->_motionControllerObj->detachObject(obj);
@@ -130,6 +136,8 @@ void MctlCompound::initMovGraph2() {
if (_objtype != kObjTypeMctlCompound)
return;
+ debugC(4, kDebugPathfinding, "MctlCompound::initMovGraph2()");
+
for (uint i = 0; i < _motionControllers.size(); i++) {
if (_motionControllers[i]->_motionControllerObj->_objtype != kObjTypeMovGraph)
continue;
@@ -151,6 +159,8 @@ void MctlCompound::initMovGraph2() {
}
void MctlCompound::detachAllObjects() {
+ debugC(4, kDebugPathfinding, "MctlCompound::detachAllObjects()");
+
for (uint i = 0; i < _motionControllers.size(); i++)
_motionControllers[i]->_motionControllerObj->detachAllObjects();
}
@@ -159,6 +169,8 @@ MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sou
int idx = -1;
int sourceIdx = -1;
+ debugC(4, kDebugPathfinding, "MctlCompound::startMove(*%d, %d, %d, %d, %d)", (ani ? ani->_id : -1), sourceX, sourceY, fuzzyMatch, staticsId);
+
if (!ani)
return 0;
@@ -186,6 +198,7 @@ MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sou
if (sourceIdx == -1)
return 0;
+ debugC(1, kDebugPathfinding, "WWW 2");
if (idx == sourceIdx)
return _motionControllers[idx]->_motionControllerObj->startMove(ani, sourceX, sourceY, fuzzyMatch, staticsId);
@@ -228,6 +241,8 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos,
int match1 = -1;
int match2 = -1;
+ debugC(1, kDebugPathfinding, "MctlCompound::doWalkTo(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId);
+
if (!subj)
return 0;
@@ -327,6 +342,8 @@ int MctlLadder::collisionDetection(StaticANIObject *man) {
}
void MctlLadder::attachObject(StaticANIObject *obj) {
+ debugC(4, kDebugPathfinding, "MctlLadder::attachObject(*%d)", obj->_id);
+
if (findObjectPos(obj) < 0) {
MctlLadderMovement *movement = new MctlLadderMovement;
@@ -348,6 +365,8 @@ int MctlLadder::findObjectPos(StaticANIObject *obj) {
}
bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement) {
+ debugC(4, kDebugPathfinding, "MctlLadder::initMovement(*%d, ...)", ani->_id);
+
GameVar *v = g_fp->getGameLoaderGameVar()->getSubVarByName(ani->getName());
if (!v)
@@ -392,6 +411,8 @@ bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement
}
void MctlLadder::detachAllObjects() {
+ debugC(4, kDebugPathfinding, "MctlLadder::detachAllObjects()");
+
_mgm.clear();
for (uint i = 0; i < _ladmovements.size(); i++) {
@@ -403,6 +424,8 @@ void MctlLadder::detachAllObjects() {
}
MessageQueue *MctlLadder::startMove(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+ debugC(4, kDebugPathfinding, "MctlLadder::startMove(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId);
+
MessageQueue *mq = doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId);
if (mq) {
@@ -414,6 +437,8 @@ MessageQueue *MctlLadder::startMove(StaticANIObject *subj, int xpos, int ypos, i
}
MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+ debugC(1, kDebugPathfinding, "MctlLadder::doWalkTo(*%d, %d, %d, %d, %d)", (ani ? ani->_id : -1), xpos, ypos, fuzzyMatch, staticsId);
+
int pos = findObjectPos(ani);
if (pos < 0)
@@ -707,11 +732,11 @@ void MovInfo1::clear() {
}
bool MctlCompoundArray::load(MfcArchive &file) {
- debug(5, "MctlCompoundArray::load()");
+ debugC(5, kDebugLoading, "MctlCompoundArray::load()");
int count = file.readUint32LE();
- debug(0, "MctlCompoundArray::count = %d", count);
+ debugC(0, kDebugLoading, "MctlCompoundArray::count = %d", count);
assert(0);
@@ -770,7 +795,7 @@ MovGraph::~MovGraph() {
}
bool MovGraph::load(MfcArchive &file) {
- debug(5, "MovGraph::load()");
+ debugC(5, kDebugLoading, "MovGraph::load()");
_links.load(file);
_nodes.load(file);
@@ -779,6 +804,8 @@ bool MovGraph::load(MfcArchive &file) {
}
void MovGraph::attachObject(StaticANIObject *obj) {
+ debugC(4, kDebugPathfinding, "MovGraph::attachObject(*%d)", obj->_id);
+
_mgm.clear();
_mgm.addItem(obj->_id);
@@ -802,6 +829,8 @@ int MovGraph::detachObject(StaticANIObject *obj) {
}
void MovGraph::detachAllObjects() {
+ debugC(4, kDebugPathfinding, "MovGraph::detachAllObjects()");
+
for (uint i = 0; i < _items.size(); i++) {
_items[i]->free();
@@ -812,6 +841,8 @@ void MovGraph::detachAllObjects() {
}
Common::Array<MovItem *> *MovGraph::getPaths(StaticANIObject *ani, int x, int y, int flag1, int *rescount) {
+ debugC(4, kDebugPathfinding, "MovGraph::getPaths(*%d, %d, %d, %d, &rescount)", (ani ? ani->_id : -1), x, y, flag1);
+
*rescount = 0;
if (_items.size() <= 0)
@@ -836,7 +867,7 @@ Common::Array<MovItem *> *MovGraph::getPaths(StaticANIObject *ani, int x, int y,
point.x = ani->_ox;
point.y = ani->_oy;
- if (!calcChunk(idx, ani->_ox, ani->_oy, &_items[idx]->movarr, 0))
+ if (!getHitPoint(idx, ani->_ox, ani->_oy, &_items[idx]->movarr, 0))
getNearestPoint(idx, &point, &_items[idx]->movarr);
_items[idx]->count = 0;
@@ -845,19 +876,19 @@ Common::Array<MovItem *> *MovGraph::getPaths(StaticANIObject *ani, int x, int y,
_items[idx]->movitems = 0;
int arrSize;
- Common::Array<MovArr *> *movarr = genMovArr(x, y, &arrSize, flag1, 0);
+ Common::Array<MovArr *> *movarr = getHitPoints(x, y, &arrSize, flag1, 0);
if (movarr) {
for (int i = 0; i < arrSize; i++) {
int sz;
- Common::Array<MovItem *> *movitems = calcMovItems(&_items[idx]->movarr, (*movarr)[i], &sz);
+ Common::Array<MovItem *> *movitems = getPaths(&_items[idx]->movarr, (*movarr)[i], &sz);
if (sz > 0) {
for (int j = 0; j < sz; j++)
_items[idx]->movitems->push_back(movitems[j]);
-
- delete movitems;
}
+
+ delete movitems;
}
delete movarr;
@@ -878,6 +909,8 @@ bool MovGraph::setPosImmediate(StaticANIObject *obj, int x, int y) {
}
MessageQueue *MovGraph::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+ debugC(4, kDebugPathfinding, "MovGraph::startMove(*%d, %d, %d, %d, %d)", (ani ? ani->_id : -1), xpos, ypos, fuzzyMatch, staticsId);
+
if (!ani) {
if (!_items.size())
return 0;
@@ -955,6 +988,8 @@ void MovGraph::setSelFunc(MovArr *(*callback1)(StaticANIObject *ani, Common::Arr
}
bool MovGraph::resetPosition(StaticANIObject *ani, int flag) {
+ debugC(4, kDebugPathfinding, "MovGraph::resetPosition(*%d, %d)", (ani ? ani->_id : -1), flag);
+
int idx = getObjectIndex(ani);
if (idx == -1)
@@ -1008,7 +1043,7 @@ bool MovGraph::canDropInventory(StaticANIObject *ani, int x, int y) {
return true;
}
}
- } else if (calcChunk(idx, ani->_ox, ani->_oy, &m, 0) && m._link && (m._link->_flags & 0x4000000)) {
+ } else if (getHitPoint(idx, ani->_ox, ani->_oy, &m, 0) && m._link && (m._link->_flags & 0x4000000)) {
return true;
}
}
@@ -1017,6 +1052,8 @@ bool MovGraph::canDropInventory(StaticANIObject *ani, int x, int y) {
}
MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+ debugC(1, kDebugPathfinding, "MovGraph::doWalkTo(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId);
+
PicAniInfo picAniInfo;
int ss;
@@ -1074,7 +1111,7 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int
_items[idx]->movarr._afield_8 = -1;
_items[idx]->movarr._link = 0;
- MessageQueue *mq = fillMGMinfo(_items[idx]->ani, &_items[idx]->movarr, staticsId);
+ MessageQueue *mq = makeWholeQueue(_items[idx]->ani, &_items[idx]->movarr, staticsId);
if (mq) {
ExCommand *ex = new ExCommand();
ex->_messageKind = 17;
@@ -1095,6 +1132,8 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int
}
MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x1, int y1, int stid2, int flag1) {
+ debugC(4, kDebugPathfinding, "MovGraph::sub1(*%d, %d, %d, %d, %d, %d, %d, %d)", (ani ? ani->_id : -1), x, y, stid, x1, y1, stid2, flag1);
+
PicAniInfo picinfo;
ani->getPicAniInfo(&picinfo);
@@ -1129,7 +1168,7 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x
_items[idx]->movarr._afield_8 = -1;
_items[idx]->movarr._link = 0;
- res = fillMGMinfo(_items[idx]->ani, &_items[idx]->movarr, stid2);
+ res = makeWholeQueue(_items[idx]->ani, &_items[idx]->movarr, stid2);
break;
}
@@ -1140,7 +1179,9 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x
return res;
}
-MessageQueue *MovGraph::fillMGMinfo(StaticANIObject *ani, MovArr *movarr, int staticsId) {
+MessageQueue *MovGraph::makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int staticsId) {
+ debugC(4, kDebugPathfinding, "MovGraph::makeWholeQueue(*%d, *, %d)", (ani ? ani->_id : -1), staticsId);
+
if (!movarr->_movStepCount)
return 0;
@@ -1176,16 +1217,16 @@ MessageQueue *MovGraph::fillMGMinfo(StaticANIObject *ani, MovArr *movarr, int st
if (i == movarr->_movStepCount - 1) {
nx = movarr->_point.x;
ny = movarr->_point.y;
- nd = st->link->_movGraphNode1->_z;
+ nd = st->link->_graphSrc->_z;
} else {
if (st->sfield_0) {
- nx = st->link->_movGraphNode1->_x;
- ny = st->link->_movGraphNode1->_y;
- nd = st->link->_movGraphNode1->_z;
+ nx = st->link->_graphSrc->_x;
+ ny = st->link->_graphSrc->_y;
+ nd = st->link->_graphSrc->_z;
} else {
- nx = st->link->_movGraphNode2->_x;
- ny = st->link->_movGraphNode2->_y;
- nd = st->link->_movGraphNode2->_z;
+ nx = st->link->_graphDst->_x;
+ ny = st->link->_graphDst->_y;
+ nd = st->link->_graphDst->_z;
}
}
@@ -1227,6 +1268,8 @@ MessageQueue *MovGraph::fillMGMinfo(StaticANIObject *ani, MovArr *movarr, int st
}
MessageQueue *MovGraph::method50(StaticANIObject *ani, MovArr *movarr, int staticsId) {
+ debugC(4, kDebugPathfinding, "MovGraph::method50(*%d, *, %d)", (ani ? ani->_id : -1), staticsId);
+
if (_items.size() == 0)
return 0;
@@ -1261,7 +1304,7 @@ MessageQueue *MovGraph::method50(StaticANIObject *ani, MovArr *movarr, int stati
_items[idx]->movarr._afield_8 = -1;
_items[idx]->movarr._link = 0;
- MessageQueue *mq = fillMGMinfo(_items[idx]->ani, &_items[idx]->movarr, 0);
+ MessageQueue *mq = makeWholeQueue(_items[idx]->ani, &_items[idx]->movarr, 0);
if (!mq)
return 0;
@@ -1283,24 +1326,24 @@ MessageQueue *MovGraph::method50(StaticANIObject *ani, MovArr *movarr, int stati
return mq;
}
-double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzzyMatch) {
- int n1x = link->_movGraphNode1->_x;
- int n1y = link->_movGraphNode1->_y;
- int n2x = link->_movGraphNode2->_x;
- int n2y = link->_movGraphNode2->_y;
+double MovGraph::putToLink(Common::Point *point, MovGraphLink *link, int fuzzyMatch) {
+ int n1x = link->_graphSrc->_x;
+ int n1y = link->_graphSrc->_y;
+ int n2x = link->_graphDst->_x;
+ int n2y = link->_graphDst->_y;
double dist1x = (double)(point->x - n1x);
- double dist1y = (double)(n1y - point->y);
+ double dist1y = (double)(point->y - n1y);
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->_z / dist1;
+ double dist1 = sqrt(dist1x * dist1x + dist1y * dist1y);
+ double dist2 = (dist2y * dist1y + dist2x * dist1x) / link->_length / dist1;
double distm = dist2 * dist1;
double res = sqrt(1.0 - dist2 * dist2) * dist1;
- if (dist2 <= 0.0 || distm >= link->_z) {
+ if (dist2 <= 0.0 || distm >= link->_length) {
if (fuzzyMatch) {
if (dist2 > 0.0) {
- if (distm >= link->_z) {
+ if (distm >= link->_length) {
point->x = n2x;
point->y = n2y;
}
@@ -1312,14 +1355,16 @@ double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzz
return -1.0;
}
} else {
- point->x = (int)(n1x + (dist2x * distm / link->_z));
- point->y = (int)(n1y + (dist2y * distm / link->_z));
+ point->x = (int)(n1x + (dist2x * distm / link->_length));
+ point->y = (int)(n1y + (dist2y * distm / link->_length));
}
return res;
}
void MovGraph::recalcLinkParams() {
+ debugC(4, kDebugPathfinding, "MovGraph::recalcLinkParams()");
+
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
@@ -1332,6 +1377,8 @@ void MovGraph::recalcLinkParams() {
}
bool MovGraph::getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr) {
+ debugC(4, kDebugPathfinding, "MovGraph::getNearestPoint(...)");
+
MovGraphLink *link = 0;
double mindist = 1.0e20;
int resx = 0, resy = 0;
@@ -1340,14 +1387,14 @@ bool MovGraph::getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr)
MovGraphLink *lnk = (MovGraphLink *)*i;
if ((lnk->_flags & 0x10000000) && !(lnk->_flags & 0x20000000) ) {
- double dx1 = lnk->_movGraphNode1->_x - p->x;
- double dy1 = lnk->_movGraphNode1->_y - p->y;
- double dx2 = lnk->_movGraphNode2->_x - p->x;
- double dy2 = lnk->_movGraphNode2->_y - p->y;
- double dx3 = lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x;
- double dy3 = lnk->_movGraphNode2->_y - lnk->_movGraphNode1->_y;
+ double dx1 = lnk->_graphSrc->_x - p->x;
+ double dy1 = lnk->_graphSrc->_y - p->y;
+ double dx2 = lnk->_graphDst->_x - p->x;
+ double dy2 = lnk->_graphDst->_y - p->y;
+ double dx3 = lnk->_graphDst->_x - lnk->_graphSrc->_x;
+ double dy3 = lnk->_graphDst->_y - lnk->_graphSrc->_y;
double sq1 = sqrt(dy1 * dy1 + dx1 * dx1);
- double sdist = (dy3 * dy1 + dx3 * dx1) / lnk->_z / sq1;
+ double sdist = (dy3 * dy1 + dx3 * dx1) / lnk->_length / sq1;
double ldist = sdist * sq1;
double dist = sqrt(1.0 - sdist * sdist) * sq1;
@@ -1356,14 +1403,14 @@ bool MovGraph::getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr)
dist = sqrt(dx1 * dx1 + dy1 * dy1);
}
- if (ldist > lnk->_z) {
- ldist = lnk->_z;
+ if (ldist > lnk->_length) {
+ ldist = lnk->_length;
dist = sqrt(dx2 * dx2 + dy2 * dy2);
}
- if (ldist >= 0.0 && ldist <= lnk->_z && dist < mindist) {
- resx = lnk->_movGraphNode1->_x + (int)(dx3 * ldist / lnk->_z);
- resy = lnk->_movGraphNode1->_y + (int)(dy3 * ldist / lnk->_z);
+ if (ldist >= 0.0 && ldist <= lnk->_length && dist < mindist) {
+ resx = lnk->_graphSrc->_x + (int)(dx3 * ldist / lnk->_length);
+ resy = lnk->_graphSrc->_y + (int)(dy3 * ldist / lnk->_length);
mindist = dist;
link = lnk;
@@ -1394,7 +1441,9 @@ int MovGraph::getObjectIndex(StaticANIObject *ani) {
return -1;
}
-Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int flag1, int flag2) {
+Common::Array<MovArr *> *MovGraph::getHitPoints(int x, int y, int *arrSize, int flag1, int flag2) {
+ debugC(4, kDebugPathfinding, "MovGraph::getHitPoints(...)");
+
if (!_links.size()) {
*arrSize = 0;
@@ -1409,15 +1458,15 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
if (flag1) {
Common::Point point(x, y);
- double dist = calcDistance(&point, lnk, 0);
+ double dist = putToLink(&point, lnk, 0);
if (dist >= 0.0 && dist < 2.0) {
movarr = new MovArr;
movarr->_link = lnk;
- movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - point.y) +
- (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(point.x - lnk->_movGraphNode1->_x)) /
- lnk->_z / lnk->_z;
+ movarr->_dist = ((double)(lnk->_graphSrc->_y - lnk->_graphDst->_y) * (double)(lnk->_graphSrc->_y - point.y) +
+ (double)(lnk->_graphDst->_x - lnk->_graphSrc->_x) * (double)(point.x - lnk->_graphSrc->_x)) /
+ lnk->_length / lnk->_length;
movarr->_point = point;
arr->push_back(movarr);
@@ -1430,27 +1479,27 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
movarr = new MovArr;
movarr->_link = lnk;
movarr->_dist = 0.0;
- movarr->_point.x = lnk->_movGraphNode1->_x;
- movarr->_point.y = lnk->_movGraphNode1->_y;
+ movarr->_point.x = lnk->_graphSrc->_x;
+ movarr->_point.y = lnk->_graphSrc->_y;
arr->push_back(movarr);
movarr = new MovArr;
movarr->_link = lnk;
movarr->_dist = 1.0;
- movarr->_point.x = lnk->_movGraphNode1->_x;
- movarr->_point.y = lnk->_movGraphNode1->_y;
+ movarr->_point.x = lnk->_graphSrc->_x;
+ movarr->_point.y = lnk->_graphSrc->_y;
arr->push_back(movarr);
}
} else {
movarr = new MovArr;
movarr->_link = lnk;
- movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - y) +
- (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(x - lnk->_movGraphNode1->_x)) /
- lnk->_z / lnk->_z;
+ movarr->_dist = ((double)(lnk->_graphSrc->_y - lnk->_graphDst->_y) * (double)(lnk->_graphSrc->_y - y) +
+ (double)(lnk->_graphDst->_x - lnk->_graphSrc->_x) * (double)(x - lnk->_graphSrc->_x)) /
+ lnk->_length / lnk->_length;
movarr->_point.x = x;
movarr->_point.y = y;
- calcDistance(&movarr->_point, lnk, 0);
+ putToLink(&movarr->_point, lnk, 0);
arr->push_back(movarr);
}
@@ -1465,6 +1514,8 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
}
void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array<MovGraphLink *> &tempObList1, Common::Array<MovGraphLink *> &allPaths) {
+ debugC(4, kDebugPathfinding, "MovGraph::findAllPaths(...)");
+
if (lnk == lnk2) {
for (uint i = 0; i < tempObList1.size(); i++)
allPaths.push_back(tempObList1[i]);
@@ -1478,9 +1529,9 @@ void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
MovGraphLink *l = (MovGraphLink *)*i;
- if (l->_movGraphNode1 != lnk->_movGraphNode1) {
- if (l->_movGraphNode2 != lnk->_movGraphNode1) {
- if (l->_movGraphNode1 != lnk->_movGraphNode2 && l->_movGraphNode2 != lnk->_movGraphNode2)
+ if (l->_graphSrc != lnk->_graphSrc) {
+ if (l->_graphDst != lnk->_graphSrc) {
+ if (l->_graphSrc != lnk->_graphDst && l->_graphDst != lnk->_graphDst)
continue;
}
}
@@ -1494,7 +1545,9 @@ void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array
}
// Returns a list of possible paths two points in graph space
-Common::Array<MovItem *> *MovGraph::calcMovItems(MovArr *currPos, MovArr *destPos, int *pathCount) {
+Common::Array<MovItem *> *MovGraph::getPaths(MovArr *currPos, MovArr *destPos, int *pathCount) {
+ debugC(4, kDebugPathfinding, "MovGraph::getPaths(...)");
+
Common::Array<MovGraphLink *> tempObList1;
Common::Array<MovGraphLink *> allPaths;
@@ -1530,7 +1583,7 @@ void MovGraph::genMovItem(MovItem *movitem, MovGraphLink *grlink, MovArr *movarr
warning("STUB: MovGraph::genMovItem()");
}
-bool MovGraph::calcChunk(int idx, int x, int y, MovArr *arr, int a6) {
+bool MovGraph::getHitPoint(int idx, int x, int y, MovArr *arr, int a6) {
int staticsId;
if (_items[idx]->ani->_statics) {
@@ -1544,7 +1597,7 @@ bool MovGraph::calcChunk(int idx, int x, int y, MovArr *arr, int a6) {
int arrSize;
- Common::Array<MovArr *> *movarr = genMovArr(x, y, &arrSize, 0, 1);
+ Common::Array<MovArr *> *movarr = getHitPoints(x, y, &arrSize, 0, 1);
if (!movarr)
return getNearestPoint(idx, 0, arr);
@@ -1581,20 +1634,22 @@ bool MovGraph::calcChunk(int idx, int x, int y, MovArr *arr, int a6) {
}
void MovGraph::setEnds(MovStep *step1, MovStep *step2) {
- if (step1->link->_movGraphNode1 == step2->link->_movGraphNode2) {
+ debugC(4, kDebugPathfinding, "MovGraph::setEnds(...)");
+
+ if (step1->link->_graphSrc == step2->link->_graphDst) {
step1->sfield_0 = 1;
step2->sfield_0 = 1;
return;
}
- if (step1->link->_movGraphNode1 == step2->link->_movGraphNode1) {
+ if (step1->link->_graphSrc == step2->link->_graphSrc) {
step1->sfield_0 = 1;
step2->sfield_0 = 0;
} else {
step1->sfield_0 = 0;
- if (step1->link->_movGraphNode2 != step2->link->_movGraphNode1) {
+ if (step1->link->_graphDst != step2->link->_graphSrc) {
step2->sfield_0 = 1;
} else {
step2->sfield_0 = 0;
@@ -1633,6 +1688,7 @@ int MovGraph2::getItemSubIndexByMGM(int index, StaticANIObject *ani) {
int min = 0;
for (int i = 0; i < 4; i++) {
+ debugC(1, kDebugPathfinding, "WWW 5");
int tmp = _mgm.refreshOffsets(ani->_id, ani->_statics->_staticsId, _items2[index]->_subItems[i]._staticsId1);
if (tmp >= 0 && (minidx == -1 || tmp < min)) {
@@ -1648,6 +1704,8 @@ int MovGraph2::getItemSubIndexByMGM(int index, StaticANIObject *ani) {
}
bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) {
+ debugC(4, kDebugPathfinding, "MovGraph::initDirections(%d, ...)", obj->_id);
+
item->_obj = obj;
item->_objectId = obj->_id;
@@ -1777,6 +1835,8 @@ bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) {
}
void MovGraph2::attachObject(StaticANIObject *obj) {
+ debugC(4, kDebugPathfinding, "MovGraph2::attachObject(*%d)", obj->_id);
+
MovGraph::attachObject(obj);
int id = getItemIndexByGameObjectId(obj->_id);
@@ -1795,6 +1855,8 @@ void MovGraph2::attachObject(StaticANIObject *obj) {
}
void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst) {
+ debugC(4, kDebugPathfinding, "MovGraph2::buildMovInfo1SubItems(...)");
+
MovInfo1Sub *elem;
Common::Point point;
Common::Rect rect;
@@ -1904,6 +1966,8 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL
}
MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) {
+ debugC(4, kDebugPathfinding, "MovGraph2::buildMovInfo1MessageQueue(...)");
+
MovInfo1 movinfo(movInfo);
int curX = movInfo->pt1.x;
@@ -2037,6 +2101,8 @@ int MovGraph2::detachObject(StaticANIObject *obj) {
}
void MovGraph2::detachAllObjects() {
+ debugC(4, kDebugPathfinding, "MovGraph2::detachAllObjects()");
+
for (uint i = 0; i < _items2.size(); i++)
delete _items2[i];
@@ -2044,12 +2110,15 @@ void MovGraph2::detachAllObjects() {
}
MessageQueue *MovGraph2::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+ debugC(4, kDebugPathfinding, "MovGraph2::startMove(*%d, %d, %d, %d, %d)", ani->_id, xpos, ypos, fuzzyMatch, staticsId);
+
if (!ani->isIdle())
return 0;
if (ani->_flags & 0x100)
return 0;
+ debugC(1, kDebugPathfinding, "WWW 3");
MessageQueue *mq = doWalkTo(ani, xpos, ypos, fuzzyMatch, staticsId);
if (!mq)
@@ -2091,7 +2160,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
PicAniInfo picAniInfo;
Common::Point point;
- debug(0, "MovGraph2::doWalkTo(%d, %d, %d, %d, %d)", obj->_id, xpos, ypos, fuzzyMatch, staticsId);
+ debugC(1, kDebugPathfinding, "MovGraph2::doWalkTo(%d, %d, %d, %d, %d)", obj->_id, xpos, ypos, fuzzyMatch, staticsId);
int idx = getItemIndexByGameObjectId(obj->_id);
@@ -2118,6 +2187,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
bool subMgm = false;
if (idxsub == -1) {
+ debugC(1, kDebugPathfinding, "WWW 4");
idxsub = getItemSubIndexByMGM(idx, obj);
subMgm = true;
@@ -2223,7 +2293,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
Common::Array<MovGraphLink *> tempLinkList;
double minPath = findMinPath(&linkInfoSource, &linkInfoDest, &tempLinkList);
- debug(0, "MovGraph2::doWalkTo(): path: %g parts: %d", minPath, tempLinkList.size());
+ debugC(0, kDebugPathfinding, "MovGraph2::doWalkTo(): path: %g parts: %d", minPath, tempLinkList.size());
if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size()))
return 0;
@@ -2241,7 +2311,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
if (linkInfoSource.node)
movInfo1.distance1 = linkInfoSource.node->_z;
else
- movInfo1.distance1 = linkInfoSource.link->_movGraphNode1->_z;
+ movInfo1.distance1 = linkInfoSource.link->_graphSrc->_z;
if (linkInfoDest.node) {
dx2 = linkInfoDest.node->_x;
@@ -2255,13 +2325,13 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
movInfo1.pt2.x = xpos;
movInfo1.pt2.y = ypos;
- MovGraphNode *nod = linkInfoDest.link->_movGraphNode1;
+ MovGraphNode *nod = linkInfoDest.link->_graphSrc;
double dst1 = sqrt((double)((ypos - nod->_y) * (ypos - nod->_y) + (xpos - nod->_x) * (xpos - nod->_x)));
- int dst = linkInfoDest.link->_movGraphNode2->_z - nod->_z;
+ int dst = linkInfoDest.link->_graphDst->_z - nod->_z;
- movInfo1.distance2 = (int)(nod->_z + (dst1 * (double)dst / linkInfoDest.link->_z));
+ movInfo1.distance2 = (int)(nod->_z + (dst1 * (double)dst / linkInfoDest.link->_length));
- calcDistance(&movInfo1.pt2, linkInfoDest.link, 1);
+ putToLink(&movInfo1.pt2, linkInfoDest.link, 1);
dx1 = movInfo1.pt1.x;
dy1 = movInfo1.pt1.y;
@@ -2349,7 +2419,7 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) {
bool cond;
if (lnk)
- cond = abs(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) > abs(lnk->_movGraphNode2->_y - lnk->_movGraphNode1->_y);
+ cond = abs(lnk->_graphDst->_x - lnk->_graphSrc->_x) > abs(lnk->_graphDst->_y - lnk->_graphSrc->_y);
else
cond = abs(x) > abs(y);
@@ -2360,16 +2430,18 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) {
}
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;
+ debugC(4, kDebugPathfinding, "MovGraph2::findLink(...)");
+
+ MovGraphNode *node1 = (*linkList)[idx]->_graphSrc;
+ MovGraphNode *node2 = (*linkList)[idx]->_graphDst;
MovGraphNode *node3 = node1;
if (idx != 0) {
MovGraphLink *lnk = (*linkList)[idx - 1];
- if (lnk->_movGraphNode2 != node1) {
- if (lnk->_movGraphNode1 != node1) {
- if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) {
+ if (lnk->_graphDst != node1) {
+ if (lnk->_graphSrc != node1) {
+ if (lnk->_graphDst == node2 || lnk->_graphSrc == node2) {
node3 = node2;
node2 = node1;
}
@@ -2380,10 +2452,10 @@ int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common
} else if (idx != (int)(linkList->size() - 1)) {
MovGraphLink *lnk = (*linkList)[idx + 1];
- if (lnk->_movGraphNode2 == node1 || lnk->_movGraphNode1 == node1) {
+ if (lnk->_graphDst == node1 || lnk->_graphSrc == node1) {
node3 = node2;
node2 = node1;
- } else if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) {
+ } else if (lnk->_graphDst == node2 || lnk->_graphSrc == node2) {
node3 = node1;
}
}
@@ -2407,6 +2479,8 @@ int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common
}
MessageQueue *MovGraph2::genMovement(MovInfo1 *info) {
+ debugC(4, kDebugPathfinding, "MovGraph2::genMovement(...)");
+
int mx1 = 0;
int my1 = 0;
@@ -2608,6 +2682,8 @@ MessageQueue *MovGraph2::genMovement(MovInfo1 *info) {
}
MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) {
+ debugC(4, kDebugPathfinding, "MovGraph2::findLink1(...)");
+
Common::Point point;
MovGraphLink *res = 0;
@@ -2619,13 +2695,13 @@ MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) {
if (fuzzyMatch) {
point.x = x;
point.y = y;
- double dst = calcDistance(&point, lnk, 0);
+ double dst = putToLink(&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 (abs(lnk->_graphSrc->_x - lnk->_graphDst->_x) <= abs(lnk->_graphSrc->_y - lnk->_graphDst->_y)) {
if (idx == 2 || idx == 3)
return lnk;
res = lnk;
@@ -2642,6 +2718,8 @@ MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) {
}
MovGraphLink *MovGraph2::findLink2(int x, int y) {
+ debugC(4, kDebugPathfinding, "MovGraph2::findLink2(...)");
+
double mindist = 1.0e20;
MovGraphLink *res = 0;
@@ -2651,14 +2729,14 @@ MovGraphLink *MovGraph2::findLink2(int x, int y) {
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 n1x = lnk->_graphSrc->_x;
+ double n1y = lnk->_graphSrc->_y;
+ double n2x = lnk->_graphDst->_x;
+ double n2y = lnk->_graphDst->_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->_z / dst1;
+ double coeff1 = ((n1y - n2y) * n1dy + (n2x - n1x) * n1dx) / lnk->_length / dst1;
double dst3 = coeff1 * dst1;
double dst2 = sqrt(1.0 - coeff1 * coeff1) * dst1;
@@ -2666,11 +2744,11 @@ MovGraphLink *MovGraph2::findLink2(int x, int y) {
dst3 = 0.0;
dst2 = sqrt(n1dy * n1dy + n1dx * n1dx);
}
- if (dst3 > lnk->_z) {
- dst3 = lnk->_z;
+ if (dst3 > lnk->_length) {
+ dst3 = lnk->_length;
dst2 = sqrt((n2x - x) * (n2x - x) + (n2y - y) * (n2y - y));
}
- if (dst3 >= 0.0 && dst3 <= lnk->_z && dst2 < mindist) {
+ if (dst3 >= 0.0 && dst3 <= lnk->_length && dst2 < mindist) {
mindist = dst2;
res = lnk;
}
@@ -2684,6 +2762,8 @@ MovGraphLink *MovGraph2::findLink2(int x, int y) {
}
double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj) {
+ debugC(4, kDebugPathfinding, "MovGraph2::findMinPath(...)");
+
LinkInfo linkInfoWorkSource;
if (linkInfoSource->link != linkInfoDest->link || linkInfoSource->node != linkInfoDest->node) {
@@ -2693,7 +2773,7 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest,
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)) {
+ if ((lnk->_graphSrc == linkInfoSource->node || lnk->_graphDst == linkInfoSource->node) && !(lnk->_flags & 0xA0000000)) {
linkInfoWorkSource.node = 0;
linkInfoWorkSource.link = lnk;
@@ -2703,18 +2783,18 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest,
double newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList);
- if (newDistance >= 0.0 && (minDistance < 0.0 || newDistance + lnk->_z < minDistance)) {
+ if (newDistance >= 0.0 && (minDistance < 0.0 || newDistance + lnk->_length < minDistance)) {
listObj->clear();
listObj->push_back(tmpList);
- minDistance = newDistance + lnk->_z;
+ minDistance = newDistance + lnk->_length;
}
lnk->_flags &= 0x7FFFFFFF;
}
}
} else if (linkInfoSource->link) {
- linkInfoWorkSource.node = linkInfoSource->link->_movGraphNode1;
+ linkInfoWorkSource.node = linkInfoSource->link->_graphSrc;
linkInfoWorkSource.link = 0;
Common::Array<MovGraphLink *> tmpList;
@@ -2731,7 +2811,7 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest,
}
linkInfoWorkSource.link = 0;
- linkInfoWorkSource.node = linkInfoSource->link->_movGraphNode2;
+ linkInfoWorkSource.node = linkInfoSource->link->_graphDst;
tmpList.clear();
@@ -2774,11 +2854,11 @@ MovGraphNode *MovGraph::calcOffset(int ox, int oy) {
}
MovGraphLink::MovGraphLink() {
- _z = 0;
+ _length = 0;
_angle = 0;
_flags = 0x10000000;
- _movGraphNode2 = 0;
- _movGraphNode1 = 0;
+ _graphDst = 0;
+ _graphSrc = 0;
_field_3C = 0;
_field_38 = 0;
_movGraphReact = 0;
@@ -2796,22 +2876,22 @@ MovGraphLink::~MovGraphLink() {
bool MovGraphLink::load(MfcArchive &file) {
- debug(5, "MovGraphLink::load()");
+ debugC(5, kDebugLoading, "MovGraphLink::load()");
_dwordArray1.load(file);
_dwordArray2.load(file);
_flags = file.readUint32LE();
- debug(8, "GraphNode1");
- _movGraphNode1 = (MovGraphNode *)file.readClass();
- debug(8, "GraphNode2");
- _movGraphNode2 = (MovGraphNode *)file.readClass();
+ debugC(8, kDebugLoading, "GraphNode1");
+ _graphSrc = (MovGraphNode *)file.readClass();
+ debugC(8, kDebugLoading, "GraphNode2");
+ _graphDst = (MovGraphNode *)file.readClass();
- _z = file.readDouble();
+ _length = file.readDouble();
_angle = file.readDouble();
- debug(8, "distance: %g, angle: %g", _z, _angle);
+ debugC(8, kDebugLoading, "length: %g, angle: %g", _length, _angle);
_movGraphReact = (MovGraphReact *)file.readClass();
_name = file.readPascalString();
@@ -2820,17 +2900,17 @@ bool MovGraphLink::load(MfcArchive &file) {
}
void MovGraphLink::recalcLength() {
- if (_movGraphNode1) {
- double dx = _movGraphNode2->_x - _movGraphNode1->_x;
- double dy = _movGraphNode2->_y - _movGraphNode1->_y;
+ if (_graphSrc) {
+ double dx = _graphDst->_x - _graphSrc->_x;
+ double dy = _graphDst->_y - _graphSrc->_y;
- _z = sqrt(dy * dy + dx * dx);
+ _length = sqrt(dy * dy + dx * dx);
_angle = atan2(dx, dy);
}
}
bool MovGraphNode::load(MfcArchive &file) {
- debug(5, "MovGraphNode::load()");
+ debugC(5, kDebugLoading, "MovGraphNode::load()");
_field_14 = file.readUint32LE();
_x = file.readUint32LE();
@@ -2850,7 +2930,7 @@ ReactParallel::ReactParallel() {
}
bool ReactParallel::load(MfcArchive &file) {
- debug(5, "ReactParallel::load()");
+ debugC(5, kDebugLoading, "ReactParallel::load()");
_x1 = file.readUint32LE();
_y1 = file.readUint32LE();
@@ -2908,7 +2988,7 @@ ReactPolygonal::~ReactPolygonal() {
}
bool ReactPolygonal::load(MfcArchive &file) {
- debug(5, "ReactPolygonal::load()");
+ debugC(5, kDebugLoading, "ReactPolygonal::load()");
_centerX = file.readUint32LE();
_centerY = file.readUint32LE();
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index a40d810ffa..41860e32d0 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -218,14 +218,14 @@ public:
class MovGraphLink : public CObject {
public:
- MovGraphNode *_movGraphNode1;
- MovGraphNode *_movGraphNode2;
+ MovGraphNode *_graphSrc;
+ MovGraphNode *_graphDst;
DWordArray _dwordArray1;
DWordArray _dwordArray2;
int _flags;
int _field_38;
int _field_3C;
- double _z;
+ double _length;
double _angle;
MovGraphReact *_movGraphReact;
char *_name;
@@ -302,18 +302,18 @@ public:
virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId);
virtual MessageQueue *method50(StaticANIObject *ani, MovArr *movarr, int staticsId);
- double calcDistance(Common::Point *point, MovGraphLink *link, int fuzzyMatch);
+ double putToLink(Common::Point *point, MovGraphLink *link, int fuzzyMatch);
void recalcLinkParams();
bool getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr);
MovGraphNode *calcOffset(int ox, int oy);
int getObjectIndex(StaticANIObject *ani);
- Common::Array<MovArr *> *genMovArr(int x, int y, int *arrSize, int flag1, int flag2);
+ Common::Array<MovArr *> *getHitPoints(int x, int y, int *arrSize, int flag1, int flag2);
void findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array<MovGraphLink *> &tempObList1, Common::Array<MovGraphLink *> &tempObList2);
- Common::Array<MovItem *> *calcMovItems(MovArr *movarr1, MovArr *movarr2, int *listCount);
+ Common::Array<MovItem *> *getPaths(MovArr *movarr1, MovArr *movarr2, int *listCount);
void genMovItem(MovItem *movitem, MovGraphLink *grlink, MovArr *movarr1, MovArr *movarr2);
- bool calcChunk(int idx, int x, int y, MovArr *arr, int a6);
+ bool getHitPoint(int idx, int x, int y, MovArr *arr, int a6);
MessageQueue *sub1(StaticANIObject *ani, int x, int y, int a5, int x1, int y1, int a8, int a9);
- MessageQueue *fillMGMinfo(StaticANIObject *ani, MovArr *movarr, int staticsId);
+ MessageQueue *makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int staticsId);
void setEnds(MovStep *step1, MovStep *step2);
};
diff --git a/engines/fullpipe/ngiarchive.cpp b/engines/fullpipe/ngiarchive.cpp
index 132f4758d3..7d75dc2e78 100644
--- a/engines/fullpipe/ngiarchive.cpp
+++ b/engines/fullpipe/ngiarchive.cpp
@@ -93,11 +93,11 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename)
g_fp->_currArchive = this;
- debug(0, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size());
+ debugC(0, kDebugLoading, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size());
}
NGIArchive::~NGIArchive() {
- debug(0, "NGIArchive Destructor Called");
+ debugC(0, kDebugLoading, "NGIArchive Destructor Called");
NgiHeadersMap::iterator it = _headers.begin();
for ( ; it != _headers.end(); ++it) {
delete it->_value;
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index 5a3fbe34b6..b47988d768 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -55,7 +55,7 @@ Scene *FullpipeEngine::accessScene(int sceneId) {
}
bool SceneTagList::load(MfcArchive &file) {
- debug(5, "SceneTagList::load()");
+ debugC(5, kDebugLoading, "SceneTagList::load()");
int numEntries = file.readUint16LE();
@@ -76,7 +76,7 @@ SceneTag::SceneTag() {
}
bool SceneTag::load(MfcArchive &file) {
- debug(5, "SceneTag::load()");
+ debugC(5, kDebugLoading, "SceneTag::load()");
_field_4 = 0;
_scene = 0;
@@ -85,7 +85,7 @@ bool SceneTag::load(MfcArchive &file) {
_tag = file.readPascalString();
- debug(6, "sceneId: %d tag: %s", _sceneId, _tag);
+ debugC(6, kDebugLoading, "sceneId: %d tag: %s", _sceneId, _tag);
return true;
}
@@ -157,7 +157,7 @@ Scene::~Scene() {
}
bool Scene::load(MfcArchive &file) {
- debug(5, "Scene::load()");
+ debugC(5, kDebugLoading, "Scene::load()");
Background::load(file);
@@ -167,7 +167,7 @@ bool Scene::load(MfcArchive &file) {
debug(0, "scene: <%s> %d", transCyrillic((byte *)_sceneName), _sceneId);
int count = file.readUint16LE();
- debug(7, "scene.ani: %d", count);
+ debugC(7, kDebugLoading, "scene.ani: %d", count);
for (int i = 0; i < count; i++) {
int aniNum = file.readUint16LE();
@@ -189,7 +189,7 @@ bool Scene::load(MfcArchive &file) {
}
count = file.readUint16LE();
- debug(7, "scene.mq: %d", count);
+ debugC(7, kDebugLoading, "scene.mq: %d", count);
for (int i = 0; i < count; i++) {
int qNum = file.readUint16LE();
@@ -211,7 +211,7 @@ bool Scene::load(MfcArchive &file) {
}
count = file.readUint16LE();
- debug(7, "scene.fa: %d", count);
+ debugC(7, kDebugLoading, "scene.fa: %d", count);
for (int i = 0; i < count; i++) {
// There are no .FA files
@@ -497,7 +497,7 @@ void Scene::objectList_sortByPriority(Common::Array<PictureObject *> &list, bool
}
void Scene::draw() {
- debug(6, ">>>>> Scene::draw()");
+ debugC(6, kDebugDrawing, ">>>>> Scene::draw()");
updateScrolling();
// Clean previous stuff
@@ -640,7 +640,7 @@ int Scene::getPictureObjectIdAtPos(int x, int y) {
}
void Scene::update(int counterdiff) {
- debug(6, "Scene::update(%d)", counterdiff);
+ debugC(6, kDebugDrawing, "Scene::update(%d)", counterdiff);
for (uint i = 0; i < _staticANIObjectList2.size(); i++)
_staticANIObjectList2[i]->update(counterdiff);
@@ -654,7 +654,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
g_fp->_globalPalette = _palette->_data;
}
- debug(1, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg);
+ debugC(1, kDebugDrawing, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg);
if (_picObjList.size() > 2) { // We need to z-sort them
objectList_sortByPriority(_picObjList, true);
@@ -666,11 +666,11 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
if (maxPri == -1)
maxPri = 60000;
- debug(1, "-> Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg);
+ debugC(1, kDebugDrawing, "-> Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg);
Common::Point point;
- debug(1, "_bigPict: %d objlist: %d", _bigPictureArray1Count, _picObjList.size());
+ debugC(1, kDebugDrawing, "_bigPict: %d objlist: %d", _bigPictureArray1Count, _picObjList.size());
if (drawBg && _bigPictureArray1Count && _picObjList.size()) {
@@ -679,11 +679,11 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
int width = point.x;
int height = point.y;
- debug(8, "w: %d h:%d", width, height);
+ debugC(8, kDebugDrawing, "w: %d h:%d", width, height);
((PictureObject *)_picObjList[0])->getDimensions(&point);
- debug(8, "w2: %d h2:%d", point.x, point.y);
+ debugC(8, kDebugDrawing, "w2: %d h2:%d", point.x, point.y);
int bgStX = g_fp->_sceneRect.left % point.x;
@@ -744,7 +744,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
int objX = obj->_ox;
int objY = obj->_oy;
- debug(8, "obj: %d %d", objX, objY);
+ debugC(8, kDebugDrawing, "obj: %d %d", objX, objY);
obj->getDimensions(&point);
diff --git a/engines/fullpipe/scenes.h b/engines/fullpipe/scenes.h
index 0b7c4e7c8f..17ef5c3140 100644
--- a/engines/fullpipe/scenes.h
+++ b/engines/fullpipe/scenes.h
@@ -26,7 +26,7 @@
namespace Fullpipe {
struct Bat;
-struct BehaviorEntryInfo;
+struct BehaviorMove;
struct Hanger;
class MGM;
class MctlLadder;
@@ -346,12 +346,12 @@ public:
int scene06_sceneClickX;
int scene06_sceneClickY;
int scene06_mumsyPos;
- BehaviorEntryInfo *scene06_mumsyJumpBk;
- BehaviorEntryInfo *scene06_mumsyJumpFw;
+ BehaviorMove *scene06_mumsyJumpBk;
+ BehaviorMove *scene06_mumsyJumpFw;
int scene06_mumsyJumpBkPercent;
int scene06_mumsyJumpFwPercent;
- BehaviorEntryInfo *scene07_lukeAnim;
+ BehaviorMove *scene07_lukeAnim;
int scene07_lukePercent;
StaticANIObject *scene07_plusMinus;
diff --git a/engines/fullpipe/scenes/scene06.cpp b/engines/fullpipe/scenes/scene06.cpp
index e9cecc42f0..14042031bf 100644
--- a/engines/fullpipe/scenes/scene06.cpp
+++ b/engines/fullpipe/scenes/scene06.cpp
@@ -38,8 +38,8 @@
namespace Fullpipe {
void scene06_initMumsy() {
- g_vars->scene06_mumsyJumpFw = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPFW);
- g_vars->scene06_mumsyJumpBk = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPBK);
+ g_vars->scene06_mumsyJumpFw = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPFW);
+ g_vars->scene06_mumsyJumpBk = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPBK);
g_vars->scene06_mumsyJumpFwPercent = g_vars->scene06_mumsyJumpFw->_percent;
g_vars->scene06_mumsyJumpBkPercent = g_vars->scene06_mumsyJumpBk->_percent;
}
diff --git a/engines/fullpipe/scenes/scene07.cpp b/engines/fullpipe/scenes/scene07.cpp
index 6db8c30932..6f98d014bc 100644
--- a/engines/fullpipe/scenes/scene07.cpp
+++ b/engines/fullpipe/scenes/scene07.cpp
@@ -66,7 +66,7 @@ void sceneHandler07_openLuke() {
} else {
StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1);
- g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE);
+ g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE);
g_vars->scene07_lukeAnim->_percent = g_vars->scene07_lukePercent;
}
@@ -78,7 +78,7 @@ void sceneHandler07_closeLuke() {
if (!g_vars->scene07_lukeAnim) {
StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1);
- g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE);
+ g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE);
}
g_vars->scene07_lukePercent = g_vars->scene07_lukeAnim->_percent;
diff --git a/engines/fullpipe/scenes/scene13.cpp b/engines/fullpipe/scenes/scene13.cpp
index c7b3c96b93..1397248bd5 100644
--- a/engines/fullpipe/scenes/scene13.cpp
+++ b/engines/fullpipe/scenes/scene13.cpp
@@ -178,14 +178,14 @@ void sceneHandler13_openFast() {
}
void sceneHandler13_uneatGum() {
- BehaviorEntryInfo *beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_CHEW);
+ BehaviorMove *beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_CHEW);
if (beh) {
beh->_percent = 0;
beh->_delay = 36;
}
- beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_PLUU);
+ beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_PLUU);
if (beh) {
beh->_percent = 0;
beh->_delay = 36;
@@ -193,7 +193,7 @@ void sceneHandler13_uneatGum() {
}
void sceneHandler13_eatGum() {
- BehaviorEntryInfo *beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_CHEW);
+ BehaviorMove *beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_CHEW);
if (beh) {
beh->_percent = 10922;
@@ -216,7 +216,7 @@ void sceneHandler13_showGum() {
chainQueue(QU_SC13_SHOWGUM, 0);
}
-void sceneHandler13_setBehFlag(BehaviorEntryInfo *beh, bool flag) {
+void sceneHandler13_setBehFlag(BehaviorMove *beh, bool flag) {
if (!flag) {
beh->_percent = 327;
beh->_flags |= 1;
@@ -229,11 +229,11 @@ void sceneHandler13_setBehFlag(BehaviorEntryInfo *beh, bool flag) {
}
void sceneHandler13_walkForward(bool flag) {
- BehaviorEntryInfo *beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_RTOL);
+ BehaviorMove *beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT, QU_STR_RTOL);
sceneHandler13_setBehFlag(beh, flag);
- beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_LEFT, QU_STR_TURNR);
+ beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_LEFT, QU_STR_TURNR);
sceneHandler13_setBehFlag(beh, flag);
@@ -241,11 +241,11 @@ void sceneHandler13_walkForward(bool flag) {
}
void sceneHandler13_walkBackward(bool flag) {
- BehaviorEntryInfo *beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT|0x4000, QU_STR_LTOR);
+ BehaviorMove *beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_RIGHT|0x4000, QU_STR_LTOR);
sceneHandler13_setBehFlag(beh, flag);
- beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene13_guard, ST_STR_LEFT|0x4000, QU_STR_TURNR_L);
+ beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene13_guard, ST_STR_LEFT|0x4000, QU_STR_TURNR_L);
sceneHandler13_setBehFlag(beh, flag);
diff --git a/engines/fullpipe/scenes/scene14.cpp b/engines/fullpipe/scenes/scene14.cpp
index dc919c6d7f..d3ba3c345e 100644
--- a/engines/fullpipe/scenes/scene14.cpp
+++ b/engines/fullpipe/scenes/scene14.cpp
@@ -266,8 +266,8 @@ void sceneHandler14_showBallFly() {
}
void sceneHandler14_grandmaJump() {
- BehaviorEntryInfo *beh1 = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_JUMPFW);
- BehaviorEntryInfo *beh2 = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_JUMPBK);
+ BehaviorMove *beh1 = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_JUMPFW);
+ BehaviorMove *beh2 = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_JUMPBK);
if (beh1) {
if (beh2) {
@@ -286,11 +286,11 @@ void sceneHandler14_endArcade() {
getGameLoaderInteractionController()->enableFlag24();
getCurrSceneSc2MotionController()->activate();
- BehaviorEntryInfo *beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_BLINK);
+ BehaviorMove *beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_BLINK);
if (beh)
beh->_percent = 327;
- beh = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_THROW);
+ beh = g_fp->_behaviorManager->getBehaviorMoveByMessageQueueDataId(g_vars->scene14_grandma, ST_GMA_SIT, QU_GMA_THROW);
if (beh)
beh->_percent = 0;
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index c82c2c414c..398e28d11b 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -44,7 +44,7 @@ SoundList::SoundList() {
}
bool SoundList::load(MfcArchive &file, char *fname) {
- debug(5, "SoundList::load()");
+ debugC(5, kDebugLoading, "SoundList::load()");
_soundItemsCount = file.readUint32LE();
_soundItems = (Sound **)calloc(_soundItemsCount, sizeof(Sound *));
@@ -107,7 +107,7 @@ Sound::~Sound() {
}
bool Sound::load(MfcArchive &file, NGIArchive *archive) {
- debug(5, "Sound::load()");
+ debugC(5, kDebugLoading, "Sound::load()");
MemoryObject::load(file);
@@ -132,7 +132,7 @@ bool Sound::load(MfcArchive &file, NGIArchive *archive) {
}
void Sound::updateVolume() {
- debug(3, "STUB Sound::updateVolume()");
+ debug(9, "STUB Sound::updateVolume()");
}
void Sound::setPanAndVolumeByStaticAni() {
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index 141196c7d7..c95f6c67f3 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -112,7 +112,7 @@ GameProject::GameProject() {
}
bool GameProject::load(MfcArchive &file) {
- debug(5, "GameProject::load()");
+ debugC(5, kDebugLoading, "GameProject::load()");
_field_4 = 0;
_headerFilename = 0;
@@ -124,10 +124,10 @@ bool GameProject::load(MfcArchive &file) {
_headerFilename = file.readPascalString();
- debug(1, "_gameProjectVersion = %d", g_fp->_gameProjectVersion);
- debug(1, "_pictureScale = %d", g_fp->_pictureScale);
- debug(1, "_scrollSpeed = %d", g_fp->_scrollSpeed);
- debug(1, "_headerFilename = %s", _headerFilename);
+ debugC(1, kDebugLoading, "_gameProjectVersion = %d", g_fp->_gameProjectVersion);
+ debugC(1, kDebugLoading, "_pictureScale = %d", g_fp->_pictureScale);
+ debugC(1, kDebugLoading, "_scrollSpeed = %d", g_fp->_scrollSpeed);
+ debugC(1, kDebugLoading, "_headerFilename = %s", _headerFilename);
_sceneTagList = new SceneTagList();
@@ -205,24 +205,24 @@ bool GameVar::load(MfcArchive &file) {
_varName = file.readPascalString();
_varType = file.readUint32LE();
- debugN(6, "[%03d] ", file.getLevel());
+ debugCN(6, kDebugLoading, "[%03d] ", file.getLevel());
for (int i = 0; i < file.getLevel(); i++)
- debugN(6, " ");
+ debugCN(6, kDebugLoading, " ");
- debugN(6, "<%s>: ", transCyrillic((byte *)_varName));
+ debugCN(6, kDebugLoading, "<%s>: ", transCyrillic((byte *)_varName));
switch (_varType) {
case 0:
_value.intValue = file.readUint32LE();
- debug(6, "d --> %d", _value.intValue);
+ debugC(6, kDebugLoading, "d --> %d", _value.intValue);
break;
case 1:
_value.intValue = file.readUint32LE(); // FIXME
- debug(6, "f --> %f", _value.floatValue);
+ debugC(6, kDebugLoading, "f --> %f", _value.floatValue);
break;
case 2:
_value.stringValue = file.readPascalString();
- debug(6, "s --> %s", _value.stringValue);
+ debugC(6, kDebugLoading, "s --> %s", _value.stringValue);
break;
default:
error("Unknown var type: %d (0x%x)", _varType, _varType);
@@ -342,7 +342,7 @@ GameVar *GameVar::getSubVarByIndex(int idx) {
}
bool PicAniInfo::load(MfcArchive &file) {
- debug(5, "PicAniInfo::load()");
+ debugC(5, kDebugLoading, "PicAniInfo::load()");
type = file.readUint32LE();
objectId = file.readUint16LE();
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 8ee3b14d0c..14245d5eaf 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -201,7 +201,7 @@ StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) {
}
bool StaticANIObject::load(MfcArchive &file) {
- debug(5, "StaticANIObject::load()");
+ debugC(5, kDebugLoading, "StaticANIObject::load()");
GameObject::load(file);
@@ -215,7 +215,7 @@ bool StaticANIObject::load(MfcArchive &file) {
}
count = file.readUint16LE();
- debug(7, "Movements: %d", count);
+ debugC(7, kDebugLoading, "Movements: %d", count);
for (int i = 0; i < count; i++) {
int movNum = file.readUint16LE();
@@ -512,7 +512,7 @@ bool StaticANIObject::getPixelAtPos(int x, int y, int *pixel) {
}
void Movement::draw(bool flipFlag, int angle) {
- debug(3, "Movement::draw(%d, %d)", flipFlag, angle);
+ debugC(3, kDebugDrawing, "Movement::draw(%d, %d)", flipFlag, angle);
Common::Point point;
@@ -594,7 +594,7 @@ void StaticANIObject::draw() {
Common::Point point;
Common::Rect rect;
- debug(6, "StaticANIObject::draw() (%s) [%d] [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy);
+ debugC(6, kDebugDrawing, "StaticANIObject::draw() (%s) [%d] [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy);
if (_shadowsOn && g_fp->_currentScene && g_fp->_currentScene->_shadows
&& (getCurrDimensions(point)->x != 1 || getCurrDimensions(point)->y != 1)) {
@@ -654,7 +654,7 @@ void StaticANIObject::draw() {
}
void StaticANIObject::draw2() {
- debug(6, "StatciANIObject::draw2(): id: (%s) %d [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy);
+ debugC(6, kDebugDrawing, "StatciANIObject::draw2(): id: (%s) %d [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy);
if ((_flags & 4) && (_flags & 0x10)) {
if (_movement) {
@@ -779,7 +779,7 @@ Common::Point *StaticANIObject::getSomeXY(Common::Point &p) {
void StaticANIObject::update(int counterdiff) {
int mqid;
- debug(6, "StaticANIObject::update() (%s) [%d] [%d, %d] fl: %x", transCyrillic((byte *)_objectName), _id, _ox, _oy, _flags);
+ debugC(6, kDebugAnimation, "StaticANIObject::update() (%s) [%d] [%d, %d] fl: %x", transCyrillic((byte *)_objectName), _id, _ox, _oy, _flags);
if (_flags & 2) {
_messageNum--;
@@ -951,7 +951,7 @@ Common::Point *StaticANIObject::calcNextStep(Common::Point *pRes) {
}
void StaticANIObject::stopAnim_maybe() {
- debug(6, "StaticANIObject::stopAnim_maybe()");
+ debugC(6, kDebugAnimation, "StaticANIObject::stopAnim_maybe()");
if (!(_flags & 1))
return;
@@ -1093,7 +1093,7 @@ void StaticANIObject::hide() {
}
void StaticANIObject::show1(int x, int y, int movId, int mqId) {
- debug(6, "StaticANIObject::show1(%d, %d, %d, %d)", x, y, movId, mqId);
+ debugC(6, kDebugAnimation, "StaticANIObject::show1(%d, %d, %d, %d)", x, y, movId, mqId);
if (_messageQueueId)
return;
@@ -1285,7 +1285,7 @@ bool StaticANIObject::startAnim(int movementId, int messageQueueId, int dynPhase
if (_flags & 0x80)
return false;
- debug(4, "StaticANIObject::startAnim(%d, %d, %d) (%s [%d]) [%d, %d]", movementId, messageQueueId, dynPhaseIdx, transCyrillic((byte *)_objectName), _id, _ox, _oy);
+ debugC(4, kDebugAnimation, "StaticANIObject::startAnim(%d, %d, %d) (%s [%d]) [%d, %d]", movementId, messageQueueId, dynPhaseIdx, transCyrillic((byte *)_objectName), _id, _ox, _oy);
if (_messageQueueId) {
updateGlobalMessageQueue(messageQueueId, _id);
@@ -1444,14 +1444,14 @@ Statics::Statics(Statics *src, bool reverse) : DynamicPhase(src, reverse) {
}
bool Statics::load(MfcArchive &file) {
- debug(5, "Statics::load()");
+ debugC(5, kDebugLoading, "Statics::load()");
DynamicPhase::load(file);
_staticsId = file.readUint16LE();
_staticsName = file.readPascalString();
- debug(7, "statics: <%s> id: %d (%x)", transCyrillic((byte *)_staticsName), _staticsId, _staticsId);
+ debugC(7, kDebugLoading, "statics: <%s> id: %d (%x)", transCyrillic((byte *)_staticsName), _staticsId, _staticsId);
_picture = new Picture();
_picture->load(file);
@@ -1576,6 +1576,9 @@ Movement::Movement(Movement *src, int *oldIdxs, int newSize, StaticANIObject *an
_m2x = 0;
_m2y = 0;
+ _counter = 0;
+ _counterMax = 0;
+
_field_78 = 0;
_framePosOffsets = 0;
_field_84 = 0;
@@ -1667,7 +1670,7 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) {
int dynCount = file.readUint16LE();
- debug(7, "dynCount: %d _id: %d", dynCount, _id);
+ debugC(7, kDebugLoading, "dynCount: %d _id: %d", dynCount, _id);
if (dynCount != 0xffff || _id == MV_MAN_TURN_LU) {
_framePosOffsets = (Common::Point **)calloc(dynCount + 2, sizeof(Common::Point *));
@@ -1763,8 +1766,8 @@ Common::Point *Movement::calcSomeXY(Common::Point &p, int idx, int dynidx) {
Common::Point point;
_staticsObj1->getSomeXY(point);
- int y1 = _my - point.y;
int x1 = _mx - point.x;
+ int y1 = _my - point.y;
setDynamicPhaseIndex(0);
@@ -1823,7 +1826,7 @@ void Movement::initStatics(StaticANIObject *ani) {
if (!_currMovement)
return;
- debug(7, "Movement::initStatics()");
+ debugC(7, kDebugAnimation, "Movement::initStatics()");
_staticsObj2 = ani->addReverseStatics(_currMovement->_staticsObj2);
_staticsObj1 = ani->addReverseStatics(_currMovement->_staticsObj1);
@@ -1850,7 +1853,7 @@ void Movement::initStatics(StaticANIObject *ani) {
}
void Movement::updateCurrDynamicPhase() {
- debug(7, "Movement::updateCurrDynamicPhase()");
+ debugC(7, kDebugAnimation, "Movement::updateCurrDynamicPhase()");
if (_currMovement) {
if (_currMovement->_dynamicPhases.size() == 0 || (uint)_currDynamicPhaseIndex >= _currMovement->_dynamicPhases.size())
@@ -1902,7 +1905,7 @@ int Movement::countPhasesWithFlag(int maxidx, int flag) {
}
void Movement::setDynamicPhaseIndex(int index) {
- debug(7, "Movement::setDynamicPhaseIndex(%d)", index);
+ debugC(7, kDebugAnimation, "Movement::setDynamicPhaseIndex(%d)", index);
while (_currDynamicPhaseIndex < index)
gotoNextFrame(0, 0);
@@ -1911,7 +1914,7 @@ void Movement::setDynamicPhaseIndex(int index) {
}
DynamicPhase *Movement::getDynamicPhaseByIndex(int idx) {
- debug(7, "Movement::updateCurrDynamicPhase()");
+ debugC(7, kDebugAnimation, "Movement::updateCurrDynamicPhase()");
if (_currMovement) {
if (_currMovement->_dynamicPhases.size() == 0 || (uint)idx >= _currMovement->_dynamicPhases.size())
@@ -1970,7 +1973,7 @@ void Movement::removeFirstPhase() {
}
bool Movement::gotoNextFrame(void (*callback1)(int, Common::Point *point, int, int), void (*callback2)(int *)) {
- debug(8, "Movement::gotoNextFrame()");
+ debugC(8, kDebugAnimation, "Movement::gotoNextFrame()");
if (!callback2) {
if (_currMovement) {
@@ -2091,7 +2094,7 @@ bool Movement::gotoNextFrame(void (*callback1)(int, Common::Point *point, int, i
}
bool Movement::gotoPrevFrame() {
- debug(8, "Movement::gotoPrevFrame()");
+ debugC(8, kDebugAnimation, "Movement::gotoPrevFrame()");
if (!_currDynamicPhaseIndex) {
gotoLastFrame();
@@ -2189,7 +2192,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) {
_field_7E = 0;
_rect = new Common::Rect();
- debug(1, "DynamicPhase::DynamicPhase(src, %d)", reverse);
+ debugC(1, kDebugAnimation, "DynamicPhase::DynamicPhase(src, %d)", reverse);
if (reverse) {
if (!src->_bitmap)
@@ -2251,7 +2254,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) {
}
bool DynamicPhase::load(MfcArchive &file) {
- debug(5, "DynamicPhase::load()");
+ debugC(5, kDebugLoading, "DynamicPhase::load()");
StaticPhase::load(file);
@@ -2287,7 +2290,7 @@ StaticPhase::~StaticPhase() {
}
bool StaticPhase::load(MfcArchive &file) {
- debug(5, "StaticPhase::load()");
+ debugC(5, kDebugLoading, "StaticPhase::load()");
Picture::load(file);
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index 0cc8bd83f4..a8e00468b5 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -45,13 +45,13 @@ bool CObject::loadFile(const char *fname) {
}
bool ObList::load(MfcArchive &file) {
- debug(5, "ObList::load()");
+ debugC(5, kDebugLoading, "ObList::load()");
int count = file.readCount();
- debug(9, "ObList::count: %d:", count);
+ debugC(9, kDebugLoading, "ObList::count: %d:", count);
for (int i = 0; i < count; i++) {
- debug(9, "ObList::[%d]", i);
+ debugC(9, kDebugLoading, "ObList::[%d]", i);
CObject *t = file.readClass();
push_back(t);
@@ -61,7 +61,7 @@ bool ObList::load(MfcArchive &file) {
}
bool ObArray::load(MfcArchive &file) {
- debug(5, "ObArray::load()");
+ debugC(5, kDebugLoading, "ObArray::load()");
int count = file.readCount();
resize(count);
@@ -76,10 +76,10 @@ bool ObArray::load(MfcArchive &file) {
}
bool DWordArray::load(MfcArchive &file) {
- debug(5, "DWordArray::load()");
+ debugC(5, kDebugLoading, "DWordArray::load()");
int count = file.readCount();
- debug(9, "DWordArray::count: %d", count);
+ debugC(9, kDebugLoading, "DWordArray::count: %d", count);
resize(count);
@@ -104,7 +104,7 @@ char *MfcArchive::readPascalString(bool twoByte) {
tmp = (char *)calloc(len + 1, 1);
read(tmp, len);
- debug(9, "readPascalString: %d <%s>", len, transCyrillic((byte *)tmp));
+ debugC(9, kDebugLoading, "readPascalString: %d <%s>", len, transCyrillic((byte *)tmp));
return tmp;
}
@@ -128,7 +128,7 @@ MemoryObject::~MemoryObject() {
}
bool MemoryObject::load(MfcArchive &file) {
- debug(5, "MemoryObject::load()");
+ debugC(5, kDebugLoading, "MemoryObject::load()");
_memfilename = file.readPascalString();
if (char *p = strchr(_memfilename, '\\')) {
@@ -147,7 +147,7 @@ bool MemoryObject::load(MfcArchive &file) {
}
void MemoryObject::loadFile(char *filename) {
- debug(5, "MemoryObject::loadFile(<%s>)", filename);
+ debugC(5, kDebugLoading, "MemoryObject::loadFile(<%s>)", filename);
if (!*filename)
return;
@@ -165,7 +165,7 @@ void MemoryObject::loadFile(char *filename) {
_dataSize = s->size();
- debug(5, "Loading %s (%d bytes)", filename, _dataSize);
+ debugC(5, kDebugLoading, "Loading %s (%d bytes)", filename, _dataSize);
_data = (byte *)calloc(_dataSize, 1);
s->read(_data, _dataSize);
@@ -194,7 +194,7 @@ byte *MemoryObject::loadData() {
}
void MemoryObject::freeData() {
- debug(8, "MemoryObject::freeData(): file: %s", _memfilename);
+ debugC(8, kDebugMemory, "MemoryObject::freeData(): file: %s", _memfilename);
if (_data)
free(_data);
@@ -222,12 +222,12 @@ MemoryObject2::~MemoryObject2() {
}
bool MemoryObject2::load(MfcArchive &file) {
- debug(5, "MemoryObject2::load()");
+ debugC(5, kDebugLoading, "MemoryObject2::load()");
MemoryObject::load(file);
_mflags |= 1;
- debug(5, "MemoryObject2::load: <%s>", _memfilename);
+ debugC(5, kDebugLoading, "MemoryObject2::load: <%s>", _memfilename);
if (_memfilename && *_memfilename) {
MemoryObject::loadFile(_memfilename);
@@ -262,15 +262,11 @@ double MfcArchive::readDouble() {
// http://randomascii.wordpress.com/2012/01/11/tricks-with-the-floating-point-format/
union {
- struct {
- int32 a;
- int32 b;
- } i;
+ byte b[8];
double d;
} tmp;
- tmp.i.a = readUint32LE();
- tmp.i.b = readUint32LE();
+ read(&tmp.b, 8);
return tmp.d;
}
@@ -381,15 +377,15 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) {
uint obTag = readUint16LE();
- debug(7, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2);
+ debugC(7, kDebugLoading, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2);
if (obTag == 0xffff) {
int schema = readUint16LE();
- debug(7, "parseClass::schema = %d", schema);
+ debugC(7, kDebugLoading, "parseClass::schema = %d", schema);
name = readPascalString(true);
- debug(7, "parseClass::class <%s>", name);
+ debugC(7, kDebugLoading, "parseClass::class <%s>", name);
if (!_classMap.contains(name)) {
error("Unknown class in MfcArchive: <%s>", name);
@@ -397,7 +393,7 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) {
objectId = _classMap[name];
- debug(7, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId);
+ debugC(7, kDebugLoading, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId);
res = createObject(objectId);
_objectMap.push_back(res);
@@ -411,7 +407,7 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) {
if (_objectMap.size() < obTag) {
error("Object index too big: %d at 0x%08x", obTag, pos() - 2);
}
- debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));
+ debugC(7, kDebugLoading, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));
res = _objectMap[obTag];
@@ -424,7 +420,7 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) {
error("Object index too big: %d at 0x%08x", obTag, pos() - 2);
}
- debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));
+ debugC(7, kDebugLoading, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));
objectId = _objectIdMap[obTag];
@@ -447,7 +443,7 @@ char *genFileName(int superId, int sceneId, const char *ext) {
snprintf(s, 255, "%04d.%s", sceneId, ext);
}
- debug(7, "genFileName: %s", s);
+ debugC(7, kDebugLoading, "genFileName: %s", s);
return s;
}