{
for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if("zone".equalsIgnoreCase(d.getNodeName()))
{
L2Zone z = new L2Zone(XMLUtil.getAttributeIntValue(d, "id", 0));
z.setType(ZoneType.valueOf(XMLUtil.getAttributeValue(d, "type")));
z.setName(XMLUtil.getAttributeValue(d, "name"));
boolean enabled = true;
for(Node e = d.getFirstChild(); e != null; e = e.getNextSibling())
{
if("set".equalsIgnoreCase(e.getNodeName()))
{
String name = XMLUtil.getAttributeValue(e, "name");
if("index".equalsIgnoreCase(name))
{
z.setIndex(XMLUtil.getAttributeIntValue(e, "val", 0));
}
else if("taxById".equalsIgnoreCase(name))
{
z.setTaxById(XMLUtil.getAttributeIntValue(e, "val", 0));
}
else if("entering_message_no".equalsIgnoreCase(name))
{
z.setEnteringMessageId(XMLUtil.getAttributeIntValue(e, "val", 0));
}
else if("leaving_message_no".equalsIgnoreCase(name))
{
z.setLeavingMessageId(XMLUtil.getAttributeIntValue(e, "val", 0));
}
else if("target".equalsIgnoreCase(name))
{
z.setTarget(XMLUtil.getAttributeValue(e, "val"));
}
else if("skill_name".equalsIgnoreCase(name))
{
z.setSkill(XMLUtil.getAttributeValue(e, "val"));
}
else if("skill_prob".equalsIgnoreCase(name))
{
z.setSkillProb(XMLUtil.getAttributeValue(e, "val"));
}
else if("unit_tick".equalsIgnoreCase(name))
{
z.setUnitTick(XMLUtil.getAttributeValue(e, "val"));
}
else if("initial_delay".equalsIgnoreCase(name))
{
z.setInitialDelay(XMLUtil.getAttributeValue(e, "val"));
}
else if("restart_time".equalsIgnoreCase(name))
{
z.setRestartTime(XMLUtil.getAttributeLongValue(e, "val", 0));
}
else if("blocked_actions".equalsIgnoreCase(name))
{
z.setBlockedActions(XMLUtil.getAttributeValue(e, "val"));
}
else if("damage_on_hp".equalsIgnoreCase(name))
{
z.setDamageOnHP(XMLUtil.getAttributeValue(e, "val"));
}
else if("damage_on_mp".equalsIgnoreCase(name))
{
z.setDamageOnМP(XMLUtil.getAttributeValue(e, "val"));
}
else if("message_no".equalsIgnoreCase(name))
{
z.setMessageNumber(XMLUtil.getAttributeValue(e, "val"));
}
else if("move_bonus".equalsIgnoreCase(name))
{
z.setMoveBonus(XMLUtil.getAttributeValue(e, "val"));
}
else if("hp_regen_bonus".equalsIgnoreCase(name))
{
z.setRegenBonusHP(XMLUtil.getAttributeValue(e, "val"));
}
else if("mp_regen_bonus".equalsIgnoreCase(name))
{
z.setRegenBonusMP(XMLUtil.getAttributeValue(e, "val"));
}
else if("affect_race".equalsIgnoreCase(name))
{
z.setAffectRace(XMLUtil.getAttributeValue(e, "val"));
}
else if("event".equalsIgnoreCase(name))
{
z.setEvent(XMLUtil.getAttributeValue(e, "val"));
}
else if("reflectionId".equalsIgnoreCase(name))
{
z.setReflectionId(XMLUtil.getAttributeIntValue(e, "val", 0));
}
else if("enabled".equalsIgnoreCase(name))
{
enabled = XMLUtil.getAttributeBooleanValue(e, "val", true) || z.getType() == ZoneType.water;
}
else
{
z.setParam(name, XMLUtil.getAttributeValue(e, "val"));
}
}
else if("shape".equalsIgnoreCase(e.getNodeName()) || "restart_point".equalsIgnoreCase(e.getNodeName()) || "PKrestart_point".equalsIgnoreCase(e.getNodeName()))
{
int locId = IdFactory.getInstance().getNextId();
boolean isRound = !XMLUtil.getAttributeValue(e, "loc").isEmpty();
L2Territory territory;
if(isRound)
{
String[] coord = XMLUtil.getAttributeValue(e, "loc").replaceAll(",", " ").replaceAll(";", " ").replaceAll(" ", " ").trim().split(" ");
if(coord.length < 5) // Не указаны minZ и maxZ, берем граничные значения
{
territory = new L2RoundTerritory(locId, Integer.parseInt(coord[0]), Integer.parseInt(coord[1]), Integer.parseInt(coord[2]), Integer.MIN_VALUE, Integer.MAX_VALUE);
}
else
{
territory = new L2RoundTerritory(locId, Integer.parseInt(coord[0]), Integer.parseInt(coord[1]), Integer.parseInt(coord[2]), Integer.parseInt(coord[3]), Integer.parseInt(coord[4]));
}
}
else
{
territory = new L2Territory(locId);
for(Node location = e.getFirstChild(); location != null; location = location.getNextSibling())
{
if("coords".equalsIgnoreCase(location.getNodeName()))
{
String[] coord = XMLUtil.getAttributeValue(location, "loc").replaceAll(",", " ").replaceAll(";", " ").replaceAll(" ", " ").trim().split(" ");
if(coord.length < 4) // Не указаны minZ и maxZ, берем граничные значения
{
territory.add(Integer.parseInt(coord[0]), Integer.parseInt(coord[1]), Integer.MIN_VALUE, Integer.MAX_VALUE);
}
else
{
territory.add(Integer.parseInt(coord[0]), Integer.parseInt(coord[1]), Integer.parseInt(coord[2]), Integer.parseInt(coord[3]));
}
}
}
}
if("shape".equalsIgnoreCase(e.getNodeName()))
{
z.setLoc(territory);
territory.setZone(z);
territory.validate();
}
else if("restart_point".equalsIgnoreCase(e.getNodeName()))
{
z.setRestartPoints(territory);
}
else if("PKrestart_point".equalsIgnoreCase(e.getNodeName()))
{
z.setPKRestartPoints(territory);
}
z.setActive(enabled);
TerritoryTable.getInstance().getLocations().put(locId, territory);
}
}
if(z.getType() == ZoneType.no_landing || z.getType() == ZoneType.Siege || z.getType() == ZoneType.Castle || z.getType() == ZoneType.Fortress || z.getType() == ZoneType.OlympiadStadia)
{
z.getListenerEngine().addMethodInvokedListener(_noLandingZoneListener);
}
if(z.getType() == ZoneType.monster_trap)
{
z.getListenerEngine().addMethodInvokedListener(_monsterTrapZoneListener);
}
if(_zonesByType.get(z.getType()) == null)
{
_zonesByType.put(z.getType(), new GArray<L2Zone>());
}
_zonesByType.get(z.getType()).add(z);
count++;
}
}
}
}