Xfire Plus: Custom Game Support, how to make -tutorial

Table of contents

Overview

This document should help you to create a custom game support file for a game that is not yet supported by Xfire and will tell you how to submit the detection code to Xfire Plus team in a correct form.

If you are completely new in making the custom game support files, go through this tutorial step by step. This tutorial is written in a logical order so that first you gather basic information of the game, then you create the first version of your detection code and test if it works. After that you will learn how to make the code better and add for example in-game chatting support.

The section Advanced information contains more of an advanced information that is not necessarily needed. Once you get the basics of creating custom game supports, then you might want to expand your knowledge into more complex methods that can be used to make your support perfect.

This document has been written by Joonas Lehtolahti (aka GODJonez) to help people create game support code for Xfire. This document is especially written for Xfire Plus to help people to publish their code with other Xfire users easily. The copyright for this document is valid and belongs to the author. If you wish to use any part of the document on your own productions, please ask for the permission from the author. You can find contact information from his public profiles on the websites mentioned earlier. You are allowed to link to this document without any special permission. This document might contain wrong or misleading information. If you find some wrong information and know how it should be, please inform the author and the document will be updated if your information can be confirmed.

This document with all its contents copyrighted © 2006 by Joonas Lehtolahti

Basic information

Game name

You define two (2) names to Xfire, LongName and ShortName. LongName is the official game name, the one seen by everybody. The other is a short form. For example the long name for Unreal Tournament 2004 is Unreal Tournament 2004 and the short name is ut2k4.

The shorter form should only contain lower case letters and numerals, no spaces or special characters. The short name should be something similar to the full name, for example the starting characters of the words in the full name. Take a note that the short name must be unique, two supported games should not define the same short name.

Files needed

You must provide at least one filename to Xfire, the file that is to be started if you want to run the game. For example the file for Wolfenstein: Enemy Territory is ET.exe. This is called LauncherExe.

Some games have a separate launcher that starts the actual game. In these cases you need to specify Xfire the file that is running when the actual game is active. For example Diablo II uses Diablo II.exe to launch the game, but once the game starts, that file is no longer running. Instead the file Game.exe is active. So you tell Xfire that Diablo II.exe is the file to be launched, but Game.exe the file to be detected. That file is called DetectExe.

Sometimes you need to tell folder names to Xfire as well when you define the file names. Those cases are covered in the advanced topic Folder structures.

Install location

You can help Xfire to find the correct game path by telling where the game is installed in the detection code. The best case is when the game installer writes the install location into Windows registry. Let's suppose you have installed the game you want to add to Xfire to location C:\Program Files\Mygame. Here are the steps to determine if the install path is in registry and where it is there:

  1. Open Registry editor
    1. Open Start menu
    2. Choose Run...
    3. Write regedit.exe and press Ok
  2. Click on HKEY_LOCAL_MACHINE
  3. Press CTRL+F
  4. Make sure only Data is checked
  5. Type the install location in the search box, in this case C:\Program Files\Mygame
  6. Click on Find Next
  7. Wait until the search is complete
  8. If you see a dialog saying Finished searching through the registry. You know that the install location is not stored in registry. In this case you should tell Xfire what is the default install location where the installer wants to put the game.
  9. Otherwise the view should be moved to the found data. In the status bar you should see the Registry key, likely My Computer\HKEY_LOCAL_MACHINE\Software\Author\Game On the right panel one Value is selected, it could be (Default) or for instance InstallPath. Double click on it to see the full value. The value contains the installation path, but it might contain more than that.
  10. Write these things up:
    • Registry key without My Computer and without the backslash after it. So the key should start with word HKEY.
    • Value (the one selected). You can see the value in the column Name
    • Data (the contents you see by double clicking the value)

One-click joining

Xfire uses command line parameters to make the game to connect to a specific server. If you know what command line parameters are used by the game you want to add, then you can add one-click joining to it. For example, to connect to server 1.2.3.4 on port 5678 on some games, you would use the following text in command line: +connect 1.2.3.4:5678

If the game you are trying to add is a multiplayer game but you don't know what command line parameters to use to connect to a server, this information can usually be found from the game manual or readme file. If the official documentation with the game does not include that kind of information, you can always search the Internet. If command line joining is possible, someone has surely put the code on his website.

Detection code

Structure

Now you should have all the necessary information to create the detection code. This section will instruct you on how to make the information readable by Xfire.

