Esempio n. 1
0
void Place::save(std::ostream & os) const
{
    os << type() << " ";
    save_properties(os); // implemented by subclasses
    os << " \"" << name_ << "\" \"" << description_ << "\"" << std::endl;
    
    save_actors(os);
    save_objects(os);
    os << std::endl;
}
Esempio n. 2
0
/*****************************************************************************
 Name:		save_area
 Purpose:	Save an area, note that this format is new.
 Called by:	do_asave(olc_save.c).
 ****************************************************************************/
void save_area( AREA_DATA *pArea )
{
    FILE *fp;

    fclose( fpReserve );
    if ( !( fp = fopen( pArea->filename, "w" ) ) )
    {
        bug( "Open_area: fopen", 0 );
        perror( pArea->filename );
    }

    fprintf( fp, "#AREADATA\n" );
    fprintf( fp, "Name        %s~\n",        pArea->name );
    fprintf( fp, "Builders    %s~\n",        fix_string( pArea->builders ) );
    fprintf( fp, "VNUMs       %d %d\n",      pArea->lvnum, pArea->uvnum );
    fprintf( fp, "Security    %d\n",         pArea->security );
    fprintf( fp, "Recall      %d\n",         pArea->recall );
    fprintf( fp, "Flags	      %d\n",         pArea->area_flags );
    fprintf( fp, "End\n\n\n\n" );

    save_helps( fp, pArea );                                /* OLC 1.1b */
    save_mobiles( fp, pArea );
    save_objects( fp, pArea );
    save_rooms( fp, pArea );

    if ( IS_SET(pArea->area_flags, AREA_VERBOSE) )          /* OLC 1.1b */
    {
        vsave_specials( fp, pArea );
        vsave_resets( fp, pArea );
        vsave_shops( fp, pArea );
    }
    else
    {
        save_specials( fp, pArea );
        save_resets( fp, pArea );
        save_shops( fp, pArea );
    }

    fprintf( fp, "#$\n" );

    fclose( fp );
    fpReserve = fopen( NULL_FILE, "r" );
    return;
}
Esempio n. 3
0
void write_all( bool forced )
{
  area_data*  area;

  for( area = area_list; area != NULL; area = area->next )
    save_area( area, forced );

  save_mobs( );
  save_objects( );
  save_help( );
  save_trainers( );
  save_banned( );
  save_quests( );
  save_shops( );
  save_tables( );
  save_rtables( );
  save_lists( );
  save_clans( );
}
Esempio n. 4
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" );
      }
    }
}
Esempio n. 5
0
void oedit_save_to_disk(int zone_num)
{
  save_objects(zone_table[zone_num].number);
}
Esempio n. 6
0
void oedit_save_to_disk(int zone_num)
{
  save_objects(zone_num);
}
Esempio n. 7
0
int delete_object(obj_rnum rnum)
{
  obj_rnum i;
  zone_rnum zrnum;
  struct obj_data *obj, *tmp, *next_tmp;
  int shop, j, zone, cmd_no;

  if (rnum == NOTHING || rnum > top_of_objt)
    return NOTHING;
  
  obj = &obj_proto[rnum];

  zrnum = real_zone_by_thing(GET_OBJ_VNUM(obj));

  /* This is something you might want to read about in the logs. */
  log("GenOLC: delete_object: Deleting object #%d (%s).", GET_OBJ_VNUM(obj), obj->short_description);

  for (tmp = object_list; tmp; tmp = next_tmp) {
    next_tmp = tmp->next;
    if (tmp->item_number != obj->item_number)
      continue;

    /* extract_obj() will just axe contents. */
    if (tmp->contains) {
      struct obj_data *this_content, *next_content;
      for (this_content = tmp->contains; this_content; this_content = next_content) {
        next_content = this_content->next_content;
        if (IN_ROOM(tmp)) {
          /* Transfer stuff from object to room. */
          obj_from_obj(this_content);
          obj_to_room(this_content, IN_ROOM(tmp));
        } else if (tmp->worn_by || tmp->carried_by) {
          /* Transfer stuff from object to person inventory. */
          obj_from_char(this_content);
          obj_to_char(this_content, tmp->carried_by);
        } else if (tmp->in_obj) {
          /* Transfer stuff from object to containing object. */
          obj_from_obj(this_content);
          obj_to_obj(this_content, tmp->in_obj);
        }
      }
    }
    /* Remove from object_list, etc. - handles weightchanges, and similar. */
    extract_obj(tmp);
  }

  /* Make sure all are removed. */
  assert(obj_index[rnum].number == 0);

  /* Adjust rnums of all other objects. */
  for (tmp = object_list; tmp; tmp = tmp->next) {
    GET_OBJ_RNUM(tmp) -= (GET_OBJ_RNUM(tmp) > rnum);
  }

  for (i = rnum; i < top_of_objt; i++) {
    obj_index[i] = obj_index[i + 1];
    obj_proto[i] = obj_proto[i + 1];
    obj_proto[i].item_number = i;
  }

  top_of_objt--;
  RECREATE(obj_index, struct index_data, top_of_objt + 1);
  RECREATE(obj_proto, struct obj_data, top_of_objt + 1);

  /* Renumber notice boards. */
  for (j = 0; j < NUM_OF_BOARDS; j++)
    BOARD_RNUM(j) -= (BOARD_RNUM(j) > rnum);

  /* Renumber shop produce. */
  for (shop = 0; shop <= top_shop; shop++)
    for (j = 0; SHOP_PRODUCT(shop, j) != NOTHING; j++)
      SHOP_PRODUCT(shop, j) -= (SHOP_PRODUCT(shop, j) > rnum);

  /* Renumber zone table. */
  for (zone = 0; zone <= top_of_zone_table; zone++) {
    for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++) {
      switch (ZCMD(zone, cmd_no).command) {
      case 'P':
        if (ZCMD(zone, cmd_no).arg3 == rnum) {
          delete_command(&zone_table[zone], cmd_no);
        } else
          ZCMD(zone, cmd_no).arg3 -= (ZCMD(zone, cmd_no).arg3 > rnum);
	break;
      case 'O':
      case 'G':
      case 'E':
        if (ZCMD(zone, cmd_no).arg1 == rnum) {
          delete_command(&zone_table[zone], cmd_no);
        } else
          ZCMD(zone, cmd_no).arg1 -= (ZCMD(zone, cmd_no).arg1 > rnum);
	break;
      case 'R':
        if (ZCMD(zone, cmd_no).arg2 == rnum) {
          delete_command(&zone_table[zone], cmd_no);
        } else
          ZCMD(zone, cmd_no).arg2 -= (ZCMD(zone, cmd_no).arg2 > rnum);
	break;
      }
    }
  }

  save_objects(zrnum);

  return rnum;
}