forked from github/server
fix_fam_spells happy case test (is familiar)
This commit is contained in:
parent
cab3f4309f
commit
670aa56d4e
|
@ -1659,7 +1659,7 @@ int read_game(gamedata *data)
|
|||
fix_familiars(fix_fam_triggers);
|
||||
}
|
||||
if (data->version < FAMILIAR_FIXSPELLBOOK_VERSION) {
|
||||
fix_familiars(fix_fam_mage);
|
||||
fix_familiars(fix_fam_spells);
|
||||
}
|
||||
|
||||
log_debug("Done loading turn %d.", turn);
|
||||
|
|
14
src/magic.c
14
src/magic.c
|
@ -2251,9 +2251,20 @@ 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) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Einheiten, die Vertraute sind, bekommen ihre fehlenden Zauber.
|
||||
*
|
||||
* Einmalige Reparatur von Vertrauten (Bugs 2451, 2517).
|
||||
*/
|
||||
void fix_fam_mage(unit *u) {
|
||||
void fix_fam_spells(unit *u) {
|
||||
sc_mage *dmage;
|
||||
unit *du = unit_create(0);
|
||||
|
||||
|
@ -2286,7 +2297,6 @@ void fix_fam_mage(unit *u) {
|
|||
|
||||
void create_newfamiliar(unit * mage, unit * fam)
|
||||
{
|
||||
|
||||
create_mage(fam, M_GRAY);
|
||||
set_familiar(mage, fam);
|
||||
equip_familiar(fam);
|
||||
|
|
|
@ -330,7 +330,8 @@ extern "C" {
|
|||
void create_newfamiliar(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 struct locale *lang);
|
||||
|
|
|
@ -473,7 +473,6 @@ static void test_regenerate_aura(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
test_teardown();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
create_mage(u, M_GWYRRD);
|
||||
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||
|
@ -487,6 +486,7 @@ static void test_regenerate_aura(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL));
|
||||
regenerate_aura();
|
||||
CuAssertIntEquals(tc, 1, get_spellpoints(u));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -500,14 +500,53 @@ static void test_regenerate_aura_migrants(CuTest *tc) {
|
|||
race *rc;
|
||||
|
||||
test_setup();
|
||||
test_teardown();
|
||||
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 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;
|
||||
fix_fam_spells(u);
|
||||
CuAssertPtrNotNull(tc, unit_get_spellbook(u));
|
||||
CuAssertTrue(tc, u_hasspell(u, sp));
|
||||
|
||||
/* u is a migrant, and does not get equipped: */
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_illusioncastle(CuTest *tc)
|
||||
|
@ -662,5 +701,6 @@ CuSuite *get_magic_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_illusioncastle);
|
||||
SUITE_ADD_TEST(suite, test_regenerate_aura);
|
||||
SUITE_ADD_TEST(suite, test_regenerate_aura_migrants);
|
||||
SUITE_ADD_TEST(suite, test_fix_fam_spells);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue