Changeset - r15751:f4fe02ef4406
[Not reviewed]
master
0 8 0
rubidium - 14 years ago 2010-08-10 15:49:35
rubidium@openttd.org
(svn r20435) -Codechange: move spritegroup to GRFFilePropsBase and prepare it for more spritegroups
8 files changed with 37 insertions and 31 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -3925,7 +3925,7 @@ static void TownHouseMapSpriteGroup(Byte
 
			continue;
 
		}
 

	
 
		hs->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
		hs->grf_prop.spritegroup[0] = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
@@ -3956,7 +3956,7 @@ static void IndustryMapSpriteGroup(ByteR
 
			continue;
 
		}
 

	
 
		indsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
		indsp->grf_prop.spritegroup[0] = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
@@ -3987,7 +3987,7 @@ static void IndustrytileMapSpriteGroup(B
 
			continue;
 
		}
 

	
 
		indtsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
		indtsp->grf_prop.spritegroup[0] = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
@@ -4075,7 +4075,7 @@ static void AirportMapSpriteGroup(ByteRe
 
			continue;
 
		}
 

	
 
		as->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
		as->grf_prop.spritegroup[0] = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
@@ -4106,7 +4106,7 @@ static void AirportTileMapSpriteGroup(By
 
			continue;
 
		}
 

	
 
		airtsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
		airtsp->grf_prop.spritegroup[0] = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
src/newgrf_airport.cpp
Show inline comments
 
@@ -223,7 +223,7 @@ SpriteID GetCustomAirportSprite(const Ai
 

	
 
	NewAirportResolver(&object, INVALID_TILE, NULL, as->GetIndex(), layout);
 

	
 
	group = SpriteGroup::Resolve(as->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(as->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return as->preview_sprite;
 

	
 
	return group->GetResult();
 
@@ -238,7 +238,7 @@ uint16 GetAirportCallback(CallbackID cal
 
	object.callback_param1 = param1;
 
	object.callback_param2 = param2;
 

	
 
	const SpriteGroup *group = SpriteGroup::Resolve(st->airport.GetSpec()->grf_prop.spritegroup, &object);
 
	const SpriteGroup *group = SpriteGroup::Resolve(st->airport.GetSpec()->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
@@ -252,7 +252,7 @@ StringID GetAirportTextCallback(const Ai
 
	NewAirportResolver(&object, INVALID_TILE, NULL, as->GetIndex(), layout);
 
	object.callback = (CallbackID)callback;
 

	
 
	group = SpriteGroup::Resolve(as->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(as->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return STR_UNDEFINED;
 

	
 
	return GetGRFStringID(as->grf_prop.grffile->grfid, 0xD000 + group->GetResult());
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -251,7 +251,7 @@ uint16 GetAirportTileCallback(CallbackID
 
	object.callback_param1 = param1;
 
	object.callback_param2 = param2;
 

	
 
	group = SpriteGroup::Resolve(AirportTileSpec::Get(gfx_id)->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(AirportTileSpec::Get(gfx_id)->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
@@ -293,7 +293,7 @@ bool DrawNewAirportTile(TileInfo *ti, St
 

	
 
	AirportTileResolver(&object, gfx, ti->tile, st);
 

	
 
	group = SpriteGroup::Resolve(airts->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(airts->grf_prop.spritegroup[0], &object);
 
	if (group == NULL || group->type != SGT_TILELAYOUT) {
 
		return false;
 
	}
src/newgrf_commons.h
Show inline comments
 
@@ -135,25 +135,31 @@ uint32 GetTerrainType(TileIndex tile, Ti
 
TileIndex GetNearbyTile(byte parameter, TileIndex tile);
 
uint32 GetNearbyTileInformation(TileIndex tile);
 

	
 
/** Data related to the handling of grf files. */
 
/**
 
 * Data related to the handling of grf files.
 
 * @tparam Tcnt Number of spritegroups
 
 */
 
template <size_t Tcnt>
 
struct GRFFilePropsBase {
 
	/** Set all data constructor for the props. */
 
	GRFFilePropsBase(uint local_id, const struct GRFFile *grffile) : local_id(local_id), grffile(grffile) {}
 
	/** Simple constructor for the props. */
 
	GRFFilePropsBase() {}
 
	uint16 local_id;                      ///< id defined by the grf file for this entity
 
	const struct GRFFile *grffile;        ///< grf file that introduced this entity
 
	/* The lack of constructor means the default zero-ing constructor is used. */
 
	uint16 local_id;                             ///< id defined by the grf file for this entity
 
	const struct GRFFile *grffile;               ///< grf file that introduced this entity
 
	const struct SpriteGroup *spritegroup[Tcnt]; ///< pointer to the different sprites of the entity
 
};
 

	
 
/** Data related to the handling of grf files. */
 
struct GRFFileProps : GRFFilePropsBase {
 
struct GRFFileProps : GRFFilePropsBase<1> {
 
	/** Set all default data constructor for the props. */
 
	GRFFileProps(uint16 subst_id) :
 
			GRFFilePropsBase(0, NULL), subst_id(subst_id), spritegroup(NULL), override(subst_id) {}
 
			GRFFilePropsBase<1>(), subst_id(subst_id), override(subst_id)
 
	{
 
		/* Check whether the constructor did comply with the specs. */
 
		assert(this->spritegroup[0] == NULL);
 
	}
 

	
 
	/** Simple constructor for the props. */
 
	GRFFileProps() : GRFFilePropsBase() {}
 
	GRFFileProps() : GRFFilePropsBase<1>() {}
 
	uint16 subst_id;
 
	struct SpriteGroup *spritegroup;      ///< pointer to the different sprites of the entity
 
	uint16 override;                      ///< id of the entity been replaced by
 
};
 

	
src/newgrf_house.cpp
Show inline comments
 
@@ -408,7 +408,7 @@ uint16 GetHouseCallback(CallbackID callb
 
	object.u.house.not_yet_constructed = not_yet_constructed;
 
	object.u.house.initial_random_bits = initial_random_bits;
 

	
 
	group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
@@ -459,7 +459,7 @@ void DrawNewHouseTile(TileInfo *ti, Hous
 

	
 
	NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile));
 

	
 
	group = SpriteGroup::Resolve(hs->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(hs->grf_prop.spritegroup[0], &object);
 
	if (group == NULL || group->type != SGT_TILELAYOUT) {
 
		return;
 
	} else {
 
@@ -639,7 +639,7 @@ static void DoTriggerHouse(TileIndex til
 
	object.callback = CBID_RANDOM_TRIGGER;
 
	object.trigger = trigger;
 

	
 
	const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup, &object);
 
	const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return;
 

	
 
	byte new_random_bits = Random();
src/newgrf_industries.cpp
Show inline comments
 
@@ -397,7 +397,7 @@ uint16 GetIndustryCallback(CallbackID ca
 
	object.callback_param1 = param1;
 
	object.callback_param2 = param2;
 

	
 
	group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
@@ -483,7 +483,7 @@ CommandCost CheckIfCallBackAllowsCreatio
 
	object.callback = CBID_INDUSTRY_LOCATION;
 
	_industry_creation_random_bits = seed;
 

	
 
	group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], &object);
 

	
 
	/* Unlike the "normal" cases, not having a valid result means we allow
 
	 * the building of the industry, as that's how it's done in TTDP. */
 
@@ -552,7 +552,7 @@ void IndustryProductionCallback(Industry
 
		}
 

	
 
		SB(object.callback_param2, 8, 16, loop);
 
		const SpriteGroup *tgroup = SpriteGroup::Resolve(spec->grf_prop.spritegroup, &object);
 
		const SpriteGroup *tgroup = SpriteGroup::Resolve(spec->grf_prop.spritegroup[0], &object);
 
		if (tgroup == NULL || tgroup->type != SGT_INDUSTRY_PRODUCTION) break;
 
		const IndustryProductionSpriteGroup *group = (const IndustryProductionSpriteGroup *)tgroup;
 

	
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -212,7 +212,7 @@ uint16 GetIndustryTileCallback(CallbackI
 
	object.callback_param1 = param1;
 
	object.callback_param2 = param2;
 

	
 
	group = SpriteGroup::Resolve(GetIndustryTileSpec(gfx_id)->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(GetIndustryTileSpec(gfx_id)->grf_prop.spritegroup[0], &object);
 
	if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
@@ -236,7 +236,7 @@ bool DrawNewIndustryTile(TileInfo *ti, I
 

	
 
	NewIndustryTileResolver(&object, gfx, ti->tile, i);
 

	
 
	group = SpriteGroup::Resolve(inds->grf_prop.spritegroup, &object);
 
	group = SpriteGroup::Resolve(inds->grf_prop.spritegroup[0], &object);
 
	if (group == NULL || group->type != SGT_TILELAYOUT) {
 
		return false;
 
	} else {
 
@@ -426,7 +426,7 @@ static void DoTriggerIndustryTile(TileIn
 
	object.callback = CBID_RANDOM_TRIGGER;
 
	object.trigger = trigger;
 

	
 
	const SpriteGroup *group = SpriteGroup::Resolve(itspec->grf_prop.spritegroup, &object);
 
	const SpriteGroup *group = SpriteGroup::Resolve(itspec->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return;
 

	
 
	byte new_random_bits = Random();
src/newgrf_station.h
Show inline comments
 
@@ -47,7 +47,7 @@ typedef byte *StationLayout;
 

	
 
/** Station specification. */
 
struct StationSpec {
 
	GRFFilePropsBase grf_prop; ///< Properties related the the grf file
 
	GRFFilePropsBase<0> grf_prop; ///< Properties related the the grf file
 
	StationClassID cls_id;     ///< The class to which this spec belongs.
 
	StringID name;             ///< Name of this station.
 

	
0 comments (0 inline, 0 general)