Wednesday, January 07, 2009

Accidental Contracts

In a previous post I ranted about the hidden cost of adding new third-party-accessible features to X-Plane - that cost being the cost of supporting the APIs way into the future so that third party content doesn't break.

Even trickier are accidental contracts - that is, unintentional behaviors that the sim exposes that third parties take advantage of.  This can be particularly tricky for us because we might not even realize that the behaviors are happening.

In 921 we allowed the HUD to be visible in the 3-d cockpit for planes that use our "default" 3-d cockpit, like the 777.  Ignoring that this was a truly silly feature to do, one of the side effects of the code change was that EFIS glass instruments now render correctly over transparent parts of the panel texture on some hardware.  Javier immediately jumpedon this to build a 3-d HUD.

These EFIS glass instruments appearing in that region was totally unintentional, and this is about the last way I wanted to implement 3-d HUDs, but now that it's in there, I have to ask: do I want to break Javier's airplane, which a lot of users will like?  Probably not!

Another accidental contract is the draw order of the cockpit objects.  Basically due to a coincidence of how the code is structured, the external cockpit object is drawn before attached objects, but the internal cockpit object is drawn after.  There is no good reason for this, but now that authors build airplanes based on this, we have to preserve it because changing draw order can break translucent geometry.

X-Plane is full of this kind of thing - and all of these hidden conventions make it tricky to restructure subsections of the code.


Anonymous said...

But if you break some contracts, what about the possibility to convert an acf to a new version. i think planemaker knows the version an acf is saved in.
sure the end user will have to deal with it if there is no maintainer for that acf anymore. but thats progress.

Anonymous said...

The only thing I have to say is thankyou to you and your effort. Just writting you and answering in no time is great from you!!

Sorry about the headaches that HUD can make to you. Is the "bad" thing of me. I like to think a lot. Maybe because I studied Phisics, and programing a little. I like to solve questions.

Thanks Ben. Javier.