summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-04 20:33:18 +0000
committerfrosch <frosch@openttd.org>2009-10-04 20:33:18 +0000
commitb243f6ca9761d75d3e5e957aa02a29500021b7d3 (patch)
tree980395eb85fe52ceec26d6da44b70d948780b030 /src
parent5ff6053326c060c0c717a0b5745423dda92d7af9 (diff)
downloadopenttd-b243f6ca9761d75d3e5e957aa02a29500021b7d3.tar.xz
(svn r17700) -Codechange: Integrate ShipVehicleInfo::refittable into EngineInfo::refit_mask during initialisation.
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_engine.cpp1
-rw-r--r--src/articulated_vehicles.cpp6
-rw-r--r--src/engine.cpp2
-rw-r--r--src/engine_type.h2
-rw-r--r--src/newgrf.cpp5
-rw-r--r--src/ship_cmd.cpp1
6 files changed, 7 insertions, 10 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index a3f5c39cd..72bf32363 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -55,7 +55,6 @@
if (GetCargoType(engine_id) == cargo_id) return true;
if (cargo_id == CT_MAIL && ::Engine::Get(engine_id)->type == VEH_AIRCRAFT) return true;
- if (::Engine::Get(engine_id)->type == VEH_SHIP && !ShipVehInfo(engine_id)->refittable) return false;
return ::CanRefitTo(engine_id, cargo_id);
}
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 04d86aa2a..791996a9a 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -75,10 +75,8 @@ static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, VehicleType
CargoID initial_cargo_type;
if (GetVehicleDefaultCapacity(engine, type, &initial_cargo_type) > 0) {
- if (type != VEH_SHIP || ShipVehInfo(engine)->refittable) {
- const EngineInfo *ei = EngInfo(engine);
- cargos = ei->refit_mask;
- }
+ const EngineInfo *ei = EngInfo(engine);
+ cargos = ei->refit_mask;
if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargos, initial_cargo_type);
}
diff --git a/src/engine.cpp b/src/engine.cpp
index 7219d27a1..95ac02828 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -784,8 +784,6 @@ bool IsEngineRefittable(EngineID engine)
/* check if it's an engine that is in the engine array */
if (e == NULL) return false;
- if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
-
if (!e->CanCarryCargo()) return false;
const EngineInfo *ei = &e->info;
diff --git a/src/engine_type.h b/src/engine_type.h
index cd903ff3f..a1a9ccada 100644
--- a/src/engine_type.h
+++ b/src/engine_type.h
@@ -67,7 +67,7 @@ struct ShipVehicleInfo {
uint16 capacity;
byte running_cost;
SoundID sfx;
- bool refittable;
+ bool old_refittable; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
};
/* AircraftVehicleInfo subtypes, bitmask type.
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index ae49f1da4..6257d09c9 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -888,7 +888,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
} break;
case 0x09: // Refittable
- svi->refittable = (grf_load_byte(&buf) != 0);
+ svi->old_refittable = (grf_load_byte(&buf) != 0);
break;
case PROP_SHIP_COST_FACTOR: // 0x0A Cost factor
@@ -5756,6 +5756,9 @@ static void CalculateRefitMasks()
* cargo type. Finally disable the vehicle, if there is still no cargo. */
if (ei->cargo_type == CT_INVALID && ei->refit_mask != 0) ei->cargo_type = (CargoID)FindFirstBit(ei->refit_mask);
if (ei->cargo_type == CT_INVALID) ei->climates = 0x80;
+
+ /* Clear refit_mask for not refittable ships */
+ if (e->type == VEH_SHIP && !e->u.ship.old_refittable) ei->refit_mask = 0;
}
}
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 82ccba38e..2971b35c1 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -920,7 +920,6 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_REFIT_DESTROYED_VEHICLE);
/* Check cargo */
- if (!ShipVehInfo(v->engine_type)->refittable) return CMD_ERROR;
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
/* Check the refit capacity callback */