Skip to content

Commit

Permalink
Fix OpenTTD#10493, Fix OpenTTD#8424: Collision sensitivity lowered to…
Browse files Browse the repository at this point in the history
… correct incorrect crash circumstances.

Collision sensitivity was lowered in a way that both problematic circumstances
appear to be rectified while true collisions still seem to function fully. (An
idea of making the trains "park in" a little less also comes to mind, but this
patch seems sufficient to resolve the overall issue.)
  • Loading branch information
TrevorShelton committed Apr 2, 2023
1 parent 73474b0 commit 7c682c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/train_cmd.cpp
Expand Up @@ -3138,8 +3138,8 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data)
if (hash & ~15) return nullptr;

/* Slower check using multiplication */
int min_diff = (Train::From(v)->gcache.cached_veh_length + 1) / 2 + (tcc->v->gcache.cached_veh_length + 1) / 2 - 1;
if (x_diff * x_diff + y_diff * y_diff > min_diff * min_diff) return nullptr;
int min_diff = (Train::From(v)->gcache.cached_veh_length + tcc->v->gcache.cached_veh_length) / 2 - 2;
if (x_diff * x_diff + y_diff * y_diff >= min_diff * min_diff) return nullptr;

/* Happens when there is a train under bridge next to bridge head */
if (abs(v->z_pos - tcc->v->z_pos) > 5) return nullptr;
Expand Down

0 comments on commit 7c682c8

Please sign in to comment.