diff options
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 955f9bde0..8f6a28bd1 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -285,6 +285,14 @@ uint Vehicle::Crash(bool flooded) return RandomRange(pass + 1); // Randomise deceased passengers. } +bool Vehicle::IsDrawn() const +{ + return !(this->vehstatus & VS_HIDDEN) || + (!IsTransparencySet(TO_TUNNELS) && + ((this->type == VEH_TRAIN && Train::From(this)->track == TRACK_BIT_WORMHOLE) || + (this->type == VEH_ROAD && RoadVehicle::From(this)->state == RVSB_WORMHOLE))); +} + /** * Displays a "NewGrf Bug" error message for a engine, and pauses the game if not networking. @@ -1082,7 +1090,7 @@ static void DoDrawVehicle(const Vehicle *v) if (v->vehstatus & VS_DEFPAL) pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); /* Check whether the vehicle shall be transparent due to the game state */ - bool shadowed = (v->vehstatus & VS_SHADOW) != 0; + bool shadowed = (v->vehstatus & (VS_SHADOW | VS_HIDDEN)) != 0; if (v->type == VEH_EFFECT) { /* Check whether the vehicle shall be transparent/invisible due to GUI settings. @@ -1144,7 +1152,7 @@ void ViewportAddVehicles(DrawPixelInfo *dpi) while (v != nullptr) { - if (!(v->vehstatus & VS_HIDDEN) && + if (v->IsDrawn() && l <= v->coord.right + xb && t <= v->coord.bottom + yb && r >= v->coord.left - xb && @@ -1210,7 +1218,7 @@ Vehicle *CheckClickOnVehicle(const Viewport *vp, int x, int y) y = ScaleByZoom(y, vp->zoom) + vp->virtual_top; for (Vehicle *v : Vehicle::Iterate()) { - if ((v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0 && + if (v->IsDrawn() && !(v->vehstatus & VS_UNCLICKABLE) && x >= v->coord.left && x <= v->coord.right && y >= v->coord.top && y <= v->coord.bottom) { |