Pages: [1]
  Print  
Author Topic: Linux UT init script fixes.  (Read 1910 times)
rork
Guest
« on: December 11, 2010, 01:19:05 pm »

'On Windows it's possible to open UT maps trough Explorer, on linux however this is broken. Mapnames or ip's can't be added to the startup command (>/ut) to be opened. It is however possible to add them to the ut binary (>/System/ut-bin). Besides that, if you load a map directly in UT it only loads the right gametype if this is set in the map. Unfortunately this often isn't the case.

There's also a flaw that by default UT logs to the terminal and not to a logfile. This can be very inconvenient if UT is started from the menu. For >/ut is written in sh it's possible to adapt it.

The following code in ut starts the game and has to be modified:

   exec "./ut-bin" -log $*

It's fairly easy to pass the first commandline argument to the execution of ut-bin, however ut-bin only accepts mapnames and ip's and no complete filenames which are passed when double clicking a map in a file browser. I use basename to retrieve the mapname, this method won't modify ip's but might break hostnames with forward slashes in them.

   URL=$(basename $1);
   exec "./ut-bin" $URL -log $*

The correct gametype can be figured out by the filename and passed to ut by adding "?game=gametype" to the filename. I use a perl snippet to extract the gametype prefix from the filename and change it to uppercase. The options to do this in sh seems to be limited.

I only build in support for the default gametypes, you can easily add more gametypes yourself. If no gametype is set it will default to DeathMatch.

   URL=$(basename $1);
   TYPE=`perl -e "'$URL' =~ m/^[^\-]+-/; print uc($&)"`;
   echo "Type: $TYPE\n";
   case $TYPE in
      CTF-)
           URL="${URL}?game=Botpack.CTFGame"
      ;;
      AS-)
           URL="${URL}?game=BotPack.Assault"
      ;;
      DOM-)
           URL="${URL}?game=BotPack.Domination"
      ;;
     esac
   exec "./ut-bin" $URL -log $*

The last modification is to log to a logfile in the preferences directory instead of the terminal.

        LOGFILE="${UT_PREFS}/Logs/UnrealTournament.log"
   exec "./ut-bin" -log $LOGFILE

The complete code (including some debugging messages) will look like this now:

   URL=$(basename $1);
   # use perl to change SUB to get the type
   TYPE=`perl -e "'$URL' =~ m/^[^\-]+-/; print uc($&)"`;
   echo "Type: $TYPE\n";
   case $TYPE in
      CTF-)
           URL="${URL}?game=Botpack.CTFGame"
      ;;
      AS-)
           URL="${URL}?game=BotPack.Assault"
      ;;
      DOM-)
           URL="${URL}?game=BotPack.Domination"
      ;;
     esac
        LOGFILE="${UT_PREFS}/Logs/UnrealTournament.log"
   echo "Run ./ut-bin $URL -log $LOGFILE\n"
   exec "./ut-bin" $URL -log $LOGFILE

It's now possible to associate .unr files with Unreal Tournament and start them automatically.

Download the modified script'
Logged
evil^bill
Guest
« Reply #1 on: December 30, 2010, 05:59:36 pm »

Nice.
Logged
evil^bill
Guest
« Reply #2 on: December 30, 2010, 06:12:30 pm »

What URL format do you use to pass in IPs to ut.bin?
Logged
rork
Guest
« Reply #3 on: December 30, 2010, 07:33:04 pm »

ip's, ip:port or hostname all work:
./ut-bin 81.169.188.18
./ut-bin 81.169.188.18:7777
./ut-bin rork.nl
Just watch out with slashes in hostnames.
Logged
Pages: [1]
  Print  
 
Jump to: