/* Add user input to the 'current' string (as defined by d->str) */ void string_add(struct descriptor_data *d, char *str) { int action; /* char *point; */ delete_doubledollar(str); smash_tilde(str); /* determine if this is the terminal string, and truncate if so */ /* changed to only accept '@' at the beginning of line - J. Elson 1/17/94 */ if ((action = (*str == '@' || *str == '~'))) *str = '\0'; else if ((action = improved_editor_execute(d, str)) == STRINGADD_ACTION) return; if (!(*d->str)) { if (strlen(str) + 3 > d->max_str) { send_to_char("String too long - Truncated.\r\n", d->character); strcpy(&str[d->max_str - 3], "\r\n"); CREATE(*d->str, char, d->max_str); strcpy(*d->str, str); if (!using_improved_editor) action = STRINGADD_SAVE; } else {
/* Add user input to the 'current' string (as defined by d->str). This is still * overly complex. */ void string_add(struct descriptor_data *d, char *str) { int action; /* Determine if this is the terminal string, and truncate if so. Changed to * only accept '@' at the beginning of line. - JE */ delete_doubledollar(str); smash_tilde(str); /* Determine if this is the terminal string, and truncate if so. Changed to * only accept '@' if it's by itself. - fnord */ if ((action = (*str == '@' && !str[1]))) *str = '\0'; else if ((action = improved_editor_execute(d, str)) == STRINGADD_ACTION) return; if (action != STRINGADD_OK) /* Do nothing. */ ; else if (!(*d->str)) { if (strlen(str) + 3 > d->max_str) { /* \r\n\0 */ send_to_char(d->character, "String too long - Truncated.\r\n"); strcpy(&str[d->max_str - 3], "\r\n"); /* strcpy: OK (size checked) */ CREATE(*d->str, char, d->max_str); strcpy(*d->str, str); /* strcpy: OK (size checked) */ if (!using_improved_editor) action = STRINGADD_SAVE; } else {
void do_message_world(char *argument, int type) { struct descriptor_data *pt; skip_spaces(&argument); delete_doubledollar(argument); switch (type) { case 0: sprintf(buf2, "&n[&DDarkness Falling&n]&n:&n &r%s&n\r\n", argument); break; case 1: sprintf(buf2, "&m[&MFreeze Tag&m]&n: &r%s&n\r\n", argument); break; } if (type == MSG_FREEZE) { for (pt = descriptor_list; pt; pt = pt->next) { if (STATE(pt) == CON_PLAYING && pt->character && GET_FREEZE_TEAM(pt->character)) { send_to_char(buf2, pt->character); } } return; } for (pt = descriptor_list; pt; pt = pt->next) { if (STATE(pt) == CON_PLAYING && pt->character) { send_to_char(buf2, pt->character); } } }
void Board_write_message(int board_type, struct char_data * ch, char *arg) { char *tmstr; int len; time_t ct; char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH]; if (WRITE_LVL(board_type) != 0 && !COM_FLAGGED(ch, WRITE_LVL(board_type))) { send_to_char("You are not holy enough to write on this board.\r\n", ch); return; } if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) { send_to_char("The board is full.\r\n", ch); return; } if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) { send_to_char("The board is malfunctioning - sorry.\r\n", ch); stderr_log("SYSERR: Board: failed to find empty slot on write."); return; } /* skip blanks */ skip_spaces(&arg); delete_doubledollar(arg); if (!*arg) { send_to_char("We must have a headline!\r\n", ch); return; } ct = time(0); tmstr = (char *) asctime(localtime(&ct)); *(tmstr + strlen(tmstr) - 1) = '\0'; sprintf(buf2, "(%s)", GET_NAME(ch)); sprintf(buf, "%6.10s %-12s :: %s", tmstr, buf2, arg); len = strlen(buf) + 1; if (!(NEW_MSG_INDEX(board_type).heading = (char *) malloc(sizeof(char) * len))) { send_to_char("The board is malfunctioning - sorry.\r\n", ch); return; } 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); sprintf(logbuffer, "%s writing new message (%s) on board in #%d", GET_NAME(ch), buf, world[ch->in_room].number); mudlog(logbuffer, 'B', COM_ADMIN, FALSE); send_to_char("Write your message. (/s saves /h for help)\r\n\r\n", ch); act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM); if (!IS_NPC(ch)) SET_BIT(PLR_FLAGS(ch), PLR_WRITING); ch->desc->str = &(msg_storage[NEW_MSG_INDEX(board_type).slot_num]); ch->desc->max_str = MAX_MESSAGE_LENGTH; ch->desc->mail_to = (char*) board_type + BOARD_MAGIC; num_of_msgs[board_type]++; }
int Board_write_message(int board_type, struct char_data *ch, char *arg, struct obj_data *board) { (void)board; char *tmstr; time_t ct; char buf[MAX_INPUT_LENGTH], buf2[MAX_NAME_LENGTH + 3]; if (GET_LEVEL(ch) < WRITE_LVL(board_type)) { send_to_char(ch, "You are not holy enough to write on this board.\r\n"); return (1); } if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) { send_to_char(ch, "The board is full.\r\n"); return (1); } if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) { send_to_char(ch, "The board is malfunctioning - sorry.\r\n"); log("SYSERR: Board: failed to find empty slot on write."); return (1); } /* skip blanks */ skip_spaces(&arg); delete_doubledollar(arg); /* JE 27 Oct 95 - Truncate headline at 80 chars if it's longer than that */ arg[80] = '\0'; if (!*arg) { send_to_char(ch, "We must have a headline!\r\n"); return (1); } ct = time(0); tmstr = (char *) asctime(localtime(&ct)); *(tmstr + strlen(tmstr) - 1) = '\0'; snprintf(buf2, sizeof(buf2), "(%s)", GET_NAME(ch)); snprintf(buf, sizeof(buf), "%6.10s %-12s :: %s", tmstr, buf2, arg); NEW_MSG_INDEX(board_type).heading = strdup(buf); NEW_MSG_INDEX(board_type).level = GET_LEVEL(ch); send_to_char(ch, "Write your message. Terminate with a @ on a new line.\r\n\r\n"); act("$n starts to write a message.", TRUE, ch, 0, 0, CommTarget::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); }
/* Add user input to the 'current' string (as defined by d->str). */ void string_add(Descriptor *d, char *str) { FILE *fl; int terminator = 0, action = 0; register int i = 2, j = 0; char actions[MAX_INPUT_LENGTH]; /* determine if this is the terminal string, and truncate if so */ /* changed to only accept '@' at the beginning of line - J. Elson 1/17/94 */ /* Changed to accept '/<letter>' style editing commands - instead */ /* of solitary '@' to end. - M. Scott 10/15/96 */ delete_doubledollar(str); if ((action = ((*str == '/') && (str[1] != '/') && (str[1] != '*')))) { while (str[i] != '\0') { actions[j] = str[i]; ++i; ++j; } actions[j] = '\0'; *str = '\0'; switch (str[1]) { case 'a': terminator = 2; /* Working on an abort message, */ break; case 'c': if (*(d->str)) { delete [](*(d->str)); *(d->str) = NULL; d->send("Current buffer cleared.\r\n"); } else d->send("Current buffer empty.\r\n"); break; case 'd': parse_action(PARSE_DELETE, actions, d); break; case 'e': parse_action(PARSE_EDIT, actions, d); break; case 'f': if (*(d->str)) parse_action(PARSE_FORMAT, actions, d); else d->send("Current buffer empty.\r\n"); break; case 'i': if (*(d->str)) parse_action(PARSE_INSERT, actions, d); else d->send("Current buffer empty.\r\n"); break; case 'h': parse_action(PARSE_HELP, actions, d); break; case 'l': if (*d->str) parse_action(PARSE_LIST_NORM, actions, d); else d->send("Current buffer empty.\r\n"); break; case 'n': if (*d->str) parse_action(PARSE_LIST_NUM, actions, d); else d->send("Current buffer empty.\r\n"); break; case 'r': parse_action(PARSE_REPLACE, actions, d); break; case 's': terminator = 1; *str = '\0'; break; default: d->send("Invalid option.\r\n"); break; } if(!terminator) return; } if(!terminator) { if (!(*d->str)) { if (strlen(str) > d->max_str) { d->send("String too long - Truncated.\r\n"); *(str + d->max_str) = '\0'; /* Changed this to NOT abort out.. just give warning. */ /* terminator = 1; */ } (*d->str) = new char[d->max_str]; *(*d->str) = '\0'; d->addToString(str); } else { if (!d->addToString(str)) d->send("String too long, limit reached on message. Last line ignored.\r\n"); } } if(terminator) { /* * OLC Edits */ extern void oedit_disp_menu(Descriptor *d); extern void oedit_disp_extradesc_menu(Descriptor *d); extern void redit_disp_menu(Descriptor *d); extern void redit_disp_extradesc_menu(Descriptor *d); extern void redit_disp_exit_menu(Descriptor *d); extern void medit_disp_menu(Descriptor *d); extern void CeditGameOptionsMenu(Descriptor *d); extern void cedit_disp_operation_options(Descriptor *d); #if defined(OASIS_MPROG) extern void medit_change_mprog(Descriptor *d); if (STATE(d) == CON_MEDIT) { switch (OLC_MODE(d)) { case MEDIT_D_DESC: medit_disp_menu(d); break; case MEDIT_MPROG_COMLIST: medit_change_mprog(d); break; } } #endif /* * Here we check for the abort option and reset the pointers. */ if ((terminator == 2) && ((STATE(d) == CON_REDIT) || (STATE(d) == CON_MEDIT) || (STATE(d) == CON_OEDIT) || (STATE(d) == CON_EXDESC) || STATE(d) == CON_CEDIT)) { delete[] (*d->str); if (d->backstr) { *d->str = d->backstr; } else *d->str = NULL; d->backstr = NULL; d->str = NULL; } /* * This fix causes the editor to NULL out empty messages -- M. Scott * Fixed to fix the fix for empty fixed messages. -- gg */ if ((d->str) && (*d->str) && (**d->str == '\0')) { delete[] (*d->str); if(!d->character || d->str != &d->character->player.description) *d->str = str_dup("Nothing.\r\n"); else *d->str = str_dup(" "); } if (STATE(d) == CON_MEDIT) medit_disp_menu(d); if (STATE(d) == CON_OEDIT) { switch (OLC_MODE(d)) { case OEDIT_ACTDESC: oedit_disp_menu(d); break; case OEDIT_EXTRADESC_DESCRIPTION: oedit_disp_extradesc_menu(d); break; } } else if (STATE(d) == CON_REDIT) { switch (OLC_MODE(d)) { case REDIT_DESC: redit_disp_menu(d); break; case REDIT_EXIT_DESCRIPTION: redit_disp_exit_menu(d); break; case REDIT_EXTRADESC_DESCRIPTION: redit_disp_extradesc_menu(d); break; } } else if(STATE(d) == CON_CEDIT) { switch(OLC_MODE(d)) { case CEDIT_GAME_OPTIONS_MENU: CeditGameOptionsMenu(d); break; case CEDIT_OPERATION_OPTIONS_MENU: CeditGameOptionsMenu(d); break; } } else if (!d->connected && d->character && !IS_NPC(d->character)) { if (terminator == 1) { if (*d->str && strlen(*d->str) == 0) { delete (*d->str); *d->str = NULL; } } else { delete (*d->str); if (d->backstr) *d->str = d->backstr; else *d->str = NULL; d->backstr = NULL; d->sendRaw("Message aborted.\r\n"); } } if (d->character && !IS_NPC(d->character)) { REMOVE_BIT(PLR_FLAGS(d->character), Q_BIT(PLR_WRITING)); REMOVE_BIT(PLR_FLAGS(d->character), Q_BIT(PLR_MAILING)); } if (d->backstr) delete [](d->backstr); d->backstr = NULL; d->str = NULL; } //Add a newline only if able -Galnor, 03/20/2009 else if (!action) d->addToString("\r\n"); }