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
 
@@ -1506,21 +1506,13 @@ static void AircraftEntersTerminal(Vehic
 
			STR_A033_CITIZENS_CELEBRATE_FIRST,
 
			flags,
 
			v->index,
 
			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);
 
	MarkAircraftDirty(v);
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1566,13 +1566,12 @@ again:
 
		/* Vehicle is at the stop position (at a bay) in a road stop.
 
		 * Note, if vehicle is loading/unloading it has already been handled,
 
		 * so if we get here the vehicle has just arrived or is just ready to leave. */
 
		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));
 
				RoadStop::Type type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK;
 

	
 
				/* Check if next inline bay is free */
 
@@ -1597,21 +1596,13 @@ again:
 
			rs->SetEntranceBusy(false);
 

	
 
			v->last_station_visited = GetStationIndex(v->tile);
 

	
 
			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)) {
 
				InvalidateWindow(WC_ROADVEH_LIST, v->owner);
 
				MarkRoadVehDirty(v);
 
			}
src/ship_cmd.cpp
Show inline comments
 
@@ -301,13 +301,13 @@ static void ProcessShipOrder(Vehicle *v)
 
}
 

	
 
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 ||
 
						(_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED))
 
					)) {
 
				SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
 
@@ -733,14 +733,12 @@ static void ShipController(Vehicle *v)
 
							v->last_station_visited = v->current_order.dest;
 

	
 
							/* Process station in the orderlist. */
 
							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);
 
								if (LoadUnloadVehicle(v, true)) {
 
									InvalidateWindow(WC_SHIPS_LIST, v->owner);
 
									MarkShipDirty(v);
src/train_cmd.cpp
Show inline comments
 
@@ -2631,25 +2631,13 @@ static void TrainEnterStation(Vehicle *v
 
			flags,
 
			v->index,
 
			0
 
		);
 
	}
 

	
 
	/* 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);
 
	if (LoadUnloadVehicle(v, true) != 0) {
 
		InvalidateWindow(WC_TRAINS_LIST, v->owner);
 
		TrainCargoChanged(v);
src/vehicle.cpp
Show inline comments
 
@@ -2947,12 +2947,30 @@ extern const ChunkHandler _veh_chunk_han
 
	{ 'VEHS', Save_VEHS, Load_VEHS, CH_SPARSE_ARRAY | CH_LAST},
 
};
 

	
 
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);
 
}
 

	
 
void Vehicle::LeaveStation()
 
{
0 comments (0 inline, 0 general)