It's not really a critique of your newgrf design choice Snail
No offense taken, we just have totally opposite ideas. You don't mind having a long purchase list, while I find it fine to use CB36 to change a vehicle's properties.
The fact we think each other's approach is silly is irrelevant
we just need to find a solution for both.
an alternative to the manual "detach" nodes to be set by the players would be that upon shunting, the vehicle gets a "shadow" link to the original vehicle that it left the depot with. with that, it could be ensured that the callbacks always refer to the same vehicle
I think this would be a very good solution indeed.
I would actually propose something similar, but maybe with a wider scope: it would be great if we had a function that not only returns the engine a wagon is currently attached to (as we have now), but also the engine it left the depot with, i.e. some sort of "original" engine. Such information could be cached and updated each single time the wagon leaves a depot.
Then, upon shunting, we would check the ID of the new shunting engine, and only allow shunting if the latter is compatible with the "original" engine.
This would solve most compatibility problems I can think about...
The French Narrow Gauge Train Set is now released! Get it here