UFO: Alien Invasion
Loading...
Searching...
No Matches
routing.h
Go to the documentation of this file.
1
5
6/*
7All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9Copyright (C) 1997-2001 Id Software, Inc.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26*/
27
28#pragma once
29
30// Should be included here because it is used-in-the-interface, but breaks uforadiant compilation :(
31//#include "tracing.h"
32
33/*==============================================================
34GLOBAL TYPES
35==============================================================*/
36
37/* Decide whether we are doing uni- or bidirectional conclusions from our traces.
38 * This constant is used in both a boolean and an integer way,
39 * so it must only be set to 0 or 1 ! */
40#define RT_IS_BIDIRECTIONAL 0
41
42/*==============================================================
43MACROS
44==============================================================*/
49/* route - Used by Grid_* only */
51
52#define RT_CONN_PX(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 0))
53#define RT_CONN_NX(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 1))
54#define RT_CONN_PY(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 2))
55#define RT_CONN_NY(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 3))
56
57#define RT_CONN_PX_PY(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 4))
58#define RT_CONN_PX_NY(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 7))
59#define RT_CONN_NX_PY(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 6))
60#define RT_CONN_NX_NY(r, actorSize, x, y, z) (r.getConn(actorSize, x, y, z, 5))
61
62#define RT_STEPUP_PX(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 0))
63#define RT_STEPUP_NX(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 1))
64#define RT_STEPUP_PY(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 2))
65#define RT_STEPUP_NY(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 3))
66
67#define RT_STEPUP_PX_PY(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 4))
68#define RT_STEPUP_PX_NY(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 7))
69#define RT_STEPUP_NX_PY(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 6))
70#define RT_STEPUP_NX_NY(r, actorSize, x, y, z) (r.getStepup(actorSize, x, y, z, 5))
71
72
74/* Surfaces used as floors are rounded up. */
75#define ModelFloorToQuant(x) (ceil((x) / QUANT))
76/* Surfaces used as ceilings are rounded down. */
77#define ModelCeilingToQuant(x) (floor((x) / QUANT))
78/* Going from QUANT units back to model units returns the approximation of the QUANT unit. */
79#define QuantToModel(x) ((x) * QUANT)
80
84#define SizedPosToVec(p, actorSize, v) { \
85 assert(actorSize > ACTOR_SIZE_INVALID); \
86 assert(actorSize <= ACTOR_MAX_SIZE); \
87 v[0] = ((int)p[0] - 128) * UNIT_SIZE + (UNIT_SIZE * actorSize) / 2; \
88 v[1] = ((int)p[1] - 128) * UNIT_SIZE + (UNIT_SIZE * actorSize) / 2; \
89 v[2] = (int)p[2] * UNIT_HEIGHT + UNIT_HEIGHT / 2; \
90}
91
92
93/*
94===============================================================================
95SHARED EXTERNS (cmodel.c and ufo2map/routing.c)
96===============================================================================
97*/
98
99extern bool debugTrace;
100
101/*
102===============================================================================
103GAME RELATED TRACING
104===============================================================================
105*/
106
107
108int RT_CheckCell(mapTiles_t* mapTiles, Routing& routing, const int actorSize, const int x, const int y, const int z, const char** list);
109void RT_UpdateConnectionColumn(mapTiles_t* mapTiles, Routing& routing, const int actorSize, const int x, const int y, const int dir, const char** list = nullptr, const int minZ = 0, const int maxZ = PATHFINDING_HEIGHT);
110bool RT_AllCellsBelowAreFilled(const Routing& routing, const int actorSize, const pos3_t pos);
111void RT_GetMapSize(mapTiles_t* mapTiles, AABB& mapBox);
112bool RT_CanActorStandHere(const Routing& routing, const int actorSize, const pos3_t pos);
113
114
115/*
116==========================================================
117DEBUGGING CODE
118==========================================================
119*/
120
121#ifdef DEBUG
122void RT_DumpWholeMap(mapTiles_t* mapTiles, const Routing& routing);
123int RT_DebugSpecial(mapTiles_t* mapTiles, Routing& routing, const int actorSize, const int x, const int y, const int dir, const char** list);
124void RT_DebugPathDisplay (Routing& routing, const int actorSize, int x, int y, int z);
125#endif
126void RT_WriteCSVFiles(const Routing& routing, const char* baseFilename, const GridBox& box);
Definition aabb.h:42
bool debugTrace
Definition routing.cpp:38
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
Definition defines.h:294
void RT_GetMapSize(mapTiles_t *mapTiles, AABB &mapBox)
Calculate the map size via model data and store grid size in map_min and map_max. This is done with e...
Definition routing.cpp:253
bool RT_CanActorStandHere(const Routing &routing, const int actorSize, const pos3_t pos)
Check if an actor can stand(up) in the cell given by pos.
Definition routing.cpp:237
int RT_CheckCell(mapTiles_t *mapTiles, Routing &routing, const int actorSize, const int x, const int y, const int z, const char **list)
This function looks to see if an actor of a given size can occupy a cell(s) and if so identifies the ...
Definition routing.cpp:360
void RT_UpdateConnectionColumn(mapTiles_t *mapTiles, Routing &routing, const int actorSize, const int x, const int y, const int dir, const char **list=nullptr, const int minZ=0, const int maxZ=PATHFINDING_HEIGHT)
Routing Function to update the connection between two fields.
Definition routing.cpp:1292
void RT_WriteCSVFiles(const Routing &routing, const char *baseFilename, const GridBox &box)
Definition routing.cpp:1330
bool RT_AllCellsBelowAreFilled(const Routing &routing, const int actorSize, const pos3_t pos)
Check if pos is on solid ground.
Definition routing.cpp:331
static mapTiles_t mapTiles
char baseFilename[MAX_OSPATH]
Definition ufo2map.cpp:55
pos_t pos3_t[3]
Definition ufotypes.h:58