Example #1
0
/* Ripped off do_description for whois bio's -- Scryn*/
void do_bio( CHAR_DATA* ch, const char* argument)
{
   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs cannot set a bio.\r\n", ch );
      return;
   }
   if( ch->level < 5 )
   {
      set_char_color( AT_SCORE, ch );
      send_to_char( "You must be at least level five to write your bio...\r\n", ch );
      return;
   }
   if( !ch->desc )
   {
      bug( "%s", "do_bio: no descriptor" );
      return;
   }

   switch ( ch->substate )
   {
      default:
         bug( "%s", "do_bio: illegal substate" );
         return;

      case SUB_RESTRICTED:
         send_to_char( "You cannot use this command from within another command.\r\n", ch );
         return;

      case SUB_NONE:
         ch->substate = SUB_PERSONAL_BIO;
         ch->dest_buf = ch;
         start_editing( ch, ch->pcdata->bio );
         return;

      case SUB_PERSONAL_BIO:
         STRFREE( ch->pcdata->bio );
         ch->pcdata->bio = copy_buffer( ch );
         stop_editing( ch );
         return;
   }
}
Example #2
0
/*
 * Set your personal description				-Thoric
 */
void do_description( CHAR_DATA* ch, const char* argument)
{
   if( IS_NPC( ch ) )
   {
      send_to_char( "Monsters are too dumb to do that!\r\n", ch );
      return;
   }

   if( !ch->desc )
   {
      bug( "%s", "do_description: no descriptor" );
      return;
   }

   switch ( ch->substate )
   {
      default:
         bug( "%s", "do_description: illegal substate" );
         return;

      case SUB_RESTRICTED:
         send_to_char( "You cannot use this command from within another command.\r\n", ch );
         return;

      case SUB_NONE:
         ch->substate = SUB_PERSONAL_DESC;
         ch->dest_buf = ch;
         start_editing( ch, ch->description );
         return;

      case SUB_PERSONAL_DESC:
         STRFREE( ch->description );
         ch->description = copy_buffer( ch );
         stop_editing( ch );
         return;
   }
}
Example #3
0
/* Ripped off do_description for whois bio's -- Scryn*/
void do_bio( CHAR_DATA * ch, const char *argument )
{
   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs can't set bio's!\r\n", ch );
      return;
   }

   if( !ch->desc )
   {
      bug( "do_bio: no descriptor", 0 );
      return;
   }

   switch ( ch->substate )
   {
      default:
         bug( "do_bio: illegal substate", 0 );
         return;

      case SUB_RESTRICTED:
         send_to_char( "You cannot use this command from within another command.\r\n", ch );
         return;

      case SUB_NONE:
         ch->substate = SUB_PERSONAL_BIO;
         ch->dest_buf = ch;
         start_editing( ch, (char *)ch->pcdata->bio );
         return;

      case SUB_PERSONAL_BIO:
         STRFREE( ch->pcdata->bio );
         ch->pcdata->bio = copy_buffer( ch );
         stop_editing( ch );
         return;
   }
}
Example #4
0
void
edit_interface_rep::handle_keypress (string key, time_t t) {
  bool started= false;
#ifdef USE_EXCEPTIONS
  try {
#endif
    if (DEBUG_KEYBOARD) {
      //for (int i=0; i<N(key); i++)
      //  cout << ((int) (unsigned char) key[i]) << " ";
      //cout << "\n";
      debug_keyboard << "Pressed " << key << " at " << t << "\n";
    }
    //time_t t1= texmacs_time ();
    if (is_nil (eb)) apply_changes ();
    start_editing ();
    started= true;
    string zero= "a"; zero[0]= '\0';
    string gkey= replace (key, zero, "<#0>");
    call ("keyboard-press", object (gkey), object ((double) t));
    update_focus_loci ();
    if (!is_nil (focus_ids))
      call ("link-follow-ids", object (focus_ids), object ("focus"));
    notify_change (THE_DECORATIONS);
    end_editing ();
    //time_t t2= texmacs_time ();
    //if (t2 - t1 >= 10) cout << "handle_keypress took " << t2-t1 << "ms\n";
#ifdef USE_EXCEPTIONS
  }
  catch (string msg) {
    if (started) {
      cancel_editing ();
      interrupt_shortcut ();
    }
  }
  handle_exceptions ();
#endif
}
Example #5
0
void do_comment( CHAR_DATA * ch, char *argument )
{
   char buf[MAX_STRING_LENGTH];
   char arg[MAX_INPUT_LENGTH];
   char arg1[MAX_INPUT_LENGTH];
   NOTE_DATA *pnote;
   CHAR_DATA *victim;
   int vnum;
   int anum;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs can't use the comment command.\r\n", ch );
      return;
   }

   if( !ch->desc )
   {
      bug( "do_comment: no descriptor", 0 );
      return;
   }

   /*
    * Put in to prevent crashing when someone issues a comment command
    * from within the editor. -Narn 
    */
   if( ch->desc->connected == CON_EDITING || ch->desc->connected == CON_NOTE_TO )
   {
      send_to_char( "You can't use the comment command from within the editor.\r\n", ch );
      return;
   }

   switch ( ch->substate )
   {
      default:
         break;
      case SUB_WRITING_NOTE:
         if( !ch->pnote )
         {
            bug( "do_comment: note got lost?", 0 );
            send_to_char( "Your note got lost!\r\n", ch );
            stop_editing( ch );
            return;
         }
         if( ch->dest_buf != ch->pnote )
            bug( "do_comment: sub_writing_note: ch->dest_buf != ch->pnote", 0 );
         STRFREE( ch->pnote->text );
         ch->pnote->text = copy_buffer( ch );
         stop_editing( ch );
         return;
   }

   set_char_color( AT_NOTE, ch );
   argument = one_argument( argument, arg );
   smash_tilde( argument );

   if( !str_cmp( arg, "about" ) )
   {

      victim = get_char_world( ch, argument );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }


   }


   if( !str_cmp( arg, "list" ) )
   {
      victim = get_char_world( ch, argument );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( get_trust( victim ) >= get_trust( ch ) )
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      if( !victim->comments )
      {
         send_to_char( "There are no relevant comments.\r\n", ch );
         return;
      }

      vnum = 0;
      for( pnote = victim->comments; pnote; pnote = pnote->next )
      {
         vnum++;
         sprintf( buf, "%2d) %-10s [%s] %s\r\n", vnum, pnote->sender, pnote->date, pnote->subject );
/* Brittany added date to comment list and whois with above change */
         send_to_char( buf, ch );
      }

      /*
       * act( AT_ACTION, "$n glances over the notes.", ch, NULL, NULL, TO_ROOM ); 
       */
      return;
   }

   if( !str_cmp( arg, "read" ) )
   {
      bool fAll;

      argument = one_argument( argument, arg1 );
      victim = get_char_world( ch, arg1 );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( get_trust( victim ) >= get_trust( ch ) )
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      if( !victim->comments )
      {
         send_to_char( "There are no relevant comments.\r\n", ch );
         return;
      }



      if( !str_cmp( argument, "all" ) )
      {
         fAll = TRUE;
         anum = 0;
      }
      else if( is_number( argument ) )
      {
         fAll = FALSE;
         anum = atoi( argument );
      }
      else
      {
         send_to_char( "Note read which number?\r\n", ch );
         return;
      }

      vnum = 0;
      for( pnote = victim->comments; pnote; pnote = pnote->next )
      {
         vnum++;
         if( vnum == anum || fAll )
         {
            sprintf( buf, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n",
                     vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list );
            send_to_char( buf, ch );
            send_to_char( pnote->text, ch );
            /*
             * act( AT_ACTION, "$n reads a note.", ch, NULL, NULL, TO_ROOM ); 
             */
            return;
         }
      }

      send_to_char( "No such comment.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "write" ) )
   {
      note_attach( ch );
      ch->substate = SUB_WRITING_NOTE;
      ch->dest_buf = ch->pnote;
      start_editing( ch, ch->pnote->text );
      return;
   }

   if( !str_cmp( arg, "subject" ) )
   {
      note_attach( ch );
      STRFREE( ch->pnote->subject );
      ch->pnote->subject = STRALLOC( argument );
      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "to" ) )
   {
      note_attach( ch );
      STRFREE( ch->pnote->to_list );
      ch->pnote->to_list = STRALLOC( argument );
      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "clear" ) )
   {
      if( ch->pnote )
      {
         STRFREE( ch->pnote->text );
         STRFREE( ch->pnote->subject );
         STRFREE( ch->pnote->to_list );
         STRFREE( ch->pnote->date );
         STRFREE( ch->pnote->sender );
         DISPOSE( ch->pnote );
      }
      ch->pnote = NULL;

      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "show" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no comment in progress.\r\n", ch );
         return;
      }

      sprintf( buf, "%s: %s\r\nTo: %s\r\n", ch->pnote->sender, ch->pnote->subject, ch->pnote->to_list );
      send_to_char( buf, ch );
      send_to_char( ch->pnote->text, ch );
      return;
   }

   if( !str_cmp( arg, "post" ) )
   {
      char *strtime;

      if( !ch->pnote )
      {
         send_to_char( "You have no comment in progress.\r\n", ch );
         return;
      }

      argument = one_argument( argument, arg1 );
      victim = get_char_world( ch, arg1 );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( get_trust( victim ) > get_trust( ch ) )
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      /*
       * act( AT_ACTION, "$n posts a note.", ch, NULL, NULL, TO_ROOM ); 
       */

      strtime = ctime( &current_time );
      strtime[strlen( strtime ) - 1] = '\0';
      ch->pnote->date = STRALLOC( strtime );

      pnote = ch->pnote;
      ch->pnote = NULL;


      /*
       * LIFO to make life easier 
       */
      pnote->next = victim->comments;
      if( victim->comments )
         victim->comments->prev = pnote;
      pnote->prev = NULL;
      victim->comments = pnote;

      save_char_obj( victim );


#ifdef NOTDEFD
      fclose( fpReserve );
      sprintf( notefile, "%s/%s", BOARD_DIR, board->note_file );
      if( ( fp = fopen( notefile, "a" ) ) == NULL )
      {
         perror( notefile );
      }
      else
      {
         fprintf( fp, "Sender  %s~\nDate    %s~\nTo      %s~\nSubject %s~\nText\n%s~\n\n",
                  pnote->sender, pnote->date, pnote->to_list, pnote->subject, pnote->text );
         fclose( fp );
      }
      fpReserve = fopen( NULL_FILE, "r" );
#endif

      send_to_char( "Ok.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "remove" ) )
   {
      argument = one_argument( argument, arg1 );
      victim = get_char_world( ch, arg1 );
      if( !victim )
      {
         send_to_char( "They're not logged on!\r\n", ch );  /* maybe fix this? */
         return;
      }

      if( IS_NPC( victim ) )
      {
         send_to_char( "No comments about mobs\r\n", ch );
         return;
      }

      if( ( get_trust( victim ) >= get_trust( ch ) ) || ( get_trust( ch ) < 58 ) )  /* switch to some LEVEL_ thingie */
      {
         send_to_char( "You're not of the right caliber to do this...\r\n", ch );
         return;
      }

      /*
       * argument = one_argument(argument, arg); 
       */
      if( !is_number( argument ) )
      {
         send_to_char( "Comment remove which number?\r\n", ch );
         return;
      }

      anum = atoi( argument );
      vnum = 0;
      for( pnote = victim->comments; pnote; pnote = pnote->next )
      {
         vnum++;
         if( ( 58 <= get_trust( ch ) ) /* switch to some LEVEL_ thingie */
             && ( vnum == anum ) )
         {
            comment_remove( victim, pnote );
            send_to_char( "Ok.\r\n", ch );
            /*
             * act( AT_ACTION, "$n removes a note.", ch, NULL, NULL, TO_ROOM ); 
             */
            return;
         }
      }

      send_to_char( "No such comment.\r\n", ch );
      return;
   }

   send_to_char( "Type 'help comment' for usage (i hope!).\r\n", ch );
   return;
}
Example #6
0
/* olc editnews command */
void do_editnews( CHAR_DATA* ch, const char* argument)
{
   char arg[MAX_INPUT_LENGTH];

   if( IS_NPC( ch ) || !IS_IMMORTAL( ch ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }

   set_char_color( AT_GREEN, ch );

   switch ( ch->substate )
   {
      default:
         break;

      case SUB_NEWS_POST:
      {
         NEWS *news = NULL;

         news = ( NEWS * ) ch->dest_buf;
         STRFREE( news->post );
         news->post = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         renumber_news(  );
         save_news(  );
         return;
      }
         break;

      case SUB_NEWS_EDIT:
      {
         NEWS *news = NULL;

         news = ( NEWS * ) ch->dest_buf;
         STRFREE( news->post );
         news->post = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         renumber_news(  );
         save_news(  );
         return;
      }
         break;
   }

   argument = one_argument( argument, arg );

   if( arg[0] == '\0' )
   {
      send_to_char( "Syntax: editnews addtype <name>\r\n"
                    "        editnews addnews <type> <subject>\r\n"
                    "        editnews removetype <number>\r\n"
                    "        editnews removenews <type> <number>\r\n"
                    "        editnews edittype <field> <value>\r\n"
                    "        editnews editnews <type> <number> <new subject [optional]>\r\n"
                    " Fields being one of the following:\r\n" " name header cmd_name level\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "save" ) )
   {
      renumber_news(  );
      save_news(  );
      send_to_char( "News saved.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "addtype" ) )
   {
      NEWS_TYPE *type = NULL;

      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews addtype <name>\r\n", ch );
         return;
      }

      if( top_news_type >= NEWS_MAX_TYPES )
      {
         send_to_char( "There are too many news types.\r\n", ch );
         return;
      }

      CREATE( type, NEWS_TYPE, 1 );
      type->name = STRALLOC( argument );
      type->cmd_name = STRALLOC( argument );
      type->vnum = top_news_type++;
      type->level = -1;

      news_command_table[type->vnum] = STRALLOC( type->cmd_name );

      LINK( type, first_news_type, last_news_type, next, prev );
      ch_printf( ch, "Newstype '%s' created.\r\n", argument );
      return;
   }

   if( !str_cmp( arg, "removetype" ) )
   {
      NEWS_TYPE *type = NULL;
      NEWS *news = NULL, *news_next;

      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews removetype <name>\r\n", ch );
         return;
      }

      if( ( type = figure_type( argument ) ) == NULL )
      {
         send_to_char( "Invaild newstype.\r\n", ch );
         return;
      }

      UNLINK( type, first_news_type, last_news_type, next, prev );
      STRFREE( type->name );
      STRFREE( type->header );
      STRFREE( type->cmd_name );
      STRFREE( news_command_table[type->vnum] );
      STRFREE( news_command_table[type->level] );

      for( news = type->first_news; news; news = news_next )
      {
         news_next = news->next;

         UNLINK( news, type->first_news, type->last_news, next, prev );
         STRFREE( news->name );
         STRFREE( news->title );
         STRFREE( news->date );
         STRFREE( news->post );
         DISPOSE( news );
      }

      DISPOSE( type );
      --top_news_type;
      renumber_news(  );
      save_news(  );
      ch_printf( ch, "Newstype '%s' removed.\r\n", argument );
      return;
   }

   if( !str_cmp( arg, "edittype" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      char arg3[MAX_INPUT_LENGTH];
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      argument = one_argument( argument, arg3 );
      if( arg2[0] == '\0' || arg3[0] == '\0' )
      {
         send_to_char( "Syntax: editnews edittype <type> <field> <value>\r\n", ch );
         send_to_char( "Fields being one of the following:\r\n" "name header cmd_name level\r\n", ch );
         return;
      }

      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype.\r\n", ch );
         return;
      }

      if( !str_cmp( arg3, "cmd_name" ) )
      {
         type->cmd_name = STRALLOC( argument );
         news_command_table[type->vnum] = STRALLOC( type->cmd_name );
         send_to_char( "Cmd_name set.\r\n", ch );
         save_news(  );
         return;
      }
      else if( !str_cmp( arg3, "name" ) )
      {
         type->name = STRALLOC( argument );
         send_to_char( "Name set.\r\n", ch );
         save_news(  );
         return;
      }
      else if( !str_cmp( arg3, "level" ) )
      {
         if( argument[0] == '\0' )
         {
            ch_printf( ch, "%d\r\n", type->level );
            return;
         }
         else
            type->level = atoi( argument );
         send_to_char( "Level set.\r\n", ch );
         save_news(  );
         return;
      }
      else
      {
         send_to_char( "Syntax: editnews edittype <type> <field> <value>\r\n", ch );
         send_to_char( "Fields being one of the following:\r\n" "name header cmd_name level\r\n", ch );
         return;
      }
   }

   if( !str_cmp( arg, "addnews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      NEWS_TYPE *type = NULL;
      NEWS *news = NULL;

      argument = one_argument( argument, arg2 );

      if( arg2[0] == '\0' || argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews addnews <type> <subject>\r\n", ch );
         return;
      }

      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invaild newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      CREATE( news, NEWS, 1 );
      news->title = STRALLOC( argument );
      news->name = STRALLOC( ch->name );
      news->date = STRALLOC( stamp_time(  ) );
      news->post = STRALLOC( "" );

      /*
       * pop character into a writing buffer 
       */
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;

      ch->substate = SUB_NEWS_POST;
      ch->dest_buf = news;
      start_editing( ch, news->post );
      LINK( news, type->first_news, type->last_news, next, prev );
      return;
   }

   if( !str_cmp( arg, "editnews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      char arg3[MAX_INPUT_LENGTH];
      NEWS *news = NULL;
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      argument = one_argument( argument, arg3 );
      if( arg2[0] == '\0' )
      {
         send_to_char( "Syntax: editnews editnews <type> <number> <new subject [optional]>\r\n", ch );
         return;
      }

      /*
       * changed for new -newstype- indexing - 5/5/02 
       */
      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      if( ( news = grab_news( type, arg3 ) ) == NULL )
      {
         pager_printf_color( ch, "That's not a valid news number.\r\nUse '%s' to view the valid numbers.\r\n",
                             type->cmd_name );
         return;
      }

      /*
       * a changed title 
       */
      if( argument[0] != '\0' )
         news->title = STRALLOC( argument );

      /*
       * new date news was edited 
       */
      news->date = STRALLOC( stamp_time(  ) );
      /*
       * pop character into a writing buffer 
       */
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;

      ch->substate = SUB_NEWS_EDIT;
      ch->dest_buf = news;
      start_editing( ch, news->post );
      return;
   }

   if( !str_cmp( arg, "removenews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      NEWS *news = NULL;
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      if( argument[0] == '\0' || arg2[0] == '\0' )
      {
         send_to_char( "Syntax: editnews remove <number>\r\n", ch );
         return;
      }

      /*
       * changed for new -newstype- indexing - 5/5/02 
       */
      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      if( ( news = grab_news( type, argument ) ) == NULL )
      {
         send_to_char( "Type 'news' to gain a list of the news numbers.\r\n", ch );
         return;
      }

      UNLINK( news, type->first_news, type->last_news, next, prev );
      STRFREE( news->name );
      STRFREE( news->title );
      STRFREE( news->date );
      STRFREE( news->post );
      DISPOSE( news );
      renumber_news(  );
      save_news(  );
      send_to_char( "News item removed.\r\n", ch );
      return;
   }
}
Example #7
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);
}
Example #8
0
void do_mapout( CHAR_DATA* ch, const char* argument)
{
   char arg[MAX_INPUT_LENGTH];
   OBJ_DATA *map_obj;   /* an obj made with map as an ed */
   OBJ_INDEX_DATA *map_obj_index;   /*    obj_index for previous     */
   EXTRA_DESCR_DATA *ed;   /*    the ed for it to go in     */
   int rooms, rows, cols, avail_rooms;

   if( !ch )
   {
      bug( "%s", "do_mapout: null ch" );
      return;
   }
   if( IS_NPC( ch ) )
   {
      send_to_char( "Not in mobs.\r\n", ch );
      return;
   }
   if( !ch->desc )
   {
      bug( "%s", "do_mapout: no descriptor" );
      return;
   }
   switch ( ch->substate )
   {
      default:
         break;
      case SUB_WRITING_NOTE:
         if( ch->dest_buf != ch->pnote )
            bug( "%s", "do_mapout: sub_writing_map: ch->dest_buf != ch->pnote" );
         STRFREE( ch->pnote->text );
         ch->pnote->text = copy_buffer( ch );
         stop_editing( ch );
         return;
   }

   set_char_color( AT_NOTE, ch );
   argument = one_argument( argument, arg );
   smash_tilde( argument );

   if( !str_cmp( arg, "stat" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress.\r\n", ch );
         return;
      }
      map_stats( ch, &rooms, &rows, &cols );
      ch_printf( ch, "Map represents %d rooms, %d rows, and %d columns\r\n", rooms, rows, cols );
      avail_rooms = num_rooms_avail( ch );
      ch_printf( ch, "You currently have %d unused rooms.\r\n", avail_rooms );
      act( AT_ACTION, "$n glances at an etherial map.", ch, NULL, NULL, TO_ROOM );
      return;
   }


   if( !str_cmp( arg, "write" ) )
   {
      note_attach( ch );
      ch->substate = SUB_WRITING_NOTE;
      ch->dest_buf = ch->pnote;
      start_editing( ch, ch->pnote->text );
      return;
   }
   if( !str_cmp( arg, "clear" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress\r\n", ch );
         return;
      }
      STRFREE( ch->pnote->text );
      STRFREE( ch->pnote->subject );
      STRFREE( ch->pnote->to_list );
      STRFREE( ch->pnote->date );
      STRFREE( ch->pnote->sender );
      DISPOSE( ch->pnote );
      ch->pnote = NULL;
      send_to_char( "Map cleared.\r\n", ch );
      return;
   }
   if( !str_cmp( arg, "show" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress.\r\n", ch );
         return;
      }
      send_to_char( ch->pnote->text, ch );
      do_mapout( ch, "stat" );
      return;
   }
   if( !str_cmp( arg, "create" ) )
   {
      if( !ch->pnote )
      {
         send_to_char( "You have no map in progress.\r\n", ch );
         return;
      }
      map_stats( ch, &rooms, &rows, &cols );
      avail_rooms = num_rooms_avail( ch );

      /*
       * check for not enough rooms 
       */
      if( rooms > avail_rooms )
      {
         send_to_char( "You don't have enough unused rooms allocated!\r\n", ch );
         return;
      }
      act( AT_ACTION, "$n warps the very dimensions of space!", ch, NULL, NULL, TO_ROOM );

      map_to_rooms( ch, NULL );  /* this does the grunt work */

      map_obj_index = get_obj_index( 91 );
      if( map_obj_index )
      {
         map_obj = create_object( map_obj_index, 0 );
         ed = SetOExtra( map_obj, "runes map scrawls" );
         STRFREE( ed->description );
         ed->description = QUICKLINK( ch->pnote->text );
         obj_to_char( map_obj, ch );
      }
      else
      {
         send_to_char( "Couldn't give you a map object.  Need Great Eastern Desert\r\n", ch );
         return;
      }

      do_mapout( ch, "clear" );
      send_to_char( "Ok.\r\n", ch );
      return;
   }
   send_to_char( "mapout write: create a map in edit buffer.\r\n", ch );
   send_to_char( "mapout stat: get information about a written, but not yet created map.\r\n", ch );
   send_to_char( "mapout clear: clear a written, but not yet created map.\r\n", ch );
   send_to_char( "mapout show: show a written, but not yet created map.\r\n", ch );
   send_to_char( "mapout create: turn a written map into rooms in your assigned room vnum range.\r\n", ch );
   return;
}
Example #9
0
void do_setquest( CHAR_DATA *ch, char *argument )
{
    char                    arg1[MIL],
                            arg2[MIL],
                            arg3[MIL],
                            arg4[MIL];
    QUEST_DATA             *quest;
    int                     x;

    set_char_color( AT_PLAIN, ch );

    if ( IS_NPC( ch ) ) {
        error( ch );
        return;
    }

    if ( !IS_IMMORTAL( ch ) ) {
        error( ch );
        return;
    }

    if ( !ch->desc ) {
        bug( "%s", "do_setquest (desc): no descriptor" );
        return;
    }

    switch ( ch->substate ) {
        default:
            break;

        case SUB_QUEST_DESC:
            if ( !ch->dest_buf || !( quest = ( QUEST_DATA * ) ch->dest_buf ) ) {
                bug( "%s: sub_quest_desc: NULL ch->dest_buf", __FUNCTION__ );
                ch->substate = SUB_NONE;
                return;
            }
            ch->dest_buf = NULL;
            if ( VLD_STR( quest->desc ) )
                STRFREE( quest->desc );
            quest->desc = copy_buffer( ch );
            stop_editing( ch );
            write_quest_list(  );
            ch->substate = SUB_NONE;
            return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( arg1[0] == '\0' ) {
        send_to_char( "&cUsage: setquest save all\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> create\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> delete\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> chapter <#> delete\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> desc\r\n", ch );
        send_to_char( "       setquest <&Cqname&c> <&Cfield&c>\r\n", ch );
        send_to_char( "       setquest <&Cquest&c> remove <&Cplayer&c>\r\n", ch );
        send_to_char( "       showquest <&Cqname&c>\r\n", ch );
        send_to_char( "  Field being one of:\r\n", ch );
        send_to_char( "level svnum stype chapters chapter timelimit skipchapters glory\r\n", ch );
        send_to_char( "\r\nchapter <n> <field2>\r\n", ch );
        send_to_char( "  Field2 being one of:\r\n", ch );
        send_to_char( "create delete svnum stype\r\n", ch );
        send_to_char( "name timelimit level kamount\r\n", ch );
        send_to_char( "Note: 3600 = 1 hour timelimit\r\n", ch );
        return;
    }

    if ( ( !str_cmp( arg1, "tutorial" ) && ch->level < 108 )
         || ( !str_cmp( arg1, "etutorial" ) && ch->level < 108 ) || ( !str_cmp( arg1, "dtutorial" )
                                                                      && ch->level < 108 ) ) {
        send_to_char( "You need Vladaar's permission to change anything with tutorials.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg1, "save" ) ) {
        if ( !str_cmp( arg2, "all" ) ) {
            write_quest_list(  );
            send_to_char( "All quests saved.\r\n", ch );
            return;
        }
    }

    quest = get_quest_from_name( arg1 );

    if ( !str_cmp( arg2, "create" ) ) {
        if ( quest && VLD_STR( quest->name ) && !str_cmp( quest->name, arg1 ) ) {
            ch_printf( ch, "(%s): quest already exists!\r\n", quest->name );
            return;
        }

        CREATE( quest, QUEST_DATA, 1 );
        quest->name = STRALLOC( arg1 );
        quest->number = -1;
        add_new_quest( ch, quest );
        write_quest_list(  );
        return;
    }

    if ( !quest ) {
        send_to_char( "No quest by that name.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "desc" ) ) {
        if ( !ch->desc ) {
            bug( "%s", "do_setquest (desc): no descriptor" );
            return;
        }

        ch->substate = SUB_QUEST_DESC;
        ch->dest_buf = quest;
        start_editing( ch, quest->desc );
        return;
    }

    if ( !str_cmp( arg2, "delete" ) ) {
        free_quest( quest );
        send_to_char( "Deleted.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "skipchapters" ) ) {
        quest->skipchapters = !quest->skipchapters;
        ch_printf( ch, "That quest will %s allow chapters to be skipped.\r\n",
                   quest->skipchapters ? "now" : "no longer" );
        return;
    }

    if ( !str_cmp( arg2, "chapters" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 30 ) {
            send_to_char( "Chapters must be between 0 and 30.\r\n", ch );
            return;
        }
        quest->chapters = x;
        send_to_char( "Done.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "svnum" ) ) {
        quest->svnum = atoi( argument );
        ch_printf( ch, "That quest's svnum (starting vnum) is set to %d.\r\n", quest->svnum );
        return;
    }

    if ( !str_cmp( arg2, "stype" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 2 ) {
            send_to_char
                ( "Can only set stype (starting type) to 0 for Mobiles, 1 for Objects, 2 for Rooms.\r\n",
                  ch );
            return;
        }
        quest->stype = x;
        ch_printf( ch, "That quest's stype (starting type) is set to %d[%s].\r\n", quest->stype,
                   ( quest->stype == 0 ) ? "Mobile" : ( quest->stype ==
                                                        1 ) ? "Object" : ( quest->stype ==
                                                                           2 ) ? "Room" :
                   "Unknown" );
        return;
    }

    if ( !str_cmp( arg2, "glory" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 1 ) {
            send_to_char( "Can only set 0 for no glory, or 1 for glory.\r\n", ch );
            return;
        }
        quest->glory = x;
        return;
    }

    if ( !str_cmp( arg2, "chapter" ) ) {
        CHAP_DATA              *chap = NULL;

        argument = one_argument( argument, arg3 );
        argument = one_argument( argument, arg4 );

        int                     chapno = atoi( arg3 );

        if ( chapno < 1 || chapno > MAX_CHAPTERS ) {
            ch_printf( ch, "Chapter range is 1 to %d.\r\n", MAX_CHAPTERS );
            return;
        }

        if ( !str_cmp( arg4, "create" ) ) {
            if ( get_chap_from_quest( chapno, quest ) ) {
                send_to_char( "That chapter already exists!\r\n", ch );
                return;
            }

            if ( !get_chap_from_quest( ( chapno - 1 ), quest ) && chapno > 1 ) {
                ch_printf( ch, "How can you create chapter %d before chapter %d even exists?\r\n",
                           chapno, chapno - 1 );
                return;
            }
            if ( chapno > quest->chapters ) {
                ch_printf( ch, "How can you create chapter %d when there are only %d chapters?\r\n",
                           chapno, quest->chapters );
                send_to_char( "Set more - 'setquest (questname) chapters (number)'.\r\n", ch );
                return;
            }
            CREATE( chap, CHAP_DATA, 1 );
            chap->number = chapno;
            add_chapter( quest, chap );
            send_to_char( "New chapter added.\r\n", ch );
            write_quest_list(  );
            return;
        }

        chap = get_chap_from_quest( chapno, quest );

        if ( !chap ) {
            send_to_char( "No such chapter.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "delete" ) ) {
            free_chapter( quest, chap );
            send_to_char( "Chapter Deleted.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "name" ) ) {
            if ( VLD_STR( chap->desc ) )
                STRFREE( chap->desc );
            if ( VLD_STR( argument ) ) {
                if ( strlen( argument ) > 50 )
                    argument[50] = '\0';
                chap->desc = STRALLOC( argument );
            }
            write_quest_list(  );
            send_to_char( "Done.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "timelimit" ) ) {
            x = atoi( argument );

            if ( x < 0 || x > 3600 ) {
                send_to_char( "Time limit is between 0 and 3600 (one hour).\r\n", ch );
                return;
            }

            chap->timelimit = x;
            send_to_char( "Done.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "kamount" ) ) {
            int                     kamount = atoi( argument );

            if ( kamount < 0 ) {
                send_to_char( "You have to set kamount to 0 or higher.\r\n", ch );
                return;
            }
            chap->kamount = kamount;
            send_to_char( "Done.\r\n", ch );
            return;
        }

        if ( !str_cmp( arg4, "level" ) ) {
            int                     level = atoi( argument );

            if ( level < 0 || level > MAX_LEVEL ) {
                ch_printf( ch, "Level range is between 0 and %d.\r\n", MAX_LEVEL );
                return;
            }

            chap->level = level;
            send_to_char( "Done.\r\n", ch );
            return;
        }
        do_setquest( ch, ( char * ) "" );
        return;
    }

    if ( !str_cmp( arg2, "level" ) ) {
        x = atoi( argument );
        if ( x < 1 || x > MAX_LEVEL ) {
            send_to_char( "Quest level must be between 1 and max.\r\n", ch );
            return;
        }
        quest->level = x;
        send_to_char( "Done.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "timelimit" ) ) {
        x = atoi( argument );
        if ( x < 0 || x > 3600 ) {
            send_to_char
                ( "Quest time limit must be between 0 (no timer) and 3600 seconds (1 hour).\r\n",
                  ch );
            return;
        }
        quest->timelimit = x;
        send_to_char( "Done.\r\n", ch );
        return;
    }

    if ( !str_cmp( arg2, "remove" ) ) {
        CHAR_DATA              *victim;
        CHQUEST_DATA           *chquest;

        if ( ( victim = get_char_world( ch, argument ) ) != NULL && !IS_NPC( victim ) ) {
            x = get_number_from_quest( quest );
            for ( chquest = victim->pcdata->first_quest; chquest; chquest = chquest->next ) {
                if ( chquest->questnum != quest->number )
                    continue;
                UNLINK( chquest, victim->pcdata->first_quest, victim->pcdata->last_quest, next,
                        prev );
                DISPOSE( chquest );
                ch_printf( ch, "You remove quest %s from %s.\r\n", quest->name, victim->name );
                ch_printf( victim, "Quest %s has been removed from your journal.\r\n",
                           quest->name );
                return;
            }
            send_to_char( "That player isn't currently on that quest.\r\n", ch );
            return;
        }
        else
            send_to_char( "That player isn't currently online.\r\n", ch );
        return;
    }

    do_setquest( ch, ( char * ) "" );
    return;
}
Example #10
0
/* Set slay values online - Samson 8-3-98 */
void do_setslay( CHAR_DATA * ch, char *argument )
{
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   SLAY_DATA *slay;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }

   switch ( ch->substate )
   {
      default:
         break;

      case SUB_RESTRICTED:
         send_to_char( "You cannot do this while in another command.\r\n", ch );
         return;

      case SUB_SLAYCMSG:
         slay = ( SLAY_DATA * ) ch->dest_buf;
         STRFREE( slay->cmsg );
         slay->cmsg = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         save_slays(  );
         return;
      case SUB_SLAYVMSG:
         slay = ( SLAY_DATA * ) ch->dest_buf;
         STRFREE( slay->vmsg );
         slay->vmsg = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         save_slays(  );
         return;
      case SUB_SLAYRMSG:
         slay = ( SLAY_DATA * ) ch->dest_buf;
         STRFREE( slay->rmsg );
         slay->rmsg = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         save_slays(  );
         return;
   }

   smash_tilde( argument );
   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );

   if( arg1[0] == '\0' )
   {
      send_to_char( "Usage: setslay <slaytype> <field> <value>\r\n", ch );
      send_to_char( "Usage: setslay save\r\n", ch );
      send_to_char( "\r\nField being one of:\r\n", ch );
      send_to_char( "owner color cmsg vmsg rmsg\r\n", ch );
      return;
   }

   if( !str_cmp( arg1, "save" ) )
   {
      save_slays(  );
      send_to_char( "Slay table saved.\r\n", ch );
      return;
   }

   if( ( slay = get_slay( arg1 ) ) == NULL )
   {
      send_to_char( "No such slaytype.\r\n", ch );
      return;
   }

   if( !str_cmp( arg2, "owner" ) )
   {
      STRFREE( slay->owner );
      slay->owner = STRALLOC( argument );
      send_to_char( "New owner set.\r\n", ch );
      save_slays(  );
      return;
   }

   if( !str_cmp( arg2, "cmsg" ) )
   {
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;
      ch->substate = SUB_SLAYCMSG;
      ch->dest_buf = slay;
      start_editing( ch, slay->cmsg );
      return;
   }

   if( !str_cmp( arg2, "vmsg" ) )
   {
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;
      ch->substate = SUB_SLAYVMSG;
      ch->dest_buf = slay;
      start_editing( ch, slay->vmsg );
      return;
   }

   if( !str_cmp( arg2, "rmsg" ) )
   {
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;
      ch->substate = SUB_SLAYRMSG;
      ch->dest_buf = slay;
      start_editing( ch, slay->rmsg );
      return;
   }

   if( !str_cmp( arg2, "color" ) )
   {
      slay->color = atoi( argument );
      send_to_char( "Slay color set.\r\n", ch );
      save_slays(  );
      return;
   }

   do_setslay( ch, "" );
   return;
}
Example #11
0
void do_note( CHAR_DATA * ch, char *arg_passed, bool IS_MAIL )
{
  char buf[MAX_STRING_LENGTH];
  char arg[MAX_INPUT_LENGTH];
  NOTE_DATA *pnote = NULL;
  BOARD_DATA *board = NULL;
  int vnum = 0;
  int anum = 0;
  int first_list = 0;
  OBJ_DATA *paper = NULL, *tmpobj = NULL;
  EXTRA_DESCR_DATA *ed = NULL;
  char notebuf[MAX_STRING_LENGTH];
  char short_desc_buf[MAX_STRING_LENGTH];
  char long_desc_buf[MAX_STRING_LENGTH];
  char keyword_buf[MAX_STRING_LENGTH];
  bool mfound = FALSE;
  bool wasfound = FALSE;

  if( IS_NPC( ch ) )
    return;

  if( !ch->desc )
  {
    bug( "do_note: no descriptor", 0 );
    return;
  }

  switch ( ch->substate )
  {
    default:
      break;
    case SUB_WRITING_NOTE:
      if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL
	  || paper->item_type != ITEM_PAPER )
      {
	bug( "do_note: player not holding paper", 0 );
	stop_editing( ch );
	return;
      }
      ed = ( EXTRA_DESCR_DATA * ) ch->dest_buf;
      STRFREE( ed->description );
      ed->description = copy_buffer( ch );
      stop_editing( ch );
      return;
  }

  set_char_color( AT_NOTE, ch );
  arg_passed = one_argument( arg_passed, arg );
  smash_tilde( arg_passed );

  if( !str_cmp( arg, "list" ) )
  {
    board = find_board( ch );
    if( !board )
    {
      send_to_char( "There is no board here to look at.\r\n", ch );
      return;
    }
    if( !can_read( ch, board ) )
    {
      send_to_char
	( "You cannot make any sense of the cryptic scrawl on this board...\r\n",
	  ch );
      return;
    }

    first_list = atoi( arg_passed );
    if( first_list )
    {
      if( IS_MAIL )
      {
	send_to_char
	  ( "You cannot use a list number (at this time) with mail.\r\n",
	    ch );
	return;
      }

      if( first_list < 1 )
      {
	send_to_char( "You can't read a message before 1!\r\n", ch );
	return;
      }
    }


    if( !IS_MAIL )
    {
      vnum = 0;
      set_pager_color( AT_NOTE, ch );
      for( pnote = board->first_note; pnote; pnote = pnote->next )
      {
	vnum++;
	if( ( first_list && vnum >= first_list ) || !first_list )
	  pager_printf( ch, "%2d%c %-12s%c %-12s %s\r\n",
	      vnum,
	      is_note_to( ch, pnote ) ? ')' : '}',
	      pnote->sender,
	      ( pnote->voting !=
		VOTE_NONE ) ? ( pnote->voting ==
		  VOTE_OPEN ? 'V' : 'C' ) : ':',
	      pnote->to_list, pnote->subject );
      }
      act( AT_ACTION, "$n glances over the messages.", ch, NULL, NULL,
	  TO_ROOM );
      return;
    }
    else
    {
      vnum = 0;


      if( IS_MAIL )		/* SB Mail check for Brit */
      {
	for( pnote = board->first_note; pnote; pnote = pnote->next )
	  if( is_note_to( ch, pnote ) )
	    mfound = TRUE;

	if( !mfound && !IS_IMMORTAL( ch ) )
	{
	  ch_printf( ch, "You have no mail.\r\n" );
	  return;
	}
      }

      for( pnote = board->first_note; pnote; pnote = pnote->next )
	if( is_note_to( ch, pnote ) || IS_IMMORTAL( ch ) )
	  ch_printf( ch, "%2d%c %s: %s\r\n",
	      ++vnum,
	      is_note_to( ch, pnote ) ? '-' : '}',
	      pnote->sender, pnote->subject );
      return;
    }
  }

  if( !str_cmp( arg, "read" ) )
  {
    bool fAll = FALSE;

    board = find_board( ch );
    if( !board )
    {
      send_to_char( "There is no board here to look at.\r\n", ch );
      return;
    }
    if( !can_read( ch, board ) )
    {
      send_to_char
	( "You cannot make any sense of the cryptic scrawl on this board...\r\n",
	  ch );
      return;
    }

    if( !str_cmp( arg_passed, "all" ) )
    {
      fAll = TRUE;
      anum = 0;
    }
    else if( is_number( arg_passed ) )
    {
      fAll = FALSE;
      anum = atoi( arg_passed );
    }
    else
    {
      send_to_char( "Note read which number?\r\n", ch );
      return;
    }

    set_pager_color( AT_NOTE, ch );
    if( !IS_MAIL )
    {
      vnum = 0;
      for( pnote = board->first_note; pnote; pnote = pnote->next )
      {
	vnum++;
	if( vnum == anum || fAll )
	{
	  wasfound = TRUE;
	  pager_printf( ch, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n%s",
	      vnum,
	      pnote->sender,
	      pnote->subject,
	      pnote->date, pnote->to_list, pnote->text );

	  if( pnote->yesvotes[0] != '\0' || pnote->novotes[0] != '\0'
	      || pnote->abstentions[0] != '\0' )
	  {
	    send_to_pager
	      ( "------------------------------------------------------------\r\n",
		ch );
	    pager_printf( ch,
		"Votes:\r\nYes:     %s\r\nNo:      %s\r\nAbstain: %s\r\n",
		pnote->yesvotes, pnote->novotes,
		pnote->abstentions );
	  }
	  act( AT_ACTION, "$n reads a message.", ch, NULL, NULL,
	      TO_ROOM );
	}
      }
      if( !wasfound )
	ch_printf( ch, "No such message: %d\r\n", anum );
      return;
    }
    else
    {
      vnum = 0;
      for( pnote = board->first_note; pnote; pnote = pnote->next )
      {
	if( is_note_to( ch, pnote ) || IS_IMMORTAL( ch ) )
	{
	  vnum++;
	  if( vnum == anum || fAll )
	  {
	    wasfound = TRUE;
	    pager_printf( ch, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n%s",
		vnum,
		pnote->sender,
		pnote->subject,
		pnote->date,
		pnote->to_list, pnote->text );
	  }
	}
      }
      if( !wasfound )
	ch_printf( ch, "No such message: %d\r\n", anum );
      return;
    }
  }

  /* Voting added by Narn, June '96 */
  if( !str_cmp( arg, "vote" ) )
  {
    char arg2[MAX_INPUT_LENGTH];
    arg_passed = one_argument( arg_passed, arg2 );

    board = find_board( ch );
    if( !board )
    {
      send_to_char( "There is no bulletin board here.\r\n", ch );
      return;
    }
    if( !can_read( ch, board ) )
    {
      send_to_char( "You cannot vote on this board.\r\n", ch );
      return;
    }

    if( is_number( arg2 ) )
      anum = atoi( arg2 );
    else
    {
      send_to_char( "Note vote which number?\r\n", ch );
      return;
    }

    vnum = 1;
    for( pnote = board->first_note; pnote && vnum < anum;
	pnote = pnote->next )
      vnum++;
    if( !pnote )
    {
      send_to_char( "No such note.\r\n", ch );
      return;
    }

    /* Options: open close yes no abstain */
    /* If you're the author of the note and can read the board you can open 
       and close voting, if you can read it and voting is open you can vote.
       */
    if( !str_cmp( arg_passed, "open" ) )
    {
      if( str_cmp( ch->name, pnote->sender ) )
      {
	send_to_char( "You are not the author of this message.\r\n",
	    ch );
	return;
      }
      pnote->voting = VOTE_OPEN;
      act( AT_ACTION, "$n opens voting on a note.", ch, NULL, NULL,
	  TO_ROOM );
      send_to_char( "Voting opened.\r\n", ch );
      write_board( board );
      return;
    }
    if( !str_cmp( arg_passed, "close" ) )
    {
      if( str_cmp( ch->name, pnote->sender ) )
      {
	send_to_char( "You are not the author of this message.\r\n",
	    ch );
	return;
      }
      pnote->voting = VOTE_CLOSED;
      act( AT_ACTION, "$n closes voting on a note.", ch, NULL, NULL,
	  TO_ROOM );
      send_to_char( "Voting closed.\r\n", ch );
      write_board( board );
      return;
    }

    /* Make sure the note is open for voting before going on. */
    if( pnote->voting != VOTE_OPEN )
    {
      send_to_char( "Voting is not open on this note.\r\n", ch );
      return;
    }

    /* Can only vote once on a note. */
    sprintf( buf, "%s %s %s",
	pnote->yesvotes, pnote->novotes, pnote->abstentions );
    if( is_name( ch->name, buf ) )
    {
      send_to_char( "You have already voted on this note.\r\n", ch );
      return;
    }
    if( !str_cmp( arg_passed, "yes" ) )
    {
      sprintf( buf, "%s %s", pnote->yesvotes, ch->name );
      DISPOSE( pnote->yesvotes );
      pnote->yesvotes = str_dup( buf );
      act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM );
      send_to_char( "Ok.\r\n", ch );
      write_board( board );
      return;
    }
    if( !str_cmp( arg_passed, "no" ) )
    {
      sprintf( buf, "%s %s", pnote->novotes, ch->name );
      DISPOSE( pnote->novotes );
      pnote->novotes = str_dup( buf );
      act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM );
      send_to_char( "Ok.\r\n", ch );
      write_board( board );
      return;
    }
    if( !str_cmp( arg_passed, "abstain" ) )
    {
      sprintf( buf, "%s %s", pnote->abstentions, ch->name );
      DISPOSE( pnote->abstentions );
      pnote->abstentions = str_dup( buf );
      act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM );
      send_to_char( "Ok.\r\n", ch );
      write_board( board );
      return;
    }
    do_note( ch, STRLIT_EMPTY, FALSE );
  }
  if( !str_cmp( arg, "write" ) )
  {
    if( ch->substate == SUB_RESTRICTED )
    {
      send_to_char
	( "You cannot write a note from within another command.\r\n",
	  ch );
      return;
    }
    if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL
	|| paper->item_type != ITEM_PAPER )
    {
      paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) );
      if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL )
	unequip_char( ch, tmpobj );
      paper = obj_to_char( paper, ch );
      equip_char( ch, paper, WEAR_HOLD );
      act( AT_MAGIC, "$n grabs a message disk to record a note.",
	  ch, NULL, NULL, TO_ROOM );
      act( AT_MAGIC, "You get a message disk to record your note.",
	  ch, NULL, NULL, TO_CHAR );
    }
    if( paper->value[0] < 2 )
    {
      paper->value[0] = 1;
      ed = SetOExtra( paper, "_text_" );
      ch->substate = SUB_WRITING_NOTE;
      ch->dest_buf = ed;
      start_editing( ch, ed->description );
      return;
    }
    else
    {
      send_to_char( "You cannot modify this message.\r\n", ch );
      return;
    }
  }

  if( !str_cmp( arg, "subject" ) )
  {
    if( !arg_passed || arg_passed[0] == '\0' )
    {
      send_to_char( "What do you wish the subject to be?\r\n", ch );
      return;
    }
    if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL
	|| paper->item_type != ITEM_PAPER )
    {
      paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) );
      if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL )
	unequip_char( ch, tmpobj );
      paper = obj_to_char( paper, ch );
      equip_char( ch, paper, WEAR_HOLD );
      act( AT_MAGIC, "$n grabs a message disk.",
	  ch, NULL, NULL, TO_ROOM );
      act( AT_MAGIC, "You get a message disk to record your note.",
	  ch, NULL, NULL, TO_CHAR );
    }
    if( paper->value[1] > 1 )
    {
      send_to_char( "You cannot modify this message.\r\n", ch );
      return;
    }
    else
    {
      paper->value[1] = 1;
      ed = SetOExtra( paper, "_subject_" );
      STRFREE( ed->description );
      ed->description = STRALLOC( arg_passed );
      send_to_char( "Ok.\r\n", ch );
      return;
    }
  }

  if( !str_cmp( arg, "to" ) )
  {
    struct stat fst;
    char fname[1024];
    if( !arg_passed || arg_passed[0] == '\0' )
    {
      send_to_char( "Please specify an addressee.\r\n", ch );
      return;
    }
    if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL
	|| paper->item_type != ITEM_PAPER )
    {
      paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) );
      if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL )
	unequip_char( ch, tmpobj );
      paper = obj_to_char( paper, ch );
      equip_char( ch, paper, WEAR_HOLD );
      act( AT_MAGIC, "$n gets a message disk to record a note.",
	  ch, NULL, NULL, TO_ROOM );
      act( AT_MAGIC, "You grab a message disk to record your note.",
	  ch, NULL, NULL, TO_CHAR );
    }

    if( paper->value[2] > 1 )
    {
      send_to_char( "You cannot modify this message.\r\n", ch );
      return;
    }

    arg_passed[0] = UPPER( arg_passed[0] );

    sprintf( fname, "%s%c/%s", PLAYER_DIR, tolower( ( int ) arg_passed[0] ),
	capitalize( arg_passed ) );

    if( !IS_MAIL || stat( fname, &fst ) != -1
	|| !str_cmp( arg_passed, "all" ) )
    {
      paper->value[2] = 1;
      ed = SetOExtra( paper, "_to_" );
      STRFREE( ed->description );
      ed->description = STRALLOC( arg_passed );
      send_to_char( "Ok.\r\n", ch );
      return;
    }
    else
    {
      send_to_char( "No player exists by that name.\r\n", ch );
      return;
    }

  }

  if( !str_cmp( arg, "show" ) )
  {
    const char *subject = "";
    const char *to_list = "";
    const char *text = "";

    if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL
	|| paper->item_type != ITEM_PAPER )
    {
      send_to_char( "You are not holding a message disk.\r\n", ch );
      return;
    }

    if( ( subject =
	  get_extra_descr( "_subject_", paper->first_extradesc ) ) == NULL )
      subject = "(no subject)";
    if( ( to_list =
	  get_extra_descr( "_to_", paper->first_extradesc ) ) == NULL )
      to_list = "(nobody)";
    sprintf( buf, "%s: %s\r\nTo: %s\r\n", ch->name, subject, to_list );
    send_to_char( buf, ch );
    if( ( text =
	  get_extra_descr( "_text_", paper->first_extradesc ) ) == NULL )
      text = "The disk is blank.\r\n";
    send_to_char( text, ch );
    return;
  }

  if( !str_cmp( arg, "post" ) )
  {
    char *strtime = NULL;
    const char *text = NULL;

    if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL
	|| paper->item_type != ITEM_PAPER )
    {
      send_to_char( "You are not holding a message disk.\r\n", ch );
      return;
    }

    if( paper->value[0] == 0 )
    {
      send_to_char( "There is nothing written on this disk.\r\n", ch );
      return;
    }

    if( paper->value[1] == 0 )
    {
      send_to_char( "This message has no subject... using 'none'.\r\n",
	  ch );
      paper->value[1] = 1;
      ed = SetOExtra( paper, "_subject_" );
      STRFREE( ed->description );
      ed->description = STRALLOC( "none" );
    }

    if( paper->value[2] == 0 )
    {
      if( IS_MAIL )
      {
	send_to_char( "This message is addressed to no one!\r\n", ch );
	return;
      }
      else
      {
	send_to_char
	  ( "This message is addressed to no one... sending to 'all'!\r\n",
	    ch );
	paper->value[2] = 1;
	ed = SetOExtra( paper, "_to_" );
	STRFREE( ed->description );
	ed->description = STRALLOC( "All" );
      }
    }

    board = find_board( ch );
    if( !board )
    {
      send_to_char
	( "There is no terminal here to upload your message to.\r\n",
	  ch );
      return;
    }
    if( !can_post( ch, board ) )
    {
      send_to_char
	( "You cannot use this terminal. It is encrypted...\r\n", ch );
      return;
    }

    if( board->num_posts >= board->max_posts )
    {
      send_to_char
	( "This terminal is full. There is no room for your message.\r\n",
	  ch );
      return;
    }

    act( AT_ACTION, "$n uploads a message.", ch, NULL, NULL, TO_ROOM );

    strtime = ctime( &current_time );
    strtime[strlen( strtime ) - 1] = '\0';
    CREATE( pnote, NOTE_DATA, 1 );
    pnote->date = STRALLOC( strtime );

    text = get_extra_descr( "_text_", paper->first_extradesc );
    pnote->text = text ? STRALLOC( text ) : STRALLOC( "" );
    text = get_extra_descr( "_to_", paper->first_extradesc );
    pnote->to_list = text ? STRALLOC( text ) : STRALLOC( "all" );
    text = get_extra_descr( "_subject_", paper->first_extradesc );
    pnote->subject = text ? STRALLOC( text ) : STRALLOC( "" );
    pnote->sender = QUICKLINK( ch->name );
    pnote->voting = 0;
    pnote->yesvotes = str_dup( "" );
    pnote->novotes = str_dup( "" );
    pnote->abstentions = str_dup( "" );

    LINK( pnote, board->first_note, board->last_note, next, prev );
    board->num_posts++;
    write_board( board );
    send_to_char( "You upload your message to the terminal.\r\n", ch );
    extract_obj( paper );
    return;
  }

  if( !str_cmp( arg, "remove" )
      || !str_cmp( arg, "take" ) || !str_cmp( arg, "copy" ) )
  {
    char take = 0;

    board = find_board( ch );
    if( !board )
    {
      send_to_char
	( "There is no terminal here to download a note from!\r\n", ch );
      return;
    }
    if( !str_cmp( arg, "take" ) )
      take = 1;
    else if( !str_cmp( arg, "copy" ) )
    {
      if( !IS_IMMORTAL( ch ) )
      {
	send_to_char( "Huh?  Type 'help note' for usage.\r\n", ch );
	return;
      }
      take = 2;
    }
    else
      take = 0;

    if( !is_number( arg_passed ) )
    {
      send_to_char( "Note remove which number?\r\n", ch );
      return;
    }

    if( !can_read( ch, board ) )
    {
      send_to_char
	( "You can't make any sense of what's posted here, let alone remove anything!\r\n",
	  ch );
      return;
    }

    anum = atoi( arg_passed );
    vnum = 0;
    for( pnote = board->first_note; pnote; pnote = pnote->next )
    {
      if( IS_MAIL && ( ( is_note_to( ch, pnote ) )
	    || IS_IMMORTAL( ch ) ) )
	vnum++;
      else if( !IS_MAIL )
	vnum++;
      if( ( !str_cmp( ch->name, pnote->sender )
	    || can_remove( ch, board ) ) && ( vnum == anum ) )
      {
	if( ( is_name( "all", pnote->to_list ) )
	    && ( !IS_IMMORTAL( ch ) ) && ( take == 1 ) )
	{
	  send_to_char
	    ( "Notes addressed to 'all' can not be taken.\r\n", ch );
	  return;
	}

	if( take != 0 )
	{
	  paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) );
	  ed = SetOExtra( paper, "_sender_" );
	  STRFREE( ed->description );
	  ed->description = QUICKLINK( pnote->sender );
	  ed = SetOExtra( paper, "_text_" );
	  STRFREE( ed->description );
	  ed->description = QUICKLINK( pnote->text );
	  ed = SetOExtra( paper, "_to_" );
	  STRFREE( ed->description );
	  ed->description = QUICKLINK( pnote->to_list );
	  ed = SetOExtra( paper, "_subject_" );
	  STRFREE( ed->description );
	  ed->description = QUICKLINK( pnote->subject );
	  ed = SetOExtra( paper, "_date_" );
	  STRFREE( ed->description );
	  ed->description = QUICKLINK( pnote->date );
	  ed = SetOExtra( paper, "note" );
	  STRFREE( ed->description );
	  sprintf( notebuf, "From: " );
	  strcat( notebuf, pnote->sender );
	  strcat( notebuf, "\r\nTo: " );
	  strcat( notebuf, pnote->to_list );
	  strcat( notebuf, "\r\nSubject: " );
	  strcat( notebuf, pnote->subject );
	  strcat( notebuf, "\r\n\r\n" );
	  strcat( notebuf, pnote->text );
	  strcat( notebuf, "\r\n" );
	  ed->description = STRALLOC( notebuf );
	  paper->value[0] = 2;
	  paper->value[1] = 2;
	  paper->value[2] = 2;
	  sprintf( short_desc_buf, "a note from %s to %s",
	      pnote->sender, pnote->to_list );
	  STRFREE( paper->short_descr );
	  paper->short_descr = STRALLOC( short_desc_buf );
	  sprintf( long_desc_buf,
	      "A note from %s to %s lies on the ground.",
	      pnote->sender, pnote->to_list );
	  STRFREE( paper->description );
	  paper->description = STRALLOC( long_desc_buf );
	  sprintf( keyword_buf, "note parchment paper %s",
	      pnote->to_list );
	  STRFREE( paper->name );
	  paper->name = STRALLOC( keyword_buf );
	}
	if( take != 2 )
	  note_remove( board, pnote );
	send_to_char( "Ok.\r\n", ch );
	if( take == 1 )
	{
	  act( AT_ACTION, "$n downloads a message.", ch, NULL, NULL,
	      TO_ROOM );
	  obj_to_char( paper, ch );
	}
	else if( take == 2 )
	{
	  act( AT_ACTION, "$n copies a message.", ch, NULL, NULL,
	      TO_ROOM );
	  obj_to_char( paper, ch );
	}
	else
	  act( AT_ACTION, "$n removes a message.", ch, NULL, NULL,
	      TO_ROOM );
	return;
      }
    }

    send_to_char( "No such message.\r\n", ch );
    return;
  }

  send_to_char( "Huh? Type 'help note' for usage.\r\n", ch );
}
Example #12
0
/*
 *  This actually puts the new ban into the proper linked list and
 *  initializes its data.  Shaddai
 */
