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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -730,6 +730,17 @@ static order *plan_dragon(unit * u)
return long_order; 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) void plan_monsters(faction * f)
{ {
region *r; region *r;
@ -748,14 +759,20 @@ void plan_monsters(faction * f)
bool can_move = true; bool can_move = true;
/* Ab hier nur noch Befehle fuer NPC-Einheiten. */ /* Ab hier nur noch Befehle fuer NPC-Einheiten. */
if (u->faction!=f) if (u->faction != f || u->number <= 0) {
continue; continue;
}
/* Parteitarnung von Monstern ist doof: */ /* Parteitarnung von Monstern ist doof: */
if (fval(u, UFL_ANON_FACTION)) { if (fval(u, UFL_ANON_FACTION)) {
u->flags &= ~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)) { if (skill_enabled(SK_PERCEPTION)) {
/* Monster bekommen jede Runde ein paar Tage Wahrnehmung dazu */ /* Monster bekommen jede Runde ein paar Tage Wahrnehmung dazu */
produceexp(u, SK_PERCEPTION, u->number); 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 "log.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <ctype.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) int atoi36(const char *str)
{ {
/* cannot use strtol, because invalid strings will cause crash */
const unsigned char *s = (const unsigned char *)str; const unsigned char *s = (const unsigned char *)str;
int i = 0, sign = 1; int i = 0, sign = 1;
assert(s); assert(s);
@ -51,6 +59,7 @@ int atoi36(const char *str)
return 0; return 0;
return i * sign; return i * sign;
} }
#endif
const char *itoab_r(int i, int base, char *s, size_t len) 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; return 0;
} }
static int wormhole_age(struct attrib *a, void *owner) void wormhole_transfer(building *b, region *exit)
{ {
building *entry = (building *)owner; int maxtransport = b->size;
region *exit = (region *)a->data.v; region *r = b->region;
int maxtransport = entry->size;
region *r = entry->region;
unit *u = r->units; unit *u = r->units;
UNUSED_ARG(owner); while (u != NULL && maxtransport != 0) {
for (; u != NULL && maxtransport != 0; u = u->next) { unit *unext = u->next;
if (u->building == entry) { if (u->building == b) {
message *m = NULL; message *m = NULL;
if (u->number > maxtransport || has_limited_skills(u)) { if (u->number > maxtransport || has_limited_skills(u)) {
m = msg_message("wormhole_requirements", "unit region", u, u->region); 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); msg_release(m);
} }
} }
u = unext;
} }
remove_building(&r->buildings, entry); remove_building(&r->buildings, b);
ADDMSG(&r->msgs, msg_message("wormhole_dissolve", "region", r)); 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 */ /* age returns 0 if the attribute needs to be removed, !=0 otherwise */
return AT_AGE_KEEP; return AT_AGE_KEEP;
} }

View file

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

View file

@ -7,6 +7,7 @@
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/unit.h>
#include <kernel/attrib.h> #include <kernel/attrib.h>
#include <util/message.h> #include <util/message.h>
@ -31,15 +32,13 @@ static void setup_wormholes(void) {
static void test_make_wormholes(CuTest *tc) { static void test_make_wormholes(CuTest *tc) {
region *r1, *r2, *match[2]; region *r1, *r2, *match[2];
terrain_type *t_plain;
building_type *btype; building_type *btype;
test_setup(); test_setup();
setup_wormholes(); setup_wormholes();
t_plain = test_create_terrain("plain", LAND_REGION);
btype = test_create_buildingtype("wormhole"); btype = test_create_buildingtype("wormhole");
match[0] = r1 = test_create_region(0, 0, t_plain); match[0] = r1 = test_create_plain(0, 0);
match[1] = r2 = test_create_region(1, 0, t_plain); match[1] = r2 = test_create_plain(1, 0);
make_wormholes(match, 2, btype); make_wormholes(match, 2, btype);
CuAssertPtrNotNull(tc, r1->buildings); CuAssertPtrNotNull(tc, r1->buildings);
CuAssertPtrNotNull(tc, r1->buildings->attribs); CuAssertPtrNotNull(tc, r1->buildings->attribs);
@ -54,14 +53,12 @@ static void test_make_wormholes(CuTest *tc) {
static void test_sort_wormhole_regions(CuTest *tc) { static void test_sort_wormhole_regions(CuTest *tc) {
region *r1, *r2, *match[2]; region *r1, *r2, *match[2];
terrain_type *t_plain;
selist *rlist = 0; selist *rlist = 0;
test_setup(); test_setup();
setup_wormholes(); setup_wormholes();
t_plain = test_create_terrain("plain", LAND_REGION); r1 = test_create_plain(0, 0);
r1 = test_create_region(0, 0, t_plain); r2 = test_create_plain(1, 0);
r2 = test_create_region(1, 0, t_plain);
r1->age = 4; r1->age = 4;
r2->age = 2; r2->age = 2;
selist_push(&rlist, r1); selist_push(&rlist, r1);
@ -73,10 +70,42 @@ static void test_sort_wormhole_regions(CuTest *tc) {
test_teardown(); 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 *get_wormhole_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_sort_wormhole_regions); SUITE_ADD_TEST(suite, test_sort_wormhole_regions);
SUITE_ADD_TEST(suite, test_make_wormholes); SUITE_ADD_TEST(suite, test_make_wormholes);
SUITE_ADD_TEST(suite, test_wormhole_transfer);
return suite; return suite;
} }