There is a file xfire_games.ini in the Xfire's folder. This is the file we are playing with when talking about game support. It is a text file, so open it to your favorite text editor, maybe Notepad.

You can see the file is divided into sections, each section containing a header enclosed in square brackets []. The number in the header is the game's ID number. The ID is assigned by Xfire staff so that everyone including Xfire servers can identify the games precisely.

Under the ID header you can see several lines defining the properties. Some of them are LongName, ShortName, LauncherExe and Launch. All the properties tell Xfire how to detect the game, how to launch it, what is needed to display in-game chat window and so on. See the xfire_games.ini entries document for full list of properties and what they mean.

Creating and testing

Once you have gathered the required information, it is time to create the detection data in xfire_games.ini to test your efforts. Create a new section to the file by adding a header line: [99]. We use ID 99 because that number is not used by any game entry in the file, so it will not cause any problems. Under that line you will then write the needed properties.

The first two properties should tell the name of the game. Use property LongName to tell what name is shown for this game. For example: LongName=Camper-Strike ultimate. Then you need to define the ShortName also. Use your imagination to create a name that is not used yet in the file but describes the game in question. In our imagination example, an appropriate short name could be csu. Written to xfire_games.ini so far: [99]
LongName=Camper-Strike ultimate
ShortName=csu

Now we have defined the identification of the game. Next we tell Xfire where to find the installed game on user's computer. The properties used for it depend on whether the install path can be found from the Windows registry or not.

Install location not in registry
Tell Xfire the most likely folder where the game could be. This is the path that the game installer wants to install the game to by default. Usually it is a subfolder in Program Files. The property used is LauncherDirDefault and the value is the default install path by installer. For example: LauncherDirDefault=C:\Program Files\Camper-Strike
There is a way to acquire the path from a shortcut file too, but that is rarely used and therefore not instructed in this tutorial. More information can be found by reading the description of LauncherDirShortcut
Install location found in registry
This makes detecting the game easier for Xfire since it can peek the most likely installation path from Windows registry to quickly find the game on user's computer. Use property LauncherDirKey to tell where in registry the current installation path can be found. The value of this property can be created using this set of rules:
  1. Take the Registry key, for example HKEY_LOCAL_MACHINE\Software\XfirePlus\csu
  2. Remember to omit My Computer from the key
  3. If the Value name is (Default), add one backslash at the end of the key. You will then get for example: HKEY_LOCAL_MACHINE\Software\XfirePlus\csu\
  4. Otherwise add one backslash and the Value name. If the Value name is InstallPath, then in our example the final value would be: HKEY_LOCAL_MACHINE\Software\XfirePlus\csu\InstallPath Remember that you don't put another backslash there!
The next part is to analyze the registry data. If the data is exactly the install location, for example C:\Program Files\Camper-Strike, then you only need to tell the registry location to Xfire. But if the value contains more than that, for example if it was C:\Program Files\Camper-Strike\csu.exe you can easily say what is the install path from that text. There is a way to tell Xfire that thing too using property LauncherDirTruncAt. The value of that property tells Xfire where to cut down the data so that only the installation path is left. The example code here would be: LauncherDirKey=HKEY_LOCAL_MACHINE\Software\XfirePlus\csu\
LauncherDirTruncAt=csu.exe

So far our code should look something like this (of course with the values that apply to the game you are trying to add): [99]
LongName=Camper-Strike ultimate
ShortName=csu
LauncherDirKey=HKEY_LOCAL_MACHINE\Software\XfirePlus\csu\InstallPath

Now Xfire is given a hint where to find the game. Of course the game doesn't need to be in the location we gave Xfire, it could be anywhere on the user's computer. We just give a hint where it is likely to reside to make finding it quicker. Next we will tell Xfire how to start up the game. We use property LauncherExe for that. In our imaginable tutorial game, Camper-Strike ultimate, the file used to start the game is csu.exe, so I would add line LauncherExe=csu.exe to our definition. You write similar line but with the executable name your game is using.

If your game was of the sort it uses a launcher and a different exe for the actual game, put the launcher's name to LauncherExe and use DetectExe to tell Xfire what is the executable file that is running when you play. If the file to be launched is the actual game (most of the time it is) then you don't need to specify DetectExe at all.

