File diff r15724:6a590b922d6c → r15725:0c28e29aa5d4
src/newgrf_station.cpp
Show inline comments
 
@@ -155,50 +155,50 @@ uint GetNumStationClasses()
 

	
 
/**
 
 * Return the number of stations for the given station class.
 
 * @param sclass Index of the station class.
 
 * @return Number of stations in the class.
 
 */
 
uint GetNumCustomStations(StationClassID sclass)
 
{
 
	assert(sclass < STAT_CLASS_MAX);
 
	return _station_classes[sclass].stations;
 
}
 

	
 
/**
 
 * Tie a station spec to its station class.
 
 * @param statspec The station spec.
 
 */
 
void SetCustomStationSpec(StationSpec *statspec)
 
{
 
	StationClass *station_class;
 
	int i;
 

	
 
	/* If the station has already been allocated, don't reallocate it. */
 
	if (statspec->allocated) return;
 

	
 
	assert(statspec->sclass < STAT_CLASS_MAX);
 
	station_class = &_station_classes[statspec->sclass];
 
	assert(statspec->cls_id < STAT_CLASS_MAX);
 
	station_class = &_station_classes[statspec->cls_id];
 

	
 
	i = station_class->stations++;
 
	station_class->spec = ReallocT(station_class->spec, station_class->stations);
 

	
 
	station_class->spec[i] = statspec;
 
	statspec->allocated = true;
 
}
 

	
 
/**
 
 * Retrieve a station spec from a class.
 
 * @param sclass Index of the station class.
 
 * @param station The station index with the class.
 
 * @return The station spec.
 
 */
 
const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station)
 
{
 
	assert(sclass < STAT_CLASS_MAX);
 
	if (station < _station_classes[sclass].stations) return _station_classes[sclass].spec[station];
 

	
 
	/* If the custom station isn't defined any more, then the GRF file
 
	 * probably was not loaded. */
 
	return NULL;
 
}
 

	
 
@@ -585,49 +585,49 @@ uint32 Waypoint::GetNewGRFVariable(const
 
	/* Handle cargo variables (deprecated) */
 
	if (variable >= 0x8C && variable <= 0xEC) {
 
		switch (GB(variable - 0x8C, 0, 3)) {
 
			case 3: return INITIAL_STATION_RATING;
 
			case 4: return INVALID_STATION;
 
			default: return 0;
 
		}
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled station variable 0x%X", variable);
 

	
 
	*available = false;
 
	return UINT_MAX;
 
}
 

	
 
static const SpriteGroup *StationResolveReal(const ResolverObject *object, const RealSpriteGroup *group)
 
{
 
	const BaseStation *bst = object->u.station.st;
 
	const StationSpec *statspec = object->u.station.statspec;
 
	uint set;
 

	
 
	uint cargo = 0;
 
	CargoID cargo_type = object->u.station.cargo_type;
 

	
 
	if (bst == NULL || statspec->sclass == STAT_CLASS_WAYP) {
 
	if (bst == NULL || statspec->cls_id == STAT_CLASS_WAYP) {
 
		return group->loading[0];
 
	}
 

	
 
	const Station *st = Station::From(bst);
 

	
 
	switch (cargo_type) {
 
		case CT_INVALID:
 
		case CT_DEFAULT_NA:
 
		case CT_PURCHASE:
 
			cargo = 0;
 
			break;
 

	
 
		case CT_DEFAULT:
 
			for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
 
				cargo += st->goods[cargo_type].cargo.Count();
 
			}
 
			break;
 

	
 
		default:
 
			cargo = st->goods[cargo_type].cargo.Count();
 
			break;
 
	}
 

	
 
	if (HasBit(statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->train_station.w + st->train_station.h);