Пример #1
0
int board_remove_msg(struct char_data *ch, char *arg) {
	int ind, msg;
	char buf[256], number[MAX_INPUT_LENGTH];

	if (GET_LEVEL(ch) < 10) {
		send_to_char("Due to misuse of the REMOVE command, only 10th level\r\n", ch);
		send_to_char("and above can remove messages.\r\n", ch);
		return;
	}

	one_argument(arg, number);

	if (!*number || !isdigit(*number))
		return(0);
	if (!(msg = atoi(number))) return(0);
	if (!msg_num) {
		send_to_char("The board is empty!\r\n", ch);
		return(1);
	}
	if (msg < 1 || msg > msg_num) {
		send_to_char("That message exists only in your imagination..\r\n",
			ch);
		return(1);
	}

	ind = msg;
	free(head[--ind]);
	if (msgs[ind])
		free(msgs[ind]);
	for (; ind < msg_num -1; ind++) {
		head[ind] = head[ind + 1];
		msgs[ind] = msgs[ind + 1];
	}
	msg_num--;
	send_to_char("Message removed.\r\n", ch);
	sprintf(buf, "$n just removed message %d.", ind + 1);
	act(buf, FALSE, ch, 0, 0, TO_ROOM);
	board_save_board();

	return(1);
}
Пример #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);
}
Пример #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);
}
Пример #4
0
int board_remove_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
  int ind, msg, slot_num;
  char number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
  struct descriptor_data *d;

  one_argument(arg, number);

  if (!*number || !is_number(number))
    return (0);
  if (!(msg = atoi(number)))
    return (0);

  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_HEADING(board_type, ind)) {
    send_to_char(ch, "That message appears to be screwed up.\r\n");
    return (1);
  }
  snprintf(buf, sizeof(buf), "(%s)", GET_NAME(ch));
  if (GET_LEVEL(ch) < REMOVE_LVL(board_type) &&
      !(strstr(MSG_HEADING(board_type, ind), buf))) {
    send_to_char(ch, "You are not holy enough to remove other people's messages.\r\n");
    return (1);
  }
  if (GET_LEVEL(ch) < MSG_LEVEL(board_type, ind)) {
    send_to_char(ch, "You can't remove a message holier than yourself.\r\n");
    return (1);
  }
  slot_num = MSG_SLOTNUM(board_type, ind);
  if (slot_num < 0 || slot_num >= INDEX_SIZE) {
    send_to_char(ch, "That message is majorly screwed up.\r\n");
    log("SYSERR: The board is seriously screwed up. (Room #%d)", GET_ROOM_VNUM(IN_ROOM(ch)));
    return (1);
  }
  for (d = descriptor_list; d; d = d->next)
    if (STATE(d) == CON_PLAYING && d->str == &(msg_storage[slot_num])) {
      send_to_char(ch, "At least wait until the author is finished before removing it!\r\n");
      return (1);
    }
  if (msg_storage[slot_num])
    free(msg_storage[slot_num]);
  msg_storage[slot_num] = 0;
  msg_storage_taken[slot_num] = 0;
  if (MSG_HEADING(board_type, ind))
    free(MSG_HEADING(board_type, ind));

  for (; ind < num_of_msgs[board_type] - 1; ind++) {
    MSG_HEADING(board_type, ind) = MSG_HEADING(board_type, ind + 1);
    MSG_SLOTNUM(board_type, ind) = MSG_SLOTNUM(board_type, ind + 1);
    MSG_LEVEL(board_type, ind) = MSG_LEVEL(board_type, ind + 1);
  }
  num_of_msgs[board_type]--;

  send_to_char(ch, "Message removed.\r\n");
  snprintf(buf, sizeof(buf), "$n just removed message %d.", msg);
  act(buf, FALSE, ch, 0, 0, TO_ROOM);
  board_save_board(board_type);

  return (1);
}