Changeset - r6550:75603d3aae13
[Not reviewed]
master
0 5 0
rubidium - 17 years ago 2007-04-29 18:21:24
rubidium@openttd.org
(svn r9752) -Codechange: remove some duplication related to BeginLoading.
5 files changed with 20 insertions and 33 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -1509,15 +1509,7 @@ static void AircraftEntersTerminal(Vehic
 
			0);
 
	}
 

	
 
	Order old_order = v->current_order;
 
	v->BeginLoading();
 
	v->current_order.flags = 0;
 

	
 
	if (old_order.type == OT_GOTO_STATION &&
 
			v->current_order.dest == v->last_station_visited) {
 
		v->current_order.flags =
 
			(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
 
	}
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
 
	LoadUnloadVehicle(v, true);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1569,7 +1569,6 @@ again:
 
		if (v->current_order.type != OT_LEAVESTATION &&
 
				v->current_order.type != OT_GOTO_DEPOT) {
 
			/* Vehicle has arrived at a bay in a road stop */
 
			Order old_order;
 

	
 
			if (IsDriveThroughStopTile(v->tile)) {
 
				TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
 
@@ -1600,15 +1599,7 @@ again:
 

	
 
			RoadVehArrivesAt(v, st);
 

	
 
			old_order = v->current_order;
 
			v->BeginLoading();
 
			v->current_order.flags = 0;
 

	
 
			if (old_order.type == OT_GOTO_STATION &&
 
					v->current_order.dest == v->last_station_visited) {
 
				v->current_order.flags =
 
					(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
 
			}
 

	
 
			SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
 
			if (LoadUnloadVehicle(v, true)) {
src/ship_cmd.cpp
Show inline comments
 
@@ -304,7 +304,7 @@ static void HandleShipLoading(Vehicle *v
 
{
 
	switch (v->current_order.type) {
 
		case OT_LOADING: {
 
			if (--v->load_unload_time_rem) return;
 
			if (--v->load_unload_time_rem != 0) return;
 

	
 
			if (CanFillVehicle(v) && (
 
						v->current_order.flags & OF_FULL_LOAD ||
 
@@ -736,8 +736,6 @@ static void ShipController(Vehicle *v)
 
							st = GetStation(v->current_order.dest);
 
							if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
 
								v->BeginLoading();
 
								v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
 
								v->current_order.flags |= OF_NON_STOP;
 
								ShipArrivesAt(v, st);
 

	
 
								SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
src/train_cmd.cpp
Show inline comments
 
@@ -2634,19 +2634,7 @@ static void TrainEnterStation(Vehicle *v
 
		);
 
	}
 

	
 
	/* Did we reach the final destination? */
 
	if (v->current_order.type == OT_GOTO_STATION &&
 
			v->current_order.dest == station) {
 
		/* Yeah, keep the load/unload flags
 
		 * Non Stop now means if the order should be increased. */
 
		v->BeginLoading();
 
		v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
 
		v->current_order.flags |= OF_NON_STOP;
 
	} else {
 
		/* No, just do a simple load */
 
		v->BeginLoading();
 
		v->current_order.flags = 0;
 
	}
 
	v->BeginLoading();
 
	v->current_order.dest = 0;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
src/vehicle.cpp
Show inline comments
 
@@ -2950,6 +2950,24 @@ extern const ChunkHandler _veh_chunk_han
 
void Vehicle::BeginLoading()
 
{
 
	assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
 

	
 
	if (this->current_order.type == OT_GOTO_STATION &&
 
			this->current_order.dest == this->last_station_visited) {
 
		/* Arriving at the ordered station.
 
		 * Keep the load/unload flags, as we (obviously) still need them. */
 
		this->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
 

	
 
		/* Furthermore add the Non Stop flag to mark that this station
 
		 * is the actual destination of the vehicle, which is (for example)
 
		 * necessary to be known for HandleTrainLoading to determine
 
		 * whether the train is lost or not; not marking a train lost
 
		 * that arrives at random stations is bad. */
 
		this->current_order.flags |= OF_NON_STOP;
 
	} else {
 
		/* This is just an unordered intermediate stop */
 
		this->current_order.flags = 0;
 
	}
 

	
 
	current_order.type = OT_LOADING;
 
	GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
 
}
0 comments (0 inline, 0 general)