Merge pull request #862 from ennorehling/master

bugfix release
This commit is contained in:
Enno Rehling 2019-08-06 18:16:13 +02:00 committed by GitHub
commit c714efac36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 98 additions and 34 deletions

2
clibs

@ -1 +1 @@
Subproject commit 1854780fe3073e491775836c22f709668b1fff62
Subproject commit 6965050165efdae89305a13bff06283229f143f4

View File

@ -2,7 +2,7 @@
if [ -z "$ERESSEA" ]; then
echo "You need to define the \$ERESSEA environment variable to run $0"
exit -2
exit 2
fi
GAME="$ERESSEA/game-$1"
@ -16,7 +16,7 @@ fi
if [ ! -d "$GAME/reports" ]; then
echo "cannot find reports directory in $GAME"
exit -1
exit 1
fi
cd "$GAME/reports" || exit

View File

@ -5,7 +5,7 @@ if [ -z "$ERESSEA" ]; then
fi
if [ ! -f reports.txt ]; then
echo "need to run $0 from the report direcory"
exit -2
exit 2
fi
TEMPLATE=report-mail.txt

View File

@ -6,7 +6,7 @@ if [ -z "$ERESSEA" ]; then
fi
if [ ! -f reports.txt ]; then
echo "need to run $0 from the report direcory"
exit -2
exit 2
fi
PWD=$(pwd)
@ -33,7 +33,7 @@ fi
if [ ! -e "$TEMPLATE" ]; then
echo "no such email template: $TEMPLATE"
exit -3
exit 3
fi
while [ -e /tmp/.stopped ] ; do

View File

