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.34 by root, Tue May 6 16:55:25 2008 UTC vs.
Revision 1.35 by root, Sun Aug 31 05:47:14 2008 UTC

1001{ 1001{
1002 int nbr = sizeof (book_descrpt) / sizeof (char *); 1002 int nbr = sizeof (book_descrpt) / sizeof (char *);
1003 1003
1004 switch (book->type) 1004 switch (book->type)
1005 { 1005 {
1006 case BOOK: 1006 case BOOK:
1007 { 1007 {
1008 titlelist *tl = get_titlelist (msgtype); 1008 titlelist *tl = get_titlelist (msgtype);
1009 title *t = NULL; 1009 title *t = NULL;
1010 int tries = 0; 1010 int tries = 0;
1011 1011
1012 /* look to see if our msg already been archived. If so, alter 1012 /* look to see if our msg already been archived. If so, alter
1013 * the book to match the archival text. If we fail to match, 1013 * the book to match the archival text. If we fail to match,
1014 * then we archive the new title/name/msg combo if there is 1014 * then we archive the new title/name/msg combo if there is
1015 * room on the titlelist. 1015 * room on the titlelist.
1016 */ 1016 */
1017 1017
1018 if ((strlen (book->msg) > 5) && (t = find_title (book, msgtype))) 1018 if ((strlen (book->msg) > 5) && (t = find_title (book, msgtype)))
1019 { 1019 {
1020 object *tmpbook;
1021
1022 /* alter book properties */ 1020 /* alter book properties */
1023 if ((tmpbook = get_archetype (t->archname)) != NULL) 1021 if (object *tmpbook = get_archetype (t->archname))
1022 {
1023 tmpbook->msg = book->msg;
1024 tmpbook->copy_to (book);
1025 tmpbook->destroy ();
1026 }
1027
1028 book->title = t->authour;
1029 book->name = t->name;
1030 book->level = t->level;
1031 }
1032 /* Don't have any default title, so lets make up a new one */
1033 else
1034 {
1035 int numb, maxnames = max_titles[msgtype];
1036 const char *old_title;
1037 const char *old_name;
1038
1039 old_title = book->title;
1040 old_name = book->name;
1041
1042 /* some pre-generated books have title already set (from
1043 * maps), also don't bother looking for unique title if
1044 * we already used up all the available names! */
1045
1046 if (!tl)
1047 {
1048 LOG (llevError, "change_book_name(): can't find title list\n");
1049 numb = 0;
1050 }
1051 else
1052 numb = tl->number;
1053
1054 if (numb == maxnames)
1055 {
1056#ifdef ARCHIVE_DEBUG
1057 LOG (llevDebug, "titles for list %d full (%d possible).\n", msgtype, maxnames);
1058#endif
1059 break;
1060 }
1061 /* shouldnt change map-maker books */
1062 else if (!book->title)
1063 do
1024 { 1064 {
1025 tmpbook->msg = book->msg; 1065 /* random book name */
1026 tmpbook->copy_to (book); 1066 new_text_name (book, msgtype);
1027 tmpbook->destroy (); 1067 add_author (book, msgtype); /* random author */
1068 tries++;
1028 } 1069 }
1070 while (!unique_book (book, msgtype) && tries < MAX_TITLE_CHECK);
1029 1071
1030 book->title = t->authour; 1072 /* Now deal with 2 cases.
1031 book->name = t->name; 1073 * 1)If no space for a new title exists lets just restore
1032 book->level = t->level; 1074 * the old book properties. Remember, if the book had
1075 * matchd an older entry on the titlelist, we shouldnt
1076 * have called this routine in the first place!
1077 * 2) If we got a unique title, we need to add it to
1078 * the list.
1033 } 1079 */
1034 /* Don't have any default title, so lets make up a new one */
1035 else
1036 {
1037 int numb, maxnames = max_titles[msgtype];
1038 const char *old_title;
1039 const char *old_name;
1040 1080
1041 old_title = book->title; 1081 if (tries == MAX_TITLE_CHECK || numb == maxnames)
1042 old_name = book->name; 1082 { /* got to check maxnames again */
1043
1044 /* some pre-generated books have title already set (from
1045 * maps), also don't bother looking for unique title if
1046 * we already used up all the available names! */
1047
1048 if (!tl)
1049 {
1050 LOG (llevError, "change_book_name(): can't find title list\n");
1051 numb = 0;
1052 }
1053 else
1054 numb = tl->number;
1055
1056 if (numb == maxnames)
1057 {
1058#ifdef ARCHIVE_DEBUG 1083#ifdef ARCHIVE_DEBUG
1059 LOG (llevDebug, "titles for list %d full (%d possible).\n", msgtype, maxnames); 1084 LOG (llevDebug, "Failed to obtain unique title for %s %s (names:%d/%d)\n", book->name, book->title, numb, maxnames);
1060#endif 1085#endif
1061 break; 1086 /* restore old book properties here */
1062 } 1087 book->title = old_title;
1063 /* shouldnt change map-maker books */ 1088
1064 else if (!book->title) 1089 if (RANDOM () % 4)
1065 do
1066 { 1090 {
1067 /* random book name */ 1091 /* Lets give the book a description to individualize it some */
1068 new_text_name (book, msgtype); 1092 char new_name[MAX_BUF];
1069 add_author (book, msgtype); /* random author */ 1093
1070 tries++; 1094 snprintf (new_name, MAX_BUF, "%s %s", book_descrpt[rndm (nbr)], old_name);
1095
1096 book->name = new_name;
1071 } 1097 }
1072 while (!unique_book (book, msgtype) && tries < MAX_TITLE_CHECK);
1073
1074 /* Now deal with 2 cases.
1075 * 1)If no space for a new title exists lets just restore
1076 * the old book properties. Remember, if the book had
1077 * matchd an older entry on the titlelist, we shouldnt
1078 * have called this routine in the first place!
1079 * 2) If we got a unique title, we need to add it to
1080 * the list.
1081 */
1082
1083 if (tries == MAX_TITLE_CHECK || numb == maxnames)
1084 { /* got to check maxnames again */
1085#ifdef ARCHIVE_DEBUG
1086 LOG (llevDebug, "Failed to obtain unique title for %s %s (names:%d/%d)\n", book->name, book->title, numb, maxnames);
1087#endif
1088 /* restore old book properties here */
1089 book->title = old_title;
1090
1091 if (RANDOM () % 4)
1092 {
1093 /* Lets give the book a description to individualize it some */
1094 char new_name[MAX_BUF];
1095
1096 snprintf (new_name, MAX_BUF, "%s %s", book_descrpt[rndm (nbr)], old_name);
1097
1098 book->name = new_name;
1099 }
1100 else 1098 else
1101 { 1099 {
1102 book->name = old_name; 1100 book->name = old_name;
1103 } 1101 }
1104 } 1102 }
1105 else if (book->title && strlen (book->msg) > 5) 1103 else if (book->title && strlen (book->msg) > 5)
1106 { /* archive if long msg texts */ 1104 { /* archive if long msg texts */
1107 add_book_to_list (book, msgtype); 1105 add_book_to_list (book, msgtype);
1108 } 1106 }
1109 } 1107 }
1110 break; 1108 break;
1111 } 1109 }
1112 1110
1113 default: 1111 default:
1114 LOG (llevError, "change_book_name() called w/ illegal obj type.\n"); 1112 LOG (llevError, "change_book_name() called w/ illegal obj type.\n");
1115 return; 1113 return;
1116 } 1114 }
1117} 1115}
1118 1116
1119/***************************************************************************** 1117/*****************************************************************************
1120 * 1118 *
1890 { 1888 {
1891 book->msg = msgbuf; 1889 book->msg = msgbuf;
1892 /* lets give the "book" a new name, which may be a compound word */ 1890 /* lets give the "book" a new name, which may be a compound word */
1893 change_book (book, msg_type); 1891 change_book (book, msg_type);
1894 } 1892 }
1895
1896} 1893}
1897 1894
1898 1895
1899/***************************************************************************** 1896/*****************************************************************************
1900 * 1897 *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines