Wine and Torchlight
This turned out to be a pain in the ass to get going (despite posts all over the web saying otherwise), so I thought I’d quickly jot down the steps I took to get Torchlight, purchased off Steam, to work under wine. For this guide I’ve used Arch Linux (but it should be adaptable to any major distro, including Ubuntu), and assume you’ve got wine setup correctly already (whether on x86_64 or x86 is up to you, of course, but given wine’s 32bit only at this stage setting it up on x86_64 will require extra work). I intend to cross-post this to the Arch wiki when I’ve done a little cleanup work on it.
Installing Steam
You can follow the guide on the Arch wiki, or you could just copy and paste the below into a terminal.
wget http://www.kegel.com/wine/winetricks
sh winetricks gecko allfonts
wget http://storefront.steampowered.com/download/SteamInstall.msi
wine start SteamInstall.msi
You might already have installed corefonts and gecko using Arch packages from the AUR/Community, in which case, you can probably remove gecko from the second winetricks line (Steam uses a couple of fonts included in allfonts that aren’t in corefonts, so to keep it pretty, install allfonts). Performing the above should install Steam cleanly, and you should be able to login to your account (or create a new one!).
Installing Torchlight
Install the game via Steam as you normally would in Windows (right-click the game and click Install Game). If your wine is configured correctly, you can opt to have the game create Start Menu and Desktop links. I don’t know if these work at all, but whatever!
Initial Torchlight Configuration
To get the initial bits and bobs for Torchlight setup, we’ll need the VC redists and DX9 installed. I’ll lay a baseline here so that all our bases are covered in case you install games in the future, but for Torchlight alone only directx9 and vcrun2008 should be necessary. Make sure you put vcrun2008 before directx9; there’s a bug with wine/winetricks (at time of writing, I’m using wine 1.1.27/winetricks 20091213, but it’s reported as present in wine-1.1.32 too) that’ll cause vcrun2008 not to install if directx9 is installed first.
sh winetricks vcrun2008 vcrun2005 directx9
wineboot
The directx9 installer might bug out a bit. I tangoed with it a bit at the end - “Finish” disappeared, so I clicked “back”, out of the window and back in again to reenable the buttons, then “next” and “finish”. YMMV. After that, right click Torchlight in Steam and go to properties. From here,
- Click “set launch options”
- Enter “-SAFEMODE”
Various guides recommend grabbing http://www.runicgames.com/uploads/safemode.zip, but that link no longer exists. Without finding any real documentation, I can only assume it was deprecated for -SAFEMODE. Note that you’ll find some guides advising you to use SAFEMODE=1; that’s invalid, so don’t :).
Once you’ve done that, fire the game up from within Steam. The initial load can take a while, as the install will try and install DirectX9 and the vcredist internally. I’m unsure if you can just let these run without using winetricks, but at least, I was unsuccessful doing so and hence would recommend running winetricks first.
Note that the DX9 install takes a long, long time. If you started Steam from the console, you can see in the background that it is doing stuff.
For the record, -SAFEMODE is necessary because for whatever reason, without it, the game does not create its settings.txt file and thus crashes when it attempts to load it.
Note: if you can’t load the game from within Steam, pop open a terminal and cd to ~/.wine/drive_c/Program Files/Steam/steamapps/common/torchlight/, and try wine Torchlight.ext -SAFEMODE. This will not support the Steam Cloud, but I sighed a massive sigh of relief when I saw it actually working! It will create the config files you need.
Tweaking Torchlight
Once the game has started, you’ll want to make a few changes - stuff like -SAFEMODE isn’t really desirable (I’m still not sure what it even does…), and there are performance enhancements we can make for Linux systems.
Altering Resolution
First, head into settings, and assign yourself a resolution - it can be anything. so long as it fits on the screen (because I use dual screens, I was presented with a crappy list of supported resolutions that’d span both screens). Applying the resolution change used to make the game crash, but that no longer appears to happen (for me at least). Quit the game. I prefer to run it windowed, so I don’t know how fullscreen pans out, but it’d be great if someone were to try it and post a comment :).
settings.txt (and local_settings.txt, which is new since Torchlight switched to the Steam cloud) will now have been created in your ~/.wine/drive_c/users/$username/Application Data/runic games/torchlight/, and you can thus directly edit it from here. Choose the resolution you really want (RES_WIDTH and RES_HEIGHT, and WINDOW_WIDTH and WINDOW_HEIGHT if you’re going to play windowed). You can toggle FULLSCREEN to 1 and 0 here as well.
Using OpenGL
Torchlight supports an OpenGL renderer. I haven’t yet benchmarked the relative performace, but I’ll do so shortly and update this post. In the meantime, it would make sense that OpenGL would run faster under Linux as Wine wouldn’t have to interpret all the DirectX calls.
To enable it, open local_settings.txt (in the directory mentioned above) and set OPENGL :1. Attempting to open the game now will result in a crash, as you need to make a couple of other changes too.
Go to Steam’s Torchlight directory (~/.wine/drive_c/Program Files/Steam/steamapps/common/torchlight/), and as per this thread, copy Plugins.cfg to plugins_opengl.cfg. Open the file, and uncomment the line #Plugin=RenderSystem_GL, while commenting out the line Plugin=RenderSystem_Direct3D9.
The game should now fire up in OpenGL.
Working with the Steam Cloud
By this point, you should be able to fire the game up locally, by calling it directly using wine. While writing this, by this point Steam was behaving erratically and basically dicking me around, and running -SAFEMODE disables Steam cloud support.
To get the game to work from within Steam, for whatever reason (I’m guessing somewhere up above this needs to be inserted, but I don’t know where), just use wineboot (which emulates a Windows restart). It took a couple of these, but once they were done Torchlight would load fine from within Steam, and with no -SAFEMODE (you’ll need to remove it from the game’s properties, same as it was added above).
Benchmarking
I performed some basic benchmarking going through the Estherian dungeon levels by pulling up the console and typing “FPS”. This is on my work PC, which is a Pentium D @ 3.00GHz per core, 2GiB of RAM and using a 7800GT - so nothing flash.
Linux Direct3D and OpenGL performed identically at an average 32fps (it would sway by 2 or 3 fps in either direction, but there was never a massive slowdown). For a game running under wine on a machine of this age, I’m happy with that kind of performance. It does make it hard to recommend the OpenGL renderer however, as the D3D renderer doesn’t suffer the in-game fire bug (at least, with the particle count reduced) whereas the OpenGL one does. I expected a bigger divergence in performance, but it’s likely that the hardware is the limiting factor here.
Common Bugs
When getting this up and running, there were a few things other guides suggested that I tried and didn’t work, and other bugs I encountered, so I’ve documented them below.
-
Starting Steam creates a popup saying dxdllreg.exe encountered an exception: this happened after I’d installed bushels of crap during my first attempt at getting this working; I suspect the straw which broke the camel’s back was dcom98. I threw my hands up and wiped wine out at this point, so unless you’ve got a decently configured wine setup, I’d recommend doing the same.
-
err:d3d:WineDirect3DCreate Direct3D9 is not available without opengl: this is an issue with your wine setup. From the Arch Forums, Dheart recommended installing lib32-nvidia-utils (for x86_64 users :)); that fix worked for me. You might also like to see the referenced wiki page
-
err:d3d:WineD3D_ChoosePixelFormat Can’t find a suitable iPixelFormat arch linux: this happened to me because I’d just updated my nvidia drivers using pacman -Syu. Do a quick glxinfo and have a look to see near the top: mine showed that DRI was disabled as there was a version mismatch between the currently loaded glx module and the kernel module. I think you could probably get away with just restarting X to resolve this, but I rebooted anyway.
-
vcrun2008 fails to install: there’s currently an open bug referencing this issue. You need to install vcrun2008 before directx9, which is why they’re listed in order above. The only solution suggested there is to nuke your ~/.wine directory and start again.
-
Steam keeps trying to run the VC Redist: I can only assume that the bug immediately above this one plays into this, but it’s a pain in the ass. From the Steam Forums, a user suggests the following (and it worked for me):
~/.wine/drive_c/Program Files/Steam/steamapps/common/torchlight/xxxxx_install.vdf
Open the file in a text editor and find the block of text labeled “run process”, these are the processes that run and check/install those first time setup programs. There should be blocks of text similar to this:
“VCRedist” { “process 1” “%windir%\system32\msiexec.exe” “command 1” “/qn /i "%INSTALLDIR%\Install\vcredist.msi"” “NoCleanup” “1” }
There will probably be blocks like this for DirectX, OpenGL, etc. Delete all of the text inside the block, so for the example above, that block would now look like this:
“VCRedist” { }
Do this for all of the blocks inside the “run process” block, and when opening the file, it shouldn’t run anything as the first time setup. A word of warning though, only do this if you know you already have the necessary files installed, otherwise your game will just error because it tries to access files that don’t exist.
-
Fire EVERYWHERE: I’m unsure what causes this issue, but this fix worked for me (it might not work for others, though…): open the local_settings.txt file, and adjust MAX_PARTICLES from 5000 to 500. Note that this only worked on Direct3D for me; I suspect the OpenGL render doesn’t respect the particle count setting.
Woot
And that, ladies and gentlemen, should be all you need to get Torchlight working from within Steam under wine. I’d love to hear any feedback :).
Tags: