Wednesday, April 4, 2012

EVE’s in-game browser – tying your code into the game

Yesterday I wrote a little about EVE Online’s database dump and API Functions, and mentioned some funky tools people had developed with them. These tools are generally Windows desktop apps, which allows for great functional interfaces, but sees you alt-tabbing out of the game if you want to fiddle around with a training plan in EVEMon, or brainstorm some ship fitting ideas in EFT.

But of course, as well as desktop apps, a popular way to present an application is via a web interface into a browser. And, as luck would have it, EVE has a browser built into the game client, the “in-game browser.”

I do a lot of different things in my day job, but the biggest part of what I do is ASP.NET web development. So this is right up my alley – I can write some code, put an ASP.NET front-end on it, run it on my local PC, and then hit http://localhost/ from the in-game browser. Neat!

It gets a lot neater, though. The in-game browser isn’t just a Webkit-based browser, it has some extra customizations that allow interaction between the game client and a trusted website. So if you add a little bit of Javascript to your page, it will pop up a message in EVE asking if you want to trust the website. Say yes, and communication can now occur in two ways.

First of all, any page requests from the in-game browser to the trusted site will have some extra HTTP headers. These are all documented on the EVE wiki’s “IGB Headers” page, but basically, it passes across useful information like your character’s name and ID, where in space you are currently located (down to the star system, or the station if your are docked), what type of ship you’re flying, etc. Obviously any type of market-related app can be greatly enhanced if it can make its recommendations based on where you are currently located.

Secondly, there are a bunch of other Javascript calls that can be made on the page to cause the EVE client to do various thing. These are all documented on the EVE wiki’s “IGN Javascript Methods” page. Useful things that can be done include setting your autopilot destination (e.g. to take you to a system that a bargain has been located at), opening the info window on an item (no need to display all the details on an item within your web app if you can just pop up a proper info window in-game), opening the market details window for an item, even sending in-game mail or a fleet invite. You can see why you need to explicitly trust a website for this functionality to be enabled!

Anyway, I did a little more hacking last night, whipping up some code to parse a market export file. While looking at an item on the market, you can hit a button to dump the buy and sell orders to a CSV file in your EVE folder. Now I have code to parse that file and store the orders into a database.

Next step – find profitable trades, and use the pathfinding code I wrote earlier to determine how far the seller is from me, and how far the buyer is from him!

3 comments:

  1. Could this be used in a hostile way? Could someone set up a site that once trusted strips their character's information and sends it to an external database?

    I can see great potential for espionage if so.

    ReplyDelete
    Replies
    1. It couldn't get much information. It could get your location and what ship you are in from the HTTP headers - which, I guess, would indeed have espionage potential. e.g. finding out that someone you had hostile designs on was in a low-sec system in a typical missioning or ratting ship, you might well seize the opportunity to go and hunt them down. But to get any information beyond that you'd need an API key. Which, of course, you could probably trick people into giving to an apparently helpful website.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete