diff options
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 47e1d16..0f0ff6a 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -205,6 +205,9 @@ void dWMPathManager_c::unlockPaths() { SaveBlock *save = GetSaveFile()->GetBlock(-1); + cachedTotalStarCoinCount = getStarCoinCount(); + cachedUnspentStarCoinCount = cachedTotalStarCoinCount - save->spentStarCoins; + u8 *in = (u8*)dScKoopatlas_c::instance->mapData.data->unlockData; SpammyReport("UNLOCKING PATHS: Unlock data @ %p\n", in); @@ -306,8 +309,33 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save, int sta UnlockCmdReport("[%p] CondStk:%d control byte: %d; condition type: %d\n", in, stack, controlByte, conditionType); if (conditionType == 0) { - UnlockCmdReport("[%p] CondStk:%d end, returning CONSTANT 1\n", in, stack); - return true; + u8 subConditionType = controlByte & 0x3F; + switch (subConditionType) { + case 0: case 1: case 2: case 3: + u8 one = *(in++); + u8 two = *(in++); + + int compareOne = (one & 0x80) ? cachedUnspentStarCoinCount : cachedTotalStarCoinCount; + int compareTwo = ((one & 0x7F) << 8) | two; + + switch (subConditionType) { + case 0: + return compareOne == compareTwo; + case 1: + return compareOne != compareTwo; + case 2: + return compareOne < compareTwo; + case 3: + return compareOne > compareTwo; + } + + case 15: + UnlockCmdReport("[%p] CondStk:%d end, returning CONSTANT 1\n", in, stack); + return true; + default: + UnlockCmdReport("[%p] CondStk:%d unknown subCondition %d, returning 0\n", in, stack, subConditionType); + return false; + } } if (conditionType == 1) { |