Esempio n. 1
0
void board_write_msg(struct char_data *ch, char *arg, int bnum) {

    int highmessage;
    char buf[MAX_STRING_LENGTH];
    long ct;                      /* clock time */
    char *tmstr;

    if (bnum == -1) {
        log_msg("Board special procedure called for non-board object.\r\n");
        send_to_char("This board is not in operation at this time.\n\r", ch);
        return;
    }

    curr_board = &boards[bnum];

    if (get_max_level(ch) < min_write_level[bnum]) {
        send_to_char
        ("You pick up a quill to write, but realize you're not powerful enough\n\r",
         ch);
        send_to_char("to submit intelligent material to THIS board.\n\r", ch);
        return;
    }

    if ((curr_board->number) > (MAX_MSGS - 1)) {
        send_to_char("The board is full already.\n\r", ch);
        return;
    }

    /* Check for locks, return if lock is found on this board */

    if (board_check_locks(bnum, ch))
        return;

    /* skip blanks */

    for (; isspace(*arg); arg++);

    if (!*arg) {
        send_to_char
        ("The board has now been saved permanently to disk.\n\rTo write a new message, use WRITE followed by a title.\n\r",
         ch);
        return;
    }

    /* Now we're committed to writing a message.  Let's lock the board. */

    board_lock[bnum].lock = 1;
    board_lock[bnum].locked_for = ch;

    /* Lock set */

    highmessage = boards[bnum].number;
    curr_msg = &curr_board->msg[++highmessage];

    if (!(strcmp("Topic", arg))) {
        (boards[bnum].number)--;
    }
    strncpy(curr_msg->title, arg, sizeof(curr_msg->title));
    strncpy(curr_msg->author, GET_NAME(ch), sizeof(curr_msg->author));
    ct = time(0);
    tmstr = (char *)asctime(localtime(&ct));
    *(tmstr + strlen(tmstr) - 1) = '\0';
    SPRINTF(buf, "%.10s", tmstr);
    strncpy(curr_msg->date, buf, sizeof(curr_msg->date));
    send_to_char("Write your message. Terminate with a @.\n\r\n\r", ch);
    act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM);

    /* Take care of free-ing and zeroing if the message text is already
       allocated previously */
    memset(curr_msg->text, 0, sizeof(curr_msg->text));

    /* Initiate the string_add procedures from comm.c */

    ch->desc->static_str = curr_msg->text;
    ch->desc->max_str = sizeof(curr_msg->text);
    (boards[bnum].number)++;
    if (boards[bnum].number < 0)
        boards[bnum].number = 0;
}
Esempio n. 2
0
int board_remove_msg(struct char_data *ch, char *arg, int bnum) {

    /* This should now be fixed so that low level chars can remove armor and such. */

    int ind, tmessage;
    char buf[256], number[MAX_INPUT_LENGTH];

    one_argument(arg, number);

    if (!*number || !isdigit(*number))
        return (0);

    if (!(tmessage = atoi(number)))
        return (0);

    if (bnum == -1) {
        log_msg("Board special procedure called for non-board object.\r\n");
        send_to_char("This board is not in operation at this time.\n\r", ch);
        return 1;
    }

    curr_board = &boards[bnum];

    if (get_max_level(ch) < min_remove_level[bnum]) {
        send_to_char
        ("You try and grab one of the notes of the board but get a nasty\n\r",
         ch);
        send_to_char("shock.  Maybe you'd better leave it alone.\n\r", ch);
        return 1;
    }

    if (curr_board->number < 1) {
        send_to_char("The board is empty!\n\r", ch);
        return (1);
    }

    if (tmessage < 0 || tmessage > curr_board->number) {
        send_to_char("That message exists only in your imagination..\n\r", ch);
        return (1);
    }

    /* Check for board locks, return if lock is found */

    if (board_check_locks(bnum, ch))
        return (1);

    ind = tmessage;

    for (; ind < (curr_board->number); ind++)
        curr_board->msg[ind] = curr_board->msg[ind + 1];

    curr_board->number--;

    send_to_char("Message removed.\n\r", ch);
    SPRINTF(buf, "%s just removed message %d.", ch->player.name, tmessage);

    /* Removal message also repaired */

    act(buf, FALSE, ch, 0, 0, TO_ROOM);
    buf[strlen(buf) - 1] = '\0';
    SAPPENDF(buf, " from board %d.", bnum);
    log_msg(buf);                 /* Message removals now logged. */

    board_save_board(bnum);
    return (1);
}
Esempio n. 3
0
int board_remove_msg(struct char_data *ch, char *arg, int bnum) {

  /* This should now be fixed so that low level chars can remove armor and such. */

  int ind, tmessage;
  char buf[256], number[MAX_INPUT_LENGTH];
  
  one_argument(arg, number);
  
  if (!*number || !isdigit(*number))
    return(0);
  
  if (!(tmessage = atoi(number))) return(0);
  
  if ( bnum == -1 ) {
    logE("Board special procedure called for non-board object.\r\n");
    send_to_char("This board is not in operation at this time.\n\r", ch);
    return 1;
  }

  curr_board = &boards[bnum];

  if (GetMaxLevel(ch) < min_remove_level[bnum]) {
    send_to_char("You try and grab one of the notes of the board but get a nasty\n\r",ch);
    send_to_char("shock.  Maybe you'd better leave it alone.\n\r",ch);
    return 1;
  }

  if (curr_board->number < 1) {
    send_to_char("The board is empty!\n\r", ch);
    return(1);
  }

  if (tmessage < 0 || tmessage > curr_board->number) {
    send_to_char("That message exists only in your imagination..\n\r",
		 ch);
    return(1);
  }

  /* Check for board locks, return if lock is found */
  
  if (board_check_locks(bnum, ch))
    return(1);

  ind = tmessage;

  free(curr_board->msg[ind].text);
  free(curr_board->msg[ind].date);
  free(curr_board->msg[ind].author);
  free(curr_board->msg[ind].title);

  for ( ; ind < (curr_board->number) ; ind++ )
    curr_board->msg[ind] = curr_board->msg[ind+1];

/* You MUST do this, or the next message written after a remove will */
/* end up doing a free(curr_board->msg[ind].text) because it's not!! */
/* Causing strange shit to happen, because now the message has a     */
/* To a memory location that doesn't exist, and if THAT message gets */
/* Removed, it will destroy what it's pointing to. THIS is the board */
/* Bug we've been looking for!        -=>White Gold<=-               */

  curr_board->msg[curr_board->number].text = NULL;
  curr_board->msg[curr_board->number].date = NULL;
  curr_board->msg[curr_board->number].author = NULL;
  curr_board->msg[curr_board->number].title = NULL;

  curr_board->number--;

  send_to_char("Message removed.\n\r", ch);
  sprintf(buf, "%s just removed message %d.", ch->player.name, tmessage);

  /* Removal message also repaired */

  act(buf, FALSE, ch, 0, 0, TO_ROOM);
  sprintf((buf+strlen(buf)-1)," from board %d.",bnum);
  logE(buf);  /* Message removals now logged. */

  board_save_board(bnum);
  return(1);
}