Merge pull request from ennorehling/develop

refactoring and cleanup
This commit is contained in:
Enno Rehling 2016-11-18 23:03:02 +01:00 committed by GitHub
commit 77c0af3785
98 changed files with 968 additions and 888 deletions

View file

@ -222,14 +222,6 @@
"div": "100" "div": "100"
} }
} }
},
"default": {
"size": 0,
"herbs": [],
"seed": 0,
"road": 0,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {}
} }
} }
} }

View file

@ -39,5 +39,5 @@ echo "build eressea"
cd $ROOT/$BUILD cd $ROOT/$BUILD
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//') VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
cmake -DERESSEA_VERSION="$VERSION" .. cmake -DERESSEA_VERSION="$VERSION" ..
make $MAKEOPTS && make test make -k $MAKEOPTS && make test
cd $OLDPWD cd $OLDPWD

View file

@ -34,7 +34,6 @@ function test_process()
assert_equal("function", _G.type(eressea.process.siege)) assert_equal("function", _G.type(eressea.process.siege))
assert_equal("function", _G.type(eressea.process.leave)) assert_equal("function", _G.type(eressea.process.leave))
assert_equal("function", _G.type(eressea.process.promote)) assert_equal("function", _G.type(eressea.process.promote))
assert_equal("function", _G.type(eressea.process.renumber))
assert_equal("function", _G.type(eressea.process.restack)) assert_equal("function", _G.type(eressea.process.restack))
assert_equal("function", _G.type(eressea.process.set_spells)) assert_equal("function", _G.type(eressea.process.set_spells))
assert_equal("function", _G.type(eressea.process.set_help)) assert_equal("function", _G.type(eressea.process.set_help))

View file

@ -380,6 +380,21 @@ function test_events()
assert(fail==0) assert(fail==0)
end end
function test_renumber_ship()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply4@eressea.de", "human", "de")
local u = unit.create(f, r)
local s = ship.create(r, config.ships[1])
u.ship = s
u:add_order("NUMMER SCHIFF 1")
process_orders()
assert_equal(1, s.id)
u:clear_orders()
u:add_order("NUMMER SCHIFF 2")
process_orders()
assert_equal(2, s.id)
end
function test_recruit2() function test_recruit2()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply4@eressea.de", "human", "de") local f = faction.create("noreply4@eressea.de", "human", "de")

View file

@ -165,7 +165,7 @@ end
function test_process_renumber() function test_process_renumber()
u:add_order("NUMMER EINHEIT 'ii'") u:add_order("NUMMER EINHEIT 'ii'")
eressea.process.renumber() process_orders()
assert_equal(666, u.id) assert_equal(666, u.id)
end end

View file

@ -7,6 +7,7 @@ function setup()
eressea.settings.set("nmr.timeout", "0") eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.grow.formula", "0")
eressea.settings.set("rules.peasants.growth.factor", "0") eressea.settings.set("rules.peasants.growth.factor", "0")
eressea.settings.set("volcano.active.percent", "0")
end end
function test_snowglobe_fail() function test_snowglobe_fail()
@ -52,7 +53,7 @@ function test_snowglobe()
for k, v in pairs(xform) do for k, v in pairs(xform) do
r2.terrain = k r2.terrain = k
process_orders() process_orders()
-- TODO: re-enable! assert_equal(v, r2.terrain) assert_equal(v, r2.terrain)
if k~=v then if k~=v then
have=have - 1 have=have - 1
else else

View file

