1
0
Fork 0

(svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID

release/0.6
peter1138 2007-04-11 21:04:03 +00:00
parent b47078d690
commit 69982b1f01
5 changed files with 9 additions and 7 deletions

View File

@ -2539,7 +2539,7 @@ static void StationMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount)
StationSpec *statspec = _cur_grffile->stations[stid];
statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid];
statspec->grfid = _cur_grffile->grfid;
statspec->grffile = _cur_grffile;
statspec->localidx = stid;
SetCustomStationSpec(statspec);
}

View File

@ -184,7 +184,7 @@ const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx)
for (j = 0; j < station_classes[i].stations; j++) {
const StationSpec *statspec = station_classes[i].spec[j];
if (statspec == NULL) continue;
if (statspec->grfid == grfid && statspec->localidx == localidx) return statspec;
if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) return statspec;
}
}
@ -638,7 +638,7 @@ int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec)
}
st->speclist[i].spec = statspec;
st->speclist[i].grfid = statspec->grfid;
st->speclist[i].grfid = statspec->grffile->grfid;
st->speclist[i].localidx = statspec->localidx;
}

View File

@ -28,7 +28,7 @@ DECLARE_POSTFIX_INCREMENT(StationClassID);
typedef byte *StationLayout;
struct StationSpec {
uint32 grfid; ///< ID of GRF file station belongs to.
const struct GRFFile *grffile; ///< ID of GRF file station belongs to.
int localidx; ///< Index within GRF file of station.
bool allocated; ///< Flag whether this station has been added to a station class list

View File

@ -57,6 +57,7 @@
#include "date.h"
#include "clear_map.h"
#include "fontcache.h"
#include "newgrf.h"
#include "newgrf_config.h"
#include "newgrf_house.h"
#include "player_face.h"
@ -1586,7 +1587,7 @@ bool AfterLoadGame()
if (statspec != NULL) {
wp->stat_id = _m[wp->xy].m4 + 1;
wp->grfid = statspec->grfid;
wp->grfid = statspec->grffile->grfid;
wp->localidx = statspec->localidx;
} else {
/* No custom graphics set, so set to default. */

View File

@ -22,6 +22,7 @@
#include "vehicle.h"
#include "yapf/yapf.h"
#include "date.h"
#include "newgrf.h"
enum {
MAX_WAYPOINTS_PER_TOWN = 64,
@ -181,7 +182,7 @@ void AfterLoadWaypoints()
for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
if (statspec != NULL && statspec->grfid == wp->grfid && statspec->localidx == wp->localidx) {
if (statspec != NULL && statspec->grffile->grfid == wp->grfid && statspec->localidx == wp->localidx) {
wp->stat_id = i;
break;
}
@ -250,7 +251,7 @@ int32 CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (statspec != NULL) {
wp->stat_id = p1;
wp->grfid = statspec->grfid;
wp->grfid = statspec->grffile->grfid;
wp->localidx = statspec->localidx;
} else {
/* Specified custom graphics do not exist, so use default. */