Fix warning waits for intervals of 1 or 2 minutes

This commit is contained in:
Ben Peddell 2017-06-15 08:51:13 +10:00
parent 9a770e6143
commit d0265ebfe8

View File

@ -1524,42 +1524,47 @@ doWarn(){
local warnintervals=( 90 60 45 30 20 15 10 5 4 3 2 ) local warnintervals=( 90 60 45 30 20 15 10 5 4 3 2 )
for warninterval in "${warnintervals[@]}"; do if (( warnminutes > 2 )); then
if [ "`getServerPID`" != "$pid" ]; then for warninterval in "${warnintervals[@]}"; do
echo "Server has stopped. Aborting $1" if [ "`getServerPID`" != "$pid" ]; then
rm -f "${arkserverroot}/${arkwarnlockfile}" echo "Server has stopped. Aborting $1"
return 1 rm -f "${arkserverroot}/${arkwarnlockfile}"
fi return 1
if (( warnminutes >= warninterval )); then fi
sleep 1m & if (( warnminutes >= warninterval )); then
sleeppid=$! sleep 1m &
printWarnMessage "$1" "$2" "minutes" "$warnminutes" sleeppid=$!
for (( min = warnminutes; min >= warninterval; min-- )); do printWarnMessage "$1" "$2" "minutes" "$warnminutes"
numplayers=$(numPlayersConnected) for (( min = warnminutes; min >= warninterval; min-- )); do
echo "There are ${numplayers} players connected" numplayers=$(numPlayersConnected)
if [[ "numplayers" == "-1" ]]; then echo "There are ${numplayers} players connected"
echo "Server is not running. Shutting down immediately" if [[ "numplayers" == "-1" ]]; then
return 0 echo "Server is not running. Shutting down immediately"
elif (( (numplayers + 0) == 0 )); then return 0
doBroadcastWithEcho "Nobody is connected. Shutting down immediately" elif (( (numplayers + 0) == 0 )); then
rm -f "${arkserverroot}/${arkwarnlockfile}" doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
return 0 rm -f "${arkserverroot}/${arkwarnlockfile}"
fi return 0
if isUpdateCancelRequested; then fi
doBroadcastWithEcho "Restart cancelled by player request" if isUpdateCancelRequested; then
return 1 doBroadcastWithEcho "Restart cancelled by player request"
fi return 1
wait $sleeppid fi
if (( $min > $warninterval )); then wait $sleeppid
sleep 1m & if (( $min > $warninterval )); then
sleeppid=$! sleep 1m &
fi sleeppid=$!
done fi
warnminutes=$(( warninterval - 1 )) done
fi warnminutes=$(( warninterval - 1 ))
done fi
done
fi
local warnseconds=120 local warnseconds=120
if (( warnminutes == 1 )); then
warnseconds = 60
fi
warnintervals=( 90 60 45 30 20 15 10 5 0 ) warnintervals=( 90 60 45 30 20 15 10 5 0 )
for warninterval in "${warnintervals[@]}"; do for warninterval in "${warnintervals[@]}"; do
sleep $(( warnseconds - warninterval ))s & sleep $(( warnseconds - warninterval ))s &