summaryrefslogtreecommitdiff
path: root/src/worldmapdata.h
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-12 23:17:12 +0100
committerTreeki <treeki@gmail.com>2011-03-12 23:17:12 +0100
commit7d4e4c0b34a613dd3c0220475ae4e448197522c1 (patch)
tree4f5cee367de3fdef4f9a7c84af59ffe76a2bb1c3 /src/worldmapdata.h
downloadkamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.tar.gz
kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.zip
initial commit. now I can start playing with stuff!
Diffstat (limited to 'src/worldmapdata.h')
-rw-r--r--src/worldmapdata.h149
1 files changed, 149 insertions, 0 deletions
diff --git a/src/worldmapdata.h b/src/worldmapdata.h
new file mode 100644
index 0000000..1d6a305
--- /dev/null
+++ b/src/worldmapdata.h
@@ -0,0 +1,149 @@
+#ifndef __NEWER_WORLDMAPDATA_H
+#define __NEWER_WORLDMAPDATA_H
+
+#include "fileload.h"
+#include <rvl/mtx.h>
+
+// 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 WMDataHeader)
+// 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;
+
+ int segCount;
+ WMPathSegment *segments[1]; // variable-length array
+};
+
+
+
+
+struct WMDataHeader {
+ u32 magic;
+
+ WMPathDef **pathList;
+ int pathCount;
+
+ WMPathPoint **pointList;
+ int pointCount;
+
+ WMPathSegment **segmentList;
+ int segmentCount;
+
+ // todo: remove action list?
+ WMPathAction **actionList;
+ int actionCount;
+};
+
+
+class WorldMapData {
+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];
+ }
+
+ int getPointID(WMPathPoint *point);
+};
+
+#endif // __NEWER_WORLDMAPDATA_H