forked from github/server
eliminate RS_FARVISION enum, there is no other kind of RC_SPELL.
This commit is contained in:
parent
42c44724f8
commit
87873702ca
7 changed files with 75 additions and 60 deletions
31
src/battle.c
31
src/battle.c
|
@ -1649,18 +1649,11 @@ static castorder * create_castorder_combat(castorder *co, fighter *fig, const sp
|
|||
return co;
|
||||
}
|
||||
|
||||
void do_combatmagic(battle * b, combatmagic_t was)
|
||||
{
|
||||
side *s;
|
||||
region *r = b->region;
|
||||
castorder *co;
|
||||
int level, rank, sl;
|
||||
spellrank spellranks[MAX_SPELLRANK];
|
||||
|
||||
memset(spellranks, 0, sizeof(spellranks));
|
||||
|
||||
#ifdef FFL_CURSED
|
||||
if (was == DO_PRECOMBATSPELL) {
|
||||
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)) {
|
||||
|
@ -1694,6 +1687,22 @@ void do_combatmagic(battle * b, combatmagic_t was)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void do_combatmagic(battle * b, combatmagic_t was)
|
||||
{
|
||||
side *s;
|
||||
castorder *co;
|
||||
region *r = b->region;
|
||||
int level, rank, sl;
|
||||
spellrank spellranks[MAX_SPELLRANK];
|
||||
|
||||
memset(spellranks, 0, sizeof(spellranks));
|
||||
|
||||
#ifdef FFL_CURSED
|
||||
if (was == DO_PRECOMBATSPELL) {
|
||||
summon_igjarjuk(b, spellranks);
|
||||
}
|
||||
#endif
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fig;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -184,12 +184,6 @@ extern "C" {
|
|||
SPC_LINEAR /* Komponenten pro Level und müssen vorhanden sein */
|
||||
};
|
||||
|
||||
enum {
|
||||
RS_DUMMY,
|
||||
RS_FARVISION,
|
||||
MAX_REGIONSPELLS
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Prototypen */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,20 +1344,16 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->faction==f) {
|
||||
if (unit_cansee(u)) {
|
||||
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! */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue