UT Cache Extractor for Mac and Linux  (Read 12641 times)

N3Cr0

  • 1337
  • *
  • Posts: 641
  • Country: de
UT Cache Extractor for Mac and Linux
« on: January 02, 2011, 12:52 »
After Raj told us multiple times we shall use the cache extractor I wanted to try it. Well, I've noticed it's only availlable for Windows and it just copies the cache files renamed to the right directories.
Then I have found a shell script for the MAC version:

Code: [Select]
#!/bin/sh

# ut2004cachex.sh
# Unreal Cache Extractor 0.1
#
# a simple script to copy the cache contents to the UT2004 bundle with proper names
# written by Chris Meyer 9 May 2004
# [7S]HunterX on Unreal
#
# known bugs:
# filenames with an equals sign in their names are not copied to bundle
# since cut uses equals sign as delimiter.
# assuming that the size of the cache filename without extension is always 34
# this should be fixable by using sed instead of cut, but I don't really know sed commands.
#
# any comments or suggestions would be welcome
# hunterx11@mcihispeed.net
#
# also feel free to modify and redistribute
# this script should be portable to linux simply by changing the appropriate directory names

pushd ~/Library/Application\ Support/Unreal\ Tournament\ 2004/Cache > /dev/null

if ! [ -d "extracted" ]; then
mkdir extracted
fi

for entry in $(grep '=' < cache.ini); do
source="$(echo $entry | cut -f 1 -d '=').uxx"
target="$(echo $entry | cut -f 2 -d '=')"
cp -fv $source extracted/$target
done

cd extracted

if [ -n "$(ls | grep .ukx)" ]; then
for animation in *.ukx; do
mv -nv $animation /Applications/Unreal\ Tournament\ 2004.app/Animations/$animation
done
fi

if [ -n "$(ls | grep .ut2)" ]; then
for map in *.ut2; do
mv -nv $map /Applications/Unreal\ Tournament\ 2004.app/Maps/$map
done
fi

if [ -n "$(ls | grep .ogg)" ]; then
for music in *.ogg; do
mv -nv $music /Applications/Unreal\ Tournament\ 2004.app/Music/$music
done
fi

if [ -n "$(ls | grep .uax)" ]; then
for sound in *.uax; do
mv -nv $sound /Applications/Unreal\ Tournament\ 2004.app/Sounds/$sound
done
fi

if [ -n "$(ls | grep .usx)" ]; then
for static in *.usx; do
mv -nv $static /Applications/Unreal\ Tournament\ 2004.app/StaticMeshes/$static
done
fi

if [ -n "$(ls | grep .u)" ]; then
for system in *.u; do
mv -nv $system /Applications/Unreal\ Tournament\ 2004.app/System/$system
done
fi

if [ -n "$(ls | grep .utx)" ]; then
for texture in *.utx; do
mv -nv $texture /Applications/Unreal\ Tournament\ 2004.app/Textures/$texture
done
fi

cd ..
if [ -n "$(ls)" ]; then
for garbage in extracted/*; do
echo -n "Deleting..."
rm -fv $garbage
done
fi
rm -fr extracted

popd > /dev/null

I confess I'm not good in making shell scripts, but I noticed it uses the same commands like in Linux so I only had to change the paths and now it fits to the Linux version

Be sure you have the directories /Animations, /Maps, /Music, /Sounds, /StaticMeshes, /System and /Textures in your ~/.ut2004 folder, if not: create them before executing this script.
Code: [Select]

#!/bin/sh

# ut2004cachex.sh
# Unreal Cache Extractor 0.1
#
# a simple script to copy the cache contents to the UT2004 bundle with proper names
# written by Chris Meyer 9 May 2004
# [7S]HunterX on Unreal
#
# modified by Sebastian Fischer aka N3Cr0 2 January 2011
#
# known bugs:
# filenames with an equals sign in their names are not copied to bundle
# since cut uses equals sign as delimiter.
# assuming that the size of the cache filename without extension is always 34
# this should be fixable by using sed instead of cut, but I don't really know sed commands.
# EDIT by N3Cr0: I'm not sure if that also applies to linux - I have not tested it yet.
#
# any comments or suggestions would be welcome
# hunterx11@mcihispeed.net
# Edit: themiasma.com or fmcnecro@yahoo.de
#
#
# also feel free to modify and redistribute
# this script should be portable to linux simply by changing the appropriate directory names
# Edit: That's the part I have forgotten to read. lol    However, He's right: it IS portable to linux ;)
#
# I take no responsibility for any damages on your game or operating system,
# so if you are unsure take a look at the directory paths

pushd ~/.ut2004/Cache > /dev/null

if ! [ -d "extracted" ]; then
mkdir extracted
fi

for entry in $(grep '=' < cache.ini); do
source="$(echo $entry | cut -f 1 -d '=').uxx"
target="$(echo $entry | cut -f 2 -d '=')"
cp -fv $source extracted/$target
done

cd extracted

if [ -n "$(ls | grep .ukx)" ]; then
for animation in *.ukx; do
mv -nv $animation ~/.ut2004/Animations/$animation
done
fi

if [ -n "$(ls | grep .ut2)" ]; then
for map in *.ut2; do
mv -nv $map ~/.ut2004/Maps/$map
done
fi

if [ -n "$(ls | grep .ogg)" ]; then
for music in *.ogg; do
mv -nv $music ~/.ut2004/Music/$music
done
fi

if [ -n "$(ls | grep .uax)" ]; then
for sound in *.uax; do
mv -nv $sound ~/.ut2004/Sounds/$sound
done
fi

if [ -n "$(ls | grep .usx)" ]; then
for static in *.usx; do
mv -nv $static ~/.ut2004/StaticMeshes/$static
done
fi

if [ -n "$(ls | grep .u)" ]; then
for system in *.u; do
mv -nv $system ~/.ut2004/System/$system
done
fi

if [ -n "$(ls | grep .utx)" ]; then
for texture in *.utx; do
mv -nv $texture ~/.ut2004/Textures/$texture
done
fi

cd ..
if [ -n "$(ls)" ]; then
for garbage in extracted/*; do
echo -n "Deleting..."
rm -fv $garbage
done
fi
rm -fr extracted

popd > /dev/null

OK, that's usefull if you wanna play UT2004, but what about KFmod? Well, i thought "Why not change the path to the KFMod20 directory?"
So here it is ;)

Code: [Select]
#!/bin/sh

# ut2004cachex.sh
# Unreal Cache Extractor 0.1
#
# a simple script to copy the cache contents to the UT2004 bundle with proper names
# written by Chris Meyer 9 May 2004
# [7S]HunterX on Unreal
#
# modified by Sebastian Fischer aka N3Cr0 2 January 2011
#
# known bugs:
# filenames with an equals sign in their names are not copied to bundle
# since cut uses equals sign as delimiter.
# assuming that the size of the cache filename without extension is always 34
# this should be fixable by using sed instead of cut, but I don't really know sed commands.
# EDIT by N3Cr0: I'm not sure if that also applies to linux - I have not tested it yet.
#
# any comments or suggestions would be welcome
# hunterx11@mcihispeed.net
# Edit: themiasma.com or fmcnecro@yahoo.de
#
#
# also feel free to modify and redistribute
# this script should be portable to linux simply by changing the appropriate directory names
# Edit: That's the part I have forgotten to read, lol    However, He's right: it IS portable to linux ;)
#
# I take no responsibility for any damages on your game or operating system,
# so if you are unsure take a look at the directory paths.


pushd ~/.ut2004/Cache > /dev/null

if ! [ -d "extracted" ]; then
mkdir extracted
fi

for entry in $(grep '=' < cache.ini); do
source="$(echo $entry | cut -f 1 -d '=').uxx"
target="$(echo $entry | cut -f 2 -d '=')"
cp -fv $source extracted/$target
done

cd extracted

if [ -n "$(ls | grep .ukx)" ]; then
for animation in *.ukx; do
mv -nv $animation ~/.ut2004/KFMod20/Animations/$animation
done
fi

if [ -n "$(ls | grep .ut2)" ]; then
for map in *.ut2; do
mv -nv $map ~/.ut2004/KFMod20/Maps/$map
done
fi

if [ -n "$(ls | grep .ogg)" ]; then
for music in *.ogg; do
mv -nv $music ~/.ut2004/KFMod20/Music/$music
done
fi

if [ -n "$(ls | grep .uax)" ]; then
for sound in *.uax; do
mv -nv $sound ~/.ut2004/KFMod20/Sounds/$sound
done
fi

if [ -n "$(ls | grep .usx)" ]; then
for static in *.usx; do
mv -nv $static ~/.ut2004/KFMod20/StaticMeshes/$static
done
fi

if [ -n "$(ls | grep .u)" ]; then
for system in *.u; do
mv -nv $system ~/.ut2004/KFMod20/System/$system
done
fi

if [ -n "$(ls | grep .utx)" ]; then
for texture in *.utx; do
mv -nv $texture ~/.ut2004/KFMod20/Textures/$texture
done
fi

cd ..
if [ -n "$(ls)" ]; then
for garbage in extracted/*; do
echo -n "Deleting..."
rm -fv $garbage
done
fi
rm -fr extracted

popd > /dev/null
http://n3cr0.itch.io/

xmpp: n3cr0@jabber.ccc.de

[MiA]Raj

  • 1337
  • *
  • Posts: 1274
  • Country: ee
    • rajliv
Re: UT Cache Extractor for Mac and Linux
« Reply #1 on: January 02, 2011, 17:58 »
Dunno if there are any Linux users here besides you but thanks - could be useful :)