Merge pull request #856 from ennorehling/develop

Bugfix: Migranten regenerieren Aura
This commit is contained in:
Enno Rehling 2019-05-19 17:41:56 +02:00 committed by GitHub
commit b6a573027a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 164 additions and 355 deletions

View File

@ -1,9 +1,9 @@
{ {
"include": [ "include": [
"config://res/races/goblin-3.xml", "config://res/e3a/races.xml",
"config://res/races/wyrm.xml", "config://res/e3a/races/goblin.xml",
"config://res/races/dragon.xml", "config://res/e3a/races/wyrm.xml",
"config://res/races/youngdragon.xml", "config://res/e3a/races/dragon.xml",
"config://res/e3a/races.xml" "config://res/e3a/races/youngdragon.xml"
] ]
} }

View File

@ -1,19 +0,0 @@
<?xml version="1.0" ?>
<race name="aquarian" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" shipspeed="yes" playerrace="yes" coastal="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="mining" modifier="-2"/>
<skill name="building" modifier="-1"/>
<skill name="trade" modifier="2"/>
<skill name="armorer" modifier="-1"/>
<skill name="shipcraft" modifier="3"/>
<skill name="sailing" modifier="3"/>
<skill name="roadwork" modifier="-1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="giantturtle"/>
<familiar race="dolphin"/>
<familiar race="giantturtle"/>
<familiar race="dolphin"/>
<familiar race="dolphin"/>
<familiar race="kraken"/>
</race>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<race name="cat" maxaura="1.000000" regaura="1.000000" recruitcost="90" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" defensemodifier="1" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="alchemy" modifier="-1"/>
<skill name="mining" modifier="-2"/>
<skill name="building" modifier="-1"/>
<skill name="catapult" modifier="-1"/>
<skill name="herbalism" modifier="1"/>
<skill name="armorer" modifier="-1"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="sailing" modifier="-2"/>
<skill name="espionage" modifier="2"/>
<skill name="quarrying" modifier="-1"/>
<skill name="roadwork" modifier="-1"/>
<skill name="stealth" modifier="1"/>
<skill name="perception" modifier="2"/>
<skill name="taxation" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="lynx"/>
<familiar race="dreamcat"/>
<familiar race="lynx"/>
<familiar race="songdragon"/>
<familiar race="tiger"/>
<familiar race="hellcat"/>
</race>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" ?>
<race name="demon" magres="15" maxaura="1.000000"
regaura="1.250000" recruitcost="150" maintenance="10" weight="1000"
capacity="540" speed="1.000000" hp="50" ac="2" damage="1d5"
unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes"
shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes"
recruitethereal="yes" equipment="yes" healing="1.5">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="alchemy" modifier="2"/>
<skill name="trade" modifier="-3"/>
<skill name="forestry" modifier="1"/>
<skill name="herbalism" modifier="-3"/>
<skill name="magic" modifier="1"/>
<skill name="training" modifier="-3"/>
<skill name="riding" modifier="-1"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="melee" modifier="1"/>
<skill name="sailing" modifier="-1"/>
<skill name="polearm" modifier="1"/>
<skill name="tactics" modifier="-1"/>
<skill name="stealth" modifier="1"/>
<skill name="entertainment" modifier="-3"/>
<skill name="weaponsmithing" modifier="1"/>
<skill name="cartmaking" modifier="-2"/>
<skill name="perception" modifier="1"/>
<skill name="taxation" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<attack type="5"/>
<familiar race="imp"/>
<familiar race="imp"/>
<familiar race="ghost"/>
<familiar race="rat"/>
<familiar race="wolf"/>
<familiar race="imp"/>
</race>

View File

@ -1,32 +0,0 @@
<?xml version="1.0" ?>
<race name="dwarf" magres="5" maxaura="1.000000" regaura="0.500000" recruitcost="110" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="mining" modifier="2"/>
<skill name="bow" modifier="-1"/>
<skill name="building" modifier="2"/>
<skill name="trade" modifier="1"/>
<skill name="forestry" modifier="-1"/>
<skill name="catapult" modifier="2"/>
<skill name="herbalism" modifier="-2"/>
<skill name="magic" modifier="-2"/>
<skill name="training" modifier="-2"/>
<skill name="riding" modifier="-2"/>
<skill name="armorer" modifier="2"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="melee" modifier="1"/>
<skill name="sailing" modifier="-2"/>
<skill name="quarrying" modifier="2"/>
<skill name="roadwork" modifier="2"/>
<skill name="stealth" modifier="-1"/>
<skill name="entertainment" modifier="-1"/>
<skill name="weaponsmithing" modifier="2"/>
<skill name="taxation" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="tunnelworm"/>
<familiar race="eagle"/>
<familiar race="owl"/>
<familiar race="lynx"/>
<familiar race="wolf"/>
<familiar race="rat"/>
</race>

