Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Thread Tools Display Modes
  #1   (View Single Post)  
Old 24th June 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default Manage Unreal Tournament cache files

This is a little Python script to manage cache file for Unreal Tournament. Been using it for years, figured I might as well put it here.
I only used/tested this with the original UT on Windows and FreeBSD, should work for Linux and possible MacOS X too.

On FreeBSD you can install UT as a port: games/linux-ut. You'll need an original UT CD. The unreal anthology release is on sale for a few euro's (... And will work with the port in spite of the InstallShield crap installer they slapped on).
AFAIK it doesn't work with OpenBSD/Linux emulation.

Note this script will just rename the files to the correct name in the Cache/ directory, it doesn't put them in the correct UT Dirctory (System/, Textures/, etc.).
This is a feature and not a bug because when you're using mods you often don't want to use the standard UT directories and there is no way of figuring out which files belongs to which mod (Or even if it belongs to any mod).

A few simple commands can move the files:

  $ utdir=/usr/local/share/linux-ut/
  $ mv *.u ${utdir}/System/
  $ mv *.utx ${utdir}/Textures

The actual code
  #!/usr/bin/env python
  # Martin Tournoij <martin@arp242.net>
  # http://carpetsmoker.net/weblog/Manage_Unreal_Tournament_cache_files.php
  # Free to use for whatever purpose. There are no restrictions.
  # Version 20100624
  # This is a very simple script to manage unreal tournament cache files.
  # Works on Windows, FreeBSD, Linux.
  import os
  import re
  import shutil
  import sys
  if sys.platform[:3] == 'win':
  	cachefile = '%s\\UnrealTournament\\Cache\\cache.ini' % os.getenv('SYSTEMDRIVE')
  	cachefile = os.path.expanduser('~/.loki/ut/Cache/cache.ini')
  if len(sys.argv) > 1:
  	cachefile = sys.argv[1]
  def ReadFile(file):
  	newfile = [ ]
  	move = [ ]
  	f = open(file)
  	for line in f:
  		if line[0] == ';' or line[0] == '[':
  		line = line.strip()
  		if line == '':
  		l = line.split('=')
  		# There are multiple versions of these files active on servers, so skip
  		# them and keep them in cache!
  		if l[1] == 'INF_AimedPistols.u' or l[1] == 'UTCompass.u':
  	return move, newfile
  if not os.path.exists(cachefile):
  	print 'Error: cache.ini file "%s" does not exists.' % cachefile
  	print 'Please specify the cache.ini file as the first argument'
  	print 'Example: %s C:/games/UnrealTournament/Cache/cache.ini' % sys.argv[0]
  shutil.copy(cachefile, cachefile + '.bak')
  move, newfile = ReadFile(cachefile)
  dirname = os.path.dirname(cachefile)
  for file in move:
  	if os.path.exists('%s/%s.uxx' % (dirname, file[0])):
  		os.rename('%s/%s.uxx' % (dirname, file[0]), '%s/%s' % (dirname, file[1]))
  		print file
  		print "Warning, cache file `%s/%s.uxx' doesn't exist." % (dirname, file[0])
  f = open(cachefile, 'w')
  for n in newfile:
  	f.write(n[0] + '=' + n[1] + '\n')
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote

freebsd, games, python, unreal tournament

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to manage multiple freebsd servers? WaBBiT FreeBSD General 1 4th April 2009 10:37 PM
improve proxy cache and replace gif MIME milo974 OpenBSD General 1 10th July 2008 12:14 PM
Memory cache graudeejs FreeBSD General 3 9th July 2008 03:27 AM
Manage changes in /etc johny FreeBSD Security 4 23rd May 2008 09:00 AM
in how many min/sec arp cache gets cleared in freebsd rex FreeBSD General 1 9th May 2008 08:01 AM

All times are GMT. The time now is 04:42 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick