1
0
Fork 0

Add: [NewGRF] Vehicle property to copy properties of an existing definition.

This simplifies creation of similar variants, but can also be used for distinct types.

Strings and Action 3-2-1 chains are not copied.
pull/12523/head
Peter Nelson 2024-04-17 21:47:41 +01:00
parent 83d99ec11d
commit 37e4942232
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 40 additions and 0 deletions

View File

@ -1334,6 +1334,16 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
SB(ei->callback_mask, 8, 8, buf->ReadByte());
break;
case 0x80: { // Copy existing train properties
uint16_t sourceid = buf->ReadWord();
Engine *source = GetNewEngine(_cur.grffile, VEH_TRAIN, sourceid, true);
if (source == nullptr) break;
*ei = source->info;
*rvi = source->u.rail;
_gted[e->index] = _gted[source->index];
break;
}
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@ -1540,6 +1550,16 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
SB(ei->callback_mask, 8, 8, buf->ReadByte());
break;
case 0x80: { // Copy existing road vehicle properties
uint16_t sourceid = buf->ReadWord();
Engine *source = GetNewEngine(_cur.grffile, VEH_ROAD, sourceid, true);
if (source == nullptr) break;
*ei = source->info;
*rvi = source->u.road;
_gted[e->index] = _gted[source->index];
break;
}
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@ -1732,6 +1752,16 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
svi->acceleration = std::max<uint8_t>(1, buf->ReadByte());
break;
case 0x80: { // Copy existing ship properties
uint16_t sourceid = buf->ReadWord();
Engine *source = GetNewEngine(_cur.grffile, VEH_SHIP, sourceid, true);
if (source == nullptr) break;
*ei = source->info;
*svi = source->u.ship;
_gted[e->index] = _gted[source->index];
break;
}
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@ -1897,6 +1927,16 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int
SB(ei->callback_mask, 8, 8, buf->ReadByte());
break;
case 0x80: { // Copy existing aircraft properties
uint16_t sourceid = buf->ReadWord();
Engine *source = GetNewEngine(_cur.grffile, VEH_AIRCRAFT, sourceid, true);
if (source == nullptr) break;
*ei = source->info;
*avi = source->u.air;
_gted[e->index] = _gted[source->index];
break;
}
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;