View File

@ -1,28 +0,0 @@
<?xml version="1.0" ?>
<race name="elf" magres="10" maxaura="1.000000" regaura="1.250000" recruitcost="130" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="alchemy" modifier="-1"/>
<skill name="mining" modifier="-2"/>
<skill name="bow" modifier="2"/>
<skill name="building" modifier="-1"/>
<skill name="catapult" modifier="-2"/>
<skill name="herbalism" modifier="2"/>
<skill name="magic" modifier="1"/>
<skill name="training" modifier="1"/>
<skill name="armorer" modifier="-1"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="sailing" modifier="-1"/>
<skill name="quarrying" modifier="-1"/>
<skill name="roadwork" modifier="-1"/>
<skill name="stealth" modifier="1"/>
<skill name="perception" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="lynx"/>
<familiar race="fairy"/>
<familiar race="owl"/>
<familiar race="nymph"/>
<familiar race="unicorn"/>
<familiar race="imp"/>
</race>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" ?>
<race name="goblin" magres="-5" maxaura="1.000000"
recruitcost="40" maintenance="10" weight="600"
capacity="440" speed="1.000000" hp="16" damage="1d5"
unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes"
giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"
healing="2.0">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="alchemy" modifier="1"/>
<skill name="mining" modifier="1"/>
<skill name="building" modifier="1"/>
<skill name="trade" modifier="-1"/>
<skill name="catapult" modifier="1"/>
<skill name="magic" modifier="-1"/>
<skill name="shipcraft" modifier="-2"/>
<skill name="sailing" modifier="-2"/>
<skill name="roadwork" modifier="-2"/>
<skill name="tactics" modifier="-2"/>
<skill name="stealth" modifier="1"/>
<skill name="entertainment" modifier="-1"/>
<skill name="cartmaking" modifier="-1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="rat"/>
<familiar race="songdragon"/>
<familiar race="imp"/>
<familiar race="rat"/>
<familiar race="rat"/>
<familiar race="imp"/>
</race>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" ?>
<race name="halfling" magres="5" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<param name="hunger_damage" value="1d14+14"/>
<skill name="crossbow" modifier="1"/>
<skill name="mining" modifier="1"/>
<skill name="bow" modifier="-1"/>
<skill name="building" modifier="1"/>
<skill name="trade" modifier="2"/>
<skill name="catapult" modifier="-1"/>
<skill name="herbalism" modifier="2"/>
<skill name="training" modifier="-1"/>
<skill name="riding" modifier="-1"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="melee" modifier="-1"/>
<skill name="sailing" modifier="-2"/>
<skill name="polearm" modifier="-1"/>
<skill name="espionage" modifier="1"/>
<skill name="roadwork" modifier="1"/>
<skill name="stealth" modifier="1"/>
<skill name="entertainment" modifier="1"/>
<skill name="cartmaking" modifier="2"/>
<skill name="perception" modifier="1"/>
<skill name="taxation" modifier="-1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="owl"/>
<familiar race="rat"/>
<familiar race="eagle"/>
<familiar race="songdragon"/>
<familiar race="eagle"/>
<familiar race="rat"/>
</race>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" ?>
<race name="human" maxaura="1.000000" regaura="1.000000" recruitcost="75" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="trade" modifier="1"/>
<skill name="herbalism" modifier="-1"/>
<skill name="shipcraft" modifier="1"/>
<skill name="sailing" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="wolf"/>
<familiar race="dreamcat"/>
<familiar race="owl"/>
<familiar race="owl"/>
<familiar race="eagle"/>
<familiar race="imp"/>
</race>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" ?>
<race name="insect" magres="5" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="crossbow" modifier="1"/>
<skill name="mining" modifier="1"/>
<skill name="bow" modifier="-2"/>
<skill name="building" modifier="2"/>
<skill name="trade" modifier="-1"/>
<skill name="forestry" modifier="1"/>
<skill name="herbalism" modifier="1"/>
<skill name="training" modifier="-3"/>
<skill name="riding" modifier="-3"/>
<skill name="armorer" modifier="2"/>
<skill name="melee" modifier="-1"/>
<skill name="polearm" modifier="1"/>
<skill name="roadwork" modifier="-1"/>
<skill name="tactics" modifier="-1"/>
<skill name="stealth" modifier="-1"/>
<skill name="entertainment" modifier="-2"/>
<skill name="perception" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="ghost"/>
<familiar race="rat"/>
<familiar race="owl"/>
<familiar race="rat"/>
<familiar race="tunnelworm"/>
<familiar race="imp"/>
</race>

