diff --git a/s/preview b/s/preview index 9833e3f89..a8291a8d5 100755 --- a/s/preview +++ b/s/preview @@ -1,58 +1,158 @@ #!/bin/bash -usage() { - echo "usage: $0 game-id" - exit 1 +function usage() { +cat <] [-g ] [-f ] command [args] +commands: + build -- pull and rebuild the code + version -- print the current build number + setup -- create base directory and config files + run -- run a turn + send [id ...] -- send reports to one or more factions, or to all ids in +HEREDOC +exit 1 } -abort() { - echo $1 - [ -z $2 ] && exit -1 - exit $2 # otherwise +function abort() { +echo $1 +[ -z $2 ] && exit -1 +exit $2 # otherwise } -[ -d $ERESSEA ] || abort "Invalid env variable ERESSEA ($ERESSEA)" - -GAME=$1 -LIVE=$ERESSEA/game-$GAME -SOURCE=$ERESSEA/git -TESTROOT=$LIVE/test -REBUILD=0 - -[ -d $LIVE ] || usage -[ -d $SOURCE ] || abort "missing source directory: $SOURCE" - -[ -f $LIVE/turn ] || abort "missing turn file" -let TURN=$(cat $LIVE/turn)-1 - -if [ $REBUILD ] ; then +function build() { +assert_dir $SOURCE cd $SOURCE git pull || abort "failed to update source. do you have local changes?" -BUILD=$(grep BUILD src/build.h | awk '{ print $3 }') s/build || abort "build failed." -fi +} -echo "testing turn $TURN of game $GAME with build $BUILD" +function assert_file() { +[ -e $1 ] || abort "missing file: $1" +} + +function assert_files() { +while [ ! -z $1 ] ; do +assert_file $1 +shift +done +} + +function assert_dir() { +[ -d $1 ] || abort "missing directory: $1" +} + +function version() { +assert_dir $SOURCE +cd $SOURCE +build=$(grep BUILD src/build.h | awk '{ print $3 }') +echo "eressea build $build" +} + +function setup() { +assert_dir $SOURCE +assert_dir $LIVE mkdir -p $TESTROOT +assert_dir $TESTROOT cd $TESTROOT -if [ ! -e eressea.ini ] ; then cat >| eressea.ini <number != 0 && u_race(u2) != u_race(u)) { - log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u_race(u)->_name[0], u_race(u2)->_name[1]); + log_debug("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u_race(u)->_name[0], u_race(u2)->_name[0]); error = 139; } else if (u2 != NULL && (get_racename(u2->attribs) diff --git a/src/laws.c b/src/laws.c index e6106bfc0..9f9e16d75 100755 --- a/src/laws.c +++ b/src/laws.c @@ -965,8 +965,6 @@ void demographics(void) free(free_migrants); free_migrants = m; }; - if (verbosity >= 1) - putchar('\n'); remove_empty_units();