game/src/main/java/com/l2jfrozen/gameserver/model/zone/L2ZoneForm.java
//landing coordinates.
+ protected boolean lineSegmentsIntersect(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
+ {
+ return java.awt.geom.Line2D.linesIntersect(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2);
+ }
+
protected boolean lineIntersectsLine(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
{
int s1 = sameSide(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2);
game/src/main/java/com/l2jfrozen/gameserver/model/zone/L2ZoneType.java
{
if(_characterList.containsKey(character.getObjectId()))
{
+ if(Config.ZONE_DEBUG && character!=null && character instanceof L2PcInstance && character.getName()!=null)
+ LOGGER.info("ZONE_DEBUG: " + "Character " + character.getName()+" removed from zone.");
+
_characterList.remove(character.getObjectId());
onExit(character);
}
game/src/main/java/com/l2jfrozen/gameserver/model/zone/form/ZoneNPoly.java
/**
* A not so primitive npoly zone
*
+ *
* @author durgus
*/
public class ZoneNPoly extends L2ZoneForm
@Override
public boolean isInsideZone(int x, int y, int z)
{
- if(z < _z1 || z > _z2)
+ if (z < _z1 || z > _z2)
return false;
boolean inside = false;
-
- for(int i = 0, j = _x.length - 1; i < _x.length; j = i++)
+ for (int i = 0, j = _x.length - 1; i < _x.length; j = i++)
{
- if((_y[i] <= y && y < _y[j] || _y[j] <= y && y < _y[i]) && x < (_x[j] - _x[i]) * (y - _y[i]) / (_y[j] - _y[i]) + _x[i])
+ if ((((_y[i] <= y) && (y < _y[j])) || ((_y[j] <= y) && (y < _y[i]))) && (x < (_x[j] - _x[i]) * (y - _y[i]) / (_y[j] - _y[i]) + _x[i]))
{
inside = !inside;
}
int tX, tY, uX, uY;
// First check if a point of the polygon lies inside the rectangle
- if(_x[0] > ax1 && _x[0] < ax2 && _y[0] > ay1 && _y[0] < ay2)
+ if (_x[0] > ax1 && _x[0] < ax2 && _y[0] > ay1 && _y[0] < ay2)
return true;
// Or a point of the rectangle inside the polygon
- if(isInsideZone(ax1, ay1, (_z2 - 1)))
+ if (isInsideZone(ax1, ay1, (_z2 - 1)))
return true;
- // If the first point wasnt inside the rectangle it might still have any line crossing any side
+ // If the first point wasn't inside the rectangle it might still have any line crossing any side
// of the rectangle
// Check every possible line of the polygon for a collision with any of the rectangles side
- for(int i = 0; i < _y.length; i++)
+ for (int i = 0; i < _y.length; i++)
{
tX = _x[i];
tY = _y[i];
uY = _y[(i + 1) % _x.length];
// Check if this line intersects any of the four sites of the rectangle
- if(lineIntersectsLine(tX, tY, uX, uY, ax1, ay1, ax1, ay2))
+ if (lineSegmentsIntersect(tX, tY, uX, uY, ax1, ay1, ax1, ay2))
return true;
-
- if(lineIntersectsLine(tX, tY, uX, uY, ax1, ay1, ax2, ay1))
+ if (lineSegmentsIntersect(tX, tY, uX, uY, ax1, ay1, ax2, ay1))
return true;
-
- if(lineIntersectsLine(tX, tY, uX, uY, ax2, ay2, ax1, ay2))
+ if (lineSegmentsIntersect(tX, tY, uX, uY, ax2, ay2, ax1, ay2))
return true;
-
- if(lineIntersectsLine(tX, tY, uX, uY, ax2, ay2, ax2, ay1))
+ if (lineSegmentsIntersect(tX, tY, uX, uY, ax2, ay2, ax2, ay1))
return true;
}
@Override
public double getDistanceToZone(int x, int y)
{
- // Since we aren't given a z coordinate to test against
- // we just use the minimum z coordinate to prevent the
- // function from saying we aren't in the zone because
- // of a bad z coordinate.
- if(isInsideZone(x, y, _z1))
- return 0; // If you are inside the zone distance to zone is 0.
-
double test, shortestDist = Math.pow(_x[0] - x, 2) + Math.pow(_y[0] - y, 2);
- for(int i = 1; i < _y.length; i++)
+ for (int i = 1; i < _y.length; i++)
{
test = Math.pow(_x[i] - x, 2) + Math.pow(_y[i] - y, 2);
- if(test < shortestDist)
- {
+ if (test < shortestDist)
shortestDist = test;
- }
}
return Math.sqrt(shortestDist);
}
- /* getLowZ() / getHighZ() - These two functions were added to cope with the demand of the new
- * fishing algorithms, wich are now able to correctly place the hook in the water, thanks to getHighZ().
- * getLowZ() was added, considering potential future modifications.
+ /*
+ * getLowZ() / getHighZ() - These two functions were added to cope with the demand of the new fishing algorithms, wich are now able to correctly place the hook in the water, thanks to getHighZ(). getLowZ() was added, considering potential future modifications.
*/
@Override
public int getLowZ()
{
return _z2;
}
-}
+}
game/src/main/java/com/l2jfrozen/gameserver/model/zone/type/L2TownZone.java
if(((L2PcInstance) character).getSiegeState() != 0 && Config.ZONE_TOWN == 1)
return;
- if(Config.DEBUG)
+ if(Config.ZONE_DEBUG)
((L2PcInstance) character).sendMessage("You entered " + _townName);
}
if(!_noPeace && Config.ZONE_TOWN != 2)
- {
character.setInsideZone(L2Character.ZONE_PEACE, true);
- }
-
}
@Override
protected void onExit(L2Character character)
{
if(!_noPeace)
- {
character.setInsideZone(L2Character.ZONE_PEACE, false);
- }
- if(Config.DEBUG)
+
+ if(Config.ZONE_DEBUG)
+ {
if(character instanceof L2PcInstance)
{
((L2PcInstance) character).sendMessage("You left " + _townName);
}
+ }
}
trunk/gameserver/head-src/com/l2jfrozen/Config.java
public static boolean DEBUG;
+ public static boolean ZONE_DEBUG;
public static boolean ASSERT;
DEBUG = Boolean.parseBoolean(devSettings.getProperty("Debug", "false"));
+ ZONE_DEBUG = Boolean.parseBoolean(devSettings.getProperty("ZoneDebug", "false"));
ASSERT = Boolean.parseBoolean(devSettings.getProperty("Assert", "false"));
gameserver\config\functions\developer.properties
Debug = False
+ # Debug Zones
+ ZoneDebug = True
Assert = False