Merge remote-tracking branch 'upstream/master' into develop

This commit is contained in:
Enno Rehling 2015-02-08 22:09:00 +01:00
commit 2481f46199
24 changed files with 148 additions and 33 deletions

View File

@ -70,5 +70,6 @@ add_subdirectory (quicklist)
add_subdirectory (critbit)
add_subdirectory (src eressea)
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml")
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.json")
install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua")

18
process/cron/crontab Normal file
View File

@ -0,0 +1,18 @@
# Crontab for Eressea on gruenbaer.kn-bremen.de
PATH=/home/eressea/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin
ERESSEA=/home/eressea/eressea
ATLANTIS=/home/eressea/atlantis
ENABLED=no
PREVIEW=no
CONFIRM=yes
# m h dom mon dow command
00 00 * * * $HOME/bin/fetchmail.cron
00 22 * * * $HOME/bin/backup-db.sh
15 21 * * Sat [ "$ENABLED" = "yes" ] && $ERESSEA/server/bin/run-eressea.cron 3
25 21 * * Sat [ "$ENABLED" = "yes" ] && $ERESSEA/server/bin/run-eressea.cron 4
35 21 * * Sat [ "$ENABLED" = "yes" ] && $ERESSEA/server/bin/run-eressea.cron 2
39 08 * * Sun [ "$PREVIEW" = "yes" ] && $ERESSEA/server/bin/previews.cron
*/5 * * * * [ "$CONFIRM" = "yes" ] && $ERESSEA/server/bin/orders.cron 2 3 4

16
process/cron/orders.cron Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
## this script processes incoming order files.
# files are delivered into an incoming queue by procmail, then cron runs
# this here script to make a non-blocking syntax check and reject or
# accept the order file.
for GAME in $*
do
if [ "$GAME" == "eressea" ]; then GAME=2 ; fi
if [ "$GAME" == "e3a" ]; then GAME=3 ; fi
if [ -e $HOME/eressea/game-$GAME/orders.queue ]
then
$HOME/bin/orders-process $GAME
fi
done

14
process/cron/preview.cron Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
[ -z ${ERESSEA} ] && ERESSEA=~/eressea
branch="develop"
if [ -e ${ERESSEA}/build/.preview ]; then
branch=`cat ${ERESSEA}/build/.preview`
fi
BIN=${ERESSEA}/server/s
${BIN}/preview build ${branch} || exit $?
${BIN}/preview version
for game in 2 3 4 ; do
${BIN}/preview -g ${game} run && \
${BIN}/preview -g ${game} send
done

View File

@ -40,6 +40,6 @@ fi
echo "sending reports for game $GAME, turn $TURN"
$BIN/compress.sh $GAME $TURN
$BIN/sendreports.sh $GAME
$BIN/backup-eressea $GAME $TURN
[ $GAME -lt 4 ] && $BIN/send-summary $GAME
$BIN/backup-eressea $GAME $TURN
rm -f test/execute.lock

View File

@ -4345,6 +4345,14 @@
</string>
</namespace>
<namespace name="spellinfo">
<string name="create_ror">
<text locale="de">Erzeugt einen Ring der Regeneration.</text>
<text locale="en">Creates a ring of regeneration.</text>
</string>
<string name="create_focus">
<text locale="de">Erzeugt einen Aurafokus.</text>
<text locale="en">Creates an aurafocus crystal.</text>
</string>
<string name="acidrain">
<text locale="de">Tötet die Feinde mit Säure.</text>
<text locale="en">Kills enemies with acid.</text>

View File

@ -889,7 +889,7 @@
<arg name="left" type="int"/>
</type>
<text locale="de">"Auf der Einheit $if($eq($left,1),"liegt","liegen") $int($left) Wirkung$if($eq($left,1),"","en") $resource($potion,1)."</text>
<text locale="en">"There are $int($left) use($eq($left,1),"s","") of $resource($potion,1) left."</text>
<text locale="en">"There $if($eq($left,1),"is","are") $int($left) $if($eq($left,1),"use","uses") of $resource($potion,1) left."</text>
</message>
<message name="nr_region_owner" section="nr">
<type>

View File

@ -1,14 +0,0 @@
#!/bin/bash
[ -z ${ERESSEA} ] && ERESSEA=~/eressea
branch="master"
if [ -e ${ERESSEA}/build/.preview ]; then
branch=`cat ${ERESSEA}/build/.preview`
fi
SRC=${ERESSEA}/git
${SRC}/s/preview build ${branch} || exit $?
${SRC}/s/preview version
for game in 2 3 4 ; do
${SRC}/s/preview -g ${game} run && \
${SRC}/s/preview -g ${game} send
done

View File

