Changeset - r17749:98b0b5178024
[Not reviewed]
master
0 1 0
terkhen - 13 years ago 2011-06-04 21:24:23
terkhen@openttd.org
(svn r22543) -Feature: [NewGRF] Support for station variable 0x69.
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/newgrf_station.cpp
Show inline comments
 
@@ -320,25 +320,25 @@ static uint32 StationGetVariable(const R
 
		case 0x47:
 
			if (!HasBit(_svc.valid, 4)) { _svc.v47 = GetPlatformInfoHelper(tile, true,  false, true); SetBit(_svc.valid, 4); }
 
			return _svc.v47;
 

	
 
		case 0x49:
 
			if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SetBit(_svc.valid, 5); }
 
			return _svc.v49;
 

	
 
		case 0x4A: // Animation frame of tile
 
			return GetAnimationFrame(tile);
 

	
 
		/* Variables which use the parameter */
 
		/* Variables 0x60 to 0x65 are handled separately below */
 
		/* Variables 0x60 to 0x65 and 0x69 are handled separately below */
 
		case 0x66: // Animation frame of nearby tile
 
			if (parameter != 0) tile = GetNearbyTile(parameter, tile);
 
			return st->TileBelongsToRailStation(tile) ? GetAnimationFrame(tile) : UINT_MAX;
 

	
 
		case 0x67: { // Land info of nearby tile
 
			Axis axis = GetRailStationAxis(tile);
 

	
 
			if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
 

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

	
 
@@ -385,38 +385,39 @@ uint32 Station::GetNewGRFVariable(const 
 
			}
 
			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 != NULL) ? this->truck_stops->status : 0;
 
		case 0xF3: return (this->bus_stops != NULL)   ? this->bus_stops->status   : 0;
 
		case 0xF6: return this->airport.flags;
 
		case 0xF7: return GB(this->airport.flags, 8, 8);
 
	}
 

	
 
	/* Handle cargo variables with parameter, 0x60 to 0x65 */
 
	if (variable >= 0x60 && variable <= 0x65) {
 
	/* Handle cargo variables with parameter, 0x60 to 0x65 and 0x69 */
 
	if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
 
		CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grf_prop.grffile);
 

	
 
		if (c == CT_INVALID) return 0;
 
		const GoodsEntry *ge = &this->goods[c];
 

	
 
		switch (variable) {
 
			case 0x60: return min(ge->cargo.Count(), 4095);
 
			case 0x61: return ge->days_since_pickup;
 
			case 0x62: return ge->rating;
 
			case 0x63: return ge->cargo.DaysInTransit();
 
			case 0x64: return ge->last_speed | (ge->last_age << 8);
 
			case 0x65: return GB(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1) << 3;
 
			case 0x69: return GB(ge->acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED, 4);
 
		}
 
	}
 

	
 
	/* Handle cargo variables (deprecated) */
 
	if (variable >= 0x8C && variable <= 0xEC) {
 
		const GoodsEntry *g = &this->goods[GB(variable - 0x8C, 3, 4)];
 
		switch (GB(variable - 0x8C, 0, 3)) {
 
			case 0: return g->cargo.Count();
 
			case 1: return GB(min(g->cargo.Count(), 4095), 0, 4) | (GB(g->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
 
			case 2: return g->days_since_pickup;
 
			case 3: return g->rating;
 
			case 4: return g->cargo.Source();
0 comments (0 inline, 0 general)