#!bin/sh
# This rebuilds the index and skips any name that isn't in the existing
# index, or where the file doesn't exist.  It doesn't have your check for
# invalid idnums etc, and doesn't have clan/race/class.  I think idnum
# and name are swapped too, but this works on the stock stuff I'm working
# with.  Bri 6/13/98

if [ -r plr_index.fixed ]; then rm -f plr_index.fixed
fi

awk '{print $2}' plr_index | {
  while read NAME
  do {
    PREFIX=`echo $NAME | cut -b 1`
    FILE=`echo $PREFIX/$NAME`
    if [ -f $FILE ]; then {
      name=`echo $FILE | cut -d"/" -f 2 | cut -d" " -f 1`
      idnum=`grep "Id  :" $FILE |cut -d" " -f 4`
      level=`grep "Levl:" $FILE |cut -d" " -f 2`
      last=`grep "Last:" $FILE |cut -d" " -f 2`
      echo $idnum $name $level "0" $last >> plr_index.fixed
    } fi
  } done
  echo "~" >> plr_index.fixed
}
