int board(struct char_data *ch, int cmd, char *arg) { static int has_loaded = 0; if (!ch->desc) return(FALSE); /* By MS or all NPC's will be trapped at the board */ /* note: I'll let display and remove return 0 if the arg was non-board- */ /* related. Thus, it'll be possible to read other things than the board */ /* while you're in the room. Conceiveably, you could do this for write, */ /* too, but I'm not in the mood for such hacking. */ if (!has_loaded) { board_load_board(); has_loaded = 1; } switch (cmd) { case 15: /* look */ return(board_show_board(ch, arg)); case 149: /* write */ board_write_msg(ch, arg); return 1; case 63: /* read */ return(board_display_msg(ch, arg)); case 66: /* remove */ return(board_remove_msg(ch, arg)); default: return 0; } }
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(struct char_data *ch, const char * cmd, char *arg, struct obj_data *obj, int type) { static int has_loaded = 0; int bnum = -1; int obj_num; if (type != PULSE_COMMAND) return (FALSE); if (!ch->desc) return (0); /* By MS or all NPC's will be trapped at the board */ if (!has_loaded) { board_load_board(); has_loaded = 1; } if (!cmd) return (FALSE); /* Identify which board we're dealing with */ obj_num = (obj->item_number); if (obj_num == (real_object(3099))) bnum = 0; else if (obj_num == (real_object(3098))) bnum = 1; else if (obj_num == (real_object(3097))) bnum = 2; if (STREQ(cmd, "look")) { return (board_show_board(ch, arg, bnum)); } else if (STREQ(cmd, "write")) { board_write_msg(ch, arg, bnum); return 1; } else if (STREQ(cmd, "read")) { return (board_display_msg(ch, arg, bnum)); } else if (STREQ(cmd, "remove")) { return (board_remove_msg(ch, arg, bnum)); } else { return 0; } }
int board(struct char_data *ch, int cmd, char *arg, struct obj_data *obj, int type) { static int has_loaded = 0; char buf[80]; int bnum = -1; int obj_num; if (type != PULSE_COMMAND) return(FALSE); if (!ch->desc) return(0); /* By MS or all NPC's will be trapped at the board */ if (!has_loaded) { board_load_board(); has_loaded = 1; } if (!cmd) return(FALSE); /* Identify which board we're dealing with */ obj_num = (obj->item_number); if (obj_num == (real_object(3099))) bnum = 0; else if (obj_num == (real_object(3098))) bnum = 1; else if (obj_num == (real_object(3097))) bnum = 2; switch (cmd) { case 15: /* look */ return(board_show_board(ch, arg, bnum)); case 149: /* write */ board_write_msg(ch, arg, bnum); return 1; case 63: /* read */ return(board_display_msg(ch, arg, bnum)); case 66: /* remove */ return(board_remove_msg(ch, arg, bnum)); default: return 0; } }