summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-08-29 19:26:25 +0200
committerTreeki <treeki@gmail.com>2012-08-29 19:26:25 +0200
commit8cedd9bfb7d35544c37f15f3f07357e0cc37c173 (patch)
treeb4052a294f5fdb18c8a369bb691efb251de3c30a /src
parentb5b55914ff6978e2b6fa6a96cb169c867abc37d2 (diff)
downloadkamek-8cedd9bfb7d35544c37f15f3f07357e0cc37c173.tar.gz
kamek-8cedd9bfb7d35544c37f15f3f07357e0cc37c173.zip
LOTS of debug output for path unlocking
Diffstat (limited to 'src')
-rw-r--r--src/koopatlas/pathmanager.cpp34
-rw-r--r--src/koopatlas/pathmanager.h2
2 files changed, 30 insertions, 6 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 6c58107..fa618b0 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -110,31 +110,47 @@ void dWMPathManager_c::unlockPaths() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
u8 *in = (u8*)dScKoopatlas_c::instance->mapData.data->unlockData;
+ OSReport("UNLOCKING PATHS: Unlock data @ %p\n", in);
+
+ int cmdID = 0;
while (*in != 0) {
+ OSReport("[%p] Cmd %d: Evaluating condition\n", in, cmdID);
// begin processing a block
- bool value = evaluateUnlockCondition(in, save);
+ bool value = evaluateUnlockCondition(in, save, 0);
+ OSReport("[%p] Cmd %d: Condition evaluated, result: %d\n", in, cmdID, value);
//OSReport("Unlock condition: %d\n", value);
// get what it's supposed to affect
// for now we'll assume that it affects one or more paths
u8 affectedCount = *(in++);
+ OSReport("[%p] Cmd %d: Affects %d path(s)\n", in, cmdID, affectedCount);
for (int i = 0; i < affectedCount; i++) {
u8 one = *(in++);
u8 two = *(in++);
u16 pathID = (one << 8) | two;
+ OSReport("[%p] Cmd %d: Affected %d: PathID: %d\n", in, cmdID, i, pathID);
dKPPath_s *path = pathLayer->paths[pathID];
+ OSReport("[%p] Cmd %d: Affected %d: Path: %p\n", in, cmdID, i, path);
path->isAvailable = value ? dKPPath_s::AVAILABLE : dKPPath_s::NOT_AVAILABLE;
+ OSReport("[%p] Cmd %d: Affected %d: IsAvailable written\n", in, cmdID, i);
PathAvailabilityData[pathID] = value ? dKPPath_s::AVAILABLE : dKPPath_s::NOT_AVAILABLE;
- //OSReport("Applied to path %p[%d]\n", path, pathID);
+ OSReport("[%p] Cmd %d: Affected %d: AvailabilityData written\n", in, cmdID, i);
// NEWLY_AVAILABLE is set later, when that stuff is figured out
path->setLayerAlpha(value ? 255 : 0);
+ OSReport("[%p] Cmd %d: Affected %d: Layer alpha applied\n", in, cmdID, i);
}
+
+ OSReport("[%p] Cmd %d: %d affected path(s) processed\n", in, cmdID, affectedCount);
+
+ cmdID++;
}
+ OSReport("UNLOCKING PATHS: All complete @ %p\n", in);
+
// did anything become newly available?!
newlyAvailablePaths = 0;
newlyAvailableNodes = 0;
@@ -177,13 +193,17 @@ void dWMPathManager_c::unlockPaths() {
unlockingAlpha = -1;
}
-bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save) {
+bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack) {
+ OSReport("[%p] CondStk:%d begin\n", in, stack);
u8 controlByte = *(in++);
u8 conditionType = (controlByte >> 6);
+ OSReport("[%p] CondStk:%d control byte: %d; condition type: %d\n", in, stack, controlByte, conditionType);
- if (conditionType == 0)
+ if (conditionType == 0) {
+ OSReport("[%p] CondStk:%d end, returning CONSTANT 1\n", in, stack);
return true;
+ }
if (conditionType == 1) {
// Simple level
@@ -191,8 +211,10 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save) {
bool isSecret = (controlByte & 0x10);
u8 worldNumber = controlByte & 0xF;
u8 levelNumber = *(in++);
+ OSReport("[%p] CondStk:%d level, w:%d l:%d secret:%d\n", in, stack, worldNumber, levelNumber, isSecret);
u32 conds = save->GetLevelCondition(worldNumber, levelNumber);
+ OSReport("[%p] CondStk:%d returning for level conditions: %d / %x\n", in, stack, conds, conds);
if (isSecret)
return (conds & COND_SECRET) != 0;
@@ -207,9 +229,10 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save) {
bool value = isOr ? false : true;
u8 termCount = (controlByte & 0x3F) + 1;
+ OSReport("[%p] CondStk:%d and:%d or:%d startValue:%d termCount:%d\n", in, stack, isAnd, isOr, value, termCount);
for (int i = 0; i < termCount; i++) {
- bool what = evaluateUnlockCondition(in, save);
+ bool what = evaluateUnlockCondition(in, save, stack+1);
if (isOr)
value |= what;
@@ -217,6 +240,7 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save) {
value &= what;
}
+ OSReport("[%p] CondStk:%d end, returning %d\n", in, stack, value);
return value;
}
diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h
index f939427..e010aa4 100644
--- a/src/koopatlas/pathmanager.h
+++ b/src/koopatlas/pathmanager.h
@@ -48,7 +48,7 @@ class dWMPathManager_c {
private:
void unlockPaths();
- bool evaluateUnlockCondition(u8 *&in, SaveBlock *save);
+ bool evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack);
bool isEnteringLevel;
};