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