Mercurial > hg > openttd
changeset 8342:441cda3cfbdb draft
(svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
author | smatz <smatz@openttd.org> |
---|---|
date | Thu, 17 Jan 2008 19:49:06 +0000 |
parents | f43e029e9905 |
children | 8ee8a732be4e |
files | src/economy.cpp src/openttd.cpp src/rail_cmd.cpp src/road_cmd.cpp src/road_func.h src/train_cmd.cpp |
diffstat | 6 files changed, 28 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -41,6 +41,7 @@ #include "sound_func.h" #include "track_type.h" #include "track_func.h" +#include "road_func.h" #include "rail_map.h" #include "signal_func.h" #include "gfx_func.h" @@ -432,7 +433,9 @@ if (new_player != PLAYER_SPECTATOR) { /* Update all signals because there can be new segment that was owned by two players - * and signals were not propagated */ + * and signals were not propagated + * Similiar with crossings - it is needed to bar crossings that weren't before + * because of different owner of crossing and approaching train */ tile = 0; do { @@ -442,6 +445,8 @@ Track track = RemoveFirstTrack(&tracks); if (HasSignalOnTrack(tile, track)) AddTrackToSignalBuffer(tile, track, new_player); } while (tracks != TRACK_BIT_NONE); + } else if (IsLevelCrossingTile(tile) && IsTileOwner(tile, new_player)) { + UpdateLevelCrossing(tile); } } while (++tile != MapSize());
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -65,6 +65,7 @@ #include "vehicle_func.h" #include "sound_func.h" #include "variables.h" +#include "road_func.h" #include "bridge_map.h" #include "clear_map.h" @@ -2313,6 +2314,13 @@ } } + if (CheckSavegameVersion(86)) { + /* Now all crossings should be in correct state */ + for (TileIndex t = 0; t < map_size; t++) { + if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t); + } + } + return InitializeWindowsAndCaches(); }
--- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -383,6 +383,7 @@ (track == TRACK_Y && road == ROAD_X)) { if (flags & DC_EXEC) { MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile)); + UpdateLevelCrossing(tile); } break; }
--- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -32,6 +32,7 @@ #include "vehicle_func.h" #include "vehicle_base.h" #include "sound_func.h" +#include "road_func.h" #include "table/sprites.h" #include "table/strings.h" @@ -486,6 +487,7 @@ YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile))); /* Always add road to the roadtypes (can't draw without it) */ MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2); + UpdateLevelCrossing(tile); MarkTileDirtyByTile(tile); } return CommandCost(EXPENSES_CONSTRUCTION, _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4)); @@ -1343,11 +1345,9 @@ { switch (GetRoadTileType(tile)) { case ROAD_TILE_CROSSING: - if (v->type == VEH_TRAIN && !IsCrossingBarred(tile)) { - /* train crossing a road */ - SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); - BarCrossing(tile); - MarkTileDirtyByTile(tile); + if (v->type == VEH_TRAIN) { + /* it should be barred */ + assert(IsCrossingBarred(tile)); } break;
--- a/src/road_func.h +++ b/src/road_func.h @@ -136,4 +136,6 @@ */ RoadTypes GetPlayerRoadtypes(const PlayerID p); +void UpdateLevelCrossing(TileIndex tile); + #endif /* ROAD_FUNC_H */
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1685,7 +1685,7 @@ * @param tile tile to update * @pre tile is a rail-road crossing */ -void UpdateTrainCrossing(TileIndex tile) +void UpdateLevelCrossing(TileIndex tile) { assert(IsLevelCrossingTile(tile)); @@ -1773,11 +1773,11 @@ ClrBit(v->u.rail.flags, VRF_REVERSING); /* update crossing we were approaching */ - if (crossing != INVALID_TILE) UpdateTrainCrossing(crossing); + if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing); /* maybe we are approaching crossing now, after reversal */ crossing = TrainApproachingCrossingTile(v); - if (crossing != INVALID_TILE) UpdateTrainCrossing(crossing); + if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing); } /** Reverse train. @@ -2856,7 +2856,7 @@ END_ENUM_WAGONS(v) /* must be updated after the train has been marked crashed */ - if (crossing != INVALID_TILE) UpdateTrainCrossing(crossing); + if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing); } static uint CountPassengersInTrain(const Vehicle* v) @@ -3148,7 +3148,7 @@ * (above) or the last vehicle moves. */ if (v->Next() == NULL) { TrainMovedChangeSignals(gp.old_tile, ReverseDiagDir(enterdir)); - if (IsLevelCrossingTile(gp.old_tile)) UpdateTrainCrossing(gp.old_tile); + if (IsLevelCrossingTile(gp.old_tile)) UpdateLevelCrossing(gp.old_tile); } } } @@ -3211,7 +3211,7 @@ v = NULL; // make sure nobody will won't try to read 'v' anymore /* check if the wagon was on a road/rail-crossing */ - if (IsLevelCrossingTile(tile)) UpdateTrainCrossing(tile); + if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile); /* Update signals */ if (IsTileType(tile, MP_TUNNELBRIDGE) || IsTileDepotType(tile, TRANSPORT_RAIL)) {