summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-05-31 11:31:10 +0000
committerfrosch <frosch@openttd.org>2009-05-31 11:31:10 +0000
commit56988b198d6657cda7a404d2f13c0d50ec3eed06 (patch)
tree0a1495866df24e3806260739a943aef3b39fa67d
parentc64fdcbef2de637d9cd7ab1fdacb27b443c57513 (diff)
downloadopenttd-56988b198d6657cda7a404d2f13c0d50ec3eed06.tar.xz
(svn r16479) -Fix (r5146): Call callbacks after initialisation of vehicle variables.
-rw-r--r--src/aircraft_cmd.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 025d6f777..94be6a9b6 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -333,24 +333,6 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
u->subtype = AIR_SHADOW;
u->UpdateDeltaXY(INVALID_DIR);
- if (v->cargo_type != CT_PASSENGERS) {
- uint16 callback = CALLBACK_FAILED;
-
- if (HasBit(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
- callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
- }
-
- if (callback == CALLBACK_FAILED) {
- /* Callback failed, or not executed; use the default cargo capacity */
- v->cargo_cap = AircraftDefaultCargoCapacity(v->cargo_type, avi);
- } else {
- v->cargo_cap = callback;
- }
-
- /* Set the 'second compartent' capacity to none */
- u->cargo_cap = 0;
- }
-
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;
@@ -391,6 +373,24 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+ if (v->cargo_type != CT_PASSENGERS) {
+ uint16 callback = CALLBACK_FAILED;
+
+ if (HasBit(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
+ callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
+ }
+
+ if (callback == CALLBACK_FAILED) {
+ /* Callback failed, or not executed; use the default cargo capacity */
+ v->cargo_cap = AircraftDefaultCargoCapacity(v->cargo_type, avi);
+ } else {
+ v->cargo_cap = callback;
+ }
+
+ /* Set the 'second compartent' capacity to none */
+ u->cargo_cap = 0;
+ }
+
UpdateAircraftCache(v);
VehicleMove(v, false);