View File

@ -1,31 +0,0 @@
<?xml version="1.0" ?>
<race name="orc" studyspeed="-5" magres="-5" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<param name="recruit_multi" value="0.5"/>
<skill name="alchemy" modifier="1"/>
<skill name="mining" modifier="1"/>
<skill name="building" modifier="1"/>
<skill name="trade" modifier="-3"/>
<skill name="forestry" modifier="1"/>
<skill name="herbalism" modifier="-2"/>
<skill name="magic" modifier="-1"/>
<skill name="training" modifier="-1"/>
<skill name="armorer" modifier="1"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="sailing" modifier="-1"/>
<skill name="espionage" modifier="-1"/>
<skill name="quarrying" modifier="1"/>
<skill name="tactics" modifier="1"/>
<skill name="entertainment" modifier="-2"/>
<skill name="weaponsmithing" modifier="2"/>
<skill name="cartmaking" modifier="-1"/>
<skill name="taxation" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/>
<familiar race="goblin"/>
<familiar race="ghost"/>
<familiar race="imp"/>
<familiar race="rat"/>
<familiar race="wolf"/>
<familiar race="demon"/>
</race>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" ?>
<race name="troll" magres="10" maxaura="1.000000"
regaura="1.000000" recruitcost="90" maintenance="10" weight="2000"
capacity="1080" speed="1.000000" hp="30" ac="1" damage="1d5+3"
unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes"
giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"
healing="1.5">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="mining" modifier="2"/>
<skill name="bow" modifier="-2"/>
<skill name="building" modifier="2"/>
<skill name="catapult" modifier="2"/>
<skill name="herbalism" modifier="-1"/>
<skill name="training" modifier="-1"/>
<skill name="riding" modifier="-2"/>
<skill name="armorer" modifier="2"/>
<skill name="shipcraft" modifier="-1"/>
<skill name="melee" modifier="1"/>
<skill name="sailing" modifier="-1"/>
<skill name="espionage" modifier="-3"/>
<skill name="quarrying" modifier="2"/>
<skill name="roadwork" modifier="2"/>
<skill name="tactics" modifier="-1"/>
<skill name="stealth" modifier="-3"/>
<skill name="entertainment" modifier="-1"/>
<skill name="perception" modifier="-1"/>
<skill name="taxation" modifier="1"/>
<skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5+3"/>
<familiar race="tunnelworm"/>
<familiar race="rat"/>
<familiar race="rat"/>
<familiar race="eagle"/>
<familiar race="tunnelworm"/>
<familiar race="wolf"/>
</race>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" ?>
<race name="zombie" magres="20" maxaura="1.0" regaura="1.0"
recruitcost="-1" maintenance="0" weight="1000" capacity="440" speed="1.000000"
hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="no"
walk="yes" shapeshift="no" giveperson="no" giveunit="no"
getitem="no" equipment="yes" scarepeasants="yes"
cansteal="no" unarmedguard="yes" noheal="yes"
undead="yes" resistpierce="yes">
<ai splitsize="1000" moverandom="yes" learn="yes" absorbpeasants="yes"/>
<attack type="1" damage="1d5" />
<attack type="5" />
</race>

View File

