version 1.20 | | version 1.21 |
---|
| | |
/* | | /* |
* static char *rcsid_readable_c = | | * static char *rcsid_readable_c = |
* "$Id: readable.c,v 1.20 2005/08/12 08:18:59 ryo_saeba Exp $"; | | * "$Id: readable.c,v 1.21 2005/08/12 13:46:34 ryo_saeba Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
/* 'title' and 'titlelist' are used by the readable code */ | | /* 'title' and 'titlelist' are used by the readable code */ |
typedef struct titlestruct { | | typedef struct titlestruct { |
char *name; /* the name of the book */ | | const char *name; /* the name of the book */ |
char *authour; /* the name of the book authour */ | | const char *authour; /* the name of the book authour */ |
char *archname; /* the archetype name of the book */ | | const char *archname; /* the archetype name of the book */ |
int level; /* level of difficulty of this message */ | | int level; /* level of difficulty of this message */ |
int size; /* size of the book message */ | | int size; /* size of the book message */ |
int msg_index; /* an index value derived from book message */ | | int msg_index; /* an index value derived from book message */ |
| | |
*/ | | */ |
| | |
int | | int |
nstrtok (char *buf1, char *buf2) | | nstrtok (const char *buf1, const char *buf2) |
{ | | { |
char *tbuf, sbuf[12], buf[MAX_BUF]; | | char *tbuf, sbuf[12], buf[MAX_BUF]; |
int number = 0; | | int number = 0; |
| | |
*/ | | */ |
| | |
char * | | char * |
strtoktolin (char *buf1, char *buf2) | | strtoktolin (const char *buf1, const char *buf2) |
{ | | { |
int maxi, i = nstrtok (buf1, buf2); | | int maxi, i = nstrtok (buf1, buf2); |
char *tbuf, buf[MAX_BUF], sbuf[12]; | | char *tbuf, buf[MAX_BUF], sbuf[12]; |
| | |
else | | else |
{ | | { |
int numb, maxnames = max_titles[msgtype]; | | int numb, maxnames = max_titles[msgtype]; |
char *old_title; | | const char *old_title; |
char *old_name; | | const char *old_name; |
| | |
old_title = book->title ? add_string(book->title) : NULL; | | old_title = book->title ? add_string(book->title) : NULL; |
old_name = add_string(book->name); | | old_name = add_string(book->name); |
| | |
*/ | | */ |
| | |
void make_formula_book(object *book, int level) { | | void make_formula_book(object *book, int level) { |
char retbuf[BOOK_BUF], title[MAX_BUF]; | | char retbuf[BOOK_BUF], title[MAX_BUF], *dup = NULL; |
recipelist *fl; | | recipelist *fl; |
recipe *formula = NULL; | | recipe *formula = NULL; |
int chance; | | int chance; |
| | |
* of information on the booklevel and the spellevel | | * of information on the booklevel and the spellevel |
* of the formula. */ | | * of the formula. */ |
| | |
char *op_name = NULL; | | const char *op_name = NULL; |
archetype *at; | | archetype *at; |
int nindex = nstrtok (formula->arch_name, ","); | | int nindex = nstrtok (formula->arch_name, ","); |
| | |
| | |
if (nindex > 1) | | if (nindex > 1) |
{ | | { |
int rnum = RANDOM () % nindex; | | int rnum = RANDOM () % nindex; |
op_name = strtok (formula->arch_name, ","); | | dup = strdup_local(formula->arch_name); |
| | op_name = strtok (dup, ","); |
while (rnum) | | while (rnum) |
{ | | { |
op_name = strtok (NULL, ","); | | op_name = strtok (NULL, ","); |
| | |
if (book->msg) free_string(book->msg); | | if (book->msg) free_string(book->msg); |
book->msg = add_string(retbuf); | | book->msg = add_string(retbuf); |
} | | } |
| | free(dup); |
} | | } |
| | |
| | |
| | |
* of a random god. Used by the book hack. b.t. | | * of a random god. Used by the book hack. b.t. |
*/ | | */ |
| | |
char * | | const char * |
god_info_msg (int level, int booksize) | | god_info_msg (int level, int booksize) |
{ | | { |
static char retbuf[BOOK_BUF]; | | static char retbuf[BOOK_BUF]; |
char *name = NULL, buf[BOOK_BUF]; | | const char *name = NULL; |
| | char buf[BOOK_BUF]; |
int i, introlen; | | int i, introlen; |
object *god = pntr_to_god_obj (get_rand_god ()); | | object *god = pntr_to_god_obj (get_rand_god ()); |
| | |
| | |
sprintf (buf, " "); | | sprintf (buf, " "); |
if (level == 2 && RANDOM () % 2) | | if (level == 2 && RANDOM () % 2) |
{ /* enemy god */ | | { /* enemy god */ |
char *enemy = god->title; | | const char *enemy = god->title; |
if (enemy) | | if (enemy) |
sprintf (buf, "The gods %s and %s are enemies.\n ---\n", | | sprintf (buf, "The gods %s and %s are enemies.\n ---\n", |
name, enemy); | | name, enemy); |
} | | } |
if (level == 3 && RANDOM () % 2) | | if (level == 3 && RANDOM () % 2) |
{ /* enemy race, what the god's holy word effects */ | | { /* enemy race, what the god's holy word effects */ |
char *enemy = god->slaying; | | const char *enemy = god->slaying; |
if (enemy && !(god->path_denied & PATH_TURNING)) | | if (enemy && !(god->path_denied & PATH_TURNING)) |
if ((i = nstrtok (enemy, ",")) > 0) | | if ((i = nstrtok (enemy, ",")) > 0) |
{ | | { |
| | |
} | | } |
if (level == 5 && RANDOM () % 2) | | if (level == 5 && RANDOM () % 2) |
{ /* aligned race, summoning */ | | { /* aligned race, summoning */ |
char *race = god->race; /* aligned race */ | | const char *race = god->race; /* aligned race */ |
if (race && !(god->path_denied & PATH_SUMMON)) | | if (race && !(god->path_denied & PATH_SUMMON)) |
if ((i = nstrtok (race, ",")) > 0) | | if ((i = nstrtok (race, ",")) > 0) |
{ | | { |