Wednesday, 3 November 2010

To facilitate new vehicles and multiplayer

In the process of sweeping changes to how the game loads vehicles and other data. A lot of data the describes how the virtual cockpit works, where you sit, angles of views etc. was not available early on and since my long term plan is a system in which we can serve you new vehicles down the wire, even adding the Chinook was going to need a bit of fiddling around. Some data was in the object LUA, some in an external file, some embedded. It wasn't the original intention to build vehicles this way, but it was expedient at the time.

Now it's time to put things right and make a nice neat all-in-one package that's flexible (after all that is my middle name).

Another thing I wanted to do was allow the ability to tie entities to simulation variables, so a cockpit altimeter needle can be assigned to the vehicle.baroaltitude parameter. Hey does any of this sound familiar? If it does then you've done aircraft/gauge development for Microsoft FSX. While this isn't anywhere as deep, it's enough for us to be able to bundle new helicopters and even ground vehicles later on. I'll publish a list of available parameters later when I know the scope myself. MPDs and HUDs can be copied to specified entities using the name of the glass instrument output and the name of the surface you want it displayed on.


* edit*
This is pretty neat, I've now added a bit more flexibility to what we can do with the cockpit inputs. Each individual switch position may now have a delay (hold at this position n seconds before firing) and fire an additional command at that position.

* end edit*




The FFD (dynamics) data could be added too to describe how it flies/drives, that's to be look at later.

There's still a quantity of code required to determine message priority, client/server authority. but at some future time if we want to add "user roles" as a message filter to any control, this is flexible enough for us to drop that in and not rely so much on coded game logic. Filtration and authority of incoming messages are important for multi-crew vehicles in multiplayer, you need to be as lean as possible (I bake state flags into bit fields as much as practical). Not all switches need to be recorded or sent, some are vital (crew helmet positions need fast updates for the HUD and sensors), some (wipers/lights) can be delayed.

The "command" string in the cockpit switch data is sent to the messaging system, if it's a network level command it's forwarded to any needed clients via Raknet.

As our vehicles are 'portals' there isn't much physics going on for attached crews. As a gunner, your helo position comes from the pilot and interpolated, your sensor position is based this, and that in turn is relayed back to the pilot. So there is room for some weirdness but not too much I hope. The way the Apache works actually works in our favour. Since each weapon system has a designated 'crew in command', the game logic knows who's the shooter and the positional data from the client in authority is used. And if you're not targeting a visible entity (e.g tank) then you're aiming at an invisible one (a pivot). This reduces oddities caused by differences of position reported by actual and interpolated crew positions.

3 comments:

  1. Sounds cool. I think using a client authoritative model is a good idea. Server-side authority with client-side-prediction can be pretty problematic especially for complex flight models.

    If I understand correctly, you're taking the target/terrain location which the gunner is currently aiming at and sending it over the network to the pilot rather than sending raw orientation? That sounds like a good way to eliminate parallax error caused by latency, especially if the sensor is ground stabilised.

    ReplyDelete
  2. You're exactly right Matthew, as you say parallax offset shouldn't be a problem except in a few circumstances. Have to fit the solution to the game and we're lucky in this case to have a system (Apache) that benefits splitting the authority. And it's a co-op game too which means we can trust things a bit more and not have to assume the worst case.

    I'll just add, there's a "mini state" for a dual-crewed Apache that has less bandwidth and higher packet rate between the crew for vehicle position, gunnery and head-tracking updates. The larger aircraft state for various system modes would be too big and not critical (there's 130 client flags alone). If the client "warning caution advisory" alert count has a mismatch then a re-sync request is sent.

    Will be testing some more cubic spline this coming week, we're using a program to simulate networking which doesn't use the 3D engine. It can be a pain to compile and run a large project to test these things as I'm sure you can appreciate.

    I'm really pumped as I've been having a big problem with crashing on one machine. After a day and a half of eliminating causes it turned out to be simply some bad terrain DDS textures, corrupted after a hard drive failure some months back.

    I just migrated to Leadwerks 2.4 after Josh fixed the corona bug and it would result in an nVidia driver recovery on frame one. Boom. So was getting a bit upset. As you do when you have an unexpected error on one hardware setup but not another. When the laptop starting doing the same but in a slightly different way it wasn't a good moment.

    Simple restoration of the textures from an older (pre-failure) backup did the trick.

    But it's funny that seemingly normal looking textures can do that to some driver/hardware configs.

    ReplyDelete
  3. I once had an issue similar to that but with a corrupt sound file. The game was continually crashing and I spent ages trying to hunt down the issue only to find that the fault was with bad audio drivers. I guess a lot of drivers are written to be as fast as possible and spend time safety checking the input data.

    ReplyDelete