forked from github/server
entirely remove RC_SPELL
This commit is contained in:
parent
30cfe2c0c0
commit
18daa9db2f
10
src/chaos.c
10
src/chaos.c
|
@ -112,9 +112,7 @@ static unit *random_unit(const region * r)
|
|||
unit *u;
|
||||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u_race(u) != get_race(RC_SPELL)) {
|
||||
c += u->number;
|
||||
}
|
||||
c += u->number;
|
||||
}
|
||||
|
||||
if (c == 0) {
|
||||
|
@ -125,9 +123,7 @@ static unit *random_unit(const region * r)
|
|||
u = r->units;
|
||||
|
||||
while (u && c < n) {
|
||||
if (u_race(u) != get_race(RC_SPELL)) {
|
||||
c += u->number;
|
||||
}
|
||||
c += u->number;
|
||||
u = u->next;
|
||||
}
|
||||
|
||||
|
@ -203,7 +199,7 @@ static void chaos(region * r)
|
|||
|
||||
for (up = &r->units; *up;) {
|
||||
unit *u = *up;
|
||||
if (u_race(u) != get_race(RC_SPELL) && u->ship == 0 && !canfly(u)) {
|
||||
if (u->ship == 0 && !canfly(u)) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("tidalwave_kill",
|
||||
"region unit", r, u));
|
||||
remove_unit(up, u);
|
||||
|
|
|
@ -2978,13 +2978,12 @@ void produce(struct region *r)
|
|||
static int bt_cache;
|
||||
static const struct building_type *caravan_bt;
|
||||
static int rc_cache;
|
||||
static const race *rc_spell, *rc_insect, *rc_aquarian;
|
||||
static const race *rc_insect, *rc_aquarian;
|
||||
|
||||
if (bt_changed(&bt_cache)) {
|
||||
caravan_bt = bt_find("caravan");
|
||||
}
|
||||
if (rc_changed(&rc_cache)) {
|
||||
rc_spell = get_race(RC_SPELL);
|
||||
rc_insect = get_race(RC_INSECT);
|
||||
rc_aquarian = get_race(RC_AQUARIAN);
|
||||
}
|
||||
|
@ -3022,7 +3021,7 @@ void produce(struct region *r)
|
|||
bool trader = false;
|
||||
keyword_t todo;
|
||||
|
||||
if (u_race(u) == rc_spell || fval(u, UFL_LONGACTION))
|
||||
if (fval(u, UFL_LONGACTION))
|
||||
continue;
|
||||
|
||||
if (u_race(u) == rc_insect && r_insectstalled(r) &&
|
||||
|
|
|
@ -667,12 +667,7 @@ void give_cmd(unit * u, order * ord)
|
|||
return;
|
||||
}
|
||||
|
||||
if (u2 && u_race(u2) == get_race(RC_SPELL)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
||||
"feedback_unit_not_found", ""));
|
||||
return;
|
||||
}
|
||||
else if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
|
||||
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
|
||||
cmistake(u, ord, 40, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ const char *racenames[MAXRACES] = {
|
|||
"dwarf", "elf", NULL, "goblin", "human", "troll", "demon", "insect",
|
||||
"halfling", "cat", "aquarian", "orc", "snotling", "undead", NULL,
|
||||
"youngdragon", "dragon", "wyrm", "ent", "catdragon", "dracoid",
|
||||
NULL, "spell", "irongolem", "stonegolem", "shadowdemon",
|
||||
NULL, NULL, "irongolem", "stonegolem", "shadowdemon",
|
||||
"shadowmaster", "mountainguard", "alp", "toad", "braineater", "peasant",
|
||||
"wolf", NULL, NULL, NULL, NULL, "songdragon", NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
|
|
|
@ -72,8 +72,7 @@ extern "C" {
|
|||
RC_BIRTHDAYDRAGON,
|
||||
RC_DRACOID,
|
||||
|
||||
RC_SPELL = 22,
|
||||
RC_IRONGOLEM,
|
||||
RC_IRONGOLEM = 23,
|
||||
RC_STONEGOLEM,
|
||||
RC_SHADOW,
|
||||
RC_SHADOWLORD,
|
||||
|
|
|
@ -132,8 +132,6 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
|
|||
i = getid();
|
||||
u = findunitg(i, NULL);
|
||||
|
||||
if (u && u_race(u) == get_race(RC_SPELL))
|
||||
return NULL;
|
||||
if (u && u->faction == f) {
|
||||
order **ordp;
|
||||
|
||||
|
@ -852,7 +850,7 @@ void write_unit(struct gamedata *data, const unit * u)
|
|||
WRITE_SECTION(data->store);
|
||||
write_items(data->store, u->items);
|
||||
WRITE_SECTION(data->store);
|
||||
if (u->hp == 0 && u_race(u)!= get_race(RC_SPELL)) {
|
||||
if (u->hp == 0 && data->version < NORCSPELL_VERSION) {
|
||||
log_error("unit %s has 0 hitpoints, adjusting.", itoa36(u->no));
|
||||
((unit *)u)->hp = u->number;
|
||||
}
|
||||
|
@ -1707,7 +1705,7 @@ int read_game(gamedata *data) {
|
|||
while (--p >= 0) {
|
||||
unit *u = read_unit(data);
|
||||
|
||||
if (u_race(u) == rc_spell) {
|
||||
if (data->version < NORCSPELL_VERSION && u_race(u) == rc_spell) {
|
||||
set_observer(r, u->faction, get_level(u, SK_PERCEPTION), u->age);
|
||||
free_unit(u);
|
||||
}
|
||||
|
|
|
@ -1891,8 +1891,7 @@ void remove_empty_units_in_region(region * r)
|
|||
set_number(u, 0);
|
||||
}
|
||||
}
|
||||
if ((u->number == 0 && u_race(u) != get_race(RC_SPELL)) || (u->age <= 0
|
||||
&& u_race(u) == get_race(RC_SPELL))) {
|
||||
if (u->number == 0) {
|
||||
remove_unit(up, u);
|
||||
}
|
||||
if (*up == u)
|
||||
|
|
|
@ -97,26 +97,6 @@ static void test_remove_units_with_dead_faction(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_remove_units_ignores_spells(CuTest *tc) {
|
||||
unit *u;
|
||||
int uid;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
u = create_unit(findregion(0, 0), test_create_faction(test_create_race("human")), 1, test_create_race("spell"), 0, 0, 0);
|
||||
uid = u->no;
|
||||
u->number = 0;
|
||||
u->age = 1;
|
||||
remove_empty_units_in_region(u->region);
|
||||
CuAssertPtrNotNull(tc, findunit(uid));
|
||||
CuAssertPtrNotNull(tc, u->region);
|
||||
u->age = 0;
|
||||
remove_empty_units_in_region(u->region);
|
||||
CuAssertPtrEquals(tc, 0, findunit(uid));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_scale_number(CuTest *tc) {
|
||||
unit *u;
|
||||
const struct potion_type *ptype;
|
||||
|
@ -555,7 +535,6 @@ CuSuite *get_unit_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_update_monster_name);
|
||||
SUITE_ADD_TEST(suite, test_remove_unit);
|
||||
SUITE_ADD_TEST(suite, test_remove_empty_units);
|
||||
SUITE_ADD_TEST(suite, test_remove_units_ignores_spells);
|
||||
SUITE_ADD_TEST(suite, test_remove_units_without_faction);
|
||||
SUITE_ADD_TEST(suite, test_remove_units_with_dead_faction);
|
||||
SUITE_ADD_TEST(suite, test_remove_empty_units_in_region);
|
||||
|
|
22
src/laws.c
22
src/laws.c
|
@ -154,22 +154,11 @@ static bool RemoveNMRNewbie(void)
|
|||
static void age_unit(region * r, unit * u)
|
||||
{
|
||||
static int rc_cache;
|
||||
static const race *rc_spell;
|
||||
const race *rc = u_race(u);
|
||||
|
||||
if (rc_changed(&rc_cache)) {
|
||||
rc_spell = get_race(RC_SPELL);
|
||||
}
|
||||
if (u_race(u) == rc_spell) {
|
||||
if (--u->age <= 0) {
|
||||
remove_unit(&r->units, u);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const race *rc = u_race(u);
|
||||
++u->age;
|
||||
if (u->number > 0 && rc->age_unit) {
|
||||
rc->age_unit(u);
|
||||
}
|
||||
++u->age;
|
||||
if (u->number > 0 && rc->age_unit) {
|
||||
rc->age_unit(u);
|
||||
}
|
||||
if (u->region && is_astral(u->region)) {
|
||||
item **itemp = &u->items;
|
||||
|
@ -2676,8 +2665,7 @@ int guard_on_cmd(unit * u, struct order *ord)
|
|||
if (fval(u, UFL_MOVED)) {
|
||||
cmistake(u, ord, 187, MSG_EVENT);
|
||||
}
|
||||
else if (fval(u_race(u), RCF_ILLUSIONARY)
|
||||
|| u_race(u) == get_race(RC_SPELL)) {
|
||||
else if (fval(u_race(u), RCF_ILLUSIONARY)) {
|
||||
cmistake(u, ord, 95, MSG_EVENT);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1209,9 +1209,6 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus)
|
|||
skill *sv;
|
||||
unit *u = (unit *)obj;
|
||||
|
||||
if (u_race(u)==get_race(RC_SPELL)) {
|
||||
return true;
|
||||
}
|
||||
at = effskill(magician, SK_MAGIC, 0);
|
||||
|
||||
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
||||
|
@ -2780,7 +2777,6 @@ void magic(void)
|
|||
int rank;
|
||||
castorder *co;
|
||||
spellrank spellranks[MAX_SPELLRANK];
|
||||
const race *rc_spell = get_race(RC_SPELL);
|
||||
const race *rc_insect = get_race(RC_INSECT);
|
||||
|
||||
memset(spellranks, 0, sizeof(spellranks));
|
||||
|
@ -2790,7 +2786,7 @@ void magic(void)
|
|||
for (u = r->units; u; u = u->next) {
|
||||
order *ord;
|
||||
|
||||
if (u->number <= 0 || u_race(u) == rc_spell)
|
||||
if (u->number <= 0)
|
||||
continue;
|
||||
|
||||
if (u_race(u) == rc_insect && r_insectstalled(r) &&
|
||||
|
|
|
@ -418,7 +418,7 @@ void drown(region * r)
|
|||
while (*up) {
|
||||
unit *u = *up;
|
||||
|
||||
if (!(u->ship || u_race(u) == get_race(RC_SPELL) || u->number == 0 || canswim(u) || canfly(u))) {
|
||||
if (!(u->ship || u->number == 0 || canswim(u) || canfly(u))) {
|
||||
scale_number(u, 0);
|
||||
ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r));
|
||||
}
|
||||
|
|
71
src/spells.c
71
src/spells.c
|
@ -1694,7 +1694,7 @@ static int sp_great_drought(castorder * co)
|
|||
rsetterrain(r, T_OCEAN);
|
||||
/* Einheiten duerfen hier auf keinen Fall geloescht werden! */
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u_race(u) != get_race(RC_SPELL) && u->ship == 0) {
|
||||
if (!u->ship) {
|
||||
set_number(u, 0);
|
||||
}
|
||||
}
|
||||
|
@ -5601,8 +5601,7 @@ int sp_showastral(castorder * co)
|
|||
region *r2 = rl2->data;
|
||||
if (!is_cursed(r2->attribs, C_ASTRALBLOCK, 0)) {
|
||||
for (u = r2->units; u; u = u->next) {
|
||||
if (u_race(u) != get_race(RC_SPELL))
|
||||
n++;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5622,26 +5621,24 @@ int sp_showastral(castorder * co)
|
|||
for (rl2 = rl; rl2; rl2 = rl2->next) {
|
||||
if (!is_cursed(rl2->data->attribs, C_ASTRALBLOCK, 0)) {
|
||||
for (u = rl2->data->units; u; u = u->next) {
|
||||
if (u_race(u) != get_race(RC_SPELL)) {
|
||||
c++;
|
||||
scat(unitname(u));
|
||||
scat(" (");
|
||||
if (!fval(u, UFL_ANON_FACTION)) {
|
||||
scat(factionname(u->faction));
|
||||
scat(", ");
|
||||
}
|
||||
icat(u->number);
|
||||
scat(" ");
|
||||
scat(LOC(mage->faction->locale, rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)));
|
||||
scat(", Entfernung ");
|
||||
icat(distance(rl2->data, rt));
|
||||
scat(")");
|
||||
if (c == n - 1) {
|
||||
scat(" und ");
|
||||
}
|
||||
else if (c < n - 1) {
|
||||
scat(", ");
|
||||
}
|
||||
c++;
|
||||
scat(unitname(u));
|
||||
scat(" (");
|
||||
if (!fval(u, UFL_ANON_FACTION)) {
|
||||
scat(factionname(u->faction));
|
||||
scat(", ");
|
||||
}
|
||||
icat(u->number);
|
||||
scat(" ");
|
||||
scat(LOC(mage->faction->locale, rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)));
|
||||
scat(", Entfernung ");
|
||||
icat(distance(rl2->data, rt));
|
||||
scat(")");
|
||||
if (c == n - 1) {
|
||||
scat(" und ");
|
||||
}
|
||||
else if (c < n - 1) {
|
||||
scat(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5758,24 +5755,22 @@ int sp_disruptastral(castorder * co)
|
|||
|
||||
if (trl != NULL) {
|
||||
for (u = r2->units; u; u = u->next) {
|
||||
if (u_race(u) != get_race(RC_SPELL)) {
|
||||
region_list *trl2 = trl;
|
||||
region *tr;
|
||||
int c = rng_int() % inhab_regions;
|
||||
region_list *trl2 = trl;
|
||||
region *tr;
|
||||
int c = rng_int() % inhab_regions;
|
||||
|
||||
/* Zufaellige Zielregion suchen */
|
||||
while (c-- != 0)
|
||||
trl2 = trl2->next;
|
||||
tr = trl2->data;
|
||||
/* Zufaellige Zielregion suchen */
|
||||
while (c-- != 0)
|
||||
trl2 = trl2->next;
|
||||
tr = trl2->data;
|
||||
|
||||
if (!is_magic_resistant(mage, u, 0) && can_survive(u, tr)) {
|
||||
message *msg = msg_message("disrupt_astral", "unit region", u, tr);
|
||||
add_message(&u->faction->msgs, msg);
|
||||
add_message(&tr->msgs, msg);
|
||||
msg_release(msg);
|
||||
if (!is_magic_resistant(mage, u, 0) && can_survive(u, tr)) {
|
||||
message *msg = msg_message("disrupt_astral", "unit region", u, tr);
|
||||
add_message(&u->faction->msgs, msg);
|
||||
add_message(&tr->msgs, msg);
|
||||
msg_release(msg);
|
||||
|
||||
move_unit(u, tr, NULL);
|
||||
}
|
||||
move_unit(u, tr, NULL);
|
||||
}
|
||||
}
|
||||
free_regionlist(trl);
|
||||
|
|
|
@ -34,10 +34,11 @@
|
|||
#define NOWATCH_VERSION 354 /* plane->watchers is gone */
|
||||
#define KEYVAL_VERSION 355 /* at_keys has values */
|
||||
#define NOLANDITEM_VERSION 356 /* land_region has no items */
|
||||
#define NORCSPELL_VERSION 357 /* data contains no RC_SPELL units */
|
||||
/* unfinished: */
|
||||
#define CRYPT_VERSION 400 /* passwords are encrypted */
|
||||
|
||||
#define RELEASE_VERSION NOLANDITEM_VERSION /* current datafile */
|
||||
#define RELEASE_VERSION NORCSPELL_VERSION /* current datafile */
|
||||
#define MIN_VERSION INTPAK_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 */
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
|
|||
int i, dead = 0, hp_rem = 0, heiltrank;
|
||||
|
||||
assert(u->number);
|
||||
if (fval(u_race(u), RCF_ILLUSIONARY) || u_race(u) == get_race(RC_SPELL)) {
|
||||
if (fval(u_race(u), RCF_ILLUSIONARY)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue