Changeset - r15725:0c28e29aa5d4
[Not reviewed]
master
0 7 0
rubidium - 14 years ago 2010-08-07 21:10:57
rubidium@openttd.org
(svn r20402) -Codechange: rename the airport/station class id to something slightly more generic
7 files changed with 13 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_rail.cpp
Show inline comments
 
@@ -166,25 +166,25 @@
 
	if (direction == RAILTRACK_NW_SE) p1 |= 1 << 4;
 
	if (station_id != AIStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
 

	
 
	const GRFFile *file;
 
	uint16 res = GetAiPurchaseCallbackResult(GSF_STATIONS, cargo_id, 0, source_industry, goal_industry, min(255, distance / 2), AICE_STATION_GET_STATION_ID, source_station ? 0 : 1, min(15, num_platforms) << 4 | min(15, platform_length), &file);
 
	uint32 p2 = (AIStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16;
 
	if (res != CALLBACK_FAILED) {
 
		int index = 0;
 
		const StationSpec *spec = GetCustomStationSpecByGrf(file->grfid, res, &index);
 
		if (spec == NULL) {
 
			DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
 
		} else {
 
			p2 |= spec->sclass | index << 8;
 
			p2 |= spec->cls_id | index << 8;
 
		}
 

	
 
	}
 
	return AIObject::DoCommand(tile, p1, p2, CMD_BUILD_RAIL_STATION);
 
}
 

	
 
/* static */ bool AIRail::BuildRailWaypoint(TileIndex tile)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, IsRailTile(tile));
 
	EnforcePrecondition(false, GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE);
 
	EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
src/newgrf.cpp
Show inline comments
 
@@ -1142,25 +1142,25 @@ static ChangeInfoResult StationChangeInf
 
			return CIR_INVALID_ID;
 
		}
 

	
 
		switch (prop) {
 
			case 0x08: { // Class ID
 
				StationSpec **spec = &_cur_grffile->stations[stid + i];
 

	
 
				/* Property 0x08 is special; it is where the station is allocated */
 
				if (*spec == NULL) *spec = CallocT<StationSpec>(1);
 

	
 
				/* Swap classid because we read it in BE meaning WAYP or DFLT */
 
				uint32 classid = buf->ReadDWord();
 
				(*spec)->sclass = AllocateStationClass(BSWAP32(classid));
 
				(*spec)->cls_id = AllocateStationClass(BSWAP32(classid));
 
				break;
 
			}
 

	
 
			case 0x09: // Define sprite layout
 
				statspec->tiles = buf->ReadExtendedByte();
 
				statspec->renderdata = CallocT<DrawTileSprites>(statspec->tiles);
 
				statspec->copied_renderdata = false;
 

	
 
				for (uint t = 0; t < statspec->tiles; t++) {
 
					DrawTileSprites *dts = &statspec->renderdata[t];
 
					uint seq_count = 0;
 

	
 
@@ -4261,26 +4261,26 @@ static void FeatureNewName(ByteReader *b
 
			case GSF_INDUSTRIES: {
 
				AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED);
 
				break;
 
			}
 

	
 
			case GSF_HOUSES:
 
			default:
 
				switch (GB(id, 8, 8)) {
 
					case 0xC4: // Station class name
 
						if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) {
 
							grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8));
 
						} else {
 
							StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass;
 
							SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED));
 
							StationClassID cls_id = _cur_grffile->stations[GB(id, 0, 8)]->cls_id;
 
							SetStationClassName(cls_id, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED));
 
						}
 
						break;
 

	
 
					case 0xC5: // Station name
 
						if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) {
 
							grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8));
 
						} else {
 
							_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED);
 
						}
 
						break;
 

	
 
					case 0xC7: // Airporttile name
src/newgrf_airport.cpp
Show inline comments
 
@@ -144,26 +144,26 @@ uint GetNumAirportClasses()
 
uint GetNumAirportsInClass(AirportClassID id)
 
{
 
	assert(id < APC_MAX);
 
	return _airport_classes[id].airports;
 
}
 

	
 
/**
 
 * Tie an airport spec to its airport class.
 
 * @param statspec The airport spec.
 
 */
 
static void BindAirportSpecToClass(AirportSpec *as)
 
