OpenTTD
yapf_type.hpp
Go to the documentation of this file.
1 /* $Id: yapf_type.hpp 27885 2017-06-22 16:57:06Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef YAPF_TYPE_HPP
13 #define YAPF_TYPE_HPP
14 
15 /* Enum used in PfCalcCost() to see why was the segment closed. */
17  /* The following reasons can be saved into cached segment */
27 
28  /* The following reasons are used only internally by PfCalcCost().
29  * They should not be found in the cached segment. */
34 
35  /* Special values */
36  ESR_NONE = 0xFF,
37 };
38 
39 enum EndSegmentReasonBits {
40  ESRB_NONE = 0,
41 
42  ESRB_DEAD_END = 1 << ESR_DEAD_END,
43  ESRB_RAIL_TYPE = 1 << ESR_RAIL_TYPE,
44  ESRB_INFINITE_LOOP = 1 << ESR_INFINITE_LOOP,
45  ESRB_SEGMENT_TOO_LONG = 1 << ESR_SEGMENT_TOO_LONG,
46  ESRB_CHOICE_FOLLOWS = 1 << ESR_CHOICE_FOLLOWS,
47  ESRB_DEPOT = 1 << ESR_DEPOT,
48  ESRB_WAYPOINT = 1 << ESR_WAYPOINT,
49  ESRB_STATION = 1 << ESR_STATION,
50  ESRB_SAFE_TILE = 1 << ESR_SAFE_TILE,
51 
52  ESRB_PATH_TOO_LONG = 1 << ESR_PATH_TOO_LONG,
53  ESRB_FIRST_TWO_WAY_RED = 1 << ESR_FIRST_TWO_WAY_RED,
54  ESRB_LOOK_AHEAD_END = 1 << ESR_LOOK_AHEAD_END,
55  ESRB_TARGET_REACHED = 1 << ESR_TARGET_REACHED,
56 
57  /* Additional (composite) values. */
58 
59  /* What reasons mean that the target can be found and needs to be detected. */
60  ESRB_POSSIBLE_TARGET = ESRB_DEPOT | ESRB_WAYPOINT | ESRB_STATION | ESRB_SAFE_TILE,
61 
62  /* What reasons can be stored back into cached segment. */
63  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,
64 
65  /* Reasons to abort pathfinding in this direction. */
66  ESRB_ABORT_PF_MASK = ESRB_DEAD_END | ESRB_PATH_TOO_LONG | ESRB_INFINITE_LOOP | ESRB_FIRST_TWO_WAY_RED,
67 };
68 
69 DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
70 
71 inline CStrA ValueStr(EndSegmentReasonBits bits)
72 {
73  static const char * const end_segment_reason_names[] = {
74  "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
75  "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
76  "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED"
77  };
78 
79  CStrA out;
80  out.Format("0x%04X (%s)", bits, ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE").Data());
81  return out.Transfer();
82 }
83 
84 #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:72
CStrA ValueStr(Trackdir td)
Return name of given Trackdir.
Definition: dbg_helpers.cpp:25
we have just passed the last look-ahead signal
Definition: yapf_type.hpp:32
station encountered (could be a target next time)
Definition: yapf_type.hpp:25
the next tile has a different rail type than our tiles
Definition: yapf_type.hpp:19
the path is too long (searching for the nearest depot in the given radius)
Definition: yapf_type.hpp:30
EndSegmentReason
Definition: yapf_type.hpp:16
we have just reached the destination
Definition: yapf_type.hpp:33
safe waiting position found (could be a target)
Definition: yapf_type.hpp:26
track ends here
Definition: yapf_type.hpp:18
infinite loop detected
Definition: yapf_type.hpp:20
no reason to end the segment here
Definition: yapf_type.hpp:36
Blob based case sensitive ANSI/UTF-8 string.
Definition: str.hpp:22
the segment is too long (possible infinite loop)
Definition: yapf_type.hpp:21
first signal was 2-way and it was red
Definition: yapf_type.hpp:31
waypoint encountered (could be a target next time)
Definition: yapf_type.hpp:24
stop in the depot (could be a target next time)
Definition: yapf_type.hpp:23
the next tile contains a choice (the track splits to more than one segments)
Definition: yapf_type.hpp:22