SHOW:
|
|
- or go back to the newest paste.
| 1 | - | Index: com/l2jserver/gameserver/GameServer.java |
| 1 | + | Index: java/com/l2jserver/gameserver/GameServer.java |
| 2 | =================================================================== | |
| 3 | - | --- com/l2jserver/gameserver/GameServer.java (revision 5685) |
| 3 | + | --- java/com/l2jserver/gameserver/GameServer.java (revision 5685) |
| 4 | - | +++ com/l2jserver/gameserver/GameServer.java (working copy) |
| 4 | + | +++ java/com/l2jserver/gameserver/GameServer.java (working copy) |
| 5 | @@ -49,6 +49,7 @@ | |
| 6 | import com.l2jserver.gameserver.datatables.EnchantOptionsData; | |
| 7 | import com.l2jserver.gameserver.datatables.EventDroplist; | |
| 8 | import com.l2jserver.gameserver.datatables.ExperienceTable; | |
| 9 | +import com.l2jserver.gameserver.datatables.FencesTable; | |
| 10 | import com.l2jserver.gameserver.datatables.FishData; | |
| 11 | import com.l2jserver.gameserver.datatables.FishingMonstersData; | |
| 12 | import com.l2jserver.gameserver.datatables.FishingRodsData; | |
| 13 | @@ -256,7 +257,7 @@ | |
| 14 | PathFinding.getInstance(); | |
| 15 | } | |
| 16 | ||
| 17 | - printSection("NPCs");
| |
| 18 | + printSection("WorldObjects");
| |
| 19 | HerbDropTable.getInstance(); | |
| 20 | NpcTable.getInstance(); | |
| 21 | NpcWalkerRoutesData.getInstance(); | |
| 22 | @@ -269,6 +270,7 @@ | |
| 23 | FortManager.getInstance().loadInstances(); | |
| 24 | NpcBufferTable.getInstance(); | |
| 25 | SpawnTable.getInstance(); | |
| 26 | + FencesTable.getInstance(); | |
| 27 | HellboundManager.getInstance(); | |
| 28 | RaidBossSpawnManager.getInstance(); | |
| 29 | DayNightSpawnManager.getInstance().trim().notifyChangeMode(); | |
| 30 | - | Index: com/l2jserver/gameserver/datatables/FencesTable.java |
| 30 | + | Index: java/com/l2jserver/gameserver/datatables/FencesTable.java |
| 31 | =================================================================== | |
| 32 | - | --- com/l2jserver/gameserver/datatables/FencesTable.java (revision 0) |
| 32 | + | --- java/com/l2jserver/gameserver/datatables/FencesTable.java (revision 0) |
| 33 | - | +++ com/l2jserver/gameserver/datatables/FencesTable.java (revision 0) |
| 33 | + | +++ java/com/l2jserver/gameserver/datatables/FencesTable.java (revision 0) |
| 34 | - | @@ -0,0 +1,173 @@ |
| 34 | + | @@ -0,0 +1,178 @@ |
| 35 | +/* | |
| 36 | + * This program is free software: you can redistribute it and/or modify it under | |
| 37 | + * the terms of the GNU General Public License as published by the Free Software | |
| 38 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 39 | + * version. | |
| 40 | + * | |
| 41 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 42 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 43 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 44 | + * details. | |
| 45 | + * | |
| 46 | + * You should have received a copy of the GNU General Public License along with | |
| 47 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 48 | + */ | |
| 49 | +package com.l2jserver.gameserver.datatables; | |
| 50 | + | |
| 51 | +import java.sql.Connection; | |
| 52 | +import java.sql.PreparedStatement; | |
| 53 | +import java.sql.ResultSet; | |
| 54 | +import java.sql.SQLException; | |
| 55 | +import java.util.HashMap; | |
| 56 | +import java.util.Map; | |
| 57 | +import java.util.logging.Level; | |
| 58 | +import java.util.logging.Logger; | |
| 59 | + | |
| 60 | +import com.l2jserver.L2DatabaseFactory; | |
| 61 | +import com.l2jserver.gameserver.model.Location; | |
| 62 | +import com.l2jserver.gameserver.model.actor.instance.L2FenceInstance; | |
| 63 | +import com.l2jserver.util.StringUtil; | |
| 64 | + | |
| 65 | +/** | |
| 66 | + * @author Nik based on Christian's work. | |
| 67 | + */ | |
| 68 | +public class FencesTable | |
| 69 | +{
| |
| 70 | + protected static final Logger _log = Logger.getLogger(FencesTable.class.getName()); | |
| 71 | + | |
| 72 | + private static final class SingletonHolder | |
| 73 | + {
| |
| 74 | + protected static final FencesTable _instance = new FencesTable(); | |
| 75 | + } | |
| 76 | + | |
| 77 | + public static FencesTable getInstance() | |
| 78 | + {
| |
| 79 | + return SingletonHolder._instance; | |
| 80 | + } | |
| 81 | + | |
| 82 | + private final Map<Integer, L2FenceInstance> _fences = new HashMap<>(); | |
| 83 | + | |
| 84 | + protected FencesTable() | |
| 85 | + {
| |
| 86 | + load(); | |
| 87 | + _log.log(Level.INFO, StringUtil.concat("Loaded ", String.valueOf(_fences.size()), " stored fences."));
| |
| 88 | + } | |
| 89 | + | |
| 90 | + private void load() | |
| 91 | + {
| |
| 92 | + try (Connection con = L2DatabaseFactory.getInstance().getConnection(); | |
| 93 | + PreparedStatement stmt = con.prepareStatement("SELECT * FROM fences"))
| |
| 94 | + {
| |
| 95 | + ResultSet res = stmt.executeQuery(); | |
| 96 | + while (res.next()) | |
| 97 | + {
| |
| 98 | + L2FenceInstance fence = new L2FenceInstance(res.getInt("object_id"), res.getInt("state"), res.getInt("x"), res.getInt("y"), res.getInt("z"), res.getInt("width"), res.getInt("length"), res.getInt("height"));
| |
| 99 | + fence.setStoredToDB(true); // They are loaded from DB, therefore they are stored there. | |
| 100 | + fence.spawnMe(); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + catch (SQLException sqle) | |
| 104 | + {
| |
| 105 | + _log.log(Level.WARNING, "Exception while loading fences: ", sqle); | |
| 106 | + } | |
| 107 | + } | |
| 108 | + | |
| 109 | + public void reload() | |
| 110 | + {
| |
| 111 | + for (L2FenceInstance fence : _fences.values()) | |
| 112 | + {
| |
| 113 | + // Do not delete temp fences, they aren't stored in DB therefore they won't be reloaded, but deleted. | |
| 114 | + if (!fence.isStoredToDB()) | |
| 115 | + {
| |
| 116 | + fence.decayMe(); | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 120 | + load(); | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void addFence(L2FenceInstance fence) | |
| 124 | + {
| |
| 125 | + _fences.put(fence.getObjectId(), fence); | |
| 126 | + } | |
| 127 | + | |
| 128 | + public L2FenceInstance getFence(int objectId) | |
| 129 | + {
| |
| 130 | + return _fences.get(objectId); | |
| 131 | + } | |
| 132 | + | |
| 133 | + public L2FenceInstance removeFence(int objectId) | |
| 134 | + {
| |
| 135 | + return _fences.remove(objectId); | |
| 136 | + } | |
| 137 | + | |
| 138 | + public Map<Integer, L2FenceInstance> getFences() | |
| 139 | + {
| |
| 140 | + return _fences; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void deleteFence(int objectId, boolean deleteFromDB) | |
| 144 | + {
| |
| 145 | + L2FenceInstance fence = removeFence(objectId); | |
| 146 | + if (fence != null) | |
| 147 | + {
| |
| 148 | + fence.decayMe(); | |
| 149 | + } | |
| 150 | + | |
| 151 | + if (deleteFromDB) | |
| 152 | + {
| |
| 153 | + deleteStoredFence(objectId); | |
| 154 | + } | |
| 155 | + } | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * @param fence - Stores the fence to the database. | |
| 159 | + */ | |
| 160 | + public void storeFence(L2FenceInstance fence) | |
| 161 | + {
| |
| 162 | + try (Connection con = L2DatabaseFactory.getInstance().getConnection(); | |
| 163 | + PreparedStatement stmt = con.prepareStatement("INSERT INTO fences (object_id,state,x,y,z,width,length,height) VALUES(?,?,?,?,?,?,?,?)"))
| |
| 164 | + {
| |
| 165 | + stmt.setInt(1, fence.getObjectId()); | |
| 166 | + stmt.setInt(2, fence.getX()); | |
| 167 | + stmt.setInt(3, fence.getY()); | |
| 168 | + stmt.setInt(4, fence.getZ()); | |
| 169 | + stmt.setInt(5, fence.getWidth()); | |
| 170 | + stmt.setInt(6, fence.getLength()); | |
| 171 | + stmt.setInt(6, fence.getHeight()); | |
| 172 | + stmt.executeUpdate(); | |
| 173 | + } | |
| 174 | + catch (SQLException sqle) | |
| 175 | + {
| |
| 176 | + _log.log(Level.WARNING, "Error while storing fence:", sqle); | |
| 177 | + } | |
| 178 | + } | |
| 179 | + | |
| 180 | + public boolean deleteStoredFence(int objectId) | |
| 181 | + {
| |
| 182 | + try (Connection con = L2DatabaseFactory.getInstance().getConnection(); | |
| 183 | + PreparedStatement stmt = con.prepareStatement("DELETE FROM fences WHERE object_id=?");)
| |
| 184 | + {
| |
| 185 | + | |
| 186 | + stmt.setInt(1, objectId); | |
| 187 | + if (stmt.executeUpdate() > 0) | |
| 188 | + {
| |
| 189 | + return true; | |
| 190 | + } | |
| 191 | + } | |
| 192 | + catch (SQLException sqle) | |
| 193 | + {
| |
| 194 | + _log.log(Level.WARNING, "Error while deleting stored fence:", sqle); | |
| 195 | + } | |
| 196 | + | |
| 197 | + return false; | |
| 198 | + } | |
| 199 | + | |
| 200 | + public boolean checkIfBetweenFences(Location loc1, Location loc2) | |
| 201 | + {
| |
| 202 | + for (L2FenceInstance fence : _fences.values()) | |
| 203 | + {
| |
| 204 | + if (!fence.canSee(loc1, loc2)) | |
| 205 | + {
| |
| 206 | + return true; | |
| 207 | + } | |
| 208 | - | Index: com/l2jserver/gameserver/model/L2Object.java |
| 208 | + | |
| 209 | + | |
| 210 | - | --- com/l2jserver/gameserver/model/L2Object.java (revision 5685) |
| 210 | + | |
| 211 | - | +++ com/l2jserver/gameserver/model/L2Object.java (working copy) |
| 211 | + | |
| 212 | +} | |
| 213 | Index: java/com/l2jserver/gameserver/model/L2Object.java | |
| 214 | =================================================================== | |
| 215 | --- java/com/l2jserver/gameserver/model/L2Object.java (revision 5685) | |
| 216 | +++ java/com/l2jserver/gameserver/model/L2Object.java (working copy) | |
| 217 | @@ -64,6 +64,7 @@ | |
| 218 | L2Object(null), | |
| 219 | L2ItemInstance(L2Object), | |
| 220 | - | Index: com/l2jserver/gameserver/model/actor/instance/L2FenceInstance.java |
| 220 | + | |
| 221 | + L2FenceInstance(L2Object), | |
| 222 | - | --- com/l2jserver/gameserver/model/actor/instance/L2FenceInstance.java (revision 0) |
| 222 | + | |
| 223 | - | +++ com/l2jserver/gameserver/model/actor/instance/L2FenceInstance.java (revision 0) |
| 223 | + | |
| 224 | L2Summon(L2Playable), | |
| 225 | Index: java/com/l2jserver/gameserver/model/actor/instance/L2FenceInstance.java | |
| 226 | =================================================================== | |
| 227 | --- java/com/l2jserver/gameserver/model/actor/instance/L2FenceInstance.java (revision 0) | |
| 228 | +++ java/com/l2jserver/gameserver/model/actor/instance/L2FenceInstance.java (revision 0) | |
| 229 | @@ -0,0 +1,214 @@ | |
| 230 | +/* | |
| 231 | + * This program is free software: you can redistribute it and/or modify it under | |
| 232 | + * the terms of the GNU General Public License as published by the Free Software | |
| 233 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 234 | + * version. | |
| 235 | + * | |
| 236 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 237 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 238 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 239 | + * details. | |
| 240 | + * | |
| 241 | + * You should have received a copy of the GNU General Public License along with | |
| 242 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 243 | + */ | |
| 244 | + | |
| 245 | +package com.l2jserver.gameserver.model.actor.instance; | |
| 246 | + | |
| 247 | +import java.awt.Rectangle; | |
| 248 | + | |
| 249 | +import com.l2jserver.gameserver.datatables.FencesTable; | |
| 250 | +import com.l2jserver.gameserver.idfactory.IdFactory; | |
| 251 | +import com.l2jserver.gameserver.model.L2Object; | |
| 252 | +import com.l2jserver.gameserver.model.Location; | |
| 253 | +import com.l2jserver.gameserver.model.actor.L2Character; | |
| 254 | +import com.l2jserver.gameserver.network.serverpackets.ExColosseumFenceInfo; | |
| 255 | + | |
| 256 | +/** | |
| 257 | + * @author Nik | |
| 258 | + */ | |
| 259 | +public final class L2FenceInstance extends L2Object | |
| 260 | +{
| |
| 261 | + public static final int HIDDEN = 0; | |
| 262 | + public static final int UNCLOSED = 1; | |
| 263 | + public static final int CLOSED = 2; | |
| 264 | + | |
| 265 | + private int _state; | |
| 266 | + private final int _width; | |
| 267 | + private final int _length; | |
| 268 | + private int _height; | |
| 269 | + private Rectangle _shape; | |
| 270 | + private boolean _storedToDB = false; | |
| 271 | + | |
| 272 | + public L2FenceInstance(int objectId, int state, int x, int y, int z, int width, int length, int height) | |
| 273 | + {
| |
| 274 | + super(objectId); | |
| 275 | + setInstanceType(InstanceType.L2FenceInstance); | |
| 276 | + initPosition(); | |
| 277 | + setXYZ(x, y, z); | |
| 278 | + | |
| 279 | + if ((state < 0) || (state > 2)) | |
| 280 | + {
| |
| 281 | + state = 0; | |
| 282 | + } | |
| 283 | + _state = state; | |
| 284 | + _width = width; | |
| 285 | + _length = length; | |
| 286 | + _height = height; | |
| 287 | + _shape = new Rectangle(getX(), getY(), _width, _length); | |
| 288 | + } | |
| 289 | + | |
| 290 | + public L2FenceInstance(int x, int y, int z, int width, int length) | |
| 291 | + {
| |
| 292 | + super(IdFactory.getInstance().getNextId()); | |
| 293 | + setInstanceType(InstanceType.L2FenceInstance); | |
| 294 | + initPosition(); | |
| 295 | + setXYZ(x, y, z); | |
| 296 | + _state = CLOSED; // Its a better default than HIDDEN. | |
| 297 | + _width = width; | |
| 298 | + _length = length; | |
| 299 | + _height = 50; | |
| 300 | + _shape = new Rectangle(getX(), getY(), _width, _length); | |
| 301 | + } | |
| 302 | + | |
| 303 | + public boolean isLocInside(Location loc) | |
| 304 | + {
| |
| 305 | + boolean isInsideZ = (loc.getZ() >= getZ()) && (loc.getZ() <= (getZ() + _height)); | |
| 306 | + return _shape.contains(loc.getX(), loc.getY()) && isInsideZ && (getInstanceId() == loc.getInstanceId()); | |
| 307 | + } | |
| 308 | + | |
| 309 | + public boolean isLocOutside(Location loc) | |
| 310 | + {
| |
| 311 | + return !isLocInside(loc); | |
| 312 | + } | |
| 313 | + | |
| 314 | + /** | |
| 315 | + * @param x1 - obj1's X loc | |
| 316 | + * @param y1 - obj1's Y loc | |
| 317 | + * @param x2 - obj2's X loc | |
| 318 | + * @param y2 - obj2's Y loc | |
| 319 | + * @return can obj1 see obj2 through this fence (their LOS do not intersect the fence's bounds). <B>No Z</B> checks are done. <B>No Instance</B> checks are done. | |
| 320 | + */ | |
| 321 | + public boolean canSee(int x1, int y1, int x2, int y2) | |
| 322 | + {
| |
| 323 | + return !_shape.intersectsLine(x1, y1, x2, y2); | |
| 324 | + } | |
| 325 | + | |
| 326 | + /** | |
| 327 | + * @param loc1 - obj1's xyz & instanceId location | |
| 328 | + * @param loc2 - obj2's xyz & instanceId location | |
| 329 | + * @return can obj1 see obj2 through this fence (their LOS do not intersect the fence's bounds). <B>Z</B> checks are done. <B>Instance</B> checks are done. | |
| 330 | + */ | |
| 331 | + public boolean canSee(Location loc1, Location loc2) | |
| 332 | + {
| |
| 333 | + if ((getState() == CLOSED) && (loc1.getInstanceId() == loc2.getInstanceId())) | |
| 334 | + {
| |
| 335 | + // Those Z checks are probably not 100% accurate, rework them if it must. | |
| 336 | + int higherZ = loc1.getZ() >= loc2.getZ() ? loc1.getZ() : loc2.getZ(); | |
| 337 | + if ((higherZ >= getZ()) && (higherZ <= (getZ() + _height))) | |
| 338 | + {
| |
| 339 | + return canSee(loc1.getX(), loc1.getY(), loc2.getX(), loc2.getY()); | |
| 340 | + } | |
| 341 | + } | |
| 342 | + | |
| 343 | + return true; | |
| 344 | + } | |
| 345 | + | |
| 346 | + /** | |
| 347 | + * @param obj1 | |
| 348 | + * @param obj2 | |
| 349 | + * @return can obj1 see obj2 through this fence (their LOS do not intersect the fence's bounds). <B>Z</B> checks are done. <B>Instance</B> checks are done. | |
| 350 | + */ | |
| 351 | + public boolean canSee(L2Object obj1, L2Object obj2) | |
| 352 | + {
| |
| 353 | + if ((getState() == CLOSED) && (obj1.getInstanceId() == obj2.getInstanceId())) | |
| 354 | + {
| |
| 355 | + // Those Z checks are probably not 100% accurate, rework them if it must. | |
| 356 | + int higherZ = obj1.getZ() >= obj2.getZ() ? obj1.getZ() : obj2.getZ(); | |
| 357 | + if ((higherZ >= getZ()) && (higherZ <= (getZ() + _height))) | |
| 358 | + {
| |
| 359 | + return canSee(obj1.getX(), obj1.getY(), obj2.getX(), obj2.getY()); | |
| 360 | + } | |
| 361 | + } | |
| 362 | + | |
| 363 | + return true; | |
| 364 | + } | |
| 365 | + | |
| 366 | + @Override | |
| 367 | + public void sendInfo(L2PcInstance activeChar) | |
| 368 | + {
| |
| 369 | + activeChar.sendPacket(new ExColosseumFenceInfo(this)); | |
| 370 | + } | |
| 371 | + | |
| 372 | + @Override | |
| 373 | + public boolean isAutoAttackable(L2Character attacker) | |
| 374 | + {
| |
| 375 | + return false; | |
| 376 | + } | |
| 377 | + | |
| 378 | + /** | |
| 379 | + * Also removes the fence from FencesTable, but its not removed from DB | |
| 380 | + */ | |
| 381 | + @Override | |
| 382 | + public void decayMe() | |
| 383 | + {
| |
| 384 | + FencesTable.getInstance().removeFence(getObjectId()); | |
| 385 | + } | |
| 386 | + | |
| 387 | + @Override | |
| 388 | + public void onSpawn() | |
| 389 | + {
| |
| 390 | + // Maybe someone for some reason decided to respawn this fence on different XYZ. RESHAPE!!! | |
| 391 | + _shape = new Rectangle(getX(), getY(), _width, _length); | |
| 392 | + FencesTable.getInstance().addFence(this); | |
| 393 | + } | |
| 394 | + | |
| 395 | + /** | |
| 396 | + * @param height - how high the fence is :D :D Although the client height of the fence is ~50, you can set it to as much as you want. <BR> | |
| 397 | + * Setting it to lower might result in some strange LOS checks. Setting it too high might result in weird LOS checks in all the floors of TOI :P | |
| 398 | + */ | |
| 399 | + public void setHeight(int height) | |
| 400 | + {
| |
| 401 | + _height = height; | |
| 402 | + } | |
| 403 | + | |
| 404 | + public void setState(int state) | |
| 405 | + {
| |
| 406 | + if ((state < 0) || (state > 2)) | |
| 407 | + {
| |
| 408 | + state = 0; | |
| 409 | + } | |
| 410 | + | |
| 411 | + _state = state; | |
| 412 | + } | |
| 413 | + | |
| 414 | + public int getState() | |
| 415 | + {
| |
| 416 | + return _state; | |
| 417 | + } | |
| 418 | + | |
| 419 | + public int getWidth() | |
| 420 | + {
| |
| 421 | + return _width; | |
| 422 | + } | |
| 423 | + | |
| 424 | + public int getLength() | |
| 425 | + {
| |
| 426 | + return _length; | |
| 427 | + } | |
| 428 | + | |
| 429 | + public int getHeight() | |
| 430 | + {
| |
| 431 | + return _height; | |
| 432 | + } | |
| 433 | + | |
| 434 | + public void setStoredToDB(boolean storedToDB) | |
| 435 | + {
| |
| 436 | + _storedToDB = storedToDB; | |
| 437 | + } | |
| 438 | + | |
| 439 | + public boolean isStoredToDB() | |
| 440 | - | Index: com/l2jserver/gameserver/GeoEngine.java |
| 440 | + | |
| 441 | + return _storedToDB; | |
| 442 | - | --- com/l2jserver/gameserver/GeoEngine.java (revision 5685) |
| 442 | + | |
| 443 | - | +++ com/l2jserver/gameserver/GeoEngine.java (working copy) |
| 443 | + | |
| 444 | \ No newline at end of file | |
| 445 | Index: java/com/l2jserver/gameserver/GeoEngine.java | |
| 446 | =================================================================== | |
| 447 | --- java/com/l2jserver/gameserver/GeoEngine.java (revision 5685) | |
| 448 | +++ java/com/l2jserver/gameserver/GeoEngine.java (working copy) | |
| 449 | @@ -34,6 +34,7 @@ | |
| 450 | ||
| 451 | import com.l2jserver.Config; | |
| 452 | import com.l2jserver.gameserver.datatables.DoorTable; | |
| 453 | +import com.l2jserver.gameserver.datatables.FencesTable; | |
| 454 | import com.l2jserver.gameserver.model.L2Object; | |
| 455 | import com.l2jserver.gameserver.model.L2Spawn; | |
| 456 | import com.l2jserver.gameserver.model.L2World; | |
| 457 | @@ -101,6 +102,12 @@ | |
| 458 | {
| |
| 459 | return false; | |
| 460 | } | |
| 461 | + | |
| 462 | + if (FencesTable.getInstance().checkIfBetweenFences(new Location(cha), new Location(target.getX(), target.getY(), target.getZ(), 0, cha.getInstanceId()))) | |
| 463 | + {
| |
| 464 | + return false; | |
| 465 | + } | |
| 466 | + | |
| 467 | if (cha.getZ() >= target.getZ()) | |
| 468 | {
| |
| 469 | return canSeeTarget(cha.getX(), cha.getY(), cha.getZ(), target.getX(), target.getY(), target.getZ()); | |
| 470 | @@ -138,6 +145,10 @@ | |
| 471 | {
| |
| 472 | return true; // door coordinates are hinge coords.. | |
| 473 | } | |
| 474 | + if (FencesTable.getInstance().checkIfBetweenFences(new Location(cha), new Location(target))) | |
| 475 | + {
| |
| 476 | + return false; | |
| 477 | + } | |
| 478 | if (target instanceof L2DefenderInstance) | |
| 479 | {
| |
| 480 | z2 += 30; // well they don't move closer to balcony fence at the moment :( | |
| 481 | @@ -189,6 +200,10 @@ | |
| 482 | {
| |
| 483 | return startpoint; | |
| 484 | } | |
| 485 | + if (FencesTable.getInstance().checkIfBetweenFences(new Location(x, y, z, 0, instanceId), new Location(tx, ty, tz, 0, instanceId))) | |
| 486 | + {
| |
| 487 | - | Index: com/l2jserver/gameserver/idfactory/IdFactory.java |
| 487 | + | |
| 488 | + } | |
| 489 | - | --- com/l2jserver/gameserver/idfactory/IdFactory.java (revision 5685) |
| 489 | + | |
| 490 | - | +++ com/l2jserver/gameserver/idfactory/IdFactory.java (working copy) |
| 490 | + | |
| 491 | return moveCheck(startpoint, destiny, (x - L2World.MAP_MIN_X) >> 4, (y - L2World.MAP_MIN_Y) >> 4, z, (tx - L2World.MAP_MIN_X) >> 4, (ty - L2World.MAP_MIN_Y) >> 4, tz); | |
| 492 | Index: java/com/l2jserver/gameserver/idfactory/IdFactory.java | |
| 493 | =================================================================== | |
| 494 | --- java/com/l2jserver/gameserver/idfactory/IdFactory.java (revision 5685) | |
| 495 | +++ java/com/l2jserver/gameserver/idfactory/IdFactory.java (working copy) | |
| 496 | @@ -102,7 +102,8 @@ | |
| 497 | "SELECT ally_id FROM clan_data WHERE ally_id >= ? AND ally_id < ?", | |
| 498 | "SELECT leader_id FROM clan_data WHERE leader_id >= ? AND leader_id < ?", | |
| 499 | "SELECT item_obj_id FROM pets WHERE item_obj_id >= ? AND item_obj_id < ?", | |
| 500 | - "SELECT object_id FROM itemsonground WHERE object_id >= ? AND object_id < ?" | |
| 501 | + "SELECT object_id FROM itemsonground WHERE object_id >= ? AND object_id < ?", | |
| 502 | + "SELECT object_id FROM fences WHERE object_id >= ? AND object_id < ?" | |
| 503 | }; | |
| 504 | ||
| 505 | private static final String[] TIMESTAMPS_CLEAN = | |
| 506 | @@ -400,6 +401,20 @@ | |
| 507 | temp.add(rs.getInt(1)); | |
| 508 | } | |
| 509 | } | |
| 510 | + | |
| 511 | + try (ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM fences"))
| |
| 512 | + {
| |
| 513 | + rs.next(); | |
| 514 | + temp.ensureCapacity(temp.size() + rs.getInt(1)); | |
| 515 | + } | |
| 516 | + | |
| 517 | + try (ResultSet rs = s.executeQuery("SELECT object_id FROM fences"))
| |
| 518 | + {
| |
| 519 | + while (rs.next()) | |
| 520 | + {
| |
| 521 | + temp.add(rs.getInt(1)); | |
| 522 | - | Index: com/l2jserver/gameserver/network/serverpackets/ExColosseumFenceInfo.java |
| 522 | + | |
| 523 | + } | |
| 524 | - | --- com/l2jserver/gameserver/network/serverpackets/ExColosseumFenceInfo.java (revision 0) |
| 524 | + | |
| 525 | - | +++ com/l2jserver/gameserver/network/serverpackets/ExColosseumFenceInfo.java (revision 0) |
| 525 | + | |
| 526 | } | |
| 527 | Index: java/com/l2jserver/gameserver/network/serverpackets/ExColosseumFenceInfo.java | |
| 528 | =================================================================== | |
| 529 | --- java/com/l2jserver/gameserver/network/serverpackets/ExColosseumFenceInfo.java (revision 0) | |
| 530 | +++ java/com/l2jserver/gameserver/network/serverpackets/ExColosseumFenceInfo.java (revision 0) | |
| 531 | @@ -0,0 +1,57 @@ | |
| 532 | +/* | |
| 533 | + * This program is free software: you can redistribute it and/or modify it under | |
| 534 | + * the terms of the GNU General Public License as published by the Free Software | |
| 535 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 536 | + * version. | |
| 537 | + * | |
| 538 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 539 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 540 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 541 | + * details. | |
| 542 | + * | |
| 543 | + * You should have received a copy of the GNU General Public License along with | |
| 544 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 545 | + */ | |
| 546 | +package com.l2jserver.gameserver.network.serverpackets; | |
| 547 | + | |
| 548 | +import com.l2jserver.gameserver.model.actor.instance.L2FenceInstance; | |
| 549 | + | |
| 550 | +/** | |
| 551 | + * OP: 0xFE<br> | |
| 552 | + * OP2: 0x0003<br> | |
| 553 | + * Format: ddddddd<br> | |
| 554 | + * - d: object id<br> | |
| 555 | + * - d: state(0=hidden, 1=unconnected corners, 2=connected corners)<br> | |
| 556 | + * - d: x<br> | |
| 557 | + * - d: y<br> | |
| 558 | + * - d: z<br> | |
| 559 | + * - d: a side length<br> | |
| 560 | + * - d: b side length<br> | |
| 561 | + */ | |
| 562 | +public class ExColosseumFenceInfo extends L2GameServerPacket | |
| 563 | +{
| |
| 564 | + private final L2FenceInstance _fence; | |
| 565 | + | |
| 566 | + public ExColosseumFenceInfo(L2FenceInstance fence) | |
| 567 | + {
| |
| 568 | + _fence = fence; | |
| 569 | + } | |
| 570 | + | |
| 571 | + /** | |
| 572 | + * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl() | |
| 573 | + */ | |
| 574 | + @Override | |
| 575 | + protected void writeImpl() | |
| 576 | + {
| |
| 577 | + writeC(0xfe); | |
| 578 | + writeH(0x0003); | |
| 579 | + | |
| 580 | + writeD(_fence.getObjectId()); | |
| 581 | + writeD(_fence.getState()); | |
| 582 | + writeD(_fence.getX()); | |
| 583 | + writeD(_fence.getY()); | |
| 584 | + writeD(_fence.getZ()); | |
| 585 | + writeD(_fence.getWidth()); | |
| 586 | + writeD(_fence.getLength()); | |
| 587 | + } | |
| 588 | +} | |
| 589 | \ No newline at end of file |