@ -17,10 +17,12 @@ set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}") COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}")
ENDIF() ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) IF (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
ENDIF()
IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
add_definitions(-DHAVE__BOOL) add_definitions(-DHAVE__BOOL)
ELSEIF(MSVC) ELSEIF(MSVC)
@ -99,7 +101,6 @@ set (ERESSEA_SRC
prefix.c prefix.c
donations.c donations.c
eressea.c eressea.c
callback.c
direction.c direction.c
keyword.c keyword.c
skill.c skill.c
@ -115,6 +116,7 @@ set (ERESSEA_SRC
morale.c morale.c
monster.c monster.c
randenc.c randenc.c
renumber.c
volcano.c volcano.c
chaos.c chaos.c
spy.c spy.c
@ -204,7 +206,6 @@ set(TESTS_SRC
report.test.c report.test.c
summary.test.c summary.test.c
travelthru.test.c travelthru.test.c
callback.test.c
direction.test.c direction.test.c
economy.test.c economy.test.c
json.test.c json.test.c
@ -218,6 +219,7 @@ set(TESTS_SRC
move.test.c move.test.c
piracy.test.c piracy.test.c
prefix.test.c prefix.test.c
renumber.test.c
skill.test.c skill.test.c
spells.test.c spells.test.c
spy.test.c spy.test.c

View file

@ -76,16 +76,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
static FILE *bdebug;
#define TACTICS_BONUS 1 /* when undefined, we have a tactics round. else this is the bonus tactics give */ #define TACTICS_BONUS 1 /* when undefined, we have a tactics round. else this is the bonus tactics give */
#define TACTICS_MODIFIER 1 /* modifier for generals in the front/rear */ #define TACTICS_MODIFIER 1 /* modifier for generals in the front/rear */
#define CATAPULT_INITIAL_RELOAD 4 /* erster schuss in runde 1 + rng_int() % INITIAL */ #define CATAPULT_INITIAL_RELOAD 4 /* erster schuss in runde 1 + rng_int() % INITIAL */
#define CATAPULT_STRUCTURAL_DAMAGE #define CATAPULT_STRUCTURAL_DAMAGE
#define BASE_CHANCE 70 /* 70% Basis-Überlebenschance */ #define BASE_CHANCE 70 /* 70% Basis-<EFBFBD>berlebenschance */
#define TDIFF_CHANGE 5 /* 5% höher pro Stufe */ #define TDIFF_CHANGE 5 /* 5% h<EFBFBD>her pro Stufe */
#define DAMAGE_QUOTIENT 2 /* damage += skilldiff/DAMAGE_QUOTIENT */ #define DAMAGE_QUOTIENT 2 /* damage += skilldiff/DAMAGE_QUOTIENT */
#define DEBUG_SELECT /* should be disabled if select_enemy works */ #define DEBUG_SELECT /* should be disabled if select_enemy works */
@ -96,7 +94,10 @@ typedef enum combatmagic {
} combatmagic_t; } combatmagic_t;
/* globals */ /* globals */
bool battledebug = false;
static int obs_count = 0; static int obs_count = 0;
static FILE *bdebug;
#define MINSPELLRANGE 1 #define MINSPELLRANGE 1
#define MAXSPELLRANGE 7 #define MAXSPELLRANGE 7
@ -303,11 +304,11 @@ static int dead_fighters(const fighter * df)
} }
fighter *select_corpse(battle * b, fighter * af) fighter *select_corpse(battle * b, fighter * af)
/* Wählt eine Leiche aus, der af hilft. casualties ist die Anzahl der /* W<EFBFBD>hlt eine Leiche aus, der af hilft. casualties ist die Anzahl der
* Toten auf allen Seiten (im Array). Wenn af == NULL, wird die * Toten auf allen Seiten (im Array). Wenn af == NULL, wird die
* Parteizugehörigkeit ignoriert, und irgendeine Leiche genommen. * Parteizugeh<EFBFBD>rigkeit ignoriert, und irgendeine Leiche genommen.
* *
* Untote werden nicht ausgewählt (casualties, not dead) */ * Untote werden nicht ausgew<EFBFBD>hlt (casualties, not dead) */
{ {
int si, maxcasualties = 0; int si, maxcasualties = 0;
fighter *df; fighter *df;
@ -323,7 +324,7 @@ fighter *select_corpse(battle * b, fighter * af)
side *s; side *s;
for (s = b->sides; s != b->sides + b->nsides; ++s) { for (s = b->sides; s != b->sides + b->nsides; ++s) {
for (df = s->fighters; df; df = df->next) { for (df = s->fighters; df; df = df->next) {
/* Geflohene haben auch 0 hp, dürfen hier aber nicht ausgewählt /* Geflohene haben auch 0 hp, d<EFBFBD>rfen hier aber nicht ausgew<65>hlt
* werden! */ * werden! */
int dead = dead_fighters(df); int dead = dead_fighters(df);
if (!playerrace(u_race(df->unit))) if (!playerrace(u_race(df->unit)))
@ -617,7 +618,7 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
} }
} }
else { else {
/* der rassen-defaultwert kann höher sein als der Talentwert von /* der rassen-defaultwert kann h<EFBFBD>her sein als der Talentwert von
* waffenloser kampf */ * waffenloser kampf */
if (attacking) { if (attacking) {
if (skill < u_race(u)->at_default) if (skill < u_race(u)->at_default)
@ -705,7 +706,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
static int static int
weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking, weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking,
bool missile) bool missile)
/* effektiver Waffenskill während des Kampfes */ /* effektiver Waffenskill w<EFBFBD>hrend des Kampfes */
{ {
/* In dieser Runde alle die Modifier berechnen, die fig durch die /* In dieser Runde alle die Modifier berechnen, die fig durch die
* Waffen bekommt. */ * Waffen bekommt. */
@ -770,16 +771,16 @@ bool missile)
if (t.index < tf->elvenhorses) { if (t.index < tf->elvenhorses) {
/* Elfenpferde: Helfen dem Reiter, egal ob und welche Waffe. Das ist /* Elfenpferde: Helfen dem Reiter, egal ob und welche Waffe. Das ist
* eleganter, und vor allem einfacher, sonst muß man noch ein * eleganter, und vor allem einfacher, sonst mu<EFBFBD> man noch ein
* WMF_ELVENHORSE einbauen. */ * WMF_ELVENHORSE einbauen. */
skill += 2; skill += 2;
} }
if (skill > 0 && !attacking && missile) { if (skill > 0 && !attacking && missile) {
/* /*
* Wenn ich verteidige, und nicht direkt meinem Feind gegenüberstehe, * Wenn ich verteidige, und nicht direkt meinem Feind gegen<EFBFBD>berstehe,
* halbiert sich mein Skill: (z.B. gegen Fernkämpfer. Nahkämpfer * halbiert sich mein Skill: (z.B. gegen Fernk<EFBFBD>mpfer. Nahk<EFBFBD>mpfer
* können mich eh nicht treffen) * k<EFBFBD>nnen mich eh nicht treffen)
*/ */
skill /= 2; skill /= 2;
} }
@ -815,9 +816,9 @@ static const armor_type *select_armor(troop t, bool shield)
} }
/* Hier ist zu beachten, ob und wie sich Zauber und Artefakte, die /* Hier ist zu beachten, ob und wie sich Zauber und Artefakte, die
* Rüstungschutz geben, addieren. * R<EFBFBD>stungschutz geben, addieren.
* - Artefakt "trollbelt" gibt Rüstung +1 * - Artefakt "trollbelt" gibt R<EFBFBD>stung +1
* - Zauber Rindenhaut gibt Rüstung +3 * - Zauber Rindenhaut gibt R<EFBFBD>stung +3
*/ */
static int trollbelts(const unit *u) { static int trollbelts(const unit *u) {
const struct resource_type *belt = rt_find("trollbelt"); const struct resource_type *belt = rt_find("trollbelt");
@ -835,7 +836,7 @@ int select_magicarmor(troop t)
return ma; return ma;
} }
/* Sind side ds und Magier des meffect verbündet, dann return 1*/ /* Sind side ds und Magier des meffect verb<EFBFBD>ndet, dann return 1*/
bool meffect_protection(battle * b, meffect * s, side * ds) bool meffect_protection(battle * b, meffect * s, side * ds)
{ {
if (!s->magician->alive) if (!s->magician->alive)
@ -871,7 +872,7 @@ void rmfighter(fighter * df, int i)
assert(df->alive >= i); assert(df->alive >= i);
assert(df->alive <= df->unit->number); assert(df->alive <= df->unit->number);
/* erst ziehen wir die Anzahl der Personen von den Kämpfern in der /* erst ziehen wir die Anzahl der Personen von den K<EFBFBD>mpfern in der
* Schlacht, dann von denen auf dieser Seite ab*/ * Schlacht, dann von denen auf dieser Seite ab*/
df->side->alive -= i; df->side->alive -= i;
df->side->battle->alive -= i; df->side->battle->alive -= i;
@ -1091,15 +1092,15 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty
} }
} }
/* natürliche Rüstung */ /* nat<EFBFBD>rliche R<>stung */
an = natural_armor(du); an = natural_armor(du);
/* magische Rüstung durch Artefakte oder Sprüche */ /* magische R<EFBFBD>stung durch Artefakte oder Spr<70>che */
/* Momentan nur Trollgürtel und Werwolf-Eigenschaft */ /* Momentan nur Trollg<EFBFBD>rtel und Werwolf-Eigenschaft */
am = select_magicarmor(dt); am = select_magicarmor(dt);
if (rule_nat_armor == 0) { if (rule_nat_armor == 0) {
/* natürliche Rüstung ist halbkumulativ */ /* nat<EFBFBD>rliche R<>stung ist halbkumulativ */
if (ar > 0) { if (ar > 0) {
ar += an / 2; ar += an / 2;
} }
@ -1133,7 +1134,7 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty
res *= (1 - dwtype->magres); res *= (1 - dwtype->magres);
} }
/* gegen Magie wirkt nur natürliche und magische Rüstung */ /* gegen Magie wirkt nur nat<EFBFBD>rliche und magische R<>stung */
ar = an + am; ar = an + am;
*magres = res > 0 ? res : 0; *magres = res > 0 ? res : 0;
} }
@ -1215,7 +1216,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
while (chance(kritchance)) { while (chance(kritchance)) {
if (bdebug) { if (bdebug) {
fprintf(bdebug, "%s/%d lands a critical hit\n", unitid(au), at.index); fprintf(bdebug, "%s/%d lands a critical hit\n", itoa36(au->no), at.index);
} }
da += dice_rand(damage); da += dice_rand(damage);
} }
@ -1273,7 +1274,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
rda -= hp; rda -= hp;
me->duration -= hp; me->duration -= hp;
} }
/* gibt Rüstung +effect für duration Treffer */ /* gibt R<EFBFBD>stung +effect f<>r duration Treffer */
if (me->typ == SHIELD_ARMOR) { if (me->typ == SHIELD_ARMOR) {
rda = _max(rda - me->effect, 0); rda = _max(rda - me->effect, 0);
me->duration--; me->duration--;
@ -1296,7 +1297,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
} }
} }
if (df->person[dt.index].hp > 0) { /* Hat überlebt */ if (df->person[dt.index].hp > 0) { /* Hat <EFBFBD>berlebt */
if (bdebug) { if (bdebug) {
fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n", fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n",
da, ar, df->person[dt.index].hp + rda, df->person[dt.index].hp); da, ar, df->person[dt.index].hp + rda, df->person[dt.index].hp);
@ -1702,7 +1703,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
unit *mage = fig->unit; unit *mage = fig->unit;
if (fig->alive <= 0) if (fig->alive <= 0)
continue; /* fighter kann im Kampf getötet worden sein */ continue; /* fighter kann im Kampf get<EFBFBD>tet worden sein */
level = effskill(mage, SK_MAGIC, r); level = effskill(mage, SK_MAGIC, r);
if (level > 0) { if (level > 0) {
@ -1811,12 +1812,12 @@ static void do_combatspell(troop at)
sp = get_combatspell(caster, 1); sp = get_combatspell(caster, 1);
if (sp == NULL) { if (sp == NULL) {
fi->magic = 0; /* Hat keinen Kampfzauber, kämpft nichtmagisch weiter */ fi->magic = 0; /* Hat keinen Kampfzauber, k<EFBFBD>mpft nichtmagisch weiter */
return; return;
} }
ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang));
if (!cancast(caster, sp, 1, 1, ord)) { if (!cancast(caster, sp, 1, 1, ord)) {
fi->magic = 0; /* Kann nicht mehr Zaubern, kämpft nichtmagisch weiter */ fi->magic = 0; /* Kann nicht mehr Zaubern, k<EFBFBD>mpft nichtmagisch weiter */
return; return;
} }
@ -1840,7 +1841,7 @@ static void do_combatspell(troop at)
} }
} }
/* Antimagie die Fehlschlag erhöht */ /* Antimagie die Fehlschlag erh<EFBFBD>ht */
if (rng_int() % 100 < fumblechance) { if (rng_int() % 100 < fumblechance) {
report_failed_spell(b, caster, sp); report_failed_spell(b, caster, sp);
pay_spell(caster, sp, level, 1); pay_spell(caster, sp, level, 1);
@ -1864,7 +1865,7 @@ static void do_combatspell(troop at)
} }
/* Sonderattacken: Monster patzern nicht und zahlen auch keine /* Sonderattacken: Monster patzern nicht und zahlen auch keine
* Spruchkosten. Da die Spruchstärke direkt durch den Level bestimmt * Spruchkosten. Da die Spruchst<EFBFBD>rke direkt durch den Level bestimmt
* wird, wirkt auch keine Antimagie (wird sonst in spellpower * wird, wirkt auch keine Antimagie (wird sonst in spellpower
* gemacht) */ * gemacht) */
@ -1916,7 +1917,7 @@ int skilldiff(troop at, troop dt, int dist)
if (strongwall_ct) { if (strongwall_ct) {
curse *c = get_curse(df->building->attribs, strongwall_ct); curse *c = get_curse(df->building->attribs, strongwall_ct);
if (curse_active(c)) { if (curse_active(c)) {
/* wirkt auf alle Gebäude */ /* wirkt auf alle Geb<EFBFBD>ude */
skdiff -= curse_geteffect_int(c); skdiff -= curse_geteffect_int(c);
is_protected = 2; is_protected = 2;
} }
@ -1979,10 +1980,10 @@ debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp,
int skdiff, int dist, bool success) int skdiff, int dist, bool success)
{ {
fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n", fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n",
unitid(at.fighter->unit), at.index, itoa36(at.fighter->unit->no), at.index,
LOC(default_locale, awp ? resourcename(awp->type->itype->rtype, LOC(default_locale, awp ? resourcename(awp->type->itype->rtype,
0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1), 0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1),
success ? "hits" : "misses", unitid(dt.fighter->unit), dt.index, success ? "hits" : "misses", itoa36(dt.fighter->unit->no), dt.index,
LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype, LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype,
0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff, 0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff,
dist); dist);
@ -2021,7 +2022,7 @@ int hits(troop at, troop dt, weapon * awp)
} }
skdiff = skilldiff(at, dt, dist); skdiff = skilldiff(at, dt, dist);
/* Verteidiger bekommt eine Rüstung */ /* Verteidiger bekommt eine R<EFBFBD>stung */
armor = select_armor(dt, true); armor = select_armor(dt, true);
if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) { if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) {
shield = select_armor(dt, false); shield = select_armor(dt, false);
@ -2065,7 +2066,7 @@ void damage_building(battle * b, building * bldg, int damage_abs)
{ {
bldg->size = _max(1, bldg->size - damage_abs); bldg->size = _max(1, bldg->size - damage_abs);
/* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebäude passen. */ /* Wenn Burg, dann gucken, ob die Leute alle noch in das Geb<EFBFBD>ude passen. */
if (bldg->type->protection) { if (bldg->type->protection) {
side *s; side *s;
@ -2123,7 +2124,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
switch (a->type) { switch (a->type) {
case AT_COMBATSPELL: case AT_COMBATSPELL:
/* Magier versuchen immer erstmal zu zaubern, erst wenn das /* Magier versuchen immer erstmal zu zaubern, erst wenn das
* fehlschlägt, wird af->magic == 0 und der Magier kämpft * fehlschl<EFBFBD>gt, wird af->magic == 0 und der Magier k<EFBFBD>mpft
* konventionell weiter */ * konventionell weiter */
if (numattack == 0 && af->magic > 0) { if (numattack == 0 && af->magic > 0) {
/* wenn der magier in die potenzielle Reichweite von Attacken des /* wenn der magier in die potenzielle Reichweite von Attacken des
@ -2135,7 +2136,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
} }
} }
break; break;
case AT_STANDARD: /* Waffen, mag. Gegenstände, Kampfzauber */ case AT_STANDARD: /* Waffen, mag. Gegenst<EFBFBD>nde, Kampfzauber */
if (numattack > 0 || af->magic <= 0) { if (numattack > 0 || af->magic <= 0) {
weapon *wp = ta.fighter->person[ta.index].missile; weapon *wp = ta.fighter->person[ta.index].missile;
int melee = int melee =
@ -2152,7 +2153,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
bool standard_attack = true; bool standard_attack = true;
bool reload = false; bool reload = false;
/* spezialattacken der waffe nur, wenn erste attacke in der runde. /* spezialattacken der waffe nur, wenn erste attacke in der runde.
* sonst helden mit feuerschwertern zu mächtig */ * sonst helden mit feuerschwertern zu m<EFBFBD>chtig */
if (numattack == 0 && wp && wp->type->attack) { if (numattack == 0 && wp && wp->type->attack) {
int dead = 0; int dead = 0;
standard_attack = wp->type->attack(&ta, wp->type, &dead); standard_attack = wp->type->attack(&ta, wp->type, &dead);
@ -2193,14 +2194,14 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
if (reload && wp && wp->type->reload && !getreload(ta)) { if (reload && wp && wp->type->reload && !getreload(ta)) {
int i = setreload(ta); int i = setreload(ta);
if (bdebug) { if (bdebug) {
fprintf(bdebug, "%s/%d reloading %d turns\n", unitid(au), fprintf(bdebug, "%s/%d reloading %d turns\n", itoa36(au->no),
ta.index, i); ta.index, i);
} }
} }
} }
} }
break; break;
case AT_SPELL: /* Extra-Sprüche. Kampfzauber in AT_COMBATSPELL! */ case AT_SPELL: /* Extra-Spr<EFBFBD>che. Kampfzauber in AT_COMBATSPELL! */
do_extra_spell(ta, a); do_extra_spell(ta, a);
break; break;
case AT_NATURAL: case AT_NATURAL:
@ -2285,14 +2286,14 @@ void do_attack(fighter * af)
assert(au && au->number); assert(au && au->number);
/* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen
* Kämpfern beruht, darf die Reihenfolge und Größe der Einheit keine * K<EFBFBD>mpfern beruht, darf die Reihenfolge und Gr<EFBFBD><EFBFBD>e der Einheit keine
* Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der
* Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufällig * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zuf<EFBFBD>llig
* mit einer großen Einheit zuerst drankommt, extrem bevorteilt. */ * mit einer gro<EFBFBD>en Einheit zuerst drankommt, extrem bevorteilt. */
ta.index = af->fighting; ta.index = af->fighting;
while (ta.index--) { while (ta.index--) {
/* Wir suchen eine beliebige Feind-Einheit aus. An der können /* Wir suchen eine beliebige Feind-Einheit aus. An der k<EFBFBD>nnen
* wir feststellen, ob noch jemand da ist. */ * wir feststellen, ob noch jemand da ist. */
int apr, attacks = attacks_per_round(ta); int apr, attacks = attacks_per_round(ta);
if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND))
@ -2317,7 +2318,7 @@ void do_attack(fighter * af)
} }
} }
} }
/* Der letzte Katapultschütze setzt die /* Der letzte Katapultsch<EFBFBD>tze setzt die
* Ladezeit neu und generiert die Meldung. */ * Ladezeit neu und generiert die Meldung. */
if (af->catmsg >= 0) { if (af->catmsg >= 0) {
struct message *m = struct message *m =
@ -2391,7 +2392,7 @@ double fleechance(unit * u)
{ {
double c = 0.20; /* Fluchtwahrscheinlichkeit in % */ double c = 0.20; /* Fluchtwahrscheinlichkeit in % */
attrib *a = a_find(u->attribs, &at_fleechance); attrib *a = a_find(u->attribs, &at_fleechance);
/* Einheit u versucht, dem Getümmel zu entkommen */ /* Einheit u versucht, dem Get<EFBFBD>mmel zu entkommen */
c += (effskill(u, SK_STEALTH, 0) * 0.05); c += (effskill(u, SK_STEALTH, 0) * 0.05);
c += horse_fleeing_bonus(u); c += horse_fleeing_bonus(u);
@ -2679,7 +2680,7 @@ static void aftermath(battle * b)
for (s = b->sides; s != b->sides + b->nsides; ++s) { for (s = b->sides; s != b->sides + b->nsides; ++s) {
int snumber = 0; int snumber = 0;
fighter *df; fighter *df;
bool relevant = false; /* Kampf relevant für diese Partei? */ bool relevant = false; /* Kampf relevant f<EFBFBD>r diese Partei? */
if (!fval(s, SIDE_HASGUARDS)) { if (!fval(s, SIDE_HASGUARDS)) {
relevant = true; relevant = true;
} }
@ -2719,7 +2720,7 @@ static void aftermath(battle * b)
/* Report the casualties */ /* Report the casualties */
reportcasualties(b, df, dead); reportcasualties(b, df, dead);
/* Zuerst dürfen die Feinde plündern, die mitgenommenen Items /* Zuerst d<EFBFBD>rfen die Feinde pl<70>ndern, die mitgenommenen Items
* stehen in fig->run.items. Dann werden die Fliehenden auf * stehen in fig->run.items. Dann werden die Fliehenden auf
* die leere (tote) alte Einheit gemapt */ * die leere (tote) alte Einheit gemapt */
if (!fval(df, FIG_NOLOOT)) { if (!fval(df, FIG_NOLOOT)) {
@ -2754,7 +2755,7 @@ static void aftermath(battle * b)
} }
else { else {
if (df->alive == 0) { if (df->alive == 0) {
/* alle sind tot, niemand geflohen. Einheit auflösen */ /* alle sind tot, niemand geflohen. Einheit aufl<EFBFBD>sen */
df->run.number = 0; df->run.number = 0;
df->run.hp = 0; df->run.hp = 0;
@ -2816,7 +2817,7 @@ static void aftermath(battle * b)
/* Wir benutzen drifted, um uns zu merken, ob ein Schiff /* Wir benutzen drifted, um uns zu merken, ob ein Schiff
* schonmal Schaden genommen hat. (moved und drifted * schonmal Schaden genommen hat. (moved und drifted
* sollten in flags überführt werden */ * sollten in flags <EFBFBD>berf<EFBFBD>hrt werden */
for (s = b->sides; s != b->sides + b->nsides; ++s) { for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *df; fighter *df;
@ -2837,7 +2838,7 @@ static void aftermath(battle * b)
} }
/* Wenn sich die Einheit auf einem Schiff befindet, wird /* Wenn sich die Einheit auf einem Schiff befindet, wird
* dieses Schiff beschädigt. Andernfalls ein Schiff, welches * dieses Schiff besch<EFBFBD>digt. Andernfalls ein Schiff, welches
* evt. zuvor verlassen wurde. */ * evt. zuvor verlassen wurde. */
if (ships_damaged) { if (ships_damaged) {
if (du->ship) if (du->ship)
@ -3129,7 +3130,7 @@ static void print_stats(battle * b)
static int weapon_weight(const weapon * w, bool missile) static int weapon_weight(const weapon * w, bool missile)
{ {
if (missile == i2b(fval(w->type, WTF_MISSILE))) { if (missile == !!(fval(w->type, WTF_MISSILE))) {
return w->attackskill + w->defenseskill; return w->attackskill + w->defenseskill;
} }
return 0; return 0;
@ -3210,8 +3211,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
else if (!stealthfaction) { else if (!stealthfaction) {
s1->stealthfaction = NULL; s1->stealthfaction = NULL;
} }
/* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit für noch /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit f<EFBFBD>r noch
* keinen Kampf ausgewählt wurde (sonst rde ein fighter existieren) */ * keinen Kampf ausgew<EFBFBD>hlt wurde (sonst w<EFBFBD>rde ein fighter existieren) */
} }
fig = (struct fighter*)calloc(1, sizeof(struct fighter)); fig = (struct fighter*)calloc(1, sizeof(struct fighter));
@ -3219,8 +3220,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
s1->fighters = fig; s1->fighters = fig;
fig->unit = u; fig->unit = u;
/* In einer Burg muß man a) nicht Angreifer sein, und b) drin sein, und /* In einer Burg mu<EFBFBD> man a) nicht Angreifer sein, und b) drin sein, und
* c) noch Platz finden. d) menschanähnlich sein */ * c) noch Platz finden. d) menschan<EFBFBD>hnlich sein */
if (attack) { if (attack) {
set_attacker(fig); set_attacker(fig);
} }
@ -3246,7 +3247,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
assert(h); assert(h);
rest = u->hp % u->number; rest = u->hp % u->number;
/* Effekte von Sprüchen */ /* Effekte von Spr<EFBFBD>chen */
if (u->attribs) { if (u->attribs) {
const curse_type *speed_ct; const curse_type *speed_ct;
@ -3267,7 +3268,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
/* Effekte von Artefakten */ /* Effekte von Artefakten */
strongmen = _min(fig->unit->number, trollbelts(u)); strongmen = _min(fig->unit->number, trollbelts(u));
/* Hitpoints, Attack- und Defence-Boni für alle Personen */ /* Hitpoints, Attack- und Defence-Boni f<EFBFBD>r alle Personen */
for (i = 0; i < fig->alive; i++) { for (i = 0; i < fig->alive; i++) {
assert(i < fig->unit->number); assert(i < fig->unit->number);
fig->person[i].hp = h; fig->person[i].hp = h;
@ -3288,8 +3289,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
} }
} }
/* Für alle Waffengattungen wird bestimmt, wie viele der Personen mit /* F<EFBFBD>r alle Waffengattungen wird bestimmt, wie viele der Personen mit
* ihr kämpfen nnten, und was ihr Wert darin ist. */ * ihr k<EFBFBD>mpfen k<EFBFBD>nnten, und was ihr Wert darin ist. */
if (u_race(u)->battle_flags & BF_EQUIPMENT) { if (u_race(u)->battle_flags & BF_EQUIPMENT) {
int oi = 0, di = 0, w = 0; int oi = 0, di = 0, w = 0;
for (itm = u->items; itm && w != WMAX; itm = itm->next) { for (itm = u->items; itm && w != WMAX; itm = itm->next) {
@ -3407,12 +3408,12 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
} }
} }
/* Jetzt muß noch geschaut werden, wo die Einheit die jeweils besten /* Jetzt mu<EFBFBD> noch geschaut werden, wo die Einheit die jeweils besten
* Werte hat, das kommt aber erst irgendwo später. Ich entscheide * Werte hat, das kommt aber erst irgendwo sp<EFBFBD>ter. Ich entscheide
* wärend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch * w<EFBFBD>rend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch
* keine addierten boni. */ * keine addierten boni. */
/* Zuerst mal die Spezialbehandlung gewisser Sonderfälle. */ /* Zuerst mal die Spezialbehandlung gewisser Sonderf<EFBFBD>lle. */
fig->magic = effskill(u, SK_MAGIC, 0); fig->magic = effskill(u, SK_MAGIC, 0);
if (fig->horses) { if (fig->horses) {
@ -3577,7 +3578,7 @@ battle *make_battle(region * r)
b->region = r; b->region = r;
b->plane = getplane(r); b->plane = getplane(r);
/* Finde alle Parteien, die den Kampf beobachten können: */ /* Finde alle Parteien, die den Kampf beobachten k<EFBFBD>nnen: */
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u->number > 0) { if (u->number > 0) {
if (!fval(u->faction, FFL_MARK)) { if (!fval(u->faction, FFL_MARK)) {
@ -3766,18 +3767,18 @@ static void join_allies(battle * b)
for (s = b->sides; s != s_end; ++s) { for (s = b->sides; s != s_end; ++s) {
side *se; side *se;
/* Wenn alle attackierten noch FFL_NOAID haben, dann kämpfe nicht mit. */ /* Wenn alle attackierten noch FFL_NOAID haben, dann k<EFBFBD>mpfe nicht mit. */
if (fval(s->faction, FFL_NOAID)) if (fval(s->faction, FFL_NOAID))
continue; continue;
if (s->faction != f) { if (s->faction != f) {
/* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */
if (s->bf->attacker) if (s->bf->attacker)
continue; continue;
/* alliiert müssen wir schon sein, sonst ist's eh egal : */ /* alliiert m<EFBFBD>ssen wir schon sein, sonst ist's eh egal : */
if (!alliedunit(u, s->faction, HELP_FIGHT)) if (!alliedunit(u, s->faction, HELP_FIGHT))
continue; continue;
/* wenn die partei verborgen ist, oder gar eine andere /* wenn die partei verborgen ist, oder gar eine andere
* vorgespiegelt wird, und er sich uns gegenüber nicht zu * vorgespiegelt wird, und er sich uns gegen<EFBFBD>ber nicht zu
* erkennen gibt, helfen wir ihm nicht */ * erkennen gibt, helfen wir ihm nicht */
if (s->stealthfaction) { if (s->stealthfaction) {
if (!allysfm(s, u->faction, HELP_FSTEALTH)) { if (!allysfm(s, u->faction, HELP_FSTEALTH)) {
@ -3785,7 +3786,7 @@ static void join_allies(battle * b)
} }
} }
} }
/* einen alliierten angreifen dürfen sie nicht, es sei denn, der /* einen alliierten angreifen d<EFBFBD>rfen sie nicht, es sei denn, der
* ist mit einem alliierten verfeindet, der nicht attackiert * ist mit einem alliierten verfeindet, der nicht attackiert
* hat: */ * hat: */
for (se = b->sides; se != s_end; ++se) { for (se = b->sides; se != s_end; ++se) {
@ -3799,7 +3800,7 @@ static void join_allies(battle * b)
} }
if (se == s_end) if (se == s_end)
continue; continue;
/* Wenn die Einheit belagert ist, muß auch einer der Alliierten belagert sein: */ /* Wenn die Einheit belagert ist, mu<EFBFBD> auch einer der Alliierten belagert sein: */
if (besieged(u)) { if (besieged(u)) {
fighter *ally; fighter *ally;
for (ally = s->fighters; ally; ally = ally->next) { for (ally = s->fighters; ally; ally = ally->next) {
@ -3810,7 +3811,7 @@ static void join_allies(battle * b)
if (ally == NULL) if (ally == NULL)
continue; continue;
} }
/* keine Einwände, also soll er mitmachen: */ /* keine Einw<EFBFBD>nde, also soll er mitmachen: */
if (c == NULL) { if (c == NULL) {
if (join_battle(b, u, false, &c)) { if (join_battle(b, u, false, &c)) {
if (battledebug) { if (battledebug) {
@ -3926,7 +3927,7 @@ static bool start_battle(region * r, battle ** bp)
continue; continue;
} }
/* ist ein Flüchtling aus einem andern Kampf */ /* ist ein Fl<EFBFBD>chtling aus einem andern Kampf */
if (fval(u, UFL_LONGACTION)) if (fval(u, UFL_LONGACTION))
continue; continue;
@ -3947,7 +3948,7 @@ static bool start_battle(region * r, battle ** bp)
cmistake(u, ord, 234, MSG_BATTLE); cmistake(u, ord, 234, MSG_BATTLE);
} }
else { else {
/* Fehler: "Das Schiff muß erst verlassen werden" */ /* Fehler: "Das Schiff mu<EFBFBD> erst verlassen werden" */
cmistake(u, ord, 19, MSG_BATTLE); cmistake(u, ord, 19, MSG_BATTLE);
} }
continue; continue;
@ -4032,8 +4033,8 @@ static bool start_battle(region * r, battle ** bp)
freset(u2->faction, FFL_NOAID); freset(u2->faction, FFL_NOAID);
if (c1 != NULL && c2 != NULL) { if (c1 != NULL && c2 != NULL) {
/* Merken, wer Angreifer ist, für die Rückzahlung der /* Merken, wer Angreifer ist, f<EFBFBD>r die R<>ckzahlung der
* Präcombataura bei kurzem Kampf. */ * Pr<EFBFBD>combataura bei kurzem Kampf. */
c1->side->bf->attacker = true; c1->side->bf->attacker = true;
if (set_enemy(c1->side, c2->side, true) && battledebug) { if (set_enemy(c1->side, c2->side, true) && battledebug) {
@ -4066,7 +4067,7 @@ static void battle_attacks(battle * b)
&& get_tactics(s, NULL) == b->max_tactics)) { && get_tactics(s, NULL) == b->max_tactics)) {
for (fig = s->fighters; fig; fig = fig->next) { for (fig = s->fighters; fig; fig = fig->next) {
/* ist in dieser Einheit noch jemand handlungsfähig? */ /* ist in dieser Einheit noch jemand handlungsf<EFBFBD>hig? */
if (fig->fighting <= 0) if (fig->fighting <= 0)
continue; continue;
@ -4110,7 +4111,7 @@ static void battle_flee(battle * b)
unit *u = fig->unit; unit *u = fig->unit;
troop dt; troop dt;
int runners = 0; int runners = 0;
/* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */ /* Flucht nicht bei mehr als 600 HP. Damit Wyrme t<EFBFBD>tbar bleiben. */
int runhp = _min(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status))); int runhp = _min(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status)));
if (u->ship && fval(u->region->terrain, SEA_REGION)) { if (u->ship && fval(u->region->terrain, SEA_REGION)) {
@ -4230,7 +4231,7 @@ void do_battle(region * r)
return; return;
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, * /* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja * Ob jemand fliehen kann. Dann er<EFBFBD>brigt sich das ganze ja
* vielleicht schon. */ * vielleicht schon. */
print_header(b); print_header(b);
if (!fighting) { if (!fighting) {
@ -4279,8 +4280,8 @@ void do_battle(region * r)
if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) {
force_leave(b->region, b); force_leave(b->region, b);
} }
/* Hier ist das Gefecht beendet, und wir können die /* Hier ist das Gefecht beendet, und wir k<EFBFBD>nnen die
* Hilfsstrukturen * wieder schen: */ * Hilfsstrukturen * wieder l<EFBFBD>schen: */
if (b) { if (b) {
free_battle(b); free_battle(b);

View file

@ -30,7 +30,7 @@ extern "C" {
#define FS_HELP 2 #define FS_HELP 2
/***** Verteidigungslinien. /***** Verteidigungslinien.
* Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enthält Summen * Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enth<EFBFBD>lt Summen
*/ */
#define NUMROWS 5 #define NUMROWS 5
@ -74,7 +74,7 @@ extern "C" {
struct fighter *fighters; struct fighter *fighters;
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */
int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kämpfer, z.B. Schattenritter. */ int nonblockers[NUMROWS]; /* Anzahl nichtblockierender K<EFBFBD>mpfer, z.B. Schattenritter. */
int alive; /* Die Partei hat den Kampf verlassen */ int alive; /* Die Partei hat den Kampf verlassen */
int removed; /* stoned */ int removed; /* stoned */
int flee; int flee;
@ -131,7 +131,7 @@ extern "C" {
/*** fighter::person::flags ***/ /*** fighter::person::flags ***/
#define FL_TIRED 1 #define FL_TIRED 1
#define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */ #define FL_DAZZLED 2 /* durch Untote oder D<EFBFBD>monen eingesch<63>chtert */
#define FL_PANICED 4 #define FL_PANICED 4
#define FL_COURAGE 8 /* Helden fliehen nie */ #define FL_COURAGE 8 /* Helden fliehen nie */
#define FL_SLEEPING 16 #define FL_SLEEPING 16
@ -156,17 +156,17 @@ extern "C" {
typedef struct fighter { typedef struct fighter {
struct fighter *next; struct fighter *next;
struct side *side; struct side *side;
struct unit *unit; /* Die Einheit, die hier kämpft */ struct unit *unit; /* Die Einheit, die hier k<EFBFBD>mpft */
struct building *building; /* Gebäude, in dem die Einheit evtl. steht */ struct building *building; /* Geb<EFBFBD>ude, in dem die Einheit evtl. steht */
status_t status; /* Kampfstatus */ status_t status; /* Kampfstatus */
struct weapon *weapons; struct weapon *weapons;
struct armor *armors; /* Anzahl Rüstungen jeden Typs */ struct armor *armors; /* Anzahl R<EFBFBD>stungen jeden Typs */
int alive; /* Anzahl der noch nicht Toten in der Einheit */ int alive; /* Anzahl der noch nicht Toten in der Einheit */
int fighting; /* Anzahl der Kämpfer in der aktuellen Runde */ int fighting; /* Anzahl der K<EFBFBD>mpfer in der aktuellen Runde */
int removed; /* Anzahl Kaempfer, die nicht tot sind, aber int removed; /* Anzahl Kaempfer, die nicht tot sind, aber
aus dem Kampf raus sind (zB weil sie aus dem Kampf raus sind (zB weil sie
versteinert wurden). Diese werden auch versteinert wurden). Diese werden auch
in alive noch mitgezählt! */ in alive noch mitgez<EFBFBD>hlt! */
int magic; /* Magietalent der Einheit */ int magic; /* Magietalent der Einheit */
int horses; /* Anzahl brauchbarer Pferde der Einheit */ int horses; /* Anzahl brauchbarer Pferde der Einheit */
int elvenhorses; /* Anzahl brauchbarer Elfenpferde der Einheit */ int elvenhorses; /* Anzahl brauchbarer Elfenpferde der Einheit */
@ -179,7 +179,7 @@ extern "C" {
int defence : 8; /* (Magie) Paradenbonus der Personen */ int defence : 8; /* (Magie) Paradenbonus der Personen */
int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */ int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */
int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */ int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */
int flags : 8; /* (Magie) Diverse Flags auf Kämpfern */ int flags : 8; /* (Magie) Diverse Flags auf K<EFBFBD>mpfern */
int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */ int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */
int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss. int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss.
* dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */ * dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */
@ -224,6 +224,7 @@ extern "C" {
} meffect; } meffect;
extern const troop no_troop; extern const troop no_troop;
extern bool battledebug;
/* BEGIN battle interface */ /* BEGIN battle interface */
side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction); side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction);

View file

@ -19,7 +19,6 @@ without prior permission by the authors of Eressea.
#include <kernel/alliance.h> #include <kernel/alliance.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/config.h>
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/faction.h> #include <kernel/faction.h>
@ -38,6 +37,23 @@ without prior permission by the authors of Eressea.
#include <tolua.h> #include <tolua.h>
#include <string.h> #include <string.h>
typedef struct helpmode {
const char *name;
int status;
} helpmode;
static helpmode helpmodes[] = {
{ "all", HELP_ALL },
{ "money", HELP_MONEY },
{ "fight", HELP_FIGHT },
{ "observe", HELP_OBSERVE },
{ "give", HELP_GIVE },
{ "guard", HELP_GUARD },
{ "stealth", HELP_FSTEALTH },
{ "travel", HELP_TRAVEL },
{ NULL, 0 }
};
int tolua_factionlist_next(lua_State * L) int tolua_factionlist_next(lua_State * L)
{ {
faction **faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1)); faction **faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1));

View file

View file

View file

@ -1,6 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "spells.h" #include "spells.h"
/* kernel includes */ /* kernel includes */

View file

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
/* kernel includes */ /* kernel includes */
#include <kernel/order.h> #include <kernel/order.h>

View file

@ -182,11 +182,6 @@ void process_promote(void) {
process_cmd(K_PROMOTION, promotion_cmd, 0); process_cmd(K_PROMOTION, promotion_cmd, 0);
} }
void process_renumber(void) {
process_cmd(K_NUMBER, renumber_cmd, 0);
renumber_factions();
}
void process_restack(void) { void process_restack(void) {
restack_units(); restack_units();
} }

View file

@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "bind_storage.h" #include "bind_storage.h"
#include <kernel/save.h> #include <kernel/save.h>

View file

@ -1,61 +0,0 @@
#include <platform.h>
#include "callback.h"
#include <stdlib.h>
#include <string.h>
static struct reg {
struct reg * next;
HCALLBACK cb;
char *name;
} *registry;
HCALLBACK create_callback(void(*cbv)(va_list va)) {
HCALLBACK cb;
cb.cbv = cbv;
return cb;
}
void reset_callbacks(void) {
while (registry) {
struct reg *r = registry;
registry = r->next;
free(r->name);
free(r);
}
registry = 0;
}
HCALLBACK register_callback(const char *name, void(*cbv)(va_list va))
{
struct reg * r = (struct reg *)malloc(sizeof(struct reg));
r->next = registry;
r->name = _strdup(name);
r->cb.cbv = cbv;
registry = r;
return r->cb;
}
int find_callback(const char *name, HCALLBACK *result) {
if (result && name) {
struct reg *r;
for (r = registry; r; r = r->next) {
if (strcmp(r->name, name) == 0) {
*result = r->cb;
return 0;
}
}
}
return -1;
}
int call_callback(HCALLBACK cb, const char *name, ...) {
va_list ap;
if (name) {
int err = find_callback(name, &cb);
if (err) return err;
}
va_start(ap, name);
cb.cbv(ap);
va_end(ap);
return 0;
}

View file

@ -1,16 +0,0 @@
#ifndef H_CALLBACK_H
#define H_CALLBACK_H
#include <stdarg.h>
typedef struct {
void(*cbv)(va_list va);
} HCALLBACK;
HCALLBACK register_callback(const char *name, void(*cbv)(va_list va));
HCALLBACK create_callback(void(*cbv)(va_list va));
int find_callback(const char *name, HCALLBACK *result);
int call_callback(HCALLBACK cb, const char *name, ...);
void reset_callbacks(void);
#endif

View file

@ -1,51 +0,0 @@
#include "callback.h"
#include <stdlib.h>
#include <CuTest.h>
void callback(va_list ap) {
int i = (int)va_arg(ap, int);
int *p = va_arg(ap, int *);
*p += i;
}
static void test_find_callback(CuTest *tc) {
HCALLBACK cb;
reset_callbacks();
CuAssertIntEquals(tc, -1, find_callback("test", &cb));
cb = register_callback("test", callback);
CuAssertIntEquals(tc, 0, find_callback("test", &cb));
reset_callbacks();
}
static void test_call_by_handle(CuTest *tc) {
HCALLBACK cb;
int x = 0;
reset_callbacks();
cb = create_callback(callback);
CuAssertIntEquals(tc, 0, call_callback(cb, 0, 42, &x));
CuAssertIntEquals(tc, 42, x);
reset_callbacks();
}
static void test_call_by_name(CuTest *tc) {
HCALLBACK cb = { 0 };
HCALLBACK ca = { 0 };
int x = 0;
reset_callbacks();
CuAssertIntEquals(tc, -1, call_callback(cb, "test", 42, &x));
cb = register_callback("test", callback);
CuAssertIntEquals(tc, 0, call_callback(cb, "test", 42, &x));
CuAssertIntEquals(tc, 42, x);
CuAssertIntEquals(tc, 0, call_callback(ca, "test", 42, &x));
CuAssertIntEquals(tc, 84, x);
reset_callbacks();
}
CuSuite *get_callback_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_find_callback);
SUITE_ADD_TEST(suite, test_call_by_name);
SUITE_ADD_TEST(suite, test_call_by_handle);
return suite;
}

View file

@ -85,7 +85,7 @@ static const terrain_type *chaosterrain(void)
if (numtypes == 0) { if (numtypes == 0) {
const terrain_type *terrain; const terrain_type *terrain;
for (terrain = terrains(); terrain != NULL; terrain = terrain->next) { for (terrain = terrains(); terrain != NULL; terrain = terrain->next) {
if (fval(terrain, LAND_REGION) && terrain->herbs) { if ((terrain->flags & LAND_REGION) && terrain->herbs) {
++numtypes; ++numtypes;
} }
} }
@ -93,7 +93,7 @@ static const terrain_type *chaosterrain(void)
types = malloc(sizeof(terrain_type *) * numtypes); types = malloc(sizeof(terrain_type *) * numtypes);
numtypes = 0; numtypes = 0;
for (terrain = terrains(); terrain != NULL; terrain = terrain->next) { for (terrain = terrains(); terrain != NULL; terrain = terrain->next) {
if (fval(terrain, LAND_REGION) && terrain->herbs) { if ((terrain->flags & LAND_REGION) && terrain->herbs) {
types[numtypes++] = terrain; types[numtypes++] = terrain;
} }
} }
@ -139,7 +139,7 @@ static void chaos(region * r)
if (rng_int() % 100 < 8) { if (rng_int() % 100 < 8) {
switch (rng_int() % 3) { switch (rng_int() % 3) {
case 0: /* Untote */ case 0: /* Untote */
if (!fval(r->terrain, SEA_REGION)) { if (!(r->terrain->flags & SEA_REGION)) {
unit *u = random_unit(r); unit *u = random_unit(r);
if (u && playerrace(u_race(u))) { if (u && playerrace(u_race(u))) {
ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u)); ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
@ -161,29 +161,28 @@ static void chaos(region * r)
break; break;
case 1: case 1:
mfac = 500; mfac = 500;
u = u = create_unit(r, get_monsters(), rng_int() % 4 + 1,
create_unit(r, get_monsters(), rng_int() % 4 + 1,
get_race(RC_DRAGON), 0, NULL, NULL); get_race(RC_DRAGON), 0, NULL, NULL);
break; break;
default: default:
mfac = 1000; mfac = 1000;
u = u = create_unit(r, get_monsters(), rng_int() % 2 + 1,
create_unit(r, get_monsters(), rng_int() % 2 + 1,
get_race(RC_WYRM), 0, NULL, NULL); get_race(RC_WYRM), 0, NULL, NULL);
break; break;
} }
if (mfac) if (mfac) {
set_money(u, u->number * (rng_int() % mfac)); set_money(u, u->number * (rng_int() % mfac));
fset(u, UFL_ISNEW | UFL_MOVED); }
u->flags |= (UFL_ISNEW | UFL_MOVED);
} }
break; break;
case 2: /* Terrainveränderung */ case 2: /* Terrainver<EFBFBD>nderung */
if (!fval(r->terrain, FORBIDDEN_REGION)) { if (!(r->terrain->flags & FORBIDDEN_REGION)) {
if (!fval(r->terrain, SEA_REGION)) { if (!(r->terrain->flags & SEA_REGION)) {
direction_t dir; direction_t dir;
for (dir = 0; dir != MAXDIRECTIONS; ++dir) { for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
region *rn = rconnect(r, dir); region *rn = rconnect(r, dir);
if (rn && fval(rn->terrain, SEA_REGION)) if (rn && (rn->terrain->flags & SEA_REGION))
break; break;
} }
if (dir != MAXDIRECTIONS) { if (dir != MAXDIRECTIONS) {
@ -224,7 +223,7 @@ static void chaos(region * r)
direction_t dir; direction_t dir;
for (dir = 0; dir != MAXDIRECTIONS; ++dir) { for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
region *rn = rconnect(r, dir); region *rn = rconnect(r, dir);
if (rn && fval(rn->terrain, SEA_REGION)) if (rn && (rn->terrain->flags & SEA_REGION))
break; break;
} }
if (dir != MAXDIRECTIONS) { if (dir != MAXDIRECTIONS) {
@ -242,7 +241,7 @@ void chaos_update(void) {
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
int i; int i;
if (fval(r, RF_CHAOTIC)) { if ((r->flags & RF_CHAOTIC)) {
chaos(r); chaos(r);
} }
i = get_chaoscount(r); i = get_chaoscount(r);

View file

@ -11,6 +11,7 @@ without prior permission by the authors of Eressea.
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/version.h> #include <kernel/version.h>
#include "creport.h" #include "creport.h"
#include "market.h"
#include "guard.h" #include "guard.h"
#include "travelthru.h" #include "travelthru.h"
@ -781,7 +782,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
if (sf != u->faction) if (sf != u->faction)
stream_printf(out, "%d;Verkleidung\n", sf->no); stream_printf(out, "%d;Verkleidung\n", sf->no);
if (fval(u, UFL_ANON_FACTION)) if (fval(u, UFL_ANON_FACTION))
stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION))); stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION)!=0);
if (otherfaction && otherfaction != u->faction) { if (otherfaction && otherfaction != u->faction) {
stream_printf(out, "%d;Anderepartei\n", otherfaction->no); stream_printf(out, "%d;Anderepartei\n", otherfaction->no);
} }
@ -793,7 +794,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
else { else {
if (fval(u, UFL_ANON_FACTION)) { if (fval(u, UFL_ANON_FACTION)) {
/* faction info is hidden */ /* faction info is hidden */
stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION))); stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0);
} }
else { else {
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);

View file

@ -1278,7 +1278,7 @@ int make_cmd(unit * u, struct order *ord)
s = gettoken(token, sizeof(token)); s = gettoken(token, sizeof(token));
if (s) { if (s) {
m = atoi((const char *)s); m = atoip(s);
sprintf(ibuf, "%d", m); sprintf(ibuf, "%d", m);
if (!strcmp(ibuf, (const char *)s)) { if (!strcmp(ibuf, (const char *)s)) {
/* a quantity was given */ /* a quantity was given */
@ -1882,7 +1882,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
} }
} }
else { else {
n = s ? atoi(s) : 0; n = s ? atoip(s) : 0;
if (n == 0) { if (n == 0) {
cmistake(u, ord, 27, MSG_COMMERCE); cmistake(u, ord, 27, MSG_COMMERCE);
return false; return false;
@ -2274,7 +2274,7 @@ static void breed_cmd(unit * u, struct order *ord)
(void)init_order(ord); (void)init_order(ord);
s = gettoken(token, sizeof(token)); s = gettoken(token, sizeof(token));
m = s ? atoi((const char *)s) : 0; m = s ? atoip(s) : 0;
if (m != 0) { if (m != 0) {
/* first came a want-paramter */ /* first came a want-paramter */
s = gettoken(token, sizeof(token)); s = gettoken(token, sizeof(token));
@ -2908,7 +2908,7 @@ void auto_work(region * r)
} }
} }
if (nextworker != workers) { if (nextworker != workers) {
expandwork(r, workers, nextworker, maxworkingpeasants(r)); expandwork(r, workers, nextworker, region_maxworkers(r));
} }
} }
@ -3112,7 +3112,7 @@ void produce(struct region *r)
if (entertaining) if (entertaining)
expandentertainment(r); expandentertainment(r);
if (!rule_autowork()) { if (!rule_autowork()) {
expandwork(r, workers, nextworker, maxworkingpeasants(r)); expandwork(r, workers, nextworker, region_maxworkers(r));
} }
if (taxorders) if (taxorders)
expandtax(r, taxorders); expandtax(r, taxorders);

View file

@ -600,16 +600,19 @@ void give_cmd(unit * u, order * ord)
} }
if (u2 && u_race(u2) == get_race(RC_SPELL)) { if (u2 && u_race(u2) == get_race(RC_SPELL)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
"")); "feedback_unit_not_found", ""));
return; return;
} }
else if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) { else if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
cmistake(u, ord, 40, MSG_COMMERCE); cmistake(u, ord, 40, MSG_COMMERCE);
return; return;
} }
else if (p == NOPARAM) {
/* the most likely case: giving items to someone.
* let's catch this and save ourselves the rest of the param_t checks.
*/
}
else if (p == P_HERBS) { else if (p == P_HERBS) {
bool given = false; bool given = false;
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) { if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) {

View file

@ -23,6 +23,7 @@
#include <assert.h> #include <assert.h>
struct give { struct give {
struct locale * lang;
struct unit *src, *dst; struct unit *src, *dst;
struct region *r; struct region *r;
struct faction *f1, *f2; struct faction *f1, *f2;
@ -46,11 +47,16 @@ static void setup_give(struct give *env) {
ally * al = ally_add(&env->f2->allies, env->f1); ally * al = ally_add(&env->f2->allies, env->f1);
al->status = HELP_GIVE; al->status = HELP_GIVE;
} }
if (env->lang) {
locale_setstring(env->lang, env->itype->rtype->_name, "SILBER");
init_locale(env->lang);
env->f1->locale = env->lang;
}
} }
static void test_give_unit_to_peasants(CuTest * tc) { static void test_give_unit_to_peasants(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = 0; env.f2 = 0;
setup_give(&env); setup_give(&env);
@ -62,8 +68,8 @@ static void test_give_unit_to_peasants(CuTest * tc) {
} }
static void test_give_unit(CuTest * tc) { static void test_give_unit(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -81,8 +87,8 @@ static void test_give_unit(CuTest * tc) {
} }
static void test_give_unit_in_ocean(CuTest * tc) { static void test_give_unit_in_ocean(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = 0; env.f2 = 0;
setup_give(&env); setup_give(&env);
@ -93,8 +99,8 @@ static void test_give_unit_in_ocean(CuTest * tc) {
} }
static void test_give_men(CuTest * tc) { static void test_give_men(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL)); CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL));
@ -104,11 +110,11 @@ static void test_give_men(CuTest * tc) {
} }
static void test_give_men_magicians(CuTest * tc) { static void test_give_men_magicians(CuTest * tc) {
struct give env; struct give env = { 0 };
int p; int p;
message * msg; message * msg;
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
set_level(env.src, SK_MAGIC, 1); set_level(env.src, SK_MAGIC, 1);
@ -135,9 +141,9 @@ static void test_give_men_magicians(CuTest * tc) {
} }
static void test_give_men_limit(CuTest * tc) { static void test_give_men_limit(CuTest * tc) {
struct give env; struct give env = { 0 };
message *msg; message *msg;
test_setup(); test_setup_ex(tc);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -165,10 +171,10 @@ static void test_give_men_limit(CuTest * tc) {
} }
static void test_give_men_in_ocean(CuTest * tc) { static void test_give_men_in_ocean(CuTest * tc) {
struct give env; struct give env = { 0 };
message * msg; message * msg;
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = 0; env.f2 = 0;
setup_give(&env); setup_give(&env);
@ -181,8 +187,8 @@ static void test_give_men_in_ocean(CuTest * tc) {
} }
static void test_give_men_too_many(CuTest * tc) { static void test_give_men_too_many(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL)); CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL));
@ -192,10 +198,10 @@ static void test_give_men_too_many(CuTest * tc) {
} }
static void test_give_men_none(CuTest * tc) { static void test_give_men_none(CuTest * tc) {
struct give env; struct give env = { 0 };
message * msg; message * msg;
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
msg = give_men(0, env.src, env.dst, NULL); msg = give_men(0, env.src, env.dst, NULL);
@ -207,10 +213,10 @@ static void test_give_men_none(CuTest * tc) {
} }
static void test_give_men_other_faction(CuTest * tc) { static void test_give_men_other_faction(CuTest * tc) {
struct give env; struct give env = { 0 };
message * msg; message * msg;
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -224,12 +230,12 @@ static void test_give_men_other_faction(CuTest * tc) {
} }
static void test_give_men_requires_contact(CuTest * tc) { static void test_give_men_requires_contact(CuTest * tc) {
struct give env; struct give env = { 0 };
message * msg; message * msg;
order *ord; order *ord;
char cmd[32]; char cmd[32];
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -251,9 +257,9 @@ static void test_give_men_requires_contact(CuTest * tc) {
} }
static void test_give_men_not_to_self(CuTest * tc) { static void test_give_men_not_to_self(CuTest * tc) {
struct give env; struct give env = { 0 };
message * msg; message * msg;
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
msg = give_men(1, env.src, env.src, NULL); msg = give_men(1, env.src, env.src, NULL);
@ -264,10 +270,10 @@ static void test_give_men_not_to_self(CuTest * tc) {
} }
static void test_give_peasants(CuTest * tc) { static void test_give_peasants(CuTest * tc) {
struct give env; struct give env = { 0 };
message * msg; message * msg;
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = 0; env.f2 = 0;
setup_give(&env); setup_give(&env);
@ -281,9 +287,9 @@ static void test_give_peasants(CuTest * tc) {
} }
static void test_give(CuTest * tc) { static void test_give(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -298,12 +304,35 @@ static void test_give(CuTest * tc) {
test_cleanup(); test_cleanup();
} }
static void test_give_herbs(CuTest * tc) { static void test_give_cmd(CuTest * tc) {
struct give env; struct give env = { 0 };
struct order *ord; struct order *ord;
char cmd[32]; char cmd[32];
test_setup(); test_setup_ex(tc);
env.lang = test_create_locale();
env.f2 = env.f1 = test_create_faction(0);
setup_give(&env);
i_change(&env.src->items, env.itype, 10);
_snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name));
ord = create_order(K_GIVE, env.f1->locale, cmd);
assert(ord);
give_cmd(env.src, ord);
CuAssertIntEquals(tc, 5, i_get(env.src->items, env.itype));
CuAssertIntEquals(tc, 5, i_get(env.dst->items, env.itype));
free_order(ord);
test_cleanup();
}
static void test_give_herbs(CuTest * tc) {
struct give env = { 0 };
struct order *ord;
char cmd[32];
test_setup_ex(tc);
test_create_world(); test_create_world();
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -321,9 +350,9 @@ static void test_give_herbs(CuTest * tc) {
} }
static void test_give_okay(CuTest * tc) { static void test_give_okay(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f2 = env.f1 = test_create_faction(0); env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -333,10 +362,10 @@ static void test_give_okay(CuTest * tc) {
} }
static void test_give_denied_by_rules(CuTest * tc) { static void test_give_denied_by_rules(CuTest * tc) {
struct give env; struct give env = { 0 };
struct message *msg; struct message *msg;
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -348,10 +377,10 @@ static void test_give_denied_by_rules(CuTest * tc) {
} }
static void test_give_dead_unit(CuTest * tc) { static void test_give_dead_unit(CuTest * tc) {
struct give env; struct give env = { 0 };
struct message *msg; struct message *msg;
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -363,9 +392,9 @@ static void test_give_dead_unit(CuTest * tc) {
} }
static void test_give_new_unit(CuTest * tc) { static void test_give_new_unit(CuTest * tc) {
struct give env; struct give env = { 0 };
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = test_create_faction(0); env.f2 = test_create_faction(0);
setup_give(&env); setup_give(&env);
@ -377,10 +406,10 @@ static void test_give_new_unit(CuTest * tc) {
static void test_give_invalid_target(CuTest *tc) { static void test_give_invalid_target(CuTest *tc) {
// bug https://bugs.eressea.de/view.php?id=1685 // bug https://bugs.eressea.de/view.php?id=1685
struct give env; struct give env = { 0 };
order *ord; order *ord;
test_setup(); test_setup_ex(tc);
env.f1 = test_create_faction(0); env.f1 = test_create_faction(0);
env.f2 = 0; env.f2 = 0;
setup_give(&env); setup_give(&env);
@ -400,6 +429,7 @@ CuSuite *get_give_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_give); SUITE_ADD_TEST(suite, test_give);
SUITE_ADD_TEST(suite, test_give_cmd);
SUITE_ADD_TEST(suite, test_give_men); SUITE_ADD_TEST(suite, test_give_men);
SUITE_ADD_TEST(suite, test_give_men_magicians); SUITE_ADD_TEST(suite, test_give_men_magicians);
SUITE_ADD_TEST(suite, test_give_men_limit); SUITE_ADD_TEST(suite, test_give_men_limit);

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "artrewards.h" #include "artrewards.h"
/* kernel includes */ /* kernel includes */

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "demonseye.h" #include "demonseye.h"
/* kernel includes */ /* kernel includes */

View file

@ -11,7 +11,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "itemtypes.h" #include "itemtypes.h"
#include "xerewards.h" #include "xerewards.h"

View file

@ -17,13 +17,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "seed.h" #include "seed.h"
/* kernel includes */ /* kernel includes */
#include <kernel/build.h> #include <kernel/build.h>
#include <kernel/config.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/region.h> #include <kernel/region.h>
@ -42,7 +40,7 @@ static void produce_seeds(region * r, const resource_type * rtype, int norders)
static int limit_seeds(const region * r, const resource_type * rtype) static int limit_seeds(const region * r, const resource_type * rtype)
{ {
if (fval(r, RF_MALLORN)) { if ((r->flags & RF_MALLORN)) {
return 0; return 0;
} }
return r->land ? r->land->trees[0] : 0; return r->land ? r->land->trees[0] : 0;
@ -68,13 +66,13 @@ void init_seed(void)
static void static void
produce_mallornseeds(region * r, const resource_type * rtype, int norders) produce_mallornseeds(region * r, const resource_type * rtype, int norders)
{ {
assert(fval(r, RF_MALLORN)); assert(r->flags & RF_MALLORN);
r->land->trees[0] -= norders; r->land->trees[0] -= norders;
} }
static int limit_mallornseeds(const region * r, const resource_type * rtype) static int limit_mallornseeds(const region * r, const resource_type * rtype)
{ {
if (!fval(r, RF_MALLORN)) { if (!(r->flags & RF_MALLORN)) {
return 0; return 0;
} }
return r->land ? r->land->trees[0] : 0; return r->land ? r->land->trees[0] : 0;

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "speedsail.h" #include "speedsail.h"
/* kernel includes */ /* kernel includes */

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "weapons.h" #include "weapons.h"
#include "battle.h" #include "battle.h"

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "xerewards.h" #include "xerewards.h"
#include "magic.h" #include "magic.h"

View file

@ -426,7 +426,7 @@ building *new_building(const struct building_type * btype, region * r,
bname = parameters[P_GEBAEUDE]; bname = parameters[P_GEBAEUDE];
} }
assert(bname); assert(bname);
slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b)); slprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no));
b->name = _strdup(bname); b->name = _strdup(bname);
return b; return b;
} }

View file

@ -101,61 +101,8 @@ struct settings global = {
}; };
bool lomem = false; bool lomem = false;
FILE *logfile;
bool battledebug = false;
int turn = -1; int turn = -1;
int NewbieImmunity(void)
{
return config_get_int("NewbieImmunity", 0);
}
bool IsImmune(const faction * f)
{
return !fval(f, FFL_NPC) && f->age < NewbieImmunity();
}
bool ExpensiveMigrants(void)
{
return config_get_int("study.expensivemigrants", 0) != 0;
}
int LongHunger(const struct unit *u)
{
if (u != NULL) {
if (!fval(u, UFL_HUNGER))
return false;
if (u_race(u) == get_race(RC_DAEMON))
return false;
}
return config_get_int("hunger.long", 0);
}
int NMRTimeout(void)
{
return config_get_int("nmr.timeout", 0);
}
helpmode helpmodes[] = {
{ "all", HELP_ALL }
,
{ "money", HELP_MONEY }
,
{ "fight", HELP_FIGHT }
,
{ "observe", HELP_OBSERVE }
,
{ "give", HELP_GIVE }
,
{ "guard", HELP_GUARD }
,
{ "stealth", HELP_FSTEALTH }
,
{ "travel", HELP_TRAVEL }
,
{ NULL, 0 }
};
const char *parameters[MAXPARAMS] = { const char *parameters[MAXPARAMS] = {
"LOCALE", "LOCALE",
"ALLES", "ALLES",
@ -179,7 +126,7 @@ const char *parameters[MAXPARAMS] = {
"TEMP", "TEMP",
"FLIEHE", "FLIEHE",
"GEBAEUDE", "GEBAEUDE",
"GIB", /* Für HELFE */ "GIB", /* F<EFBFBD>r HELFE */
"KAEMPFE", "KAEMPFE",
"DURCHREISE", "DURCHREISE",
"BEWACHE", "BEWACHE",
@ -203,43 +150,6 @@ const char *parameters[MAXPARAMS] = {
"ALLIANZ" "ALLIANZ"
}; };
const char *report_options[MAX_MSG] = {
"Kampf",
"Ereignisse",
"Bewegung",
"Einkommen",
"Handel",
"Produktion",
"Orkvermehrung",
"Zauber",
"",
""
};
const char *message_levels[ML_MAX] = {
"Wichtig",
"Debug",
"Fehler",
"Warnungen",
"Infos"
};
const char *options[MAXOPTIONS] = {
"AUSWERTUNG",
"COMPUTER",
"ZUGVORLAGE",
NULL,
"STATISTIK",
"DEBUG",
"ZIPPED",
"ZEITUNG", /* Option hat Sonderbehandlung! */
NULL,
"ADRESSEN",
"BZIP2",
"PUNKTE",
"SHOWSKCHANGE"
};
FILE *debug; FILE *debug;
void void
@ -433,13 +343,6 @@ int newcontainerid(void)
return random_no; return random_no;
} }
int maxworkingpeasants(const struct region *r)
{
int size = production(r);
int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
return _max(size - treespace, _min(size / 10, 200));
}
static const char * parameter_key(int i) static const char * parameter_key(int i)
{ {
assert(i < MAXPARAMS && i >= 0); assert(i < MAXPARAMS && i >= 0);
@ -749,8 +652,8 @@ char *_strdup(const char *s)
} }
#endif #endif
/* Lohn bei den einzelnen Burgstufen für Normale Typen, Orks, Bauern, /* Lohn bei den einzelnen Burgstufen f<EFBFBD>r Normale Typen, Orks, Bauern,
* Modifikation für Städter. */ * Modifikation f<EFBFBD>r St<EFBFBD>dter. */
static const int wagetable[7][4] = { static const int wagetable[7][4] = {
{ 10, 10, 11, -7 }, /* Baustelle */ { 10, 10, 11, -7 }, /* Baustelle */
@ -967,7 +870,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
wage = _max(0, wage - 10); wage = _max(0, wage - 10);
} }
/* Bei einer Dürre verdient man nur noch ein Viertel */ /* Bei einer D<EFBFBD>rre verdient man nur noch ein Viertel */
if (drought_ct) { if (drought_ct) {
curse *c = get_curse(r->attribs, drought_ct); curse *c = get_curse(r->attribs, drought_ct);
if (curse_active(c)) if (curse_active(c))
@ -991,7 +894,7 @@ minimum_wage(const region * r, const faction * f, const race * rc, int in_turn)
return default_wage(r, f, rc, in_turn); return default_wage(r, f, rc, in_turn);
} }
/* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für /* Gibt Arbeitslohn f<EFBFBD>r entsprechende Rasse zur<75>ck, oder f<>r
* die Bauern wenn f == NULL. */ * die Bauern wenn f == NULL. */
int wage(const region * r, const faction * f, const race * rc, int in_turn) int wage(const region * r, const faction * f, const race * rc, int in_turn)
{ {
@ -1001,14 +904,6 @@ int wage(const region * r, const faction * f, const race * rc, int in_turn)
return default_wage(r, f, rc, in_turn); return default_wage(r, f, rc, in_turn);
} }
int lovar(double xpct_x2)
{
int n = (int)(xpct_x2 * 500) + 1;
if (n == 0)
return 0;
return (rng_int() % n + rng_int() % n) / 1000;
}
void kernel_init(void) void kernel_init(void)
{ {
register_reports(); register_reports();
@ -1068,11 +963,6 @@ int rule_give(void)
return rule; return rule;
} }
bool markets_module(void)
{
return (bool)config_get_int("modules.markets", 0);
}
static struct param *configuration; static struct param *configuration;
static int config_cache_key = 1; static int config_cache_key = 1;

View file

@ -27,19 +27,12 @@ extern "C" {
#include "types.h" #include "types.h"
struct param; struct param;
#define DISPLAYSIZE 8192 /* max. Länge einer Beschreibung, incl trailing 0 */ #define DISPLAYSIZE 8192 /* max. L<EFBFBD>nge einer Beschreibung, incl trailing 0 */
#define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */ #define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */
#define NAMESIZE 128 /* max. Länge eines Namens, incl trailing 0 */ #define NAMESIZE 128 /* max. L<>nge eines Namens, incl trailing 0 */
#define IDSIZE 16 /* max. Länge einer no (als String), incl trailing 0 */ #define IDSIZE 16 /* max. L<>nge einer no (als String), incl trailing 0 */
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die #define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. L<>nge der Strings, die
* von struct unitname, etc. zurückgegeben werden. ohne die 0 */ * von struct unitname, etc. zur<EFBFBD>ckgegeben werden. ohne die 0 */
/* ----------------- Befehle ----------------------------------- */
#define want(option) (1<<option)
/* ------------------------------------------------------------- */
#define i2b(i) ((bool)((i)?(true):(false)))
#define fval(u, i) ((u)->flags & (i)) #define fval(u, i) ((u)->flags & (i))
#define fset(u, i) ((u)->flags |= (i)) #define fset(u, i) ((u)->flags |= (i))
@ -52,16 +45,8 @@ struct param;
bool isparam(const char *s, const struct locale * lang, param_t param); bool isparam(const char *s, const struct locale * lang, param_t param);
param_t getparam(const struct locale *lang); param_t getparam(const struct locale *lang);
#define unitid(x) itoa36((x)->no)
#define buildingid(x) itoa36((x)->no)
#define shipid(x) itoa36((x)->no)
#define factionid(x) itoa36((x)->no)
#define curseid(x) itoa36((x)->no)
const char * game_name(void); const char * game_name(void);
int game_id(void); int game_id(void);
int lovar(double xpct_x2);
/* returns a value between [0..xpct_2], generated with two dice */ /* returns a value between [0..xpct_2], generated with two dice */
void init_locale(struct locale *lang); void init_locale(struct locale *lang);
@ -110,12 +95,10 @@ struct param;
#define GF_SPECIFIC 16 #define GF_SPECIFIC 16
/* der, die, das vs. ein, eine */ /* der, die, das vs. ein, eine */
#define GF_DETAILED 32 #define GF_DETAILED 32
/* mehr Informationen. z.b. straße zu 50% */ /* mehr Informationen. z.b. stra<EFBFBD>e zu 50% */
#define GF_PURE 64 #define GF_PURE 64
/* untranslated */ /* untranslated */
int maxworkingpeasants(const struct region *r);
bool markets_module(void);
int wage(const struct region *r, const struct faction *f, int wage(const struct region *r, const struct faction *f,
const struct race *rc, int in_turn); const struct race *rc, int in_turn);
@ -139,7 +122,6 @@ struct param;
struct attrib *attribs; struct attrib *attribs;
unsigned int data_turn; unsigned int data_turn;
void *vm_state; void *vm_state;
int data_version; /* TODO: eliminate in favor of gamedata.version */
struct _dictionary_ *inifile; struct _dictionary_ *inifile;
struct global_functions { struct global_functions {
int(*wage) (const struct region * r, const struct faction * f, int(*wage) (const struct region * r, const struct faction * f,
@ -147,11 +129,6 @@ struct param;
} functions; } functions;
} settings; } settings;
typedef struct helpmode {
const char *name;
int status;
} helpmode;
void set_param(struct param **p, const char *key, const char *value); void set_param(struct param **p, const char *key, const char *value);
const char *get_param(const struct param *p, const char *key); const char *get_param(const struct param *p, const char *key);
int get_param_int(const struct param *p, const char *key, int def); int get_param_int(const struct param *p, const char *key, int def);
@ -167,11 +144,6 @@ struct param;
bool config_changed(int *cache_key); bool config_changed(int *cache_key);
char * join_path(const char *p1, const char *p2, char *dst, size_t len); char * join_path(const char *p1, const char *p2, char *dst, size_t len);
bool ExpensiveMigrants(void);
int NMRTimeout(void);
int LongHunger(const struct unit *u);
int NewbieImmunity(void);
bool IsImmune(const struct faction *f);
struct order *default_order(const struct locale *lang); struct order *default_order(const struct locale *lang);
@ -181,18 +153,11 @@ struct param;
void free_gamedata(void); void free_gamedata(void);
void free_config(void); void free_config(void);
extern struct helpmode helpmodes[];
extern const char *parameters[]; extern const char *parameters[];
extern const char *localenames[];
extern settings global; extern settings global;
extern bool battledebug;
extern bool sqlpatch;
extern bool lomem; /* save memory */ extern bool lomem; /* save memory */
extern int turn; extern int turn;
extern bool getunitpeasants;
extern const char *options[MAXOPTIONS]; /* report options */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -30,6 +30,8 @@ extern "C" {
struct curse_type; struct curse_type;
struct gamedata; struct gamedata;
struct storage; struct storage;
struct attrib;
struct faction;
/* Sprueche in der struct region und auf Einheiten, Schiffen oder Burgen /* Sprueche in der struct region und auf Einheiten, Schiffen oder Burgen
* (struct attribute) * (struct attribute)

View file

@ -273,11 +273,11 @@ faction *addfaction(const char *email, const char *password,
addlist(&factions, f); addlist(&factions, f);
fhash(f); fhash(f);
slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f)); slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no));
f->name = _strdup(buf); f->name = _strdup(buf);
if (!f->race) { if (!f->race) {
log_warning("creating a faction that has no race", factionid(f)); log_warning("creating a faction that has no race", itoa36(f->no));
} }
return f; return f;
@ -828,7 +828,7 @@ int writepasswd(void)
for (f = factions; f; f = f->next) { for (f = factions; f; f = f->next) {
fprintf(F, "%s:%s:%s:%u\n", fprintf(F, "%s:%s:%s:%u\n",
factionid(f), f->email, f->_password, f->subscription); itoa36(f->no), f->email, f->_password, f->subscription);
} }
fclose(F); fclose(F);
return 0; return 0;

View file

@ -42,10 +42,10 @@ extern "C" {
#define FFL_DEFENDER (1<<10) #define FFL_DEFENDER (1<<10)
#define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */ #define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */ #define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
#define FFL_MARK (1<<23) /* für markierende algorithmen, die das #define FFL_MARK (1<<23) /* f<EFBFBD>r markierende algorithmen, die das
* hinterher auch wieder löschen ssen! * hinterher auch wieder l<EFBFBD>schen m<EFBFBD>ssen!
* (FFL_SELECT muss man vorher initialisieren, * (FFL_SELECT muss man vorher initialisieren,
* FL_MARK hinterher löschen) */ * FL_MARK hinterher l<EFBFBD>schen) */
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */ #define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */ #define FFL_NPC (1<<25) /* eine Partei mit Monstern */
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_NOIDLEOUT|FFL_CURSED) #define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_NOIDLEOUT|FFL_CURSED)
@ -101,6 +101,8 @@ extern "C" {
extern struct faction *factions; extern struct faction *factions;
#define want(option) (1<<option)
void fhash(struct faction *f); void fhash(struct faction *f);
void funhash(struct faction *f); void funhash(struct faction *f);

View file

@ -75,3 +75,4 @@ CuSuite *get_messages_suite(void) {
SUITE_ADD_TEST(suite, test_message); SUITE_ADD_TEST(suite, test_message);
return suite; return suite;
} }

View file

@ -117,7 +117,7 @@ extern "C" {
float healing; float healing;
double maxaura; /* Faktor auf Maximale Aura */ double maxaura; /* Faktor auf Maximale Aura */
double regaura; /* Faktor auf Regeneration */ double regaura; /* Faktor auf Regeneration */
double recruit_multi; /* Faktor für Bauernverbrauch */ double recruit_multi; /* Faktor f<EFBFBD>r Bauernverbrauch */
int index; int index;
int recruitcost; int recruitcost;
int maintenance; int maintenance;
@ -132,8 +132,8 @@ extern "C" {
int armor; int armor;
int at_default; /* Angriffsskill Unbewaffnet (default: -2) */ int at_default; /* Angriffsskill Unbewaffnet (default: -2) */
int df_default; /* Verteidigungsskill Unbewaffnet (default: -2) */ int df_default; /* Verteidigungsskill Unbewaffnet (default: -2) */
int at_bonus; /* Verändert den Angriffsskill (default: 0) */ int at_bonus; /* Ver<EFBFBD>ndert den Angriffsskill (default: 0) */
int df_bonus; /* Verändert den Verteidigungskill (default: 0) */ int df_bonus; /* Ver<EFBFBD>ndert den Verteidigungskill (default: 0) */
struct param *parameters; // additional properties, for an example see natural_armor struct param *parameters; // additional properties, for an example see natural_armor
const struct spell *precombatspell; const struct spell *precombatspell;
signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */ signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */
@ -190,20 +190,20 @@ extern "C" {
#define RCF_LEARN (1<<6) /* Lernt automatisch wenn struct faction == 0 */ #define RCF_LEARN (1<<6) /* Lernt automatisch wenn struct faction == 0 */
#define RCF_FLY (1<<7) /* kann fliegen */ #define RCF_FLY (1<<7) /* kann fliegen */
#define RCF_SWIM (1<<8) /* kann schwimmen */ #define RCF_SWIM (1<<8) /* kann schwimmen */
#define RCF_WALK (1<<9) /* kann über Land gehen */ #define RCF_WALK (1<<9) /* kann <EFBFBD>ber Land gehen */
#define RCF_NOLEARN (1<<10) /* kann nicht normal lernen */ #define RCF_NOLEARN (1<<10) /* kann nicht normal lernen */
#define RCF_NOTEACH (1<<11) /* kann nicht lehren */ #define RCF_NOTEACH (1<<11) /* kann nicht lehren */
#define RCF_HORSE (1<<12) /* Einheit ist Pferd, sozusagen */ #define RCF_HORSE (1<<12) /* Einheit ist Pferd, sozusagen */
#define RCF_DESERT (1<<13) /* 5% Chance, das Einheit desertiert */ #define RCF_DESERT (1<<13) /* 5% Chance, das Einheit desertiert */
#define RCF_ILLUSIONARY (1<<14) /* (Illusion & Spell) Does not drop items. */ #define RCF_ILLUSIONARY (1<<14) /* (Illusion & Spell) Does not drop items. */
#define RCF_ABSORBPEASANTS (1<<15) /* Tötet und absorbiert Bauern */ #define RCF_ABSORBPEASANTS (1<<15) /* T<EFBFBD>tet und absorbiert Bauern */
#define RCF_NOHEAL (1<<16) /* Einheit kann nicht geheilt werden */ #define RCF_NOHEAL (1<<16) /* Einheit kann nicht geheilt werden */
#define RCF_NOWEAPONS (1<<17) /* Einheit kann keine Waffen benutzen */ #define RCF_NOWEAPONS (1<<17) /* Einheit kann keine Waffen benutzen */
#define RCF_SHAPESHIFT (1<<18) /* Kann TARNE RASSE benutzen. */ #define RCF_SHAPESHIFT (1<<18) /* Kann TARNE RASSE benutzen. */
#define RCF_SHAPESHIFTANY (1<<19) /* Kann TARNE RASSE "string" benutzen. */ #define RCF_SHAPESHIFTANY (1<<19) /* Kann TARNE RASSE "string" benutzen. */
#define RCF_UNDEAD (1<<20) /* Undead. */ #define RCF_UNDEAD (1<<20) /* Undead. */
#define RCF_DRAGON (1<<21) /* Drachenart (für Zauber) */ #define RCF_DRAGON (1<<21) /* Drachenart (f<EFBFBD>r Zauber) */
#define RCF_COASTAL (1<<22) /* kann in Landregionen an der Küste sein */ #define RCF_COASTAL (1<<22) /* kann in Landregionen an der K<EFBFBD>ste sein */
#define RCF_UNARMEDGUARD (1<<23) /* kann ohne Waffen bewachen */ #define RCF_UNARMEDGUARD (1<<23) /* kann ohne Waffen bewachen */
#define RCF_CANSAIL (1<<24) /* Einheit darf Schiffe betreten */ #define RCF_CANSAIL (1<<24) /* Einheit darf Schiffe betreten */
#define RCF_INVISIBLE (1<<25) /* not visible in any report */ #define RCF_INVISIBLE (1<<25) /* not visible in any report */
@ -213,16 +213,16 @@ extern "C" {
#define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */ #define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */
/* Economic flags */ /* Economic flags */
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenstände weg */ #define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst<EFBFBD>nde weg */
#define GIVEPERSON (1<<2) /* übergibt Personen */ #define GIVEPERSON (1<<2) /* <EFBFBD>bergibt Personen */
#define GIVEUNIT (1<<3) /* Einheiten an andere Partei übergeben */ #define GIVEUNIT (1<<3) /* Einheiten an andere Partei <EFBFBD>bergeben */
#define GETITEM (1<<4) /* nimmt Gegenstände an */ #define GETITEM (1<<4) /* nimmt Gegenst<EFBFBD>nde an */
#define ECF_REC_ETHEREAL (1<<7) /* Rekrutiert aus dem Nichts */ #define ECF_REC_ETHEREAL (1<<7) /* Rekrutiert aus dem Nichts */
#define ECF_REC_UNLIMITED (1<<8) /* Rekrutiert ohne Limit */ #define ECF_REC_UNLIMITED (1<<8) /* Rekrutiert ohne Limit */
/* Battle-Flags */ /* Battle-Flags */
#define BF_EQUIPMENT (1<<0) /* Kann Ausrüstung benutzen */ #define BF_EQUIPMENT (1<<0) /* Kann Ausr<EFBFBD>stung benutzen */
#define BF_NOBLOCK (1<<1) /* Wird in die Rückzugsberechnung nicht einbezogen */ #define BF_NOBLOCK (1<<1) /* Wird in die R<EFBFBD>ckzugsberechnung nicht einbezogen */
#define BF_RES_PIERCE (1<<2) /* Halber Schaden durch PIERCE */ #define BF_RES_PIERCE (1<<2) /* Halber Schaden durch PIERCE */
#define BF_RES_CUT (1<<3) /* Halber Schaden durch CUT */ #define BF_RES_CUT (1<<3) /* Halber Schaden durch CUT */
#define BF_RES_BASH (1<<4) /* Halber Schaden durch BASH */ #define BF_RES_BASH (1<<4) /* Halber Schaden durch BASH */
@ -232,10 +232,10 @@ extern "C" {
const char *racename(const struct locale *lang, const struct unit *u, const char *racename(const struct locale *lang, const struct unit *u,
const race * rc); const race * rc);
#define playerrace(rc) (!fval((rc), RCF_NPC)) #define playerrace(rc) (!((rc)->flags & RCF_NPC))
#define dragonrace(rc) (fval(rc, RCF_DRAGON)) #define dragonrace(rc) ((rc)->flags & RCF_DRAGON)
#define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc)) #define humanoidrace(rc) (((rc)->flags & RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc))
#define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY)) #define illusionaryrace(rc) ((rc)->flags & RCF_ILLUSIONARY)
bool allowed_dragon(const struct region *src, bool allowed_dragon(const struct region *src,
const struct region *target); const struct region *target);

View file

@ -134,6 +134,13 @@ const char *regionname(const region * r, const faction * f)
return write_regionname(r, f, buf[index], sizeof(buf[index])); return write_regionname(r, f, buf[index], sizeof(buf[index]));
} }
int region_maxworkers(const region *r)
{
int size = production(r);
int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
return _max(size - treespace, _min(size / 10, 200));
}
int deathcount(const region * r) int deathcount(const region * r)
{ {
attrib *a = a_find(r->attribs, &at_deathcount); attrib *a = a_find(r->attribs, &at_deathcount);
@ -1207,7 +1214,7 @@ void terraform_region(region * r, const terrain_type * terrain)
if (!fval(r, RF_CHAOTIC)) { if (!fval(r, RF_CHAOTIC)) {
int peasants; int peasants;
peasants = (maxworkingpeasants(r) * (20 + dice_rand("6d10"))) / 100; peasants = (region_maxworkers(r) * (20 + dice_rand("6d10"))) / 100;
rsetpeasants(r, _max(100, peasants)); rsetpeasants(r, _max(100, peasants));
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
INT_MAX) + 1) + rng_int() % 5)); INT_MAX) + 1) + rng_int() % 5));

View file

@ -264,6 +264,7 @@ extern "C" {
const char *regionname(const struct region *r, const struct faction *f); const char *regionname(const struct region *r, const struct faction *f);
int region_maxworkers(const struct region *r);
const char *region_getname(const struct region *self); const char *region_getname(const struct region *self);
void region_setname(struct region *self, const char *name); void region_setname(struct region *self, const char *name);
const char *region_getinfo(const struct region *self); const char *region_getinfo(const struct region *self);

View file

@ -1291,7 +1291,7 @@ faction *read_faction(struct gamedata * data)
}; };
f->banner = _strdup(name); f->banner = _strdup(name);
log_debug(" - Lese Partei %s (%s)", f->name, factionid(f)); log_debug(" - Lese Partei %s (%s)", f->name, itoa36(f->no));
READ_STR(data->store, name, sizeof(name)); READ_STR(data->store, name, sizeof(name));
if (set_email(&f->email, name) != 0) { if (set_email(&f->email, name) != 0) {

View file

@ -31,6 +31,8 @@ extern "C" {
struct spellbook; struct spellbook;
struct unit; struct unit;
struct building; struct building;
struct faction;
struct region;
struct ship; struct ship;
struct gamedata; struct gamedata;
@ -38,8 +40,6 @@ extern "C" {
/* Nach MAX_INPUT_SIZE brechen wir das Einlesen der Zeile ab und nehmen an, /* Nach MAX_INPUT_SIZE brechen wir das Einlesen der Zeile ab und nehmen an,
* dass hier ein Fehler (fehlende ") vorliegt */ * dass hier ein Fehler (fehlende ") vorliegt */
extern int data_version;
// TODO: is this *really* still in use? // TODO: is this *really* still in use?
extern int enc_gamedata; extern int enc_gamedata;

View file

@ -201,7 +201,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
sname = parameters[P_SHIP]; sname = parameters[P_SHIP];
} }
assert(sname); assert(sname);
slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh)); slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no));
sh->name = _strdup(buffer); sh->name = _strdup(buffer);
shash(sh); shash(sh);
if (r) { if (r) {

View file

@ -51,8 +51,8 @@ extern "C" {
int minskill; /* min. skill to sail this (crew) */ int minskill; /* min. skill to sail this (crew) */
int sumskill; /* min. sum of crew+captain */ int sumskill; /* min. sum of crew+captain */
int at_bonus; /* Verändert den Angriffsskill (default: 0) */ int at_bonus; /* Ver<EFBFBD>ndert den Angriffsskill (default: 0) */
int df_bonus; /* Verändert den Verteidigungskill (default: 0) */ int df_bonus; /* Ver<EFBFBD>ndert den Verteidigungskill (default: 0) */
float tac_bonus; float tac_bonus;
struct terrain_type ** coasts; /* coast that this ship can land on */ struct terrain_type ** coasts; /* coast that this ship can land on */
@ -70,12 +70,12 @@ extern "C" {
#define NOSHIP NULL #define NOSHIP NULL
#define SF_DRIFTED 1<<0 #define SF_DRIFTED (1<<0)
#define SF_MOVED 1<<1 #define SF_MOVED (1<<1)
#define SF_DAMAGED 1<<2 /* for use in combat */ #define SF_DAMAGED (1<<2) /* for use in combat */
#define SF_SELECT 1<<3 /* previously FL_DH */ #define SF_SELECT (1<<3) /* previously FL_DH */
#define SF_FISHING 1<<4 /* was on an ocean, can fish */ #define SF_FISHING (1<<4) /* was on an ocean, can fish */
#define SF_FLYING 1<<5 /* the ship can fly */ #define SF_FLYING (1<<5) /* the ship can fly */
#define SFL_SAVEMASK (SF_FLYING) #define SFL_SAVEMASK (SF_FLYING)
#define INCOME_FISHING 10 #define INCOME_FISHING 10

View file

@ -19,14 +19,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef ERESSEA_TYPES_H #ifndef ERESSEA_TYPES_H
#define ERESSEA_TYPES_H #define ERESSEA_TYPES_H
/*
* Features enabled:
* If you are lacking the settings.h, create a new file common/settings.h,
* and write #include <settings-config.h> (or whatever settings you want
* your game to use) in there.
* !!! DO NOT COMMIT THE SETTINGS.H FILE TO CVS !!!
* settings.h should always be the first thing you include (after platform.h).
*/
#include <settings.h> #include <settings.h>
#include <util/variant.h> #include <util/variant.h>

View file

@ -494,6 +494,10 @@ attrib_type at_alias = {
NO_READ NO_READ
}; };
/** remember old unit.no (for the creport, mostly)
* if alias is positive, then this unit was a TEMP
* if alias is negative, then this unit has been RENUMBERed
*/
int ualias(const unit * u) int ualias(const unit * u)
{ {
attrib *a = a_find(u->attribs, &at_alias); attrib *a = a_find(u->attribs, &at_alias);
@ -1716,7 +1720,7 @@ void renumber_unit(unit *u, int no) {
uunhash(u); uunhash(u);
if (!ualias(u)) { if (!ualias(u)) {
attrib *a = a_add(&u->attribs, a_new(&at_alias)); attrib *a = a_add(&u->attribs, a_new(&at_alias));
a->data.i = -u->no; // TODO: why is the alias negative? confusing! a->data.i = -u->no;
} }
u->no = no; u->no = no;
uhash(u); uhash(u);

View file

@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "monster.h" #include "monster.h"
#include "move.h" #include "move.h"
#include "randenc.h" #include "randenc.h"
#include "renumber.h"
#include "spy.h" #include "spy.h"
#include "study.h" #include "study.h"
#include "wormhole.h" #include "wormhole.h"
@ -116,6 +117,32 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* - exported global symbols ----------------------------------- */ /* - exported global symbols ----------------------------------- */
int NewbieImmunity(void)
{
return config_get_int("NewbieImmunity", 0);
}
bool IsImmune(const faction * f)
{
return !fval(f, FFL_NPC) && f->age < NewbieImmunity();
}
int NMRTimeout(void)
{
return config_get_int("nmr.timeout", 0);
}
bool LongHunger(const struct unit *u)
{
if (u != NULL) {
if (!fval(u, UFL_HUNGER))
return false;
if (u_race(u) == get_race(RC_DAEMON))
return false;
}
return config_get_int("hunger.long", 0) != 0;
}
static bool RemoveNMRNewbie(void) static bool RemoveNMRNewbie(void)
{ {
int value = config_get_int("nmr.removenewbie", 0); int value = config_get_int("nmr.removenewbie", 0);
@ -221,7 +248,7 @@ static void live(region * r)
static void calculate_emigration(region * r) static void calculate_emigration(region * r)
{ {
int i; int i;
int maxp = maxworkingpeasants(r); int maxp = region_maxworkers(r);
int rp = rpeasants(r); int rp = rpeasants(r);
int max_immigrants = MAX_IMMIGRATION(maxp - rp); int max_immigrants = MAX_IMMIGRATION(maxp - rp);
@ -236,7 +263,7 @@ static void calculate_emigration(region * r)
if (rc != NULL && fval(rc->terrain, LAND_REGION)) { if (rc != NULL && fval(rc->terrain, LAND_REGION)) {
int rp2 = rpeasants(rc); int rp2 = rpeasants(rc);
int maxp2 = maxworkingpeasants(rc); int maxp2 = region_maxworkers(rc);
int max_emigration = MAX_EMIGRATION(rp2 - maxp2); int max_emigration = MAX_EMIGRATION(rp2 - maxp2);
if (max_emigration > 0) { if (max_emigration > 0) {
@ -419,7 +446,7 @@ static void horses(region * r)
direction_t n; direction_t n;
/* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */ /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */
maxhorses = maxworkingpeasants(r) / 10; maxhorses = region_maxworkers(r) / 10;
maxhorses = _max(0, maxhorses); maxhorses = _max(0, maxhorses);
horses = rhorses(r); horses = rhorses(r);
if (horses > 0) { if (horses > 0) {
@ -621,7 +648,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
* verfügbaren Fläche ab. In Gletschern gibt es weniger * verfügbaren Fläche ab. In Gletschern gibt es weniger
* Möglichkeiten als in Ebenen. */ * Möglichkeiten als in Ebenen. */
sprout = 0; sprout = 0;
seedchance = (1000 * maxworkingpeasants(r2)) / r2->terrain->size; seedchance = (1000 * region_maxworkers(r2)) / r2->terrain->size;
for (i = 0; i < seeds / MAXDIRECTIONS; i++) { for (i = 0; i < seeds / MAXDIRECTIONS; i++) {
if (rng_int() % 10000 < seedchance) if (rng_int() % 10000 < seedchance)
sprout++; sprout++;
@ -720,7 +747,7 @@ void immigration(void)
if (repopulate) { if (repopulate) {
int peasants = rpeasants(r); int peasants = rpeasants(r);
int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL) + 1; int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL) + 1;
if (income >= 0 && r->land && (peasants < repopulate) && maxworkingpeasants(r) >(peasants + 30) * 2) { if (income >= 0 && r->land && (peasants < repopulate) && region_maxworkers(r) >(peasants + 30) * 2) {
int badunit = 0; int badunit = 0;
unit *u; unit *u;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
@ -816,7 +843,7 @@ void demographics(void)
calculate_emigration(r); calculate_emigration(r);
peasants(r); peasants(r);
if (r->age > 20) { if (r->age > 20) {
double mwp = _max(maxworkingpeasants(r), 1); double mwp = _max(region_maxworkers(r), 1);
double prob = double prob =
pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0) pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0)
* PLAGUE_CHANCE; * PLAGUE_CHANCE;
@ -970,7 +997,7 @@ int quit_cmd(unit * u, struct order *ord)
char buffer[64]; char buffer[64];
write_order(ord, buffer, sizeof(buffer)); write_order(ord, buffer, sizeof(buffer));
cmistake(u, ord, 86, MSG_EVENT); cmistake(u, ord, 86, MSG_EVENT);
log_warning("QUIT with illegal password for faction %s: %s\n", factionid(f), buffer); log_warning("QUIT with illegal password for faction %s: %s\n", itoa36(f->no), buffer);
} }
return 0; return 0;
} }
@ -2742,74 +2769,6 @@ void sinkships(struct region * r)
} }
} }
static attrib_type at_number = {
"faction_renum",
NULL, NULL, NULL, NULL, NULL, NULL,
ATF_UNIQUE
};
void renumber_factions(void)
/* gibt parteien neue nummern */
{
struct renum {
struct renum *next;
int want;
faction *faction;
attrib *attrib;
} *renum = NULL, *rp;
faction *f;
for (f = factions; f; f = f->next) {
attrib *a = a_find(f->attribs, &at_number);
int want;
struct renum **rn;
faction *old;
if (!a)
continue;
want = a->data.i;
if (fval(f, FFL_NEWID)) {
ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want));
continue;
}
old = findfaction(want);
if (old) {
a_remove(&f->attribs, a);
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
continue;
}
if (!faction_id_is_unused(want)) {
a_remove(&f->attribs, a);
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
continue;
}
for (rn = &renum; *rn; rn = &(*rn)->next) {
if ((*rn)->want >= want)
break;
}
if (*rn && (*rn)->want == want) {
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
}
else {
struct renum *r = calloc(sizeof(struct renum), 1);
r->next = *rn;
r->attrib = a;
r->faction = f;
r->want = want;
*rn = r;
}
}
for (rp = renum; rp; rp = rp->next) {
f = rp->faction;
a_remove(&f->attribs, rp->attrib);
renumber_faction(f, rp->want);
}
while (renum) {
rp = renum->next;
free(renum);
renum = rp;
}
}
void restack_units(void) void restack_units(void)
{ {
region *r; region *r;
@ -2897,118 +2856,6 @@ void restack_units(void)
} }
} }
int renumber_cmd(unit * u, order * ord)
{
char token[128];
const char *s;
int i = 0;
faction *f = u->faction;
init_order(ord);
s = gettoken(token, sizeof(token));
switch (findparam_ex(s, u->faction->locale)) {
case P_FACTION:
s = gettoken(token, sizeof(token));
if (s && *s) {
int id = atoi36((const char *)s);
attrib *a = a_find(f->attribs, &at_number);
if (!a)
a = a_add(&f->attribs, a_new(&at_number));
a->data.i = id;
}
break;
case P_UNIT:
s = gettoken(token, sizeof(token));
if (s && *s) {
i = atoi36((const char *)s);
if (i <= 0 || i > MAX_UNIT_NR) {
cmistake(u, ord, 114, MSG_EVENT);
break;
}
if (forbiddenid(i)) {
cmistake(u, ord, 116, MSG_EVENT);
break;
}
if (findunitg(i, u->region)) {
cmistake(u, ord, 115, MSG_EVENT);
break;
}
}
renumber_unit(u, i);
break;
case P_SHIP:
if (!u->ship) {
cmistake(u, ord, 144, MSG_EVENT);
break;
}
if (ship_owner(u->ship) != u) {
cmistake(u, ord, 146, MSG_EVENT);
break;
}
if (u->ship->coast != NODIRECTION) {
cmistake(u, ord, 116, MSG_EVENT);
break;
}
s = gettoken(token, sizeof(token));
if (s == NULL || *s == 0) {
i = newcontainerid();
}
else {
i = atoi36((const char *)s);
if (i <= 0 || i > MAX_CONTAINER_NR) {
cmistake(u, ord, 114, MSG_EVENT);
break;
}
if (findship(i) || findbuilding(i)) {
cmistake(u, ord, 115, MSG_EVENT);
break;
}
}
sunhash(u->ship);
u->ship->no = i;
shash(u->ship);
break;
case P_BUILDING:
case P_GEBAEUDE:
if (!u->building) {
cmistake(u, ord, 145, MSG_EVENT);
break;
}
if (building_owner(u->building) != u) {
cmistake(u, ord, 148, MSG_EVENT);
break;
}
s = gettoken(token, sizeof(token));
if (*s == 0) {
i = newcontainerid();
}
else {
i = atoi36((const char *)s);
if (i <= 0 || i > MAX_CONTAINER_NR) {
cmistake(u, ord, 114, MSG_EVENT);
break;
}
if (findship(i) || findbuilding(i)) {
cmistake(u, ord, 115, MSG_EVENT);
break;
}
}
bunhash(u->building);
u->building->no = i;
bhash(u->building);
break;
default:
cmistake(u, ord, 239, MSG_EVENT);
}
return 0;
}
/* blesses stone circles create an astral protection in the astral region /* blesses stone circles create an astral protection in the astral region
* above the shield, which prevents chaos suction and other spells. * above the shield, which prevents chaos suction and other spells.
* The shield is created when a magician enters the blessed stone circle, * The shield is created when a magician enters the blessed stone circle,
@ -3693,7 +3540,7 @@ int use_cmd(unit * u, struct order *ord)
cmistake(u, ord, 43, MSG_PRODUCE); cmistake(u, ord, 43, MSG_PRODUCE);
return err; return err;
} }
n = atoi((const char *)t); n = atoip((const char *)t);
if (n == 0) { if (n == 0) {
if (isparam(t, u->faction->locale, P_ANY)) { if (isparam(t, u->faction->locale, P_ANY)) {
/* BENUTZE ALLES Yanxspirit */ /* BENUTZE ALLES Yanxspirit */
@ -3841,7 +3688,7 @@ int claim_cmd(unit * u, struct order *ord)
t = gettoken(token, sizeof(token)); t = gettoken(token, sizeof(token));
if (t) { if (t) {
n = atoi((const char *)t); n = atoip((const char *)t);
if (n == 0) { if (n == 0) {
n = 1; n = 1;
} }

View file

@ -59,7 +59,6 @@ extern "C" {
void defaultorders(void); void defaultorders(void);
void quit(void); void quit(void);
void monthly_healing(void); void monthly_healing(void);
void renumber_factions(void);
void restack_units(void); void restack_units(void);
void update_long_order(struct unit *u); void update_long_order(struct unit *u);
void sinkships(struct region * r); void sinkships(struct region * r);
@ -83,7 +82,6 @@ extern "C" {
int leave_cmd(struct unit *u, struct order *ord); int leave_cmd(struct unit *u, struct order *ord);
int pay_cmd(struct unit *u, struct order *ord); int pay_cmd(struct unit *u, struct order *ord);
int promotion_cmd(struct unit *u, struct order *ord); int promotion_cmd(struct unit *u, struct order *ord);
int renumber_cmd(struct unit *u, struct order *ord);
int combatspell_cmd(struct unit *u, struct order *ord); int combatspell_cmd(struct unit *u, struct order *ord);
int contact_cmd(struct unit *u, struct order *ord); int contact_cmd(struct unit *u, struct order *ord);
int guard_on_cmd(struct unit *u, struct order *ord); int guard_on_cmd(struct unit *u, struct order *ord);
@ -110,6 +108,10 @@ extern "C" {
#define FORCE_LEAVE_POSTCOMBAT 1 #define FORCE_LEAVE_POSTCOMBAT 1
#define FORCE_LEAVE_ALL 2 #define FORCE_LEAVE_ALL 2
bool rule_force_leave(int flag); bool rule_force_leave(int flag);
bool LongHunger(const struct unit *u);
int NMRTimeout(void);
int NewbieImmunity(void);
bool IsImmune(const struct faction *f);
bool help_enter(struct unit *uo, struct unit *u); bool help_enter(struct unit *uo, struct unit *u);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -88,7 +88,6 @@ list_selection *do_selection(list_selection * sel, const char *title,
width = (int)strlen(s->str); width = (int)strlen(s->str);
} }
++height; ++height;
log_debug("s %s w %d h %d\n", s->str, width, height);
} }
if (height == 0 || width == 0) if (height == 0 || width == 0)
return 0; return 0;
@ -97,8 +96,6 @@ list_selection *do_selection(list_selection * sel, const char *title,
if (height + 2 > SY) if (height + 2 > SY)
height = SY - 2; height = SY - 2;
log_debug("w %d h %d\n", width, height);
wn = wn =
newwin(height + 2, width + 4, (SY - height - 2) / 2, (SX - width - 4) / 2); newwin(height + 2, width + 4, (SY - height - 2) / 2, (SX - width - 4) / 2);

View file

@ -347,7 +347,7 @@ attrib_type at_mage = {
bool is_mage(const unit * u) bool is_mage(const unit * u)
{ {
return i2b(get_mage(u) != NULL); return get_mage(u) != NULL;
} }
sc_mage *get_mage(const unit * u) sc_mage *get_mage(const unit * u)
@ -376,7 +376,7 @@ static int read_seenspell(attrib * a, void *owner, struct gamedata *data)
char token[32]; char token[32];
READ_TOK(store, token, sizeof(token)); READ_TOK(store, token, sizeof(token));
i = atoi(token); i = atoip(token);
if (i != 0) { if (i != 0) {
sp = find_spellbyid((unsigned int)i); sp = find_spellbyid((unsigned int)i);
} }
@ -2167,7 +2167,7 @@ typedef struct familiar_data {
bool is_familiar(const unit * u) bool is_familiar(const unit * u)
{ {
attrib *a = a_find(u->attribs, &at_familiarmage); attrib *a = a_find(u->attribs, &at_familiarmage);
return i2b(a != NULL); return a != NULL;
} }
static void static void

View file

@ -25,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/filereader.h> #include <util/filereader.h>
#include <util/language.h> #include <util/language.h>
#include "eressea.h" #include "eressea.h"
#include "battle.h"
#ifdef USE_CURSES #ifdef USE_CURSES
#include "gmtool.h" #include "gmtool.h"
#endif #endif

View file

@ -85,6 +85,11 @@ static int rc_herb_trade(const struct race *rc)
#define MAX_MARKETS 128 #define MAX_MARKETS 128
#define MIN_PEASANTS 50 /* if there are at least this many peasants, you will get 1 good */ #define MIN_PEASANTS 50 /* if there are at least this many peasants, you will get 1 good */
bool markets_module(void)
{
return (bool)config_get_int("modules.markets", 0);
}
void do_markets(void) void do_markets(void)
{ {
quicklist *traders = 0; quicklist *traders = 0;

View file

@ -17,7 +17,8 @@ extern "C" {
#endif #endif
struct building; struct building;
extern void do_markets(void); bool markets_module(void);
void do_markets(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -14,6 +14,8 @@
#include <kernel/config.h> #include <kernel/config.h>
#include "autoseed.h" #include "autoseed.h"
#include "market.h"
/* kernel includes */ /* kernel includes */
#include <kernel/alliance.h> #include <kernel/alliance.h>
#include <kernel/item.h> #include <kernel/item.h>

View file

@ -169,7 +169,7 @@ void score(void)
fprintf(scoreFP, "%30.30s (%3.3s) %5s (%3d)\n", fprintf(scoreFP, "%30.30s (%3.3s) %5s (%3d)\n",
f->name, f->name,
f->race->_name, f->race->_name,
factionid(f), itoa36(f->no),
f->age); f->age);
} }
fclose(scoreFP); fclose(scoreFP);

View file

@ -31,7 +31,7 @@ extern "C" {
void make_zombie(struct unit * u); void make_zombie(struct unit * u);
#define MONSTER_ID 666 #define MONSTER_ID 666
#define is_monsters(f) (fval(f, FFL_NPC) && f==get_monsters()) #define is_monsters(f) ((f->flags & FFL_NPC) && f==get_monsters())
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -25,7 +25,6 @@ module eressea {
void process_leave @ leave(void); /* LEAVE */ void process_leave @ leave(void); /* LEAVE */
void process_maintenance @ maintenance(void); /* PAY */ void process_maintenance @ maintenance(void); /* PAY */
void process_promote @ promote(void); /* PROMOTE */ void process_promote @ promote(void); /* PROMOTE */
void process_renumber @ renumber(void); /* RENUMBER */
void process_restack @ restack(void); /* SORT */ void process_restack @ restack(void); /* SORT */
void process_setspells @ set_spells(void); /* COMBATSPELL */ void process_setspells @ set_spells(void); /* COMBATSPELL */
void process_sethelp @ set_help(void); /* HELP */ void process_sethelp @ set_help(void); /* HELP */

View file

@ -531,30 +531,6 @@ static int tolua_process_eressea_process_promote00(lua_State* tolua_S)
#endif #endif
} }
/* function: process_renumber */
static int tolua_process_eressea_process_renumber00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isnoobj(tolua_S,1,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
{
process_renumber();
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'renumber'.",&tolua_err);
return 0;
#endif
}
/* function: process_restack */ /* function: process_restack */
static int tolua_process_eressea_process_restack00(lua_State* tolua_S) static int tolua_process_eressea_process_restack00(lua_State* tolua_S)
{ {
@ -1021,7 +997,6 @@ LUALIB_API int luaopen_process (lua_State* tolua_S)
tolua_function(tolua_S,"leave",tolua_process_eressea_process_leave00); tolua_function(tolua_S,"leave",tolua_process_eressea_process_leave00);
tolua_function(tolua_S,"maintenance",tolua_process_eressea_process_maintenance00); tolua_function(tolua_S,"maintenance",tolua_process_eressea_process_maintenance00);
tolua_function(tolua_S,"promote",tolua_process_eressea_process_promote00); tolua_function(tolua_S,"promote",tolua_process_eressea_process_promote00);
tolua_function(tolua_S,"renumber",tolua_process_eressea_process_renumber00);
tolua_function(tolua_S,"restack",tolua_process_eressea_process_restack00); tolua_function(tolua_S,"restack",tolua_process_eressea_process_restack00);
tolua_function(tolua_S,"set_spells",tolua_process_eressea_process_set_spells00); tolua_function(tolua_S,"set_spells",tolua_process_eressea_process_set_spells00);
tolua_function(tolua_S,"set_help",tolua_process_eressea_process_set_help00); tolua_function(tolua_S,"set_help",tolua_process_eressea_process_set_help00);

View file

@ -13,7 +13,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
/* kernel includes */ /* kernel includes */
#include <kernel/race.h> #include <kernel/race.h>

View file

@ -11,7 +11,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
/* kernel includes */ /* kernel includes */
#include <kernel/race.h> #include <kernel/race.h>

View file

@ -9,7 +9,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "races.h" #include "races.h"
#include <kernel/building.h> #include <kernel/building.h>

View file

@ -14,6 +14,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct unit;
void register_races(void); void register_races(void);
void make_undead_unit(struct unit *); void make_undead_unit(struct unit *);

View file

@ -13,7 +13,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
/* kernel includes */ /* kernel includes */
#include <kernel/race.h> #include <kernel/race.h>
@ -40,7 +39,7 @@ void make_undead_unit(unit * u)
{ {
free_orders(&u->orders); free_orders(&u->orders);
name_unit(u); name_unit(u);
fset(u, UFL_ISNEW); u->flags |= UFL_ISNEW;
} }
void age_undead(unit * u) void age_undead(unit * u)

191
src/renumber.c Normal file
View file

@ -0,0 +1,191 @@
#include <platform.h>
#include "renumber.h"
#include <kernel/config.h>
#include <kernel/faction.h>
#include <kernel/building.h>
#include <kernel/ship.h>
#include <kernel/unit.h>
#include <kernel/order.h>
#include <kernel/messages.h>
#include <util/attrib.h>
#include <util/base36.h>
#include <util/parser.h>
#include <assert.h>
#include <stdlib.h>
static attrib_type at_number = {
"faction_renum",
NULL, NULL, NULL, NULL, NULL, NULL,
ATF_UNIQUE
};
void renumber_factions(void)
/* gibt parteien neue nummern */
{
struct renum {
struct renum *next;
int want;
faction *faction;
attrib *attrib;
} *renum = NULL, *rp;
faction *f;
for (f = factions; f; f = f->next) {
attrib *a = a_find(f->attribs, &at_number);
int want;
struct renum **rn;
if (!a)
continue;
want = a->data.i;
if (fval(f, FFL_NEWID)) {
ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want));
continue;
}
if (!faction_id_is_unused(want)) {
a_remove(&f->attribs, a);
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
continue;
}
for (rn = &renum; *rn; rn = &(*rn)->next) {
if ((*rn)->want >= want)
break;
}
if (*rn && (*rn)->want == want) {
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
}
else {
struct renum *r = calloc(sizeof(struct renum), 1);
r->next = *rn;
r->attrib = a;
r->faction = f;
r->want = want;
*rn = r;
}
}
for (rp = renum; rp; rp = rp->next) {
f = rp->faction;
a_remove(&f->attribs, rp->attrib);
renumber_faction(f, rp->want);
}
while (renum) {
rp = renum->next;
free(renum);
renum = rp;
}
}
int renumber_cmd(unit * u, order * ord)
{
char token[128];
const char *s;
int i = 0;
faction *f = u->faction;
init_order(ord);
s = gettoken(token, sizeof(token));
switch (findparam_ex(s, u->faction->locale)) {
case P_FACTION:
s = gettoken(token, sizeof(token));
if (s && *s) {
int id = atoi36((const char *)s);
attrib *a = a_find(f->attribs, &at_number);
if (!a)
a = a_add(&f->attribs, a_new(&at_number));
a->data.i = id;
}
break;
case P_UNIT:
s = gettoken(token, sizeof(token));
if (s && *s) {
i = atoi36((const char *)s);
if (i <= 0 || i > MAX_UNIT_NR) {
cmistake(u, ord, 114, MSG_EVENT);
break;
}
if (forbiddenid(i)) {
cmistake(u, ord, 116, MSG_EVENT);
break;
}
if (findunitg(i, u->region)) {
cmistake(u, ord, 115, MSG_EVENT);
break;
}
}
renumber_unit(u, i);
break;
case P_SHIP:
if (!u->ship) {
cmistake(u, ord, 144, MSG_EVENT);
break;
}
if (ship_owner(u->ship) != u) {
cmistake(u, ord, 146, MSG_EVENT);
break;
}
if (u->ship->coast != NODIRECTION) {
cmistake(u, ord, 116, MSG_EVENT);
break;
}
s = gettoken(token, sizeof(token));
if (s == NULL || *s == 0) {
i = newcontainerid();
}
else {
i = atoi36((const char *)s);
if (i <= 0 || i > MAX_CONTAINER_NR) {
cmistake(u, ord, 114, MSG_EVENT);
break;
}
if (findship(i)) {
cmistake(u, ord, 115, MSG_EVENT);
break;
}
}
sunhash(u->ship);
u->ship->no = i;
shash(u->ship);
break;
case P_BUILDING:
case P_GEBAEUDE:
if (!u->building) {
cmistake(u, ord, 145, MSG_EVENT);
break;
}
if (building_owner(u->building) != u) {
cmistake(u, ord, 148, MSG_EVENT);
break;
}
s = gettoken(token, sizeof(token));
if (*s == 0) {
i = newcontainerid();
}
else {
i = atoi36((const char *)s);
if (i <= 0 || i > MAX_CONTAINER_NR) {
cmistake(u, ord, 114, MSG_EVENT);
break;
}
if (findbuilding(i)) {
cmistake(u, ord, 115, MSG_EVENT);
break;
}
}
bunhash(u->building);
u->building->no = i;
bhash(u->building);
break;
default:
cmistake(u, ord, 239, MSG_EVENT);
}
return 0;
}

12
src/renumber.h Normal file
View file

@ -0,0 +1,12 @@
#pragma once
#ifndef H_RENUMBER
#define H_RENUMBER
struct unit;
struct order;
void renumber_factions(void);
int renumber_cmd(struct unit *u, struct order *ord);
#endif

233
src/renumber.test.c Normal file
View file

@ -0,0 +1,233 @@
#include "renumber.h"
#include <tests.h>
#include <kernel/unit.h>
#include <kernel/faction.h>
#include <kernel/building.h>
#include <kernel/ship.h>
#include <kernel/order.h>
#include <util/base36.h>
#include <util/language.h>
#include <stddef.h>
#include <CuTest.h>
static void test_renumber_faction(CuTest *tc) {
unit *u;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
no = u->faction->no;
uno = (no > 1) ? no - 1 : no + 1;
lang = u->faction->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(uno));
renumber_cmd(u, u->thisorder);
renumber_factions();
CuAssertIntEquals(tc, uno, u->faction->no);
test_cleanup();
}
static void test_renumber_faction_duplicate(CuTest *tc) {
unit *u;
faction *f, *f2;
int no;
const struct locale *lang;
test_setup_ex(tc);
f2 = test_create_faction(0);
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
no = f->no;
lang = f->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(f2->no));
renumber_cmd(u, u->thisorder);
renumber_factions();
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "renumber_inuse"));
CuAssertIntEquals(tc, no, u->faction->no);
test_cleanup();
}
static void test_renumber_building(CuTest *tc) {
unit *u;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
u->building = test_create_building(u->region, 0);
no = u->building->no;
uno = (no > 1) ? no - 1 : no + 1;
lang = u->faction->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, uno, u->building->no);
test_cleanup();
}
static void test_renumber_building_duplicate(CuTest *tc) {
unit *u;
faction *f;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
u->building = test_create_building(u->region, 0);
uno = u->building->no;
u->building = test_create_building(u->region, 0);
no = u->building->no;
lang = f->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
CuAssertIntEquals(tc, no, u->building->no);
test_cleanup();
}
static void test_renumber_ship(CuTest *tc) {
unit *u;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
u->ship = test_create_ship(u->region, 0);
no = u->ship->no;
uno = (no > 1) ? no - 1 : no + 1;
lang = u->faction->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, uno, u->ship->no);
test_cleanup();
}
static void test_renumber_ship_twice(CuTest *tc) {
unit *u;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
u->ship = test_create_ship(u->region, 0);
no = u->ship->no;
uno = (no > 1) ? no - 1 : no + 1;
lang = u->faction->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, uno, u->ship->no);
free_order(u->thisorder);
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(no));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, no, u->ship->no);
test_cleanup();
}
static void test_renumber_ship_duplicate(CuTest *tc) {
unit *u;
faction *f;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
u->ship = test_create_ship(u->region, 0);
uno = u->ship->no;
u->ship = test_create_ship(u->region, 0);
no = u->ship->no;
lang = f->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
CuAssertIntEquals(tc, no, u->ship->no);
test_cleanup();
}
static void test_renumber_unit(CuTest *tc) {
unit *u;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
no = u->no;
uno = (no > 1) ? no - 1 : no + 1;
lang = u->faction->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, uno, u->no);
CuAssertIntEquals(tc, -no, ualias(u));
test_cleanup();
}
static void test_renumber_unit_duplicate(CuTest *tc) {
unit *u, *u2;
faction *f;
int no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
no = u->no;
u2 = test_create_unit(f, u->region);
lang = f->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(u2->no));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, no, u->no);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
CuAssertIntEquals(tc, 0, ualias(u));
test_cleanup();
}
static void test_renumber_unit_limit(CuTest *tc) {
unit *u;
faction *f;
int no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
no = u->no;
lang = f->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s 10000", LOC(lang, parameters[P_UNIT]));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, no, u->no);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error114"));
CuAssertIntEquals(tc, 0, ualias(u));
test_cleanup();
}
static void test_renumber_unit_invalid(CuTest *tc) {
unit *u;
faction *f;
int no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
no = u->no;
lang = f->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s TEMP", LOC(lang, parameters[P_UNIT]));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, no, u->no);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error116"));
CuAssertIntEquals(tc, 0, ualias(u));
test_cleanup();
}
CuSuite *get_renumber_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_renumber_unit);
SUITE_ADD_TEST(suite, test_renumber_unit_limit);
SUITE_ADD_TEST(suite, test_renumber_unit_duplicate);
SUITE_ADD_TEST(suite, test_renumber_unit_invalid);
SUITE_ADD_TEST(suite, test_renumber_building);
SUITE_ADD_TEST(suite, test_renumber_building_duplicate);
SUITE_ADD_TEST(suite, test_renumber_ship);
SUITE_ADD_TEST(suite, test_renumber_ship_twice);
SUITE_ADD_TEST(suite, test_renumber_ship_duplicate);
SUITE_ADD_TEST(suite, test_renumber_faction);
SUITE_ADD_TEST(suite, test_renumber_faction_duplicate);
return suite;
}

View file

@ -25,8 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "reports.h" #include "reports.h"
#include "guard.h" #include "guard.h"
#include "laws.h" #include "laws.h"
#include "travelthru.h" #include "market.h"
#include "monster.h" #include "monster.h"
#include "travelthru.h"
/* modules includes */ /* modules includes */
#include <modules/score.h> #include <modules/score.h>
@ -1405,7 +1406,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
newline(out); newline(out);
newline(out); newline(out);
sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), factionid(f)); sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), itoa36(f->no));
rps_nowrap(out, buf); rps_nowrap(out, buf);
newline(out); newline(out);
newline(out); newline(out);
@ -1452,7 +1453,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
size = sizeof(buf) - 1; size = sizeof(buf) - 1;
bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$", bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$",
LOC(u->faction->locale, parameters[P_UNIT]), LOC(u->faction->locale, parameters[P_UNIT]),
unitid(u), unit_getname(u), u->number, get_money(u)); itoa36(u->no), unit_getname(u), u->number, get_money(u));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
if (u->building && building_owner(u->building) == u) { if (u->building && building_owner(u->building) == u) {
@ -1478,7 +1479,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
} }
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, shipid(u->ship), size); bytes = (int)strlcpy(bufp, itoa36(u->ship->no), size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }

View file

@ -105,6 +105,22 @@ const char *coasts[MAXDIRECTIONS] = {
"coast::w" "coast::w"
}; };
const char *options[MAXOPTIONS] = {
"AUSWERTUNG",
"COMPUTER",
"ZUGVORLAGE",
NULL,
"STATISTIK",
"DEBUG",
"ZIPPED",
"ZEITUNG", /* Option hat Sonderbehandlung! */
NULL,
"ADRESSEN",
"BZIP2",
"PUNKTE",
"SHOWSKCHANGE"
};
bool omniscient(const faction *f) bool omniscient(const faction *f)
{ {
static const race *rc_template, *rc_illusion; static const race *rc_template, *rc_illusion;
@ -124,7 +140,7 @@ static char *groupid(const struct group *g, const struct faction *f)
static name idbuf[8]; static name idbuf[8];
static int nextbuf = 0; static int nextbuf = 0;
char *buf = idbuf[(++nextbuf) % 8]; char *buf = idbuf[(++nextbuf) % 8];
sprintf(buf, "%s (%s)", g->name, factionid(f)); sprintf(buf, "%s (%s)", g->name, itoa36(f->no));
return buf; return buf;
} }
@ -1402,7 +1418,7 @@ int write_reports(faction * f, time_t ltime)
do { do {
char filename[32]; char filename[32];
char path[MAX_PATH]; char path[MAX_PATH];
sprintf(filename, "%d-%s.%s", turn, factionid(f), sprintf(filename, "%d-%s.%s", turn, itoa36(f->no),
rtype->extension); rtype->extension);
join_path(reportpath(), filename, path, sizeof(path)); join_path(reportpath(), filename, path, sizeof(path));
errno = 0; errno = 0;
@ -1425,7 +1441,7 @@ int write_reports(faction * f, time_t ltime)
} }
} }
if (!gotit) { if (!gotit) {
log_warning("No report for faction %s!", factionid(f)); log_warning("No report for faction %s!", itoa36(f->no));
} }
finish_reports(&ctx); finish_reports(&ctx);
return 0; return 0;
@ -1436,7 +1452,7 @@ static void write_script(FILE * F, const faction * f)
report_type *rtype; report_type *rtype;
char buf[1024]; char buf[1024];
fprintf(F, "faction=%s:email=%s:lang=%s", factionid(f), f->email, fprintf(F, "faction=%s:email=%s:lang=%s", itoa36(f->no), f->email,
locale_name(f->locale)); locale_name(f->locale));
if (f->options & (1 << O_BZIP2)) if (f->options & (1 << O_BZIP2))
fputs(":compression=bz2", F); fputs(":compression=bz2", F);

View file

@ -43,6 +43,7 @@ extern "C" {
extern bool nocr; extern bool nocr;
extern bool noreports; extern bool noreports;
extern const char *visibility[]; extern const char *visibility[];
extern const char *options[MAXOPTIONS]; /* report options */
void reports_done(void); void reports_done(void);

View file

@ -107,10 +107,6 @@
static double zero_effect = 0.0; static double zero_effect = 0.0;
attrib_type at_wdwpyramid = {
"wdwpyramid", NULL, NULL, NULL, NULL, NULL
};
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static void report_spell(unit * mage, region * r, message * msg) static void report_spell(unit * mage, region * r, message * msg)
@ -450,7 +446,7 @@ report_effect(region * r, unit * mage, message * seen, message * unseen)
* Vertrauten sehen, und durch den Vertrauten zaubern, allerdings nur * Vertrauten sehen, und durch den Vertrauten zaubern, allerdings nur
* mit seiner halben Stufe. Je nach Vertrautem erhaelt der Magier * mit seiner halben Stufe. Je nach Vertrautem erhaelt der Magier
* evtl diverse Skillmodifikationen. Der Typ des Vertrauten ist * evtl diverse Skillmodifikationen. Der Typ des Vertrauten ist
* zufaellig bestimmt, wird aber durch Magiegebiet und Rasse beeinflußt. * zufaellig bestimmt, wird aber durch Magiegebiet und Rasse beeinflu<EFBFBD>t.
* "Tierische" Vertraute brauchen keinen Unterhalt. * "Tierische" Vertraute brauchen keinen Unterhalt.
* *
* Ein paar Moeglichkeiten: * Ein paar Moeglichkeiten:
@ -1603,7 +1599,7 @@ static int sp_create_stonegolem(castorder * co)
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Name: Große Duerre /* Name: Gro<EFBFBD>e Duerre
* Stufe: 17 * Stufe: 17
* Kategorie: Region, negativ * Kategorie: Region, negativ
* Gebiet: Gwyrrd * Gebiet: Gwyrrd
@ -1911,7 +1907,7 @@ static int sp_treewalkexit(castorder * co)
return 0; return 0;
} }
/* Koordinaten setzen und Region loeschen fuer Überpruefung auf /* Koordinaten setzen und Region loeschen fuer <EFBFBD>berpruefung auf
* Gueltigkeit */ * Gueltigkeit */
rt = pa->param[0]->data.r; rt = pa->param[0]->data.r;
tax = rt->x; tax = rt->x;
@ -2198,7 +2194,7 @@ static int sp_ironkeeper(castorder * co)
setstatus(keeper, ST_AVOID); /* kaempft nicht */ setstatus(keeper, ST_AVOID); /* kaempft nicht */
setguard(keeper, true); setguard(keeper, true);
fset(keeper, UFL_ISNEW); fset(keeper, UFL_ISNEW);
/* Parteitarnen, damit man nicht sofort weiß, wer dahinter steckt */ /* Parteitarnen, damit man nicht sofort wei<EFBFBD>, wer dahinter steckt */
if (rule_stealth_anon()) { if (rule_stealth_anon()) {
fset(keeper, UFL_ANON_FACTION); fset(keeper, UFL_ANON_FACTION);
} }
@ -2576,7 +2572,7 @@ void patzer_fumblecurse(const castorder * co)
* *
* Wirkung: * Wirkung:
* In einer Wueste, Sumpf oder Gletscher gezaubert kann innerhalb der * In einer Wueste, Sumpf oder Gletscher gezaubert kann innerhalb der
* naechsten 6 Runden ein bis 6 Dracheneinheiten bis Groeße Wyrm * naechsten 6 Runden ein bis 6 Dracheneinheiten bis Groe<EFBFBD>e Wyrm
* entstehen. * entstehen.
* *
* Mit Stufe 12-15 erscheinen Jung- oder normaler Drachen, mit Stufe * Mit Stufe 12-15 erscheinen Jung- oder normaler Drachen, mit Stufe
@ -2821,7 +2817,7 @@ static int change_hitpoints(unit * u, int value)
hp += value; hp += value;
/* Jede Person benötigt mindestens 1 HP */ /* Jede Person ben<EFBFBD>tigt mindestens 1 HP */
if (hp < u->number) { if (hp < u->number) {
if (hp < 0) { /* Einheit tot */ if (hp < 0) { /* Einheit tot */
hp = 0; hp = 0;
@ -3768,7 +3764,7 @@ static int sp_rallypeasantmob(castorder * co)
* Gebiet: Cerddor * Gebiet: Cerddor
* Wirkung: * Wirkung:
* Wiegelt 60% bis 90% der Bauern einer Region auf. Bauern werden ein * Wiegelt 60% bis 90% der Bauern einer Region auf. Bauern werden ein
* großer Mob, der zur Monsterpartei gehoert und die Region bewacht. * gro<EFBFBD>er Mob, der zur Monsterpartei gehoert und die Region bewacht.
* Regionssilber sollte auch nicht durch Unterhaltung gewonnen werden * Regionssilber sollte auch nicht durch Unterhaltung gewonnen werden
* koennen. * koennen.
* *
@ -4029,7 +4025,7 @@ static int sp_recruit(castorder * co)
return 0; return 0;
} }
/* Immer noch zuviel auf niedrigen Stufen. Deshalb die Rekrutierungskosten /* Immer noch zuviel auf niedrigen Stufen. Deshalb die Rekrutierungskosten
* mit einfliessen lassen und dafuer den Exponenten etwas groeßer. * mit einfliessen lassen und dafuer den Exponenten etwas groe<EFBFBD>er.
* Wenn die Rekrutierungskosten deutlich hoeher sind als der Faktor, * Wenn die Rekrutierungskosten deutlich hoeher sind als der Faktor,
* ist das Verhaeltniss von ausgegebene Aura pro Bauer bei Stufe 2 * ist das Verhaeltniss von ausgegebene Aura pro Bauer bei Stufe 2
* ein mehrfaches von Stufe 1, denn in beiden Faellen gibt es nur 1 * ein mehrfaches von Stufe 1, denn in beiden Faellen gibt es nur 1
@ -4060,7 +4056,7 @@ static int sp_recruit(castorder * co)
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Name: Wanderprediger - Große Anwerbung /* Name: Wanderprediger - Gro<EFBFBD>e Anwerbung
* Stufe: 14 * Stufe: 14
* Gebiet: Cerddor * Gebiet: Cerddor
* Wirkung: * Wirkung:
@ -4116,8 +4112,8 @@ static int sp_bigrecruit(castorder * co)
* Gebiet: Cerddor * Gebiet: Cerddor
* Wirkung: * Wirkung:
* Erliegt die Einheit dem Zauber, so wird sie dem Magier alles * Erliegt die Einheit dem Zauber, so wird sie dem Magier alles
* erzaehlen, was sie ueber die gefragte Region weiß. Ist in der Region * erzaehlen, was sie ueber die gefragte Region wei<EFBFBD>. Ist in der Region
* niemand ihrer Partei, so weiß sie nichts zu berichten. Auch kann * niemand ihrer Partei, so wei<EFBFBD> sie nichts zu berichten. Auch kann
* sie nur das erzaehlen, was sie selber sehen koennte. * sie nur das erzaehlen, was sie selber sehen koennte.
* Flags: * Flags:
* (UNITSPELL | TESTCANSEE) * (UNITSPELL | TESTCANSEE)
@ -4180,7 +4176,7 @@ static int sp_pump(castorder * co)
* Stufe: 6 * Stufe: 6
* Gebiet: Cerddor * Gebiet: Cerddor
* Wirkung: * Wirkung:
* Betoert eine Einheit, so das sie ihm den groeßten Teil ihres Bargelds * Betoert eine Einheit, so das sie ihm den groe<EFBFBD>ten Teil ihres Bargelds
* und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie * und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie
* sie zum ueberleben braucht. Wirkt gegen Magieresistenz. * sie zum ueberleben braucht. Wirkt gegen Magieresistenz.
* _min(Stufe*1000$, u->money - maintenace) * _min(Stufe*1000$, u->money - maintenace)
@ -4337,7 +4333,7 @@ static int sp_headache(castorder * co)
if (target->number == 0 || pa->param[0]->flag == TARGET_NOTFOUND) if (target->number == 0 || pa->param[0]->flag == TARGET_NOTFOUND)
return 0; return 0;
/* finde das groeßte Talent: */ /* finde das groe<EFBFBD>te Talent: */
for (i = 0; i != target->skill_size; ++i) { for (i = 0; i != target->skill_size; ++i) {
skill *sv = target->skills + i; skill *sv = target->skills + i;
if (smax == NULL || skill_compare(sv, smax) > 0) { if (smax == NULL || skill_compare(sv, smax) > 0) {
@ -4483,7 +4479,7 @@ int sp_puttorest(castorder * co)
return co->level; return co->level;
} }
/* Name: Traumschloeßchen /* Name: Traumschloe<EFBFBD>chen
* Stufe: 3 * Stufe: 3
* Kategorie: Region, Gebaeude, positiv * Kategorie: Region, Gebaeude, positiv
* Gebiet: Illaun * Gebiet: Illaun
@ -4518,7 +4514,7 @@ int sp_icastle(castorder * co)
b = new_building(bt_illusion, r, mage->faction->locale); b = new_building(bt_illusion, r, mage->faction->locale);
/* Groeße festlegen. */ /* Groe<EFBFBD>e festlegen. */
if (type == bt_illusion) { if (type == bt_illusion) {
b->size = (rng_int() % (int)((power * power) + 1) * 10); b->size = (rng_int() % (int)((power * power) + 1) * 10);
} }
@ -4696,7 +4692,7 @@ int sp_baddreams(castorder * co)
* Kategorie: * Kategorie:
* Wirkung: * Wirkung:
* Dieser Zauber ermoeglicht es dem Traeumer, den Schlaf aller aliierten * Dieser Zauber ermoeglicht es dem Traeumer, den Schlaf aller aliierten
* Einheiten in der Region so zu beeinflussen, daß sie fuer einige Zeit * Einheiten in der Region so zu beeinflussen, da<EFBFBD> sie fuer einige Zeit
* einen Bonus von 1 Talentstufe in allen Talenten * einen Bonus von 1 Talentstufe in allen Talenten
* bekommen. Der Zauber wirkt erst im Folgemonat. * bekommen. Der Zauber wirkt erst im Folgemonat.
* Flags: * Flags:
@ -6295,21 +6291,21 @@ int sp_q_antimagie(castorder * co)
{ {
unit *u = pa->param[0]->data.u; unit *u = pa->param[0]->data.u;
ap = &u->attribs; ap = &u->attribs;
ts = unitid(u); ts = itoa36(u->no);
break; break;
} }
case SPP_BUILDING: case SPP_BUILDING:
{ {
building *b = pa->param[0]->data.b; building *b = pa->param[0]->data.b;
ap = &b->attribs; ap = &b->attribs;
ts = buildingid(b); ts = itoa36(b->no);
break; break;
} }
case SPP_SHIP: case SPP_SHIP:
{ {
ship *sh = pa->param[0]->data.sh; ship *sh = pa->param[0]->data.sh;
ap = &sh->attribs; ap = &sh->attribs;
ts = shipid(sh); ts = itoa36(sh->no);
break; break;
} }
default: default:
@ -6388,21 +6384,21 @@ int sp_break_curse(castorder * co)
{ {
unit *u = pa->param[0]->data.u; unit *u = pa->param[0]->data.u;
ap = &u->attribs; ap = &u->attribs;
ts = unitid(u); ts = itoa36(u->no);
break; break;
} }
case SPP_BUILDING: case SPP_BUILDING:
{ {
building *b = pa->param[0]->data.b; building *b = pa->param[0]->data.b;
ap = &b->attribs; ap = &b->attribs;
ts = buildingid(b); ts = itoa36(b->no);
break; break;
} }
case SPP_SHIP: case SPP_SHIP:
{ {
ship *sh = pa->param[0]->data.sh; ship *sh = pa->param[0]->data.sh;
ap = &sh->attribs; ap = &sh->attribs;
ts = shipid(sh); ts = itoa36(sh->no);
break; break;
} }
default: default:
@ -6722,7 +6718,6 @@ void register_spells(void)
{ {
register_borders(); register_borders();
at_register(&at_wdwpyramid);
at_register(&at_deathcloud_compat); at_register(&at_deathcloud_compat);
/* init_firewall(); */ /* init_firewall(); */

View file

@ -12,7 +12,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "buildingcurse.h" #include "buildingcurse.h"
/* kernel includes */ /* kernel includes */

View file

@ -10,7 +10,6 @@
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "combatspells.h" #include "combatspells.h"
/* kernel includes */ /* kernel includes */
@ -81,7 +80,7 @@ static const char *spell_damage(int sp)
{ {
switch (sp) { switch (sp) {
case 0: case 0:
/* meist tödlich 20-65 HP */ /* meist t<EFBFBD>dlich 20-65 HP */
return "5d10+15"; return "5d10+15";
case 1: case 1:
/* sehr variabel 4-48 HP */ /* sehr variabel 4-48 HP */
@ -90,7 +89,7 @@ static const char *spell_damage(int sp)
/* leicht verwundet 4-18 HP */ /* leicht verwundet 4-18 HP */
return "2d8+2"; return "2d8+2";
case 3: case 3:
/* fast immer tödlich 30-50 HP */ /* fast immer t<EFBFBD>dlich 30-50 HP */
return "5d5+25"; return "5d5+25";
case 4: case 4:
/* verwundet 11-26 HP */ /* verwundet 11-26 HP */
@ -382,11 +381,11 @@ int sp_combatrosthauch(struct castorder * co)
ql_free(fgs); ql_free(fgs);
if (k == 0) { if (k == 0) {
/* keine Waffen mehr da, die zerstört werden könnten */ /* keine Waffen mehr da, die zerst<EFBFBD>rt werden k<>nnten */
message *msg = msg_message("rust_effect_1", "mage", fi->unit); message *msg = msg_message("rust_effect_1", "mage", fi->unit);
message_all(b, msg); message_all(b, msg);
msg_release(msg); msg_release(msg);
fi->magic = 0; /* kämpft nichtmagisch weiter */ fi->magic = 0; /* k<EFBFBD>mpft nichtmagisch weiter */
level = 0; level = 0;
} }
else { else {
@ -453,7 +452,7 @@ int sp_speed(struct castorder * co)
allies = allies =
count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY); count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY);
/* maximal 2*allies Versuche ein Opfer zu finden, ansonsten bestände /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best<EFBFBD>nde
* die Gefahr eine Endlosschleife*/ * die Gefahr eine Endlosschleife*/
allies *= 2; allies *= 2;
@ -546,7 +545,7 @@ int sp_mindblast_temp(struct castorder * co)
assert(dt.fighter); assert(dt.fighter);
du = dt.fighter->unit; du = dt.fighter->unit;
if (fval(du, UFL_MARK)) { if (du->flags & UFL_MARK) {
/* not this one again */ /* not this one again */
continue; continue;
} }
@ -564,7 +563,7 @@ int sp_mindblast_temp(struct castorder * co)
} }
force -= du->number; force -= du->number;
} }
fset(du, UFL_MARK); du->flags |= UFL_MARK;
reset = 1; reset = 1;
enemies -= du->number; enemies -= du->number;
} }
@ -572,7 +571,7 @@ int sp_mindblast_temp(struct castorder * co)
if (reset) { if (reset) {
unit *u; unit *u;
for (u = b->region->units; u; u = u->next) { for (u = b->region->units; u; u = u->next) {
freset(u, UFL_MARK); u->flags &= ~UFL_MARK;
} }
} }
@ -612,7 +611,7 @@ int sp_mindblast(struct castorder * co)
assert(dt.fighter); assert(dt.fighter);
du = dt.fighter->unit; du = dt.fighter->unit;
if (fval(du, UFL_MARK)) { if (du->flags & UFL_MARK) {
/* not this one again */ /* not this one again */
continue; continue;
} }
@ -640,7 +639,7 @@ int sp_mindblast(struct castorder * co)
else { else {
/* only works against humanoids, don't try others. but do remove them /* only works against humanoids, don't try others. but do remove them
* from 'force' once or we may never terminate. */ * from 'force' once or we may never terminate. */
fset(du, UFL_MARK); du->flags |= UFL_MARK;
reset = 1; reset = 1;
} }
enemies -= du->number; enemies -= du->number;
@ -649,7 +648,7 @@ int sp_mindblast(struct castorder * co)
if (reset) { if (reset) {
unit *u; unit *u;
for (u = b->region->units; u; u = u->next) { for (u = b->region->units; u; u = u->next) {
freset(u, UFL_MARK); u->flags &= ~UFL_MARK;
} }
} }
@ -866,8 +865,8 @@ static fighter *summon_allies(const fighter *fi, const race *rc, int number) {
u->hp = u->number * unit_max_hp(u); u->hp = u->number * unit_max_hp(u);
if (fval(mage, UFL_ANON_FACTION)) { if (mage->flags & UFL_ANON_FACTION) {
fset(u, UFL_ANON_FACTION); u->flags |= UFL_ANON_FACTION;
} }
a = a_new(&at_unitdissolve); a = a_new(&at_unitdissolve);
@ -932,8 +931,8 @@ int sp_shadowknights(struct castorder * co)
u->hp = u->number * unit_max_hp(u); u->hp = u->number * unit_max_hp(u);
if (fval(mage, UFL_ANON_FACTION)) { if (mage->flags & UFL_ANON_FACTION) {
fset(u, UFL_ANON_FACTION); u->flags |= UFL_ANON_FACTION;
} }
a = a_new(&at_unitdissolve); a = a_new(&at_unitdissolve);
@ -1016,7 +1015,7 @@ int sp_chaosrow(struct castorder * co)
continue; continue;
if (power <= 0.0) if (power <= 0.0)
break; break;
/* force sollte wegen des _max(0,x) nicht unter 0 fallen können */ /* force sollte wegen des _max(0,x) nicht unter 0 fallen k<EFBFBD>nnen */
if (is_magic_resistant(mage, df->unit, 0)) if (is_magic_resistant(mage, df->unit, 0))
continue; continue;
@ -1068,7 +1067,7 @@ int sp_chaosrow(struct castorder * co)
} }
/* Gesang der Furcht (Kampfzauber) */ /* Gesang der Furcht (Kampfzauber) */
/* Panik (Präkampfzauber) */ /* Panik (Pr<EFBFBD>kampfzauber) */
int sp_flee(struct castorder * co) int sp_flee(struct castorder * co)
{ {
@ -1114,13 +1113,13 @@ int sp_flee(struct castorder * co)
if (force < 0) if (force < 0)
break; break;
if (df->person[n].flags & FL_PANICED) { /* bei SPL_SONG_OF_FEAR möglich */ if (df->person[n].flags & FL_PANICED) { /* bei SPL_SONG_OF_FEAR m<EFBFBD>glich */
df->person[n].attack -= 1; df->person[n].attack -= 1;
--force; --force;
++panik; ++panik;
} }
else if (!(df->person[n].flags & FL_COURAGE) else if (!(df->person[n].flags & FL_COURAGE)
|| !fval(u_race(df->unit), RCF_UNDEAD)) { || !(u_race(df->unit)->flags & RCF_UNDEAD)) {
if (!is_magic_resistant(mage, df->unit, 0)) { if (!is_magic_resistant(mage, df->unit, 0)) {
df->person[n].flags |= FL_PANICED; df->person[n].flags |= FL_PANICED;
++panik; ++panik;
@ -1165,7 +1164,7 @@ int sp_hero(struct castorder * co)
allies = allies =
count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY); count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY);
/* maximal 2*allies Versuche ein Opfer zu finden, ansonsten bestände /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best<EFBFBD>nde
* die Gefahr eine Endlosschleife*/ * die Gefahr eine Endlosschleife*/
allies *= 2; allies *= 2;
@ -1222,7 +1221,7 @@ int sp_berserk(struct castorder * co)
allies = allies =
count_allies(fi->side, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE, ALLY_ANY); count_allies(fi->side, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE, ALLY_ANY);
/* maximal 2*allies Versuche ein Opfer zu finden, ansonsten bestände /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best<EFBFBD>nde
* die Gefahr eine Endlosschleife*/ * die Gefahr eine Endlosschleife*/
allies *= 2; allies *= 2;
@ -1419,7 +1418,7 @@ int sp_reeling_arrows(struct castorder * co)
} }
/* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in /* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in
* eine Nachbarregion, wobei ein NACH berücksichtigt wird. Ansonsten * eine Nachbarregion, wobei ein NACH ber<EFBFBD>cksichtigt wird. Ansonsten
* bleibt er stehen und nimmt nicht weiter am Kampf teil. */ * bleibt er stehen und nimmt nicht weiter am Kampf teil. */
int sp_denyattack(struct castorder * co) int sp_denyattack(struct castorder * co)
{ {
@ -1432,17 +1431,16 @@ int sp_denyattack(struct castorder * co)
region *r = b->region; region *r = b->region;
message *m; message *m;
/* Fliehende Einheiten verlassen auf jeden Fall Gebäude und Schiffe. */ /* Fliehende Einheiten verlassen auf jeden Fall Geb<EFBFBD>ude und Schiffe. */
if (!fval(r->terrain, SEA_REGION)) { if (!(r->terrain->flags & SEA_REGION)) {
leave(mage, false); leave(mage, false);
} }
/* und bewachen nicht */ /* und bewachen nicht */
setguard(mage, false); setguard(mage, false);
/* irgendwie den langen befehl sperren */ /* irgendwie den langen befehl sperren */
/* fset(fi, FIG_ATTACKED); */
/* wir tun so, als wäre die Person geflohen */ /* wir tun so, als w<EFBFBD>re die Person geflohen */
fset(fi, FIG_NOLOOT); fi->flags |= FIG_NOLOOT;
fi->run.hp = mage->hp; fi->run.hp = mage->hp;
fi->run.number = mage->number; fi->run.number = mage->number;
/* fighter leeren */ /* fighter leeren */
@ -1480,7 +1478,7 @@ int sp_armorshield(struct castorder * co)
message_all(b, m); message_all(b, m);
msg_release(m); msg_release(m);
/* gibt Rüstung +effect für duration Treffer */ /* gibt R<EFBFBD>stung +effect f<>r duration Treffer */
switch (sp->id) { switch (sp->id) {
case SPL_ARMORSHIELD: case SPL_ARMORSHIELD:
@ -1539,7 +1537,7 @@ int sp_fumbleshield(struct castorder * co)
message_all(b, m); message_all(b, m);
msg_release(m); msg_release(m);
/* der erste Zauber schlägt mit 100% fehl */ /* der erste Zauber schl<EFBFBD>gt mit 100% fehl */
switch (sp->id) { switch (sp->id) {
case SPL_DRAIG_FUMBLESHIELD: case SPL_DRAIG_FUMBLESHIELD:
@ -1605,7 +1603,7 @@ int sp_reanimate(struct castorder * co)
&& u_race(tf->unit) != get_race(RC_DAEMON) && u_race(tf->unit) != get_race(RC_DAEMON)
&& (chance(c))) { && (chance(c))) {
assert(tf->alive < tf->unit->number); assert(tf->alive < tf->unit->number);
/* t.fighter->person[].hp beginnt mit t.index = 0 zu zählen, /* t.fighter->person[].hp beginnt mit t.index = 0 zu z<EFBFBD>hlen,
* t.fighter->alive ist jedoch die Anzahl lebender in der Einheit, * t.fighter->alive ist jedoch die Anzahl lebender in der Einheit,
* also sind die hp von t.fighter->alive * also sind die hp von t.fighter->alive
* t.fighter->hitpoints[t.fighter->alive-1] und der erste Tote * t.fighter->hitpoints[t.fighter->alive-1] und der erste Tote
@ -1668,7 +1666,7 @@ static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters)
break; break;
/* Untote kann man nicht heilen */ /* Untote kann man nicht heilen */
if (df->unit->number == 0 || fval(u_race(df->unit), RCF_NOHEAL)) if (df->unit->number == 0 || (u_race(df->unit)->flags & RCF_NOHEAL))
continue; continue;
/* wir heilen erstmal keine Monster */ /* wir heilen erstmal keine Monster */
@ -1711,8 +1709,8 @@ int sp_healing(struct castorder * co)
message *msg; message *msg;
bool use_item = has_ao_healing(mage); bool use_item = has_ao_healing(mage);
/* bis zu 11 Personen pro Stufe (einen HP müssen sie ja noch /* bis zu 11 Personen pro Stufe (einen HP m<EFBFBD>ssen sie ja noch
* haben, sonst wären sie tot) nnen geheilt werden */ * haben, sonst w<EFBFBD>ren sie tot) k<EFBFBD>nnen geheilt werden */
if (use_item) { if (use_item) {
healhp *= 2; healhp *= 2;
@ -1758,7 +1756,7 @@ int sp_undeadhero(struct castorder * co)
int force = (int)get_force(power, 0); int force = (int)get_force(power, 0);
double c = 0.50 + 0.02 * power; double c = 0.50 + 0.02 * power;
/* Liste aus allen Kämpfern */ /* Liste aus allen K<EFBFBD>mpfern */
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP); fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP);
scramble_fighters(fgs); scramble_fighters(fgs);
@ -1776,7 +1774,7 @@ int sp_undeadhero(struct castorder * co)
if (df->alive + df->run.number < du->number) { if (df->alive + df->run.number < du->number) {
int j = 0; int j = 0;
/* Wieviele Untote können wir aus dieser Einheit wecken? */ /* Wieviele Untote k<EFBFBD>nnen wir aus dieser Einheit wecken? */
for (n = df->alive + df->run.number; n != du->number; n++) { for (n = df->alive + df->run.number; n != du->number; n++) {
if (chance(c)) { if (chance(c)) {
++j; ++j;
@ -1818,8 +1816,8 @@ int sp_undeadhero(struct castorder * co)
} }
/* inherit stealth from magician */ /* inherit stealth from magician */
if (fval(mage, UFL_ANON_FACTION)) { if (mage->flags & UFL_ANON_FACTION) {
fset(u, UFL_ANON_FACTION); u->flags |= UFL_ANON_FACTION;
} }
/* transfer dead people to new unit, set hitpoints to those of old unit */ /* transfer dead people to new unit, set hitpoints to those of old unit */

View file

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "flyingship.h" #include "flyingship.h"
#include <kernel/build.h> #include <kernel/build.h>
@ -27,8 +26,8 @@
* Stufe: 6 * Stufe: 6
* *
* Wirkung: * Wirkung:
* Laeßt ein Schiff eine Runde lang fliegen. Wirkt nur auf Boote * Lae<EFBFBD>t ein Schiff eine Runde lang fliegen. Wirkt nur auf Boote
* bis Kapazität 50. * bis Kapazit<EFBFBD>t 50.
* Kombinierbar mit "Guenstige Winde", aber nicht mit "Sturmwind". * Kombinierbar mit "Guenstige Winde", aber nicht mit "Sturmwind".
* *
* Flag: * Flag:
@ -81,18 +80,20 @@ int sp_flying_ship(castorder * co)
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) for (u = r->units; u; u = u->next)
freset(u->faction, FFL_SELECT); u->faction->flags &= ~FFL_SELECT;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
/* das sehen natuerlich auch die Leute an Land */ /* das sehen natuerlich auch die Leute an Land */
if (!fval(u->faction, FFL_SELECT)) { if (!(u->faction->flags & FFL_SELECT)) {
fset(u->faction, FFL_SELECT); u->faction->flags |= FFL_SELECT;
if (!m) if (!m) {
m = msg_message("flying_ship_result", "mage ship", mage, sh); m = msg_message("flying_ship_result", "mage ship", mage, sh);
}
add_message(&u->faction->msgs, m); add_message(&u->faction->msgs, m);
} }
} }
if (m) if (m) {
msg_release(m); msg_release(m);
}
return cast_level; return cast_level;
} }
@ -120,7 +121,7 @@ static int flyingship_age(curse * c)
{ {
ship *sh = (ship *)c->data.v; ship *sh = (ship *)c->data.v;
if (sh && c->duration == 1) { if (sh && c->duration == 1) {
freset(sh, SF_FLYING); sh->flags &= ~SF_FLYING;
return 1; return 1;
} }
return 0; return 0;

View file

@ -23,3 +23,4 @@ extern "C" {
#endif #endif
#endif #endif

View file

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <util/language.h> #include <util/language.h>

View file

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/faction.h> #include <kernel/faction.h>

View file

@ -12,7 +12,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "regioncurse.h" #include "regioncurse.h"
#include "magic.h" #include "magic.h"
@ -50,7 +49,7 @@ static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ,
unused_arg(self); unused_arg(self);
assert(typ == TYP_REGION); assert(typ == TYP_REGION);
if (fval(r->terrain, SEA_REGION)) { if (r->terrain->flags & SEA_REGION) {
return msg_message("curseinfo::godcurseocean", "id", c->no); return msg_message("curseinfo::godcurseocean", "id", c->no);
} }
return msg_message("curseinfo::godcurse", "id", c->no); return msg_message("curseinfo::godcurse", "id", c->no);

View file

@ -12,7 +12,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "shipcurse.h" #include "shipcurse.h"
/* kernel includes */ /* kernel includes */

View file

@ -12,7 +12,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "unitcurse.h" #include "unitcurse.h"
/* kernel includes */ /* kernel includes */

View file

@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "study.h" #include "study.h"
#include "laws.h"
#include "move.h" #include "move.h"
#include "monster.h" #include "monster.h"
#include "alchemy.h" #include "alchemy.h"
@ -438,7 +439,7 @@ int teach_cmd(unit * u, struct order *ord)
strncat(zOrder, " ", sz - 1); strncat(zOrder, " ", sz - 1);
--sz; --sz;
} }
sz -= strlcpy(zOrder + 4096 - sz, unitid(u2), sz); sz -= strlcpy(zOrder + 4096 - sz, itoa36(u2->no), sz);
if (getkeyword(u2->thisorder) != K_STUDY) { if (getkeyword(u2->thisorder) != K_STUDY) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
@ -531,6 +532,16 @@ static double study_speedup(unit * u, skill_t s, study_rule_t rule)
return 1.0; return 1.0;
} }
static bool ExpensiveMigrants(void)
{
static bool rule;
static int cache;
if (config_changed(&cache)) {
rule = config_get_int("study.expensivemigrants", 0) != 0;
}
return rule;
}
int study_cmd(unit * u, order * ord) int study_cmd(unit * u, order * ord)
{ {
region *r = u->region; region *r = u->region;
@ -772,7 +783,7 @@ int study_cmd(unit * u, order * ord)
a_remove(&u->attribs, a); a_remove(&u->attribs, a);
a = NULL; a = NULL;
} }
fset(u, UFL_LONGACTION | UFL_NOTMOVING); u->flags |= (UFL_LONGACTION | UFL_NOTMOVING);
/* Anzeigen neuer Traenke */ /* Anzeigen neuer Traenke */
/* Spruchlistenaktualiesierung ist in Regeneration */ /* Spruchlistenaktualiesierung ist in Regeneration */

View file

@ -96,12 +96,12 @@ int update_nmrs(void)
int nmr = turn - f->lastorders + 1; int nmr = turn - f->lastorders + 1;
if (timeout>0) { if (timeout>0) {
if (nmr < 0 || nmr > timeout) { if (nmr < 0 || nmr > timeout) {
log_error("faction %s has %d NMR", factionid(f), nmr); log_error("faction %s has %d NMR", itoa36(f->no), nmr);
nmr = _max(0, nmr); nmr = _max(0, nmr);
nmr = _min(nmr, timeout); nmr = _min(nmr, timeout);
} }
if (nmr > 0) { if (nmr > 0) {
log_debug("faction %s has %d NMR", factionid(f), nmr); log_debug("faction %s has %d NMR", itoa36(f->no), nmr);
} }
++nmrs[nmr]; ++nmrs[nmr];
} }

View file

@ -60,7 +60,6 @@ int RunAllTests(int argc, char *argv[])
{ {
/* self-test */ /* self-test */
ADD_SUITE(tests); ADD_SUITE(tests);
ADD_SUITE(callback);
ADD_SUITE(json); ADD_SUITE(json);
ADD_SUITE(jsonconf); ADD_SUITE(jsonconf);
ADD_SUITE(direction); ADD_SUITE(direction);
@ -114,7 +113,6 @@ int RunAllTests(int argc, char *argv[])
ADD_SUITE(guard); ADD_SUITE(guard);
ADD_SUITE(report); ADD_SUITE(report);
ADD_SUITE(creport); ADD_SUITE(creport);
ADD_SUITE(prefix);
ADD_SUITE(summary); ADD_SUITE(summary);
ADD_SUITE(names); ADD_SUITE(names);
ADD_SUITE(battle); ADD_SUITE(battle);
@ -130,6 +128,8 @@ int RunAllTests(int argc, char *argv[])
ADD_SUITE(monsters); ADD_SUITE(monsters);
ADD_SUITE(move); ADD_SUITE(move);
ADD_SUITE(piracy); ADD_SUITE(piracy);
ADD_SUITE(prefix);
ADD_SUITE(renumber);
ADD_SUITE(key); ADD_SUITE(key);
ADD_SUITE(stealth); ADD_SUITE(stealth);
ADD_SUITE(otherfaction); ADD_SUITE(otherfaction);

View file

@ -196,9 +196,15 @@ static void test_reset(void) {
} }
} }
void test_setup(void) { void test_setup_test(CuTest *tc, const char *file, int line) {
test_log_stderr(LOG_CPERROR); test_log_stderr(LOG_CPERROR);
test_reset(); test_reset();
if (tc) {
log_debug("start test: %s", tc->name);
}
else {
log_debug("start test in %s:%d", file, line);
}
} }
void test_cleanup(void) void test_cleanup(void)

View file

@ -31,7 +31,10 @@ extern "C" {
struct CuTest; struct CuTest;
void test_setup(void); void test_setup_test(struct CuTest *tc, const char *file, int line);
#define test_setup() test_setup_test(NULL, __FILE__, __LINE__)
#define test_setup_ex(tc) test_setup_test(tc, __FILE__, __LINE__)
void test_cleanup(void); void test_cleanup(void);
void test_log_stderr(int on); void test_log_stderr(int on);
struct log_t * test_log_start(int flags, struct strlist **slist); struct log_t * test_log_start(int flags, struct strlist **slist);

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "changefaction.h" #include "changefaction.h"
/* kernel includes */ /* kernel includes */

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "changerace.h" #include "changerace.h"
/* kernel includes */ /* kernel includes */

View file

@ -26,6 +26,7 @@ extern "C" {
struct trigger_type; struct trigger_type;
struct trigger; struct trigger;
struct unit; struct unit;
struct race;
extern struct trigger_type tt_changerace; extern struct trigger_type tt_changerace;

View file

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/config.h>
#include "clonedied.h" #include "clonedied.h"
#include "magic.h" #include "magic.h"

View file

@ -118,7 +118,7 @@ static void shock_write(const trigger * t, struct storage *store)
next = next->next; next = next->next;
} }
if (next && u) { if (next && u) {
log_error("more than one shock-attribut for %s on a unit. FIXED.\n", unitid(u)); log_error("more than one shock-attribut for %s on a unit. FIXED.\n", itoa36(u->no));
write_unit_reference(NULL, store); write_unit_reference(NULL, store);
} }
else { else {

View file

@ -52,3 +52,4 @@ void register_function(pf_generic fun, const char *name)
void free_functions(void) { void free_functions(void) {
cb_clear(&cb_functions); cb_clear(&cb_functions);
} }

View file

@ -30,33 +30,34 @@ extern "C" {
struct locale; struct locale;
struct critbit_tree; struct critbit_tree;
extern const char *localenames[];
extern struct locale *default_locale;
extern struct locale *locales;
extern struct locale *nextlocale(const struct locale *lang);
/** managing multiple locales: **/ /** managing multiple locales: **/
extern struct locale *get_locale(const char *name); struct locale *get_locale(const char *name);
extern struct locale *get_or_create_locale(const char *key); struct locale *get_or_create_locale(const char *key);
void init_locales(void); void init_locales(void);
void free_locales(void); void free_locales(void);
void reset_locales(void); void reset_locales(void);
/** operations on locales: **/ /** operations on locales: **/
extern void locale_setstring(struct locale *lang, const char *key, void locale_setstring(struct locale *lang, const char *key,
const char *value); const char *value);
extern const char *locale_getstring(const struct locale *lang, const char *locale_getstring(const struct locale *lang,
const char *key); const char *key);
extern const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */ const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */
extern unsigned int locale_index(const struct locale *lang); unsigned int locale_index(const struct locale *lang);
extern const char *locale_name(const struct locale *lang); const char *locale_name(const struct locale *lang);
extern const char *mkname(const char *namespc, const char *key); const char *mkname(const char *namespc, const char *key);
extern char *mkname_buf(const char *namespc, const char *key, char *buffer); char *mkname_buf(const char *namespc, const char *key, char *buffer);
extern void make_locales(const char *str); void make_locales(const char *str);
#define LOC(lang, s) (lang?locale_string(lang, s, true):s) #define LOC(lang, s) (lang?locale_string(lang, s, true):s)
extern struct locale *default_locale;
extern struct locale *locales;
extern struct locale *nextlocale(const struct locale *lang);
enum { enum {
UT_PARAMS, UT_PARAMS,
UT_KEYWORDS, UT_KEYWORDS,

View file

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <config.h>
#include "language.h" #include "language.h"
#include <CuTest.h> #include <CuTest.h>

View file

@ -6,6 +6,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include <wctype.h> #include <wctype.h>
#include <memory.h> #include <memory.h>
@ -250,7 +251,7 @@ unsigned int atoip(const char *s)
int n; int n;
assert(s); assert(s);
n = atoi(s); n = isdigit(s[0]) ? atoi(s) : 0;
if (n < 0) if (n < 0)
n = 0; n = 0;

View file

@ -2,8 +2,16 @@
#include "parser.h" #include "parser.h"
#include <string.h> #include <string.h>
#include <errno.h>
#include <CuTest.h> #include <CuTest.h>
static void test_atoip(CuTest *tc) {
CuAssertIntEquals(tc, 0, atoip("ALLES"));
CuAssertIntEquals(tc, 0, errno);
CuAssertIntEquals(tc, 42, atoip("42"));
CuAssertIntEquals(tc, 0, atoip("-1"));
}
static void test_parse_token(CuTest *tc) { static void test_parse_token(CuTest *tc) {
char lbuf[8]; char lbuf[8];
const char *tok; const char *tok;
@ -103,12 +111,6 @@ static void test_getstrtoken(CuTest *tc) {
CuAssertPtrEquals(tc, NULL, (void *)getstrtoken()); CuAssertPtrEquals(tc, NULL, (void *)getstrtoken());
} }
static void test_atoip(CuTest *tc) {
CuAssertIntEquals(tc, 42, atoip("42"));
CuAssertIntEquals(tc, 0, atoip("-42"));
CuAssertIntEquals(tc, 0, atoip("NOPE"));
}
CuSuite *get_parser_suite(void) CuSuite *get_parser_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();

View file

@ -28,6 +28,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <float.h> #include <float.h>
#include <ctype.h> #include <ctype.h>
int lovar(double xpct_x2)
{
int n = (int)(xpct_x2 * 500) + 1;
if (n == 0)
return 0;
return (rng_int() % n + rng_int() % n) / 1000;
}
/* NormalRand aus python, random.py geklaut, dort ist Referenz auf /* NormalRand aus python, random.py geklaut, dort ist Referenz auf
* den Algorithmus. mu = Mittelwert, sigma = Standardabweichung. * den Algorithmus. mu = Mittelwert, sigma = Standardabweichung.
* http://de.wikipedia.org/wiki/Standardabweichung#Diskrete_Gleichverteilung.2C_W.C3.BCrfel * http://de.wikipedia.org/wiki/Standardabweichung#Diskrete_Gleichverteilung.2C_W.C3.BCrfel

View file

@ -23,13 +23,14 @@ extern "C" {
#endif #endif
/* in dice.c: */ /* in dice.c: */
extern int dice_rand(const char *str); int dice_rand(const char *str);
extern int dice(int count, int value); int dice(int count, int value);
/* in rand.c: */ /* in rand.c: */
extern double normalvariate(double mu, double sigma); int lovar(double xpct_x2);
extern int ntimespprob(int n, double p, double mod); double normalvariate(double mu, double sigma);
extern bool chance(double x); int ntimespprob(int n, double p, double mod);
bool chance(double x);
/* a random source that generates numbers in [0, 1). /* a random source that generates numbers in [0, 1).
By calling the random_source_inject... functions you can set a special random source, By calling the random_source_inject... functions you can set a special random source,

View file

@ -284,7 +284,8 @@ void volcano_update(void)
} }
} }
else if (r->terrain == t_volcano) { else if (r->terrain == t_volcano) {
if (rng_int() % 100 < 4) { int volcano_chance = config_get_int("volcano.active.percent", 4);
if (rng_int() % 100 < volcano_chance) {
ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r)); ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r));
r->terrain = t_active; r->terrain = t_active;
} }