From c62e867b5679f8bfa405611d31e8070fa053b934 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 28 Jun 2013 19:21:24 +0000 Subject: [PATCH] (svn r25498) [1.3] -Backport from trunk: - Fix: [NewGRF] When cargo NewGRF define a multiplier to modify vehicle capacities, use the same multiplier to modify loading speed (r25497, r25479) - Fix: [OSX] OS X SDK versions >= 10.5 always have a non-const iconv declaration (r25480) - Fix: Disable the depot-refit button in the order GUI, if the consist is not refittable unless it already has a refit order (r25459, r25458, r25457) --- config.lib | 4 ++-- src/economy.cpp | 8 ++++++-- src/order_gui.cpp | 17 +++++++++++++---- src/os/macosx/osx_stdafx.h | 5 +++++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/config.lib b/config.lib index d13bb04aec..23b5d430de 100644 --- a/config.lib +++ b/config.lib @@ -1754,7 +1754,7 @@ make_cflags_and_ldflags() { fi fi - if [ "$have_non_const_iconv" != "no" ]; then + if [ "$os" != "OSX" ] && [ "$have_non_const_iconv" != "no" ]; then CFLAGS="$CFLAGS -DHAVE_NON_CONST_ICONV" fi fi @@ -3488,7 +3488,7 @@ generate_src_osx() { CFLAGS="-isysroot $osx_sdk_path $CFLAGS_orig" LDFLAGS="-Wl,-syslibroot,$osx_sdk_path $LDFLAGS_orig" fi - CFLAGS="$CFLAGS -D_SQ64 -DHAVE_NON_CONST_ICONV -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW" + CFLAGS="$CFLAGS -D_SQ64 -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW" LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`" fi diff --git a/src/economy.cpp b/src/economy.cpp index 39cb8ddaa8..e61176c94b 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1313,10 +1313,11 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left) artic_part++; const Engine *e = v->GetEngine(); - byte load_amount = e->info.load_amount; + uint load_amount = e->info.load_amount; /* The default loadamount for mail is 1/4 of the load amount for passengers */ - if (v->type == VEH_AIRCRAFT && !Aircraft::From(v)->IsNormalAircraft()) load_amount = CeilDiv(load_amount, 4); + bool air_mail = v->type == VEH_AIRCRAFT && !Aircraft::From(v)->IsNormalAircraft(); + if (air_mail) load_amount = CeilDiv(load_amount, 4); if (_settings_game.order.gradual_loading) { uint16 cb_load_amount = CALLBACK_FAILED; @@ -1337,6 +1338,9 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left) } } + /* Scale load amount the same as capacity */ + if (HasBit(e->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER) && !air_mail) load_amount = CeilDiv(load_amount * CargoSpec::Get(v->cargo_type)->multiplier, 0x100); + GoodsEntry *ge = &st->goods[v->cargo_type]; if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (front->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) { diff --git a/src/order_gui.cpp b/src/order_gui.cpp index d6614bff50..845c0c3e57 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -28,6 +28,7 @@ #include "core/geometry_func.hpp" #include "hotkeys.h" #include "aircraft.h" +#include "engine_func.h" #include "widgets/order_widget.h" @@ -518,6 +519,7 @@ private: OrderPlaceObjectState goto_type; const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated. Scrollbar *vscroll; + bool can_do_refit; ///< Vehicle chain can be refitted in depot. bool can_do_autorefit; ///< Vehicle chain can be auto-refitted. /** @@ -786,8 +788,10 @@ private: /** Cache auto-refittability of the vehicle chain. */ void UpdateAutoRefitState() { + this->can_do_refit = false; this->can_do_autorefit = false; - for (const Vehicle *w = this->vehicle; w != NULL; w = w->Next()) { + for (const Vehicle *w = this->vehicle; w != NULL; w = w->IsGroundVehicle() ? w->Next() : NULL) { + if (IsEngineRefittable(w->engine_type)) this->can_do_refit = true; if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true; } } @@ -1014,8 +1018,11 @@ public: this->SetWidgetLoweredState(WID_O_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY); this->SetWidgetLoweredState(WID_O_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD); - /* Can only do refitting when stopping at the destination and loading cargo. */ - this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN, !this->can_do_autorefit || order->GetLoadType() == OLFB_NO_LOAD || order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION); + /* Can only do refitting when stopping at the destination and loading cargo. + * Also enable the button if a refit is already set to allow clearing it. */ + this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN, + order->GetLoadType() == OLFB_NO_LOAD || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) || + ((!this->can_do_refit || !this->can_do_autorefit) && !order->IsRefit())); break; @@ -1048,7 +1055,9 @@ public: } /* Disable refit button if the order is no 'always go' order. * However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */ - this->SetWidgetDisabledState(WID_O_REFIT, (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT)); + this->SetWidgetDisabledState(WID_O_REFIT, + (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) || + (!this->can_do_refit && !order->IsRefit())); this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE); break; diff --git a/src/os/macosx/osx_stdafx.h b/src/os/macosx/osx_stdafx.h index 688762be9c..decd0ba6c2 100644 --- a/src/os/macosx/osx_stdafx.h +++ b/src/os/macosx/osx_stdafx.h @@ -75,4 +75,9 @@ typedef unsigned int NSUInteger; #endif /* __LP64__ */ #endif /* NSInteger */ +/* OS X SDK versions >= 10.5 have a non-const iconv. */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +# define HAVE_NON_CONST_ICONV +#endif + #endif /* MACOS_STDAFX_H */