예제 #1
0
void delete_exit( wizard_data* imm, exit_data* exit, bool one_way )
{
  exit_data* back;

  if( !can_edit( imm, imm->in_room ) ) 
    return;

  if( ( back = reverse( exit ) ) != NULL && !one_way ) {
    if( !can_edit( imm, exit->to_room, FALSE ) ) {
      send( imm,
        "You don't have permission to delete the return exit.\n\r" );
      return;
      }
    imm->exit_edit = back;
    extract( imm, offset( &imm->exit_edit, imm ), "exit" );
    exit->to_room->exits -= back;
    delete back;
    }

  imm->exit_edit = exit;
  extract( imm, offset( &imm->exit_edit, imm ), "exit" );
  imm->in_room->exits -= exit;
  delete exit;

  send( imm, "You remove %sthe exit %s.\n\r",
    back != NULL && one_way ? "just this side of " : "",
    dir_table[ exit->direction ].where );

  return;
}
예제 #2
0
void create_exit( wizard_data* ch, int dir, char* argument, bool one_way )
{
  room_data*  room  = ch->in_room;
  exit_data*  exit;

  if( exit_direction( room, dir ) != NULL ) {
    send( ch, "An exit already exists %s.\n\r",
      dir_table[ dir ].where );
    return;
    }

  if( *argument == '\0' ) {
    if( ( room = create_room( ch ) ) == NULL )
      return;
    }
  else {
    if( ( room = get_room_index( atoi( argument ), FALSE ) ) == NULL ) {
      send( ch, "No room with that vnum exists.\n\r" );
      return;
      }
    if( !one_way
      && exit_direction( room, dir_table[dir].reverse ) != NULL ) {
      send( ch, "Door returning already exists.\n\r" );  
      return;
      }
    if( !can_edit( ch, room, FALSE ) ) {
      send( ch, "You don't have permission to tunnel into that area.\n\r" );
      return;
      }
    }

  exit                        = add_exit( ch->in_room, dir );
  exit->to_room               = room;
  ch->exit_edit               = exit;
  ch->in_room->area->modified = TRUE;

  if( !one_way ) {
    exit                 = add_exit( room, dir_table[dir].reverse );
    exit->to_room        = ch->in_room;
    room->area->modified = TRUE;
    }

  send( ch, "%s-way exit %s to room %d added.\n\r",
    one_way ? "One" : "Two", dir_table[dir].name, room->vnum );
}
예제 #3
0
void do_dflag( char_data* ch, char* argument )
{
  wizard_data*   imm  = (wizard_data*) ch; 
  exit_data*    exit;
  exit_data*    back;
  int          flags;

  if( !get_flags( ch, argument, &flags, "1", "dflag" ) )
    return;

  if( ( exit = imm->exit_edit ) == NULL ) {
    send( ch, "Use dedit to specify direction.\n\r" );
    return;
    }

  if( *argument == '\0' ) {
    display_flags( "Door Flags", &dflag_name[0], &dflag_name[1],
      &exit->exit_info, MAX_DFLAG, ch );
    return;
    }

  if( !can_edit( ch, ch->in_room ) ) 
    return;

  ch->in_room->area->modified = TRUE;

  for( int i = 0; i < MAX_DFLAG; i++ ) 
    if( fmatches( argument, dflag_name[i] ) ) {
      switch_bit( &exit->exit_info, i );
      if( ( back = reverse( exit ) ) != NULL
        && !is_set( &flags, 0 ) )
        assign_bit( &back->exit_info, i, is_set( &exit->exit_info,i ) );
      send( ch, "%s set %s on %sthe %s exit.\n\r",
        dflag_name[i], true_false( &exit->exit_info, i ),
        back != NULL && !is_set( &flags, 0 ) ? "both sides of " : "",
        dir_table[ exit->direction ].name );
      return;
      }

  send( ch, "Unknown flag - see dflag with no arguments for list.\n\r" );
}
예제 #4
0
/* ................................................................
 * Handle user interaction with a form in open window `w'.
 *
 * Initial conditions are as follows:
 * w->x is the address of the form.
 * window is open, with appropriate WINFO rects & coordinates set
 * form is drawn within window, at correct virtual coordinates
 * ROOT object of form has correct x,y coordinates
 *
 * This routine works just like form_do, but dispatches window
 * events, redrawing and fixing up the object tree as appropriate,
 * and maintaining the various rects and coordinates in the WINFO struct.
 *
 * Returns exit object selected, |= 0x8000 if double clicked a TOUCHEXIT,
 * OR -1 if a message was received which couldn't be handled.
 * In the latter case, the `puntmsg' array is filled with the message buffer
 * which xform_do() couldn't handle, and the application is responsible for
 * picking up where xform_do() left off.  A cop-out, I know.
 *
 * NOTE: form_dial( FMD_START,... ) and form_dial( FMD_FINISH,... )
 *		should NOT be used with xform_do().
 *
 * User defined objects could cause problems with this routine, as
 * the boundary of the object may lie outside the window coordinates.
 * Caveat programmer.
 */