{
 
	assert(as->aclass < APC_MAX);
 
	AirportClass *airport_class = &_airport_classes[as->aclass];
 
	assert(as->cls_id < APC_MAX);
 
	AirportClass *airport_class = &_airport_classes[as->cls_id];
 

	
 
	int i = airport_class->airports++;
 
	airport_class->spec = ReallocT(airport_class->spec, airport_class->airports);
 

	
 
	airport_class->spec[i] = as;
 
}
 

	
 
/**
 
 * Tie all airportspecs to their class.
 
 */
 
void BindAirportSpecs()
 
{
src/newgrf_airport.h
Show inline comments
 
@@ -63,25 +63,25 @@ struct AirportSpec {
 
	Direction *rotation;                   ///< the rotation of each tiletable
 
	byte num_table;                        ///< number of elements in the table
 
	const HangarTileTable *depot_table;    ///< gives the position of the depots on the airports
 
	byte nof_depots;                       ///< the number of hangar tiles in this airport
 
	byte size_x;                           ///< size of airport in x direction
 
	byte size_y;                           ///< size of airport in y direction
 
	byte noise_level;                      ///< noise that this airport generates
 
	byte catchment;                        ///< catchment area of this airport
 
	Year min_year;                         ///< first year the airport is available
 
	Year max_year;                         ///< last year the airport is available
 
	StringID name;                         ///< name of this airport
 
	TTDPAirportType ttd_airport_type;      ///< ttdpatch airport type (Small/Large/Helipad/Oilrig)
 
	AirportClassID aclass;                 ///< the class to which this airport type belongs
 
	AirportClassID cls_id;                 ///< the class to which this airport type belongs
 
	SpriteID preview_sprite;               ///< preview sprite for this airport
 
	/* Newgrf data */
 
	bool enabled;                          ///< entity still avaible (by default true).newgrf can disable it, though
 
	struct GRFFileProps grf_prop;          ///< properties related the the grf file
 

	
 
	static const AirportSpec *Get(byte type);
 
	static AirportSpec *GetWithoutOverride(byte type);
 

	
 
	bool IsAvailable() const;
 

	
 
	static void ResetAirports();
 

	
src/newgrf_station.cpp
Show inline comments
 
@@ -167,26 +167,26 @@ uint GetNumCustomStations(StationClassID
 
/**
 
 * 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.
 
@@ -597,25 +597,25 @@ uint32 Waypoint::GetNewGRFVariable(const
 
	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;
 

	
src/newgrf_station.h
Show inline comments
 
@@ -42,26 +42,26 @@ enum StationSpecFlags {
 
};
 

	
 
/* Station layout for given dimensions - it is a two-dimensional array
 
 * where index is computed as (x * platforms) + platform. */
 
typedef byte *StationLayout;
 

	
 
/** Station specification. */
 
struct StationSpec {
 
	GRFFilePropsBase grf_prop; ///< Properties related the the grf file
 

	
 
	bool allocated; ///< Flag whether this station has been added to a station class list
 

	
 
	StationClassID sclass; ///< The class to which this spec belongs.
 
	StringID name; ///< Name of this station.
 
	StationClassID cls_id;    ///< The class to which this spec belongs.
 
	StringID name;            ///< Name of this station.
 

	
 
	/**
 
	 * Bitmask of number of platforms available for the station.
 
	 * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 platforms.
 
	 */
 
	byte disallowed_platforms;
 
	/**
 
	 * Bitmask of platform lengths available for the station.
 
	 * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 tiles long.
 
	 */
 
	byte disallowed_lengths;
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -2792,25 +2792,25 @@ static void GetTileDesc_Station(TileInde
 
			if (tram_owner != INVALID_OWNER) {
 
				td->owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
 
				td->owner[i] = tram_owner;
 
			}
 
		}
 
	}
 
	td->build_date = BaseStation::GetByTile(tile)->build_date;
 

	
 
	if (HasStationTileRail(tile)) {
 
		const StationSpec *spec = GetStationSpec(tile);
 

	
 
		if (spec != NULL) {
 
			td->station_class = GetStationClassName(spec->sclass);
 
			td->station_class = GetStationClassName(spec->cls_id);
 
			td->station_name  = spec->name;
 

	
 
			if (spec->grf_prop.grffile != NULL) {
 
				const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grffile->grfid);
 
				td->grf = gc->GetName();
 
			}
 
		}
 

	
 
		const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
 
		td->rail_speed = rti->max_speed;
 
	}
 

	
0 comments (0 inline, 0 general)