@ -24,10 +24,10 @@ static bool equip_callback(unit *u, const char *eqname, int mask) {
static void test_equipment(CuTest * tc) static void test_equipment(CuTest * tc)
{ {
callbacks.equip_unit = equip_callback;
unit * u; unit * u;
test_setup(); test_setup();
callbacks.equip_unit = equip_callback;
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
CuAssertIntEquals(tc, true, equip_unit_mask(u, "hodor", EQUIP_ALL)); CuAssertIntEquals(tc, true, equip_unit_mask(u, "hodor", EQUIP_ALL));

View File

@ -281,6 +281,7 @@ unit *addplayer(region * r, faction * f)
assert(f->units == NULL); assert(f->units == NULL);
faction_setorigin(f, 0, r->x, r->y); faction_setorigin(f, 0, r->x, r->y);
u = create_unit(r, f, 1, f->race, 0, NULL, NULL); u = create_unit(r, f, 1, f->race, 0, NULL, NULL);
u->status = ST_FLEE;
u->thisorder = default_order(f->locale); u->thisorder = default_order(f->locale);
unit_addorder(u, copy_order(u->thisorder)); unit_addorder(u, copy_order(u->thisorder));
name = config_get("rules.equip_first"); name = config_get("rules.equip_first");

View File

@ -44,8 +44,9 @@
#define FIX_STARTLEVEL_VERSION 366 /* fixing resource startlevels */ #define FIX_STARTLEVEL_VERSION 366 /* fixing resource startlevels */
#define FIX_RES_BASE_VERSION 367 /* fixing resource base */ #define FIX_RES_BASE_VERSION 367 /* fixing resource base */
#define FIX_CLONES_VERSION 368 /* dissolve clones */ #define FIX_CLONES_VERSION 368 /* dissolve clones */
#define FIX_MIGRANT_AURA_VERSION 369 /* bug 2585, migrants with aura */
#define RELEASE_VERSION FIX_CLONES_VERSION /* current datafile */ #define RELEASE_VERSION FIX_MIGRANT_AURA_VERSION /* current datafile */
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */ #define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ #define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */

View File

@ -1659,7 +1659,10 @@ int read_game(gamedata *data)
fix_familiars(fix_fam_triggers); fix_familiars(fix_fam_triggers);
} }
if (data->version < FAMILIAR_FIXSPELLBOOK_VERSION) { if (data->version < FAMILIAR_FIXSPELLBOOK_VERSION) {
fix_familiars(fix_fam_mage); fix_familiars(fix_fam_spells);
}
if (data->version < FIX_MIGRANT_AURA_VERSION) {
fix_familiars(fix_fam_migrant);
} }
log_debug("Done loading turn %d.", turn); log_debug("Done loading turn %d.", turn);

View File

@ -651,12 +651,13 @@ int max_spellpoints(const struct unit *u, const region * r)
const sc_mage *m; const sc_mage *m;
assert(u); assert(u);
m = get_mage(u);
if (!m) return 0;
if (!r) r = u->region; if (!r) r = u->region;
sk = effskill(u, SK_MAGIC, r); sk = effskill(u, SK_MAGIC, r);
msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1); msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1);
m = get_mage(u); msp += m->spchange;
if (m) msp += m->spchange;
rtype = rt_find("aurafocus"); rtype = rt_find("aurafocus");
if (rtype && i_get(u->items, rtype->itype) > 0) { if (rtype && i_get(u->items, rtype->itype) > 0) {
@ -2250,12 +2251,29 @@ static int copy_spell_cb(spellbook_entry *sbe, void *udata) {
} }
/** /**
* Entferne Magie-Attribut von Migranten, die keine Vertrauten sind.
*
* Einmalige Reparatur von Vertrauten (Bug 2585).
*/
void fix_fam_migrant(unit *u) {
if (!is_familiar(u)) {
a_removeall(&u->attribs, &at_mage);
}
}
/**
* Einheiten, die Vertraute sind, bekommen ihre fehlenden Zauber.
*
* Einmalige Reparatur von Vertrauten (Bugs 2451, 2517). * Einmalige Reparatur von Vertrauten (Bugs 2451, 2517).
*/ */
void fix_fam_mage(unit *u) { void fix_fam_spells(unit *u) {
sc_mage *dmage; sc_mage *dmage;
unit *du = unit_create(0); unit *du = unit_create(0);
if (!is_familiar(u)) {
return;
}
u_setrace(du, u_race(u)); u_setrace(du, u_race(u));
dmage = create_mage(du, M_GRAY); dmage = create_mage(du, M_GRAY);
equip_familiar(du); equip_familiar(du);
@ -2285,7 +2303,6 @@ void fix_fam_mage(unit *u) {
void create_newfamiliar(unit * mage, unit * fam) void create_newfamiliar(unit * mage, unit * fam)
{ {
create_mage(fam, M_GRAY); create_mage(fam, M_GRAY);
set_familiar(mage, fam); set_familiar(mage, fam);
equip_familiar(fam); equip_familiar(fam);

View File

@ -330,7 +330,8 @@ extern "C" {
void create_newfamiliar(struct unit *mage, struct unit *familiar); void create_newfamiliar(struct unit *mage, struct unit *familiar);
void create_newclone(struct unit *mage, struct unit *familiar); void create_newclone(struct unit *mage, struct unit *familiar);
void fix_fam_mage(struct unit *u); void fix_fam_spells(struct unit *u);
void fix_fam_migrant(struct unit *u);
const char *spell_info(const struct spell *sp, const char *spell_info(const struct spell *sp,
const struct locale *lang); const struct locale *lang);

View File

@ -442,25 +442,30 @@ static void test_magic_resistance(CuTest *tc) {
static void test_max_spellpoints(CuTest *tc) { static void test_max_spellpoints(CuTest *tc) {
unit *u; unit *u;
race *rc; race *rc;
item_type *it_aura;
test_setup(); test_setup();
rc = test_create_race("human"); rc = test_create_race("human");
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0)); u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
CuAssertIntEquals(tc, 1, max_spellpoints_depr(u->region, u)); CuAssertIntEquals(tc, 0, max_spellpoints_depr(u->region, u));
CuAssertIntEquals(tc, 1, max_spellpoints(u, u->region)); CuAssertIntEquals(tc, 0, max_spellpoints(u, u->region));
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL)); CuAssertIntEquals(tc, 0, max_spellpoints(u, NULL));
rc->maxaura = 100;
CuAssertIntEquals(tc, 1, max_spellpoints(u, u->region));
rc->maxaura = 200;
CuAssertIntEquals(tc, 2, max_spellpoints(u, u->region));
create_mage(u, M_GWYRRD); create_mage(u, M_GWYRRD);
rc->maxaura = 100;
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL));
rc->maxaura = 200;
CuAssertIntEquals(tc, 2, max_spellpoints(u, NULL));
set_level(u, SK_MAGIC, 1); set_level(u, SK_MAGIC, 1);
CuAssertIntEquals(tc, 3, max_spellpoints(u, u->region)); CuAssertIntEquals(tc, 3, max_spellpoints(u, NULL));
set_level(u, SK_MAGIC, 2); set_level(u, SK_MAGIC, 2);
CuAssertIntEquals(tc, 9, max_spellpoints(u, u->region)); CuAssertIntEquals(tc, 9, max_spellpoints(u, NULL));
/* permanent aura loss: */ /* permanent aura loss: */
CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2)); CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2));
CuAssertIntEquals(tc, 7, max_spellpoints(u, u->region)); CuAssertIntEquals(tc, 7, max_spellpoints(u, NULL));
/* aurafocus: */
it_aura = test_create_itemtype("aurafocus");
i_change(&u->items, it_aura, 1);
CuAssertIntEquals(tc, 9, max_spellpoints(u, NULL));
test_teardown(); test_teardown();
} }
@ -468,7 +473,6 @@ static void test_regenerate_aura(CuTest *tc) {
unit *u; unit *u;
test_setup(); test_setup();
test_teardown();
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0)); u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
create_mage(u, M_GWYRRD); create_mage(u, M_GWYRRD);
CuAssertIntEquals(tc, 0, get_spellpoints(u)); CuAssertIntEquals(tc, 0, get_spellpoints(u));
@ -482,6 +486,110 @@ static void test_regenerate_aura(CuTest *tc) {
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL)); CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL));
regenerate_aura(); regenerate_aura();
CuAssertIntEquals(tc, 1, get_spellpoints(u)); CuAssertIntEquals(tc, 1, get_spellpoints(u));
test_teardown();
}
/**
* Test for Bug 2582.
*
* Migrant units that are not familiars, but whose race has a maxaura
* must not regenerate aura.
*/
static void test_regenerate_aura_migrants(CuTest *tc) {
unit *u;
race *rc;
test_setup();
rc = test_create_race("demon");
rc->maxaura = 100;
rc->flags |= RCF_FAMILIAR;
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u_setrace(u, rc);
CuAssertIntEquals(tc, 0, get_spellpoints(u));
regenerate_aura();
CuAssertIntEquals(tc, 0, get_spellpoints(u));
test_teardown();
}
static void test_fix_fam_migrants(CuTest *tc) {
unit *u, *mage;
race *rc;
test_setup();
rc = test_create_race("demon");
rc->maxaura = 100;
rc->flags |= RCF_FAMILIAR;
/* u is a migrant with at_mage attribute, but not a familiar */
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u_setrace(u, rc);
create_mage(u, M_GRAY);
CuAssertTrue(tc, !is_familiar(u));
CuAssertPtrNotNull(tc, get_mage(u));
fix_fam_migrant(u);
CuAssertTrue(tc, !is_familiar(u));
CuAssertPtrEquals(tc, NULL, get_mage(u));
/* u is a familiar, and stays unchanged: */
mage = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u_setrace(u, rc);
/* reproduce the bug, create a broken familiar: */
create_newfamiliar(mage, u);
set_level(u, SK_MAGIC, 1);
CuAssertTrue(tc, is_familiar(u));
CuAssertPtrNotNull(tc, get_mage(u));
fix_fam_migrant(u);
CuAssertTrue(tc, is_familiar(u));
CuAssertPtrNotNull(tc, get_mage(u));
test_teardown();
}
static bool equip_spell(unit *u, const char *eqname, int mask) {
spell * sp = find_spell("test");
unit_add_spell(u, sp, 1);
return true;
}
static void test_fix_fam_spells(CuTest *tc) {
unit *u, *mage;
race *rc;
spell * sp;
test_setup();
sp = create_spell("test");
rc = test_create_race("demon");
rc->maxaura = 100;
rc->flags |= RCF_FAMILIAR;
/* u is a familiar, and gets equipped: */
mage = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u_setrace(u, rc);
/* reproduce the bug, create a broken familiar: */
callbacks.equip_unit = NULL;
create_newfamiliar(mage, u);
set_level(u, SK_MAGIC, 1);
CuAssertPtrEquals(tc, NULL, unit_get_spellbook(u));
CuAssertTrue(tc, !u_hasspell(u, sp));
callbacks.equip_unit = equip_spell;
CuAssertTrue(tc, is_familiar(u));
fix_fam_spells(u);
CuAssertTrue(tc, is_familiar(u));
CuAssertPtrNotNull(tc, unit_get_spellbook(u));
CuAssertTrue(tc, u_hasspell(u, sp));
/* u is a migrant, and does not get equipped: */
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u_setrace(u, rc);
CuAssertTrue(tc, !is_familiar(u));
fix_fam_spells(u);
CuAssertTrue(tc, !is_familiar(u));
CuAssertPtrEquals(tc, NULL, unit_get_spellbook(u));
test_teardown();
} }
static void test_illusioncastle(CuTest *tc) static void test_illusioncastle(CuTest *tc)
@ -635,5 +743,8 @@ CuSuite *get_magic_suite(void)
SUITE_ADD_TEST(suite, test_max_spellpoints); SUITE_ADD_TEST(suite, test_max_spellpoints);
SUITE_ADD_TEST(suite, test_illusioncastle); SUITE_ADD_TEST(suite, test_illusioncastle);
SUITE_ADD_TEST(suite, test_regenerate_aura); SUITE_ADD_TEST(suite, test_regenerate_aura);
SUITE_ADD_TEST(suite, test_regenerate_aura_migrants);
SUITE_ADD_TEST(suite, test_fix_fam_spells);
SUITE_ADD_TEST(suite, test_fix_fam_migrants);
return suite; return suite;
} }

