Merge pull request #701 from ennorehling/develop

merge hotfixes back into develop
This commit is contained in:
Enno Rehling 2017-06-18 22:12:39 +02:00 committed by GitHub
commit 60c939289c
16 changed files with 70 additions and 77 deletions

View File

@ -4,7 +4,6 @@
<xi:include href="config://core/de/strings.xml"/> <xi:include href="config://core/de/strings.xml"/>
<xi:include href="config://core/en/strings.xml"/> <xi:include href="config://core/en/strings.xml"/>
<xi:include href="config://game/strings.xml"/> <xi:include href="config://game/strings.xml"/>
<xi:include href="config://game/messages.xml"/>
<xi:include href="config://default/names-undead.xml"/> <xi:include href="config://default/names-undead.xml"/>
<xi:include href="config://default/names-skeletons.xml"/> <xi:include href="config://default/names-skeletons.xml"/>
<xi:include href="config://default/names-zombies.xml"/> <xi:include href="config://default/names-zombies.xml"/>

View File

@ -2033,6 +2033,13 @@
<text locale="de">$if($isnull($mage),"Ein unentdeckter Magier",$unit($mage)) erschuf einen heiligen Hain von $int($amount) Schößlingen.</text> <text locale="de">$if($isnull($mage),"Ein unentdeckter Magier",$unit($mage)) erschuf einen heiligen Hain von $int($amount) Schößlingen.</text>
<text locale="en">$if($isnull($mage),"An unknown magician",$unit($mage)) created a holy forest of $int($amount) young trees.</text> <text locale="en">$if($isnull($mage),"An unknown magician",$unit($mage)) created a holy forest of $int($amount) young trees.</text>
</message> </message>
<message name="raindance_effect" section="magic">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$if($isnull($mage),"Ein unentdeckter Magier",$unit($mage)) führt einen sonderbaren Tanz auf. Kurz darauf beginnt es zu regnen."</text>
<text locale="en">"$if($isnull($mage),"an unseen magician",$unit($mage)) dances a strange dance. Shortly after, rain begins to fall on the fields."</text>
</message>
<message name="harvest_effect" section="magic"> <message name="harvest_effect" section="magic">
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<messages>
<message name="raindance_effect" section="magic">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$if($isnull($mage),"Ein unentdeckter Magier",$unit($mage)) führt einen sonderbaren Tanz auf. Kurz darauf beginnt es zu regnen."</text>
<text locale="en">"$if($isnull($mage),"an unseen magician",$unit($mage)) dances a strange dance. Shortly after, rain begins to fall on the fields."</text>
</message>
</messages>

View File

@ -10,23 +10,25 @@ local jokes = {
} }
local function ponnuki_brain(u) local function ponnuki_brain(u)
u:clear_orders()
local i = math.random(#jokes) local i = math.random(#jokes)
u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i]) u:add_order("BOTSCHAFT REGION \"" .. jokes[i] .. "\"")
eressea.log.info("Ponnuki is telling jokes in " .. tostring(u.region))
local d = math.random(6) local d = math.random(6)
local r = u.region:next(d-1) local r = u.region:next(d-1)
if r.terrain == 'glacier' then if r.terrain == 'glacier' then
u:clear_orders()
u:add_order("NACH " .. directions[d]) u:add_order("NACH " .. directions[d])
eressea.log.info("Ponnuki is walking to " .. tostring(r))
end end
end end
function ponnuki.init() function ponnuki.init()
-- initialize other scripts -- initialize other scripts
local f = get_faction(666)
local u = get_unit(atoi36("ponn")) local u = get_unit(atoi36("ponn"))
if not u then if not u then
eressea.log.error("Ponnuki is missing, will re-create") eressea.log.error("Ponnuki is missing, will re-create")
local home = get_region(-67, -5) local home = get_region(-67, -5)
local f = get_faction(666)
if home and f then if home and f then
if home.terrain~="glacier" then if home.terrain~="glacier" then
home.terrain="glacier" home.terrain="glacier"
@ -44,10 +46,11 @@ function ponnuki.init()
else else
eressea.log.error("Ponnuki cannot find Magrathea") eressea.log.error("Ponnuki cannot find Magrathea")
end end
elseif u.faction==f then
eressea.log.info("Ponnuki is in " .. tostring(u.region))
u.status = 5 -- FLIEHE
end end
if u then
ponnuki_brain(u) ponnuki_brain(u)
end end
end
return ponnuki return ponnuki

