NFO proposal: Wagon attach callback for multiple sets
Moderator: Graphics Moderators
NFO proposal: Wagon attach callback for multiple sets
When multiple sets are enabled, the possibly to mix 'mismatching' vehicles is greatly increased. Callback 1D works well for internal set restrictions but is one-way only.
Therefore this proposal calls for a new callback, which is similar to 1D, but is checks both trailing and leading wagons that are being attached.
Callback 1D will be changed so that it is only called if the two vehicles to be attached are from the same NewGRF (or listed as compatible, such as UKRS and UKRS Addons). This allows existing callbacks to work properly and not have to know or care about different sets.
The new callback will only be called for vehicles from differing sets. The two vehicles will be attached, then the following happens:
* The callback for the trailing vehicle is tested but with the leading vehicle as the current vehicle.
* The callback for the leading vehicle is tested but with the trailing vehicle as the current vehicle.
* Unless both callbacks return a successful response, the vehicles will be detached.
A minor point is that a callback failure (i.e. the callback is not implemented) will behave differently depending on whether multiple sets are enabled or not:
* If multiple sets are enabled, a callback fail is treated as a no.
* If multiple sets are disabled, a callback fail is treated as a yes.
Additional variables will be needed, most likely the GRF ID. Proposals welcome.
Discuss.
Therefore this proposal calls for a new callback, which is similar to 1D, but is checks both trailing and leading wagons that are being attached.
Callback 1D will be changed so that it is only called if the two vehicles to be attached are from the same NewGRF (or listed as compatible, such as UKRS and UKRS Addons). This allows existing callbacks to work properly and not have to know or care about different sets.
The new callback will only be called for vehicles from differing sets. The two vehicles will be attached, then the following happens:
* The callback for the trailing vehicle is tested but with the leading vehicle as the current vehicle.
* The callback for the leading vehicle is tested but with the trailing vehicle as the current vehicle.
* Unless both callbacks return a successful response, the vehicles will be detached.
A minor point is that a callback failure (i.e. the callback is not implemented) will behave differently depending on whether multiple sets are enabled or not:
* If multiple sets are enabled, a callback fail is treated as a no.
* If multiple sets are disabled, a callback fail is treated as a yes.
Additional variables will be needed, most likely the GRF ID. Proposals welcome.
Discuss.
He's like, some kind of OpenTTD developer.
Re: NFO proposal: Wagon attach callback for multiple sets
In both cases the "trailing" vehicle should be the "current vehicle", as you can access the leading anyway as "related vehicle".peter1138 wrote:* The callback for the trailing vehicle is tested but with the leading vehicle as the current vehicle.
* The callback for the leading vehicle is tested but with the trailing vehicle as the current vehicle.
I assume the other callback info var will tell which one is the case. Or two callbacks?
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: NFO proposal: Wagon attach callback for multiple sets
By 'trailing vehicle' I mean the trailing vehicle of the chain that is being attached to.frosch wrote:In both cases the "trailing" vehicle should be the "current vehicle", as you can access the leading anyway as "related vehicle".peter1138 wrote:* The callback for the trailing vehicle is tested but with the leading vehicle as the current vehicle.
* The callback for the leading vehicle is tested but with the trailing vehicle as the current vehicle.
I assume the other callback info var will tell which one is the case. Or two callbacks?
By 'leading vehicle' I mean the leading vehicle of the chain that is being attached.
Related vehicle would be the leading vehicle of the whole train... at least normally...
He's like, some kind of OpenTTD developer.
Re: NFO proposal: Wagon attach callback for multiple sets
So every vehicle has to implement both halves of this callback?
I'd expect that most of the leading-vehicle tests amount to engine callbacks -- figure out what engine is pulling the train and then check the properties of the new vehicle against that of the engine. Assuming, of course, you have access to that data.
Imagine an engine, from GRF 1, that only accepts passenger cars.
Once it accepts the attachment of a passenger wagon from GRF2, who is responsible for refusing to allow Livestock Van from GRF 2 or GRF 3 to be connected?
I'd expect that most of the leading-vehicle tests amount to engine callbacks -- figure out what engine is pulling the train and then check the properties of the new vehicle against that of the engine. Assuming, of course, you have access to that data.
Imagine an engine, from GRF 1, that only accepts passenger cars.
Once it accepts the attachment of a passenger wagon from GRF2, who is responsible for refusing to allow Livestock Van from GRF 2 or GRF 3 to be connected?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: NFO proposal: Wagon attach callback for multiple sets
i might have understood you wrong, but attaching wagon from grf2 to engine of grf1 does not invalidate the callback of the engine that checks for passenger wagons, so livestock wagon from grf3 attached to the train will both check the callback of grf1-engine and grf2-wagon.
Re: NFO proposal: Wagon attach callback for multiple sets
What is the leading vehicle of the chain that is being attached? You only attach one wagon at a time. At least the existing callback acts like that.peter1138 wrote:By 'trailing vehicle' I mean the trailing vehicle of the chain that is being attached to.
By 'leading vehicle' I mean the leading vehicle of the chain that is being attached.
So when you have a front engine A with wagons B and C. Now you attach wagon D to the end.
I would expect a callback for A that can access variables of A and D, and a callback for D that can also access variables of A and D.
It seems you want to call a callback for C ?
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: NFO proposal: Wagon attach callback for multiple sets
Callback 1D already checks the callback of head engine against the wagon(s) to be attached. Adding the same thing again probably won't help?
Unless all that's needed is a couple of extra variables?
Unless all that's needed is a couple of extra variables?
He's like, some kind of OpenTTD developer.
Re: NFO proposal: Wagon attach callback for multiple sets
Need ideas quick before 0.7.0...
He's like, some kind of OpenTTD developer.
Re: NFO proposal: Wagon attach callback for multiple sets
Since Callback 1D has proved quite sufficient within grfs, why do you think a cross-grf callback needs to test different things? All we really need is an additional vehicle variable containing the grfid.peter1138 wrote:Callback 1D already checks the callback of head engine against the wagon(s) to be attached. Adding the same thing again probably won't help?
Re: NFO proposal: Wagon attach callback for multiple sets
I would go with PikkaBird's suggestion. Simple yet effective...
Who is online
Users browsing this forum: No registered users and 6 guests