Update the script to make it work correctly, it assumed too much about the layout of the file, so it was broken. New script should be somewhat more robust.
git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@9121 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
3726c4d95c
commit
f19c9ca871
|
@ -1,3 +1,8 @@
|
||||||
|
2008-05-20 16:01 anmaster
|
||||||
|
* brest/pshops/pshop_copier: Update the script to make it work correctly,
|
||||||
|
it assumed too much about the layout of the file, so it was broken.
|
||||||
|
New script should be somewhat more robust.
|
||||||
|
|
||||||
2008-05-18 19:37 rednaxela
|
2008-05-18 19:37 rednaxela
|
||||||
* mlab/citydeclouds/*,
|
* mlab/citydeclouds/*,
|
||||||
darcap/darcap/pirates.1,
|
darcap/darcap/pirates.1,
|
||||||
|
|
|
@ -16,70 +16,80 @@ mv pshop1 PSHOP
|
||||||
rm -f pshop*/*
|
rm -f pshop*/*
|
||||||
|
|
||||||
#copy PSHOP to all the pshop directories
|
#copy PSHOP to all the pshop directories
|
||||||
for FILE in pshop*;do
|
for FILE in pshop*; do
|
||||||
if [ -d "$FILE" ]
|
if [[ -d "$FILE" ]]; then
|
||||||
then
|
#copy the files into the pshops directories
|
||||||
#copy the files into the pshops directories
|
cp PSHOP/* "${FILE}/"
|
||||||
cp PSHOP/* "$FILE"/
|
|
||||||
|
|
||||||
#go there
|
#go there
|
||||||
cd $FILE
|
cd $FILE
|
||||||
|
|
||||||
#for each file in the pshop directory
|
#for each file in the pshop directory
|
||||||
for MYFILE in *;do
|
for MYFILE in *; do
|
||||||
#correct the key values on inventory checkers
|
#correct the key values on inventory checkers
|
||||||
sed s/pshop1/$FILE/ $MYFILE > "$MYFILE"_2
|
sed "s/pshop1/${FILE}/" "$MYFILE" > "${MYFILE}_2"
|
||||||
rm -f $MYFILE
|
rm -f $MYFILE
|
||||||
mv "$MYFILE"_2 $MYFILE
|
mv "${MYFILE}_2" $MYFILE
|
||||||
done
|
done
|
||||||
|
|
||||||
#get the pshopnum
|
#get the pshopnum
|
||||||
PSHOPNUM=`echo "$FILE" | cut -d p -f3`
|
PSHOPNUM=$(cut -d p -f3 <<< "$FILE")
|
||||||
|
|
||||||
#calculate HP and SP based on pshopnum
|
#calculate HP and SP based on pshopnum
|
||||||
if [ $PSHOPNUM -lt 14 ]
|
if [[ $PSHOPNUM -lt 14 ]]; then
|
||||||
then
|
#top row of shops
|
||||||
#top row of shops
|
SP="2"
|
||||||
SP="2"
|
HP=$(( PSHOPNUM * 3 + 1 ))
|
||||||
TEMPHP=`expr $PSHOPNUM \* 3`
|
else
|
||||||
HP=`expr $TEMPHP + 1`
|
#bottom row of shops
|
||||||
else
|
SP="6"
|
||||||
#bottom row of shops
|
MODPSHOPNUM=$(( PSHOPNUM - 14 ))
|
||||||
SP="6"
|
HP=$(( MODPSHOPNUM * 3 + 1 ))
|
||||||
MODPSHOPNUM=`expr $PSHOPNUM - 14`
|
fi
|
||||||
TEMPHP=`expr $MODPSHOPNUM \* 3`
|
|
||||||
HP=`expr $TEMPHP + 1`
|
# Keep track of state when parsing.
|
||||||
|
# 0 Before/after exit, looking for slaying
|
||||||
|
# 1 During exit, looking for hp and sp
|
||||||
|
state=0
|
||||||
|
hadhp=0
|
||||||
|
hadsp=0
|
||||||
|
#fix the exit on gfloor
|
||||||
|
while read LINE; do
|
||||||
|
case $state in
|
||||||
|
0)
|
||||||
|
if [[ "$LINE" == "slaying ../pshops_main" ]]; then
|
||||||
|
state=1
|
||||||
|
fi
|
||||||
|
echo "$LINE" >> gfloor2
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
case $LINE in
|
||||||
|
"hp "*)
|
||||||
|
echo "hp $HP" >> gfloor2
|
||||||
|
hadhp=1
|
||||||
|
;;
|
||||||
|
"sp "*)
|
||||||
|
echo "sp $SP" >> gfloor2
|
||||||
|
hadsp=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$LINE" >> gfloor2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [[ ( $hadhp == 1 ) && ( $hadsp == 1 ) ]]; then
|
||||||
|
state=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < gfloor
|
||||||
|
|
||||||
|
#replace gfloor with gfloor2
|
||||||
|
rm -f gfloor
|
||||||
|
mv gfloor2 gfloor
|
||||||
|
|
||||||
|
#go back up
|
||||||
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#fix the exit on gfloor
|
|
||||||
while read LINE
|
|
||||||
do
|
|
||||||
if [ "$LINE" == "slaying ../pshops_main" ]
|
|
||||||
then
|
|
||||||
#remove the 2 lines
|
|
||||||
read dummy_hp_line
|
|
||||||
read dummp_sp_line
|
|
||||||
|
|
||||||
#add the original back
|
|
||||||
echo "$LINE" >> gfloor2
|
|
||||||
|
|
||||||
#write the new lines
|
|
||||||
echo "hp $HP" >> gfloor2
|
|
||||||
echo "sp $SP" >> gfloor2
|
|
||||||
|
|
||||||
else
|
|
||||||
#just add it back to the file
|
|
||||||
echo "$LINE" >> gfloor2
|
|
||||||
fi
|
|
||||||
done < gfloor
|
|
||||||
|
|
||||||
#replace gfloor with gfloor2
|
|
||||||
rm -f gfloor
|
|
||||||
mv gfloor2 gfloor
|
|
||||||
|
|
||||||
#go back up
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#put pshop1 back
|
#put pshop1 back
|
||||||
|
|
Loading…
Reference in New Issue