--- deliantra/server/common/readable.C 2009/10/15 22:50:41 1.45 +++ deliantra/server/common/readable.C 2009/10/15 23:02:28 1.46 @@ -1442,11 +1442,13 @@ static void make_formula_book (object *book, int level) { - char retbuf[BOOK_BUF], title[MAX_BUF]; + char title[MAX_BUF]; recipelist *fl; recipe *formula = NULL; int chance; + static dynbuf_text buf; buf.clear (); + /* the higher the book level, the more complex (ie number of * ingredients) the formula can be. */ @@ -1468,6 +1470,7 @@ for (formula = fl->items; formula; formula = formula->next) { chance -= formula->chance; + if (chance <= 0) break; } @@ -1477,78 +1480,75 @@ book->msg = "\n"; new_text_name (book, 4); add_author (book, 4); - + return; } - else - { - /* looks like a formula was found. Base the amount - * of information on the booklevel and the spellevel - * of the formula. */ - const char *op_name = formula->arch_name [rndm (formula->arch_names)]; - archetype *at; + /* looks like a formula was found. Base the amount + * of information on the booklevel and the spellevel + * of the formula. */ + + const char *op_name = formula->arch_name [rndm (formula->arch_names)]; + archetype *at; + + /* preamble */ + buf << "Herein is described a project using B<< " + << (formula->skill ? &formula->skill : "an unknown skill") + << " >>:\n\n"; - /* preamble */ - sprintf (retbuf, "Herein is described a project using %s: \n", formula->skill ? &formula->skill : "an unknown skill"); + if ((at = archetype::find (op_name))) + op_name = at->object::name; + else + LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name); - if ((at = archetype::find (op_name)) != (archetype *) NULL) - op_name = at->object::name; - else - LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name); + /* item name */ + if (formula->title != shstr_NONE) + { + buf.printf ("The B<< %s of %s >>", op_name, &formula->title); + /* This results in things like pile of philo. sulfur. + * while philo. sulfur may look better, without this, + * you get things like 'the wise' because its missing the + * water of section. + */ + sprintf (title, "%s: %s of %s", + formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name, &formula->title); + } + else + { + buf << "The B<< " << op_name; - /* item name */ - if (formula->title != shstr_NONE) + sprintf (title, "%s: %s", formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name); + if (at->title) { - sprintf (retbuf, "%sThe %s of %s", retbuf, op_name, &formula->title); - /* This results in things like pile of philo. sulfur. - * while philo. sulfur may look better, without this, - * you get things like 'the wise' because its missing the - * water of section. - */ - sprintf (title, "%s: %s of %s", - formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name, &formula->title); - } - else - { - sprintf (retbuf, "%sThe %s", retbuf, op_name); - sprintf (title, "%s: %s", formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name); - if (at->title) - { - strcat (retbuf, " "); - strcat (retbuf, at->title); - strcat (title, " "); - strcat (title, at->title); - } + buf << " " << at->title; + strcat (title, " "); + strcat (title, at->title); } - /* Lets name the book something meaningful ! */ - book->name = title; - book->title = NULL; + buf << " >>"; + } - /* ingredients to make it */ - if (formula->ingred != NULL) - { - linked_char *next; - archetype *at; + /* Lets name the book something meaningful ! */ + book->name = title; + book->title = NULL; - at = archetype::find (formula->cauldron); + /* ingredients to make it */ + if (formula->ingred) + { + linked_char *next; + archetype *at; - sprintf (retbuf + strlen (retbuf), - " may be made at %s using the following ingredients:\n", at ? query_name (at) : "an unknown place"); + at = archetype::find (formula->cauldron); - for (next = formula->ingred; next != NULL; next = next->next) - { - strcat (retbuf, next->name); - strcat (retbuf, "\n"); - } - } - else - LOG (llevError, "formula_msg() no ingredient list for object %s of %s\n", op_name, &formula->title); - if (retbuf[strlen (retbuf) - 1] != '\n') - strcat (retbuf, "\n"); + buf.printf (" may be made at %s using the following ingredients:\n\n", + at ? query_name (at) : "an appropriate place"); - book->msg = retbuf; + for (next = formula->ingred; next; next = next->next) + buf << next->name << '\r'; } + else + LOG (llevError, "formula_msg() no ingredient list for object %s of %s\n", op_name, &formula->title); + + book->msg = buf; } #define DESCRIBE_PATH(retbuf, variable, name) \ @@ -1817,7 +1817,7 @@ * 4) you may want separate authour/book name arrays in read.h */ msg_type = msg_type > 0 ? msg_type : rndm (8); - switch (msg_type*0+2)//D + switch (msg_type*0+4)//D { case 1: /* monster attrib */ strcpy (msgbuf, mon_info_msg (level, book_buf_size));