WORD
cdecl
xform_do( OBJECT *tree, WORD start_field, WORD puntmsg[] )
{
	WORD	next_obj, edit_obj, idx;
	BOOLEAN	cont, doedit;
	WORD	event;
	MRETS	m;
	WORD	key, clicks;
	DIRS	direction; /* form_keybd */
	GRECT	rect;
		
	cpx_tree = tree;
	SetAccCloseState( FALSE );
	SetWmCloseState( FALSE );
	/*
	 * Get the next editable object
	 */
	if( start_field == 0 )
		next_obj = find_obj( tree, 0, FORWARD );
	else
		next_obj = start_field;

	edit_obj = 0;
	cont = TRUE;
	
	cursor = FALSE;
	
	while( cont ) {

		/*
		 * Put the cursor in the edit field
		 * Note: This is skipped if there is only one field.
		 */
		if( (next_obj != 0) && (edit_obj != next_obj) ) {
			edit_obj = next_obj;
			next_obj = 0;
			doedit = can_edit( tree, edit_obj );
			if( doedit && !cursor )
			{
				objc_edit( tree, edit_obj, 0, (int *)&idx, ED_INIT );
				cursor = TRUE;
			}	
		}
		wind_update( FALSE );
		/*
		 * Wait...
		 */
		event = Evnt_multi( MU_KEYBD|MU_BUTTON|MU_MESAG, 2, 1, 1,
							NULL, NULL, msg, 0L, &m, &key, &clicks );
		wind_update( TRUE );

		if( EvMessage() ) {
			switch( MsgType(msg) ) {
				case AC_OPEN:   acc_open( (int *)msg );
						break;
						
				case WM_TOPPED:
				case WM_NEWTOP:
					        Wm_Topped( ( int *)msg );
						doedit = can_edit( tree, edit_obj );
					        if( doedit && !cursor )
					        {
					           objc_edit( tree, edit_obj, 0, (int *)&idx, ED_INIT );
						   cursor = TRUE;
					        }
						break;
						
				case WM_SIZED:
					doedit = can_edit( tree, edit_obj );
					
				/* fall through */
				case WM_MOVED:	/* if moving, that means we are on top, therefore, cursor is already on */
						doedit = can_edit( tree, edit_obj );
						if( !doedit )
							cursor = FALSE;
				case WM_REDRAW:
				case WM_FULLED:
				case WM_ARROWED:
				case WM_HSLID:
				case WM_VSLID:
				/* redraw 'n' shit */
						
					if( edit_obj && ( msg[0] == WM_REDRAW ))
					{
					    NoEdit( edit_obj );
					    rect = ObRect( edit_obj );
					    objc_offset( tree, edit_obj, &rect.g_x, &rect.g_y );

					    /* The offsets will take care of the blinking cursor
					     * area that needs to be redraw to erase it.
					     */
					    rect.g_y -= 3;
					    rect.g_w += 3;
					    rect.g_h += 6;

					    /* Clip the rectangle to the work area of the form.*/
					    rc_intersect( &w.work, &rect ); 

					    /* The redraw is necessary to turn off the blinking cursor.
					     * We are going to need to send a redraw message to the calling
					     * cpx in case they have any custom redraws that need to be done.
					     */
					    Redraw_XForm_Do( &rect );
					    
					    if( msg[0] == WM_REDRAW )
					    {	
					       for( idx = 0; idx < 8; idx++ )
						   puntmsg[idx] = msg[idx];
					    }

					}
					/* Here we redraw/move the area that is dirtied */    
					do_windows( (int *)msg, (int *)&event );
					if( edit_obj )
					    MakeEditable( edit_obj );
					doedit = can_edit( tree, edit_obj );
					if( !doedit )
						cursor = FALSE;
					if( msg[0] == WM_REDRAW )
					{	
					   for( idx = 0; idx < 8; idx++ )
						   puntmsg[idx] = msg[idx];
					   return -1;
					}
				break;

				default:if( msg[0] == AC_CLOSE )
						SetAccCloseState( TRUE );
					if( msg[0] == AP_TERM )
					{
					    SetAccCloseState( TRUE );
					    msg[0] = AC_CLOSE;
					}
					if( msg[0] == WM_CLOSED )
					        SetWmCloseState( TRUE );
					for( idx = 0; idx < 8; idx++ )
						puntmsg[idx] = msg[idx];
					return -1;
			}
		}


/*
 * What about hot keys?? AIEEE!!
 */
		if( EvKey() ) {

			/*
			 * form_keybd() encapsulated here
			 */
			direction = NODIR;
			switch( key ) {

				case K_RETURN:
				case K_ENTER:
					next_obj = 0;
					direction = DEFAULTDIR;
					break;

				case K_BACKTAB:
				case K_UP:
					direction = BACKWARD;
					break;

				case K_TAB:
				case K_DOWN:
					direction = FORWARD;
					break;
			}

			if( direction != NODIR ) {
				key = 0;
				next_obj = find_obj( tree, edit_obj, direction );
				if( (direction == DEFAULTDIR) && (next_obj != 0) ) {
					Objc_change( tree, next_obj, &w.work,
 				        ObState(next_obj)|SELECTED, TRUE );
					cont = FALSE;
				}
			}
			/*
			 * End of form_keybd()
			 */

			/* The above code clears 'key', therefore, we'll
			 * check key FIRST, then test the ASCII and 
			 * scancode
			 */
			if( key && ( !( key & 0xff ) )  )
			{
			  if( ( key != K_UP     )  &&
			      ( key != K_DOWN   )  &&
			      ( key != K_RIGHT  )  &&
			      ( key != K_LEFT   )  &&
			      ( key != K_RETURN )  &&
			      ( key != K_ENTER  )  &&
			      ( key != K_TAB )	   &&
			      ( key != K_BACKTAB)
			    )
			    {
			      puntmsg[0] = CT_KEY;
			      puntmsg[3] = key;
			      return -1;
			    }  
			}

			if( key && doedit )
				objc_edit( tree, edit_obj, key, (int *)&idx, ED_CHAR );
		}

		if( EvButton() ) {
			next_obj = objc_find( tree, ROOT, MAX_DEPTH, m.x, m.y );
			if( next_obj == NIL ) {
				Bconout( 2, 7 );
				next_obj = 0;
			} else {
				cont = fm_button( tree, next_obj, clicks, &next_obj );
			}
		}

		if(  doedit && (!cont || (next_obj != 0)) && ( next_obj != edit_obj) )
		{
		   objc_edit( tree, edit_obj, 0, (int *)&idx, ED_END );
		   cursor = FALSE;
		}   		
	}

	return next_obj;
}
예제 #5
0
void do_write( char_data* ch, char* argument )
{
  char           buf  [ MAX_INPUT_LENGTH ];
  area_data*    area;
  int         number  = 0;
  int          flags;

  if( !get_flags( ch, argument, &flags, "f", "write" ) )
    return;

  if( !strcasecmp( argument, "all" ) ) {
    if( !has_permission( ch, PERM_WRITE_ALL, TRUE ) ) 
      return;
    write_all( is_set( &flags, 0 ) );
    send( ch, "All files written.\r\n" );
    sprintf( buf, "All files written (%s).", ch->descr->name );
    info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( fmatches( argument, "areas" ) ) {
    if( !has_permission( ch, PERM_WRITE_AREAS, TRUE ) )
      return;
    for( area = area_list; area != NULL; area = area->next ) 
      number += save_area( area, is_set( &flags, 0 ) );
    if( number > 0 ) {
      send( ch, "All areas written. ( %d file )\r\n", number );
      sprintf( buf, "All areas written (%s).", ch->real_name() );
      info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
      }
    else {
      send( ch, "No area needed saving.\r\n" );
      }
    return;
    }

  if( fmatches( argument, "rtables" ) ) {
    if( !has_permission( ch, PERM_RTABLES, TRUE ) ) 
      return;
    save_rtables( );
    send( ch, "Rtables written.\r\n" );
    sprintf( buf, "Rtables written (%s).", ch->real_name() );
    info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( fmatches( argument, "mobs" ) ) {
    if( !has_permission( ch, PERM_MOBS, TRUE ) )
      return;
    save_mobs( );
    send( ch, "Ok.\r\n" );
    sprintf( buf, "Mob file written (%s).", ch->real_name() );
    info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( fmatches( argument, "objects" ) ) {
    if( !has_permission( ch, PERM_OBJECTS, TRUE ) )
      return;
    save_objects( );
    send( ch, "Ok.\r\n" );
    sprintf( buf, "Object file written (%s).", ch->real_name() );
    info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "notes" ) ) {
    save_notes( -1 );
    send( ch, "All noteboards written.\r\n" );
    return;
    }

  if( !strcasecmp( argument, "shops" ) ) {
    if( !has_permission( ch, PERM_ROOMS, TRUE ) )
      return;
    save_shops( );
    send( "Ok.\r\n", ch );
    sprintf( buf, "Shop file written (%s).", ch->real_name() );
    info( "", LEVEL_IMMORTAL, buf , IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "tables" ) ) {
    if( !has_permission( ch, PERM_MISC_TABLES )
      && !has_permission( ch, PERM_SOCIALS, TRUE ) ) 
      return;
    save_tables( );
    send( "Ok.\r\n", ch );
    sprintf( buf, "Table file written (%s).", ch->real_name() );
    info( "", LEVEL_IMMORTAL, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "clans" ) ) {
    if( !has_permission( ch, PERM_CLANS, TRUE ) )
      return;
    save_clans( );
    send( ch, "Ok.\r\n" );
    sprintf( buf, "Clan files written (%s).", ch->real_name() );
    info( "", LEVEL_IMMORTAL, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "lists" ) ) {
    if( !has_permission( ch, PERM_LISTS, TRUE ) ) 
      return;
    save_lists( );
    send( "Ok.\r\n", ch );
    sprintf( buf, "Table file written (%s).", ch->real_name() );
    info( "", LEVEL_IMMORTAL, buf , IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "trainers" ) ) {
    if( !IS_IMMORTAL( ch ) ) {
      send( "You don't have permission.", ch );
      return;
      }
    save_trainers( );
    send( "Ok.\r\n", ch );
    sprintf( buf, "Trainer file written (%s).", ch->real_name() );
    info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "help" ) ) {
    if( !has_permission( ch, PERM_HELP_FILES, TRUE ) )
      return;
    if( !save_help( ch ) ) 
      send( ch, "Help was not modified so was not saved.\r\n" );
    return;
    }

  if( !strcasecmp( argument, "quests" ) ) {
    if( get_trust( ch ) < LEVEL_QUEST ) {
      send( ch, "You don't have permission." );
      return;
      }
    save_quests( );
    send( ch, "Ok.\r\n" );
    sprintf( buf, "Quest file written (%s).", ch->real_name() );
    info( "", LEVEL_BUILDER, buf, IFLAG_WRITES, 1, ch );
    return;
    }

  if( !strcasecmp( argument, "w3" ) ) {
    w3_help( );
    send( ch, "Webpage Updated.\r\n" );
    return;
    }

  if( *argument != '\0' ) {
    send( ch, "What do you want to write?\r\n" );
    return;
    }

  if( can_edit( ch, ch->in_room ) ) {
    if( !ch->in_room->area->modified ) {
      send( "Area has not been modified so was not saved.\r\n", ch );
      }
    else {
      save_area( ch->in_room->area );
      send( ch, "Area written.\r\n" );
      }
    }
}
예제 #6
0
void do_shedit( char_data* ch, char* argument )
{
  char                  buf  [MAX_STRING_LENGTH ];
  mob_data*          keeper;
  shop_data*           shop;
  char_data*         victim;
  species_data*     species;
  int                number;
  
  for( shop = shop_list; shop != NULL; shop = shop->next )
    if( ch->in_room == shop->room ) 
      break;  

  if( *argument != '\0' && !can_edit( ch, ch->in_room ) )
    return;

  if( exact_match( argument, "new" ) ) {
    if( shop != NULL ) {
      send( ch, "There is already a shop here.\r\n" );
      return;
      }
    shop = new shop_data;
    shop->room = ch->in_room;
    shop->custom = NULL;
    shop->keeper = -1;
    shop->repair = 0;
    shop->materials = 0;
    shop->buy_type[0] = 0;
    shop->buy_type[1] = 0;
    shop->next = shop_list;
    shop_list = shop;
    send( ch, "New shop created here.\r\n" );
    return;
    }

  if( shop == NULL ) {
    send( ch, "There is no shop associated with this room.\r\n" );
    return;
    }

  if( *argument == '\0' ) {
    species = get_species( shop->keeper ); 
    sprintf( buf, "Shop Keeper: %s  [ Vnum: %d ]\r\n\r\n", ( species == NULL
      ? "none" : species->descr->name ), shop->keeper );
    sprintf( buf+strlen( buf ), "Repair: %d\r\n\r\n", shop->repair );
    send( buf, ch );
    return;
    }
  
  if( exact_match( argument, "delete" ) ) {
    remove( shop_list, shop );
    for( int i = 0; i < mob_list; i++ )
      if( mob_list[i]->pShop == shop )
        mob_list[i]->pShop = NULL;
    send( ch, "Shop deleted.\r\n" );
    return;
    }
   
  if( matches( argument, "keeper" ) ) {
    if( ( victim = one_character( ch, argument, "set keepr",
      ch->array ) ) == NULL )
      return;

    if( ( keeper = mob( victim ) ) == NULL ) {
      send( ch, "Players can not be shop keepers.\r\n" );
      return;
      }
    shop->keeper = keeper->species->vnum;
    keeper->pShop = shop;
    send( ch, "Shop keeper set to %s.\r\n", keeper->descr->name );
    return;
    }

  if( matches( argument, "repair" ) ) {
    if( ( number = atoi( argument ) ) < 0 || number > 10 ) {
      send( ch,
        "A shop's repair level must be between 0 and 10.\r\n" ); 
      return;
      }
    shop->repair = number;
    send( ch, "The shop's repair level is set to %d.\r\n", number );
    } 
}
예제 #7
0
void do_dset( char_data* ch, char* argument )
{ 
  wizard_data*   imm  = (wizard_data*) ch;
  exit_data*    exit;
  obj_data*      obj;
  int          flags;

  if( !get_flags( ch, argument, &flags, "1", "dset" ) )
    return;

  if( *argument == '\0' ) {
    do_dstat( ch, "" );
    return;
    }
  
  if( !can_edit( ch, ch->in_room ) )
    return;

  if( ( exit = imm->exit_edit ) == NULL ) {
    send( ch, "You must specify a direction with dedit.\n\r" );
    return;
    }

  ch->in_room->area->modified = TRUE;

  if( matches( argument, "key" ) ) {
    if( *argument == '\0' ) {
      exit->key = -1;
      send( ch, "Key for lock on %s exit set to none.\n\r",
        dir_table[ exit->direction ].name );
      return;
      }
    if( ( obj = one_object( ch, argument,
      "key", &ch->contents ) ) == NULL )
      return;
    if( obj->pIndexData->item_type != ITEM_KEY ) {
      send( ch, "%s isn't a key.\n\r", obj );
      return;
      }  
    exit->key = obj->pIndexData->vnum;
    send( ch, "Key for lock on %s exit set to %s.\n\r",
      dir_table[ exit->direction ].name, obj->pIndexData->Name( ) );
    return;
    }

  class type_field type_list[] = {
    { "size",  MAX_SIZE,  &size_name[0],  &size_name[1],  &exit->size },
    { "",      0,         NULL,           NULL,           NULL        }
    };

  if( process( type_list, ch, dir_table[ exit->direction ].name,
    argument ) )
    return;

  class string_field string_list[] = {
    { "name",      MEM_EXIT,  &exit->name,       NULL },
    { "keywords",  MEM_EXIT,  &exit->keywords,   NULL },
    { "",          0,         NULL,              NULL },   
    };

  if( process( string_list, ch, dir_table[ exit->direction ].name,
    argument ) )
    return;

  class int_field int_list[] = {
    { "strength",          0,   10,  &exit->strength  },
    { "light",             0,  100,  &exit->light     },
    { "",                  0,    0,  NULL             }
    };

  if( process( int_list, ch, dir_table[ exit->direction ].name,
    argument ) )
    return;

  send( ch, "Unknown field - See help dset.\n\r" );
}