eliminate RS_FARVISION enum, there is no other kind of RC_SPELL.

This commit is contained in:
Enno Rehling 2016-09-24 20:31:31 +02:00
parent 42c44724f8
commit 87873702ca
7 changed files with 75 additions and 60 deletions

View File

@ -1649,11 +1649,51 @@ static castorder * create_castorder_combat(castorder *co, fighter *fig, const sp
return co;
}
#ifdef FFL_CURSED
static void summon_igjarjuk(battle *b, spellrank spellranks[]) {
side *s;
castorder *co;
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fig = 0;
if (s->bf->attacker && fval(s->faction, FFL_CURSED)) {
spell *sp = find_spell("igjarjuk");
if (sp) {
int si;
for (si = 0; s->enemies[si]; ++si) {
side *se = s->enemies[si];
if (se && !fval(se->faction, FFL_NPC)) {
fighter *fi;
for (fi = se->fighters; fi; fi = fi->next) {
if (fi && (!fig || fig->unit->number > fi->unit->number)) {
fig = fi;
if (fig->unit->number == 1) {
break;
}
}
}
if (fig && fig->unit->number == 1) {
break;
}
}
}
if (fig) {
co = create_castorder_combat(0, fig, sp, 10, 10);
co->magician.fig = fig;
add_castorder(&spellranks[sp->rank], co);
break;
}
}
}
}
}
#endif
void do_combatmagic(battle * b, combatmagic_t was)
{
side *s;
region *r = b->region;
castorder *co;
region *r = b->region;
int level, rank, sl;
spellrank spellranks[MAX_SPELLRANK];
@ -1661,38 +1701,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
#ifdef FFL_CURSED
if (was == DO_PRECOMBATSPELL) {
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fig = 0;
if (s->bf->attacker && fval(s->faction, FFL_CURSED)) {
spell *sp = find_spell("igjarjuk");
if (sp) {
int si;
for (si = 0; s->enemies[si]; ++si) {
side *se = s->enemies[si];
if (se && !fval(se->faction, FFL_NPC)) {
fighter *fi;
for (fi = se->fighters; fi; fi = fi->next) {
if (fi && (!fig || fig->unit->number > fi->unit->number)) {
fig = fi;
if (fig->unit->number == 1) {
break;
}
}
}
if (fig && fig->unit->number == 1) {
break;
}
}
}
if (fig) {
co = create_castorder_combat(0, fig, sp, 10, 10);
co->magician.fig = fig;
add_castorder(&spellranks[sp->rank], co);
break;
}
}
}
}
summon_igjarjuk(b, spellranks);
}
#endif
for (s = b->sides; s != b->sides + b->nsides; ++s) {

View File

@ -159,6 +159,7 @@ struct param;
unsigned int data_turn;
void *vm_state;
int data_version; /* TODO: eliminate in favor of gamedata.version */
int debug;
struct _dictionary_ *inifile;
struct global_functions {
int(*wage) (const struct region * r, const struct faction * f,

View File

@ -184,12 +184,6 @@ extern "C" {
SPC_LINEAR /* Komponenten pro Level und müssen vorhanden sein */
};
enum {
RS_DUMMY,
RS_FARVISION,
MAX_REGIONSPELLS
};
/* ------------------------------------------------------------- */
/* Prototypen */

View File

@ -184,6 +184,9 @@ static int parse_args(int argc, char **argv, int *exitcode)
else {
const char *arg;
switch (argi[1]) {
case 'd': // check configuration for consistency
i = get_arg(argc, argv, 2, i, &arg, 0);
global.debug = arg ? atoi(arg) : 0xff;
case 'r':
i = get_arg(argc, argv, 2, i, &arg, 0);
config_set("config.rules", arg);

View File

@ -1308,17 +1308,6 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) {
}
}
static bool unit_cansee(const unit *u)
{
const race *rc = u_race(u);
static const race *rc_spell;
static int rc_cache;
if (rc_changed(&rc_cache)) {
rc_spell = get_race(RC_SPELL);
}
return (rc!=rc_spell || u->number == RS_FARVISION);
}
/** set region.seen based on visibility by one faction.
*
* this function may also update ctx->last and ctx->first for potential
@ -1355,9 +1344,7 @@ void prepare_report(report_context *ctx, faction *f)
u = building_owner(b);
if (u && u->faction==f) {
prepare_lighthouse(b, ctx);
if (unit_cansee(u)) {
add_seen_nb(f, r, seen_unit);
}
add_seen_nb(f, r, seen_unit);
}
}
}
@ -1366,9 +1353,7 @@ void prepare_report(report_context *ctx, faction *f)
}
for (u = r->units; u; u = u->next) {
if (u->faction==f) {
if (unit_cansee(u)) {
add_seen_nb(f, r, seen_unit);
}
add_seen_nb(f, r, seen_unit);
if (fval(r, RF_LIGHTHOUSE)) {
if (u->building && u->building->type == bt_lighthouse && inside_building(u)) {
/* we are in a lighthouse. add the regions we can see from here! */

View File

@ -425,6 +425,29 @@ static void test_seen_travelthru(CuTest *tc) {
test_cleanup();
}
static void test_report_far_vision(CuTest *tc) {
unit *u1, *u2;
faction *f;
region *r1, *r2;
const race *rc;
test_setup();
f = test_create_faction(0);
r1 = test_create_region(0, 0, 0);
u1 = test_create_unit(f, r1);
r2 = test_create_region(10, 0, 0);
rc = test_create_race("spell");
u2 = create_unit(r2, u1->faction, 1, rc, 0, "spell/dreamreading", NULL);
set_number(u2, 1);
report_context ctx;
prepare_report(&ctx, f);
CuAssertPtrEquals(tc, r1, ctx.first);
CuAssertPtrEquals(tc, 0, ctx.last);
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
CuAssertIntEquals(tc, seen_unit, r2->seen.mode);
finish_reports(&ctx);
test_cleanup();
}
CuSuite *get_reports_suite(void)
{
CuSuite *suite = CuSuiteNew();
@ -434,6 +457,7 @@ CuSuite *get_reports_suite(void)
SUITE_ADD_TEST(suite, test_prepare_lighthouse);
SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity);
SUITE_ADD_TEST(suite, test_prepare_travelthru);
SUITE_ADD_TEST(suite, test_report_far_vision);
SUITE_ADD_TEST(suite, test_reorder_units);
SUITE_ADD_TEST(suite, test_seen_faction);
SUITE_ADD_TEST(suite, test_regionid);

View File

@ -4168,7 +4168,7 @@ static int sp_pump(castorder * co)
}
u =
create_unit(rt, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0,
create_unit(rt, mage->faction, 1, get_race(RC_SPELL), 0,
"spell/pump", NULL);
u->age = 2;
set_level(u, SK_PERCEPTION, effskill(target, SK_PERCEPTION, 0));
@ -4812,9 +4812,8 @@ int sp_dreamreading(castorder * co)
}
u2 =
create_unit(u->region, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0,
create_unit(u->region, mage->faction, 1, get_race(RC_SPELL), 0,
"spell/dreamreading", NULL);
set_number(u2, 1);
u2->age = 2; /* Nur fuer diese Runde. */
set_level(u2, SK_PERCEPTION, effskill(u, SK_PERCEPTION, u2->region));
@ -5691,7 +5690,7 @@ int sp_viewreality(castorder * co)
region *rt = rl2->data;
if (!is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) {
u =
create_unit(rt, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0,
create_unit(rt, mage->faction, 1, get_race(RC_SPELL), 0,
"spell/viewreality", NULL);
set_level(u, SK_PERCEPTION, co->level / 2);
u->age = 2;