int Board_show_board(int board_type, struct char_data *ch, char *arg, struct obj_data *board) { int i; char tmp[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH]; if (!ch->desc) return (0); one_argument(arg, tmp); if (!*tmp || !isname(tmp, board->name)) return (0); if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char(ch, "You try but fail to understand the holy words.\r\n"); return (1); } act("$n studies the board.", TRUE, ch, 0, 0, CommTarget::TO_ROOM); if (!num_of_msgs[board_type]) send_to_char(ch, "This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>.\r\nThe board is empty.\r\n"); else { size_t len = 0; int nlen; len = snprintf(buf, sizeof(buf), "This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>.\r\n" "You will need to look at the board to save your message.\r\n" "There are %d messages on the board.\r\n", num_of_msgs[board_type]); #if NEWEST_AT_TOP for (i = num_of_msgs[board_type] - 1; i >= 0; i--) { if (!MSG_HEADING(board_type, i)) goto fubar; nlen = snprintf(buf + len, sizeof(buf) - len, "%-2d : %s\r\n", num_of_msgs[board_type] - i, MSG_HEADING(board_type, i)); if (len + nlen >= sizeof(buf) || nlen < 0) break; len += nlen; } #else for (i = 0; i < num_of_msgs[board_type]; i++) { if (!MSG_HEADING(board_type, i)) goto fubar; nlen = snprintf(buf + len, sizeof(buf) - len, "%-2d : %s\r\n", i + 1, MSG_HEADING(board_type, i)); if (len + nlen >= sizeof(buf) || nlen < 0) break; len += nlen; } #endif page_string(ch->desc, buf, TRUE); } return (1); fubar: log("SYSERR: Board %d is fubar'd.", board_type); send_to_char(ch, "Sorry, the board isn't working.\r\n"); return (1); }
int Board_display_msg(int board_type, struct char_data * ch, char *arg) { char number[MAX_STRING_LENGTH], buffer[MAX_STRING_LENGTH]; int msg, ind; one_argument(arg, number); if (!*number) return 0; if (isname(number, "board bulletin")) /* so "read board" works */ return (Board_show_board(board_type, ch, arg)); if (!isdigit(*number) || (!(msg = atoi(number)))) return 0; if (READ_LVL(board_type) != 0 && !COM_FLAGGED(ch, READ_LVL(board_type))) { send_to_char("You try but fail to understand the holy words.\r\n", ch); return 1; } if (!num_of_msgs[board_type]) { send_to_char("The board is empty!\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); stderr_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; } if (!(msg_storage[MSG_SLOTNUM(board_type, ind)])) { send_to_char("That message seems to be empty.\r\n", ch); return 1; } sprintf(buffer, "Message %d : %s\r\n\r\n%s\r\n", msg, MSG_HEADING(board_type, ind), msg_storage[MSG_SLOTNUM(board_type, ind)]); page_string(ch->desc, buffer, 1); return 1; }
int Board_display_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board) { char number[MAX_INPUT_LENGTH], buffer[MAX_STRING_LENGTH]; int msg, ind; one_argument(arg, number); if (!*number) return (0); if (isname(number, board->name)) /* so "read board" works */ return (Board_show_board(board_type, ch, arg, board)); if (!is_number(number)) /* read 2.mail, look 2.sword */ return (0); if (!(msg = atoi(number))) return (0); if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char(ch, "You try but fail to understand the holy words.\r\n"); return (1); } if (!num_of_msgs[board_type]) { send_to_char(ch, "The board is empty!\r\n"); return (1); } if (msg < 1 || msg > num_of_msgs[board_type]) { send_to_char(ch, "That message exists only in your imagination.\r\n"); return (1); } #if NEWEST_AT_TOP ind = num_of_msgs[board_type] - msg; #else ind = msg - 1; #endif if (MSG_SLOTNUM(board_type, ind) < 0 || MSG_SLOTNUM(board_type, ind) >= INDEX_SIZE) { send_to_char(ch, "Sorry, the board is not working.\r\n"); log("SYSERR: Board is screwed up. (Room #%d)", GET_ROOM_VNUM(IN_ROOM(ch))); return (1); } if (!(MSG_HEADING(board_type, ind))) { send_to_char(ch, "That message appears to be screwed up.\r\n"); return (1); } if (!(msg_storage[MSG_SLOTNUM(board_type, ind)])) { send_to_char(ch, "That message seems to be empty.\r\n"); return (1); } snprintf(buffer, sizeof(buffer), "Message %d : %s\r\n\r\n%s\r\n", msg, MSG_HEADING(board_type, ind), msg_storage[MSG_SLOTNUM(board_type, ind)]); page_string(ch->desc, buffer, TRUE); return (1); }
int Board_show_board(int board_type, struct char_data * ch, char *arg) { int i; char tmp[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH]; if (!ch->desc) return 0; one_argument(arg, tmp); if (!*tmp || !isname(tmp, "board bulletin")) return 0; if (READ_LVL(board_type) != 0 && !COM_FLAGGED(ch, READ_LVL(board_type))) { send_to_char("You try but fail to understand the holy words.\r\n", ch); return 1; } act("$n studies the board.", TRUE, ch, 0, 0, TO_ROOM); strcpy(buf, "This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>.\r\n" "You will need to look at the board to save your message.\r\n"); if (!num_of_msgs[board_type]) strcat(buf, "The board is empty.\r\n"); else { sprintf(buf + strlen(buf), "There are %d messages on the board.\r\n", num_of_msgs[board_type]); /* uncomment below if want most recent message at bottom */ /* for (i = 0; i < num_of_msgs[board_type]; i++) { */ for (i = num_of_msgs[board_type] - 1; i >= 0; i--) { if (MSG_HEADING(board_type, i)) sprintf(buf + strlen(buf), "%s%-2d%s : %s%s\r\n", CBWHT(ch, C_NRM), i + 1, CCCYN(ch, C_NRM), MSG_HEADING(board_type, i), CCNRM(ch, C_NRM)); else { stderr_log("SYSERR: The board is fubar'd."); send_to_char("Sorry, the board isn't working.\r\n", ch); return 1; } } } page_string(ch->desc, buf, 1); return 1; }
int Board_display_msg(int board_type, struct char_data *ch, char *arg) { char buf[512], number[MAX_STRING_LENGTH], buffer[MAX_STRING_LENGTH]; int msg, ind; one_argument(arg, number); if (!*number || !isdigit(*number)) return 0; if (!(msg = atoi(number))) return 0; if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char("You try but fail to understand the holy words.\n\r", ch); return 1; } if (!num_of_msgs[board_type]) { send_to_char("The board is empty!\n\r", ch); return(1); } if (msg < 1 || msg > num_of_msgs[board_type]) { send_to_char("That message exists only in your imagination..\n\r", 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.\n\r", ch); log("Board is screwed up."); return 1; } if (!(MSG_HEADING(board_type, ind))) { send_to_char("That message appears to be screwed up.\n\r", ch); return 1; } if(!(msg_storage[MSG_SLOTNUM(board_type, ind)])) { send_to_char("That message seems to be empty.\n\r", ch); return 1; } sprintf(buffer, "Message %d : %s\n\r\n\r%s\n\r", msg, MSG_HEADING(board_type, ind), msg_storage[MSG_SLOTNUM(board_type, ind)]); page_string(ch->desc, buffer, 1); return 1; }
int Board_show_board(int board_type, struct char_data *ch) { int i; char buf[MAX_STRING_LENGTH]; if (!ch->desc) return 0; if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char("You try but fail to understand the holy words.\n\r", ch); return 1; } act("$n studies the board.", TRUE, ch, 0, 0, TO_ROOM); strcpy(buf, "This is a bulletin board. Usage: READ/ERASE <messg #>, WRITE <header>.\n\r"); if (!num_of_msgs[board_type]) strcat(buf, "The board is empty.\n\r"); else { sprintf(buf + strlen(buf), "There are %d messages on the board.\n\r", num_of_msgs[board_type]); for (i = 0; i < num_of_msgs[board_type]; i++) { if (MSG_HEADING(board_type, i)) sprintf(buf + strlen(buf), "%-2d : %s\n\r", i + 1, MSG_HEADING(board_type, i)); else { log("The board is fubar'd."); send_to_char("Sorry, the board isn't working.\n\r", ch); return 1; } } } page_string(ch->desc, buf, 1); return 1; }