author | KUDr |
Fri, 29 Jun 2007 23:45:13 +0000 | |
changeset 7119 | afb9000a598e |
parent 7084 | 3a9673715c50 |
child 7120 | 8cb5c92f23a8 |
permissions | -rw-r--r-- |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
1 |
/* $Id$ */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
2 |
|
6121
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5475
diff
changeset
|
3 |
/** @file yapf_node_rail.hpp */ |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5475
diff
changeset
|
4 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
5 |
#ifndef YAPF_NODE_RAIL_HPP |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
6 |
#define YAPF_NODE_RAIL_HPP |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
7 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
8 |
/** key for cached segment cost for rail YAPF */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
9 |
struct CYapfRailSegmentKey |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
10 |
{ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
11 |
uint32 m_value; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
12 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
13 |
FORCEINLINE CYapfRailSegmentKey(const CYapfRailSegmentKey& src) : m_value(src.m_value) {} |
7084
3a9673715c50
(svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents:
7037
diff
changeset
|
14 |
FORCEINLINE CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key) {Set(node_key);} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
15 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
16 |
FORCEINLINE void Set(const CYapfRailSegmentKey& src) {m_value = src.m_value;} |
7084
3a9673715c50
(svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents:
7037
diff
changeset
|
17 |
FORCEINLINE void Set(const CYapfNodeKeyTrackDir& node_key) {m_value = (((int)node_key.m_tile) << 3) | node_key.m_td;} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
18 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
19 |
FORCEINLINE int32 CalcHash() const {return m_value;} |
7084
3a9673715c50
(svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents:
7037
diff
changeset
|
20 |
FORCEINLINE TileIndex GetTile() const {return (TileIndex)(m_value >> 3);} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
21 |
FORCEINLINE bool operator == (const CYapfRailSegmentKey& other) const {return m_value == other.m_value;} |
7119
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
22 |
|
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
23 |
void Dump(DumpTarget &dmp) const |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
24 |
{ |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
25 |
dmp.WriteTile("tile", GetTile()); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
26 |
dmp.WriteEnumT("td", GetTrackdir()); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
27 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
28 |
}; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
29 |
|
7037
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
30 |
/* Enum used in PfCalcCost() to see why was the segment closed. */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
31 |
enum EndSegmentReason { |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
32 |
/* The following reasons can be saved into cached segment */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
33 |
ESR_DEAD_END = 0, ///< track ends here |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
34 |
ESR_RAIL_TYPE, ///< the next tile has a different rail type than our tiles |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
35 |
ESR_INFINITE_LOOP, ///< infinite loop detected |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
36 |
ESR_SEGMENT_TOO_LONG, ///< the segment is too long (possible infinite loop) |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
37 |
ESR_CHOICE_FOLLOWS, ///< the next tile contains a choice (the track splits to more than one segments) |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
38 |
ESR_DEPOT, ///< stop in the depot (could be a target next time) |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
39 |
ESR_WAYPOINT, ///< waypoint encountered (could be a target next time) |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
40 |
ESR_STATION, ///< station encountered (could be a target next time) |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
41 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
42 |
/* The following reasons are used only internally by PfCalcCost(). |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
43 |
* They should not be found in the cached segment. */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
44 |
ESR_PATH_TOO_LONG, ///< the path is too long (searching for the nearest depot in the given radius) |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
45 |
ESR_FIRST_TWO_WAY_RED, ///< first signal was 2-way and it was red |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
46 |
ESR_LOOK_AHEAD_END, ///< we have just passed the last look-ahead signal |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
47 |
ESR_TARGET_REACHED, ///< we have just reached the destination |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
48 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
49 |
/* Special values */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
50 |
ESR_NONE = 0xFF, ///< no reason to end the segment here |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
51 |
}; |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
52 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
53 |
enum EndSegmentReasonBits { |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
54 |
ESRB_NONE = 0, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
55 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
56 |
ESRB_DEAD_END = 1 << ESR_DEAD_END, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
57 |
ESRB_RAIL_TYPE = 1 << ESR_RAIL_TYPE, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
58 |
ESRB_INFINITE_LOOP = 1 << ESR_INFINITE_LOOP, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
59 |
ESRB_SEGMENT_TOO_LONG = 1 << ESR_SEGMENT_TOO_LONG, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
60 |
ESRB_CHOICE_FOLLOWS = 1 << ESR_CHOICE_FOLLOWS, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
61 |
ESRB_DEPOT = 1 << ESR_DEPOT, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
62 |
ESRB_WAYPOINT = 1 << ESR_WAYPOINT, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
63 |
ESRB_STATION = 1 << ESR_STATION, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
64 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
65 |
ESRB_PATH_TOO_LONG = 1 << ESR_PATH_TOO_LONG, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
66 |
ESRB_FIRST_TWO_WAY_RED = 1 << ESR_FIRST_TWO_WAY_RED, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
67 |
ESRB_LOOK_AHEAD_END = 1 << ESR_LOOK_AHEAD_END, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
68 |
ESRB_TARGET_REACHED = 1 << ESR_TARGET_REACHED, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
69 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
70 |
/* Additional (composite) values. */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
71 |
|
7119
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
72 |
/* What reasons mean that the target can be found and needs to be detected. */ |
7037
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
73 |
ESRB_POSSIBLE_TARGET = ESRB_DEPOT | ESRB_WAYPOINT | ESRB_STATION, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
74 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
75 |
/* What reasons can be stored back into cached segment. */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
76 |
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, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
77 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
78 |
/* Reasons to abort pathfinding in this direction. */ |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
79 |
ESRB_ABORT_PF_MASK = ESRB_DEAD_END | ESRB_PATH_TOO_LONG | ESRB_INFINITE_LOOP | ESRB_FIRST_TWO_WAY_RED, |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
80 |
}; |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
81 |
|
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
82 |
DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits); |
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
83 |
|
7119
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
84 |
inline CStrA ValueStr(EndSegmentReasonBits bits) |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
85 |
{ |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
86 |
static const char* end_segment_reason_names[] = { |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
87 |
"DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS", |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
88 |
"DEPOT", "WAYPOINT", "STATION", |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
89 |
"PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED" |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
90 |
}; |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
91 |
|
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
92 |
CStrA out; |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
93 |
out.Format("0x%04X (%s)", bits, ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE").Data()); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
94 |
return out.Transfer(); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
95 |
} |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
96 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
97 |
/** cached segment cost for rail YAPF */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
98 |
struct CYapfRailSegment |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
99 |
{ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
100 |
typedef CYapfRailSegmentKey Key; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
101 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
102 |
CYapfRailSegmentKey m_key; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
103 |
TileIndex m_last_tile; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
104 |
Trackdir m_last_td; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
105 |
int m_cost; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
106 |
TileIndex m_last_signal_tile; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
107 |
Trackdir m_last_signal_td; |
7037
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
108 |
EndSegmentReasonBits m_end_segment_reason; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
109 |
CYapfRailSegment* m_hash_next; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
110 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
111 |
FORCEINLINE CYapfRailSegment(const CYapfRailSegmentKey& key) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
112 |
: m_key(key) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
113 |
, m_last_tile(INVALID_TILE) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
114 |
, m_last_td(INVALID_TRACKDIR) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
115 |
, m_cost(-1) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
116 |
, m_last_signal_tile(INVALID_TILE) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
117 |
, m_last_signal_td(INVALID_TRACKDIR) |
7037
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
118 |
, m_end_segment_reason(ESRB_NONE) |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
119 |
, m_hash_next(NULL) |
7037
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6121
diff
changeset
|
120 |
{} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
121 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
122 |
FORCEINLINE const Key& GetKey() const {return m_key;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
123 |
FORCEINLINE TileIndex GetTile() const {return m_key.GetTile();} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
124 |
FORCEINLINE CYapfRailSegment* GetHashNext() {return m_hash_next;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
125 |
FORCEINLINE void SetHashNext(CYapfRailSegment* next) {m_hash_next = next;} |
7119
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
126 |
|
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
127 |
void Dump(DumpTarget &dmp) const |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
128 |
{ |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
129 |
dmp.WriteStructT("m_key", &m_key); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
130 |
dmp.WriteTile("m_last_tile", m_last_tile); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
131 |
dmp.WriteEnumT("m_last_td", m_last_td); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
132 |
dmp.WriteLine("m_cost = %d", m_cost); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
133 |
dmp.WriteTile("m_last_signal_tile", m_last_signal_tile); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
134 |
dmp.WriteEnumT("m_last_signal_td", m_last_signal_td); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
135 |
dmp.WriteEnumT("m_end_segment_reason", m_end_segment_reason); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
136 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
137 |
}; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
138 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
139 |
/** Yapf Node for rail YAPF */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
140 |
template <class Tkey_> |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
141 |
struct CYapfRailNodeT |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
142 |
: CYapfNodeT<Tkey_, CYapfRailNodeT<Tkey_> > |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
143 |
{ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
144 |
typedef CYapfNodeT<Tkey_, CYapfRailNodeT<Tkey_> > base; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
145 |
typedef CYapfRailSegment CachedData; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
146 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
147 |
CYapfRailSegment *m_segment; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
148 |
uint16 m_num_signals_passed; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
149 |
union { |
3978
30b43c605f21
(svn r5162) - CodeChange: [YAPF] added flag "choice seen" into YAPF node for trains
KUDr
parents:
3900
diff
changeset
|
150 |
uint32 m_inherited_flags; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
151 |
struct { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
152 |
bool m_targed_seen : 1; |
3978
30b43c605f21
(svn r5162) - CodeChange: [YAPF] added flag "choice seen" into YAPF node for trains
KUDr
parents:
3900
diff
changeset
|
153 |
bool m_choice_seen : 1; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
154 |
bool m_last_signal_was_red : 1; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
155 |
} flags_s; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
156 |
} flags_u; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
157 |
SignalType m_last_red_signal_type; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
158 |
|
3978
30b43c605f21
(svn r5162) - CodeChange: [YAPF] added flag "choice seen" into YAPF node for trains
KUDr
parents:
3900
diff
changeset
|
159 |
FORCEINLINE void Set(CYapfRailNodeT* parent, TileIndex tile, Trackdir td, bool is_choice) |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
160 |
{ |
3978
30b43c605f21
(svn r5162) - CodeChange: [YAPF] added flag "choice seen" into YAPF node for trains
KUDr
parents:
3900
diff
changeset
|
161 |
base::Set(parent, tile, td, is_choice); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
162 |
m_segment = NULL; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
163 |
if (parent == NULL) { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
164 |
m_num_signals_passed = 0; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
165 |
flags_u.m_inherited_flags = 0; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
166 |
m_last_red_signal_type = SIGTYPE_NORMAL; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
167 |
} else { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
168 |
m_num_signals_passed = parent->m_num_signals_passed; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
169 |
flags_u.m_inherited_flags = parent->flags_u.m_inherited_flags; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
170 |
m_last_red_signal_type = parent->m_last_red_signal_type; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
171 |
} |
3978
30b43c605f21
(svn r5162) - CodeChange: [YAPF] added flag "choice seen" into YAPF node for trains
KUDr
parents:
3900
diff
changeset
|
172 |
flags_u.flags_s.m_choice_seen |= is_choice; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
173 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
174 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
175 |
FORCEINLINE TileIndex GetLastTile() const {assert(m_segment != NULL); return m_segment->m_last_tile;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
176 |
FORCEINLINE Trackdir GetLastTrackdir() const {assert(m_segment != NULL); return m_segment->m_last_td;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
177 |
FORCEINLINE void SetLastTileTrackdir(TileIndex tile, Trackdir td) {assert(m_segment != NULL); m_segment->m_last_tile = tile; m_segment->m_last_td = td;} |
7119
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
178 |
|
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
179 |
void Dump(DumpTarget &dmp) const |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
180 |
{ |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
181 |
base::Dump(dmp); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
182 |
dmp.WriteStructT("m_segment", m_segment); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
183 |
dmp.WriteLine("m_num_signals_passed = %d", m_num_signals_passed); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
184 |
dmp.WriteLine("m_targed_seen = %s", flags_u.flags_s.m_targed_seen ? "Yes" : "No"); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
185 |
dmp.WriteLine("m_choice_seen = %s", flags_u.flags_s.m_choice_seen ? "Yes" : "No"); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
186 |
dmp.WriteLine("m_last_signal_was_red = %s", flags_u.flags_s.m_last_signal_was_red ? "Yes" : "No"); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
187 |
dmp.WriteEnumT("m_last_red_signal_type", m_last_red_signal_type); |
afb9000a598e
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents:
7084
diff
changeset
|
188 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
189 |
}; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
190 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
191 |
// now define two major node types (that differ by key type) |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
192 |
typedef CYapfRailNodeT<CYapfNodeKeyExitDir> CYapfRailNodeExitDir; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
193 |
typedef CYapfRailNodeT<CYapfNodeKeyTrackDir> CYapfRailNodeTrackDir; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
194 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
195 |
// Default NodeList types |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
196 |
typedef CNodeList_HashTableT<CYapfRailNodeExitDir , 10, 12> CRailNodeListExitDir; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
197 |
typedef CNodeList_HashTableT<CYapfRailNodeTrackDir, 12, 16> CRailNodeListTrackDir; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
198 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
199 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
200 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
201 |
#endif /* YAPF_NODE_RAIL_HPP */ |