@ -3,14 +3,14 @@
if [ -z "$ERESSEA" ]; then
echo "You have to define the \$ERESSEA environment variable to run $0"
exit -2
exit 2
fi
function abort() {
if [ $# -gt 0 ]; then
echo "$@"
fi
exit -1
exit 1
}
GAME=$1
@ -47,7 +47,7 @@ fi
bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION"
OWNER=$("$BIN/getfaction.py" "$PWFILE" "$FACTION")
if [ ! -z "$OWNER" ]; then
if [ -n "$OWNER" ]; then
echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \
| mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER"
fi

View File

@ -5,10 +5,10 @@
if [ -z "$ERESSEA" ]; then
echo "You have to define the \$ERESSEA environment variable to run $0"
exit -2
exit 2
fi
if [ ! -z "$1" ]; then
if [ -n "$1" ]; then
GAME="$ERESSEA/game-$1"
else
GAME=$ERESSEA

View File

@ -95,11 +95,11 @@ local function write_htpasswd()
end
local function write_files(locales)
write_reports()
write_summary()
write_database()
write_passwords()
write_htpasswd()
write_reports()
write_summary()
end
local function write_scores()

View File

@ -730,6 +730,17 @@ static order *plan_dragon(unit * u)
return long_order;
}
static void monster_cannibalism(unit *u) {
unit *u2;
for (u2 = u->next; u2; u2 = u2->next) {
if (u2->_race == u->_race) {
stats_count("monsters.cannibalism", u2->number);
u2->number = 0;
}
}
}
void plan_monsters(faction * f)
{
region *r;
@ -748,14 +759,20 @@ void plan_monsters(faction * f)
bool can_move = true;
/* Ab hier nur noch Befehle fuer NPC-Einheiten. */
if (u->faction!=f)
if (u->faction != f || u->number <= 0) {
continue;
}
/* Parteitarnung von Monstern ist doof: */
if (fval(u, UFL_ANON_FACTION)) {
u->flags &= ~UFL_ANON_FACTION;
}
if (rc->splitsize < 10) {
/* hermit-type monsters eat each other */
monster_cannibalism(u);
}
if (skill_enabled(SK_PERCEPTION)) {
/* Monster bekommen jede Runde ein paar Tage Wahrnehmung dazu */
produceexp(u, SK_PERCEPTION, u->number);

View File

@ -21,12 +21,20 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "log.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#define USE_STRTOL
#ifdef USE_STRTOL
int atoi36(const char *str)
{
assert(str);
return (int)strtol(str, NULL, 36);
}
#else
int atoi36(const char *str)
{
/* cannot use strtol, because invalid strings will cause crash */
const unsigned char *s = (const unsigned char *)str;
int i = 0, sign = 1;
assert(s);
@ -51,6 +59,7 @@ int atoi36(const char *str)
return 0;
return i * sign;
}
#endif
const char *itoab_r(int i, int base, char *s, size_t len)
{

View File

@ -55,17 +55,15 @@ static int cmp_age(const void *v1, const void *v2)
return 0;
}
static int wormhole_age(struct attrib *a, void *owner)
void wormhole_transfer(building *b, region *exit)
{
building *entry = (building *)owner;
region *exit = (region *)a->data.v;
int maxtransport = entry->size;
region *r = entry->region;
int maxtransport = b->size;
region *r = b->region;
unit *u = r->units;
UNUSED_ARG(owner);
for (; u != NULL && maxtransport != 0; u = u->next) {
if (u->building == entry) {
while (u != NULL && maxtransport != 0) {
unit *unext = u->next;
if (u->building == b) {
message *m = NULL;
if (u->number > maxtransport || has_limited_skills(u)) {
m = msg_message("wormhole_requirements", "unit region", u, u->region);
@ -81,11 +79,18 @@ static int wormhole_age(struct attrib *a, void *owner)
msg_release(m);
}
}
u = unext;
}
remove_building(&r->buildings, entry);
remove_building(&r->buildings, b);
ADDMSG(&r->msgs, msg_message("wormhole_dissolve", "region", r));
}
static int wormhole_age(struct attrib *a, void *owner) {
building *b = (building *)owner;
region *exit = (region *)a->data.v;
wormhole_transfer(b, exit);
/* age returns 0 if the attribute needs to be removed, !=0 otherwise */
return AT_AGE_KEEP;
}

View File

@ -22,8 +22,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" {
#endif
extern void wormholes_update(void);
extern void wormholes_register(void);
struct region;
struct building;
void wormholes_update(void);
void wormholes_register(void);
void wormhole_transfer(struct building *b, struct region *exit);
#ifdef __cplusplus
}

View File

@ -7,6 +7,7 @@
#include <kernel/building.h>
#include <kernel/region.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <kernel/attrib.h>
#include <util/message.h>
@ -31,15 +32,13 @@ static void setup_wormholes(void) {
static void test_make_wormholes(CuTest *tc) {
region *r1, *r2, *match[2];
terrain_type *t_plain;
building_type *btype;
test_setup();
setup_wormholes();
t_plain = test_create_terrain("plain", LAND_REGION);
btype = test_create_buildingtype("wormhole");
match[0] = r1 = test_create_region(0, 0, t_plain);
match[1] = r2 = test_create_region(1, 0, t_plain);
match[0] = r1 = test_create_plain(0, 0);
match[1] = r2 = test_create_plain(1, 0);
make_wormholes(match, 2, btype);
CuAssertPtrNotNull(tc, r1->buildings);
CuAssertPtrNotNull(tc, r1->buildings->attribs);
@ -54,14 +53,12 @@ static void test_make_wormholes(CuTest *tc) {
static void test_sort_wormhole_regions(CuTest *tc) {
region *r1, *r2, *match[2];
terrain_type *t_plain;
selist *rlist = 0;
test_setup();
setup_wormholes();
t_plain = test_create_terrain("plain", LAND_REGION);
r1 = test_create_region(0, 0, t_plain);
r2 = test_create_region(1, 0, t_plain);
r1 = test_create_plain(0, 0);
r2 = test_create_plain(1, 0);
r1->age = 4;
r2->age = 2;
selist_push(&rlist, r1);
@ -73,10 +70,42 @@ static void test_sort_wormhole_regions(CuTest *tc) {
test_teardown();
}
static void test_wormhole_transfer(CuTest *tc) {
region *r1, *r2;
building *b;
unit *u1, *u2;
struct faction *f;
test_setup();
setup_wormholes();
r1 = test_create_plain(0, 0);
r2 = test_create_plain(1, 0);
b = test_create_building(r1, NULL);
b->size = 4;
f = test_create_faction(NULL);
u1 = test_create_unit(f, r1);
u1->number = 2;
u_set_building(u1, b);
u2 = test_create_unit(f, r1);
u2->number = 3;
u_set_building(u2, b);
u1 = test_create_unit(f, r1);
u1->number = 2;
u_set_building(u1, b);
wormhole_transfer(b, r2);
CuAssertPtrEquals(tc, u2, r1->units);
CuAssertPtrEquals(tc, NULL, u2->building);
CuAssertPtrEquals(tc, NULL, u2->next);
CuAssertPtrEquals(tc, r2, u1->region);
CuAssertPtrEquals(tc, u1, r2->units->next);
test_teardown();
}
CuSuite *get_wormhole_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_sort_wormhole_regions);
SUITE_ADD_TEST(suite, test_make_wormholes);
SUITE_ADD_TEST(suite, test_wormhole_transfer);
return suite;
}