diff options
author | smatz <smatz@openttd.org> | 2007-12-15 23:11:18 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2007-12-15 23:11:18 +0000 |
commit | 60f9bbd17e0a2974d4e2d4da573ca6d75e06d3a2 (patch) | |
tree | 8577a9e0a6fc5a9738a729065c3218757a625053 /src/train_cmd.cpp | |
parent | 38c25ab03b8cfa939f9e78d796e9d92bee867b7a (diff) | |
download | openttd-60f9bbd17e0a2974d4e2d4da573ca6d75e06d3a2.tar.xz |
(svn r11642) -Codechange: VehicleFromPos does check for v->tile == tile, so remove useless checks
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 7c1f488cd..8264b0fa3 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1528,15 +1528,15 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r) /* Check if the vehicle is a train and is on the tile we are testing */ static void *TestTrainOnCrossing(Vehicle *v, void *data) { - if (v->tile != *(const TileIndex*)data || v->type != VEH_TRAIN) return NULL; + if (v->type != VEH_TRAIN) return NULL; return v; } static void DisableTrainCrossing(TileIndex tile) { if (IsLevelCrossingTile(tile) && - VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL && // empty? - IsCrossingBarred(tile)) { + IsCrossingBarred(tile) && + VehicleFromPos(tile, NULL, &TestTrainOnCrossing) == NULL) { // empty? UnbarCrossing(tile); MarkTileDirtyByTile(tile); } @@ -2798,17 +2798,12 @@ static void CheckTrainCollision(Vehicle *v) SndPlayVehicleFx(SND_13_BIG_CRASH, v); } -struct VehicleAtSignalData { - TileIndex tile; - Direction direction; -}; - static void *CheckVehicleAtSignal(Vehicle *v, void *data) { - const VehicleAtSignalData* vasd = (VehicleAtSignalData*)data; + Direction dir = *(Direction*)data; - if (v->type == VEH_TRAIN && IsFrontEngine(v) && v->tile == vasd->tile) { - DirDiff diff = ChangeDirDiff(DirDifference(v->direction, vasd->direction), DIRDIFF_90RIGHT); + if (v->type == VEH_TRAIN && IsFrontEngine(v)) { + DirDiff diff = ChangeDirDiff(DirDifference(v->direction, dir), DIRDIFF_90RIGHT); if (diff == DIRDIFF_90RIGHT || (v->cur_speed <= 5 && diff <= DIRDIFF_REVERSE)) return v; } @@ -2907,12 +2902,10 @@ static void TrainController(Vehicle *v, bool update_image) v->progress = 255 - 10; if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); - VehicleAtSignalData vasd; - vasd.tile = o_tile; - vasd.direction = ReverseDir(dir); + Direction rdir = ReverseDir(dir); /* check if a train is waiting on the other side */ - if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return; + if (VehicleFromPos(o_tile, &rdir, &CheckVehicleAtSignal) == NULL) return; } } goto reverse_train_direction; |