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

@ -43,12 +43,18 @@ use_phoenixcompass(struct unit * u, const struct item_type * itype,
direction_t direction; direction_t direction;
unit *u2; unit *u2;
direction_t closest_neighbour_direction = 0; 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. */ /* find the closest phoenix. */
for(r=regions; r; r=r->next) { for(r=regions; r; r=r->next) {
for(u2=r->units; u2; u2=u2->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) { if(closest_phoenix == NULL) {
closest_phoenix = u2; closest_phoenix = u2;
closest_phoenix_distance = distance(u->region, closest_phoenix->region); closest_phoenix_distance = distance(u->region, closest_phoenix->region);

View File

@ -653,28 +653,11 @@ enum {
RC_HIRNTOETER, RC_HIRNTOETER,
RC_PEASANT, RC_PEASANT,
RC_WOLF, /* 31 */ RC_WOLF = 31, /* 31 */
RC_LYNX, RC_SONGDRAGON = 36,
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_SEASERPENT, RC_SEASERPENT = 50,
RC_SHADOWKNIGHT, /* 51 */ RC_SHADOWKNIGHT, /* 51 */
RC_CENTAUR, RC_CENTAUR,
@ -689,13 +672,7 @@ enum {
RC_MUS_SPIRIT, /* 60 */ RC_MUS_SPIRIT, /* 60 */
RC_GNOME, /* 61 */ RC_GNOME, /* 61 */
RC_TEMPLATE, /* 62 */ RC_TEMPLATE, /* 62 */
RC_CLONE, /* 63 */ RC_CLONE = 63, /* 63 */
RC_SHADOWDRAGON, /* 64 */
RC_SHADOWBAT,
RC_NIGHTMARE,
RC_VAMPUNICORN,
RC_PHOENIX,
MAXRACES, MAXRACES,
NORACE = (race_t) - 1 NORACE = (race_t) - 1

View File

@ -59,6 +59,7 @@
/** external variables **/ /** external variables **/
race * races; race * races;
race_list * familiarraces;
void void
racelist_clear(struct race_list **rl) 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; while (rc && !strcmp(rname, rc->_name[0])==0) rc = rc->next;
if (rc->init_familiar!=NULL) {
racelist_insert(&familiarraces, rc);
}
return rc; return rc;
} }

View File

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

View File

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

View File

@ -753,27 +753,12 @@ sp_shadowcall(fighter * fi, int level, double power, spell * sp)
unit *mage = fi->unit; unit *mage = fi->unit;
attrib *a; attrib *a;
int force = (int)(get_force(power, 3)/2); int force = (int)(get_force(power, 3)/2);
const race *rc = NULL;
int num;
unit *u; unit *u;
const char * races[3] = { "shadowbat", "nightmare", "vampunicorn" };
const race *rc = rc_find(races[rand()%3]);
unused(sp); 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 = create_unit(r, mage->faction, force, rc, 0, NULL, mage);
u->status = ST_FIGHT; u->status = ST_FIGHT;

View File

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