ScummVM API documentation
prim_route_builder.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * Additional copyright for this file:
8 * Copyright (C) 1999-2000 Revolution Software Ltd.
9 * This code is based on source code created by Revolution Software,
10 * used with permission.
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#ifndef ICB_PRIM_ROUTE_BUILDER_H
28#define ICB_PRIM_ROUTE_BUILDER_H
29
30#include "engines/icb/common/px_rcutypes.h"
31#include "engines/icb/common/px_route_barriers.h"
32#include "engines/icb/route_manager.h"
33
34namespace ICB {
35
36#define MAX_barriers 255 // Changed from 256 to 300, 'cos M08 was tipping it.
37
38#if MAX_barriers > 255
39
40#error "MAX_barriers must be less than 256, because of e.g. uint8 temp_route[MAX_final_route];"
41
42#endif
43
44enum _route_stat { __PRIM_ROUTE_OK, __PRIM_ROUTE_FAIL };
45
47
48 public:
49 void Reset_barrier_list();
50 void Add_barrier(RouteBarrier *new_barrier);
51
52 _route_stat Calc_route(PXreal startx, PXreal startz, PXreal endx, PXreal endz); // does extraping
53
54 void Give_route(_route_description *route); // copy the route to pass_to
55 void Give_barrier_list(_route_description *route); // copy the barriers - this is for the debug NETHACK diagnostics mode
56
57 uint32 final_points;
58 _point final_route[MAX_final_route]; // tempory place for final route - caller should copy out
59 PXreal final_len; // internal temp flag - here so we can print it
60
61 uint32 extrap_size; // denotes the length to extend barriers by
62
63 // Public so everyone can use this function
64 int32 Get_intersect(PXreal x0, PXreal y0, PXreal x1, PXreal y1, PXreal x2, PXreal y2, PXreal x3, PXreal y3);
65
66 // This is a wrapper function to make the Cohen-Sutherland line-intersection algorithm
67 // available to the router.
68 bool8 LineIntersectsRect(DXrect oRect, int32 nX1, int32 nY1, int32 nX2, int32 nY2) const;
69
70private:
71 _point barrier_list[MAX_barriers];
72
73 uint32 total_points; // points dervived from start and end of each barrier line
74
75 // Bit based arrays hence the add 7 and divide by 8 (+7 rounds up)
76 uint8 hitsBits[MAX_barriers][(MAX_barriers + 7) / 8];
77 uint8 gohitsBits[MAX_barriers][(MAX_barriers + 7) / 8];
78
79 // Jake : note this can only be uint8 if MAX_barriers < 256
80 uint8 temp_route[MAX_final_route];
81
82 // These could be bit arrays as well :
83 // but not much gain compared to hits & gohits
84 uint8 exclude[MAX_barriers];
85 uint8 temp_exclude[MAX_barriers];
86
87#if defined(PRIM_BYTE_ARRAYS) && PRIM_BYTE_ARRAYS
88 uint8 hits[MAX_barriers][MAX_barriers];
89 uint8 gohits[MAX_barriers][MAX_barriers];
90#endif
91
92 void Find_connects(uint32 point, PXreal cur_len, uint32 level);
93 uint32 ExtrapolateLine(_point *pSrc0, _point *pSrc1, _point *pDst0, _point *pDst1, int32 d);
94 PXfloat m_fabs(PXfloat val); // abs
95};
96
97} // End of namespace ICB
98
99#endif
Definition: prim_route_builder.h:46
Definition: route_manager.h:74
Definition: graphic_prims.h:47
Definition: px_types.h:32
Definition: px_route_barriers.h:146