@ -8,6 +8,8 @@ while [ ! -d $ROOT/.git ]; do
fi
done
DEST=$(dirname $ROOT)/server
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
@ -17,3 +19,10 @@ BIN_DIR="build-$MACHINE-$CC-Debug"
cd $ROOT/$BIN_DIR
make install
[ -d $DEST/bin ] || mkdir -p $DEST/bin
install -v $ROOT/process/cron/*.cron $DEST/bin/
programs="create-orders backup-eressea run-turn"
for prg in ${programs} ; do
install -v $ROOT/process/$prg $DEST/bin/
done
crontab $ROOT/process/cron/crontab

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 4
#define VERSION_BUILD 698
#define VERSION_BUILD 3

View File

@ -363,6 +363,7 @@ static void test_btype_defaults(CuTest *tc) {
btype = bt_get_or_create("hodor");
CuAssertPtrNotNull(tc, btype);
CuAssertStrEquals(tc, "hodor", btype->_name);
CuAssertPtrEquals(tc, 0, btype->maintenance);
CuAssertPtrEquals(tc, 0, btype->construction);
CuAssertTrue(tc, !btype->name);
@ -370,7 +371,6 @@ static void test_btype_defaults(CuTest *tc) {
CuAssertTrue(tc, !btype->age);
CuAssertTrue(tc, !btype->protection);
CuAssertTrue(tc, !btype->taxes);
CuAssertStrEquals(tc, "hodor", btype->_name);
CuAssertDblEquals(tc, 1.0, btype->auraregen, 0.0);
CuAssertIntEquals(tc, -1, btype->maxsize);
CuAssertIntEquals(tc, -1, btype->capacity);

View File

@ -320,6 +320,30 @@ static void test_buildings_default(CuTest * tc)
test_cleanup();
}
static const char * ship_defaults_data = "{\"ships\": { "
"\"hodor\" : { }"
"}}";
static void test_ships_default(CuTest * tc)
{
cJSON *json = cJSON_Parse(ship_defaults_data);
const ship_type *st;
ship_type clone;
test_cleanup();
st = st_get_or_create("hodor");
clone = *st;
CuAssertIntEquals(tc, 0, memcmp(st, &clone, sizeof(ship_type)));
CuAssertPtrNotNull(tc, json);
json_config(json);
CuAssertPtrEquals(tc, (void *)st, (void *)st_find("hodor"));
CuAssertIntEquals(tc, 0, memcmp(st, &clone, sizeof(ship_type)));
test_cleanup();
}
static void test_configs(CuTest * tc)
{
const char * data = "{\"include\": [ \"test.json\" ] }";
@ -470,6 +494,7 @@ CuSuite *get_jsonconf_suite(void)
SUITE_ADD_TEST(suite, test_skills);
SUITE_ADD_TEST(suite, test_directions);
SUITE_ADD_TEST(suite, test_items);
SUITE_ADD_TEST(suite, test_ships_default);
SUITE_ADD_TEST(suite, test_ships);
SUITE_ADD_TEST(suite, test_buildings);
SUITE_ADD_TEST(suite, test_buildings_default);

View File

@ -110,6 +110,7 @@ ship_type *st_get_or_create(const char * name) {
if (!st) {
st = (ship_type *)calloc(sizeof(ship_type), 1);
st->_name = _strdup(name);
st->storm = 1.0;
ql_push(&shiptypes, (void *)st);
}
return st;

View File

@ -38,6 +38,7 @@ extern "C" {
int range; /* range in regions */
int flags; /* flags */
int combat; /* modifier for combat */
int fishing; /* weekly income from fishing */
double storm; /* multiplier for chance to drift in storm */
double damage; /* multiplier for damage taken by the ship */
@ -49,8 +50,6 @@ extern "C" {
int minskill; /* min. skill to sail this (crew) */
int sumskill; /* min. sum of crew+captain */
int fishing; /* weekly income from fishing */
int at_bonus; /* Verändert den Angriffsskill (default: 0) */
int df_bonus; /* Verändert den Verteidigungskill (default: 0) */
float tac_bonus;

View File

@ -342,10 +342,36 @@ void test_shipowner_goes_to_empty_unit_after_leave(CuTest * tc)
CuAssertPtrEquals(tc, u2, ship_owner(sh));
}
static void test_stype_defaults(CuTest *tc) {
ship_type *stype;
test_cleanup();
stype = st_get_or_create("hodor");
CuAssertPtrNotNull(tc, stype);
CuAssertStrEquals(tc, "hodor", stype->_name);
CuAssertPtrEquals(tc, 0, stype->construction);
CuAssertPtrEquals(tc, 0, stype->coasts);
CuAssertDblEquals(tc, 0.0, stype->damage, 0.0);
CuAssertDblEquals(tc, 1.0, stype->storm, 0.0);
CuAssertDblEquals(tc, 0.0, stype->tac_bonus, 0.0);
CuAssertIntEquals(tc, 0, stype->cabins);
CuAssertIntEquals(tc, 0, stype->cargo);
CuAssertIntEquals(tc, 0, stype->combat);
CuAssertIntEquals(tc, 0, stype->fishing);
CuAssertIntEquals(tc, 0, stype->range);
CuAssertIntEquals(tc, 0, stype->cptskill);
CuAssertIntEquals(tc, 0, stype->minskill);
CuAssertIntEquals(tc, 0, stype->sumskill);
CuAssertIntEquals(tc, 0, stype->at_bonus);
CuAssertIntEquals(tc, 0, stype->df_bonus);
CuAssertIntEquals(tc, 0, stype->flags);
test_cleanup();
}
CuSuite *get_ship_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_register_ship);
SUITE_ADD_TEST(suite, test_stype_defaults);
SUITE_ADD_TEST(suite, test_ship_set_owner);
SUITE_ADD_TEST(suite, test_shipowner_resets_when_empty);
SUITE_ADD_TEST(suite, test_shipowner_goes_to_next_when_empty);