Now our first code is almost complete and looks something like this: [99]
LongName=Camper-Strike ultimate
ShortName=csu
LauncherDirKey=HKEY_LOCAL_MACHINE\Software\XfirePlus\csu\InstallPath
LauncherExe=csu.exe
Xfire now knows what file to use to start the game, but it still doesn't know how to use that file. We need to specify one more required property, Launch. If the game doesn't need any special parameters that are always needed regardless of the computer the game is running on, then you can use the normal line for this property: Launch=%UA_LAUNCHER_EXE_PATH% %UA_LAUNCHER_NETWORK_ARGS% %UA_LAUNCHER_EXTRA_ARGS% If there are some mandatory command line parameters (usually to start a game mod), add the parameters to that line.

If you know what command line parameters are used to join a server, you can define it now to add one-click joining support. Put the parameters as a value to property LauncherNetworkArgs. You can use some special environment variables that will be replaced by real values when the game is launched. The server's IP address can be referenced using %UA_GAME_HOST_NAME% and the port the server uses can be referenced using %UA_GAME_HOST_PORT%. For example one kind of command line joining could be of form: LauncherNetworkArgs=+connect %UA_GAME_HOST_NAME%:%UA_GAME_HOST_PORT%.

More information to add passworded server support and login info as well as RCON password support can be found in the advanced topics of Network support.

The first version of our code is now ready. Here is an example what it could look like: [99]
LongName=Camper-Strike ultimate
ShortName=csu
LauncherDirKey=HKEY_LOCAL_MACHINE\Software\XfirePlus\csu\InstallPath
LauncherExe=csu.exe
LauncherNetworkArgs=+connect %UA_GAME_HOST_NAME%:%UA_GAME_HOST_PORT%
Launch=%UA_LAUNCHER_EXE_PATH% %UA_LAUNCHER_NETWORK_ARGS% %UA_LAUNCHER_EXTRA_ARGS%
To test if the code works, save xfire_games.ini and open Xfire. In Xfire, open Find Installed Software tool and check if it can find the game you just added support for. The icon shown in the dialog is basic Xfire icon. You will learn later how to add the actual game icon to it.

Xfire Plus

When you send the detection code to us, it is almost identical to what you just wrote into xfire_games.ini. The only exception is that you do not include the header (for example, [99]), but only the properties. We will then use our own method to assign an unique ID number for the game once we add it to our support database.

Xfire In-Game

Overview

Making in-game chat possible is not as easy as it might seem to be. There has been quite a bit of work to make the XIG to work with so many games it currently works with. This includes a lot of special tweaks and custom methods for specific games to be compatible with them.

This makes it possible that if it seems you added everything correctly to the detection code regarding in-game chat, it might still not work as the game in question might need its very own special fix in the Xfire code.

Renderer types

The game can use different methods to draw the graphics on the screen. Xfire must know what method the game uses so that it could draw the in-game window correctly on top of the game graphics. You can specify the render type the game uses to your detection code with property InGameRenderer. The different render types are listed in the description of InGameRenderer.

Finding out

Finding out the rendering engine game uses is sometimes very easy, sometimes very difficult. The easiest cases are games that tell it to you or you can change the rendering engine from the game's graphics options. If the game supports multiple rendering modes, try using all of them and changing the support code also to test which one works best with Xfire In-Game.

For games that do not tell the rendering engine to you so easily, you can try guessing the engine using the guidelines found in the description of property InGameRenderer.

One method is the trial and error. There are only five rendering methods Xfire supports, so it does not take forever to test all five values to see which one works.

Testing

To test your in-game support, all you need to do after adding / modifying the InGameRenderer line, is to save the xfire_games.ini file and run Find Installed Software. When you start the Find Installed Software utility, xfire_games.ini gets reloaded and all changes are applied instantly including the in-game rendering mode. Then just launch the game and test if the in-game window shows up.

Sometimes the rendering works correctly, but Xfire can't get the keyboard input so pressing the hotkey to open the chat window doesn't work and it seems like the renderer value was wrong. So if the chat window does not open using the hotkey, a better way to test the rendering support is to ask your friend to spam you with messages. Whenever he sends you a message while you are in the game, the alert window is displayed in case the rendering mode is correct.

If you get the in-game chat to work partially, for example the alert window is shown when a friend messages you but the hotkey to open the main window does not work, read the advanced topic of in-game Troubleshooting

Completing support

Acquiring icon

Now your code works perfectly and you think you would like to share your work with all other Xfire Plus users. One thing you are still missing is the game icon, Xfire still displays the regular Xfire icon instead of the game's own icon.

The easy case is when the game has a separate icon file (.ico). Test that the icon works by copying the icon file to icons folder in Xfire. That folder does not necessarily exist. If so, create it. Once you have copied the icon to Xfire's icons folder, rename it to match the short name of the game. In our example the filename should be csu.ico.

