diff options
author | Treeki <treeki@gmail.com> | 2013-02-22 00:26:49 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2013-02-22 00:26:49 +0100 |
commit | 92cab6b9d62e38d09a77fbcab798fc87de201f50 (patch) | |
tree | 07881673731694ac072fa8f767a2a1984566f217 /src | |
parent | 457a40644f0a492ed8acf8dbf66888bee9035100 (diff) | |
download | kamek-92cab6b9d62e38d09a77fbcab798fc87de201f50.tar.gz kamek-92cab6b9d62e38d09a77fbcab798fc87de201f50.zip |
map paths can now be unlocked based on star coin amounts
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 32 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.h | 2 |
2 files changed, 32 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) { diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h index 8f04e34..9119235 100644 --- a/src/koopatlas/pathmanager.h +++ b/src/koopatlas/pathmanager.h @@ -65,6 +65,8 @@ class dWMPathManager_c { private: void unlockPaths(); bool evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack); + int cachedTotalStarCoinCount; + int cachedUnspentStarCoinCount; public: bool shouldRequestSave; |