NFO proposal: Wagon attach callback for multiple sets

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

NFO proposal: Wagon attach callback for multiple sets

Post by peter1138 »

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.
He's like, some kind of OpenTTD developer.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: NFO proposal: Wagon attach callback for multiple sets

Post by DJ Nekkid »

looks good :)
Member of the
ImageImage
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NFO proposal: Wagon attach callback for multiple sets

Post by frosch »

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.
In both cases the "trailing" vehicle should be the "current vehicle", as you can access the leading anyway as "related vehicle".

I assume the other callback info var will tell which one is the case. Or two callbacks?
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: NFO proposal: Wagon attach callback for multiple sets

Post by peter1138 »

frosch wrote:
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.
In both cases the "trailing" vehicle should be the "current vehicle", as you can access the leading anyway as "related vehicle".

I assume the other callback info var will tell which one is the case. Or two callbacks?
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.
Related vehicle would be the leading vehicle of the whole train... at least normally...
He's like, some kind of OpenTTD developer.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: NFO proposal: Wagon attach callback for multiple sets

Post by DaleStan »

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?
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
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: NFO proposal: Wagon attach callback for multiple sets

Post by Eddi »

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.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NFO proposal: Wagon attach callback for multiple sets

Post by frosch »

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.
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.

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 ?
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: NFO proposal: Wagon attach callback for multiple sets

Post by peter1138 »

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?
He's like, some kind of OpenTTD developer.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: NFO proposal: Wagon attach callback for multiple sets

Post by peter1138 »

Need ideas quick before 0.7.0... ;)
He's like, some kind of OpenTTD developer.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: NFO proposal: Wagon attach callback for multiple sets

Post by PikkaBird »

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?
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.
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: NFO proposal: Wagon attach callback for multiple sets

Post by Zephyris »

I would go with PikkaBird's suggestion. Simple yet effective...
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 7 guests