A more difficult case is when you need to extract the icon from the exe file itself. There are plenty of programs that can do it. My favorite program for it is Microangelo. Freeware programs that can extract icons from executables are for example IrfanView and Resource Hacker.

You need to restart Xfire to make the icon to be loaded. Run then Find Installed Software to see if the icon is correct.

Sending

Ok, you have a working code and icon too. Great! That means you are ready to send your work to us so it will be added to our Custom Game support database.

We would prefer if you sent your code to our forums with the icon as an attachment. That way we can quickly add the code to the database and get the icon from your post.

Advanced information

Folder structures

There are three main types of folder structures as I describe them. You will probably understand better what I mean with folder structures by reading my descriptions of each of them

Normal folder structure

This is the most common folder structure. Let's take an example, the game XEvil. If the installation path is C:\XEvil, the executable file is C:\XEvil\xevil.exe, so it is located in the install folder itself.

Type categorized subfolders

Some games use this kind of structure. It has all different kinds of files in their own subfolders. Unlike the normal folder structure, even the executable files are in their own folder. The example game would be Unreal Tournament. The install path could be C:\Unreal Tournament, but the executable file is located in its own subfolder: C:\Unreal Tournament\system\UnrealTournament.exe

These cases are better done by adding the subfolder name into LauncherExe property. (If DetectExe is needed, remember to add the subfolder name to it also). In the example, the line would be LauncherExe=system\UnrealTournament.exe Why do it like this? Well, it is nicer to display the actual install path in Xfire instead of the path with the subfolder as "Install location".

Steam folder structure

Steam games use their own folder structure. Since the detected executable is in a folder that you can't know (it is in subfolder named by the user's Steam account name), there has been coded a method for this folder structure inside Xfire. You will get the idea how to add Steam game support by looking the lines of Counter-Strike: Source: LauncherExe=steam.exe
DetectExe=SteamApps\*\counter-strike source\HL2.exe
InstallHint=steamapps\counter-strike source shared.gcf
Launch=%UA_LAUNCHER_EXE_PATH% -applaunch 240 -console %UA_LAUNCHER_EXTRA_ARGS% %UA_LAUNCHER_NETWORK_ARGS%

Launching URL

There are some games that need going to some website to start up. For those games you can order Xfire to launch your favorite web browser to the address the game needs going to. You can specify the URL with property LauncherUrl. You also need to modify the Launch property to launch to the url instead of the game. To do this, replace %UA_LAUNCHER_EXE_PATH% with %UA_LAUNCHER_URL%.

Alternate entries

For some games there are more than one possible way to detect them. An example is Counter-Strike: Condition Zero with both Steam and non-Steam version. Of course Xfire can't detect the Steam version with the detection code for non-Steam version and vice versa.

Instead of creating two different entries for one game to include all versions, you can create alternate entries for one game to reserve only one ID number for the game. Normally the header looks like [1234]. But when you create alternate entries, the headers look like [1234_1], [1234_2] and so on. The number after underscore tells Xfire the priority of the entries. So name the more common detection as alternate entry 1 and less common version detection with next smaller number. You can include more than two alternate entries. The maximum number of alternate entries for one game is unknown for me.

Network support

Username

There are a few games that you can provide a username from command line. An example of a program that needs username is TeamSpeak.

When you add property LauncherUsernameArgs Xfire will ask for the username when the game is launched. The value of this property should be the command line parameters used to tell the game what the username is. Use variable %UA_GAME_HOST_USERNAME% that will be replaced by the username given to Xfire upon launch.

You also need to remember to add the environment variable %UA_LAUNCHER_USERNAME_ARGS% to property LauncherNetworkArgs

Password

To join a password protected server you must tell Xfire how to pass the password to game command line. The property used for this is LauncherPasswordArgs that has the command line parameter as its value. You can use %UA_GAME_HOST_PASSWORD% that is to be replaced by the password given to Xfire.

You also need to remember to add the environment variable %UA_LAUNCHER_PASSWORD_ARGS% to property LauncherNetworkArgs

RCON Password

If you can give RCON password in the command line when joining a server, use the property LauncherRconArgs to tell Xfire what command line parameters to use. You can use %UA_GAME_RCON_PASSWORD% that is to be replaced by the RCON password given to Xfire.

You also need to remember to add the environment variable %UA_LAUNCHER_RCON_ARGS% to property LauncherNetworkArgs

