Index: src/train_cmd.cpp =================================================================== --- src/train_cmd.cpp (Revision 20902) +++ src/train_cmd.cpp (Arbeitskopie) @@ -2861,14 +2861,14 @@ }; /** Modify the speed of the vehicle due to a change in altitude */ -static inline void AffectSpeedByZChange(Train *v, byte old_z) +static inline void AffectSpeedByZChange(Train *v, int32 old_z) { if (old_z == v->z_pos || _settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) return; const RailtypeSlowdownParams *rsp = &_railtype_slowdown[v->railtype]; if (old_z < v->z_pos) { - v->cur_speed -= (v->cur_speed * rsp->z_up >> 8); + v->cur_speed -= ((uint32)(v->cur_speed * rsp->z_up) >> 8); } else { uint16 spd = v->cur_speed + rsp->z_down; if (spd <= v->max_speed) v->cur_speed = spd; @@ -3317,7 +3317,7 @@ v->y_pos = gp.y; /* update the Z position of the vehicle */ - byte old_z = v->UpdateInclination(gp.new_tile != gp.old_tile, false); + int32 old_z = v->UpdateInclination(gp.new_tile != gp.old_tile, false); if (prev == NULL) { /* This is the first vehicle in the train */ Index: src/elrail.cpp =================================================================== --- src/elrail.cpp (Revision 20902) +++ src/elrail.cpp (Arbeitskopie) @@ -204,7 +204,7 @@ * @param PCPpos The PCP of the tile. * @return The Z position of the PCP. */ -static byte GetPCPElevation(TileIndex tile, DiagDirection PCPpos) +static int32 GetPCPElevation(TileIndex tile, DiagDirection PCPpos) { /* The elevation of the "pylon"-sprite should be the elevation at the PCP. * PCPs are always on a tile edge. @@ -220,8 +220,11 @@ * Also note that the result of GetSlopeZ() is very special on bridge-ramps. */ - byte z = GetSlopeZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1)); - return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2); + int32 z = GetSlopeZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1)); + z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2); + return z; + /* Removed because this bit magic almost surely does no longer work with int32. + * return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2); */ } /** @@ -311,7 +314,7 @@ SpriteID pylon_base = (halftile_corner != CORNER_INVALID && HasBit(edge_corners[i], halftile_corner)) ? pylon_halftile : pylon_normal; TileIndex neighbour = ti->tile + TileOffsByDiagDir(i); Foundation foundation = FOUNDATION_NONE; - byte elevation = GetPCPElevation(ti->tile, i); + int32 elevation = GetPCPElevation(ti->tile, i); /* Here's one of the main headaches. GetTileSlope does not correct for possibly * existing foundataions, so we do have to do that manually later on.*/