Package l2p.gameserver.model

Examples of l2p.gameserver.model.L2Territory


          int location = spawn.getLocation();
          if(location == 0)
          {
            continue;
          }
          L2Territory terr = TerritoryTable.getInstance().getLocation(location);
          if(terr == null)
          {
            continue;
          }
          if(terr.isInside(activeChar.getX(), activeChar.getY()))
          {
            activeChar.sendMessage("Territory: " + terr.getId());
          }
        }
        break;
      }
      case admin_region:
      {
        activeChar.sendMessage("Current region: " + activeChar.getCurrentRegion().getName());
        activeChar.sendMessage("Objects list:");
        for(L2Object o : activeChar.getCurrentRegion().getObjectsList(new GArray<L2Object>(activeChar.getCurrentRegion().getObjectsSize()), 0, activeChar.getReflection()))
        {
          if(o != null)
          {
            activeChar.sendMessage(o.toString());
          }
        }
        break;
      }
      case admin_vis_count:
      {
        activeChar.sendMessage("Players count: " + L2World.getAroundPlayers(activeChar).size());
        break;
      }
      /*
             * Пишет в консоль текущую точку для локации, оформляем в виде SQL запроса
             * пример: (8699,'loc_8699',111104,-112528,-1400,-1200),
             * Удобно для рисования локаций под спавн, разброс z +100/-10
             * необязательные параметры: id локации и название локации
             * Бросает бутылку, чтобы не запутаццо :)
             */
      case admin_loc:
      {
        String loc_id = "0";
        String loc_name;
        if(wordList.length > 1)
        {
          loc_id = wordList[1];
        }
        if(wordList.length > 2)
        {
          loc_name = wordList[2];
        }
        else
        {
          loc_name = "loc_" + loc_id;
        }
        //System.out.println("  (" + loc_id + ",'" + loc_name + "'," + activeChar.getX() + "," + activeChar.getY() + "," + activeChar.getZ() + "," + (activeChar.getZ() + 100) + ",0),");
        System.out.println("<point xyzz=\"" + activeChar.getX() + " " + activeChar.getY() + " " + activeChar.getZ() + " " + (activeChar.getZ() + 100) + "\"/>");
        activeChar.sendMessage("Point saved.");
        L2ItemInstance temp = ItemTable.getInstance().createItem(1060);
        temp.dropMe(activeChar, activeChar.getLoc());
        break;
      }
      case admin_xloc:
      {
        System.out.println("      <coords loc=\"" + activeChar.getX() + " " + activeChar.getY() + " " + activeChar.getZ() + " 0\" />");
        activeChar.sendMessage("Point saved.");
        L2ItemInstance temp = ItemTable.getInstance().createItem(1060);
        temp.dropMe(activeChar, activeChar.getLoc());
        break;
      }
      case admin_pos:
        String pos = activeChar.getX() + ", " + activeChar.getY() + ", " + activeChar.getZ() + ", " + activeChar.getHeading() + " Geo [" + (activeChar.getX() - L2World.MAP_MIN_X >> 4) + ", " + (activeChar.getY() - L2World.MAP_MIN_Y >> 4) + "] Ref " + activeChar.getReflection().getId();
        System.out.println(activeChar.getName() + "'s position: " + pos);
        activeChar.sendMessage("Pos: " + pos);
        break;
      case admin_location:
        locationMenu(activeChar);
        break;
      case admin_loc_begin:
      {
        if(wordList.length < 2)
        {
          activeChar.sendMessage("Usage: //loc_begin <location_id>");
          locationMenu(activeChar);
          return false;
        }
        try
        {
          create_loc_id = Integer.valueOf(wordList[1]);
        }
        catch(Exception E)
        {
          activeChar.sendMessage("location_id should be integer");
          create_loc = null;
          locationMenu(activeChar);
          return false;
        }
        create_loc = new GArray<int[]>();
        create_loc.add(new int[] {activeChar.getX(), activeChar.getY(), activeChar.getZ(), activeChar.getZ() + 100});
        activeChar.sendMessage("Now you can add points...");
        activeChar.sendPacket(new ExShowTrace());
        locationMenu(activeChar);
        break;
      }
      case admin_loc_add:
      {
        if(create_loc == null)
        {
          activeChar.sendMessage("Location not started");
          locationMenu(activeChar);
          return false;
        }
        create_loc.add(new int[] {activeChar.getX(), activeChar.getY(), activeChar.getZ(), activeChar.getZ() + 100});
        if(create_loc.size() > 1)
        {
          activeChar.sendPacket(Points2Trace(create_loc, 50, false, false));
        }
        if(wordList.length > 1 && wordList[1].equals("menu"))
        {
          locationMenu(activeChar);
        }
        break;
      }
      case admin_loc_reset:
      {
        if(create_loc == null)
        {
          activeChar.sendMessage("Location not started");
          locationMenu(activeChar);
          return false;
        }
        create_loc.clear();
        activeChar.sendPacket(new ExShowTrace());
        locationMenu(activeChar);
        break;
      }
      case admin_loc_end:
      {
        if(create_loc == null)
        {
          activeChar.sendMessage("Location not started");
          locationMenu(activeChar);
          return false;
        }
        if(create_loc.size() < 3)
        {
          activeChar.sendMessage("Minimum location size 3 points");
          locationMenu(activeChar);
          return false;
        }
        String prefix = "(" + create_loc_id + ",'loc_" + create_loc_id + "',";
        for(int[] _p : create_loc)
        {
          System.out.println(prefix + _p[0] + "," + _p[1] + "," + _p[2] + "," + _p[3] + ", 0),");
        }
        System.out.println("");
        activeChar.sendPacket(Points2Trace(create_loc, 50, true, false));
        create_loc = null;
        create_loc_id = 0;
        activeChar.sendMessage("Location Created, check stdout");
        if(wordList.length > 1 && wordList[1].equals("menu"))
        {
          locationMenu(activeChar);
        }
        break;
      }
      case admin_showloc:
      {
        if(wordList.length < 2)
        {
          activeChar.sendMessage("Usage: //showloc <location>");
          return false;
        }
        String loc_id = wordList[1];
        L2Territory terr = TerritoryTable.getInstance().getLocations().get(Integer.parseInt(loc_id));
        if(terr == null)
        {
          activeChar.sendMessage("Location <" + loc_id + "> undefined.");
          return false;
        }
        if(!terr.isInside(activeChar.getX(), activeChar.getY()))
        {
          int[] _loc = terr.getRandomPoint();
          activeChar.teleToLocation(_loc[0], _loc[1], _loc[2]);
        }
        activeChar.sendPacket(Points2Trace(terr.getCoords(), 50, true, false));
        if(wordList.length > 2 && wordList[2].equals("menu"))
        {
          locationMenu(activeChar);
        }
        break;
      }
      case admin_loc_remove:
      {
        if(wordList.length < 2)
        {
          activeChar.sendMessage("Usage: //showloc <location>");
          return false;
        }
        if(create_loc == null)
        {
          activeChar.sendMessage("Location not started");
          locationMenu(activeChar);
          return false;
        }
        int point_id = Integer.parseInt(wordList[1]);
        create_loc.remove(point_id);
        if(create_loc.size() > 1)
        {
          activeChar.sendPacket(Points2Trace(create_loc, 50, false, false));
        }
        locationMenu(activeChar);
        break;
      }
      case admin_show_locations:
      {
        for(L2Territory terr : TerritoryTable.getInstance().getLocations().values())
        {
          if(activeChar.isInRange(terr.getCenter(), 2000))
          {
            activeChar.sendPacket(Points2Trace(terr.getCoords(), 50, true, false));
          }
        }
        for(L2Territory terr : TerritoryTable.getInstance().getLocations().values())
        {
          if(activeChar.isInRange(terr.getCenter(), 2000))
          {
            activeChar.sendPacket(Points2Trace(terr.getCoords(), 50, true, true));
          }
        }
        break;
      }
    }
