Implement NewGRF road stop root sprite group selection

pull/374/head
Jonathan G Rennison 3 years ago
parent 1084bb8566
commit a69eba31fe

@ -5849,7 +5849,7 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype)
}
}
/* Special cargo types for purchase list and stations */
if (feature == GSF_STATIONS && ctype == 0xFE) return CT_DEFAULT_NA;
if ((feature == GSF_STATIONS || feature == GSF_ROADSTOPS) && ctype == 0xFE) return CT_DEFAULT_NA;
if (ctype == 0xFF) return CT_PURCHASE;
if (_cur.grffile->cargo_list.size() == 0) {

@ -112,8 +112,31 @@ RoadStopResolverObject::RoadStopResolverObject(const RoadStopSpec *roadstopspec,
{
this->town_scope = nullptr;
this->root_spritegroup = (st == nullptr && roadstopspec->grf_prop.spritegroup[CT_DEFAULT] != nullptr)
? roadstopspec->grf_prop.spritegroup[CT_DEFAULT] : roadstopspec->grf_prop.spritegroup[CT_DEFAULT];
CargoID ctype = CT_DEFAULT_NA;
if (st == nullptr) {
/* No station, so we are in a purchase list */
ctype = CT_PURCHASE;
} else if (Station::IsExpected(st)) {
const Station *station = Station::From(st);
/* Pick the first cargo that we have waiting */
for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (roadstopspec->grf_prop.spritegroup[cs->Index()] != nullptr &&
station->goods[cs->Index()].cargo.TotalCount() > 0) {
ctype = cs->Index();
break;
}
}
}
if (roadstopspec->grf_prop.spritegroup[ctype] == nullptr) {
ctype = CT_DEFAULT;
}
/* Remember the cargo type we've picked */
this->roadstop_scope.cargo_type = ctype;
this->root_spritegroup = roadstopspec->grf_prop.spritegroup[ctype];
}
RoadStopResolverObject::~RoadStopResolverObject()

@ -110,8 +110,13 @@ struct RoadStopResolverObject : public ResolverObject {
/** Road stop specification. */
struct RoadStopSpec {
// We'll have a default and a fence "cargo". Or maybe just a default one?
GRFFilePropsBase<NUM_CARGO + 1> grf_prop;
/**
* Properties related the the grf file.
* NUM_CARGO real cargo plus three pseudo cargo sprite groups.
* Used for obtaining the sprite offset of custom sprites, and for
* evaluating callbacks.
*/
GRFFilePropsBase<NUM_CARGO + 3> grf_prop;
RoadStopClassID cls_id; ///< The class to which this spec belongs.
int spec_id; ///< The ID of this spec inside the class.
StringID name; ///< Name of this stop

Loading…
Cancel
Save