@@ -1669,13 +1669,10 @@ static bool SignalVehicleCheck(TileIndex
/* check for a vehicle with that trackdir on the end tile of the tunnel */
if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
/* now check all tiles from start to end for a warping vehicle
* NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? */
/* now check all tiles from start to end for a warping vehicle */
dest.track = 0x40; //Vehicle inside a tunnel or on a bridge
for (; tile != end; tile += TileOffsByDiagDir(direction)) {
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL)
return true;
}
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
/* no vehicle found */
return false;
@@ -2760,7 +2760,16 @@ static void CheckTrainCollision(Vehicle
tcc.num = 0;
/* find colliding vehicles */
if (v->u.rail.track == TRACK_BIT_WORMHOLE) {
VehicleFromPos(v->tile, &tcc, FindTrainCollideEnum);
if (IsBridgeTile(v->tile)) {
VehicleFromPos(GetOtherBridgeEnd(v->tile), &tcc, FindTrainCollideEnum);
} else {
VehicleFromPos(GetOtherTunnelEnd(v->tile), &tcc, FindTrainCollideEnum);
VehicleFromPosXY(v->x_pos, v->y_pos, &tcc, FindTrainCollideEnum);
/* any dead -> no crash */
if (tcc.num == 0) return;
@@ -471,8 +471,8 @@ static void UpdateNewVehiclePosHash(Vehi
if (remove) {
new_hash = NULL;
int x = GB(v->x_pos / TILE_SIZE, HASH_RES, HASH_BITS);
int y = GB(v->y_pos / TILE_SIZE, HASH_RES, HASH_BITS) << HASH_BITS;
int x = GB(TileX(v->tile), HASH_RES, HASH_BITS);
int y = GB(TileY(v->tile), HASH_RES, HASH_BITS) << HASH_BITS;
new_hash = &_new_vehicle_position_hash[(x + y) & TOTAL_HASH_MASK];
Status change: