Changeset - r6616:876f96dd626c
[Not reviewed]
master
0 4 0
rubidium - 17 years ago 2007-05-14 16:07:05
rubidium@openttd.org
(svn r9836) -Codechange: make non-improved loading happen FIFO-ish; generally loading/unloading will happen fifo, but there are no guarantees on the FIFO-ness. For (better) FIFO guarantees you still need to use improved loading.
4 files changed with 27 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1482,8 +1482,13 @@ void VehiclePayment(Vehicle *front_v)
 
 * Loads/unload the vehicle if possible.
 
 * @param v the vehicle to be (un)loaded
 
 */
 
void LoadUnloadVehicle(Vehicle *v)
 
static void LoadUnloadVehicle(Vehicle *v)
 
{
 
	assert(v->current_order.type == OT_LOADING);
 

	
 
	/* We have not waited enough time till the next round of loading/unloading */
 
	if (--v->load_unload_time_rem != 0) return;
 

	
 
	int unloading_time = 0;
 
	Vehicle *u = v;
 
	int result = 0;
 
@@ -1496,8 +1501,6 @@ void LoadUnloadVehicle(Vehicle *v)
 
	uint32 cargo_full      = 0;
 
	int total_cargo_feeder_share = 0; // the feeder cash amount for the goods being loaded/unloaded in this load step
 

	
 
	assert(v->current_order.type == OT_LOADING);
 

	
 
	v->cur_speed = 0;
 

	
 
	StationID last_visited = v->last_station_visited;
 
@@ -1706,6 +1709,20 @@ void LoadUnloadVehicle(Vehicle *v)
 
	}
 
}
 

	
 
/**
 
 * Load/unload the vehicles in this station according to the order
 
 * they entered.
 
 * @param st the station to do the loading/unloading for
 
 */
 
void LoadUnloadStation(Station *st)
 
{
 
	std::list<Vehicle *>::iterator iter;
 
	for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
 
		Vehicle *v = *iter;
 
		if (!(v->vehstatus & (VS_STOPPED | VS_CRASHED))) LoadUnloadVehicle(v);
 
	}
 
}
 

	
 
void PlayersMonthlyLoop()
 
{
 
	PlayersGenStatistics();
src/economy.h
Show inline comments
 
@@ -69,5 +69,6 @@ int32 GetTransportedGoodsIncome(uint num
 
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
 

	
 
void VehiclePayment(Vehicle *front_v);
 
void LoadUnloadStation(Station *st);
 

	
 
#endif /* ECONOMY_H */
src/vehicle.cpp
Show inline comments
 
@@ -659,8 +659,6 @@ static VehicleTickProc* _vehicle_tick_pr
 

	
 
void CallVehicleTicks()
 
{
 
	Vehicle *v;
 

	
 
#ifdef ENABLE_NETWORK
 
	/* hotfix for desync problem:
 
	 *  for MP games invalidate the YAPF cache every tick to keep it exactly the same on the server and all clients */
 
@@ -671,6 +669,10 @@ void CallVehicleTicks()
 

	
 
	_first_veh_in_depot_list = NULL; // now we are sure it's initialized at the start of each tick
 

	
 
	Station *st;
 
	FOR_ALL_STATIONS(st) LoadUnloadStation(st);
 

	
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		_vehicle_tick_procs[v->type](v);
 

	
 
@@ -2933,17 +2935,8 @@ void Vehicle::HandleLoading(bool mode)
 
{
 
	switch (this->current_order.type) {
 
		case OT_LOADING: {
 
			/* Not the first call for this tick */
 
			if (mode) return;
 

	
 
			/* We have not waited enough time till the next round of loading/unloading */
 
			if (--this->load_unload_time_rem) return;
 

	
 
			/* Load/unload the vehicle; when it actually did something
 
			 * we do not leave the station. */
 
			LoadUnloadVehicle(this);
 

	
 
			if (!HASBIT(this->vehicle_flags, VF_LOADING_FINISHED)) return;
 
			/* Not the first call for this tick, or still loading */
 
			if (mode || !HASBIT(this->vehicle_flags, VF_LOADING_FINISHED)) return;
 

	
 
			this->PlayLeaveStationSound();
 

	
src/vehicle.h
Show inline comments
 
@@ -521,8 +521,6 @@ void ShowAircraftViewWindow(const Vehicl
 

	
 
UnitID GetFreeUnitNumber(byte type);
 

	
 
void LoadUnloadVehicle(Vehicle *v);
 

	
 
void TrainConsistChanged(Vehicle *v);
 
void TrainPowerChanged(Vehicle *v);
 
int32 GetTrainRunningCost(const Vehicle *v);
0 comments (0 inline, 0 general)