Changeset - r2704:d6b47e3c8810
[Not reviewed]
master
0 5 0
peter1138 - 19 years ago 2005-11-29 22:29:59
peter1138@openttd.org
(svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved.
5 files changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -493,13 +493,13 @@ int32 CmdRefitAircraft(int x, int y, uin
 
	if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!CheckStoppedInHangar(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
 

	
 
	avi = AircraftVehInfo(v->engine_type);
 

	
 
	/* Check cargo */
 
	if (new_cid > NUM_CARGO || !CanRefitTo(v, new_cid)) return CMD_ERROR;
 
	if (new_cid > NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 

	
 
	switch (new_cid) {
 
		case CT_PASSENGERS:
 
			pass = avi->passenger_capacity;
ship_cmd.c
Show inline comments
 
@@ -1053,13 +1053,13 @@ int32 CmdRefitShip(int x, int y, uint32 
 
	if (!IsTileDepotType(v->tile, TRANSPORT_WATER) || !(v->vehstatus&VS_STOPPED) || v->u.ship.state != 0x80)
 
			return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
 

	
 

	
 
	/* Check cargo */
 
	if (!ShipVehInfo(v->engine_type)->refittable) return CMD_ERROR;
 
	if (new_cid > NUM_CARGO || !CanRefitTo(v, new_cid)) return CMD_ERROR;
 
	if (new_cid > NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
 

	
 
	cost = 0;
 
	if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
 
		cost = _price.ship_base >> 7;
train_cmd.c
Show inline comments
 
@@ -1714,13 +1714,13 @@ int32 CmdRefitRailVehicle(int x, int y, 
 
	num = 0;
 

	
 
	do {
 
		/* XXX: We also refit all the attached wagons en-masse if they
 
		 * can be refitted. This is how TTDPatch does it.  TODO: Have
 
		 * some nice [Refit] button near each wagon. --pasky */
 
		if (!CanRefitTo(v, new_cid)) continue;
 
		if (!CanRefitTo(v->engine_type, new_cid)) continue;
 

	
 
		if (v->cargo_cap != 0) {
 
			const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
 
			uint16 amount = CALLBACK_FAILED;
 

	
 
			if (HASBIT(rvi->callbackmask, CBM_REFIT_CAP)) {
vehicle.c
Show inline comments
 
@@ -677,21 +677,21 @@ bool CanFillVehicle(Vehicle *v)
 
				return true;
 
		} while ( (v=v->next) != NULL);
 
	}
 
	return false;
 
}
 

	
 
/** Check if a given vehicle (type) can be refitted to a given cargo
 
 * @param *v vehicle to check
 
/** Check if a given engine type can be refitted to a given cargo
 
 * @param engine_type Engine type to check
 
 * @param cid_to check refit to this cargo-type
 
 * @return true if it is possible, false otherwise
 
 */
 
bool CanRefitTo(const Vehicle *v, CargoID cid_to)
 
bool CanRefitTo(EngineID engine_type, CargoID cid_to)
 
{
 
	CargoID cid = _global_cargo_id[_opt_ptr->landscape][cid_to];
 
	return HASBIT(_engine_info[v->engine_type].refit_mask, cid) != 0;
 
	return HASBIT(_engine_info[engine_type].refit_mask, cid) != 0;
 
}
 

	
 
static void DoDrawVehicle(const Vehicle *v)
 
{
 
	uint32 image = v->cur_image;
 

	
vehicle.h
Show inline comments
 
@@ -270,13 +270,13 @@ void *VehicleFromPos(TileIndex tile, voi
 
void CallVehicleTicks(void);
 
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
 

	
 
void InitializeTrains(void);
 

	
 
bool CanFillVehicle(Vehicle *v);
 
bool CanRefitTo(const Vehicle *v, CargoID cid_to);
 
bool CanRefitTo(EngineID engine_type, CargoID cid_to);
 

	
 
void ViewportAddVehicles(DrawPixelInfo *dpi);
 

	
 
void TrainEnterDepot(Vehicle *v, TileIndex tile);
 

	
 
void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building) ;
0 comments (0 inline, 0 general)