View File

@ -239,6 +239,7 @@ static void move_iceberg(region * r)
"region dir", r, dir)); "region dir", r, dir));
} }
stats_count("iceberg.drift", 1);
x = r->x; x = r->x;
y = r->y; y = r->y;
@ -379,6 +380,7 @@ static void create_icebergs(void)
continue; continue;
r->terrain = t_iceberg; r->terrain = t_iceberg;
stats_count("iceberg.terraform", 1);
fset(r, RF_SELECT); fset(r, RF_SELECT);
move_iceberg(r); move_iceberg(r);

View File

@ -7,8 +7,9 @@
#include "vortex.h" #include "vortex.h"
#include "kernel/calendar.h" #include "kernel/calendar.h"
#include <kernel/config.h> #include "kernel/callbacks.h"
#include <kernel/alliance.h> #include "kernel/config.h"
#include "kernel/alliance.h"
#include <kernel/equipment.h> #include <kernel/equipment.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/plane.h> #include <kernel/plane.h>
@ -228,7 +229,7 @@ static void test_reset(void) {
errno = 0; errno = 0;
log_error("errno: %d (%s)", error, strerror(error)); log_error("errno: %d (%s)", error, strerror(error));
} }
memset(&callbacks, 0, sizeof(callbacks));
free_gamedata(); free_gamedata();
free_terrains(); free_terrains();
free_resources(); free_resources();