Merge branch 'master' of github.com:badgerman/eressea

This commit is contained in:
Enno Rehling 2015-01-12 20:25:09 +01:00
commit 2ddd5d242a
15 changed files with 168 additions and 23 deletions

31
process/cron/backup-eressea Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
if [ -z $ERESSEA ] ; then
ERESSEA=$HOME/eressea
echo "The ERESSEA environment variable is not set. Assuming $ERESSEA."
fi
GAME=$1
if [ ! -d $ERESSEA/game-$GAME ]; then
echo "No such game: game-$GAME."
exit 1
fi
cd $ERESSEA/game-$GAME
TURN=$2
if [ -z $TURN ]; then
TURN=$(cat turn)
fi
if [ ! -e data/$TURN.dat ]; then
echo "No data for turn $TURN in game $GAME."
exit 2
fi
if [ ! -d backup ] ; then
echo "creating missing backup directory for game $GAME."
mkdir -p ~/backup/eressea/game-$GAME
ln -sf ~/backup/eressea/game-$GAME backup
fi
files="data/$TURN.dat parteien.full parteien"
if [ -e orders.$TURN ]; then
files="$files orders.$TURN"
fi
echo "backup turn $TURN, game $GAME, files: $files"
tar cjf backup/$TURN.tar.bz2 $files

16
process/cron/create-orders Executable file
View File

@ -0,0 +1,16 @@
GAME=$1
TURN=$2
if [ ! -d $ERESSEA/game-$GAME ] ; then
echo "No such game: $GAME"
exit 1
fi
cd $ERESSEA/game-$GAME
if [ -d orders.dir.$TURN ]; then
echo "orders.dir.$TURN already exists"
else
mv orders.dir orders.dir.$TURN
mkdir -p orders.dir
fi
ls -1rt orders.dir.$TURN/turn-* | xargs cat > orders.$TURN

View File

@ -12,14 +12,15 @@ if [ -d $REPORTS ]; then
rm -rf $REPORTS
fi
mkdir $REPORTS
$BIN/backup-eressea $GAME $TURN
cd $ERESSEA/game-$GAME
if [ -d test ]; then
touch test/execute.lock
fi
$BIN/create-orders $GAME $TURN
$BIN/backup-eressea $GAME $TURN
rm -f execute.lock
$BIN/run-turn $GAME
$BIN/run-turn $GAME $TURN
touch execute.lock
if [ ! -s $ERESSEA/game-$GAME/orders.$TURN ]; then

14
process/cron/run-turn Executable file
View File

@ -0,0 +1,14 @@
GAME=$1
TURN=$2
if [ ! -d $ERESSEA/game-$GAME ] ; then
echo "No such game: $GAME"
exit 1
fi
cd $ERESSEA/game-$GAME
echo "running turn $TURN, game $GAME"
$ERESSEA/server/bin/eressea -v1 -t $TURN run-turn.lua
mkdir -p log
ln -f eressea.log log/eressea.log.$TURN

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 5
#define VERSION_BUILD 696
#define VERSION_BUILD 697

View File

@ -20,12 +20,14 @@
#include <modules/xmas.h>
#include <items/itemtypes.h>
#include <attributes/attributes.h>
#include <races/races.h>
#include "chaos.h"
#include "report.h"
#include "items.h"
#include "creport.h"
#include "names.h"
#include "wormhole.h"
#include "spells.h"
void game_done(void)
{
@ -55,6 +57,8 @@ void game_init(void)
register_nr();
register_cr();
register_races();
register_spells();
register_names();
register_resources();
register_buildings();

View File

@ -106,7 +106,7 @@ static void test_give_men_none(CuTest * tc) {
env.f2 = env.f1 = test_create_faction(0);
setup_give(&env);
msg = give_men(0, env.src, env.dst, NULL);
CuAssertStrEquals(tc, "error96", (const char *)msg->parameters[3].v);
CuAssertStrEquals(tc, "error96", test_get_messagetype(msg));
CuAssertIntEquals(tc, 1, env.dst->number);
CuAssertIntEquals(tc, 1, env.src->number);
test_cleanup();
@ -137,7 +137,7 @@ static void test_give_men_requires_contact(CuTest * tc) {
env.f2 = test_create_faction(0);
setup_give(&env);
msg = give_men(1, env.src, env.dst, NULL);
CuAssertStrEquals(tc, "feedback_no_contact", (const char *)msg->parameters[3].v);
CuAssertStrEquals(tc, "feedback_no_contact", test_get_messagetype(msg));
CuAssertIntEquals(tc, 1, env.dst->number);
CuAssertIntEquals(tc, 1, env.src->number);
test_cleanup();
@ -150,7 +150,7 @@ static void test_give_men_not_to_self(CuTest * tc) {
env.f2 = env.f1 = test_create_faction(0);
setup_give(&env);
msg = give_men(1, env.src, env.src, NULL);
CuAssertStrEquals(tc, "error10", (const char *)msg->parameters[3].v);
CuAssertStrEquals(tc, "error10", test_get_messagetype(msg));
CuAssertIntEquals(tc, 1, env.src->number);
test_cleanup();
}

View File

@ -2,7 +2,11 @@
#include "types.h"
#include "curse.h"
#include <kernel/region.h>
#include <kernel/unit.h>
#include <util/attrib.h>
#include <util/message.h>
#include <tests.h>
#include <CuTest.h>
@ -22,9 +26,70 @@ static void test_curse(CuTest * tc)
CuAssertPtrEquals(tc, NULL, result);
}
typedef struct {
curse *c;
region *r;
unit *u;
} curse_fixture;
static void setup_curse(curse_fixture *fix, const char *name) {
test_cleanup();
fix->r = test_create_region(0, 0, NULL);
fix->u = test_create_unit(test_create_faction(NULL), fix->r);
fix->c = create_curse(fix->u, &fix->r->attribs, ct_find(name), 1.0, 1, 1.0, 0);
}
static void test_magicstreet(CuTest *tc) {
curse_fixture fix;
message *msg;
setup_curse(&fix, "magicstreet");
fix.c->duration = 2;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::magicstreet", test_get_messagetype(msg));
msg_release(msg);
test_cleanup();
}
static void test_magicstreet_warning(CuTest *tc) {
curse_fixture fix;
message *msg;
setup_curse(&fix, "magicstreet");
fix.c->duration = 1;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::magicstreetwarn", test_get_messagetype(msg));
msg_release(msg);
test_cleanup();
}
static void test_good_dreams(CuTest *tc) {
curse_fixture fix;
message *msg;
setup_curse(&fix, "gbdream");
fix.c->effect = 1;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::gooddream", test_get_messagetype(msg));
msg_release(msg);
test_cleanup();
}
static void test_bad_dreams(CuTest *tc) {
curse_fixture fix;
message *msg;
setup_curse(&fix, "gbdream");
fix.c->effect = -1;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::baddream", test_get_messagetype(msg));
msg_release(msg);
test_cleanup();
}
CuSuite *get_curse_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_curse);
SUITE_ADD_TEST(suite, test_magicstreet);
SUITE_ADD_TEST(suite, test_magicstreet_warning);
SUITE_ADD_TEST(suite, test_good_dreams);
SUITE_ADD_TEST(suite, test_bad_dreams);
return suite;
}

