File diff r27883:ddbd33508a8a → r27884:803962be0328
src/newgrf_station.cpp
Show inline comments
 
@@ -270,49 +270,49 @@ TownScopeResolver *StationResolverObject
 
{
 
	if (this->st == nullptr) {
 
		/* Station does not exist, so we're in a purchase list or the land slope check callback. */
 
		switch (variable) {
 
			case 0x40:
 
			case 0x41:
 
			case 0x46:
 
			case 0x47:
 
			case 0x49: return 0x2110000;        // Platforms, tracks & position
 
			case 0x42: return 0;                // Rail type (XXX Get current type from GUI?)
 
			case 0x43: return GetCompanyInfo(_current_company); // Station owner
 
			case 0x44: return 2;                // PBS status
 
			case 0x67: // Land info of nearby tile
 
				if (this->axis != INVALID_AXIS && this->tile != INVALID_TILE) {
 
					TileIndex tile = this->tile;
 
					if (parameter != 0) tile = GetNearbyTile(parameter, tile, true, this->axis); // only perform if it is required
 

	
 
					Slope tileh = GetTileSlope(tile);
 
					bool swap = (this->axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
 

	
 
					return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
 
				}
 
				break;
 

	
 
			case 0xFA: return ClampTo<uint16_t>(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
 
			case 0xFA: return ClampTo<uint16_t>(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
 
		}
 

	
 
		*available = false;
 
		return UINT_MAX;
 
	}
 

	
 
	switch (variable) {
 
		/* Calculated station variables */
 
		case 0x40:
 
			if (!HasBit(_svc.valid, 0)) { _svc.v40 = GetPlatformInfoHelper(this->tile, false, false, false); SetBit(_svc.valid, 0); }
 
			return _svc.v40;
 

	
 
		case 0x41:
 
			if (!HasBit(_svc.valid, 1)) { _svc.v41 = GetPlatformInfoHelper(this->tile, true,  false, false); SetBit(_svc.valid, 1); }
 
			return _svc.v41;
 

	
 
		case 0x42: return GetTerrainType(this->tile) | (GetReverseRailTypeTranslation(GetRailType(this->tile), this->statspec->grf_prop.grffile) << 8);
 
		case 0x43: return GetCompanyInfo(this->st->owner); // Station owner
 
		case 0x44: return HasStationReservation(this->tile) ? 7 : 4; // PBS status
 
		case 0x45:
 
			if (!HasBit(_svc.valid, 2)) { _svc.v45 = GetRailContinuationInfo(this->tile); SetBit(_svc.valid, 2); }
 
			return _svc.v45;
 

	
 
		case 0x46:
 
@@ -360,49 +360,49 @@ TownScopeResolver *StationResolverObject
 
			uint32_t res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
 

	
 
			if (IsCustomStationSpecIndex(nearby_tile)) {
 
				const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
 
				res |= 1 << (ssl.grfid != grfid ? 9 : 8) | ClampTo<uint8_t>(ssl.localidx);
 
			}
 
			return res;
 
		}
 

	
 
		case 0x6A: { // GRFID of nearby station tiles
 
			TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
 

	
 
			if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF;
 
			if (!IsCustomStationSpecIndex(nearby_tile)) return 0;
 

	
 
			const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
 
			return ssl.grfid;
 
		}
 

	
 
		/* General station variables */
 
		case 0x82: return 50;
 
		case 0x84: return this->st->string_id;
 
		case 0x86: return 0;
 
		case 0xF0: return this->st->facilities;
 
		case 0xFA: return ClampTo<uint16_t>(this->st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR);
 
		case 0xFA: return ClampTo<uint16_t>(this->st->build_date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR);
 
	}
 

	
 
	return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
 
}
 

	
 
uint32_t Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
 
{
 
	switch (variable) {
 
		case 0x48: { // Accepted cargo types
 
			CargoID cargo_type;
 
			uint32_t value = 0;
 

	
 
			for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
 
				if (HasBit(this->goods[cargo_type].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(value, cargo_type);
 
			}
 
			return value;
 
		}
 

	
 
		case 0x8A: return this->had_vehicle_of_type;
 
		case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE;
 
		case 0xF2: return (this->truck_stops != nullptr) ? this->truck_stops->status : 0;
 
		case 0xF3: return (this->bus_stops != nullptr)   ? this->bus_stops->status   : 0;
 
		case 0xF6: return this->airport.flags;
 
		case 0xF7: return GB(this->airport.flags, 8, 8);