OpenTTD
yapf_type.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef YAPF_TYPE_HPP
11 #define YAPF_TYPE_HPP
12 
13 /* Enum used in PfCalcCost() to see why was the segment closed. */
15  /* The following reasons can be saved into cached segment */
25 
26  /* The following reasons are used only internally by PfCalcCost().
27  * They should not be found in the cached segment. */
32 
33  /* Special values */
34  ESR_NONE = 0xFF,
35 };
36 
37 enum EndSegmentReasonBits {
38  ESRB_NONE = 0,
39 
40  ESRB_DEAD_END = 1 << ESR_DEAD_END,
41  ESRB_RAIL_TYPE = 1 << ESR_RAIL_TYPE,
42  ESRB_INFINITE_LOOP = 1 << ESR_INFINITE_LOOP,
43  ESRB_SEGMENT_TOO_LONG = 1 << ESR_SEGMENT_TOO_LONG,
44  ESRB_CHOICE_FOLLOWS = 1 << ESR_CHOICE_FOLLOWS,
45  ESRB_DEPOT = 1 << ESR_DEPOT,
46  ESRB_WAYPOINT = 1 << ESR_WAYPOINT,
47  ESRB_STATION = 1 << ESR_STATION,
48  ESRB_SAFE_TILE = 1 << ESR_SAFE_TILE,
49 
50  ESRB_PATH_TOO_LONG = 1 << ESR_PATH_TOO_LONG,
51  ESRB_FIRST_TWO_WAY_RED = 1 << ESR_FIRST_TWO_WAY_RED,
52  ESRB_LOOK_AHEAD_END = 1 << ESR_LOOK_AHEAD_END,
53  ESRB_TARGET_REACHED = 1 << ESR_TARGET_REACHED,
54 
55  /* Additional (composite) values. */
56 
57  /* What reasons mean that the target can be found and needs to be detected. */
58  ESRB_POSSIBLE_TARGET = ESRB_DEPOT | ESRB_WAYPOINT | ESRB_STATION | ESRB_SAFE_TILE,
59 
60  /* What reasons can be stored back into cached segment. */
61  ESRB_CACHED_MASK = ESRB_DEAD_END | ESRB_RAIL_TYPE | ESRB_INFINITE_LOOP | ESRB_SEGMENT_TOO_LONG | ESRB_CHOICE_FOLLOWS | ESRB_DEPOT | ESRB_WAYPOINT | ESRB_STATION | ESRB_SAFE_TILE,
62 
63  /* Reasons to abort pathfinding in this direction. */
64  ESRB_ABORT_PF_MASK = ESRB_DEAD_END | ESRB_PATH_TOO_LONG | ESRB_INFINITE_LOOP | ESRB_FIRST_TWO_WAY_RED,
65 };
66 
67 DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
68 
69 inline CStrA ValueStr(EndSegmentReasonBits bits)
70 {
71  static const char * const end_segment_reason_names[] = {
72  "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
73  "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
74  "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED"
75  };
76 
77  CStrA out;
78  out.Format("0x%04X (%s)", bits, ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE").Data());
79  return out.Transfer();
80 }
81 
82 #endif /* YAPF_TYPE_HPP */
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
CStrA ComposeNameT(E value, T &t, const char *t_unk, E val_inv, const char *name_inv)
Helper template function that returns compound bitfield name that is concatenation of names of each s...
Definition: dbg_helpers.h:70
CStrA ValueStr(Trackdir td)
Return name of given Trackdir.
Definition: dbg_helpers.cpp:23
we have just passed the last look-ahead signal
Definition: yapf_type.hpp:30
station encountered (could be a target next time)
Definition: yapf_type.hpp:23
the next tile has a different rail type than our tiles
Definition: yapf_type.hpp:17
the path is too long (searching for the nearest depot in the given radius)
Definition: yapf_type.hpp:28
EndSegmentReason
Definition: yapf_type.hpp:14
we have just reached the destination
Definition: yapf_type.hpp:31
safe waiting position found (could be a target)
Definition: yapf_type.hpp:24
track ends here
Definition: yapf_type.hpp:16
infinite loop detected
Definition: yapf_type.hpp:18
no reason to end the segment here
Definition: yapf_type.hpp:34
Blob based case sensitive ANSI/UTF-8 string.
Definition: str.hpp:20
the segment is too long (possible infinite loop)
Definition: yapf_type.hpp:19
first signal was 2-way and it was red
Definition: yapf_type.hpp:29
waypoint encountered (could be a target next time)
Definition: yapf_type.hpp:22
stop in the depot (could be a target next time)
Definition: yapf_type.hpp:21
the next tile contains a choice (the track splits to more than one segments)
Definition: yapf_type.hpp:20