summaryrefslogtreecommitdiff
path: root/src/ship_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-28 18:31:16 +0000
committerfrosch <frosch@openttd.org>2009-10-28 18:31:16 +0000
commit83894809d0bf63f5375cf546f3d353f5299a6442 (patch)
treee5bc6eae133e4d7d043c01575a691812798c353e /src/ship_cmd.cpp
parent2a3c797138b988a4c836215a8d98b8f85244c48e (diff)
downloadopenttd-83894809d0bf63f5375cf546f3d353f5299a6442.tar.xz
(svn r17897) -Fix [FS#3255]: CB15 and CB36 (capacity) were not always called when they should.
-Codechange: Move capacity calculation to a single function for all vehicle types, so the behaviour can be kept consistent easier.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 0025aabac..7c64e4ee5 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -813,7 +813,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
v->InvalidateNewGRFCacheOfChain();
- v->cargo_cap = GetVehicleProperty(v, PROP_SHIP_CARGO_CAPACITY, svi->capacity);
+ v->cargo_cap = GetVehicleCapacity(v);
v->InvalidateNewGRFCacheOfChain();
@@ -912,7 +912,6 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
CommandCost cost(EXPENSES_SHIP_RUN);
CargoID new_cid = GB(p2, 0, 8); // gets the cargo number
byte new_subtype = GB(p2, 8, 8);
- uint16 capacity = CALLBACK_FAILED;
Ship *v = Ship::GetIfValid(p1);
@@ -920,29 +919,23 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_REFIT_DESTROYED_VEHICLE);
- const Engine *e = Engine::Get(v->engine_type);
-
/* Check cargo */
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
- /* Check the refit capacity callback */
- if (HasBit(e->info.callback_mask, CBM_VEHICLE_REFIT_CAPACITY)) {
- /* Back up the existing cargo type */
- CargoID temp_cid = v->cargo_type;
- byte temp_subtype = v->cargo_subtype;
- v->cargo_type = new_cid;
- v->cargo_subtype = new_subtype;
+ v->InvalidateNewGRFCacheOfChain();
- capacity = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
+ /* Back up the existing cargo type */
+ CargoID temp_cid = v->cargo_type;
+ byte temp_subtype = v->cargo_subtype;
+ v->cargo_type = new_cid;
+ v->cargo_subtype = new_subtype;
- /* Restore the cargo type */
- v->cargo_type = temp_cid;
- v->cargo_subtype = temp_subtype;
- }
+ uint capacity = GetVehicleCapacity(v);
+
+ /* Restore the cargo type */
+ v->cargo_type = temp_cid;
+ v->cargo_subtype = temp_subtype;
- if (capacity == CALLBACK_FAILED) {
- capacity = GetVehicleProperty(v, PROP_SHIP_CARGO_CAPACITY, e->u.ship.capacity);
- }
_returned_refit_capacity = capacity;
if (new_cid != v->cargo_type) {