View File

@ -280,9 +280,7 @@ unit *addplayer(region * r, faction * f)
bool checkpasswd(const faction * f, const char *passwd)
{
if (passwd && unicode_utf8_strcasecmp(f->passw, passwd) == 0)
return true;
return false;
return (passwd && unicode_utf8_strcasecmp(f->passw, passwd) == 0);
}
variant read_faction_reference(struct storage * store)

View File

@ -1725,21 +1725,23 @@ int unit_max_hp(const unit * u)
get_param_int(global.parameters, "rules.stamina", STAMINA_AFFECTS_HP);
}
h = u_race(u)->hitpoints;
if (heal_ct == NULL)
heal_ct = ct_find("healingzone");
if (rules_stamina & 1) {
p = pow(effskill(u, SK_STAMINA) / 2.0, 1.5) * 0.2;
h += (int)(h * p + 0.5);
}
/* der healing curse veraendert die maximalen hp */
if (u->region) {
if (heal_ct == NULL)
heal_ct = ct_find("healingzone");
if (heal_ct) {
curse *c = get_curse(u->region->attribs, heal_ct);
if (c) {
h = (int)(h * (1.0 + (curse_geteffect(c) / 100)));
}
}
}
return h;
}

View File

@ -304,8 +304,6 @@ int main(int argc, char **argv)
L = lua_init();
game_init();
register_races();
register_spells();
bind_monsters(L);
err = eressea_run(L, luafile);
if (err) {

View File

@ -74,11 +74,12 @@ static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c
unused_arg(obj);
assert(typ == TYP_REGION);
if (curse_geteffect(c) > 0) {
if (c->effect > 0) {
return msg_message("curseinfo::gooddream", "id", c->no);
}
} else {
return msg_message("curseinfo::baddream", "id", c->no);
}
}
static struct curse_type ct_gbdream = {
"gbdream",
@ -99,7 +100,7 @@ static message *cinfo_magicstreet(const void *obj, objtype_t typ, const curse *
assert(typ == TYP_REGION);
/* Warnung vor Auflösung */
if (c->duration <= 2) {
if (c->duration >= 2) {
return msg_message("curseinfo::magicstreet", "id", c->no);
}
return msg_message("curseinfo::magicstreetwarn", "id", c->no);

View File

@ -1,4 +1,5 @@
#include <platform.h>
#include <eressea.h>
#include <kernel/config.h>
#include <CuTest.h>
#include <stdio.h>
@ -30,7 +31,7 @@ int RunAllTests(void)
int fail_count, flags = log_flags;
log_flags = LOG_FLUSH | LOG_CPERROR;
kernel_init();
game_init();
/* self-test */
RUN_TESTS(suite, tests);
@ -86,7 +87,7 @@ int RunAllTests(void)
log_flags = flags;
fail_count = suite->failCount;
CuSuiteDelete(suite);
kernel_done();
game_done();
return fail_count;
}

View File

@ -16,6 +16,7 @@
#include <kernel/terrain.h>
#include <util/functions.h>
#include <util/language.h>
#include <util/message.h>
#include <util/log.h>
#include <assert.h>
@ -192,3 +193,14 @@ void test_create_world(void)
test_create_shiptype("boat");
}
const char * test_get_messagetype(const message *msg) {
const char * name = msg->type->name;
if (strcmp(name, "missing_message") == 0) {
name = (const char *)msg->parameters[0].v;
}
else if (strcmp(name, "missing_feedback") == 0) {
name = (const char *)msg->parameters[3].v;
}
return name;
}

View File

@ -13,6 +13,7 @@ extern "C" {
struct faction;
struct building;
struct ship;
struct message;
struct item_type;
struct building_type;
struct ship_type;
@ -35,6 +36,7 @@ extern "C" {
int RunAllTests(void);
void test_translate_param(const struct locale *lang, param_t param, const char *text);
const char * test_get_messagetype(const struct message *msg);
#ifdef __cplusplus
}