(svn r10373) [0.5] -Backport from trunk (r10306, r10311, r10317, r10339, r10344):
- Fix: Acceleration for trains on slopes is not calculated properly [FS#786] (r10317, r10344)
- Fix: Rail could be destroyed when building tunnels (r10306)
--- a/misc_gui.c Thu Jun 28 13:58:39 2007 +0000
+++ b/misc_gui.c Thu Jun 28 14:11:00 2007 +0000
@@ -213,16 +213,16 @@
" Loïc Guilloux (glx) - In training, not yet specialized",
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
" Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
+ " Owen Rudge (orudge) - Forum host, OS/2 port",
" Peter Nelson (peter1138) - Spiritual descendant from newgrf gods",
" Remko Bijker (Rubidium) - THE desync hunter",
" Christoph Mallon (Tron) - Programmer, code correctness police",
- " Patric Stout (TrueLight) - Coder, network guru, SVN- and website host",
+ " Patric Stout (TrueLight) - Coder, network guru, SVN-, MS- and website host",
"",
"Retired Developers:",
" Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)",
" Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)",
" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)",
- " Owen Rudge (orudge) - Forum- and masterserver host, OS/2 port (0.1 - 0.4.8)",
"",
"Special thanks go out to:",
" Josef Drexler - For his great work on TTDPatch",
--- a/train_cmd.c Thu Jun 28 13:58:39 2007 +0000
+++ b/train_cmd.c Thu Jun 28 14:11:00 2007 +0000
@@ -2748,26 +2748,28 @@
static byte AfterSetTrainPos(Vehicle *v, bool new_tile)
{
- byte new_z, old_z;
-
- // need this hint so it returns the right z coordinate on bridges.
- _get_z_hint = v->z_pos;
- new_z = GetSlopeZ(v->x_pos, v->y_pos);
- _get_z_hint = 0;
-
- old_z = v->z_pos;
- v->z_pos = new_z;
+ byte old_z = v->z_pos;
+ v->z_pos = GetSlopeZ(v->x_pos, v->y_pos);
if (new_tile) {
CLRBIT(v->u.rail.flags, VRF_GOINGUP);
CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
- if (new_z != old_z) {
- TileIndex tile = TileVirtXY(v->x_pos, v->y_pos);
-
- // XXX workaround, whole UP/DOWN detection needs overhaul
- if (!IsTunnelTile(tile)) {
- SETBIT(v->u.rail.flags, (new_z > old_z) ? VRF_GOINGUP : VRF_GOINGDOWN);
+ if (v->u.rail.track == TRACK_BIT_X || v->u.rail.track == TRACK_BIT_Y) {
+ /* Any track that isn't TRACK_BIT_X or TRACK_BIT_Y cannot be sloped.
+ * To check whether the current tile is sloped, and in which
+ * direction it is sloped, we get the 'z' at the center of
+ * the tile (middle_z) and the edge of the tile (old_z),
+ * which we then can compare. */
+ static const int HALF_TILE_SIZE = TILE_SIZE / 2;
+ static const int INV_TILE_SIZE_MASK = ~(TILE_SIZE - 1);
+
+ byte middle_z = GetSlopeZ((v->x_pos & INV_TILE_SIZE_MASK) | HALF_TILE_SIZE, (v->y_pos & INV_TILE_SIZE_MASK) | HALF_TILE_SIZE);
+
+ /* For some reason tunnel tiles are always given as sloped :(
+ * But they are not sloped... */
+ if (middle_z != v->z_pos && !IsTunnelTile(TileVirtXY(v->x_pos, v->y_pos))) {
+ SETBIT(v->u.rail.flags, (middle_z > old_z) ? VRF_GOINGUP : VRF_GOINGDOWN);
}
}
}
--- a/tunnelbridge_cmd.c Thu Jun 28 13:58:39 2007 +0000
+++ b/tunnelbridge_cmd.c Thu Jun 28 14:11:00 2007 +0000
@@ -507,6 +507,15 @@
// slope of end tile must be complementary to the slope of the start tile
if (end_tileh != ComplementSlope(start_tileh)) {
+ /* Some (rail) track bits might be terraformed into the correct direction,
+ * but that would still leave tracks on foundation. Therefor excavation will
+ * always fail for rail tiles. On the other hand, for road tiles it might
+ * succeed when there is only one road bit on the tile, but then that road
+ * bit is removed leaving a clear tile.
+ * This therefor preserves the behaviour that half road tiles are always removable.
+ */
+ if (IsTileType(end_tile, MP_RAILWAY)) return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
+
ret = DoCommand(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND);
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND);
} else {