summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-05-14 16:38:53 +0000
committersmatz <smatz@openttd.org>2008-05-14 16:38:53 +0000
commit9b8d16b7ff71d2599f91835332a9903fc2ba4bba (patch)
tree73fe802bb7f94ddb5fbfc6fc4c60f37761576126
parent2475959196ba9ccb0c9910680f3c7ebb5aa1082c (diff)
downloadopenttd-9b8d16b7ff71d2599f91835332a9903fc2ba4bba.tar.xz
(svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
-rw-r--r--src/signal.cpp11
-rw-r--r--src/signal_func.h8
-rw-r--r--src/train_cmd.cpp2
3 files changed, 15 insertions, 6 deletions
diff --git a/src/signal.cpp b/src/signal.cpp
index 03747eefe..e64480a4d 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -468,12 +468,12 @@ static inline void ResetSets()
* @return false iff presignal entry would be green (needed for trains leaving depot)
* @pre IsValidPlayer(owner)
*/
-static bool UpdateSignalsInBuffer(Owner owner)
+static SigSegState UpdateSignalsInBuffer(Owner owner)
{
assert(IsValidPlayer(owner));
bool first = true; // first block?
- bool state = false; // value to return
+ SigSegState state = SIGSEG_FREE; // value to return
TileIndex tile;
DiagDirection dir;
@@ -532,7 +532,10 @@ static bool UpdateSignalsInBuffer(Owner owner)
if (first) {
first = false;
- state = (flags & SF_TRAIN) || (flags & SF_EXIT && !(flags & SF_GREEN)) || (flags & SF_FULL); // true iff train CAN'T leave the depot
+ if ((flags & SF_TRAIN) || (flags & SF_EXIT && !(flags & SF_GREEN)) || (flags & SF_FULL)) {
+ /* SIGSEG_FREE is set by default */
+ state = SIGSEG_FULL;
+ }
}
/* do not do anything when some buffer was full */
@@ -629,7 +632,7 @@ void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
* @param owner owner whose signals we will update
* @return false iff train can leave depot
*/
-bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner)
+SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner)
{
assert(_globset.IsEmpty());
_globset.Add(tile, side);
diff --git a/src/signal_func.h b/src/signal_func.h
index a5479a3e0..7dcf3fd81 100644
--- a/src/signal_func.h
+++ b/src/signal_func.h
@@ -41,7 +41,13 @@ static inline byte SignalOnTrack(Track track)
return _signal_on_track[track];
}
-bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner);
+/** State of the signal segment */
+enum SigSegState {
+ SIGSEG_FREE, ///< Free and has no pre-signal exits or at least one green exit
+ SIGSEG_FULL, ///< Occupied by a train
+};
+
+SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner);
void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner);
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner);
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 4f7fef012..c6bc5d135 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2262,7 +2262,7 @@ static bool CheckTrainStayInDepot(Vehicle *v)
v->load_unload_time_rem = 0;
- if (UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner)) {
+ if (UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner) == SIGSEG_FULL) {
InvalidateWindowClasses(WC_TRAINS_LIST);
return true;
}