-
Notifications
You must be signed in to change notification settings - Fork 6
/
navdata.h
100 lines (96 loc) · 2.99 KB
/
navdata.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/************************************************************************
* Copyright (c) 2005-2007 [email protected] *
* *
* This file contains code derived from information copyrighted by *
* DMA Design. It may not be used in a commercial product. *
* *
* See license.txt for details. *
* *
* This notice may not be removed or altered. *
************************************************************************/
#ifndef NAVDATA_H
#define NAVDATA_H
#include <map>
#include <string>
#include <physfs.h>
namespace OpenGTA {
/** Helper class for area names.
*
* A simple box; beware uint8 overflow!
*
* @see NavData
*/
struct Rect2D {
public:
/** Zero-constructor.
* Everything is 0
*/
Rect2D();
/** Constructor with full params.
* @param x
* @param y
* @param w
* @param h
*/
Rect2D(PHYSFS_uint8, PHYSFS_uint8, PHYSFS_uint8, PHYSFS_uint8);
/** Test: point-in-box.
* @param x
* @param y
* @note If the point is inside 'lastSubLocation' is updated before returning.
*/
bool isInside(PHYSFS_uint8, PHYSFS_uint8);
/** Calculate north/south/east/west/central of point (which has to be inside).
* @param x
* @param y
* @return uint8 bitfield
*/
PHYSFS_uint8 subLocation(PHYSFS_uint8, PHYSFS_uint8);
PHYSFS_uint16 getSize();
PHYSFS_uint8 x, y;
PHYSFS_uint8 w, h;
/** Last sub-area location.
* 0 = central
* 1 = north
* 2 = south
* 4 = east
* 8 = west
* ... valid combinations of the last four
*/
PHYSFS_uint8 lastSubLocation;
};
/** Container of all named sectors.
* @see Sector
*/
class NavData {
public:
/** A named sector of the map.
*/
struct Sector : public Rect2D {
/** Constructor from valid PHYSFS handle.
*/
Sector(PHYSFS_file*);
Sector();
/** Sample number.
* 1) see $LANGUAGE.FXT file for actual name
* 2) probably sound?
*/
PHYSFS_uint8 sam; // sample number
//char name2[30]; // FIXME: should not be used
std::string name;
/** Returns the name prefixed with sub-area location.
*/
const char* getFullName();
private:
bool isADummy;
};
NavData(PHYSFS_uint32 size, PHYSFS_file *fd, const size_t level_num);
~NavData();
Sector* getSectorAt(PHYSFS_uint8, PHYSFS_uint8);
static std::string _c, _n, _s, _w, _e, _nw, _ne, _sw, _se;
private:
void clear();
typedef std::multimap<PHYSFS_uint16, Sector*> SectorMapType;
SectorMapType areas;
};
}
#endif