Hi all, I just had an idea and wanted some clarification about maintaining backwards compatibility:
If I explicitly define my vehicle ids, is it safe to add new vehicles 'in front' of existing ones, or should I always add new vehicles to the end of the list no matter what?
I ask because when changing sensitive properties, the only option to maintain backwards compatibility is to create a new vehicle and mark the old one as unavailable. That's fine, but after changing properties on many vehicles multiple times, the end of the vehicle list becomes a cluttered mess, and I'd like my NML code to remain easily readable. So if it's possible (i.e. won't cause problems), I was thinking of just inserting those 'new' vehicles right below the one I'm 'replacing', obviously with a new vehicle id, instead of just adding each new vehicle to the end of the list haphazardly. I just want to make sure it's safe before doing it.
Also on a related note, do you have to use all ids sequentially, ie. 00, 01, 02, 03... etc, or can you define them in intervals like 00, 10, 20, 30... and then later add vehicles with ids in-between? Would that be safe, or no?
Backwards Compatibility and Vehicle IDs
Moderator: Graphics Moderators
-
- Tycoon
- Posts: 2781
- Joined: 22 Feb 2011 18:34
Re: Backwards Compatibility and Vehicle IDs
That should indeed be possible, but if people upgrade from multiple versions back, they might get some errors because the ID already was in use in their version, but now is replaced by a different vehicle.Andrew350 wrote:If I explicitly define my vehicle ids, is it safe to add new vehicles 'in front' of existing ones, or should I always add new vehicles to the end of the list no matter what?
If you define them in a separate file (like 2cc TrainsInNML does for example), things still keep quite readable, it just becomes a long list.I ask because when changing sensitive properties, the only option to maintain backwards compatibility is to create a new vehicle and mark the old one as unavailable. That's fine, but after changing properties on many vehicles multiple times, the end of the vehicle list becomes a cluttered mess, and I'd like my NML code to remain easily readable.
You can define them as you wish, as long as you do not have the same ID for different vehicles. In 2cc TrainsInNML, I reserved blocks of 1000 IDs for different vehicle types, also because I use the IDs to check if vehicles may be attached to other vehicles in the set. You can check the file here.Also on a related note, do you have to use all ids sequentially, ie. 00, 01, 02, 03... etc, or can you define them in intervals like 00, 10, 20, 30... and then later add vehicles with ids in-between? Would that be safe, or no?
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Backwards Compatibility and Vehicle IDs
If you simply add new vehicles and keep the old vehicles with their IDs and properties around, if you do not change the meaning of NewGRF parameters, then the NewGRF will be compatible with old(er) versions. However at some stage you got the same vehicle defined several times in the code, just with slightly varying properties - which doesn't exactly help maintaining the code
VehicleIDs do not need to be sequentially in the code and can have any gap you want. As long as the IDs are un-touched you can insert new vehicles at any place in the code as well.
VehicleIDs do not need to be sequentially in the code and can have any gap you want. As long as the IDs are un-touched you can insert new vehicles at any place in the code as well.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Backwards Compatibility and Vehicle IDs
Awesome! Now I just wish I had thought to do this from the beginning.
Thanks guys
Thanks guys
Who is online
Users browsing this forum: No registered users and 6 guests