Codechange: Use helper to set grf_prop's grffile and grfid together. (#13612)
This commit is contained in:
@@ -649,8 +649,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16_t inte
|
||||
if (engine != EngineID::Invalid()) {
|
||||
Engine *e = Engine::Get(engine);
|
||||
if (!e->grf_prop.HasGrfFile()) {
|
||||
e->grf_prop.grfid = file->grfid;
|
||||
e->grf_prop.grffile = file;
|
||||
e->grf_prop.SetGRFFile(file);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -662,8 +661,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16_t inte
|
||||
Engine *e = Engine::Get(engine);
|
||||
|
||||
if (!e->grf_prop.HasGrfFile()) {
|
||||
e->grf_prop.grfid = file->grfid;
|
||||
e->grf_prop.grffile = file;
|
||||
e->grf_prop.SetGRFFile(file);
|
||||
GrfMsg(5, "Replaced engine at index {} for GRFID {:x}, type {}, index {}", e->index, std::byteswap(file->grfid), type, internal_id);
|
||||
}
|
||||
|
||||
@@ -681,8 +679,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16_t inte
|
||||
|
||||
/* ... it's not, so create a new one based off an existing engine */
|
||||
Engine *e = new Engine(type, internal_id);
|
||||
e->grf_prop.grfid = file->grfid;
|
||||
e->grf_prop.grffile = file;
|
||||
e->grf_prop.SetGRFFile(file);
|
||||
|
||||
/* Reserve the engine slot */
|
||||
_engine_mngr.SetID(type, internal_id, scope_grfid, std::min<uint8_t>(internal_id, _engine_counts[type]), e->index);
|
||||
@@ -2559,8 +2556,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt
|
||||
housespec->enabled = true;
|
||||
housespec->grf_prop.local_id = id;
|
||||
housespec->grf_prop.subst_id = subs_id;
|
||||
housespec->grf_prop.grfid = _cur.grffile->grfid;
|
||||
housespec->grf_prop.grffile = _cur.grffile;
|
||||
housespec->grf_prop.SetGRFFile(_cur.grffile);
|
||||
/* Set default colours for randomization, used if not overridden. */
|
||||
housespec->random_colour[0] = COLOUR_RED;
|
||||
housespec->random_colour[1] = COLOUR_BLUE;
|
||||
@@ -3472,8 +3468,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop,
|
||||
|
||||
tsp->grf_prop.local_id = id;
|
||||
tsp->grf_prop.subst_id = subs_id;
|
||||
tsp->grf_prop.grfid = _cur.grffile->grfid;
|
||||
tsp->grf_prop.grffile = _cur.grffile;
|
||||
tsp->grf_prop.SetGRFFile(_cur.grffile);
|
||||
_industile_mngr.AddEntityID(id, _cur.grffile->grfid, subs_id); // pre-reserve the tile slot
|
||||
}
|
||||
break;
|
||||
@@ -3738,8 +3733,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By
|
||||
indsp->enabled = true;
|
||||
indsp->grf_prop.local_id = id;
|
||||
indsp->grf_prop.subst_id = subs_id;
|
||||
indsp->grf_prop.grfid = _cur.grffile->grfid;
|
||||
indsp->grf_prop.grffile = _cur.grffile;
|
||||
indsp->grf_prop.SetGRFFile(_cur.grffile);
|
||||
/* If the grf industry needs to check its surrounding upon creation, it should
|
||||
* rely on callbacks, not on the original placement functions */
|
||||
indsp->check_proc = CHECK_NOTHING;
|
||||
@@ -4116,8 +4110,7 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR
|
||||
as->enabled = true;
|
||||
as->grf_prop.local_id = id;
|
||||
as->grf_prop.subst_id = subs_id;
|
||||
as->grf_prop.grfid = _cur.grffile->grfid;
|
||||
as->grf_prop.grffile = _cur.grffile;
|
||||
as->grf_prop.SetGRFFile(_cur.grffile);
|
||||
/* override the default airport */
|
||||
_airport_mngr.Add(id, _cur.grffile->grfid, subs_id);
|
||||
}
|
||||
@@ -4904,8 +4897,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop,
|
||||
|
||||
tsp->grf_prop.local_id = id;
|
||||
tsp->grf_prop.subst_id = subs_id;
|
||||
tsp->grf_prop.grfid = _cur.grffile->grfid;
|
||||
tsp->grf_prop.grffile = _cur.grffile;
|
||||
tsp->grf_prop.SetGRFFile(_cur.grffile);
|
||||
_airporttile_mngr.AddEntityID(id, _cur.grffile->grfid, subs_id); // pre-reserve the tile slot
|
||||
}
|
||||
break;
|
||||
@@ -6018,8 +6010,7 @@ static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount)
|
||||
}
|
||||
|
||||
statspec->grf_prop.SetSpriteGroup(SpriteGroupCargo::SG_DEFAULT, _cur.spritegroups[groupid]);
|
||||
statspec->grf_prop.grfid = _cur.grffile->grfid;
|
||||
statspec->grf_prop.grffile = _cur.grffile;
|
||||
statspec->grf_prop.SetGRFFile(_cur.grffile);
|
||||
statspec->grf_prop.local_id = station;
|
||||
StationClass::Assign(statspec);
|
||||
}
|
||||
@@ -6203,8 +6194,7 @@ static void ObjectMapSpriteGroup(ByteReader &buf, uint8_t idcount)
|
||||
}
|
||||
|
||||
spec->grf_prop.SetSpriteGroup(OBJECT_SPRITE_GROUP_DEFAULT, _cur.spritegroups[groupid]);
|
||||
spec->grf_prop.grfid = _cur.grffile->grfid;
|
||||
spec->grf_prop.grffile = _cur.grffile;
|
||||
spec->grf_prop.SetGRFFile(_cur.grffile);
|
||||
spec->grf_prop.local_id = object;
|
||||
}
|
||||
}
|
||||
@@ -6390,8 +6380,7 @@ static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount)
|
||||
}
|
||||
|
||||
roadstopspec->grf_prop.SetSpriteGroup(SpriteGroupCargo::SG_DEFAULT, _cur.spritegroups[groupid]);
|
||||
roadstopspec->grf_prop.grfid = _cur.grffile->grfid;
|
||||
roadstopspec->grf_prop.grffile = _cur.grffile;
|
||||
roadstopspec->grf_prop.SetGRFFile(_cur.grffile);
|
||||
roadstopspec->grf_prop.local_id = roadstop;
|
||||
RoadStopClass::Assign(roadstopspec);
|
||||
}
|
||||
@@ -6442,7 +6431,7 @@ static void BadgeMapSpriteGroup(ByteReader &buf, uint8_t idcount)
|
||||
|
||||
auto &badge = *GetBadge(found->second);
|
||||
badge.grf_prop.SetSpriteGroup(GSF_END, _cur.spritegroups[groupid]);
|
||||
badge.grf_prop.grffile = _cur.grffile;
|
||||
badge.grf_prop.SetGRFFile(_cur.grffile);
|
||||
badge.grf_prop.local_id = local_id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user