示例#1
0
文件: redit.c 项目: Calebros/aol
void redit_setup_new(struct descriptor_data *d)
{
  CREATE(OLC_ROOM(d), struct room_data, 1);

  OLC_ROOM(d)->name = str_dup("An unfinished room");
  OLC_ROOM(d)->description = str_dup("You are in an unfinished room.\r\n");
  redit_disp_menu(d);
  OLC_VAL(d) = 0;
}
示例#2
0
文件: redit.c 项目: matthewbode/mg2
void redit_setup_new(struct descriptor_data *d)
{
  CREATE(OLC_ROOM(d), struct room_data, 1);

  OLC_ROOM(d)->name = str_dup("An unfinished room");
  OLC_ROOM(d)->description = str_dup("You are in an unfinished room.\r\n");
  OLC_ROOM(d)->number = NOWHERE;
  OLC_ITEM_TYPE(d) = WLD_TRIGGER;
  redit_disp_menu(d);
  OLC_VAL(d) = 0;
}
示例#3
0
DO_RET do_redit_reset( CHAR_DATA *ch, char *argument )
{
	ROOM_DATA		 *room = ch->dest_buf;
	EXTRA_DESCR_DATA *ed = ch->spare_ptr;

	switch ( ch->substate )
	{
	  case SUB_ROOM_DESCR:
		if ( !ch->dest_buf )
		{
			/* If theres no dest_buf, theres no object, so stick em back as playing */
			ch_printf( ch, "Fatal error: report to Coder.\r\n" );
			send_log( NULL, LOG_OLC, "do_redit_reset: sub_obj_extra: NULL ch->dest_buf" );
			ch->substate = SUB_NONE;
			ch->desc->connected = CON_PLAYING;
			return;
		}
		DISPOSE( room->description );
		room->description = copy_buffer( ch );
		stop_editing( ch );
		ch->dest_buf = room;
		ch->desc->connected = CON_REDIT;
		ch->substate = SUB_NONE;

		olc_log( ch->desc, "Edited room description" );
		redit_disp_menu( ch->desc );
		return;

	  case SUB_ROOM_EXTRA:
		DISPOSE( ed->description );
		ed->description = copy_buffer( ch );
		stop_editing( ch );
		ch->dest_buf = room;
		ch->spare_ptr = ed;
		ch->substate = SUB_NONE;
		ch->desc->connected = CON_REDIT;
		oedit_disp_extra_choice( ch->desc );
		OLC_MODE(ch->desc) = REDIT_EXTRADESC_CHOICE;
		olc_log( ch->desc, "Edit description for exdesc %s", ed->keyword );

		return;
	}
}
示例#4
0
void redit_parse( DESCRIPTOR_DATA *d , char *arg )
{
	ROOM_DATA		 *room  = d->character->dest_buf;
	ROOM_DATA		 *tmp;
	EXIT_DATA		 *pexit = d->character->spare_ptr;
	EXTRA_DESCR_DATA *ed	  = d->character->spare_ptr;
	char			  arg1[MIL];
	char			  buf[MSL];
	int				  number = 0;

	switch ( OLC_MODE(d) )
	{
	  case REDIT_CONFIRM_SAVESTRING:
		switch ( *arg )
		{
		  case 'y':
		  case 'Y':
			/* redit_save_internally(d); */
			send_log( NULL, LOG_OLC, "OLC: %s edits room %d", d->character->name, OLC_NUM(d) );
			cleanup_olc( d );
			send_to_char( d->character, "Room saved to memory.\r\n" );
			break;
		  case 'n':
		  case 'N':
			cleanup_olc( d );
			break;
		  default:
			send_to_char( d->character, "Invalid choice!\r\n" );
			send_to_char( d->character, "Do you wish to save this room internally? : " );
			break;
		}
		return;

	  case REDIT_MAIN_MENU:
		switch ( *arg )
		{
		  case 'q':
		  case 'Q':
/*			if ( OLC_CHANGE(d) )
			{ *. Something has been modified .*
				send_to_char( d->character, "Do you wish to save this room internally? : " );
				OLC_MODE(d) = REDIT_CONFIRM_SAVESTRING;
			}
			else */
			cleanup_olc( d );
			return;
		  case '1':
			send_to_char( d->character, "Enter room name:-\r\n| " );
			OLC_MODE(d) = REDIT_NAME;
			break;
		  case '2':
			OLC_MODE(d) = REDIT_DESC;
			d->character->substate = SUB_ROOM_DESCR;
			d->character->last_cmd = do_redit_reset;

			send_to_char( d->character, "Enter room description:-\r\n" );
			if ( !room->description )
				room->description = str_dup( "" );
			start_editing( d->character, room->description );
			break;
		  case '3':
			redit_disp_flag_menu(d);
			break;
		  case '4':
			redit_disp_sector_menu(d);
			break;
		  case '5':
			send_to_char( d->character, "How many people can fit in the room? " );
			OLC_MODE(d) = REDIT_TUNNEL;
			break;
		  case '6':
			send_to_char( d->character, "How long before people are teleported out? " );
			OLC_MODE(d) = REDIT_TELEDELAY;
			break;
		  case '7':
			send_to_char( d->character, "Where are they teleported to? " );
			OLC_MODE(d) = REDIT_TELEVNUM;
			break;
		  case 'a':
		  case 'A':
			redit_disp_exit_menu(d);
			break;
		  case 'b':
		  case 'B':
			redit_disp_extradesc_menu(d);
			break;

		  default:
			send_to_char( d->character, "Invalid choice!" );
			redit_disp_menu(d);
			break;
		}
		return;

	  case REDIT_NAME:
		DISPOSE( room->name );
		room->name = str_dup( arg );
		olc_log( d, "Changed name to %s", room->name );
		break;

	  case REDIT_DESC:
		/* we will NEVER get here */
		send_log( NULL, LOG_OLC, "redit_parse: reached REDIT_DESC case in redit_parse" );
		break;

	  case REDIT_FLAGS:
		if ( is_number(arg) )
		{
			number = atoi( arg );
			if ( number == 0 )
				break;
			else if ( number < 0 || number >= MAX_ROOM )
			{
				send_to_char( d->character, "Invalid flag, try again: " );
				return;
			}
			else
			{
				number--;	/* Offset for 0 */
				TOGGLE_BIT( room->flags, number );
				olc_log( d, "%s the room flag %s",
				HAS_BIT( room->flags, number ) ? "Added" : "Removed",
				code_name(NULL, number, CODE_ROOM) );
			}
		}
		else
		{
			while ( VALID_STR(arg) )
			{
				arg = one_argument( arg, arg1 );
				number = code_num( NULL, arg1, CODE_ROOM );
				if ( number > 0 )
				{
					TOGGLE_BIT( room->flags, number );
					olc_log( d, "%s the room flag %s",
						HAS_BIT( room->flags, number ) ? "Added" : "Removed",
						code_name( NULL, number, CODE_ROOM) );
				}
			}
		}
		redit_disp_flag_menu(d);
		return;

	  case REDIT_SECTOR:
		number = atoi( arg );
		if ( number < 0 || number >= MAX_SECTOR )
		{
			send_to_char( d->character, "Invalid choice!" );
			redit_disp_sector_menu(d);
			return;
		}
		else
			room->sector = number;

		olc_log( d, "Changed sector to %s", code_name(NULL, number, CODE_SECTOR) );
		break;

	  case REDIT_TUNNEL:
		number = atoi( arg );
		room->tunnel = URANGE( 0, number, 1000 );
		olc_log( d, "Changed tunnel amount to %d", room->tunnel );
		break;

	  case REDIT_TELEDELAY:
		number = atoi( arg );
		room->tele_delay = number;
		olc_log( d, "Changed teleportation delay to %d", room->tele_delay );
		break;

	  case REDIT_TELEVNUM:
		number = atoi( arg );
		room->tele_vnum = URANGE( 1, number, MAX_VNUM-1 );
		olc_log( d, "Changed teleportation vnum to %d", room->tele_vnum );
		break;

	  case REDIT_EXIT_MENU:
		switch ( toupper(arg[0]) )
		{
		  default:
			if ( is_number(arg) )
			{
				number = atoi( arg );
				pexit = get_exit_num( room, number );
				d->character->spare_ptr = pexit;
				redit_disp_exit_edit(d);
				return;
			}
			redit_disp_exit_menu( d );
			return;
		  case 'A':
			OLC_MODE(d) = REDIT_EXIT_ADD;
			redit_disp_exit_dirs( d );
			return;
		  case 'R':
			OLC_MODE(d) = REDIT_EXIT_DELETE;
			send_to_char( d->character, "Delete which exit? " );
			return;
		  case 'Q':
			d->character->spare_ptr = NULL;
			break;
		}
		break;

	  case REDIT_EXIT_EDIT:
		switch ( toupper(arg[0]) )
		{
		  case 'Q':
			d->character->spare_ptr = NULL;
			redit_disp_exit_menu(d);
			return;
		  case '1':
			/* OLC_MODE(d) = REDIT_EXIT_DIR;
			redit_disp_exit_dirs(d); */
			send_to_char( d->character, "This option can only be changed by remaking the exit.\r\n" );
			break;
		  case '2':
			OLC_MODE(d) = REDIT_EXIT_VNUM;
			send_to_char( d->character, "Which room does this exit go to? " );
			return;
		  case '3':
			OLC_MODE(d) = REDIT_EXIT_KEY;
			send_to_char( d->character, "What is the vnum of the key to this exit? " );
			return;
		  case '4':
			OLC_MODE(d) = REDIT_EXIT_KEYWORD;
			send_to_char( d->character, "What is the keyword to this exit? " );
			return;
		  case '5':
			OLC_MODE(d) = REDIT_EXIT_FLAGS;
			redit_disp_exit_flag_menu(d);
			return;
		  case '6':
			OLC_MODE(d) = REDIT_EXIT_DESC;
			send_to_char( d->character, "Description:\r\n] " );
			return;
		}
		redit_disp_exit_edit(d);
		return;

	  case REDIT_EXIT_DESC:
		if ( !VALID_STR(arg) )
		{
			DISPOSE( pexit->description );
			pexit->description = str_dup( "" );
		}
		else
		{
			sprintf( buf, "%s\r\n", arg );
			DISPOSE( pexit->description );
			pexit->description = str_dup( buf );
		}
		olc_log( d, "Changed %s description to %s", code_name( NULL, pexit->vdir, CODE_DIR), arg  ?  arg  :  "none" );
		redit_disp_exit_edit(d);
		return;

	  case REDIT_EXIT_ADD:
		if ( is_number( arg ) )
		{
			number = atoi( arg );
			if ( number < 0 || number >= MAX_DIR )
			{
				send_to_char( d->character, "Invalid direction, try again: " );
				return;
			}
			d->character->tempnum = number;
		}
		else
		{
			number = get_dir(arg);
			pexit = get_exit( room, number );
			if ( pexit )
			{
				send_to_char( d->character, "An exit in that direction already exists.\r\n" );
				redit_disp_exit_menu(d);
				return;
			}
			d->character->tempnum = number;
		}
		OLC_MODE(d) = REDIT_EXIT_ADD_VNUM;
		send_to_char( d->character, "Which room does this exit go to? " );
		return;

	  case REDIT_EXIT_ADD_VNUM:
		number = atoi( arg );
		if ( (tmp = get_room_index(NULL, number)) == NULL )
		{
			send_to_char( d->character, "Non-existant room.\r\n" );
			OLC_MODE(d) = REDIT_EXIT_MENU;
			redit_disp_exit_menu(d);
			return;
		}
		pexit = make_exit( room, tmp, d->character->tempnum );
		DISPOSE( pexit->keyword );
		DISPOSE( pexit->description );
		pexit->keyword		= str_dup( "" );
		pexit->description	= str_dup( "" );
		pexit->key			= -1;
		pexit->flags	= 0;
		act( AT_ADMIN, "$n reveals a hidden passage!", d->character, NULL, NULL, TO_ROOM );
		d->character->spare_ptr = pexit;

		olc_log( d, "Added %s exit to %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->vnum );

		OLC_MODE(d) = REDIT_EXIT_EDIT;
		redit_disp_exit_edit(d);
		return;

	  case REDIT_EXIT_DELETE:
		if ( !is_number( arg ) )
		{
			send_to_char( d->character, "Exit must be specified in a number.\r\n" );
			redit_disp_exit_menu(d);
		}
		number = atoi( arg );
		pexit = get_exit_num( room, number );

		if ( !pexit )
		{
			send_to_char( d->character, "That exit does not exist.\r\n" );
			redit_disp_exit_menu(d);
		}
		olc_log( d, "Removed %s exit", code_name( NULL, pexit->vdir, CODE_DIR) );
		extract_exit( room, pexit );
		redit_disp_exit_menu( d );
		return;

	  case REDIT_EXIT_VNUM:
		number = atoi( arg );
		if ( number < 1 || number >= MAX_VNUM )
		{
			send_to_char( d->character, "Invalid room number, try again : " );
			return;
		}

		if ( get_room_index(NULL, number) == NULL )
		{
			send_to_char( d->character, "That room does not exist, try again: " );
			return;
		}
		pexit->vnum = number;
		olc_log( d, "%s exit vnum changed to %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->vnum );
		redit_disp_exit_menu( d );
		return;

	  case REDIT_EXIT_KEYWORD:
		DISPOSE( pexit->keyword );
		pexit->keyword = str_dup( arg );
		olc_log( d, "Changed %s keyword to %s", code_name( NULL, pexit->vdir, CODE_DIR), pexit->keyword );
		redit_disp_exit_edit( d );
		return;

	  case REDIT_EXIT_KEY:
		number = atoi( arg );
		if ( number < 1 || number >= MAX_VNUM )
			send_to_char( d->character, "Invalid vnum, try again: " );
		else
		{
			pexit->key = number;
			redit_disp_exit_edit( d );
		}
		olc_log( d, "%s key vnum is now %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->key );
		return;

	  case REDIT_EXIT_FLAGS:
		number = atoi( arg );
		if ( number == 0 )
		{
			redit_disp_exit_edit( d );
			return;
		}

		if ( number < 0 || number >= MAX_EXIT
		  || ((number-1) == EXIT_RES1)
		  || ((number-1) == EXIT_RES2)
		  || ((number-1) == EXIT_PORTAL) )
		{
			send_to_char( d->character, "That's not a valid choice!\r\n" );
			redit_disp_exit_flag_menu( d );
		}
		number -= 1;
		TOGGLE_BIT( pexit->flags, number );
		olc_log( d, "%s %s to %s exit",
			HAS_BIT(pexit->flags, number)  ?  "Added"  :  "Removed",
			code_name(NULL, number, CODE_EXIT),
			code_name(NULL, pexit->vdir, CODE_DIR) );
		redit_disp_exit_flag_menu( d );
		return;

	  case REDIT_EXTRADESC_DELETE:
		ed = redit_find_extradesc( room, atoi(arg) );
		if ( !ed )
		{
			send_to_char( d->character, "Not found, try again: " );
			return;
		}
		olc_log( d, "Deleted exdesc %s", ed->keyword );
		UNLINK( ed, room->first_extradescr, room->last_extradescr, next, prev );
		DISPOSE( ed->keyword );
		DISPOSE( ed->description );
		DISPOSE( ed );
		top_ed--;
		redit_disp_extradesc_menu(d);
		return;

	  case REDIT_EXTRADESC_CHOICE:
		switch ( toupper( arg[0] ) )
		{
		  case 'Q':
			if ( !ed->keyword || !ed->description )
			{
				send_to_char( d->character, "No keyword and/or description, junking..." );
				UNLINK( ed, room->first_extradescr, room->last_extradescr, next, prev );
				DISPOSE( ed->keyword );
				DISPOSE( ed->keyword );
				DISPOSE( ed );
				top_ed--;
			}
			d->character->spare_ptr = NULL;
			redit_disp_extradesc_menu(d);
			return;
		  case '1':
			OLC_MODE(d) = REDIT_EXTRADESC_KEY;
			send_to_char( d->character, "Keywords, seperated by spaces: " );
			return;
		  case '2':
			OLC_MODE(d) = REDIT_EXTRADESC_DESCRIPTION;
			d->character->substate = SUB_ROOM_EXTRA;
			d->character->last_cmd = do_redit_reset;
			send_to_char( d->character, "Enter new extradesc description: \r\n" );
			start_editing( d->character, ed->description );
			return;
		}
		break;

	  case REDIT_EXTRADESC_KEY:
/*		if ( SetRExtra( room, arg ) )
		{
			send_to_char( d->character, "A extradesc with that keyword already exists.\r\n" );
			redit_disp_extradesc_menu(d);
			return;
		} */
		olc_log( d, "Changed exkey %s to %s", ed->keyword, arg );
		DISPOSE( ed->keyword );
		ed->keyword = str_dup( arg );
		oedit_disp_extra_choice(d);
		OLC_MODE(d) = REDIT_EXTRADESC_CHOICE;
		return;

	  case REDIT_EXTRADESC_MENU:
		switch ( toupper( arg[0] ) )
		{
		  case 'Q':
			break;
		  case 'A':
			CREATE( ed, EXTRA_DESCR_DATA, 1 );
			LINK( ed, room->first_extradescr, room->last_extradescr, next, prev );
			ed->keyword = str_dup( "" );
			ed->description = str_dup( "" );
			top_ed++;
			d->character->spare_ptr = ed;
			olc_log( d, "Added new exdesc" );
			oedit_disp_extra_choice(d);
			OLC_MODE(d) = REDIT_EXTRADESC_CHOICE;
			return;
		  case 'R':
			OLC_MODE(d) = REDIT_EXTRADESC_DELETE;
			send_to_char( d->character, "Delete which extra description? " );
			return;
		  default:
			if ( is_number(arg) )
			{
				ed = redit_find_extradesc( room, atoi(arg) );
				if ( !ed )
				{
					send_to_char( d->character, "Not found, try again: " );
					return;
				}
				d->character->spare_ptr = ed;
				oedit_disp_extra_choice(d);
				OLC_MODE(d) = REDIT_EXTRADESC_CHOICE;
			}
			else
				redit_disp_extradesc_menu(d);

			return;
		}
		break;

	  default:
		/* we should never get here */
		send_log( NULL, LOG_OLC, "redit_parse: reached default case in parse_redit" );
		break;
	} /* chiude lo switch */
	/* Log the changes, so we can keep track of those sneaky bastards */
	/* Don't log on the flags cause it does that above */
/*	if ( OLC_MODE(d) != REDIT_FLAGS )
		olc_log( d, arg );
*/
	/*. If we get this far, something has be changed .*/
	OLC_CHANGE(d) = TRUE;
	redit_disp_menu(d);
}
示例#5
0
DO_RET do_oredit( CHAR_DATA *ch, char *argument )
{
	DESCRIPTOR_DATA	*d;
	ROOM_DATA		*room;
	char			arg[MIL];

	if ( IS_MOB(ch) || !ch->desc )
	{
		send_to_char( ch, "I don't think so...\r\n" );
		return;
	}

	argument = one_argument( argument, arg );

	if ( !VALID_STR(argument) )
		room = ch->in_room;
	else
	{
		if ( is_number(arg) )
		{
			argument = one_argument( argument, arg );
			room = get_room_index( NULL, atoi(arg) );
		}
		else
		{
			send_to_char( ch, "Vnum must be specified in numbers!\r\n" );
			return;
		}
	}

	if ( !room )
	{
		send_to_char( ch, "That room does not exist!\r\n" );
		return;
	}

	/* Make sure the room isnt already being edited */
	for ( d = first_descriptor; d; d = d->next )
	{
		if ( d->connected == CON_REDIT )
		{
			if ( d->olc && OLC_VNUM(d) == room->vnum )
			{
				ch_printf( ch, "That room is currently being edited by %s.\r\n", d->character->name );
				return;
			}
		}
	}

	if ( !can_modify_room(ch, room) )
		return;

	d = ch->desc;
	CREATE( d->olc, OLC_DATA, 1 );
	OLC_VNUM(d)	= room->vnum;
	OLC_CHANGE(d) = FALSE;
	d->character->dest_buf = room;
	d->connected = CON_REDIT;
	redit_disp_menu( d );

	act( AT_ACTION, "$n starts using OLC.", ch, NULL, NULL, TO_ADMIN );
}
示例#6
0
/*
 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");
}
示例#7
0
int JScriptParse(Descriptor *d, const std::string &arg)
{
	if( arg.empty() )
		return 0;

	char leadingChar = (arg.empty() ? '\0' : toupper(arg[0]));
	
	switch( OLC_SCRIPT_EDIT_MODE(d) )
	{
	case JSCRIPT_MAIN_MENU:
		switch( leadingChar )
		{
		case 'N':
			d->send("Enter the vnum of the script you would like to add: ");
			OLC_SCRIPT_EDIT_MODE(d) = JSCRIPT_NEW_TRIGGER;
			break;
		case 'D':
			d->send("Which script would you like to delete?\r\n");
			OLC_SCRIPT_EDIT_MODE(d) = JSCRIPT_DEL_TRIGGER;
			break;
		case 'X':
			d->send("You exit the editor.\r\n");
			OLC_SCRIPT_EDIT_MODE( d ) = 0;
			if( d->olc->mob != NULL )
				medit_disp_menu( d ) ;
			else if( d->olc->room != NULL )
				redit_disp_menu( d );
			else if( d->olc->obj != NULL )
				oedit_disp_menu( d );
			else
				d->send("Error! Unknown origin point in javascript attachment editor.\r\n");
			break;
		default:
			d->send("Invalid option.\r\nTry again: ");
			break;
		}
		break;
	case JSCRIPT_NEW_TRIGGER:
	{
		if( !MiscUtil::isNumber(arg) ) {
			d->send("Your input must be numerical.\r\nTry again:");
			break;
		}
		if( JSManager::get()->triggerExists( atoi(arg.c_str()) ) == false )
			d->send("No trigger exists with that vnum.\r\n");
		else
			d->olc->jsScripts->push_back( JSManager::get()->getTrigger(atoi(arg.c_str())) );
		OLC_SCRIPT_EDIT_MODE( d ) = JSCRIPT_MAIN_MENU;
		JScriptDispMenu(d);
		break;
	}
	case JSCRIPT_DEL_TRIGGER:
	{
		if( !MiscUtil::isNumber(arg) ) {
			d->send("Your input must be numerical.\r\nTry again:");
			break;
		}
		int pos = atoi(arg.c_str())-1;
		if( pos >= 0 && pos < d->olc->jsScripts->size() ) {
			d->olc->jsScripts->erase( (*(d->olc->jsScripts)).begin() + pos );
		}
		OLC_SCRIPT_EDIT_MODE( d ) = JSCRIPT_MAIN_MENU;
		JScriptDispMenu(d);
		break;
	}
	default:
		d->send("Invalid Javascript Editor mode.\r\n");
		break;
	}
	return 1;
}