forked from github/server
fix any migrants that have received aura.
This commit is contained in:
parent
1c01f4d083
commit
9f2741f3dc
|
@ -24,10 +24,10 @@ static bool equip_callback(unit *u, const char *eqname, int mask) {
|
|||
|
||||
static void test_equipment(CuTest * tc)
|
||||
{
|
||||
callbacks.equip_unit = equip_callback;
|
||||
unit * u;
|
||||
|
||||
test_setup();
|
||||
callbacks.equip_unit = equip_callback;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, true, equip_unit_mask(u, "hodor", EQUIP_ALL));
|
||||
|
|
|
@ -44,8 +44,9 @@
|
|||
#define FIX_STARTLEVEL_VERSION 366 /* fixing resource startlevels */
|
||||
#define FIX_RES_BASE_VERSION 367 /* fixing resource base */
|
||||
#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 MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
||||
|
||||
|
|
|
@ -1661,6 +1661,9 @@ int read_game(gamedata *data)
|
|||
if (data->version < FAMILIAR_FIXSPELLBOOK_VERSION) {
|
||||
fix_familiars(fix_fam_spells);
|
||||
}
|
||||
if (data->version < FIX_MIGRANT_AURA_VERSION) {
|
||||
fix_familiars(fix_fam_migrant);
|
||||
}
|
||||
|
||||
log_debug("Done loading turn %d.", turn);
|
||||
|
||||
|
|
|
@ -2256,7 +2256,9 @@ static int copy_spell_cb(spellbook_entry *sbe, void *udata) {
|
|||
* Einmalige Reparatur von Vertrauten (Bug 2585).
|
||||
*/
|
||||
void fix_fam_migrant(unit *u) {
|
||||
|
||||
if (!is_familiar(u)) {
|
||||
a_removeall(&u->attribs, &at_mage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -512,6 +512,41 @@ static void test_regenerate_aura_migrants(CuTest *tc) {
|
|||
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);
|
||||
|
@ -710,5 +745,6 @@ CuSuite *get_magic_suite(void)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
#include "vortex.h"
|
||||
|
||||
#include "kernel/calendar.h"
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/alliance.h>
|
||||
#include "kernel/callbacks.h"
|
||||
#include "kernel/config.h"
|
||||
#include "kernel/alliance.h"
|
||||
#include <kernel/equipment.h>
|
||||
#include <kernel/messages.h>
|
||||
#include <kernel/plane.h>
|
||||
|
@ -228,7 +229,7 @@ static void test_reset(void) {
|
|||
errno = 0;
|
||||
log_error("errno: %d (%s)", error, strerror(error));
|
||||
}
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
free_gamedata();
|
||||
free_terrains();
|
||||
free_resources();
|
||||
|
|
Loading…
Reference in New Issue