I have several questions for all of you. Since my mud will not dump a core, I have to do things by hand (which really sucks). So here are my questions: Is this correct to find out the character that is second in the arg string? or should I use *(arg+1)? switch (LOWER(*arg+1)) { Why will this appear to work, but when the character enters the game, crash it? Only strdup seems to work reliably, any ideas why? case CON_QDESCR: switch (*arg) { case '0': if (!short_char) strcpy(d->character->player.xtra_descr, player_room_descs[0]); else strcpy(d->character->player.xtra_descr, player_room_descs[1]); break; case '1': if (!weak_char) strcpy(d->character->player.xtra_descr, player_room_descs[2]); else strcpy(d->character->player.xtra_descr, player_room_descs[3]); break; case '2': if (!weakminded_char) strcpy(d->character->player.xtra_descr, player_room_descs[4]); else strcpy(d->character->player.xtra_descr, player_room_descs[5]); break; case '3': if (!ugly_char) { if (d->character->player.sex == SEX_MALE) strcpy(d->character->player.xtra_descr, player_room_descs[7]); else strcpy(d->character->player.xtra_descr, player_room_descs[6]); } else strcpy(d->character->player.xtra_descr, player_room_descs[8]); break; case '4': if (!wimpy_char) d->character->player.xtra_descr = strdup(player_room_descs[9]); else d->character->player.xtra_descr = strdup(player_room_descs[10]); break; default: SEND_TO_Q("That is not a valid choice!\r\n" "You must pick a number: ", d); d->character->player.xtra_descr = '\0'; return; break; } strcat(d->character->player.xtra_descr, racetypebuf); /* The characters race name */ strcat(d->character->player.xtra_descr, '\0'); /* Should '\0' be "\0"? */ This also crashes the game when it tries to send it to the player. I make sure in interpre.c (before it sends the motd) to check if the player has color on. void colorlogin(struct descriptor_data *d) { char buf[250]; sprintf(buf,"%sWelcome to The Dominion!\r\n%s", CCYOB(d->character, C_SPR), CCNRM(d->character, C_SPR)); SEND_TO_Q(buf, d); /* Once I can figure out the number of block characters and other */ /* graphical chars, this will be different.... */ SEND_TO_Q("Press RETURN for the Message of the Day.\r\n", d); } Now for the trickiest part of all. This will crash the game if a character moves anywhere. I think it's because the character's xtra_descr is NULL, but I dont see how when I just copied it in interpre.c (see above). (utils.h) #define GET_CHAR_RDESC(ch) (IS_NPC(ch) ? \ (ch)->player.short_descr : \ ((ch)->player.xtra_descr != NULL ? \ (ch)->player.xtra_descr) : \ GET_NAME(ch))) /* If the GET_NAME part wasn't there, it would crash each time a player moved */ /* If this macro worked it would be 'A(n) <variable> <racename>' is standing here */ (act.move.c) if ((!IS_AFFECTED(ch, AFF_SNEAK) || !RIDDEN(ch) || !SHADOWING(ch)) && GET_COND(ch, DRUNK) < 2){ if (MOUNTED(ch)) sprintf(buf2, "%s has arrived riding on %s.", GET_CHAR_RDESC(ch), GET_NAME(mount)); else sprintf(buf2, "%s has arrived.", GET_CHAR_RDESC(ch)); act(buf2, TRUE, ch, 0, 0, TO_ROOM); } if (GET_COND(ch, DRUNK) >= 3) { sprintf(buf2, "%s stumbles into the room.", (IS_NPC(ch) ? "$n" : GET_CHAR_RDESC(ch))); act(buf2, TRUE, ch, 0, 0, TO_ROOM); } (act.info.c) list_one_char() if (IS_NPC(i)) { strcpy(buf, i->player.short_descr); CAP(buf); } else sprintf(buf, "%s", GET_CHAR_RDESC(i)); /* So we don't show the player's name in the room, just what they look like */ And just to be thorough, here's the array that holds the 1st part of the descriptions. (changes.c) const char *player_room_descs[] = { "A large ", /* rbuf1 */ "A short ", /* rbuf2 */ "A stout ", /* rbuf3 */ "A gaunt ", /* rbuf4 */ "A worldly ", /* rbuf5 */ "An absent-minded ", /* rbuf6 */ "A beautiful ", /* rbuf7 */ "A handsome ", /* rbuf8 */ "An ugly ", /* rbuf9 */ "A brawny ", /* rbuf10 */ "A weak ", /* rbuf11 */ "\n" }; I would greatly appreciate any help anyone could offer. Feel free to use this code in your mud, but if you do, and you get it to work, please let me know what I'm doing wrong. Thanks, - Sean Mountcastle
This archive was generated by hypermail 2b30 : 12/07/00 PST