Logging in to game

If the game needs logging in and it can be achieved using command line parameters, you can use property LauncherLoginArgs to tell Xfire what command line parameters to use. You can use %UA_GAME_LOGIN_NAME% and %UA_GAME_LOGIN_PASSWORD% to refer to the values given by user upon launching the game. An example of this kind of game is Battlefield 2.

You also need to remember to add the environment variable %UA_LAUNCHER_LOGIN_ARGS% to property LauncherNetworkArgs

Server query

As you have seen, there are plenty of games Xfire can query the server status for to show you the server name, the players on it and other information that is provided by the server. You can not add this support for every game as the server query process is different from game to game and all the different ways to query the servers are built into Xfire program.

If the game you are adding to Xfire uses a server query type that is already supported by Xfire (this is usually the case with mods) you can use property ServerStatusType to tell Xfire which server query method to use. However, this will not add server browsing support because the list of servers for the game is hosted on Xfire's database.

You can see the list of supported query methods and what values to use on the property by reading the description of ServerStatusType. There are a few cases you might need using additional property ServerEncodingType, read its description for more information.

Excluding ports

If you know the game connects to other places than the server the user is playing on (for example it might connect to master server) and the port used on those addresses is different from the ports used by game servers, you can tell Xfire not to track connections to those ports, so it will not be shown to your friend that you are playing on the master server which only hosts the server list.

The property used for this goal is ExcludeIPPorts. The value consists of ports that should not be tracked, separated with commas ,.

Massively multiplayer online games

Most MMO games are played in a different way than "normal" online games where you choose the server to join to. As there is a big world where everyone is playing on, you don't usually select a server to join with MMO games, but the game selects the best one using the logic built into it. Therefore the IP address of the server you are playing on holds little meaning and you might want to follow the Xfire's way to disable IP address tracking for the game completely.

To stop Xfire from reporting the IP address where the game is connected to, add the following line to your detection code: DetectServer=FALSE

Xfire In-Game

Troubleshooting

If the in-game chat does not work perfectly on the first try, you can try making it better with this little troubleshooting topic.

XIG not working at all
Symptoms:
  • Can't get chat window show up
  • Alert window is not shown
  • Can't take screenshots
You might try changing the value of InGameRenderer to something else. If none of the values work, then the game is using an unsupported method to display the graphics meaning that it needs a special fix to be built into Xfire. Please leave the in-game support properties away to keep the code clean and to prevent wrong information from being displayed to other users.
Xfire hotkeys do not work
Symptoms:
  • Can't get chat window show up
  • Can't take screenshots
  • The alert window works normally
Since the alert window is displayed when you get messaged, it means that the XIG works, but it can't read your keyboard for some reason. To cure this issue, you need to use InGameFlags to add a special fix for the game. The values for this: Try them in the order listed above.
In-game chat window does not eat keystrokes
Symptoms:
  • In-game chat works normally
  • Keystrokes to Xfire window get passed to the game also
Xfire keyboard hook is unable to completely take control of the keyboard. You can try using various special fixes to cure this issue by using InGameFlags. The values that might help are: Try them in the order listed above.
The game turned slow after adding in-game support
The way Xfire adds itself on the game's rendering mode, it might cause performance problems on some games. If you seem to get bad FPS rate after adding in-game support to the detection code, there is a special fix you might want to try: InGameFlags=DISABLE_RELEASE
Problem not listed above
Try using some special in-game tweaks to see if they help with your problem. They are described below.

Flags

There are a dozen built-in tweaks in the Xfire In-game engine that you can activate using InGameFlags property. If you don't seem to get the in-game support to work perfectly, the first thing to try is adding these tweaks. To see the list of values you can use for this property, see the description of InGameFlags.

OpenGL texture offset

If your game is using OpenGL renderer and you don't seem to get the in-game chat window to show up or it doesn't seem correct, you can try a special property InGameOGLTextureOffset with some numeric value. At the time this documentation was written, only one value has been used with this property and it has worked for all the games using it: InGameOGLTextureOffset=32000

Palette based games

There are a few games running in paletted 256 color mode. Displaying the in-game chat window with right colors needs editing the palette to include the colors needed by the skin used in Xfire.

If the in-game chat window edits some colors of the game in a way it looks very strange, you might want to tell Xfire which palette entries not to edit. Instructions on how to determine the color indexes that should be excluded from editing and how to tell them to Xfire are described in the description of property InGamePaletteIgnore that is used for this purpose.