void create_maptile( const std::string& realmname )
{
  Plib::RealmDescriptor descriptor = Plib::RealmDescriptor::Load( realmname );
  uo_map_height = static_cast<unsigned short>( descriptor.height );
  uo_map_width = static_cast<unsigned short>( descriptor.width );

  INFO_PRINT << "Creating maptile file.\n"
             << "  Realm: " << realmname << "\n"
             << "  Map ID: " << descriptor.uomapid << "\n"
             << "  Use Dif files: " << ( descriptor.uodif ? "Yes" : "No" ) << "\n"
             << "  Size: " << uo_map_width << "x" << uo_map_height << "\n";

  auto writer = new Plib::MapWriter();
  writer->OpenExistingFiles( realmname );

  for ( unsigned short y_base = 0; y_base < uo_map_height; y_base += Plib::MAPTILE_CHUNK )
  {
    for ( unsigned short x_base = 0; x_base < uo_map_width; x_base += Plib::MAPTILE_CHUNK )
    {
      for ( unsigned short x_add = 0; x_add < Plib::MAPTILE_CHUNK; ++x_add )
      {
        for ( unsigned short y_add = 0; y_add < Plib::MAPTILE_CHUNK; ++y_add )
        {
          unsigned short x = x_base + x_add;
          unsigned short y = y_base + y_add;

          short z;
          Core::USTRUCT_MAPINFO mi;

          safe_getmapinfo( x, y, &z, &mi );

          if ( mi.landtile > 0x3FFF )
            INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) << mi.landtile << x
                                                                                 << y << z;

          // for water, don't average with surrounding tiles.
          if ( landtile_uoflags( mi.landtile ) & Core::USTRUCT_TILE::FLAG_LIQUID )
            z = mi.z;

          Plib::MAPTILE_CELL cell;
          cell.landtile = mi.landtile;
          cell.z = static_cast<signed char>( z );
          writer->SetMapTile( x, y, cell );
        }
      }
    }
    INFO_PRINT << "\rConverting: " << y_base * 100 / uo_map_height << "%";
  }
  writer->Flush();
  delete writer;
  INFO_PRINT << "\rConversion complete.\n";
}
    void update_map(const std::string& realm, unsigned short x, unsigned short y)
	{
	  auto mapwriter = new MapWriter();
	  mapwriter->OpenExistingFiles( realm );
	  rawmapfullread();
	  rawstaticfullread();
	  unsigned short x_base = x / SOLIDX_X_SIZE * SOLIDX_X_SIZE;
	  unsigned short y_base = y / SOLIDX_Y_SIZE * SOLIDX_Y_SIZE;

	  ProcessSolidBlock( x_base, y_base, *mapwriter );
	  delete mapwriter;
      INFO_PRINT << "empty=" << empty << ", nonempty=" << nonempty << "\n"
        << "with more_solids: " << with_more_solids << "\n"
        << "total statics=" << total_statics << "\n";
	}