code-polishing: Vertraute werden nicht mehr als RC_* gebraucht.

This commit is contained in:
Enno Rehling 2006-01-01 20:50:36 +00:00
parent c60502bfc8
commit 9eb50890c6
7 changed files with 41 additions and 63 deletions

View File

@ -34,7 +34,7 @@
static int
use_phoenixcompass(struct unit * u, const struct item_type * itype,
int amount, struct order * ord)
int amount, struct order * ord)
{
region *r;
unit *closest_phoenix = NULL;
@ -43,12 +43,18 @@ use_phoenixcompass(struct unit * u, const struct item_type * itype,
direction_t direction;
unit *u2;
direction_t closest_neighbour_direction = 0;
static race * rc_phoenix = NULL;
if (rc_phoenix==NULL) {
rc_phoenix = rc_find("phoenix");
if (rc_phoenix==NULL) return 0;
}
/* find the closest phoenix. */
for(r=regions; r; r=r->next) {
for(u2=r->units; u2; u2=u2->next) {
if(u2->race == new_race[RC_PHOENIX]) {
if (u2->race == rc_phoenix) {
if(closest_phoenix == NULL) {
closest_phoenix = u2;
closest_phoenix_distance = distance(u->region, closest_phoenix->region);

View File

@ -653,28 +653,11 @@ enum {
RC_HIRNTOETER,
RC_PEASANT,
RC_WOLF, /* 31 */
RC_WOLF = 31, /* 31 */
RC_LYNX,
RC_TUNNELWORM,
RC_EAGLE,
RC_RAT,
RC_SONGDRAGON,
RC_NYMPH,
RC_UNICORN,
RC_DIREWOLF,
RC_GHOST,
RC_IMP, /* 41 */
RC_DREAMCAT,
RC_FAIRY,
RC_OWL,
RC_HELLCAT,
RC_TIGER,
RC_DOLPHIN,
RC_OCEANTURTLE,
RC_KRAKEN,
RC_SONGDRAGON = 36,
RC_SEASERPENT,
RC_SEASERPENT = 50,
RC_SHADOWKNIGHT, /* 51 */
RC_CENTAUR,
@ -689,13 +672,7 @@ enum {
RC_MUS_SPIRIT, /* 60 */
RC_GNOME, /* 61 */
RC_TEMPLATE, /* 62 */
RC_CLONE, /* 63 */
RC_SHADOWDRAGON, /* 64 */
RC_SHADOWBAT,
RC_NIGHTMARE,
RC_VAMPUNICORN,
RC_PHOENIX,
RC_CLONE = 63, /* 63 */
MAXRACES,
NORACE = (race_t) - 1

View File

@ -59,6 +59,7 @@
/** external variables **/
race * races;
race_list * familiarraces;
void
racelist_clear(struct race_list **rl)
@ -131,6 +132,9 @@ rc_find(const char * name)
}
}
while (rc && !strcmp(rname, rc->_name[0])==0) rc = rc->next;
if (rc->init_familiar!=NULL) {
racelist_insert(&familiarraces, rc);
}
return rc;
}

View File

@ -102,6 +102,7 @@ typedef struct race_list {
extern void racelist_clear(struct race_list **rl);
extern void racelist_insert(struct race_list **rl, const struct race *r);
extern struct race_list * familiarraces;
extern struct race * races;
extern struct race * rc_find(const char *);

View File

@ -542,13 +542,12 @@ race_compat(void)
"youngdragon", "dragon", "wyrm", "ent", "catdragon", "dracoid",
"special", "spell", "irongolem", "stonegolem", "shadowdemon",
"shadowmaster", "mountainguard", "alp", "toad", "braineater", "peasant",
"wolf", "lynx", "tunnelworm", "eagle", "rat", "songdragon", "nymph",
"unicorn", "direwolf", "ghost", "imp", "dreamcat", "fairy", "owl",
"hellcat", "tiger", "dolphin", "giantturtle", "kraken", "seaserpent",
"wolf", NULL, NULL, NULL, NULL, "songdragon", NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, "seaserpent",
"shadowknight", "centaur", "skeleton", "skeletonlord", "zombie",
"juju-zombie", "ghoul", "ghast", "museumghost", "gnome", "template",
"clone", "shadowdragon", "shadowbat", "nightmare", "vampunicorn",
"phoenix"
"clone"
};
int i;

View File

@ -753,27 +753,12 @@ sp_shadowcall(fighter * fi, int level, double power, spell * sp)
unit *mage = fi->unit;
attrib *a;
int force = (int)(get_force(power, 3)/2);
const race *rc = NULL;
int num;
unit *u;
const char * races[3] = { "shadowbat", "nightmare", "vampunicorn" };
const race *rc = rc_find(races[rand()%3]);
unused(sp);
switch(rand()%3) {
case 0:
rc = new_race[RC_SHADOWBAT];
num = 5000+dice_rand("3d5000");
break;
case 1:
rc = new_race[RC_NIGHTMARE];
num = 500+dice_rand("3d500");
break;
case 2:
rc = new_race[RC_VAMPUNICORN];
num = 500+dice_rand("3d500");
break;
}
u = create_unit(r, mage->faction, force, rc, 0, NULL, mage);
u->status = ST_FIGHT;

View File

@ -516,20 +516,26 @@ static const race *
select_familiar(const race * magerace, magic_t magiegebiet)
{
const race * retval = NULL;
int rnd = rand()%100;
assert(magerace->familiars[0]);
int rnd = rand()%100;
do {
if (rnd < 3) {
/* RC_KRAKEN muß letzter Vertraute sein */
int rc = RC_LYNX + rand()%(RC_KRAKEN+1-RC_LYNX);
retval = new_race[rc];
} else if (rnd < 80) {
retval = magerace->familiars[0];
}
retval = magerace->familiars[magiegebiet];
assert(magerace->familiars[0]);
if (rnd < 3) {
unsigned int maxlen = listlen(familiarraces);
if (maxlen>0) {
race_list * rclist = familiarraces;
int index = rand()%maxlen;
while (index-->0) {
rclist = rclist->next;
}
retval = rclist->data;
}
} else if (rnd < 70) {
retval = magerace->familiars[0];
} else {
retval = magerace->familiars[magiegebiet];
}
while (retval->init_familiar==NULL);
assert (retval!=NULL && retval->init_familiar!=NULL);
return retval;
}