#ifndef __NEWER_WORLDMAPDATA_H #define __NEWER_WORLDMAPDATA_H #include #include // Forward declarations struct WMPathPoint; struct WMPathAction; struct WMPathSegment; 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 WMPathHeader) // WorldMapData::load() fixes these offsets. /******************************************************************************/ // Definition for an entrance onto one side of a path // (TODO: Maybe rename this struct?) // Note: a null WMPathEntrance has no path defined // since the path pointer is stored as an index in the data file, the index for // a null path becomes -1 struct WMPathEntrance { WMPathDef *path; bool isEndSide; bool isValid() { return (this->path != 0); } }; /******************************************************************************/ // Definition for one point on the map struct WMPathPoint { enum PointType { NONE_TYPE, LEVEL_TYPE }; // Paths you arrive on when you press a direction when at this point union { struct { WMPathEntrance left; WMPathEntrance right; WMPathEntrance up; WMPathEntrance down; } asDirection; WMPathEntrance asArray[4]; } exits; // Point metadata PointType type; int params[4]; Vec position; }; /******************************************************************************/ // Definition for an action that can be triggered when the player reaches a // specific point struct WMPathAction { enum ActionType { TELEPORT_TYPE // teleports to another submap }; // Action metadata ActionType type; int params[4]; }; /******************************************************************************/ // Definition for one part of a path struct WMPathSegment { // Segment metadata Vec start; Vec end; float stepsPerFrame; int animationType; float animationSpeed; short direction; bool useLastDir; bool alwaysSameDir; // Optional Action that's triggered when the player touches this segment WMPathAction *action; }; /******************************************************************************/ // Definition for one path struct WMPathDef { // Path metadata WMPathPoint *startPoint; WMPathPoint *endPoint; u16 eventRequired; 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; } }; struct WMPathHeader { u32 magic; WMPathDef **pathList; int pathCount; WMPathPoint **pointList; int pointCount; WMPathSegment **segmentList; int segmentCount; // todo: remove action list? WMPathAction **actionList; int actionCount; }; class dWMPathData_c { private: WMPathHeader *data; public: 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