--- deliantra/server/common/readable.C 2007/01/15 21:06:18 1.18 +++ deliantra/server/common/readable.C 2007/03/18 03:05:39 1.22 @@ -190,7 +190,7 @@ {"Boots", BOOTS}, {"Cloak", CLOAK}, {"Gloves", GLOVES}, - {"Gridle", GIRDLE}, + {"Girdle", GIRDLE}, {"Ring", RING}, {"Horn", HORN}, {"Missile Weapon", BOW}, @@ -921,39 +921,39 @@ switch (msgtype) { - case 1: /*monster */ - nbr = sizeof (mon_book_name) / sizeof (char *); - strcpy (name, mon_book_name[RANDOM () % nbr]); - break; - case 2: /*artifact */ - nbr = sizeof (art_book_name) / sizeof (char *); - strcpy (name, art_book_name[RANDOM () % nbr]); - break; - case 3: /*spellpath */ - nbr = sizeof (path_book_name) / sizeof (char *); - strcpy (name, path_book_name[RANDOM () % nbr]); - break; - case 4: /*alchemy */ - nbr = sizeof (formula_book_name) / sizeof (char *); - strcpy (name, formula_book_name[RANDOM () % nbr]); - break; - case 5: /*gods */ - nbr = sizeof (gods_book_name) / sizeof (char *); - strcpy (name, gods_book_name[RANDOM () % nbr]); - break; - case 6: /*msg file */ - default: - if (book->weight > 2000) - { /* based on weight */ - nbr = sizeof (heavy_book_name) / sizeof (char *); - strcpy (name, heavy_book_name[RANDOM () % nbr]); - } - else if (book->weight < 2001) - { - nbr = sizeof (light_book_name) / sizeof (char *); - strcpy (name, light_book_name[RANDOM () % nbr]); - } - break; + case 1: /*monster */ + nbr = sizeof (mon_book_name) / sizeof (char *); + assign (name, mon_book_name[rndm (nbr)]); + break; + case 2: /*artifact */ + nbr = sizeof (art_book_name) / sizeof (char *); + assign (name, art_book_name[rndm (nbr)]); + break; + case 3: /*spellpath */ + nbr = sizeof (path_book_name) / sizeof (char *); + assign (name, path_book_name[rndm (nbr)]); + break; + case 4: /*alchemy */ + nbr = sizeof (formula_book_name) / sizeof (char *); + assign (name, formula_book_name[rndm (nbr)]); + break; + case 5: /*gods */ + nbr = sizeof (gods_book_name) / sizeof (char *); + assign (name, gods_book_name[rndm (nbr)]); + break; + case 6: /*msg file */ + default: + if (book->weight > 2000) + { /* based on weight */ + nbr = sizeof (heavy_book_name) / sizeof (char *); + assign (name, heavy_book_name[rndm (nbr)]); + } + else if (book->weight < 2001) + { + nbr = sizeof (light_book_name) / sizeof (char *); + assign (name, light_book_name[rndm (nbr)]); + } + break; } book->name = name; @@ -975,29 +975,29 @@ switch (msgtype) { - case 1: /* monster */ - nbr = sizeof (mon_author) / sizeof (char *); - strcpy (name, mon_author[RANDOM () % nbr]); - break; - case 2: /* artifacts */ - nbr = sizeof (art_author) / sizeof (char *); - strcpy (name, art_author[RANDOM () % nbr]); - break; - case 3: /* spellpath */ - nbr = sizeof (path_author) / sizeof (char *); - strcpy (name, path_author[RANDOM () % nbr]); - break; - case 4: /* alchemy */ - nbr = sizeof (formula_author) / sizeof (char *); - strcpy (name, formula_author[RANDOM () % nbr]); - break; - case 5: /* gods */ - nbr = sizeof (gods_author) / sizeof (char *); - strcpy (name, gods_author[RANDOM () % nbr]); - break; - case 6: /* msg file */ - default: - strcpy (name, book_author[RANDOM () % nbr]); + case 1: /* monster */ + nbr = sizeof (mon_author) / sizeof (char *); + assign (name, mon_author[rndm (nbr)]); + break; + case 2: /* artifacts */ + nbr = sizeof (art_author) / sizeof (char *); + assign (name, art_author[rndm (nbr)]); + break; + case 3: /* spellpath */ + nbr = sizeof (path_author) / sizeof (char *); + assign (name, path_author[rndm (nbr)]); + break; + case 4: /* alchemy */ + nbr = sizeof (formula_author) / sizeof (char *); + assign (name, formula_author[rndm (nbr)]); + break; + case 5: /* gods */ + nbr = sizeof (gods_author) / sizeof (char *); + assign (name, gods_author[rndm (nbr)]); + break; + case 6: /* msg file */ + default: + assign (name, book_author[rndm (nbr)]); } sprintf (title, "of %s", name); @@ -1171,7 +1171,7 @@ /* Lets give the book a description to individualize it some */ char new_name[MAX_BUF]; - snprintf (new_name, MAX_BUF, "%s %s", book_descrpt[RANDOM () % nbr], old_name); + snprintf (new_name, MAX_BUF, "%s %s", book_descrpt[rndm (nbr)], old_name); book->name = new_name; } @@ -1370,15 +1370,15 @@ /* artifact_msg() - generate a message detailing the properties * of 1-6 artifacts drawn sequentially from the artifact list. */ - -char * +const char * artifact_msg (int level, int booksize) { artifactlist *al = NULL; artifact *art; int chance, i, type, index; int book_entries = level > 5 ? RANDOM () % 3 + RANDOM () % 3 + 2 : RANDOM () % level + 1; - char *ch, name[MAX_BUF], buf[BOOK_BUF], sbuf[MAX_BUF]; + const char *ch; + char name[MAX_BUF], buf[BOOK_BUF], sbuf[MAX_BUF]; static char retbuf[BOOK_BUF]; object *tmp = NULL; @@ -1402,7 +1402,7 @@ while ((al == NULL) && (i < 10)); if (i == 10) /* Unable to find a message */ - return ("None"); + return "None"; /* There is no reason to start on the artifact list at the begining. Lets * take our starting position randomly... */ @@ -1415,7 +1415,7 @@ } /* the base 'generic' name for our artifact */ - strcpy (name, art_name_array[index].name); + assign (name, art_name_array[index].name); /* Ok, lets print out the contents */ sprintf (retbuf, "Herein %s detailed %s...\n", book_entries > 1 ? "are" : "is", book_entries > 1 ? "some artifacts" : "an artifact"); @@ -1529,7 +1529,7 @@ if (at->clone.type == SPELL && at->clone.path_attuned & pnum && ((at->clone.stats.grace && prayers) || (at->clone.stats.sp && !prayers)) && (at->clone.level < (level * 8))) { - strcpy (tmpbuf, at->clone.name); + assign (tmpbuf, at->clone.name); if (book_overflow (retbuf, tmpbuf, booksize)) break; @@ -1697,7 +1697,7 @@ } if (msg && !book_overflow (retbuf, msg->name, booksize)) - strcpy (retbuf, msg->name); + assign (retbuf, msg->name); else sprintf (retbuf, "\n "); @@ -1709,11 +1709,9 @@ return retbuf; } - /* god_info_msg() - generate a message detailing the properties * of a random god. Used by the book hack. b.t. */ - const char * god_info_msg (int level, int booksize) { @@ -1759,6 +1757,7 @@ if (enemy) sprintf (buf, "The gods %s and %s are enemies.\n ---\n", name, enemy); } + if (level == 3 && RANDOM () % 2) { /* enemy race, what the god's holy word effects */ const char *enemy = god->slaying; @@ -1777,13 +1776,12 @@ sprintf (buf, "%s%s\n ---\n", buf, tmpbuf); } } + if (level == 4 && RANDOM () % 2) { /* Priest of god gets these protect,vulnerable... */ - char tmpbuf[MAX_BUF], *cp; - - cp = describe_resistance (god, 1); + char tmpbuf[MAX_BUF]; - if (*cp) + if (const char *cp = describe_resistance (god, 1)) { /* This god does have protections */ sprintf (tmpbuf, "%s has a potent aura which is extended\n", name); strcat (tmpbuf, "faithful priests. The effects of this aura include:\n"); @@ -1794,6 +1792,7 @@ else sprintf (buf, " "); } + if (level == 5 && RANDOM () % 2) { /* aligned race, summoning */ const char *race = god->race; /* aligned race */ @@ -1811,13 +1810,12 @@ sprintf (buf, "%s%s\n ---\n", buf, tmpbuf); } } + if (level == 6 && RANDOM () % 2) { /* blessing,curse properties of the god */ - char tmpbuf[MAX_BUF], *cp; - - cp = describe_resistance (god, 1); + char tmpbuf[MAX_BUF]; - if (*cp) + if (const char *cp = describe_resistance (god, 1)) { /* This god does have protections */ sprintf (tmpbuf, "\nThe priests of %s are known to be able to \n", name); strcat (tmpbuf, "bestow a blessing which makes the recipient\n"); @@ -1829,6 +1827,7 @@ sprintf (buf, " "); } + if (level == 8 && RANDOM () % 2) { /* immunity, holy possession */ int has_effect = 0, tmpvar; @@ -1847,6 +1846,7 @@ sprintf (tmpbuf + strlen (tmpbuf), "Immunity to %s", attacktype_desc[tmpvar]); } } + if (has_effect) { strcat (buf, tmpbuf); @@ -1855,6 +1855,7 @@ else sprintf (buf, " "); } + if (level == 12 && RANDOM () % 2) { /* spell paths */ int has_effect = 0, tmpvar; @@ -1863,21 +1864,25 @@ sprintf (tmpbuf, "\n"); sprintf (tmpbuf, "It is rarely known fact that the priests of %s\n", name); strcat (tmpbuf, "are mystically transformed. Effects of this include:\n"); + if ((tmpvar = god->path_attuned)) { has_effect = 1; DESCRIBE_PATH (tmpbuf, tmpvar, "Attuned"); } + if ((tmpvar = god->path_repelled)) { has_effect = 1; DESCRIBE_PATH (tmpbuf, tmpvar, "Repelled"); } + if ((tmpvar = god->path_denied)) { has_effect = 1; DESCRIBE_PATH (tmpbuf, tmpvar, "Denied"); } + if (has_effect) { strcat (buf, tmpbuf); @@ -1895,8 +1900,10 @@ break; else if (strlen (buf) > 1) strcat (retbuf, buf); + level--; } + if (strlen (retbuf) == introlen) { /* we got no information beyond the preamble! */ strcat (retbuf, " [Unfortunately the rest of the information is\n");