summaryrefslogtreecommitdiff
path: root/src/koopatlas/pathmanager.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-05-08 02:43:37 +0200
committerTreeki <treeki@gmail.com>2012-05-08 02:43:37 +0200
commita6ddc5c5bcdbc18feb1c04d38b452d225dd7852b (patch)
tree18f1a7b3dcd56f9a44284ce2690ff759abec09df /src/koopatlas/pathmanager.cpp
parent57ffe9814a0074c01843700af0498d35a84c80f0 (diff)
downloadkamek-a6ddc5c5bcdbc18feb1c04d38b452d225dd7852b.tar.gz
kamek-a6ddc5c5bcdbc18feb1c04d38b452d225dd7852b.zip
I don't even remember what shit this commit contains
Diffstat (limited to 'src/koopatlas/pathmanager.cpp')
-rw-r--r--src/koopatlas/pathmanager.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 923d08c..632edfa 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -10,39 +10,57 @@ void dWMPathManager_c::setup() {
pathLayer = dScKoopatlas_c::instance->mapData.pathLayer;
+ SpammyReport("setting up PathManager\n");
SaveBlock *save = GetSaveFile()->GetBlock(-1);
+ mustComplainToMapCreator = false;
+
// Figure out what path node to start at
if (dScKoopatlas_c::instance->settings & 0x10000000) {
// Start off from a "Change"
u8 changeID = dScKoopatlas_c::instance->settings & 0xFF;
+ SpammyReport("entering at Change ID %d\n", changeID);
+ SpammyReport("Path layer: %p\n", pathLayer);
+ SpammyReport("Node count: %d\n", pathLayer->nodeCount);
bool found = false;
for (int i = 0; i < pathLayer->nodeCount; i++) {
dKPNode_s *node = pathLayer->nodes[i];
+ SpammyReport("Checking node: %p\n", node);
if (node->type == dKPNode_s::CHANGE && node->thisID == changeID) {
found = true;
currentNode = node;
- startMovementTo(node->getAnyExit());
+ SpammyReport("a1 Node: %p\n", node);
+ dKPPath_s *exit = node->getAnyExit();
+ SpammyReport("a2 Exit: %p\n", exit);
+ startMovementTo(exit);
+ SpammyReport("a3\n");
+ break;
}
}
if (!found) {
OSReport("Couldn't find target node %d!\n", changeID);
+ currentNode = pathLayer->nodes[0];
+ mustComplainToMapCreator = true;
}
} else {
+ SpammyReport("saved path node: %d\n", save->current_path_node);
if (save->current_path_node >= pathLayer->nodeCount) {
+ SpammyReport("out of bounds (%d), using node 0\n", pathLayer->nodeCount);
currentNode = pathLayer->nodes[0];
} else {
currentNode = pathLayer->nodes[save->current_path_node];
+ SpammyReport("OK %p\n", currentNode);
}
}
// unlock all needed paths
+ SpammyReport("Unlocking paths\n");
for (int i = 0; i < pathLayer->pathCount; i++) {
dKPPath_s *path = pathLayer->paths[i];
@@ -55,6 +73,7 @@ void dWMPathManager_c::setup() {
path->isAvailable = true;
}
}
+ SpammyReport("done\n");
}
@@ -79,25 +98,37 @@ void dWMPathManager_c::execute() {
void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
+ SpammyReport("moving to path %p\n", path);
dWMHud_c::instance->hidePointBar();
+ SpammyReport("point bar hidden\n");
+ SpammyReport("a\n");
isMoving = true;
reverseThroughPath = (path->end == currentNode);
+ SpammyReport("b\n");
currentPath = path;
+ SpammyReport("c\n");
// calculate direction of the path
short deltaX = path->end->x - path->start->x;
short deltaY = path->end->y - path->start->y;
+ SpammyReport("d\n");
u16 direction = (u16)(atan2(deltaX, deltaY) / ((M_PI * 2) / 65536.0));
+ SpammyReport("e\n");
if (reverseThroughPath) {
+ SpammyReport("e2\n");
direction += 0x8000;
}
+ SpammyReport("f\n");
daWMPlayer_c *player = daWMPlayer_c::instance;
+ SpammyReport("g %p\n", player);
player->startAnimation(2, 2.0, 10.0, 0.0);
+ SpammyReport("h\n");
player->rot.y = direction;
+ SpammyReport("i\n");
}
void dWMPathManager_c::moveThroughPath() {
@@ -125,6 +156,8 @@ void dWMPathManager_c::moveThroughPath() {
player->pos.x = to->x;
player->pos.y = -to->y;
+ SpammyReport("reached path end (%p)\n", to);
+
if (to->type == dKPNode_s::CHANGE) {
// Go to another map
isMoving = false;
@@ -132,20 +165,26 @@ void dWMPathManager_c::moveThroughPath() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
save->current_world = dScKoopatlas_c::instance->getIndexForMapName(to->destMap);
+ SpammyReport("Change to map ID %d (%s), entrance ID %d\n", save->current_world, to->destMap, to->foreignID);
+
DoSceneChange(WORLD_MAP, 0x10000000 | to->foreignID, 0);
} else if (to->type != dKPNode_s::PASS_THROUGH) {
// Stop here
player->startAnimation(0, 1.2, 10.0, 0.0);
+ SpammyReport("stopping here\n");
+
isMoving = false;
SaveBlock *save = GetSaveFile()->GetBlock(-1);
save->current_path_node = pathLayer->findNodeID(to);
dWMHud_c::instance->showPointBar();
+ SpammyReport("Point bar shown\n");
} else {
startMovementTo(to->getOppositeExitTo(currentPath));
+ SpammyReport("passthrough node, continuing to next path\n");
}
}
}