# yapf_type.hpp

Go to the documentation of this file.

    00001 /* $Id: yapf_type.hpp 25608 2013-07-14 09:20:34Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef YAPF_TYPE_HPP
    00013 #define YAPF_TYPE_HPP
    00014
    00015 /* Enum used in PfCalcCost() to see why was the segment closed. */
    00016 enum EndSegmentReason {
    00017   /* The following reasons can be saved into cached segment */
    00018   ESR_DEAD_END = 0,
    00019   ESR_RAIL_TYPE,
    00020   ESR_INFINITE_LOOP,
    00021   ESR_SEGMENT_TOO_LONG,
    00022   ESR_CHOICE_FOLLOWS,
    00023   ESR_DEPOT,
    00024   ESR_WAYPOINT,
    00025   ESR_STATION,
    00026   ESR_SAFE_TILE,
    00027
    00028   /* The following reasons are used only internally by PfCalcCost().
    00029    *  They should not be found in the cached segment. */
    00030   ESR_PATH_TOO_LONG,
    00031   ESR_FIRST_TWO_WAY_RED,
    00032   ESR_LOOK_AHEAD_END,
    00033   ESR_TARGET_REACHED,
    00034
    00035   /* Special values */
    00036   ESR_NONE = 0xFF,
    00037 };
    00038
    00039 enum EndSegmentReasonBits {
    00040   ESRB_NONE = 0,
    00041
    00042   ESRB_DEAD_END          = 1 << ESR_DEAD_END,
    00043   ESRB_RAIL_TYPE         = 1 << ESR_RAIL_TYPE,
    00044   ESRB_INFINITE_LOOP     = 1 << ESR_INFINITE_LOOP,
    00045   ESRB_SEGMENT_TOO_LONG  = 1 << ESR_SEGMENT_TOO_LONG,
    00046   ESRB_CHOICE_FOLLOWS    = 1 << ESR_CHOICE_FOLLOWS,
    00047   ESRB_DEPOT             = 1 << ESR_DEPOT,
    00048   ESRB_WAYPOINT          = 1 << ESR_WAYPOINT,
    00049   ESRB_STATION           = 1 << ESR_STATION,
    00050   ESRB_SAFE_TILE         = 1 << ESR_SAFE_TILE,
    00051
    00052   ESRB_PATH_TOO_LONG     = 1 << ESR_PATH_TOO_LONG,
    00053   ESRB_FIRST_TWO_WAY_RED = 1 << ESR_FIRST_TWO_WAY_RED,
    00054   ESRB_LOOK_AHEAD_END    = 1 << ESR_LOOK_AHEAD_END,
    00055   ESRB_TARGET_REACHED    = 1 << ESR_TARGET_REACHED,
    00056
    00057   /* Additional (composite) values. */
    00058
    00059   /* What reasons mean that the target can be found and needs to be detected. */
    00060   ESRB_POSSIBLE_TARGET = ESRB_DEPOT | ESRB_WAYPOINT | ESRB_STATION | ESRB_SAFE_TILE,
    00061
    00062   /* What reasons can be stored back into cached segment. */
    00063   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,
    00064
    00065   /* Reasons to abort pathfinding in this direction. */
    00066   ESRB_ABORT_PF_MASK = ESRB_DEAD_END | ESRB_PATH_TOO_LONG | ESRB_INFINITE_LOOP | ESRB_FIRST_TWO_WAY_RED,
    00067 };
    00068
    00069 DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
    00070
    00071 inline CStrA ValueStr(EndSegmentReasonBits bits)
    00072 {
    00073   static const char * const end_segment_reason_names[] = {
    00074     "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
    00075     "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
    00076     "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED"
    00077   };
    00078
    00079   CStrA out;
    00080   out.Format("0x%04X (%s)", bits, ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE").Data());
    00081   return out.Transfer();
    00082 }
    00083
    00084 #endif /* YAPF_TYPE_HPP */