From b0cc56a8b500880d11d26f16412ba766431e21a4 Mon Sep 17 00:00:00 2001 From: enveeed <25058915+enveeed@users.noreply.github.com> Date: Sat, 15 Mar 2025 21:58:47 +0100 Subject: [PATCH] Fix: NewGRF vehicles display loading sprites when not actually loading or unloading (#13554) --- src/newgrf_engine.cpp | 4 +++- src/order_cmd.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 592a385d76..a6f7cb34e8 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -1008,7 +1008,9 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec return nullptr; } - bool in_motion = !v->First()->current_order.IsType(OT_LOADING); + const Order &order = v->First()->current_order; + bool not_loading = (order.GetUnloadType() & OUFB_NO_UNLOAD) && (order.GetLoadType() & OLFB_NO_LOAD); + bool in_motion = !order.IsType(OT_LOADING) || not_loading; uint totalsets = in_motion ? (uint)group->loaded.size() : (uint)group->loading.size(); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 6ad26ed1a3..f3d0f9a527 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -197,7 +197,7 @@ bool Order::Equals(const Order &other) const uint16_t Order::MapOldOrder() const { uint16_t order = this->GetType(); - switch (this->type) { + switch (this->GetType()) { case OT_GOTO_STATION: if (this->GetUnloadType() & OUFB_UNLOAD) SetBit(order, 5); if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6); @@ -211,6 +211,12 @@ uint16_t Order::MapOldOrder() const break; case OT_LOADING: if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6); + /* If both "no load" and "no unload" are set, return nothing order instead */ + if ((this->GetLoadType() & OLFB_NO_LOAD) && (this->GetUnloadType() & OUFB_NO_UNLOAD)) { + order = OT_NOTHING; + } + break; + default: break; } return order;