int add_ban( CHAR_DATA * ch, const char *arg1, const char *arg2, int btime, int type )
{
    char arg[MAX_STRING_LENGTH];
    char buf[MAX_STRING_LENGTH];
    BAN_DATA *pban, *temp;
    struct tm *tms;
    char *name;
    int level, i, value;

    /*
     * Should we check to see if they have dropped link sometime in between
     * * writing the note and now?  Not sure but for right now we won't since
     * * do_ban checks for that.  Shaddai
     */

    switch ( ch->substate )
    {
    default:
        bug( "%s", "add_ban: illegal substate" );
        return 0;

    case SUB_RESTRICTED:
        send_to_char( "You cannot use this command from within another command.\r\n", ch );
        return 0;

    case SUB_NONE:
    {
        one_argument( arg1, arg );
        smash_tilde( arg );  /* Make sure the immortals don't put a ~ in it. */

        if( arg[0] == '\0' || arg2[0] == '\0' )
            return 0;

        if( is_number( arg2 ) )
        {
            level = atoi( arg2 );
            if( level < 0 || level > LEVEL_SUPREME )
            {
                ch_printf( ch, "Level range is from 0 to %d.\r\n", LEVEL_SUPREME );
                return 0;
            }
        }
        else if( !str_cmp( arg2, "all" ) )
            level = LEVEL_SUPREME;
        else if( !str_cmp( arg2, "newbie" ) )
            level = 1;
        else if( !str_cmp( arg2, "mortal" ) )
            level = LEVEL_AVATAR;
        else if( !str_cmp( arg2, "warn" ) )
            level = BAN_WARN;
        else
        {
            bug( "%s", "Bad string for flag in add_ban." );
            return 0;
        }

        switch ( type )
        {
        case BAN_CLASS:
            if( arg[0] == '\0' )
                return 0;
            if( is_number( arg ) )
                value = atoi( arg );
            else
            {
                for( i = 0; i < MAX_CLASS; i++ )
                    if( !str_cmp( class_table[i]->who_name, arg ) )
                        break;
                value = i;
            }
            if( value < 0 || value >= MAX_CLASS )
            {
                send_to_char( "Unknown class.\r\n", ch );
                return 0;
            }
            for( temp = first_ban_class; temp; temp = temp->next )
            {
                if( temp->flag == value )
                {
                    if( temp->level == level )
                    {
                        send_to_char( "That entry already exists.\r\n", ch );
                        return 0;
                    }
                    else
                    {
                        temp->level = level;
                        if( temp->level == BAN_WARN )
                            temp->warn = TRUE;
                        snprintf( buf, MAX_STRING_LENGTH, "%24.24s", ctime( &current_time ) );
                        temp->ban_time = str_dup( buf );
                        if( btime > 0 )
                        {
                            temp->duration = btime;
                            tms = localtime( &current_time );
                            tms->tm_mday += btime;
                            temp->unban_date = mktime( tms );
                        }
                        else
                        {
                            temp->duration = -1;
                            temp->unban_date = -1;
                        }
                        if( temp->ban_by )
                            DISPOSE( temp->ban_by );
                        temp->ban_by = str_dup( ch->name );
                        send_to_char( "Updated entry.\r\n", ch );
                        return 1;
                    }
                }
            }
            CREATE( pban, BAN_DATA, 1 );
            pban->name = str_dup( class_table[value]->who_name );
            pban->flag = value;
            pban->level = level;
            pban->ban_by = str_dup( ch->name );
            LINK( pban, first_ban_class, last_ban_class, next, prev );
            break;

        case BAN_RACE:
            if( is_number( arg ) )
                value = atoi( arg );
            else
            {
                for( i = 0; i < MAX_RACE; i++ )
                    if( !str_cmp( race_table[i]->race_name, arg ) )
                        break;
                value = i;
            }
            if( value < 0 || value >= MAX_RACE )
            {
                send_to_char( "Unknown race.\r\n", ch );
                return 0;
            }
            for( temp = first_ban_race; temp; temp = temp->next )
            {
                if( temp->flag == value )
                {
                    if( temp->level == level )
                    {
                        send_to_char( "That entry already exists.\r\n", ch );
                        return 0;
                    }
                    else
                    {
                        temp->level = level;
                        if( temp->level == BAN_WARN )
                            temp->warn = TRUE;
                        snprintf( buf, MAX_STRING_LENGTH, "%24.24s", ctime( &current_time ) );
                        temp->ban_time = str_dup( buf );
                        if( btime > 0 )
                        {
                            temp->duration = btime;
                            tms = localtime( &current_time );
                            tms->tm_mday += btime;
                            temp->unban_date = mktime( tms );
                        }
                        else
                        {
                            temp->duration = -1;
                            temp->unban_date = -1;
                        }
                        if( temp->ban_by )
                            DISPOSE( temp->ban_by );
                        temp->ban_by = str_dup( ch->name );
                        send_to_char( "Updated entry.\r\n", ch );
                        return 1;
                    }
                }
            }
            CREATE( pban, BAN_DATA, 1 );
            pban->name = str_dup( race_table[value]->race_name );
            pban->flag = value;
            pban->level = level;
            pban->ban_by = str_dup( ch->name );
            LINK( pban, first_ban_race, last_ban_race, next, prev );
            break;

        case BAN_SITE:
        {
            bool prefix = FALSE, suffix = FALSE, user_name = FALSE;
            char *temp_host = NULL, *temp_user = NULL;
            size_t x;

            for( x = 0; x < strlen( arg ); x++ )
            {
                if( arg[x] == '@' )
                {
                    user_name = TRUE;
                    temp_host = str_dup( &arg[x + 1] );
                    arg[x] = '\0';
                    temp_user = str_dup( arg );
                    break;
                }
            }
            if( !user_name )
                name = arg;
            else
                name = temp_host;

            if( !name ) /* Double check to make sure name isnt null */
            {
                /*
                 * Free this stuff if its there
                 */
                if( user_name )
                {
                    DISPOSE( temp_host );
                    DISPOSE( temp_user );
                }
                send_to_char( "Name was null.\r\n", ch );
                return 0;
            }

            if( name[0] == '*' )
            {
                prefix = TRUE;
                name++;
            }

            if( name[strlen( name ) - 1] == '*' )
            {
                suffix = TRUE;
                name[strlen( name ) - 1] = '\0';
            }
            for( temp = first_ban; temp; temp = temp->next )
            {
                if( !str_cmp( temp->name, name ) )
                {
                    if( temp->level == level && ( prefix && temp->prefix ) && ( suffix && temp->suffix ) )
                    {
                        /*
                         * Free this stuff if its there
                         */
                        if( user_name )
                        {
                            DISPOSE( temp_host );
                            DISPOSE( temp_user );
                        }
                        send_to_char( "That entry already exists.\r\n", ch );
                        return 0;
                    }
                    else
                    {
                        temp->suffix = suffix;
                        temp->prefix = prefix;
                        if( temp->level == BAN_WARN )
                            temp->warn = TRUE;
                        temp->level = level;
                        snprintf( buf, MAX_STRING_LENGTH, "%24.24s", ctime( &current_time ) );
                        temp->ban_time = str_dup( buf );
                        if( btime > 0 )
                        {
                            temp->duration = btime;
                            tms = localtime( &current_time );
                            tms->tm_mday += btime;
                            temp->unban_date = mktime( tms );
                        }
                        else
                        {
                            temp->duration = -1;
                            temp->unban_date = -1;
                        }
                        if( temp->ban_by )
                            DISPOSE( temp->ban_by );
                        if( user_name )
                        {
                            DISPOSE( temp_host );
                            DISPOSE( temp_user );
                        }
                        temp->ban_by = str_dup( ch->name );
                        send_to_char( "Updated entry.\r\n", ch );
                        return 1;
                    }
                }
            }
            CREATE( pban, BAN_DATA, 1 );
            pban->ban_by = str_dup( ch->name );
            pban->suffix = suffix;
            pban->prefix = prefix;
            pban->name = str_dup( name );
            pban->level = level;
            LINK( pban, first_ban, last_ban, next, prev );
            if( user_name )
            {
                DISPOSE( temp_host );
                DISPOSE( temp_user );
            }
            break;
        }
        default:
            bug( "Bad type in add_ban: %d.", type );
            return 0;
        }
        snprintf( buf, MAX_STRING_LENGTH, "%24.24s", ctime( &current_time ) );
        pban->ban_time = str_dup( buf );
        if( btime > 0 )
        {
            pban->duration = btime;
            tms = localtime( &current_time );
            tms->tm_mday += btime;
            pban->unban_date = mktime( tms );
        }
        else
        {
            pban->duration = -1;
            pban->unban_date = -1;
        }
        if( pban->level == BAN_WARN )
            pban->warn = TRUE;
        ch->substate = SUB_BAN_DESC;
        ch->dest_buf = pban;
        if( !pban->note )
            pban->note = STRALLOC( "" );;
        start_editing( ch, pban->note );
        return 1;
    }
    case SUB_BAN_DESC:
        pban = ( BAN_DATA * ) ch->dest_buf;
        if( !pban )
        {
            bug( "%s", "do_ban: sub_ban_desc: NULL ch->dest_buf" );
            ch->substate = SUB_NONE;
            return 0;
        }
        if( pban->note )
            STRFREE( pban->note );
        pban->note = copy_buffer( ch );
        stop_editing( ch );
        ch->substate = ch->tempnum;
        save_banlist(  );
        if( pban->duration > 0 )
        {
            ch_printf( ch, "%s banned for %d days.\r\n", pban->name, pban->duration );
        }
        else
        {
            ch_printf( ch, "%s banned forever.\r\n", pban->name );
        }
        return 1;
    }
}