View File

@ -491,21 +491,21 @@ static int parse_ships(xmlDocPtr doc)
xmlFree(propValue);
st->cabins = xml_ivalue(node, "cabins", 0) * PERSON_WEIGHT;
st->cargo = xml_ivalue(node, "cargo", 0);
st->combat = xml_ivalue(node, "combat", 0);
st->cptskill = xml_ivalue(node, "cptskill", 0);
st->damage = xml_fvalue(node, "damage", 0.0);
st->cargo = xml_ivalue(node, "cargo", st->cargo);
st->combat = xml_ivalue(node, "combat", st->combat);
st->damage = xml_fvalue(node, "damage", st->damage);
if (xml_bvalue(node, "nocoast", false))
st->flags |= SFL_NOCOAST;
if (xml_bvalue(node, "fly", false))
st->flags |= SFL_FLY;
if (xml_bvalue(node, "opensea", false))
st->flags |= SFL_OPENSEA;
st->fishing = xml_ivalue(node, "fishing", 0);
st->minskill = xml_ivalue(node, "minskill", 0);
st->range = xml_ivalue(node, "range", 0);
st->storm = xml_fvalue(node, "storm", 1.0);
st->sumskill = xml_ivalue(node, "sumskill", 0);
st->fishing = xml_ivalue(node, "fishing", st->fishing);
st->cptskill = xml_ivalue(node, "cptskill", st->cptskill);
st->minskill = xml_ivalue(node, "minskill", st->minskill);
st->sumskill = xml_ivalue(node, "sumskill", st->sumskill);
st->range = xml_ivalue(node, "range", st->range);
st->storm = xml_fvalue(node, "storm", st->storm);
/* reading eressea/ships/ship/construction */
xpath->node = node;

View File

@ -1896,7 +1896,10 @@ int name_cmd(struct unit *u, struct order *ord)
}
if (s != NULL) {
return rename_cmd(u, ord, s, getstrtoken());
const char *name = getstrtoken();
if (name) {
rename_cmd(u, ord, s, name);
}
}
return 0;

View File

@ -781,7 +781,7 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_force_leave_ships);
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
SUITE_ADD_TEST(suite, test_peasant_luck_effect);
SUITE_ADD_TEST(suite, test_luck_message);
DISABLE_TEST(suite, test_luck_message);
return suite;
}

View File

@ -240,13 +240,12 @@ const message_type *register_msg(const char *type, int n_param, ...) {
void assert_messages(struct CuTest * tc, struct mlist *msglist, const message_type **types,
int num_msgs, bool exact_match, ...) {
va_list args;
int found, argc;
int found, argc = -1;
struct message *msg;
bool match = true;
va_start(args, exact_match);
found = 0;
while (msglist) {
if (found >= num_msgs) {
if (exact_match) {
@ -272,3 +271,8 @@ void assert_messages(struct CuTest * tc, struct mlist *msglist, const message_ty
va_end(args);
}
void disabled_test(void *suite, void (*test)(CuTest *), const char *name) {
(void)test;
fprintf(stderr, "%s: SKIP\n", name);
}

View File

@ -47,6 +47,10 @@ extern "C" {
void assert_messages(struct CuTest * tc, struct mlist *msglist, const struct message_type **types,
int num_msgs, bool exact_match, ...);
void disabled_test(void *suite, void (*)(struct CuTest *), const char *name);
#define DISABLE_TEST(SUITE, TEST) disabled_test(SUITE, TEST, #TEST)
#ifdef __cplusplus
}
#endif

View File

@ -263,6 +263,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_
assert(maxstrings > 0);
tokens = get_translations(lang, ut);
for (i = 0; i != maxstrings; ++i) {
// TODO: swap the name of s and key
const char * s = string_cb(i);
const char * key = s ? locale_string(lang, s, false) : 0;
key = key ? key : s;