View Full Code Here


        {
          activeChar.sendMessage("->" + targetName + "<- is incorrect.");
        }
        break;
      case admin_fix_gh_1:
        L2Territory gh_spawn_loc;
        // Зона крафта
        gh_spawn_loc = new L2Territory(10000001);
        gh_spawn_loc.add(45704, 186617, -3480, -3380);
        gh_spawn_loc.add(46086, 186419, -3488, -3388);
        gh_spawn_loc.add(46733, 187506, -3480, -3380);
        gh_spawn_loc.add(46294, 187709, -3480, -3380);
        for(L2Player player : L2ObjectsStorage.getAllPlayers())
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_MANUFACTURE && player.getReflection().getId() == -2)
          {
            int[] point = gh_spawn_loc.getRandomPoint();
            player.decayMe();
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        // Зона покупки
        gh_spawn_loc = new L2Territory(10000002);
        gh_spawn_loc.add(46091, 186412, -3488, -3388);
        gh_spawn_loc.add(47218, 185902, -3488, -3388);
        gh_spawn_loc.add(47761, 186929, -3480, -3380);
        gh_spawn_loc.add(46742, 187511, -3480, -3380);
        for(L2Player player : L2ObjectsStorage.getAllPlayers())
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_BUY && player.getReflection().getId() == -2)
          {
            int[] point = gh_spawn_loc.getRandomPoint();
            player.decayMe();
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        // Зона продажи
        gh_spawn_loc = new L2Territory(10000003);
        gh_spawn_loc.add(47665, 186755, -3480, -3380);
        gh_spawn_loc.add(48167, 186488, -3480, -3380);
        gh_spawn_loc.add(48397, 186625, -3480, -3380);
        gh_spawn_loc.add(50156, 184674, -3488, -3388);
        gh_spawn_loc.add(49292, 183916, -3488, -3388);
        gh_spawn_loc.add(47758, 185654, -3488, -3388);
        gh_spawn_loc.add(47244, 185894, -3488, -3388);
        for(L2Player player : L2ObjectsStorage.getAllPlayers())
        {
          if((player.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL || player.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL_PACKAGE) && player.getReflection().getId() == -2)
          {
            int[] point = gh_spawn_loc.getRandomPoint();
            player.decayMe();
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        break;
      case admin_fix_gh_2:
        L2Territory gh_spawn_loc2;
        // Зона покупки
        gh_spawn_loc2 = new L2Territory(10000004);
        gh_spawn_loc2.add(46091, 186412, -3488, -3388);
        gh_spawn_loc2.add(47218, 185902, -3488, -3388);
        gh_spawn_loc2.add(47761, 186929, -3480, -3380);
        gh_spawn_loc2.add(46742, 187511, -3480, -3380);
        for(L2Player player : L2ObjectsStorage.getAllPlayers())
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_BUY)
          {
            int[] point = gh_spawn_loc2.getRandomPoint();
            player.decayMe();
            if(player.getReflection().getId() != -2)
            {
              player.setVar("backCoords", player.getLoc().toXYZString());
              player.setReflection(-2);
            }
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        // Зона крафта
        gh_spawn_loc2 = new L2Territory(10000005);
        gh_spawn_loc2.add(45704, 186617, -3480, -3380);
        gh_spawn_loc2.add(46086, 186419, -3488, -3388);
        gh_spawn_loc2.add(46733, 187506, -3480, -3380);
        gh_spawn_loc2.add(46294, 187709, -3480, -3380);
        for(L2Player player : L2ObjectsStorage.getAllPlayers())
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_MANUFACTURE)
          {
            int[] point = gh_spawn_loc2.getRandomPoint();
            player.decayMe();
            if(player.getReflection().getId() != -2)
            {
              player.setVar("backCoords", player.getLoc().toXYZString());
              player.setReflection(-2);
            }
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        // Зона продажи
        gh_spawn_loc2 = new L2Territory(10000006);
        gh_spawn_loc2.add(47665, 186755, -3480, -3380);
        gh_spawn_loc2.add(48167, 186488, -3480, -3380);
        gh_spawn_loc2.add(48397, 186625, -3480, -3380);
        gh_spawn_loc2.add(50156, 184674, -3488, -3388);
        gh_spawn_loc2.add(49292, 183916, -3488, -3388);
        gh_spawn_loc2.add(47758, 185654, -3488, -3388);
        gh_spawn_loc2.add(47244, 185894, -3488, -3388);
        for(L2Player player : L2ObjectsStorage.getAllPlayers())
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL || player.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL_PACKAGE)
          {
            int[] point = gh_spawn_loc2.getRandomPoint();
            player.decayMe();
            if(player.getReflection().getId() != -2)
            {
              player.setVar("backCoords", player.getLoc().toXYZString());
              player.setReflection(-2);
            }
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        break;
      case admin_fix_gh_r:
        int radius = 500;
        if(wordList.length > 1)
        {
          radius = Integer.parseInt(wordList[1]);
        }
        L2Territory spawn_loc;
        // Зона покупки
        spawn_loc = new L2Territory(10000004);
        spawn_loc.add(46091, 186412, -3488, -3388);
        spawn_loc.add(47218, 185902, -3488, -3388);
        spawn_loc.add(47761, 186929, -3480, -3380);
        spawn_loc.add(46742, 187511, -3480, -3380);
        for(L2Player player : L2World.getAroundPlayers(activeChar, radius, 200))
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_BUY)
          {
            int[] point = spawn_loc.getRandomPoint();
            player.decayMe();
            if(player.getReflection().getId() != -2)
            {
              player.setVar("backCoords", player.getLoc().toXYZString());
              player.setReflection(-2);
            }
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        // Зона крафта
        spawn_loc = new L2Territory(10000005);
        spawn_loc.add(45704, 186617, -3480, -3380);
        spawn_loc.add(46086, 186419, -3488, -3388);
        spawn_loc.add(46733, 187506, -3480, -3380);
        spawn_loc.add(46294, 187709, -3480, -3380);
        for(L2Player player : L2World.getAroundPlayers(activeChar, radius, 200))
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_MANUFACTURE)
          {
            int[] point = spawn_loc.getRandomPoint();
            player.decayMe();
            if(player.getReflection().getId() != -2)
            {
              player.setVar("backCoords", player.getLoc().toXYZString());
              player.setReflection(-2);
            }
            player.setXYZ(point[0], point[1], point[2]);
            player.spawnMe();
          }
        }
        // Зона продажи
        spawn_loc = new L2Territory(10000006);
        spawn_loc.add(47665, 186755, -3480, -3380);
        spawn_loc.add(48167, 186488, -3480, -3380);
        spawn_loc.add(48397, 186625, -3480, -3380);
        spawn_loc.add(50156, 184674, -3488, -3388);
        spawn_loc.add(49292, 183916, -3488, -3388);
        spawn_loc.add(47758, 185654, -3488, -3388);
        spawn_loc.add(47244, 185894, -3488, -3388);
        for(L2Player player : L2World.getAroundPlayers(activeChar, radius, 200))
        {
          if(player.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL || player.getPrivateStoreType() == L2Player.STORE_PRIVATE_SELL_PACKAGE)
          {
            int[] point = spawn_loc.getRandomPoint();
            player.decayMe();
            if(player.getReflection().getId() != -2)
            {
              player.setVar("backCoords", player.getLoc().toXYZString());
              player.setReflection(-2);
View Full Code Here

                      {
                        spawnType = 0;
                        _log.warning("Spawn type  '" + spawnTypeNode.getNodeValue() + "' is unknown!");
                      }
                      int locId = IdFactory.getInstance().getNextId();
                      L2Territory territory = new L2Territory(locId);
                      for(Node location = spawn.getFirstChild(); location != null; location = location.getNextSibling())
                      {
                        if("coords".equalsIgnoreCase(location.getNodeName()))
                        {
                          territory.add(new Location(location.getAttributes().getNamedItem("loc").getNodeValue()));
                        }
                      }
                      if(spawnType == 2) //точечный спавн не проверять
                      {
                        territory.validate();
                      }
                      TerritoryTable.getInstance().getLocations().put(locId, territory);
                      L2World.addTerritory(territory);
                      for(String mob : mobs)
                      {
View Full Code Here

{
  public ObeliskInstance(int objectId, L2NpcTemplate template)
  {
    super(objectId, template);
    int id = IdFactory.getInstance().getNextId();
    L2Territory pos = new L2RoundTerritory(id, -245825, 217075, 230, -12208, -12000);
    setGeoPos(pos);
    GeoEngine.applyControl(this);
  }
View Full Code Here

                      zMin = Integer.parseInt(attrs.getNamedItem("zMin").getNodeValue());
                      zMax = Integer.parseInt(attrs.getNamedItem("zMax").getNodeValue());
                    }
                  }
                  int loc_id = IdFactory.getInstance().getNextId();
                  L2Territory territory = new L2Territory(loc_id);
                  territory.add(xMin, yMin, zMin, zMax);
                  territory.add(xMax, yMin, zMin, zMax);
                  territory.add(xMax, yMax, zMin, zMax);
                  territory.add(xMin, yMax, zMin, zMax);
                  territory.validate();
                  TerritoryTable.getInstance().getLocations().put(loc_id, territory);
                  L2World.addTerritory(territory);
                  if(!_rooms.containsKey(type))
                  {
                    _rooms.put(type, new FastMap<Integer, DimensionalRiftRoom>().setShared(true));
View Full Code Here

    GArray<Integer> locIds = new GArray<Integer>();
    for(int locId : TerritoryTable.getInstance().getLocations().keySet())
    {
      locIds.add(locId);
    }
    L2Territory terr = TerritoryTable.getInstance().getLocation(locIds.get(Rnd.get(locIds.size())));
    return new Location(terr.getRandomPoint());
  }
View Full Code Here

              npcDat.set("basePDef", pdef);
              npcDat.set("baseMDef", mdef);
              L2CharTemplate template = new L2CharTemplate(npcDat);
              L2DoorInstance door = new L2DoorInstance(IdFactory.getInstance().getNextId(), template, id, name, unlockable, showHp);
              _staticItems.put(id, door);
              L2Territory pos = new L2Territory(id);
              door.setGeoPos(pos);
              pos.add(ax, ay, minz, maxz);
              pos.add(bx, by, minz, maxz);
              pos.add(cx, cy, minz, maxz);
              pos.add(dx, dy, minz, maxz);
              door.getTemplate().collisionHeight = maxz - minz & 0xfff0;
              door.getTemplate().collisionRadius = Math.max(50, Math.min(posx - pos.getXmin(), posy - pos.getYmin()));
              door.setXYZInvisible(posx, posy, minz + 32);
              door.setCurrentHpMp(door.getMaxHp(), door.getMaxMp(), true);
              door.setOpen(false);
              door.level = level;
              door.key = key;
              // Дверь/стена может быть атакована только осадным оружием
              door.setSiegeWeaponOlnyAttackable(siege_weapon);
              door.setGeodata(geodata);
              door.spawnMe(door.getLoc());
              if(Config.debugDoor)
              {
                if(door.getTemplate().collisionRadius > 200)
                {
                  System.out.println("DoorId: " + id + ", collision: " + door.getTemplate().collisionRadius + ", posx: " + posx + ", posy: " + posy + ", xMin: " + pos.getXmin() + ", yMin: " + pos.getYmin());
                }
                if(pos.getXmin() == pos.getXmax())
                {
                  _log.warning("door " + id + " has zero size");
                }
                else if(pos.getYmin() == pos.getYmax())
                {
                  _log.warning("door " + id + " has zero size");
                }
              }
            }
View Full Code Here

    return false;
  }

  public static void returnGeoAtControl(GeoControl control)
  {
    L2Territory pos = control.getGeoPos();
    HashMap<Long, Byte> around = control.getGeoAround();
    int refIndex = control.getReflection().getGeoIndex();
    if(around == null)
    {
      Log.add("GeoEngine: Attempt to open 'not closed' door", "doors");
      Thread.dumpStack();
      return;
    }
    short height;
    byte old_nswe;
    synchronized(around)
    {
      for(long geoXY : around.keySet())
      {
        int geoX = (int) geoXY;
        int geoY = (int) (geoXY >> 32);
        // Получение мировых координат
        int ix = geoX >> 11;
        int iy = geoY >> 11;
        // Получение индекса блока
        int blockX = getBlock(geoX);
        int blockY = getBlock(geoY);
        int blockIndex = getBlockIndex(blockX, blockY);
        byte[][][] region = geodata[ix][iy];
        if(region == null)
        {
          Log.add("GeoEngine: Attempt to open door at block with no geodata", "doors");
          return;
        }
        if(region.length <= refIndex)
        {
          refIndex = 0;
        }
        byte[] block = region[blockIndex][refIndex];
        int cellX = getCell(geoX);
        int cellY = getCell(geoY);
        int index = 0;
        byte blockType = block[index];
        index++;
        switch(blockType)
        {
          case BLOCKTYPE_COMPLEX:
            index += (cellX << 3) + cellY << 1;
            // Получаем высоту клетки
            height = makeShort(block[index + 1], block[index]);
            old_nswe = (byte) (height & 0x0F);
            height &= 0xfff0;
            height >>= 1;
            // around
            height <<= 1;
            height &= 0xfff0;
            height |= old_nswe;
            if(control.isGeoCloser())
            {
              height |= around.get(geoXY);
            }
            else
            {
              height &= ~around.get(geoXY);
            }
            // Записываем высоту в массив
            block[index + 1] = (byte) (height >> 8);
            block[index] = (byte) (height & 0x00ff);
            break;
          case BLOCKTYPE_MULTILEVEL:
            // Последний валидный индекс для двери
            int neededIndex = -1;
            // Далее следует стандартный механизм получения высоты
            int offset = (cellX << 3) + cellY;
            while(offset > 0)
            {
              byte lc = block[index];
              index += (lc << 1) + 1;
              offset--;
            }
            byte layers = block[index];
            index++;
            if(layers <= 0 || layers > MAX_LAYERS)
            {
              break;
            }
            short temph = Short.MIN_VALUE;
            old_nswe = NSWE_ALL;
            while(layers > 0)
            {
              height = makeShort(block[index + 1], block[index]);
              byte tmp_nswe = (byte) (height & 0x0F);
              height &= 0xfff0;
              height >>= 1;
              int z_diff_last = Math.abs(pos.getZmin() - temph);
              int z_diff_curr = Math.abs(pos.getZmin() - height);
              if(z_diff_last > z_diff_curr)
              {
                old_nswe = tmp_nswe;
                temph = height;
                neededIndex = index;
View Full Code Here

    }
  }

  public static void applyControl(GeoControl control)
  {
    L2Territory pos = control.getGeoPos();
    HashMap<Long, Byte> around = control.getGeoAround();
    int refIndex = control.getReflection().getGeoIndex();
    boolean first_time = around == null;
    // TODO сделать этот самый Init :)
    // т.е. скопировать кусок геодаты из реального мира в инстанс, еще до закрытия двери.
    if(around == null)
    {
      around = new HashMap<Long, Byte>();
      GArray<Long> around_blocks = new GArray<Long>();
      int minX = pos.getXmin() - L2World.MAP_MIN_X >> 4;
      int maxX = pos.getXmax() - L2World.MAP_MIN_X >> 4;
      int minY = pos.getYmin() - L2World.MAP_MIN_Y >> 4;
      int maxY = pos.getYmax() - L2World.MAP_MIN_Y >> 4;
      for(int geoX = minX; geoX <= maxX; geoX++)
      {
        for(int geoY = minY; geoY <= maxY; geoY++)
        {
          if(check_cell_in_door(geoX, geoY, pos))
          {
            around_blocks.add(makeLong(geoX, geoY));
          }
        }
      }
      for(long geoXY : around_blocks)
      {
        int geoX = (int) geoXY;
        int geoY = (int) (geoXY >> 32);
        long aroundN_geoXY = makeLong(geoX, geoY - 1); // close S
        long aroundS_geoXY = makeLong(geoX, geoY + 1); // close N
        long aroundW_geoXY = makeLong(geoX - 1, geoY); // close E
        long aroundE_geoXY = makeLong(geoX + 1, geoY); // close W
        around.put(geoXY, NSWE_ALL);
        byte _nswe;
        if(!around_blocks.contains(aroundN_geoXY))
        {
          _nswe = around.containsKey(aroundN_geoXY) ? around.remove(aroundN_geoXY) : 0;
          _nswe |= SOUTH;
          around.put(aroundN_geoXY, _nswe);
        }
        if(!around_blocks.contains(aroundS_geoXY))
        {
          _nswe = around.containsKey(aroundS_geoXY) ? around.remove(aroundS_geoXY) : 0;
          _nswe |= NORTH;
          around.put(aroundS_geoXY, _nswe);
        }
        if(!around_blocks.contains(aroundW_geoXY))
        {
          _nswe = around.containsKey(aroundW_geoXY) ? around.remove(aroundW_geoXY) : 0;
          _nswe |= EAST;
          around.put(aroundW_geoXY, _nswe);
        }
        if(!around_blocks.contains(aroundE_geoXY))
        {
          _nswe = around.containsKey(aroundE_geoXY) ? around.remove(aroundE_geoXY) : 0;
          _nswe |= WEST;
          around.put(aroundE_geoXY, _nswe);
        }
      }
      around_blocks.clear();
      control.setGeoAround(around);
    }
    short height;
    byte old_nswe, close_nswe;
    synchronized(around)
    {
      Long[] around_keys = around.keySet().toArray(new Long[around.size()]);
      for(long geoXY : around_keys)
      {
        int geoX = (int) geoXY;
        int geoY = (int) (geoXY >> 32);
        // Получение мировых координат
        int ix = geoX >> 11;
        int iy = geoY >> 11;
        // Получение индекса блока
        int blockX = getBlock(geoX);
        int blockY = getBlock(geoY);
        int blockIndex = getBlockIndex(blockX, blockY);
        // Попытка скопировать блок геодаты, если уже существует, то не скопируется
        if(first_time)
        {
          copyBlock(ix, iy, blockIndex);
        }
        byte[][][] region = geodata[ix][iy];
        if(region == null)
        {
          Log.add("GeoEngine: Attempt to close door at block with no geodata", "doors");
          return;
        }
        if(region.length <= refIndex)
        {
          refIndex = 0;
        }
        byte[] block = region[blockIndex][refIndex];
        int cellX = getCell(geoX);
        int cellY = getCell(geoY);
        int index = 0;
        byte blockType = block[index];
        index++;
        switch(blockType)
        {
          case BLOCKTYPE_COMPLEX:
            index += (cellX << 3) + cellY << 1;
            // Получаем высоту клетки
            height = makeShort(block[index + 1], block[index]);
            old_nswe = (byte) (height & 0x0F);
            height &= 0xfff0;
            height >>= 1;
            if(first_time)
            {
              close_nswe = around.remove(geoXY);
              // подходящий слой не найден
              if(!check_door_z(pos.getZmin(), pos.getZmax(), height))
              {
                break;
              }
              if(control.isGeoCloser())
              {
                close_nswe &= old_nswe;
              }
              else
              {
                close_nswe &= ~old_nswe;
              }
              around.put(geoXY, close_nswe);
            }
            else
            {
              close_nswe = around.get(geoXY);
            }
            // around
            height <<= 1;
            height &= 0xfff0;
            height |= old_nswe;
            if(control.isGeoCloser())
            {
              height &= ~close_nswe;
            }
            else
            {
              height |= close_nswe;
            }
            // Записываем высоту в массив
            block[index + 1] = (byte) (height >> 8);
            block[index] = (byte) (height & 0x00ff);
            break;
          case BLOCKTYPE_MULTILEVEL:
            // Последний валидный индекс для двери
            int neededIndex = -1;
            // Далее следует стандартный механизм получения высоты
            int offset = (cellX << 3) + cellY;
            while(offset > 0)
            {
              byte lc = block[index];
              index += (lc << 1) + 1;
              offset--;
            }
            byte layers = block[index];
            index++;
            if(layers <= 0 || layers > MAX_LAYERS)
            {
              break;
            }
            short temph = Short.MIN_VALUE;
            old_nswe = NSWE_ALL;
            while(layers > 0)
            {
              height = makeShort(block[index + 1], block[index]);
              byte tmp_nswe = (byte) (height & 0x0F);
              height &= 0xfff0;
              height >>= 1;
              int z_diff_last = Math.abs(pos.getZmin() - temph);
              int z_diff_curr = Math.abs(pos.getZmin() - height);
              if(z_diff_last > z_diff_curr)
              {
                old_nswe = tmp_nswe;
                temph = height;
                neededIndex = index;
              }
              layers--;
              index += 2;
            }
            if(first_time)
            {
              close_nswe = around.remove(geoXY);
              // подходящий слой не найден
              if(temph == Short.MIN_VALUE || !check_door_z(pos.getZmin(), pos.getZmax(), temph))
              {
                break;
              }
              if(control.isGeoCloser())
              {
View Full Code Here

  {
    NamedNodeMap attr_point = points.getAttributes();
    String xyzz = attr_point.getNamedItem("xyzz").getNodeValue();
    if(TerritoryTable._locations.get(id) == null)
    {
      L2Territory t = new L2Territory(id);
      TerritoryTable._locations.put(id, t);
    }
    StringTokenizer st = new StringTokenizer(xyzz, " ");
    int x = Integer.parseInt(st.nextToken());
    int y = Integer.parseInt(st.nextToken());
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.L2Territory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.