summaryrefslogtreecommitdiff
path: root/src/koopatlas
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-02-22 00:26:49 +0100
committerTreeki <treeki@gmail.com>2013-02-22 00:26:49 +0100
commit92cab6b9d62e38d09a77fbcab798fc87de201f50 (patch)
tree07881673731694ac072fa8f767a2a1984566f217 /src/koopatlas
parent457a40644f0a492ed8acf8dbf66888bee9035100 (diff)
downloadkamek-92cab6b9d62e38d09a77fbcab798fc87de201f50.tar.gz
kamek-92cab6b9d62e38d09a77fbcab798fc87de201f50.zip
map paths can now be unlocked based on star coin amounts
Diffstat (limited to 'src/koopatlas')
-rw-r--r--src/koopatlas/pathmanager.cpp32
-rw-r--r--src/koopatlas/pathmanager.h2
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;