Hi Worked on a flexible title command so that you can have pretitles. Made it so you would set your title like this title Sir * the Valiant Knight This will resolve into Sir Playername the Valiant Knight. It works sweetly actually, but then i wanted to add a check that insured that the asteriks was in the title somewhere. When the asteriks is found no problems, when no asterisk it goes through the if and sets it. It even prompts me that it has the set the title, but then it's chrashes. it hangs like some sort of endless loop. Gdb output is. Program received signal SIGSEGV, segmentation fault. 0x400cf177 in malloc() from /lib/libc.so.6 What wrong ??? The set_title snippet is supplied below. ## START SNIPPET ## void set_title(struct char_data * ch, char *title) { const char *i = NULL; char lbuf[MAX_STRING_LENGTH], *buf, *retitle; bool found = FALSE; buf = lbuf; if (title == NULL && !PLR_FLAGGED(ch, PLR_ROLLED)) { if (GET_SEX(ch) == SEX_FEMALE) title = title_female(GET_RACE(ch), GET_LEVEL(ch)); else title = title_male(GET_RACE(ch), GET_LEVEL(ch)); } if (strlen(title) > MAX_TITLE_LENGTH) title[MAX_TITLE_LENGTH] = '\0'; if (GET_TITLE(ch) != NULL) free(GET_TITLE(ch)); for (;;) { if (*title == '*') { found = TRUE; i = GET_NAME(ch); while ((*buf = *(i++))) buf++; title++; } else if (!(*(buf++) = *(title++))) break; } *(--buf) = '\0'; /* if no asteriks (*) found reset title */ if (!found) { if (GET_SEX(ch) == SEX_FEMALE) { retitle = title_female(GET_RACE(ch), GET_LEVEL(ch)); } else { retitle = title_male(GET_RACE(ch), GET_LEVEL(ch)); } send_to_char("Title has to contain the (*) asterisk sign to be valid!\r\n" "Title reset to default.\r\n", ch); set_title(ch, retitle); return; } GET_TITLE(ch) = str_dup(lbuf); sprintf(buf2, "Okay, you're now %s.\r\n", GET_TITLE(ch)); send_to_char(buf2, ch); } ## STOP SNIPPET ## Thanks in advance Christian -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT