#!/bin/sh
#
# enable_tpp  -- Enable the Third Person Perspective CTF mod...
#

cd ..
INST=`pwd`
BASE=`basename $INST`
if [ "$BASE" == "ctf" ]
then
  if [ -f gamei586.so ]
  then
    if [ -h gamei586.so ]
    then
      if [ -f thirdpp/tag ]
      then
        echo "Thirdpp-CTF already enabled..."
      else
        if [ -f thirdpp/gamei586.so ]
        then
          rm -f gamei586.so
          rm -f zoid/tag
          echo `date` > thirdpp/tag
          ln -s thirdpp/gamei586.so gamei586.so
          echo "Thirdpp-CTF enabled..."
        else
          echo "ERROR: unable to find Quake2/ctf/thirdpp/gamei586.so"
        fi
      fi
    else
      if [ -f zoid/gamei586.so ]
      then
        echo "ERROR: Quake2/ctf/zoid/gamei586.so already exists..."
      else
        if [ -f thirdpp/gamei586.so ]
        then 
          mv gamei586.so zoid
          rm -f zoid/tag
          echo `date` > thirdpp/tag
          ln -s thirdpp/gamei586.so gamei586.so
          echo "Thirdpp-CTF enabled..."
        else
          echo "ERROR: unable to find Quake2/ctf/thirdpp/gamei586.so"
        fi
      fi
    fi
  else
    echo "ERROR: unable to find Quake2/ctf/gamei586.so"
  fi
else
  echo "ERROR: not in Quake2/ctf/ directory..."
fi