View File

@ -142,7 +142,7 @@ function process(rules, orders)
return -1 return -1
end end
callbacks(rules, 'init') turn_begin()
init_summary() init_summary()
-- run the turn: -- run the turn:
@ -151,14 +151,14 @@ function process(rules, orders)
return -1 return -1
end end
plan_monsters()
if nmr_check(config.maxnmrs or 80)~=0 then if nmr_check(config.maxnmrs or 80)~=0 then
return -1 return -1
end end
plan_monsters()
process_orders() callbacks(rules, 'init')
turn_process()
callbacks(rules, 'update') callbacks(rules, 'update')
turn_end() -- ageing, etc.
write_files(config.locales) write_files(config.locales)
dbupdate() dbupdate()

View File

@ -869,6 +869,7 @@ const char * game_mailcmd(void)
} }
*r = '\0'; *r = '\0';
log_warning("game.mailcmd configuration is not set, using %s from game.name", result); log_warning("game.mailcmd configuration is not set, using %s from game.name", result);
config_set("game.mailcmd", result);
return result; return result;
} }
return param; return param;

View File

@ -278,6 +278,7 @@ static void test_game_mailcmd(CuTest *tc) {
CuAssertStrEquals(tc, "Eressea", game_name()); CuAssertStrEquals(tc, "Eressea", game_name());
CuAssertStrEquals(tc, "ERESSEA", game_mailcmd()); CuAssertStrEquals(tc, "ERESSEA", game_mailcmd());
config_set("game.name", "Hodor"); config_set("game.name", "Hodor");
config_set("game.mailcmd", NULL);
CuAssertStrEquals(tc, "Hodor", game_name()); CuAssertStrEquals(tc, "Hodor", game_name());
CuAssertStrEquals(tc, "HODOR", game_mailcmd()); CuAssertStrEquals(tc, "HODOR", game_mailcmd());
config_set("game.mailcmd", "ERESSEA"); config_set("game.mailcmd", "ERESSEA");

View File

@ -107,24 +107,21 @@ void curse_init(attrib * a)
int curse_age(attrib * a, void *owner) int curse_age(attrib * a, void *owner)
{ {
curse *c = (curse *)a->data.v; curse *c = (curse *)a->data.v;
int result = 0; int result = AT_AGE_KEEP;
UNUSED_ARG(owner); UNUSED_ARG(owner);
c_clearflag(c, CURSE_ISNEW); c_clearflag(c, CURSE_ISNEW);
if (c_flags(c) & CURSE_NOAGE) { if ((c_flags(c) & CURSE_NOAGE) == 0) {
c->duration = INT_MAX;
}
if (c->type->age) { if (c->type->age) {
result = c->type->age(c); if (c->type->age(c) == 0) {
result = AT_AGE_REMOVE;
} }
if (result != 0) {
c->duration = 0;
} }
else if (c->duration != INT_MAX) { if (--c->duration <= 0) {
c->duration = MAX(0, c->duration - 1); result = AT_AGE_REMOVE;
} }
return (c->duration > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; }
return result;
} }
void destroy_curse(curse * c) void destroy_curse(curse * c)
@ -308,6 +305,7 @@ void ct_register(const curse_type * ct)
unsigned int hash = tolower(ct->cname[0]) & 0xFF; unsigned int hash = tolower(ct->cname[0]) & 0xFF;
selist **ctlp = cursetypes + hash; selist **ctlp = cursetypes + hash;
assert(ct->age==NULL || (ct->flags&CURSE_NOAGE) == 0);
selist_set_insert(ctlp, (void *)ct, NULL); selist_set_insert(ctlp, (void *)ct, NULL);
++ct_changes; ++ct_changes;
} }

View File

