I got the board code from the ftp site, and I'm having a small problem with it. I tried to adapt it to the new style bpl16 code, but whenever you type anything in the same room as the board, the mud crashes, with this in the syslog: SYSERR: malloc failure: Cannot allocate memory What could the problem be? --BEGIN CHANGES-- in void init_boards(void) . . } Board_load_board(i); } ACMD_READ = find_command("read"); ACMD_WRITE = find_command("write"); ACMD_REMOVE = find_command("remove"); ACMD_LOOK = find_command("look"); ACMD_EXAMINE = find_command("examine"); + ACMD_RESPOND = find_command("respond"); if (fatal_error) . . in SPECIAL(gen_board) { . . } if (!ch->desc) return (0); if (cmd != ACMD_WRITE && cmd != ACMD_LOOK && cmd != ACMD_EXAMINE && ++ cmd != ACMD_READ && cmd != ACMD_REMOVE && cmd != ACMD_RESPOND) return (0); if ((board_type = find_board(ch)) == -1) { log("SYSERR: degenerate board! (what the hell...)"); return (0); } if (cmd == ACMD_WRITE) return (Board_write_message(board_type, ch, argument, board)); + else if (cmd == ACMD_RESPOND) + return (Board_respond_message(board_type, ch, argument, board)); else if (cmd == ACMD_LOOK || cmd == ACMD_EXAMINE) return (Board_show_board(board_type, ch, argument, board)); in Board_show_board . . for (i = 0; i < num_of_msgs[board_type]; i++) #endif { if (MSG_HEADING(board_type, i)) { + if(MSG_REPLY(board_type, i) == -1) + Board_display_response(board_type, i, buf); } else { log("SYSERR: The board is fubar'd."); send_to_char("Sorry, the board isn't working.\r\n", ch); return (1); . . void Board_display_response(int board_type, int slot_num, char *output) { int k; char buf[MAX_STRING_LENGTH]; sprintf(buf, "%-2d : %s\r\n", slot_num + 1, MSG_HEADING(board_type, slot_num)); strcat(output, buf); for (k = slot_num; k < num_of_msgs[board_type]; k++) if (MSG_REPLY(board_type, k) == slot_num) Board_display_response(board_type, k, output); } int Board_respond_message(int board_type, struct char_data * ch, char *arg, struct obj_data *board) { char *tmstr; int len, msg, ind; time_t ct; char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH]; char number[MAX_STRING_LENGTH]; one_argument(arg, number); if (GET_LEVEL(ch) < WRITE_LVL(board_type)) { send_to_char("You are not holy enough to write on this board.\r\n", ch); return (1); } if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) { send_to_char("The board is full.\r\n", ch); return (1); } if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) { send_to_char("The board is malfunctioning - sorry.\r\n", ch); log("SYSERR: Board: failed to find empty slot on write."); return (1); } if(!*number) { send_to_char("You must respond to something!\r\n", ch); return(1); } if(!isdigit(*number) || (!(msg = atoi(number)))) { send_to_char("What are you trying to respond to?\r\n", ch); return(1); } if(GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char("You try but fail to understand the holy words.\r\n", ch); return(1); } if(msg < 1 || msg > num_of_msgs[board_type]) { send_to_char("That message exists only in your imagination.\r\n", ch); return(1); } ind = msg -1; if(MSG_SLOTNUM(board_type, ind) < 0 || MSG_SLOTNUM(board_type, ind) >= INDEX_SIZE) { send_to_char("Sorry, the board is not working.\r\n", ch); log("SYSERR: Board is screwed up."); return(1); } if(!(MSG_HEADING(board_type, ind))) { send_to_char("That message appears to be screwed up.\r\n", ch); return(1); } ct = time(0); tmstr = (char *) asctime(localtime(&ct)); *(tmstr + strlen(tmstr) - 1) = '\0'; sprintf(buf2, "(%s)", GET_NAME(ch)); sprintf(buf, "%6.10s %-12s :: Re: %s", tmstr, buf2, (MSG_HEADING(board_type, ind) + 27)); buf[81] = '\0'; len = strlen(buf) +1; if(!(NEW_MSG_INDEX(board_type).heading = (char *) malloc(sizeof(char) * len))) { send_to_char("The board is malfucntioning - sorry.\r\n", ch); return(1); } strcpy(NEW_MSG_INDEX(board_type).heading, buf); NEW_MSG_INDEX(board_type).heading[len - 1] = '\0'; NEW_MSG_INDEX(board_type).level = GET_LEVEL(ch); NEW_MSG_INDEX(board_type).reply_num = ind; send_to_char("Write your message. Terminate with a @ on a new line.\r\n\r\n", ch); act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM); string_write(ch->desc, &(msg_storage[NEW_MSG_INDEX(board_type).slot_num]), MAX_MESSAGE_LENGTH, board_type + BOARD_MAGIC, NULL); num_of_msgs[board_type]++; return (1); } Plus various other things in boards.h Thanks Sliver +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT