diff options
Diffstat (limited to '')
-rw-r--r-- | src/worldmapdata.h | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/worldmapdata.h b/src/worldmapdata.h index 1d6a305..16322b0 100644 --- a/src/worldmapdata.h +++ b/src/worldmapdata.h @@ -1,7 +1,7 @@ #ifndef __NEWER_WORLDMAPDATA_H #define __NEWER_WORLDMAPDATA_H -#include "fileload.h" +#include <common.h> #include <rvl/mtx.h> // Forward declarations @@ -12,7 +12,7 @@ struct WMPathDef; // here's a note: while most of these structs contain pointers to other structs, // in the data file these fields actually contain an index into the lists -// (defined in WMDataHeader) +// (defined in WMPathHeader) // WorldMapData::load() fixes these offsets. /******************************************************************************/ @@ -26,7 +26,7 @@ struct WMPathDef; struct WMPathEntrance { WMPathDef *path; bool isEndSide; - + bool isValid() { return (this->path != 0); } }; @@ -39,7 +39,7 @@ struct WMPathPoint { NONE_TYPE, LEVEL_TYPE }; - + // Paths you arrive on when you press a direction when at this point union { struct { @@ -50,11 +50,11 @@ struct WMPathPoint { } asDirection; WMPathEntrance asArray[4]; } exits; - + // Point metadata PointType type; int params[4]; - + Vec position; }; @@ -67,7 +67,7 @@ struct WMPathAction { enum ActionType { TELEPORT_TYPE // teleports to another submap }; - + // Action metadata ActionType type; int params[4]; @@ -87,7 +87,7 @@ struct WMPathSegment { short direction; bool useLastDir; bool alwaysSameDir; - + // Optional Action that's triggered when the player touches this segment WMPathAction *action; }; @@ -100,7 +100,7 @@ struct WMPathDef { // Path metadata WMPathPoint *startPoint; WMPathPoint *endPoint; - + int segCount; WMPathSegment *segments[1]; // variable-length array }; @@ -108,15 +108,15 @@ struct WMPathDef { -struct WMDataHeader { +struct WMPathHeader { u32 magic; - + WMPathDef **pathList; int pathCount; - + WMPathPoint **pointList; int pointCount; - + WMPathSegment **segmentList; int segmentCount; @@ -126,24 +126,26 @@ struct WMDataHeader { }; -class WorldMapData { +class dWMPathData_c { +private: + WMPathHeader *data; + public: - WorldMapData(); - ~WorldMapData(); - - bool load(const char *filename); - - FileHandle fh; - - int getPathCount() { - return ((WMDataHeader*)fh.filePtr)->pathCount; - } - - WMPathDef *getPath(int idx) { - return ((WMDataHeader*)fh.filePtr)->pathList[idx]; - } - + dWMPathData_c(); + ~dWMPathData_c(); + + bool load(void *data); + + int pathCount() { return data->pathCount; } + int pointCount() { return data->pointCount; } + int segmentCount() { return data->segmentCount; } + + WMPathDef *getPath(int idx) { return data->pathList[idx]; } + WMPathPoint *getPoint(int idx) { return data->pointList[idx]; } + WMPathSegment *getSegment(int idx) { return data->segmentList[idx]; } + int getPointID(WMPathPoint *point); }; #endif // __NEWER_WORLDMAPDATA_H + |