Various unnecessary code changes.
This commit is contained in:
@@ -77,7 +77,7 @@ public class AdminHtml implements IAdminCommandHandler
|
||||
* @param activeChar activeChar where html is shown
|
||||
* @param path relative path from directory data/html/admin/ to html
|
||||
*/
|
||||
public static void showAdminHtml(L2PcInstance activeChar, String path)
|
||||
static void showAdminHtml(L2PcInstance activeChar, String path)
|
||||
{
|
||||
showHtml(activeChar, "data/html/admin/" + path, false);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class AdminHtml implements IAdminCommandHandler
|
||||
* @param path relative path from Config.DATAPACK_ROOT to html.
|
||||
* @param reload {@code true} will reload html and show it {@code false} will show it from cache.
|
||||
*/
|
||||
public static void showHtml(L2PcInstance activeChar, String path, boolean reload)
|
||||
private static void showHtml(L2PcInstance activeChar, String path, boolean reload)
|
||||
{
|
||||
String content = null;
|
||||
if (!reload)
|
||||
|
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public class AdminQuest implements IAdminCommandHandler
|
||||
{
|
||||
public static final Logger LOGGER = Logger.getLogger(AdminQuest.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(AdminQuest.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.gameserver.util.BuilderUtil;
|
||||
*/
|
||||
public class AdminSummon implements IAdminCommandHandler
|
||||
{
|
||||
public static final String[] ADMIN_COMMANDS =
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_summon"
|
||||
};
|
||||
|
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
*/
|
||||
public final class AdminSuperHaste implements IAdminCommandHandler
|
||||
{
|
||||
public static final String[] ADMIN_COMMANDS =
|
||||
static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_superhaste",
|
||||
"admin_superhaste_menu",
|
||||
|
@@ -53,16 +53,16 @@ public class DropSearchBoard implements IParseBoardHandler
|
||||
"_bbs_npc_trace"
|
||||
};
|
||||
|
||||
class CBDropHolder
|
||||
private class CBDropHolder
|
||||
{
|
||||
int itemId;
|
||||
int npcId;
|
||||
byte npcLevel;
|
||||
long min;
|
||||
long max;
|
||||
double chance;
|
||||
boolean isSpoil;
|
||||
boolean isRaid;
|
||||
final int itemId;
|
||||
final int npcId;
|
||||
final byte npcLevel;
|
||||
final long min;
|
||||
final long max;
|
||||
final double chance;
|
||||
final boolean isSpoil;
|
||||
final boolean isRaid;
|
||||
|
||||
public CBDropHolder(L2NpcTemplate npcTemplate, DropHolder dropHolder)
|
||||
{
|
||||
|
@@ -60,7 +60,7 @@ public final class TriggerSkillByDamage extends AbstractEffect
|
||||
_attackerType = params.getEnum("attackerType", InstanceType.class, InstanceType.L2Character);
|
||||
}
|
||||
|
||||
public void onDamageReceivedEvent(OnCreatureDamageReceived event)
|
||||
private void onDamageReceivedEvent(OnCreatureDamageReceived event)
|
||||
{
|
||||
if (event.isDamageOverTime() || (_chance == 0) || (_skill.getSkillLevel() == 0))
|
||||
{
|
||||
|
@@ -57,7 +57,7 @@ public class PetFood implements IItemHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean useFood(L2Playable activeChar, int skillId, int skillLevel, L2ItemInstance item)
|
||||
private boolean useFood(L2Playable activeChar, int skillId, int skillLevel, L2ItemInstance item)
|
||||
{
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill != null)
|
||||
|
@@ -251,7 +251,7 @@ public class Debug implements ITelnetCommand
|
||||
throw new IllegalStateException("Deadlocked Thread not found");
|
||||
}
|
||||
|
||||
public static String getServerStatus()
|
||||
static String getServerStatus()
|
||||
{
|
||||
int playerCount = 0, objectCount = 0;
|
||||
final int max = LoginServerThread.getInstance().getMaxPlayer();
|
||||
|
@@ -44,11 +44,6 @@ public class AutoPotion implements IVoicedCommandHandler
|
||||
"apoff"
|
||||
};
|
||||
|
||||
public static AutoPotion getInstance()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
|
||||
{
|
||||
|
@@ -80,28 +80,28 @@ public final class Config
|
||||
// --------------------------------------------------
|
||||
// Config File Definitions
|
||||
// --------------------------------------------------
|
||||
public static final String CHARACTER_CONFIG_FILE = "./config/Character.ini";
|
||||
public static final String CH_SIEGE_CONFIG_FILE = "./config/ConquerableHallSiege.ini";
|
||||
public static final String FEATURE_CONFIG_FILE = "./config/Feature.ini";
|
||||
public static final String FLOOD_PROTECTOR_CONFIG_FILE = "./config/FloodProtector.ini";
|
||||
public static final String FORTSIEGE_CONFIG_FILE = "./config/FortSiege.ini";
|
||||
public static final String GENERAL_CONFIG_FILE = "./config/General.ini";
|
||||
public static final String GEOENGINE_CONFIG_FILE = "./config/GeoEngine.ini";
|
||||
public static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini";
|
||||
public static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini";
|
||||
public static final String IDFACTORY_CONFIG_FILE = "./config/IdFactory.ini";
|
||||
public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini";
|
||||
public static final String NPC_CONFIG_FILE = "./config/NPC.ini";
|
||||
public static final String OLYMPIAD_CONFIG_FILE = "./config/Olympiad.ini";
|
||||
public static final String PVP_CONFIG_FILE = "./config/PVP.ini";
|
||||
public static final String RATES_CONFIG_FILE = "./config/Rates.ini";
|
||||
public static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
public static final String SIEGE_CONFIG_FILE = "./config/Siege.ini";
|
||||
public static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
public static final String FORTSIEGE_CONFIG_FILE = "./config/FortSiege.ini";
|
||||
public static final String TW_CONFIG_FILE = "./config/TerritoryWar.ini";
|
||||
public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
public static final String HEXID_FILE = "./config/hexid.txt";
|
||||
public static final String IPCONFIG_FILE = "./config/ipconfig.xml";
|
||||
private static final String CHARACTER_CONFIG_FILE = "./config/Character.ini";
|
||||
private static final String CH_SIEGE_CONFIG_FILE = "./config/ConquerableHallSiege.ini";
|
||||
private static final String FEATURE_CONFIG_FILE = "./config/Feature.ini";
|
||||
private static final String FLOOD_PROTECTOR_CONFIG_FILE = "./config/FloodProtector.ini";
|
||||
private static final String GENERAL_CONFIG_FILE = "./config/General.ini";
|
||||
private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini";
|
||||
private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini";
|
||||
private static final String IDFACTORY_CONFIG_FILE = "./config/IdFactory.ini";
|
||||
private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini";
|
||||
private static final String NPC_CONFIG_FILE = "./config/NPC.ini";
|
||||
private static final String PVP_CONFIG_FILE = "./config/PVP.ini";
|
||||
private static final String RATES_CONFIG_FILE = "./config/Rates.ini";
|
||||
private static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
private static final String HEXID_FILE = "./config/hexid.txt";
|
||||
private static final String IPCONFIG_FILE = "./config/ipconfig.xml";
|
||||
|
||||
// --------------------------------------------------
|
||||
// Custom Config File Definitions
|
||||
|
@@ -37,10 +37,10 @@ import com.l2jmobius.Config;
|
||||
*/
|
||||
public final class ThreadPool
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(ThreadPool.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(ThreadPool.class.getName());
|
||||
|
||||
protected static ScheduledThreadPoolExecutor[] SCHEDULED_POOLS;
|
||||
protected static ThreadPoolExecutor[] INSTANT_POOLS;
|
||||
private static ScheduledThreadPoolExecutor[] SCHEDULED_POOLS;
|
||||
private static ThreadPoolExecutor[] INSTANT_POOLS;
|
||||
private static int THREAD_POOL_RANDOMIZER;
|
||||
|
||||
/**
|
||||
|
@@ -21,9 +21,9 @@ import java.net.UnknownHostException;
|
||||
|
||||
public class IPSubnet
|
||||
{
|
||||
final byte[] _addr;
|
||||
final byte[] _mask;
|
||||
final boolean _isIPv4;
|
||||
private final byte[] _addr;
|
||||
private final byte[] _mask;
|
||||
private final boolean _isIPv4;
|
||||
|
||||
public IPSubnet(String input) throws UnknownHostException, NumberFormatException, ArrayIndexOutOfBoundsException
|
||||
{
|
||||
@@ -47,23 +47,12 @@ public class IPSubnet
|
||||
}
|
||||
}
|
||||
|
||||
public IPSubnet(InetAddress addr, int mask) throws UnknownHostException
|
||||
{
|
||||
_addr = addr.getAddress();
|
||||
_isIPv4 = _addr.length == 4;
|
||||
_mask = getMask(mask, _addr.length);
|
||||
if (!applyMask(_addr))
|
||||
{
|
||||
throw new UnknownHostException(addr + "/" + mask);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getAddress()
|
||||
{
|
||||
return _addr;
|
||||
}
|
||||
|
||||
public boolean applyMask(byte[] addr)
|
||||
private boolean applyMask(byte[] addr)
|
||||
{
|
||||
// V4 vs V4 or V6 vs V6 checks
|
||||
if (_isIPv4 == (addr.length == 4))
|
||||
|
@@ -25,8 +25,8 @@ import java.util.logging.Logger;
|
||||
public class ScrambledKeyPair
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(ScrambledKeyPair.class.getName());
|
||||
public KeyPair _pair;
|
||||
public byte[] _scrambledModulus;
|
||||
private final KeyPair _pair;
|
||||
private final byte[] _scrambledModulus;
|
||||
|
||||
public ScrambledKeyPair(KeyPair pPair)
|
||||
{
|
||||
|
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
*/
|
||||
public class FortUpdater implements Runnable
|
||||
{
|
||||
protected static Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||
private static Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||
private final L2Clan _clan;
|
||||
private final Fort _fort;
|
||||
private int _runCount;
|
||||
|
@@ -489,7 +489,7 @@ public class GameServer
|
||||
INSTANCE = new GameServer();
|
||||
}
|
||||
|
||||
public static void printSection(String s)
|
||||
private static void printSection(String s)
|
||||
{
|
||||
s = "=[ " + s + " ]";
|
||||
while (s.length() < 61)
|
||||
|
@@ -39,9 +39,7 @@ public final class GameTimeController extends Thread
|
||||
public static final int IG_DAYS_PER_DAY = 6;
|
||||
public static final int MILLIS_PER_IG_DAY = (3600000 * 24) / IG_DAYS_PER_DAY;
|
||||
public static final int SECONDS_PER_IG_DAY = MILLIS_PER_IG_DAY / 1000;
|
||||
public static final int MINUTES_PER_IG_DAY = SECONDS_PER_IG_DAY / 60;
|
||||
public static final int TICKS_PER_IG_DAY = SECONDS_PER_IG_DAY * TICKS_PER_SECOND;
|
||||
public static final int TICKS_SUN_STATE_CHANGE = TICKS_PER_IG_DAY / 4;
|
||||
|
||||
private static GameTimeController _instance;
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public final class ItemsAutoDestroy
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
public synchronized void removeItems()
|
||||
private synchronized void removeItems()
|
||||
{
|
||||
if (_items.isEmpty())
|
||||
{
|
||||
|
@@ -62,10 +62,10 @@ public class Shutdown extends Thread
|
||||
|
||||
private int _secondsShut;
|
||||
private int _shutdownMode;
|
||||
public static final int SIGTERM = 0;
|
||||
public static final int GM_SHUTDOWN = 1;
|
||||
public static final int GM_RESTART = 2;
|
||||
public static final int ABORT = 3;
|
||||
private static final int SIGTERM = 0;
|
||||
private static final int GM_SHUTDOWN = 1;
|
||||
private static final int GM_RESTART = 2;
|
||||
private static final int ABORT = 3;
|
||||
private static final String[] MODE_TEXT =
|
||||
{
|
||||
"SIGTERM",
|
||||
|
@@ -39,14 +39,14 @@ public class L2PlayerAI extends L2PlayableAI
|
||||
{
|
||||
private boolean _thinking; // to prevent recursive thinking
|
||||
|
||||
IntentionCommand _nextIntention = null;
|
||||
private IntentionCommand _nextIntention = null;
|
||||
|
||||
public L2PlayerAI(L2PcInstance player)
|
||||
{
|
||||
super(player);
|
||||
}
|
||||
|
||||
void saveNextIntention(CtrlIntention intention, Object arg0, Object arg1)
|
||||
private void saveNextIntention(CtrlIntention intention, Object arg0, Object arg1)
|
||||
{
|
||||
_nextIntention = new IntentionCommand(intention, arg0, arg1);
|
||||
}
|
||||
|
@@ -28,8 +28,8 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
*/
|
||||
public class WarehouseCacheManager
|
||||
{
|
||||
protected final Map<L2PcInstance, Long> _cachedWh = new ConcurrentHashMap<>();
|
||||
protected final long _cacheTime = Config.WAREHOUSE_CACHE_TIME * 60000;
|
||||
final Map<L2PcInstance, Long> _cachedWh = new ConcurrentHashMap<>();
|
||||
final long _cacheTime = Config.WAREHOUSE_CACHE_TIME * 60000;
|
||||
|
||||
protected WarehouseCacheManager()
|
||||
{
|
||||
@@ -46,8 +46,12 @@ public class WarehouseCacheManager
|
||||
_cachedWh.remove(pc);
|
||||
}
|
||||
|
||||
public class CacheScheduler implements Runnable
|
||||
private class CacheScheduler implements Runnable
|
||||
{
|
||||
public CacheScheduler()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
@@ -70,7 +70,7 @@ public class Post
|
||||
insertindb(cp);
|
||||
}
|
||||
|
||||
public void insertindb(CPost cp)
|
||||
private void insertindb(CPost cp)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
|
||||
|
@@ -69,7 +69,7 @@ public class Topic
|
||||
}
|
||||
}
|
||||
|
||||
public void insertindb()
|
||||
private void insertindb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
|
||||
|
@@ -104,7 +104,7 @@ public final class AnnouncementsTable
|
||||
* @param player
|
||||
* @param type
|
||||
*/
|
||||
public void sendAnnouncements(L2PcInstance player, AnnouncementType type)
|
||||
private void sendAnnouncements(L2PcInstance player, AnnouncementType type)
|
||||
{
|
||||
for (IAnnouncement announce : _announcements.values())
|
||||
{
|
||||
|
@@ -595,25 +595,28 @@ public final class BotReportTable
|
||||
}
|
||||
}
|
||||
|
||||
class PunishHolder
|
||||
private class PunishHolder
|
||||
{
|
||||
final Skill _punish;
|
||||
final int _systemMessageId;
|
||||
|
||||
PunishHolder(Skill sk, int sysMsg)
|
||||
public PunishHolder(Skill sk, int sysMsg)
|
||||
{
|
||||
_punish = sk;
|
||||
_systemMessageId = sysMsg;
|
||||
}
|
||||
}
|
||||
|
||||
class ResetPointTask implements Runnable
|
||||
private class ResetPointTask implements Runnable
|
||||
{
|
||||
public ResetPointTask()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
resetPointsAndSchedule();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,10 +21,10 @@ import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
|
||||
public class Item
|
||||
{
|
||||
public int id;
|
||||
public String type;
|
||||
public String name;
|
||||
public StatsSet set;
|
||||
public int currentLevel;
|
||||
public L2Item item;
|
||||
int id;
|
||||
String type;
|
||||
String name;
|
||||
StatsSet set;
|
||||
int currentLevel;
|
||||
L2Item item;
|
||||
}
|
||||
|
@@ -29,15 +29,12 @@ import com.l2jmobius.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.FenceData;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.ABlock;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockComplex;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockComplexDynamic;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockFlat;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockMultilayer;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockMultilayerDynamic;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockNull;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.GeoFormat;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.GeoLocation;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.GeoStructure;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.IBlockDynamic;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.IGeoObject;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
@@ -382,200 +379,6 @@ public class GeoEngine
|
||||
return getHeightNearest(getGeoX(worldX), getGeoY(worldY), worldZ);
|
||||
}
|
||||
|
||||
// GEODATA - DYNAMIC
|
||||
|
||||
/**
|
||||
* Returns calculated NSWE flag byte as a description of {@link IGeoObject}.<br>
|
||||
* The {@link IGeoObject} is defined by boolean 2D array, saying if the object is present on given cell or not.
|
||||
* @param inside : 2D description of {@link IGeoObject}
|
||||
* @return byte[][] : Returns NSWE flags of {@link IGeoObject}.
|
||||
*/
|
||||
public static byte[][] calculateGeoObject(boolean inside[][])
|
||||
{
|
||||
// get dimensions
|
||||
final int width = inside.length;
|
||||
final int height = inside[0].length;
|
||||
|
||||
// create object flags for geodata, according to the geo object 2D description
|
||||
final byte[][] result = new byte[width][height];
|
||||
|
||||
// loop over each cell of the geo object
|
||||
for (int ix = 0; ix < width; ix++)
|
||||
{
|
||||
for (int iy = 0; iy < height; iy++)
|
||||
{
|
||||
if (inside[ix][iy])
|
||||
{
|
||||
// cell is inside geo object, block whole movement (nswe = 0)
|
||||
result[ix][iy] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// cell is outside of geo object, block only movement leading inside geo object
|
||||
|
||||
// set initial value -> no geodata change
|
||||
byte nswe = (byte) 0xFF;
|
||||
|
||||
// perform axial and diagonal checks
|
||||
if (iy < (height - 1))
|
||||
{
|
||||
if (inside[ix][iy + 1])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_S;
|
||||
}
|
||||
}
|
||||
if (iy > 0)
|
||||
{
|
||||
if (inside[ix][iy - 1])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_N;
|
||||
}
|
||||
}
|
||||
if (ix < (width - 1))
|
||||
{
|
||||
if (inside[ix + 1][iy])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_E;
|
||||
}
|
||||
}
|
||||
if (ix > 0)
|
||||
{
|
||||
if (inside[ix - 1][iy])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_W;
|
||||
}
|
||||
}
|
||||
if ((ix < (width - 1)) && (iy < (height - 1)))
|
||||
{
|
||||
if (inside[ix + 1][iy + 1] || inside[ix][iy + 1] || inside[ix + 1][iy])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_SE;
|
||||
}
|
||||
}
|
||||
if ((ix < (width - 1)) && (iy > 0))
|
||||
{
|
||||
if (inside[ix + 1][iy - 1] || inside[ix][iy - 1] || inside[ix + 1][iy])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_NE;
|
||||
}
|
||||
}
|
||||
if ((ix > 0) && (iy < (height - 1)))
|
||||
{
|
||||
if (inside[ix - 1][iy + 1] || inside[ix][iy + 1] || inside[ix - 1][iy])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_SW;
|
||||
}
|
||||
}
|
||||
if ((ix > 0) && (iy > 0))
|
||||
{
|
||||
if (inside[ix - 1][iy - 1] || inside[ix][iy - 1] || inside[ix - 1][iy])
|
||||
{
|
||||
nswe &= ~GeoStructure.CELL_FLAG_NW;
|
||||
}
|
||||
}
|
||||
|
||||
result[ix][iy] = nswe;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add {@link IGeoObject} to the geodata.
|
||||
* @param object : An object using {@link IGeoObject} interface.
|
||||
*/
|
||||
public final void addGeoObject(IGeoObject object)
|
||||
{
|
||||
toggleGeoObject(object, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove {@link IGeoObject} from the geodata.
|
||||
* @param object : An object using {@link IGeoObject} interface.
|
||||
*/
|
||||
public final void removeGeoObject(IGeoObject object)
|
||||
{
|
||||
toggleGeoObject(object, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles an {@link IGeoObject} in the geodata.
|
||||
* @param object : An object using {@link IGeoObject} interface.
|
||||
* @param add : Add/remove object.
|
||||
*/
|
||||
private final void toggleGeoObject(IGeoObject object, boolean add)
|
||||
{
|
||||
// get object geo coordinates and data
|
||||
final int minGX = object.getGeoX();
|
||||
final int minGY = object.getGeoY();
|
||||
final byte[][] geoData = object.getObjectGeoData();
|
||||
|
||||
// get min/max block coordinates
|
||||
int minBX = minGX / GeoStructure.BLOCK_CELLS_X;
|
||||
int maxBX = ((minGX + geoData.length) - 1) / GeoStructure.BLOCK_CELLS_X;
|
||||
int minBY = minGY / GeoStructure.BLOCK_CELLS_Y;
|
||||
int maxBY = ((minGY + geoData[0].length) - 1) / GeoStructure.BLOCK_CELLS_Y;
|
||||
|
||||
// loop over affected blocks in X direction
|
||||
for (int bx = minBX; bx <= maxBX; bx++)
|
||||
{
|
||||
// loop over affected blocks in Y direction
|
||||
for (int by = minBY; by <= maxBY; by++)
|
||||
{
|
||||
ABlock block;
|
||||
|
||||
// conversion to dynamic block must be synchronized to prevent 2 independent threads converting same block
|
||||
synchronized (_blocks)
|
||||
{
|
||||
// get related block
|
||||
block = _blocks[bx][by];
|
||||
|
||||
// check for dynamic block
|
||||
if (!(block instanceof IBlockDynamic))
|
||||
{
|
||||
// null block means no geodata (particular region file is not loaded), no geodata means no geobjects
|
||||
if (block instanceof BlockNull)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// not a dynamic block, convert it
|
||||
if (block instanceof BlockFlat)
|
||||
{
|
||||
// convert flat block to the dynamic complex block
|
||||
block = new BlockComplexDynamic(bx, by, (BlockFlat) block);
|
||||
_blocks[bx][by] = block;
|
||||
}
|
||||
else if (block instanceof BlockComplex)
|
||||
{
|
||||
// convert complex block to the dynamic complex block
|
||||
block = new BlockComplexDynamic(bx, by, (BlockComplex) block);
|
||||
_blocks[bx][by] = block;
|
||||
}
|
||||
else if (block instanceof BlockMultilayer)
|
||||
{
|
||||
// convert multilayer block to the dynamic multilayer block
|
||||
block = new BlockMultilayerDynamic(bx, by, (BlockMultilayer) block);
|
||||
_blocks[bx][by] = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add/remove geo object to/from dynamic block
|
||||
if (add)
|
||||
{
|
||||
((IBlockDynamic) block).addGeoObject(object);
|
||||
}
|
||||
else
|
||||
{
|
||||
((IBlockDynamic) block).removeGeoObject(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PATHFINDING
|
||||
|
||||
/**
|
||||
|
@@ -1,255 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.geoengine.geodata;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Hasha
|
||||
*/
|
||||
public final class BlockComplexDynamic extends BlockComplex implements IBlockDynamic
|
||||
{
|
||||
private final int _bx;
|
||||
private final int _by;
|
||||
private final byte[] _original;
|
||||
private final List<IGeoObject> _objects;
|
||||
|
||||
/**
|
||||
* Creates {@link BlockComplexDynamic}.
|
||||
* @param bx : Block X coordinate.
|
||||
* @param by : Block Y coordinate.
|
||||
* @param block : The original FlatBlock to create a dynamic version from.
|
||||
*/
|
||||
public BlockComplexDynamic(int bx, int by, BlockFlat block)
|
||||
{
|
||||
// load data
|
||||
final byte nswe = block._nswe;
|
||||
final byte heightLow = (byte) (block._height & 0x00FF);
|
||||
final byte heightHigh = (byte) (block._height >> 8);
|
||||
|
||||
// initialize buffer
|
||||
_buffer = new byte[GeoStructure.BLOCK_CELLS * 3];
|
||||
|
||||
// save data
|
||||
for (int i = 0; i < GeoStructure.BLOCK_CELLS; i++)
|
||||
{
|
||||
// set nswe
|
||||
_buffer[i * 3] = nswe;
|
||||
|
||||
// set height
|
||||
_buffer[(i * 3) + 1] = heightLow;
|
||||
_buffer[(i * 3) + 2] = heightHigh;
|
||||
}
|
||||
|
||||
// get block coordinates
|
||||
_bx = bx;
|
||||
_by = by;
|
||||
|
||||
// create copy for dynamic implementation
|
||||
_original = new byte[GeoStructure.BLOCK_CELLS * 3];
|
||||
System.arraycopy(_buffer, 0, _original, 0, GeoStructure.BLOCK_CELLS * 3);
|
||||
|
||||
// create list for geo objects
|
||||
_objects = new LinkedList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link BlockComplexDynamic}.
|
||||
* @param bx : Block X coordinate.
|
||||
* @param by : Block Y coordinate.
|
||||
* @param block : The original ComplexBlock to create a dynamic version from.
|
||||
*/
|
||||
public BlockComplexDynamic(int bx, int by, BlockComplex block)
|
||||
{
|
||||
// move buffer from BlockComplex object to this object
|
||||
_buffer = block._buffer;
|
||||
block._buffer = null;
|
||||
|
||||
// get block coordinates
|
||||
_bx = bx;
|
||||
_by = by;
|
||||
|
||||
// create copy for dynamic implementation
|
||||
_original = new byte[GeoStructure.BLOCK_CELLS * 3];
|
||||
System.arraycopy(_buffer, 0, _original, 0, GeoStructure.BLOCK_CELLS * 3);
|
||||
|
||||
// create list for geo objects
|
||||
_objects = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final short getHeightNearestOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// get cell index
|
||||
final int index = (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)) * 3;
|
||||
|
||||
// get height
|
||||
return (short) ((_original[index + 1] & 0x00FF) | (_original[index + 2] << 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final byte getNsweNearestOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// get cell index
|
||||
final int index = (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)) * 3;
|
||||
|
||||
// get nswe
|
||||
return _original[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getIndexAboveOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// get cell index
|
||||
final int index = (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)) * 3;
|
||||
|
||||
// get height
|
||||
final int height = (_original[index + 1] & 0x00FF) | (_original[index + 2] << 8);
|
||||
|
||||
// check height and return nswe
|
||||
return height > worldZ ? index : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getIndexBelowOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// get cell index
|
||||
final int index = (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)) * 3;
|
||||
|
||||
// get height
|
||||
final int height = (_original[index + 1] & 0x00FF) | (_original[index + 2] << 8);
|
||||
|
||||
// check height and return nswe
|
||||
return height < worldZ ? index : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final short getHeightOriginal(int index)
|
||||
{
|
||||
return (short) ((_original[index + 1] & 0x00FF) | (_original[index + 2] << 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final byte getNsweOriginal(int index)
|
||||
{
|
||||
return _original[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final synchronized void addGeoObject(IGeoObject object)
|
||||
{
|
||||
// add geo object, update block geodata when added
|
||||
if (_objects.add(object))
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final synchronized void removeGeoObject(IGeoObject object)
|
||||
{
|
||||
// remove geo object, update block geodata when removed
|
||||
if (_objects.remove(object))
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private final void update()
|
||||
{
|
||||
// copy original geodata, than apply changes
|
||||
System.arraycopy(_original, 0, _buffer, 0, GeoStructure.BLOCK_CELLS * 3);
|
||||
|
||||
// get block geo coordinates
|
||||
final int minBX = _bx * GeoStructure.BLOCK_CELLS_X;
|
||||
final int minBY = _by * GeoStructure.BLOCK_CELLS_Y;
|
||||
final int maxBX = minBX + GeoStructure.BLOCK_CELLS_X;
|
||||
final int maxBY = minBY + GeoStructure.BLOCK_CELLS_Y;
|
||||
|
||||
// for all objects
|
||||
for (IGeoObject object : _objects)
|
||||
{
|
||||
// get object geo coordinates and other object variables
|
||||
final int minOX = object.getGeoX();
|
||||
final int minOY = object.getGeoY();
|
||||
final int minOZ = object.getGeoZ();
|
||||
final int maxOZ = minOZ + object.getHeight();
|
||||
final byte[][] geoData = object.getObjectGeoData();
|
||||
|
||||
// calculate min/max geo coordinates for iteration (intersection of block and object)
|
||||
final int minGX = Math.max(minBX, minOX);
|
||||
final int minGY = Math.max(minBY, minOY);
|
||||
final int maxGX = Math.min(maxBX, minOX + geoData.length);
|
||||
final int maxGY = Math.min(maxBY, minOY + geoData[0].length);
|
||||
|
||||
// iterate over intersection of block and object
|
||||
for (int gx = minGX; gx < maxGX; gx++)
|
||||
{
|
||||
for (int gy = minGY; gy < maxGY; gy++)
|
||||
{
|
||||
// get object nswe
|
||||
final byte objNswe = geoData[gx - minOX][gy - minOY];
|
||||
|
||||
// object contains no change of data in this cell, continue to next cell
|
||||
if (objNswe == 0xFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get block index of this cell
|
||||
final int ib = (((gx - minBX) * GeoStructure.BLOCK_CELLS_Y) + (gy - minBY)) * 3;
|
||||
|
||||
// compare block data and original data, when height differs -> height was affected by other geo object
|
||||
// -> cell is inside an object -> no need to check/change it anymore (Z is lifted, nswe is 0)
|
||||
// compare is done in raw format (2 bytes) instead of conversion to short
|
||||
if ((_buffer[ib + 1] != _original[ib + 1]) || (_buffer[ib + 2] != _original[ib + 2]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// so far cell is not inside of any object
|
||||
if (objNswe == 0)
|
||||
{
|
||||
// cell is inside of this object -> set nswe to 0 and lift Z up
|
||||
|
||||
// set block nswe
|
||||
_buffer[ib] = 0;
|
||||
|
||||
// set block Z to object height
|
||||
_buffer[ib + 1] = (byte) (maxOZ & 0x00FF);
|
||||
_buffer[ib + 2] = (byte) (maxOZ >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
// cell is outside of this object -> update nswe
|
||||
|
||||
// height different is too high (trying to update another layer), skip
|
||||
short z = getHeight(ib);
|
||||
if (Math.abs(z - minOZ) > GeoStructure.CELL_IGNORE_HEIGHT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// adjust block nswe according to the object nswe
|
||||
_buffer[ib] &= objNswe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,312 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.geoengine.geodata;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Hasha
|
||||
*/
|
||||
public final class BlockMultilayerDynamic extends BlockMultilayer implements IBlockDynamic
|
||||
{
|
||||
private final int _bx;
|
||||
private final int _by;
|
||||
private final byte[] _original;
|
||||
private final List<IGeoObject> _objects;
|
||||
|
||||
/**
|
||||
* Creates {@link BlockMultilayerDynamic}.
|
||||
* @param bx : Block X coordinate.
|
||||
* @param by : Block Y coordinate.
|
||||
* @param block : The original MultilayerBlock to create a dynamic version from.
|
||||
*/
|
||||
public BlockMultilayerDynamic(int bx, int by, BlockMultilayer block)
|
||||
{
|
||||
// move buffer from ComplexBlock object to this object
|
||||
_buffer = block._buffer;
|
||||
block._buffer = null;
|
||||
|
||||
// get block coordinates
|
||||
_bx = bx;
|
||||
_by = by;
|
||||
|
||||
// create copy for dynamic implementation
|
||||
_original = new byte[_buffer.length];
|
||||
System.arraycopy(_buffer, 0, _original, 0, _buffer.length);
|
||||
|
||||
// create list for geo objects
|
||||
_objects = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getHeightNearestOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// get cell index
|
||||
final int index = getIndexNearestOriginal(geoX, geoY, worldZ);
|
||||
|
||||
// get height
|
||||
return (short) ((_original[index + 1] & 0x00FF) | (_original[index + 2] << 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getNsweNearestOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// get cell index
|
||||
final int index = getIndexNearestOriginal(geoX, geoY, worldZ);
|
||||
|
||||
// get nswe
|
||||
return _original[index];
|
||||
}
|
||||
|
||||
private final int getIndexNearestOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// move index to the cell given by coordinates
|
||||
int index = 0;
|
||||
for (int i = 0; i < (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)); i++)
|
||||
{
|
||||
// move index by amount of layers for this cell
|
||||
index += (_original[index] * 3) + 1;
|
||||
}
|
||||
|
||||
// get layers count and shift to first layer data (first from bottom)
|
||||
byte layers = _original[index++];
|
||||
|
||||
// loop though all cell layers, find closest layer
|
||||
int limit = Integer.MAX_VALUE;
|
||||
while (layers-- > 0)
|
||||
{
|
||||
// get layer height
|
||||
final int height = (_original[index + 1] & 0x00FF) | (_original[index + 2] << 8);
|
||||
|
||||
// get Z distance and compare with limit
|
||||
// note: When 2 layers have same distance to worldZ (worldZ is in the middle of them):
|
||||
// > returns bottom layer
|
||||
// >= returns upper layer
|
||||
final int distance = Math.abs(height - worldZ);
|
||||
if (distance > limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// update limit and move to next layer
|
||||
limit = distance;
|
||||
index += 3;
|
||||
}
|
||||
|
||||
// return layer index
|
||||
return index - 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getIndexAboveOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// move index to the cell given by coordinates
|
||||
int index = 0;
|
||||
for (int i = 0; i < (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)); i++)
|
||||
{
|
||||
// move index by amount of layers for this cell
|
||||
index += (_original[index] * 3) + 1;
|
||||
}
|
||||
|
||||
// get layers count and shift to last layer data (first from bottom)
|
||||
byte layers = _original[index++];
|
||||
index += (layers - 1) * 3;
|
||||
|
||||
// loop though all layers, find first layer above worldZ
|
||||
while (layers-- > 0)
|
||||
{
|
||||
// get layer height
|
||||
final int height = (_original[index + 1] & 0x00FF) | (_original[index + 2] << 8);
|
||||
|
||||
// layer height is higher than worldZ, return layer index
|
||||
if (height > worldZ)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
// move index to next layer
|
||||
index -= 3;
|
||||
}
|
||||
|
||||
// none layer found
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getIndexBelowOriginal(int geoX, int geoY, int worldZ)
|
||||
{
|
||||
// move index to the cell given by coordinates
|
||||
int index = 0;
|
||||
for (int i = 0; i < (((geoX % GeoStructure.BLOCK_CELLS_X) * GeoStructure.BLOCK_CELLS_Y) + (geoY % GeoStructure.BLOCK_CELLS_Y)); i++)
|
||||
{
|
||||
// move index by amount of layers for this cell
|
||||
index += (_original[index] * 3) + 1;
|
||||
}
|
||||
|
||||
// get layers count and shift to first layer data (first from top)
|
||||
byte layers = _original[index++];
|
||||
|
||||
// loop though all layers, find first layer below worldZ
|
||||
while (layers-- > 0)
|
||||
{
|
||||
// get layer height
|
||||
final int height = (_original[index + 1] & 0x00FF) | (_original[index + 2] << 8);
|
||||
|
||||
// layer height is lower than worldZ, return layer index
|
||||
if (height < worldZ)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
// move index to next layer
|
||||
index += 3;
|
||||
}
|
||||
|
||||
// none layer found
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getHeightOriginal(int index)
|
||||
{
|
||||
// get height
|
||||
return (short) ((_original[index + 1] & 0x00FF) | (_original[index + 2] << 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getNsweOriginal(int index)
|
||||
{
|
||||
// get nswe
|
||||
return _original[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final synchronized void addGeoObject(IGeoObject object)
|
||||
{
|
||||
// add geo object, update block geodata when added
|
||||
if (_objects.add(object))
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final synchronized void removeGeoObject(IGeoObject object)
|
||||
{
|
||||
// remove geo object, update block geodata when removed
|
||||
if (_objects.remove(object))
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private final void update()
|
||||
{
|
||||
// copy original geodata, than apply changes
|
||||
System.arraycopy(_original, 0, _buffer, 0, _original.length);
|
||||
|
||||
// get block geo coordinates
|
||||
final int minBX = _bx * GeoStructure.BLOCK_CELLS_X;
|
||||
final int minBY = _by * GeoStructure.BLOCK_CELLS_Y;
|
||||
final int maxBX = minBX + GeoStructure.BLOCK_CELLS_X;
|
||||
final int maxBY = minBY + GeoStructure.BLOCK_CELLS_Y;
|
||||
|
||||
// for all objects
|
||||
for (IGeoObject object : _objects)
|
||||
{
|
||||
// get object geo coordinates and other object variables
|
||||
final int minOX = object.getGeoX();
|
||||
final int minOY = object.getGeoY();
|
||||
final int minOZ = object.getGeoZ();
|
||||
final int maxOZ = minOZ + object.getHeight();
|
||||
final byte[][] geoData = object.getObjectGeoData();
|
||||
|
||||
// calculate min/max geo coordinates for iteration (intersection of block and object)
|
||||
final int minGX = Math.max(minBX, minOX);
|
||||
final int minGY = Math.max(minBY, minOY);
|
||||
final int maxGX = Math.min(maxBX, minOX + geoData.length);
|
||||
final int maxGY = Math.min(maxBY, minOY + geoData[0].length);
|
||||
|
||||
// iterate over intersection of block and object
|
||||
for (int gx = minGX; gx < maxGX; gx++)
|
||||
{
|
||||
for (int gy = minGY; gy < maxGY; gy++)
|
||||
{
|
||||
// get object nswe
|
||||
final byte objNswe = geoData[gx - minOX][gy - minOY];
|
||||
|
||||
// object contains no change of data in this cell, continue to next cell
|
||||
if (objNswe == 0xFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get block index of this cell
|
||||
int ib = getIndexNearest(gx, gy, minOZ);
|
||||
|
||||
// compare block data and original data, when height differs -> height was affected by other geo object
|
||||
// -> cell is inside an object -> no need to check/change it anymore (Z is lifted, nswe is 0)
|
||||
// compare is done in raw format (2 bytes) instead of conversion to short
|
||||
if ((_buffer[ib + 1] != _original[ib + 1]) || (_buffer[ib + 2] != _original[ib + 2]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// so far cell is not inside of any object
|
||||
if (objNswe == 0)
|
||||
{
|
||||
// cell is inside of this object -> set nswe to 0 and lift Z up
|
||||
|
||||
// set block nswe
|
||||
_buffer[ib] = 0;
|
||||
|
||||
// calculate object height, limit to next layer
|
||||
int z = maxOZ;
|
||||
int i = getIndexAbove(gx, gy, minOZ);
|
||||
if (i != -1)
|
||||
{
|
||||
int az = getHeight(i);
|
||||
if (az <= maxOZ)
|
||||
{
|
||||
z = az - GeoStructure.CELL_IGNORE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
// set block Z to object height
|
||||
_buffer[ib + 1] = (byte) (z & 0x00FF);
|
||||
_buffer[ib + 2] = (byte) (z >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
// cell is outside of this object -> update nswe
|
||||
|
||||
// height different is too high (trying to update another layer), skip
|
||||
short z = getHeight(ib);
|
||||
if (Math.abs(z - minOZ) > GeoStructure.CELL_IGNORE_HEIGHT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// adjust block nswe according to the object nswe
|
||||
_buffer[ib] &= objNswe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,12 +32,7 @@ public final class GeoStructure
|
||||
public static final byte CELL_FLAG_SW = 1 << 5;
|
||||
public static final byte CELL_FLAG_NE = 1 << 6;
|
||||
public static final byte CELL_FLAG_NW = (byte) (1 << 7);
|
||||
public static final byte CELL_FLAG_S_AND_E = CELL_FLAG_S | CELL_FLAG_E;
|
||||
public static final byte CELL_FLAG_S_AND_W = CELL_FLAG_S | CELL_FLAG_W;
|
||||
public static final byte CELL_FLAG_N_AND_E = CELL_FLAG_N | CELL_FLAG_E;
|
||||
public static final byte CELL_FLAG_N_AND_W = CELL_FLAG_N | CELL_FLAG_W;
|
||||
|
||||
public static final int CELL_SIZE = 16;
|
||||
public static final int CELL_HEIGHT = 8;
|
||||
public static final int CELL_IGNORE_HEIGHT = CELL_HEIGHT * 6;
|
||||
|
||||
@@ -64,8 +59,8 @@ public final class GeoStructure
|
||||
public static final int REGION_CELLS_Y = REGION_BLOCKS_Y * BLOCK_CELLS_Y;
|
||||
|
||||
// global geodata
|
||||
public static final int GEO_REGIONS_X = ((L2World.TILE_X_MAX - L2World.TILE_X_MIN) + 1);
|
||||
public static final int GEO_REGIONS_Y = ((L2World.TILE_Y_MAX - L2World.TILE_Y_MIN) + 1);
|
||||
private static final int GEO_REGIONS_X = ((L2World.TILE_X_MAX - L2World.TILE_X_MIN) + 1);
|
||||
private static final int GEO_REGIONS_Y = ((L2World.TILE_Y_MAX - L2World.TILE_Y_MIN) + 1);
|
||||
|
||||
public static final int GEO_BLOCKS_X = GEO_REGIONS_X * REGION_BLOCKS_X;
|
||||
public static final int GEO_BLOCKS_Y = GEO_REGIONS_Y * REGION_BLOCKS_Y;
|
||||
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.geoengine.geodata;
|
||||
|
||||
/**
|
||||
* @author Hasha
|
||||
*/
|
||||
public interface IBlockDynamic
|
||||
{
|
||||
/**
|
||||
* Adds {@link IGeoObject} to the {@link ABlock}. The block will update geodata according the object.
|
||||
* @param object : {@link IGeoObject} to be added.
|
||||
*/
|
||||
void addGeoObject(IGeoObject object);
|
||||
|
||||
/**
|
||||
* Removes {@link IGeoObject} from the {@link ABlock}. The block will update geodata according the object.
|
||||
* @param object : {@link IGeoObject} to be removed.
|
||||
*/
|
||||
void removeGeoObject(IGeoObject object);
|
||||
}
|
@@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
*/
|
||||
public final class QuestManager
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(QuestManager.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(QuestManager.class.getName());
|
||||
|
||||
/** Map containing all the quests. */
|
||||
private final Map<String, Quest> _quests = new ConcurrentHashMap<>();
|
||||
|
@@ -157,26 +157,6 @@ public class TradeList
|
||||
return new TradeItem(item, item.getCount(), item.getReferencePrice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust ItemRequest by corresponding item in this list using its <b>ObjectId</b>
|
||||
* @param item : ItemRequest to be adjusted
|
||||
*/
|
||||
public void adjustItemRequest(ItemRequest item)
|
||||
{
|
||||
for (TradeItem filtItem : _items)
|
||||
{
|
||||
if (filtItem.getObjectId() == item.getObjectId())
|
||||
{
|
||||
if (filtItem.getCount() < item.getCount())
|
||||
{
|
||||
item.setCount(filtItem.getCount());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
item.setCount(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add simplified item to TradeList
|
||||
* @param objectId : int
|
||||
@@ -312,7 +292,7 @@ public class TradeList
|
||||
* @param count : int
|
||||
* @return
|
||||
*/
|
||||
public synchronized TradeItem removeItem(int objectId, int itemId, long count)
|
||||
private synchronized TradeItem removeItem(int objectId, int itemId, long count)
|
||||
{
|
||||
if (_locked)
|
||||
{
|
||||
@@ -456,7 +436,7 @@ public class TradeList
|
||||
/**
|
||||
* Cancels TradeList confirmation
|
||||
*/
|
||||
public void invalidateConfirmation()
|
||||
private void invalidateConfirmation()
|
||||
{
|
||||
_confirmed = false;
|
||||
}
|
||||
@@ -542,7 +522,7 @@ public class TradeList
|
||||
* @param partner
|
||||
* @return items slots count
|
||||
*/
|
||||
public int countItemsSlots(L2PcInstance partner)
|
||||
private int countItemsSlots(L2PcInstance partner)
|
||||
{
|
||||
int slots = 0;
|
||||
|
||||
@@ -573,7 +553,7 @@ public class TradeList
|
||||
/**
|
||||
* @return the weight of items in tradeList
|
||||
*/
|
||||
public int calcItemsWeight()
|
||||
private int calcItemsWeight()
|
||||
{
|
||||
long weight = 0;
|
||||
|
||||
|
@@ -40,12 +40,11 @@ public abstract class VoteSystem implements Runnable
|
||||
|
||||
private static List<VoteSystem> voteSystems = new ArrayList<>();
|
||||
|
||||
protected int votesDiff;
|
||||
protected boolean allowReport;
|
||||
protected int boxes;
|
||||
protected Map<Integer, Integer> rewards;
|
||||
protected int checkMins;
|
||||
protected int lastVotes = 0;
|
||||
private final int votesDiff;
|
||||
private final boolean allowReport;
|
||||
private final int boxes;
|
||||
private final Map<Integer, Integer> rewards;
|
||||
private int lastVotes = 0;
|
||||
private final Map<String, Integer> playerIps = new HashMap<>();
|
||||
|
||||
public static void initialize()
|
||||
@@ -87,26 +86,12 @@ public abstract class VoteSystem implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
public static VoteSystem getVoteSystem(String name)
|
||||
{
|
||||
for (VoteSystem vs : voteSystems)
|
||||
{
|
||||
if (vs.getSiteName().equals(name))
|
||||
{
|
||||
return vs;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public VoteSystem(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
|
||||
{
|
||||
this.votesDiff = votesDiff;
|
||||
this.allowReport = allowReport;
|
||||
this.boxes = boxes;
|
||||
this.rewards = rewards;
|
||||
this.checkMins = checkMins;
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(this, checkMins * 1000 * 60, checkMins * 1000 * 60);
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.zone.L2ZoneForm;
|
||||
public class ZoneCuboid extends L2ZoneForm
|
||||
{
|
||||
private final int _z1, _z2;
|
||||
Rectangle _r;
|
||||
private final Rectangle _r;
|
||||
|
||||
public ZoneCuboid(int x1, int x2, int y1, int y2, int z1, int z2)
|
||||
{
|
||||
|
@@ -23,26 +23,21 @@ import com.l2jmobius.commons.network.BaseSendablePacket;
|
||||
*/
|
||||
public class TempBan extends BaseSendablePacket
|
||||
{
|
||||
public TempBan(String accountName, String ip, long time, String reason)
|
||||
public TempBan(String accountName, String ip, long time)
|
||||
{
|
||||
writeC(0x0A);
|
||||
writeS(accountName);
|
||||
writeS(ip);
|
||||
writeQ(System.currentTimeMillis() + (time * 60000));
|
||||
if (reason != null)
|
||||
{
|
||||
writeC(0x01);
|
||||
writeS(reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeC(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
public TempBan(String accountName, String ip, long time)
|
||||
{
|
||||
this(accountName, ip, time, null);
|
||||
// if (reason != null)
|
||||
// {
|
||||
// writeC(0x01);
|
||||
// writeS(reason);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
writeC(0x00);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -52,7 +52,7 @@ public class TelnetServer
|
||||
}
|
||||
}
|
||||
|
||||
public void init()
|
||||
private void init()
|
||||
{
|
||||
addHandler(new ITelnetCommand()
|
||||
{
|
||||
|
@@ -55,12 +55,12 @@ import com.l2jmobius.gameserver.taskmanager.tasks.TaskShutdown;
|
||||
*/
|
||||
public final class TaskManager
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(TaskManager.class.getName());
|
||||
static final Logger LOGGER = Logger.getLogger(TaskManager.class.getName());
|
||||
|
||||
private final Map<Integer, Task> _tasks = new ConcurrentHashMap<>();
|
||||
protected final List<ExecutedTask> _currentTasks = new CopyOnWriteArrayList<>();
|
||||
final List<ExecutedTask> _currentTasks = new CopyOnWriteArrayList<>();
|
||||
|
||||
protected static final String[] SQL_STATEMENTS =
|
||||
static final String[] SQL_STATEMENTS =
|
||||
{
|
||||
"SELECT id,task,type,last_activation,param1,param2,param3 FROM global_tasks",
|
||||
"UPDATE global_tasks SET last_activation=? WHERE id=?",
|
||||
@@ -78,13 +78,13 @@ public final class TaskManager
|
||||
public class ExecutedTask implements Runnable
|
||||
{
|
||||
int id;
|
||||
long lastActivation;
|
||||
Task task;
|
||||
TaskTypes type;
|
||||
String[] params;
|
||||
private long lastActivation;
|
||||
private final Task task;
|
||||
private final TaskTypes type;
|
||||
private final String[] params;
|
||||
ScheduledFuture<?> scheduled;
|
||||
|
||||
public ExecutedTask(Task ptask, TaskTypes ptype, ResultSet rset) throws SQLException
|
||||
ExecutedTask(Task ptask, TaskTypes ptype, ResultSet rset) throws SQLException
|
||||
{
|
||||
task = ptask;
|
||||
type = ptype;
|
||||
@@ -158,7 +158,7 @@ public final class TaskManager
|
||||
return lastActivation;
|
||||
}
|
||||
|
||||
public void stopTask()
|
||||
private void stopTask()
|
||||
{
|
||||
task.onDestroy();
|
||||
|
||||
@@ -187,7 +187,7 @@ public final class TaskManager
|
||||
registerTask(new TaskShutdown());
|
||||
}
|
||||
|
||||
public void registerTask(Task task)
|
||||
private void registerTask(Task task)
|
||||
{
|
||||
_tasks.computeIfAbsent(task.getName().hashCode(), k ->
|
||||
{
|
||||
@@ -328,7 +328,7 @@ public final class TaskManager
|
||||
return addUniqueTask(task, type, param1, param2, param3, 0);
|
||||
}
|
||||
|
||||
public static boolean addUniqueTask(String task, TaskTypes type, String param1, String param2, String param3, long lastActivation)
|
||||
private static boolean addUniqueTask(String task, TaskTypes type, String param1, String param2, String param3, long lastActivation)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(SQL_STATEMENTS[2]))
|
||||
@@ -364,7 +364,7 @@ public final class TaskManager
|
||||
return addTask(task, type, param1, param2, param3, 0);
|
||||
}
|
||||
|
||||
public static boolean addTask(String task, TaskTypes type, String param1, String param2, String param3, long lastActivation)
|
||||
private static boolean addTask(String task, TaskTypes type, String param1, String param2, String param3, long lastActivation)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(SQL_STATEMENTS[3]))
|
||||
|
@@ -24,7 +24,7 @@ import com.l2jmobius.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
*/
|
||||
public final class TaskCleanUp extends Task
|
||||
{
|
||||
public static final String NAME = "clean_up";
|
||||
private static final String NAME = "clean_up";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
|
@@ -25,7 +25,7 @@ import com.l2jmobius.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
*/
|
||||
public final class TaskRestart extends Task
|
||||
{
|
||||
public static final String NAME = "restart";
|
||||
private static final String NAME = "restart";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
|
@@ -25,7 +25,7 @@ import com.l2jmobius.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
*/
|
||||
public class TaskShutdown extends Task
|
||||
{
|
||||
public static final String NAME = "shutdown";
|
||||
private static final String NAME = "shutdown";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
|
@@ -39,8 +39,8 @@ import com.l2jmobius.Config;
|
||||
public class frmAbout
|
||||
{
|
||||
private JFrame frmAbout;
|
||||
static final String URL = "www.l2jmobius.com";
|
||||
URI uri;
|
||||
private static final String URL = "www.l2jmobius.com";
|
||||
final URI uri;
|
||||
|
||||
public frmAbout()
|
||||
{
|
||||
@@ -129,7 +129,7 @@ public class frmAbout
|
||||
frmAbout.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
public static URI createURI(String str)
|
||||
private static URI createURI(String str)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -13,7 +13,6 @@ package com.l2jmobius.gameserver.util;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
@@ -32,16 +31,6 @@ public class TimeAmountInterpreter
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #consolidate(long, TimeUnit)} with {@link TimeUnit#NANOSECONDS}.
|
||||
* @param timeAmountInNanos amount of time in nanoseconds
|
||||
* @return an user-friendly description of the given time amount
|
||||
*/
|
||||
public static String consolidateNanos(long timeAmountInNanos)
|
||||
{
|
||||
return consolidate(timeAmountInNanos, NANOSECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #consolidate(long, TimeUnit)} with {@link TimeUnit#MILLISECONDS}.
|
||||
* @param timeAmountInMillis amount of time in milliseconds
|
||||
@@ -58,7 +47,7 @@ public class TimeAmountInterpreter
|
||||
* @param timeUnit unit of the given amount
|
||||
* @return an user-friendly description of the given time amount
|
||||
*/
|
||||
public static String consolidate(long timeAmount, TimeUnit timeUnit)
|
||||
private static String consolidate(long timeAmount, TimeUnit timeUnit)
|
||||
{
|
||||
return consolidate(timeAmount, timeUnit, timeUnit, DAYS, "0 " + timeUnit.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
@@ -92,7 +81,7 @@ public class TimeAmountInterpreter
|
||||
* @throws RuntimeException if {@code textBuilder} throws an {@link IOException}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Appendable & CharSequence> T appendConsolidated(T textBuilder, long timeAmount, TimeUnit timeUnit, TimeUnit minConsolidationUnit, TimeUnit maxConsolidationUnit, String noTimeUsedIndicator) throws RuntimeException
|
||||
private static <T extends Appendable & CharSequence> T appendConsolidated(T textBuilder, long timeAmount, TimeUnit timeUnit, TimeUnit minConsolidationUnit, TimeUnit maxConsolidationUnit, String noTimeUsedIndicator) throws RuntimeException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -37,8 +37,8 @@ import javax.swing.WindowConstants;
|
||||
public class frmAbout
|
||||
{
|
||||
private JFrame frmAbout;
|
||||
static final String URL = "www.l2jmobius.com";
|
||||
URI uri;
|
||||
private static final String URL = "www.l2jmobius.com";
|
||||
final URI uri;
|
||||
|
||||
public frmAbout()
|
||||
{
|
||||
@@ -101,7 +101,7 @@ public class frmAbout
|
||||
frmAbout.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
public static URI createURI(String str)
|
||||
private static URI createURI(String str)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user