@ -240,10 +240,7 @@ static faction *factionorders(void)
} }
/* Die Partei hat sich zumindest gemeldet, so dass sie noch /* Die Partei hat sich zumindest gemeldet, so dass sie noch
* nicht als untätig gilt */ * nicht als untätig gilt */
f->lastorders = turn;
/* TODO: +1 ist ein Workaround, weil cturn erst in process_orders
* incrementiert wird. */
f->lastorders = turn + 1;
} }
else { else {
@ -762,7 +759,7 @@ unit *read_unit(struct gamedata *data)
assert(u_race(u)); assert(u_race(u));
for (;;) { for (;;) {
int n, level, weeks; int n = NOSKILL, level, weeks;
skill_t sk; skill_t sk;
READ_INT(data->store, &n); READ_INT(data->store, &n);
sk = (skill_t)n; sk = (skill_t)n;
@ -1665,7 +1662,7 @@ int read_game(gamedata *data) {
if (rmax < 0) { if (rmax < 0) {
rmax = nread; rmax = nread;
} }
log_debug(" - Einzulesende Regionen: %d/%d\r", rmax, nread); log_debug(" - Einzulesende Regionen: %d/%d", rmax, nread);
while (--nread >= 0) { while (--nread >= 0) {
unit **up; unit **up;
@ -1725,10 +1722,6 @@ int read_game(gamedata *data) {
update_interval(u->faction, r); update_interval(u->faction, r);
} }
} }
if ((nread & 0x3FF) == 0) { /* das spart extrem Zeit */
log_debug(" - Einzulesende Regionen: %d/%d * %d,%d \r", rmax, nread, r->x, r->y);
}
--rmax; --rmax;
} }
read_borders(data); read_borders(data);

View File

@ -3010,6 +3010,7 @@ int cast_spell(struct castorder *co)
fun = get_spellcast(sp->sname); fun = get_spellcast(sp->sname);
if (!fun) { if (!fun) {
log_debug("no spell function for %s, try callback", sp->sname);
return callbacks.cast_spell(co, fname); return callbacks.cast_spell(co, fname);
} }
return fun(co); return fun(co);

View File

@ -187,8 +187,9 @@ void monsters_desert(struct faction *monsters)
} }
} }
int monster_attacks(unit * monster, bool respect_buildings, bool rich_only) int monster_attacks(unit * monster, bool rich_only)
{ {
if (monster->status < ST_AVOID) {
region *r = monster->region; region *r = monster->region;
unit *u2; unit *u2;
int money = 0; int money = 0;
@ -207,6 +208,8 @@ int monster_attacks(unit * monster, bool respect_buildings, bool rich_only)
} }
return money; return money;
} }
return 0;
}
static order *get_money_for_dragon(region * r, unit * udragon, int wanted) static order *get_money_for_dragon(region * r, unit * udragon, int wanted)
{ {
@ -226,7 +229,7 @@ static order *get_money_for_dragon(region * r, unit * udragon, int wanted)
* und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */ * und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */
money = 0; money = 0;
if (attacks && is_guard(udragon)) { if (attacks && is_guard(udragon)) {
money += monster_attacks(udragon, true, true); money += monster_attacks(udragon, true);
} }
/* falls die einnahmen erreicht werden, bleibt das monster noch eine */ /* falls die einnahmen erreicht werden, bleibt das monster noch eine */
@ -749,7 +752,7 @@ void plan_monsters(faction * f)
} }
if (attacking && (!r->land || is_guard(u))) { if (attacking && (!r->land || is_guard(u))) {
monster_attacks(u, true, false); monster_attacks(u, false);
} }
/* units with a plan to kill get ATTACK orders: */ /* units with a plan to kill get ATTACK orders: */
@ -773,7 +776,7 @@ void plan_monsters(faction * f)
} }
/* All monsters guard the region: */ /* All monsters guard the region: */
if (!monster_is_waiting(u) && r->land) { if (u->status < ST_FLEE && !monster_is_waiting(u) && r->land) {
addlist(&u->orders, create_order(K_GUARD, u->faction->locale, NULL)); addlist(&u->orders, create_order(K_GUARD, u->faction->locale, NULL));
} }

View File

