Changeset - r13183:9f8ce87db9c1
[Not reviewed]
master
0 6 0
frosch - 15 years ago 2009-10-04 20:33:18
frosch@openttd.org
(svn r17700) -Codechange: Integrate ShipVehicleInfo::refittable into EngineInfo::refit_mask during initialisation.
6 files changed with 7 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_engine.cpp
Show inline comments
 
@@ -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);
 
}
 

	
src/articulated_vehicles.cpp
Show inline comments
 
@@ -75,10 +75,8 @@ static inline uint32 GetAvailableVehicle
 
	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);
 
	}
 

	
src/engine.cpp
Show inline comments
 
@@ -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;
src/engine_type.h
Show inline comments
 
@@ -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.
src/newgrf.cpp
Show inline comments
 
@@ -888,7 +888,7 @@ static ChangeInfoResult ShipVehicleChang
 
			} 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;
 
	}
 
}
 

	
src/ship_cmd.cpp
Show inline comments
 
@@ -920,7 +920,6 @@ CommandCost CmdRefitShip(TileIndex tile,
 
	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 */
0 comments (0 inline, 0 general)