diff options
author | Treeki <treeki@gmail.com> | 2011-06-17 04:10:28 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-06-17 04:10:28 +0200 |
commit | e74f7b687c4d4196979933d73aaf54747fd0de85 (patch) | |
tree | 6feffcf304c814c8d242cf36ae715f2ae27d1917 /src | |
parent | 1a0290bfce4c9aa473abc9d143c308170988c402 (diff) | |
download | kamek-e74f7b687c4d4196979933d73aaf54747fd0de85.tar.gz kamek-e74f7b687c4d4196979933d73aaf54747fd0de85.zip |
guess what? PATHS
Diffstat (limited to '')
-rw-r--r-- | src/wm_map.cpp | 3 | ||||
-rw-r--r-- | src/wm_path_manager.cpp | 47 | ||||
-rw-r--r-- | src/worldmap.cpp | 1 | ||||
-rw-r--r-- | src/worldmap.h | 30 | ||||
-rw-r--r-- | src/worldmapdata.cpp | 7 | ||||
-rw-r--r-- | src/worldmapdata.h | 9 |
6 files changed, 94 insertions, 3 deletions
diff --git a/src/wm_map.cpp b/src/wm_map.cpp index 1fa4065..73ae1c8 100644 --- a/src/wm_map.cpp +++ b/src/wm_map.cpp @@ -48,6 +48,9 @@ int dWMMap_c::onCreate() { SpammyReport("Unlinking allocator\n"); allocator.unlink(); + SpammyReport("Loading paths\n"); + dWMPathManager_c::instance->setInitialPathVisibility(); + SpammyReport("dWMMap_c::onCreate() completed\n"); return true; } diff --git a/src/wm_path_manager.cpp b/src/wm_path_manager.cpp index d94e5be..03c11d4 100644 --- a/src/wm_path_manager.cpp +++ b/src/wm_path_manager.cpp @@ -209,3 +209,50 @@ void dWMPathManager_c::setup() { } + + +void dWMPathManager_c::setInitialPathVisibility() { + for (int i = 0; i < pathData.pathCount(); i++) { + WMPathDef *path = pathData.getPath(i); + + char **materials = path->getMaterialArray(); + u8 alphaToUse = 255; + if (path->eventRequired != 0xFFFF) { + if (!events[path->eventRequired]) + alphaToUse = 128; + } + + for (int j = 0; j < path->materialCount; j++) { + // TODO: fix this + dWMMap_c::instance->nodes[0].updateAlpha(materials[j], alphaToUse); + } + } +} + + + +void dWMPathManager_c::computeEvents() { + for (int i = 0; i < EVENT_COUNT; i++) + events[i] = false; + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + // loop through every point, and apply the event from it if necessary + for (int i = 0; i < pathData.pointCount(); i++) { + WMPathPoint *point = pathData.getPoint(i); + + if (point->type == WMPathPoint::LEVEL_TYPE) { + // TODO: check if the world/level need to be -1 or not + u32 conds = save->GetLevelCondition(point->params[0], point->params[1]); + + if (conds & COND_NORMAL && point->params[2] != -1) + events[point->params[2]] = true; + if (conds & COND_SECRET && point->params[3] != -1) + events[point->params[3]] = true; + + OSReport("checking level %d-%d with events %d,%d set them to %d,%d\n", point->params[0], point->params[1], point->params[2], point->params[3], events[point->params[2]], events[point->params[3]]); + } + } +} + + diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 288d2bb..50e82c7 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -175,6 +175,7 @@ bool WMInit_SetupExtra(void *ptr) { // since we've got all the resources, set up the path data too
wm->pathManager->setup();
+ wm->pathManager->computeEvents();
// and now Player setup
wm->player = (daWMPlayer_c*)CreateParentedObject(WM_PLAYER, wm, 0, 2);
diff --git a/src/worldmap.h b/src/worldmap.h index ef08b99..b356bac 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -14,6 +14,8 @@ #define WM_DEBUGGING
//#define WM_SPAMMY_DEBUGGING
+#include <m_dynarray.h>
+
#include <common.h>
#include <game.h>
#include <g3dhax.h>
@@ -70,6 +72,9 @@ class dWMHud_c : public dBase_c { };
+
+#define EVENT_COUNT 512
+
class dWMPathManager_c : public dBase_c {
public:
dWMPathManager_c();
@@ -81,6 +86,25 @@ class dWMPathManager_c : public dBase_c { dWMPathData_c pathData;
+ /* Paths */
+ struct pathFadeInfo {
+ char *materialName;
+ u16 currentAlpha;
+ u16 framesRemaining;
+ int delta;
+ };
+
+ mDynArray_c<pathFadeInfo *,32> fadingPaths;
+
+ void setInitialPathVisibility();
+
+ /* Event Data - 512 events should be more than enough for everyone */
+ mDynArray_c<u16,32> newlyActivatedEvents;
+ bool events[EVENT_COUNT];
+
+ void computeEvents();
+
+ /* Movement Data/Methods */
bool isMoving;
WMPathPoint *currentPoint;
WMPathPoint *nextPoint;
@@ -90,15 +114,17 @@ class dWMPathManager_c : public dBase_c { int currentSegmentID;
bool reverseThroughPath; // direction we are going through the path
- void setup();
-
void startMovementTo(WMDirection direction);
void moveToSegment(int id);
void moveThroughPath();
+ /* Other Methods */
+ void setup();
+
void activatePoint();
+ /* Process Housekeeping */
static dWMPathManager_c *build();
static dWMPathManager_c *instance;
};
diff --git a/src/worldmapdata.cpp b/src/worldmapdata.cpp index 2f23afc..a8e0cf9 100644 --- a/src/worldmapdata.cpp +++ b/src/worldmapdata.cpp @@ -48,6 +48,13 @@ bool dWMPathData_c::load(void *data) { for (int j = 0; j < thisPath->segCount; j++) { thisPath->segments[j] = header->segmentList[(u32)thisPath->segments[j]]; } + + MapReport("Path @ %p\n", thisPath); + char **materialArray = thisPath->getMaterialArray(); + MapReport("Material Array @ %p, Count is %d\n", materialArray, thisPath->materialCount); + for (int j = 0; j < thisPath->materialCount; j++) { + materialArray[j] = (char*)((u32)materialArray[j] + ptr); + } } MapReport("Fixing up point pointers [%d]\n", header->pointCount); diff --git a/src/worldmapdata.h b/src/worldmapdata.h index a436114..71071f0 100644 --- a/src/worldmapdata.h +++ b/src/worldmapdata.h @@ -102,8 +102,15 @@ struct WMPathDef { WMPathPoint *endPoint; u16 eventRequired; - u16 segCount; + u8 segCount; + u8 materialCount; WMPathSegment *segments[1]; // variable-length array + + char **getMaterialArray() { + u8 *ptr = (u8*)(this + 1); + ptr += sizeof(segments[0]) * (segCount - 1); + return (char **)ptr; + } }; |