@ -27,7 +27,7 @@
#include <string.h> #include <string.h>
extern void plan_monsters(struct faction *f); extern void plan_monsters(struct faction *f);
extern int monster_attacks(unit * monster, bool respect_buildings, bool rich_only); extern int monster_attacks(unit * monster, bool rich_only);
static order *find_order(const char *expected, const unit *unit) static order *find_order(const char *expected, const unit *unit)
{ {
@ -64,6 +64,7 @@ static void create_monsters(faction **player, faction **monsters, unit **u, unit
*u = test_create_unit(*player, r); *u = test_create_unit(*player, r);
unit_setid(*u, 1); unit_setid(*u, 1);
*m = test_create_unit(*monsters, r); *m = test_create_unit(*monsters, r);
unit_setstatus(*m, ST_FIGHT);
} }
static void test_monsters_attack(CuTest * tc) static void test_monsters_attack(CuTest * tc)
@ -72,7 +73,6 @@ static void test_monsters_attack(CuTest * tc)
unit *u, *m; unit *u, *m;
create_monsters(&f, &f2, &u, &m); create_monsters(&f, &f2, &u, &m);
setguard(m, true); setguard(m, true);
config_set("rules.monsters.attack_chance", "1"); config_set("rules.monsters.attack_chance", "1");
@ -112,7 +112,7 @@ static void test_monsters_waiting(CuTest * tc)
create_monsters(&f, &f2, &u, &m); create_monsters(&f, &f2, &u, &m);
setguard(m, true); setguard(m, true);
fset(m, UFL_ISNEW); fset(m, UFL_ISNEW);
monster_attacks(m, false, false); monster_attacks(m, false);
CuAssertPtrEquals(tc, 0, find_order("attack 1", m)); CuAssertPtrEquals(tc, 0, find_order("attack 1", m));
test_cleanup(); test_cleanup();
} }

View File

@ -2081,7 +2081,6 @@ static int sp_homestone(castorder * co)
cmistake(mage, co->order, 206, MSG_MAGIC); cmistake(mage, co->order, 206, MSG_MAGIC);
return 0; return 0;
} }
c_setflag(c, CURSE_NOAGE | CURSE_ONLYONE);
/* Magieresistenz der Burg erhoeht sich um 50% */ /* Magieresistenz der Burg erhoeht sich um 50% */
effect = 50.0F; effect = 50.0F;

View File

@ -76,7 +76,7 @@ CURSETYP_NORM, 0, M_SUMEFFECT, cinfo_magicrunes
/* Heimstein-Zauber */ /* Heimstein-Zauber */
static struct curse_type ct_magicwalls = { "magicwalls", static struct curse_type ct_magicwalls = { "magicwalls",
CURSETYP_NORM, 0, NO_MERGE, cinfo_building CURSETYP_NORM, CURSE_ONLYONE|CURSE_NOAGE, NO_MERGE, cinfo_building
}; };
/* Feste Mauer - Präkampfzauber, wirkt nur 1 Runde */ /* Feste Mauer - Präkampfzauber, wirkt nur 1 Runde */

View File

@ -149,10 +149,8 @@ bool flying_ship(const ship * sh)
static curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration) static curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
{ {
curse *c; curse *c;
const curse_type *ct_flyingship = ct_find("flyingship");
assert(ct_flyingship);
if (sh->attribs) { if (sh->attribs) {
if (curse_active(get_curse(sh->attribs, ct_flyingship))) { if (curse_active(get_curse(sh->attribs, &ct_flyingship))) {
return NULL; return NULL;
} }
if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) { if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
@ -160,7 +158,7 @@ static curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int dur
} }
} }
/* mit C_SHIP_NODRIFT haben wir kein Problem */ /* mit C_SHIP_NODRIFT haben wir kein Problem */
c = create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0); c = create_curse(mage, &sh->attribs, &ct_flyingship, power, duration, 0.0, 0);
if (c) { if (c) {
c->data.v = sh; c->data.v = sh;
if (c->duration > 0) { if (c->duration > 0) {

View File

@ -92,7 +92,7 @@ int update_nmrs(void)
++newplayers; ++newplayers;
} }
else if (!fval(f, FFL_NOIDLEOUT|FFL_CURSED)) { else if (!fval(f, FFL_NOIDLEOUT|FFL_CURSED)) {
int nmr = turn - f->lastorders + 1; int nmr = turn - f->lastorders;
if (timeout>0) { if (timeout>0) {
if (nmr < 0 || nmr > timeout) { if (nmr < 0 || nmr > timeout) {
log_error("faction %s has %d NMR", itoa36(f->no), nmr); log_error("faction %s has %d NMR", itoa36(f->no), nmr);