(svn r20400) -Codechange: let StationSpec use GRFFilePropsBase

pull/155/head
rubidium 14 years ago
parent ecb6d8cf74
commit 3285c6ab58

@ -3886,8 +3886,8 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount)
}
statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid];
statspec->grffile = _cur_grffile;
statspec->localidx = stations[i];
statspec->grf_prop.grffile = _cur_grffile;
statspec->grf_prop.local_id = stations[i];
SetCustomStationSpec(statspec);
}
}

@ -217,7 +217,7 @@ const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *i
for (j = 0; j < _station_classes[i].stations; j++) {
const StationSpec *statspec = _station_classes[i].spec[j];
if (statspec == NULL) continue;
if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) {
if (statspec->grf_prop.grffile->grfid == grfid && statspec->grf_prop.local_id == localidx) {
if (index != NULL) *index = j;
return statspec;
}
@ -439,7 +439,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
if (!HasBit(_svc.valid, 1)) { _svc.v41 = GetPlatformInfoHelper(tile, true, false, false); SetBit(_svc.valid, 1); }
return _svc.v41;
case 0x42: return GetTerrainType(tile) | (GetReverseRailTypeTranslation(GetRailType(tile), object->u.station.statspec->grffile) << 8);
case 0x42: return GetTerrainType(tile) | (GetReverseRailTypeTranslation(GetRailType(tile), object->u.station.statspec->grf_prop.grffile) << 8);
case 0x43: return st->owner; // Station owner
case 0x44: return HasStationReservation(tile) ? 7 : 4; // PBS status
case 0x45:
@ -529,7 +529,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
/* Handle cargo variables with parameter, 0x60 to 0x65 */
if (variable >= 0x60 && variable <= 0x65) {
CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grf_prop.grffile);
if (c == CT_INVALID) return 0;
const GoodsEntry *ge = &this->goods[c];
@ -668,7 +668,7 @@ static void NewStationResolver(ResolverObject *res, const StationSpec *statspec,
res->trigger = 0;
res->reseed = 0;
res->count = 0;
res->grffile = (statspec != NULL ? statspec->grffile : NULL);
res->grffile = (statspec != NULL ? statspec->grf_prop.grffile : NULL);
}
static const SpriteGroup *ResolveStation(ResolverObject *object)
@ -813,8 +813,8 @@ int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exe
}
st->speclist[i].spec = statspec;
st->speclist[i].grfid = statspec->grffile->grfid;
st->speclist[i].localidx = statspec->localidx;
st->speclist[i].grfid = statspec->grf_prop.grffile->grfid;
st->speclist[i].localidx = statspec->grf_prop.local_id;
}
return i;
@ -989,7 +989,7 @@ void AnimateStationTile(TileIndex tile)
/* If the lower 7 bits of the upper byte of the callback
* result are not empty, it is a sound effect. */
if (GB(callback, 8, 7) != 0) PlayTileSound(ss->grffile, GB(callback, 8, 7), tile);
if (GB(callback, 8, 7) != 0) PlayTileSound(ss->grf_prop.grffile, GB(callback, 8, 7), tile);
}
}
@ -1027,7 +1027,7 @@ static void ChangeStationAnimationFrame(const StationSpec *ss, const BaseStation
/* If the lower 7 bits of the upper byte of the callback
* result are not empty, it is a sound effect. */
if (GB(callback, 8, 7) != 0) PlayTileSound(ss->grffile, GB(callback, 8, 7), tile);
if (GB(callback, 8, 7) != 0) PlayTileSound(ss->grf_prop.grffile, GB(callback, 8, 7), tile);
}
void StationAnimationTrigger(const BaseStation *st, TileIndex tile, StatAnimTrigger trigger, CargoID cargo_type)
@ -1056,7 +1056,7 @@ void StationAnimationTrigger(const BaseStation *st, TileIndex tile, StatAnimTrig
if (cargo_type == CT_INVALID) {
cargo = CT_INVALID;
} else {
cargo = GetReverseCargoTranslation(cargo_type, ss->grffile);
cargo = GetReverseCargoTranslation(cargo_type, ss->grf_prop.grffile);
}
ChangeStationAnimationFrame(ss, st, tile, random_bits, trigger, cargo);
}

@ -13,6 +13,7 @@
#define NEWGRF_STATION_H
#include "newgrf_callbacks.h"
#include "newgrf_commons.h"
#include "sprite.h"
#include "direction_type.h"
#include "cargo_type.h"
@ -46,8 +47,7 @@ typedef byte *StationLayout;
/** Station specification. */
struct StationSpec {
const struct GRFFile *grffile; ///< ID of GRF file station belongs to.
int localidx; ///< Index within GRF file of station.
GRFFilePropsBase grf_prop; ///< Properties related the the grf file
bool allocated; ///< Flag whether this station has been added to a station class list

@ -85,7 +85,7 @@ void MoveWaypointsToBaseStations()
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
for (uint i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
if (statspec != NULL && statspec->grffile->grfid == wp->grfid && statspec->localidx == wp->localidx) {
if (statspec != NULL && statspec->grf_prop.grffile->grfid == wp->grfid && statspec->grf_prop.local_id == wp->localidx) {
wp->spec = statspec;
break;
}

@ -2804,8 +2804,8 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
td->station_class = GetStationClassName(spec->sclass);
td->station_name = spec->name;
if (spec->grffile != NULL) {
const GRFConfig *gc = GetGRFConfig(spec->grffile->grfid);
if (spec->grf_prop.grffile != NULL) {
const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grffile->grfid);
td->grf = gc->GetName();
}
}

Loading…
Cancel
Save