Changeset - r8928:b99c60f72521
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-04-14 07:08:43
rubidium@openttd.org
(svn r12698) -Codechange: skip orders to stations that do not have a train part anymore, just like is done for road vehicles and ships.
2 files changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ship_cmd.cpp
Show inline comments
 
@@ -222,49 +222,49 @@ static void HandleBrokenShip(Vehicle *v)
 
}
 

	
 
void Ship::MarkDirty()
 
{
 
	this->cur_image = this->GetImage(this->direction);
 
	MarkSingleVehicleDirty(this);
 
}
 

	
 
static void PlayShipSound(const Vehicle *v)
 
{
 
	if (!PlayVehicleSound(v, VSE_START)) {
 
		SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
 
	}
 
}
 

	
 
void Ship::PlayLeaveStationSound() const
 
{
 
	PlayShipSound(this);
 
}
 

	
 
TileIndex Ship::GetOrderStationLocation(StationID station)
 
{
 
	if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
 

	
 
	Station *st = GetStation(station);
 
	const Station *st = GetStation(station);
 
	if (st->dock_tile != 0) {
 
		return TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
 
	} else {
 
		this->cur_order_index++;
 
		return 0;
 
	}
 
}
 

	
 
void Ship::UpdateDeltaXY(Direction direction)
 
{
 
#define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0)
 
	static const uint32 _delta_xy_table[8] = {
 
		MKIT( 6,  6,  -3,  -3),
 
		MKIT( 6, 32,  -3, -16),
 
		MKIT( 6,  6,  -3,  -3),
 
		MKIT(32,  6, -16,  -3),
 
		MKIT( 6,  6,  -3,  -3),
 
		MKIT( 6, 32,  -3, -16),
 
		MKIT( 6,  6,  -3,  -3),
 
		MKIT(32,  6, -16,  -3),
 
	};
 
#undef MKIT
 

	
 
	uint32 x = _delta_xy_table[direction];
src/train_cmd.cpp
Show inline comments
 
@@ -2542,49 +2542,56 @@ static bool CheckReverseTrain(Vehicle *v
 
					int r = GB(Random(), 0, 8);
 
					if (_pick_track_table[i] == (v->direction & 3)) r += 80;
 
					if (_pick_track_table[best_track] == (v->direction & 3)) r -= 80;
 
					if (r <= 127) goto bad;
 
				}
 
good:;
 
				best_track = i;
 
				best_bird_dist = fd.best_bird_dist;
 
				best_track_dist = fd.best_track_dist;
 
				reverse_best = reverse;
 
bad:;
 
				if (reverse != 0) break;
 
				reverse = 2;
 
			}
 
		} break;
 
	}
 

	
 
	return reverse_best != 0;
 
}
 

	
 
TileIndex Train::GetOrderStationLocation(StationID station)
 
{
 
	if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
 

	
 
	return GetStation(station)->xy;
 
	const Station *st = GetStation(station);
 
	if (!(st->facilities & FACIL_TRAIN)) {
 
		/* The destination station has no trainstation tiles. */
 
		this->cur_order_index++;
 
		return 0;
 
	}
 

	
 
	return st->xy;
 
}
 

	
 
void Train::MarkDirty()
 
{
 
	Vehicle *v = this;
 
	do {
 
		v->cur_image = v->GetImage(v->direction);
 
		MarkSingleVehicleDirty(v);
 
	} while ((v = v->Next()) != NULL);
 

	
 
	/* need to update acceleration and cached values since the goods on the train changed. */
 
	TrainCargoChanged(this);
 
	UpdateTrainAcceleration(this);
 
}
 

	
 
static int UpdateTrainSpeed(Vehicle *v)
 
{
 
	uint accel;
 

	
 
	if (v->vehstatus & VS_STOPPED || HasBit(v->u.rail.flags, VRF_REVERSING)) {
 
		if (_patches.realistic_acceleration) {
 
			accel = GetTrainAcceleration(v, AM_BRAKE) * 2;
 
		} else {
 
			accel = v->acceleration * -2;
0 comments (0 inline, 0 general)