From 0211bc04ff85a01c982dad73a51a1a10e6ecff5f Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Wed, 27 Feb 2013 16:46:33 +0200 Subject: [PATCH] OpenArena: cron script to announce gaming event --- .../commandergenius/commandergenius | 2 +- .../openarena/GamingEventCountdown.sh | 63 +++++++++++++++++++ project/jni/application/openarena/engine | 2 +- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100755 project/jni/application/openarena/GamingEventCountdown.sh diff --git a/project/jni/application/commandergenius/commandergenius b/project/jni/application/commandergenius/commandergenius index 6f28771d5..d1b8a7ae0 160000 --- a/project/jni/application/commandergenius/commandergenius +++ b/project/jni/application/commandergenius/commandergenius @@ -1 +1 @@ -Subproject commit 6f28771d57ca7d878e3cfee08014651b854b9c7f +Subproject commit d1b8a7ae03b1a0960722abbab38bbb8fca98e7cd diff --git a/project/jni/application/openarena/GamingEventCountdown.sh b/project/jni/application/openarena/GamingEventCountdown.sh new file mode 100755 index 000000000..34800815e --- /dev/null +++ b/project/jni/application/openarena/GamingEventCountdown.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# Date format is free-form +DATE="This Friday 9PM +EST" +# Event message +MESSAGE="^2Friday ^1Frag ^2Evening ^7on ^3CyberXZT server\n^6" +# Message when no event is happening +NO_EVENT_MESSAGE="To change map, press ^3Back ^7-> ^3Vote" +# How long event will happen, in hours +DURATION=2 +# When to start announcing event, in days +ANNOUNCE_START=3 + +OUT="$1" +if [ -z "$OUT" ]; then + OUT=motd.cfg +fi + +S1=`date +%s -d "$DATE"` +S2=`date +%s -d now` +SECONDS=`expr $S1 - $S2` +MINUTES=`expr $SECONDS / 60` +HOURS=`expr $MINUTES / 60` +DAYS=`expr $HOURS / 24` +MINUTES=`expr $MINUTES % 60` +HOURS=`expr $HOURS % 24` + +TXT="" +if [ $SECONDS -lt 0 ]; then + if [ $SECONDS -gt `expr -$DURATION '*' 3600` ]; then + TXT="come join right now!" + fi +else + if [ "$MINUTES" '!=' 0 ]; then + TXT="$MINUTES minutes" + fi + if [ "$HOURS" '!=' 0 ]; then + if [ "$HOURS" '=' 1 ]; then + TXT="$HOURS hour $TXT" + else + TXT="$HOURS hours $TXT" + fi + fi + if [ "$DAYS" '!=' 0 ]; then + if [ "$DAYS" '=' 1 ]; then + TXT="tomorrow $TXT" + else + TXT="in $DAYS days $TXT" + fi + else + TXT="in $TXT" + fi +fi + +if [ $SECONDS -gt `expr $ANNOUNCE_START '*' 3600 '*' 24` ]; then + TXT="" # Do not announce event if it's too far in the future +fi + +if [ -n "$TXT" ]; then + echo "$MESSAGE$TXT" > "$OUT" +else + echo "$NO_EVENT_MESSAGE" > "$OUT" +fi diff --git a/project/jni/application/openarena/engine b/project/jni/application/openarena/engine index eaa309f9c..37e74bc92 160000 --- a/project/jni/application/openarena/engine +++ b/project/jni/application/openarena/engine @@ -1 +1 @@ -Subproject commit eaa309f9c18c4e4773e04d7c97c148454ad32d50 +Subproject commit 37e74bc922952a6e81af9719c11f47bf0f593860