ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/readable.C
(Generate patch)

Comparing deliantra/server/common/readable.C (file contents):
Revision 1.38 by root, Sat Dec 27 02:31:19 2008 UTC vs.
Revision 1.42 by sf-marcmagus, Thu Oct 15 16:00:37 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24/* This file contains code relevant to the BOOKS hack -- designed 25/* This file contains code relevant to the BOOKS hack -- designed
817 else 818 else
818 t = t->next; 819 t = t->next;
819 820
820#ifdef ARCHIVE_DEBUG 821#ifdef ARCHIVE_DEBUG
821 if (t) 822 if (t)
822 LOG (llevDebug, "Found title match (list %d): %s %s (%d)\n", msgtype, t->name, t->authour, t->msg_index); 823 LOG (llevDebug, "Found title match (list %d): %s %s (%d)\n", msgtype, &t->name, &t->authour, t->msg_index);
823#endif 824#endif
824 825
825 return t; 826 return t;
826} 827}
827 828
932 */ 933 */
933 934
934static int 935static int
935unique_book (const object *book, int msgtype) 936unique_book (const object *book, int msgtype)
936{ 937{
937 title *test;
938
939 if (!booklist) 938 if (!booklist)
940 return 1; /* No archival entries! Must be unique! */ 939 return 1; /* No archival entries! Must be unique! */
941 940
942 /* Go through the booklist. If the author and name match, not unique so 941 /* Go through the booklist. If the author and name match, not unique so
943 * return 0. 942 * return 0.
944 */ 943 */
945 for (test = get_titlelist (msgtype)->first_book; test; test = test->next) 944 for (title *test = get_titlelist (msgtype)->first_book; test; test = test->next)
946 {
947 if (!strcmp (test->name, book->name) && !strcmp (book->title, test->authour)) 945 if (test->name == book->name && book->title == test->authour)
948 return 0; 946 return 0;
949 } 947
950 return 1; 948 return 1;
951} 949}
952 950
953/* add_book_to_list() */ 951/* add_book_to_list() */
954 952
978 976
979 /* We have stuff we need to write now */ 977 /* We have stuff we need to write now */
980 need_to_write_bookarchive = 1; 978 need_to_write_bookarchive = 1;
981 979
982#ifdef ARCHIVE_DEBUG 980#ifdef ARCHIVE_DEBUG
983 LOG (llevDebug, "Archiving new title: %s %s (%d)\n", book->name, book->title, msgtype); 981 LOG (llevDebug, "Archiving new title: %s %s (%d)\n", &book->name, &book->title, msgtype);
984#endif 982#endif
985 983
986} 984}
987 985
988 986
1054 if (numb == maxnames) 1052 if (numb == maxnames)
1055 { 1053 {
1056#ifdef ARCHIVE_DEBUG 1054#ifdef ARCHIVE_DEBUG
1057 LOG (llevDebug, "titles for list %d full (%d possible).\n", msgtype, maxnames); 1055 LOG (llevDebug, "titles for list %d full (%d possible).\n", msgtype, maxnames);
1058#endif 1056#endif
1059 break;
1060 } 1057 }
1061 /* shouldnt change map-maker books */ 1058 /* shouldnt change map-maker books */
1062 else if (!book->title) 1059 else if (!book->title)
1063 do 1060 do
1064 { 1061 {
1079 */ 1076 */
1080 1077
1081 if (tries == MAX_TITLE_CHECK || numb == maxnames) 1078 if (tries == MAX_TITLE_CHECK || numb == maxnames)
1082 { /* got to check maxnames again */ 1079 { /* got to check maxnames again */
1083#ifdef ARCHIVE_DEBUG 1080#ifdef ARCHIVE_DEBUG
1084 LOG (llevDebug, "Failed to obtain unique title for %s %s (names:%d/%d)\n", book->name, book->title, numb, maxnames); 1081 LOG (llevDebug, "Failed to obtain unique title for %s %s (names:%d/%d)\n", &book->name, &book->title, numb, maxnames);
1085#endif 1082#endif
1086 /* restore old book properties here */ 1083 /* restore old book properties here */
1087 book->title = old_title; 1084 book->title = old_title;
1088 1085
1089 if (rndm (4)) 1086 if (rndm (4))
1273 /* Note that the value this returns is not based on level */ 1270 /* Note that the value this returns is not based on level */
1274 tmp = get_next_mon (tmp); 1271 tmp = get_next_mon (tmp);
1275 } 1272 }
1276 1273
1277#ifdef BOOK_MSG_DEBUG 1274#ifdef BOOK_MSG_DEBUG
1278 LOG (llevDebug, "\n mon_info_msg() created strng: %d\n", strlen (retbuf)); 1275 LOG (llevDebug, "\n mon_info_msg() created string: %d\n", strlen (retbuf));
1279 fprintf (logfile, " MADE THIS:\n%s\n", retbuf); 1276 LOG (llevDebug, " MADE THIS:\n%s\n", retbuf);
1280#endif 1277#endif
1281 1278
1282 return retbuf; 1279 return retbuf;
1283} 1280}
1284 1281
1352 1349
1353 /* separator of items */ 1350 /* separator of items */
1354 strcpy (buf, "--- \n"); 1351 strcpy (buf, "--- \n");
1355 1352
1356 /* Name */ 1353 /* Name */
1357 if (art->allowed != NULL && strcmp (art->allowed->name, "All")) 1354 if (art->allowed && art->allowed->name != shstr_All)
1358 { 1355 {
1359 linked_char *temp, *next = art->allowed; 1356 linked_char *temp, *next = art->allowed;
1360 1357
1361 do 1358 do
1362 { 1359 {
1408 art = art->next; 1405 art = art->next;
1409 book_entries--; 1406 book_entries--;
1410 } 1407 }
1411 1408
1412#ifdef BOOK_MSG_DEBUG 1409#ifdef BOOK_MSG_DEBUG
1413 LOG (llevDebug, "artifact_msg() created strng: %d\n", strlen (retbuf)); 1410 LOG (llevDebug, "artifact_msg() created string: %d\n", strlen (retbuf));
1414 fprintf (logfile, " MADE THIS:\n%s", retbuf); 1411 LOG (llevDebug, " MADE THIS:\n%s", retbuf);
1415#endif 1412#endif
1416 return retbuf; 1413 return retbuf;
1417} 1414}
1418 1415
1419/***************************************************************************** 1416/*****************************************************************************
1475 } 1472 }
1476 else 1473 else
1477 { 1474 {
1478 strcat (retbuf, "\n"); 1475 strcat (retbuf, "\n");
1479 } 1476 }
1477
1478#ifdef BOOK_MSG_DEBUG
1479 LOG (llevDebug, "spellpath_msg() created string: %d\n", strlen (retbuf));
1480 LOG (llevDebug, " MADE THIS:\n%s", retbuf);
1481#endif
1480 return retbuf; 1482 return retbuf;
1481} 1483}
1482 1484
1483/* formula_msg() - generate a message detailing the properties 1485/* formula_msg() - generate a message detailing the properties
1484 * of a randomly selected alchemical formula. 1486 * of a randomly selected alchemical formula.
1539 op_name = at->object::name; 1541 op_name = at->object::name;
1540 else 1542 else
1541 LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name); 1543 LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name);
1542 1544
1543 /* item name */ 1545 /* item name */
1544 if (strcmp (formula->title, "NONE")) 1546 if (formula->title != shstr_NONE)
1545 { 1547 {
1546 sprintf (retbuf, "%sThe %s of %s", retbuf, op_name, &formula->title); 1548 sprintf (retbuf, "%sThe %s of %s", retbuf, op_name, &formula->title);
1547 /* This results in things like pile of philo. sulfur. 1549 /* This results in things like pile of philo. sulfur.
1548 * while philo. sulfur may look better, without this, 1550 * while philo. sulfur may look better, without this,
1549 * you get things like 'the wise' because its missing the 1551 * you get things like 'the wise' because its missing the
1562 strcat (retbuf, at->title); 1564 strcat (retbuf, at->title);
1563 strcat (title, " "); 1565 strcat (title, " ");
1564 strcat (title, at->title); 1566 strcat (title, at->title);
1565 } 1567 }
1566 } 1568 }
1569
1567 /* Lets name the book something meaningful ! */ 1570 /* Lets name the book something meaningful ! */
1568 book->name = title; 1571 book->name = title;
1569 book->title = NULL; 1572 book->title = NULL;
1570 1573
1571 /* ingredients to make it */ 1574 /* ingredients to make it */
1807 { /* we got no information beyond the preamble! */ 1810 { /* we got no information beyond the preamble! */
1808 strcat (retbuf, " [Unfortunately the rest of the information is\n"); 1811 strcat (retbuf, " [Unfortunately the rest of the information is\n");
1809 strcat (retbuf, " hopelessly garbled!]\n ---\n"); 1812 strcat (retbuf, " hopelessly garbled!]\n ---\n");
1810 } 1813 }
1811#ifdef BOOK_MSG_DEBUG 1814#ifdef BOOK_MSG_DEBUG
1812 LOG (llevDebug, "\n god_info_msg() created strng: %d\n", strlen (retbuf)); 1815 LOG (llevDebug, "\n god_info_msg() created string: %d\n", strlen (retbuf));
1813 fprintf (logfile, " MADE THIS:\n%s", retbuf); 1816 LOG (llevDebug, " MADE THIS:\n%s", retbuf);
1814#endif 1817#endif
1815 return retbuf; 1818 return retbuf;
1816} 1819}
1817 1820
1818/* tailor_readable_ob()- The main routine. This chooses a random 1821/* tailor_readable_ob()- The main routine. This chooses a random

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines