TASClient with Wine


Running TASClient under Linux with Wine requires a number of configuration steps. Although much of the following is the work of others (especially det and tobi), I have rewritten the guide with some improvements, namely making AI bots work and allowing proper communication of ingame status between TASClient and native Linux spring. --LordMatt

Contents

Install Wine

You can get wine from this site.

No configuration of wine should be needed, if your distribution is sane.

Further information about how to install and configure wine for its first use can be found here, should you need it.

Install Windows Spring

Download the installer of Spring for Windows, and run it in wine:

wget http://spring.clan-sy.com/dl/spring_0.76b1.exe
wine spring_0.76b1.exe

Complete the install, and let it install to the default location, which is Program Files\Spring.

Link Windows Spring to Native Linux Spring

Assuming you have already installed Native Linux Spring in the default locations (user modifiable data in ~/.spring and libraries in /usr/local/lib/spring), now we need to link the windows and linux data together: HINT: Under Ubuntu gutsy the LIBS folder may located under /usr/lib/spring/ !

WINESPRING=~/.wine/drive_c/Program\ Files/Spring
NATIVE=~/.spring
LIBS=/usr/local/lib/spring

touch "${WINESPRING}/script.txt"
ln -s "${WINESPRING}/script.txt" "${NATIVE}/script.txt"

rm -r "${WINESPRING}/maps"
ln -s "${NATIVE}/maps" "${WINESPRING}/maps"

rm -r "${WINESPRING}/mods"
ln -s "${NATIVE}/mods" "${WINESPRING}/mods"

rm -r "${WINESPRING}/base"
ln -s "${NATIVE}/base" "${WINESPRING}/base"

rm -r "${WINESPRING}/demos"
ln -s "${NATIVE}/demos" "${WINESPRING}/demos"

rm -r "${WINESPRING}/AI/Bot-libs/AAI.dll"
ln -s "${LIBS}/AI/Bot-libs/AAI.so" "${WINESPRING}/AI/Bot-libs/AAI.dll"

rm -r "${WINESPRING}/AI/Bot-libs/KAI-0.12.dll"
ln -s "${LIBS}/AI/Bot-libs/KAI-0.12.so" "${WINESPRING}/AI/Bot-libs/KAI-0.12.dll"

rm -r "${WINESPRING}/AI/Bot-libs/KAIK-0.13.dll"
ln -s "${LIBS}/AI/Bot-libs/KAIK-0.13.so" "${WINESPRING}/AI/Bot-libs/KAIK-0.13.dll"

rm -r "${WINESPRING}/AI/Bot-libs/TestGlobalAI.dll"
ln -s "${LIBS}/AI/Bot-libs/TestGlobalAI.so" "${WINESPRING}/AI/Bot-libs/TestGlobalAI.dll"

Create a Windows exe Wrapper to Communicate with TASClient

For the windows-TASClient to be able to launch native Linux spring, and determine when native Linux spring exits at the end of the game, we need a wrapper exe between them. Create a file called spring.cc and paste in the following source code:

Note that you must change the paths in the #define lines to your own home directory

#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <unistd.h>

#define SHELL_WRAPPER_LOCATION TEXT("/home/matt/.spring/spring.sh") //Change
#define GAME_STATUS_FILE_LOCATION TEXT("/home/matt/.spring/game") //Change

int main (int argc, char **argv)
{
  STARTUPINFO si;
  ZeroMemory( &si, sizeof(si) );
  si.cb = sizeof(si);

  PROCESS_INFORMATION pi;
  ZeroMemory( &pi, sizeof(pi) );

  // Start the child process.
  if (!CreateProcess(
    _tcsdup(SHELL_WRAPPER_LOCATION), // No module name (use command line)
    GetCommandLine(),                // Command line
    NULL,                            // Process handle not inheritable
    NULL,                            // Thread handle not inheritable
    FALSE,                           // Set handle inheritance to FALSE
    0,                               // No creation flags
    NULL,                            // Use parent's environment block
    NULL,                            // Use parent's starting directory
    &si,                             // Pointer to STARTUPINFO structure
    &pi))                            // Pointer to PROCESS_INFORMATION structure
    {
      printf( "CreateProcess failed (%d).\n", GetLastError() );
      return 1;
    }

  //Sleep while the game status file exists.  This file is created just before      
  //spring is started, and is deleted just after spring exits.  As long as this
  //wrapper is running, TASClient to recognizes that you are ingame, and allows    
  //your rank to increase, show your ingame status properly, etc. 
  Sleep(1000);
  while (access(_tcsdup(GAME_STATUS_FILE_LOCATION), F_OK) == 0)
    {
    Sleep(1000);
    }

  // Close process and thread handles.
  CloseHandle( pi.hProcess );
  CloseHandle( pi.hThread );

  return 0;
}

After saving the code, we need to install a windows-crosscompiler and compile a windows binary from it inside our Linux box like this:

aptitude install mingw32
i586-mingw32msvc-g++ spring.cc -o ~/.wine/drive_c/Program\ Files/Spring/spring.exe

This assumed debian for installing the crosscompiler, but mingw32 is probably simple to install on other distributions as well.

Create a Shell Wrapper to Communicate with Native Linux Spring

To be able to use AI bots, and to properly communicate spring's ingame status to the Windows exe wrapper we made above, we will need to make a shell script. Make a file called spring.sh in your ~/.spring folder and put the following code in it.

#!/usr/bin/env sh

sed -i s/.dll/.so/g ~/.wine/drive_c/"Program Files"/Spring/script.txt
sed -i s@AI/@/usr/local/lib/spring/AI/@g ~/.wine/drive_c/"Program Files"/Spring/script.txt
cd /home/matt/.spring
touch ./game
/usr/local/games/spring
rm ./game

Along with fixing the AI bot paths in your script.txt, the shell wrapper also ensures that your infolog.txt is saved in ~/.spring and creates a file /home/matt/.spring/game just before launching spring which the Windows exe wrapper looks for. As long as /home/matt/.spring/game exists, the Windows exe wrapper will not exit, and TASClient will display your status as ingame (and you will accrue ingame minutes. As soon as spring exits, the shell wrapper deletes the file and the Windows exe wrapper exits as well.

Create a Shell Wrapper to Launch TASClient

Finally, you should make a script for launching TASClient. The script can be named tasclient for example, and just put it somewhere in your path and make it executable. The script code is:

#!/usr/bin/env sh
cd ~/.wine/drive_c/Program\ Files/Spring
wine TASClient.exe

Now you should be able to type tasclient on the command line, and the lobby appears. This cd operation is necessary. If your working directory is not the same as TASClient.exe's location, it will just give access violations to you.

Final Notes and Tips

Note that every time when you have added new maps, the lobby client caches them and this will take some time, or a long time if you downloaded many maps since last time. Just wait patiently.

Then you should register an account and login with it, and you should be ready to join an online multiplayer game from the list that appears.

It's likely that you don't have the correct map or mod at this point, so just get them and join the game. You don't need to restart your lobby client after downloading the files.

It's recommended that you spectate a couple of high rank games first, to get some idea of how the game should be played. Some hosts don't allow spectators, but most do.

Retrieved from "http://spring.clan-sy.com/wiki/TASClient_with_Wine"

This page has been accessed 590 times. This page was last modified 15:58, 14 March 2008.




Page editing toolbox

Browse
Main Page
Community portal
Current events
Recent changes
Random page
Help
Donations
Edit
View source
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Log in
Special pages
New pages
File list
Statistics
Bug reports
More...

Site layout created by Roflcopter.