(svn r20435) -Codechange: move spritegroup to GRFFilePropsBase and prepare it for more spritegroups

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 14 years ago
parent 21e4e7ce06
commit ca7a067b7a

@ -3925,7 +3925,7 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8 idcount)
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(ByteReader *buf, uint8 idcount)
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(ByteReader *buf, uint8 idcount)
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(ByteReader *buf, uint8 idcount)
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(ByteReader *buf, uint8 idcount)
continue;
}
airtsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
airtsp->grf_prop.spritegroup[0] = _cur_grffile->spritegroups[groupid];
}
}

@ -223,7 +223,7 @@ SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout)
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 callback, uint32 param1, uint32 param2, Sta
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 AirportSpec *as, byte layout, uint16 callb
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());

@ -251,7 +251,7 @@ uint16 GetAirportTileCallback(CallbackID callback, uint32 param1, uint32 param2,
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, Station *st, StationGfx gfx, const Airport
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;
}

@ -135,25 +135,31 @@ uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
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
};

@ -408,7 +408,7 @@ uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, House
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, HouseID house_id)
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 tile, HouseTrigger trigger, byte base_rando
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();

@ -397,7 +397,7 @@ uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, In
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 CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
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 *ind, int reason)
}
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;

@ -212,7 +212,7 @@ uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2
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, Industry *i, IndustryGfx gfx, const Indus
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(TileIndex tile, IndustryTileTrigger trigger, I
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();

@ -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.

Loading…
Cancel
Save