summaryrefslogtreecommitdiff
path: root/src/koopatlas/mapdata.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-07-25 19:01:07 +0200
committerTreeki <treeki@gmail.com>2012-07-25 19:01:07 +0200
commitc01d2d5df5c0bca7b8714f54e8efbd3456b1182e (patch)
tree32e300afd926ba181a8a0b1c5a2199d075e0e258 /src/koopatlas/mapdata.cpp
parentaea689a23e1390d62896ba96667631add5c33018 (diff)
parent6895c831ad320c14b01ccabe1c8adcec354e3f9f (diff)
downloadkamek-c01d2d5df5c0bca7b8714f54e8efbd3456b1182e.tar.gz
kamek-c01d2d5df5c0bca7b8714f54e8efbd3456b1182e.zip
Merge branch 'freeform-unlocks' into level-select
Diffstat (limited to 'src/koopatlas/mapdata.cpp')
-rw-r--r--src/koopatlas/mapdata.cpp51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp
index 9c84c4a..63fd0b7 100644
--- a/src/koopatlas/mapdata.cpp
+++ b/src/koopatlas/mapdata.cpp
@@ -2,17 +2,31 @@
// HELPER FUNCTIONS
-dKPPath_s *dKPNode_s::getOppositeExitTo(dKPPath_s *path) {
+dKPPath_s *dKPNode_s::getOppositeExitTo(dKPPath_s *path, bool mustBeAvailable) {
for (int i = 0; i < 4; i++) {
dKPPath_s *check = exits[i];
- if (check != 0 && check != path)
+ if (check != 0 && check != path) {
+ if (mustBeAvailable && !check->isAvailable)
+ continue;
+
return check;
+ }
}
return 0;
}
+int dKPNode_s::getExitCount(bool mustBeAvailable) {
+ int ct = 0;
+
+ for (int i = 0; i < 4; i++)
+ if (exits[i] && (mustBeAvailable ? exits[i]->isAvailable : true))
+ ct++;
+
+ return ct;
+}
+
bool dKPNode_s::isUnlocked() {
for (int i = 0; i < 4; i++)
if (exits[i])
@@ -89,6 +103,20 @@ void dKPNode_s::setupNodeExtra() {
this->extra->mallocator.unlink();
}
+void dKPNode_s::setLayerAlpha(u8 alpha) {
+ if (tileLayer)
+ tileLayer->alpha = alpha;
+ if (doodadLayer)
+ doodadLayer->alpha = alpha;
+}
+
+void dKPPath_s::setLayerAlpha(u8 alpha) {
+ if (tileLayer)
+ tileLayer->alpha = alpha;
+ if (doodadLayer)
+ doodadLayer->alpha = alpha;
+}
+
int dKPLayer_s::findNodeID(dKPNode_s *node) {
for (int i = 0; i < nodeCount; i++)
if (nodes[i] == node)
@@ -173,6 +201,7 @@ void dKPMapData_c::fixup() {
fixRef(data->layers);
fixRef(data->tilesets);
+ fixRef(data->unlockData);
for (int iLayer = 0; iLayer < data->layerCount; iLayer++) {
dKPLayer_s *layer = fixRef(data->layers[iLayer]);
@@ -227,24 +256,6 @@ void dKPMapData_c::fixup() {
// before we finish here, create the Node Extra classes
- // before the first off, do the unlocking.
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
- for (int i = 0; i < pathLayer->pathCount; i++) {
- dKPPath_s *path = pathLayer->paths[i];
-
- if (path->unlockType > 0) {
- u32 conds = save->GetLevelCondition(path->unlockLevelNumber[0] - 1, path->unlockLevelNumber[1] - 1);
-
- if (path->unlockType == 1 && (conds & COND_NORMAL))
- path->isAvailable = true;
- else if (path->unlockType == 2 && (conds & COND_SECRET))
- path->isAvailable = true;
- else
- path->isAvailable = false;
- }
- }
-
-
// first off, count how many we need...
int count = 0;
for (int nodeIdx = 0; nodeIdx < pathLayer->nodeCount; nodeIdx++) {