1 #ifndef __GNUC__
2 #pragma once
3 #endif
4 #ifndef __XR_AI_GRAPH_H__
5 #define __XR_AI_GRAPH_H__
6 
7 #include <string>
8 #include "xr_guid.h"
9 #include "xr_vector3.h"
10 
11 namespace xray_re {
12 
13 // on-disk structures (not used)
14 #pragma pack(push, 1)
15 struct gg_header_2215 {
16 	uint32_t	version;
17 	uint32_t	level_count;
18 	uint32_t	vertex_count;
19 	uint32_t	edge_count;
20 	uint32_t	death_point_count;
21 	xr_guid		guid;
22 };
23 
24 struct gg_header_2947 {
25 	uint8_t		version;
26 	uint16_t	vertex_count;
27 	uint32_t	edge_count;
28 	uint32_t	death_point_count;
29 	xr_guid		guid;
30 	uint8_t		level_count;
31 };
32 
33 struct gg_vertex_2215 {
34 	fvector3	local_point;
35 	fvector3	global_point;
36 	uint32_t	level_id:8;
37 	uint32_t	node_id:24;
38 	uint8_t		vertex_types[4];
39 	uint32_t	neighbour_count:8;
40 	uint32_t	edge_offset:24;
41 	uint32_t	death_point_count:8;
42 	uint32_t	point_offset:24;
43 };
44 
45 struct gg_vertex_2947 {
46 	fvector3	local_point;
47 	fvector3	global_point;
48 	uint32_t	level_id:8;
49 	uint32_t	node_id:24;
50 	uint8_t		vertex_types[4];
51 	uint32_t	edge_offset;
52 	uint32_t	point_offset;
53 	uint8_t		neighbour_count;
54 	uint8_t		death_point_count;
55 };
56 
57 struct gg_edge_2215 {
58 	uint32_t	vertex_id;
59 	float		distance;
60 };
61 
62 struct gg_edge_2947 {
63 	uint16_t	vertex_id;
64 	float		distance;
65 };
66 #pragma pack(pop)
67 
68 struct gg_level {
69 	std::string	name;
70 	std::string	section;
71 	fvector3	offset;
72 	unsigned	level_id;
73 	xr_guid		guid;
74 };
75 
76 struct gg_vertex {
77 	fvector3	local_point;
78 	fvector3	global_point;
79 	uint32_t	node_id;
80 	uint8_t		vertex_types[4];
81 	uint32_t	edge_index;
82 	uint32_t	point_index;
83 	uint8_t		neighbour_count;
84 	uint8_t		death_point_count;
85 	uint8_t		level_id;
86 	uint8_t		__pad;
87 };
88 
89 struct gg_edge {
90 	unsigned	vertex_id;
91 	float		distance;
92 };
93 
94 struct gg_level_point {
95 	fvector3	point;
96 	uint32_t	node_id;
97 	float		distance;
98 };
99 
100 class xr_reader;
101 class xr_writer;
102 
103 struct gg_level2215_io {
104 	void	operator()(gg_level& level, xr_reader& r) const;
105 	void	operator()(const gg_level& level, xr_writer& w) const;
106 };
107 
108 struct gg_level_io {
109 	void	operator()(gg_level& level, xr_reader& r) const;
110 	void	operator()(const gg_level& level, xr_writer& w) const;
111 };
112 
113 struct gg_vertex2215_io {
114 			gg_vertex2215_io(unsigned _edge_base, unsigned _death_point_base);
115 	void		operator()(gg_vertex& vert, xr_reader& r) const;
116 	void		operator()(const gg_vertex& vert, xr_writer& r) const;
117 	unsigned	edge_base;
118 	unsigned	death_point_base;
119 };
120 
121 struct gg_vertex_io: public gg_vertex2215_io {
122 		gg_vertex_io(unsigned _edge_base, unsigned _death_point_base);
123 	void	operator()(gg_vertex& vert, xr_reader& r) const;
124 	void	operator()(const gg_vertex& vert, xr_writer& r) const;
125 };
126 
127 struct gg_edge2215_io {
128 	void	operator()(gg_edge& edge, xr_reader& r) const;
129 	void	operator()(const gg_edge& edge, xr_writer& w) const;
130 };
131 
132 struct gg_edge_io {
133 	void	operator()(gg_edge& edge, xr_reader& r) const;
134 	void	operator()(const gg_edge& edge, xr_writer& w) const;
135 };
136 
137 struct gg_level_point_io {
138 	void	operator()(gg_level_point& point, xr_reader& r) const;
139 	void	operator()(const gg_level_point& point, xr_writer& w) const;
140 };
141 
gg_vertex2215_io(unsigned _edge_base,unsigned _death_point_base)142 inline gg_vertex2215_io::gg_vertex2215_io(unsigned _edge_base, unsigned _death_point_base):
143 	edge_base(_edge_base), death_point_base(_death_point_base) {}
144 
gg_vertex_io(unsigned _edge_base,unsigned _death_point_base)145 inline gg_vertex_io::gg_vertex_io(unsigned _edge_base, unsigned _death_point_base):
146 	gg_vertex2215_io(_edge_base, _death_point_base) {}
147 
148 } // end of namespace xray_re
149 
150 #endif
151