Respawn rework and various changes.

This commit is contained in:
MobiusDev
2018-03-31 16:36:49 +00:00
parent 41e19cc19e
commit 10b722829a
282 changed files with 866 additions and 1807 deletions
@@ -37,7 +37,7 @@ import ai.AbstractNpcAI;
*/ */
public final class SelMahumSquad extends AbstractNpcAI public final class SelMahumSquad extends AbstractNpcAI
{ {
// NPC's // NPCs
private static final int CHEF = 18908; private static final int CHEF = 18908;
private static final int FIRE = 18927; private static final int FIRE = 18927;
private static final int STOVE = 18933; private static final int STOVE = 18933;
@@ -32,7 +32,7 @@ import ai.AbstractNpcAI;
*/ */
public final class ClassTransferTalk extends AbstractNpcAI public final class ClassTransferTalk extends AbstractNpcAI
{ {
// NPC's // NPCs
// Talking Island Village (Administrative office) // Talking Island Village (Administrative office)
private static final int FRANCO = 32153; private static final int FRANCO = 32153;
private static final int RIVIAN = 32147; private static final int RIVIAN = 32147;
@@ -85,7 +85,7 @@ public final class Elpies extends Event
return false; return false;
} }
// Check Custom Table - we use custom NPC's // Check Custom Table - we use custom NPCs
if (!Config.CUSTOM_NPC_DATA) if (!Config.CUSTOM_NPC_DATA)
{ {
_log.info(getName() + ": Event can't be started because custom NPC table is disabled!"); _log.info(getName() + ": Event can't be started because custom NPC table is disabled!");
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
*/ */
public final class Race extends Event public final class Race extends Event
{ {
// Event NPC's list // Event NPCs list
private List<L2Npc> _npclist; private List<L2Npc> _npclist;
// Npc // Npc
private L2Npc _npc; private L2Npc _npc;
@@ -56,7 +56,7 @@ public final class Race extends Event
private static final int _time_register = 5; private static final int _time_register = 5;
// 5 min for race // 5 min for race
private static final int _time_race = 10; private static final int _time_race = 10;
// NPC's // NPCs
private static final int _start_npc = 900103; private static final int _start_npc = 900103;
private static final int _stop_npc = 900104; private static final int _stop_npc = 900104;
// Skills (Frog by default) // Skills (Frog by default)
@@ -118,7 +118,7 @@ public final class Race extends Event
{ {
return false; return false;
} }
// Check Custom Table - we use custom NPC's // Check Custom Table - we use custom NPCs
if (!Config.CUSTOM_NPC_DATA) if (!Config.CUSTOM_NPC_DATA)
{ {
_log.info(getName() + ": Event can't be started, because custom npc table is disabled!"); _log.info(getName() + ": Event can't be started, because custom npc table is disabled!");
@@ -128,8 +128,6 @@ public class AdminEffects implements IAdminCommandHandler
activeChar.setInvisible(true); activeChar.setInvisible(true);
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar)); activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar));
activeChar.decayMe();
activeChar.spawnMe();
activeChar.sendMessage("You are now invisible."); activeChar.sendMessage("You are now invisible.");
} }
else else
@@ -149,8 +147,6 @@ public class AdminEffects implements IAdminCommandHandler
activeChar.setInvisible(true); activeChar.setInvisible(true);
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar)); activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar));
activeChar.decayMe();
activeChar.spawnMe();
activeChar.sendMessage("You are now invisible."); activeChar.sendMessage("You are now invisible.");
} }
else if (command.startsWith("admin_vis")) else if (command.startsWith("admin_vis"))
@@ -401,8 +397,6 @@ public class AdminEffects implements IAdminCommandHandler
else if (command.startsWith("admin_unpolyself")) else if (command.startsWith("admin_unpolyself"))
{ {
activeChar.getPoly().setPolyInfo(null, "1"); activeChar.getPoly().setPolyInfo(null, "1");
activeChar.decayMe();
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
} }
else if (command.equals("admin_clearteams")) else if (command.equals("admin_clearteams"))
@@ -167,8 +167,7 @@ public class AdminPolymorph implements IAdminCommandHandler
Char.sendPacket(sg); Char.sendPacket(sg);
} }
// end of animation // end of animation
obj.decayMe(); obj.broadcastInfo();
obj.spawnMe(obj.getX(), obj.getY(), obj.getZ());
activeChar.sendMessage("Polymorph succeed"); activeChar.sendMessage("Polymorph succeed");
} }
else else
@@ -187,8 +186,7 @@ public class AdminPolymorph implements IAdminCommandHandler
if (target != null) if (target != null)
{ {
target.getPoly().setPolyInfo(null, "1"); target.getPoly().setPolyInfo(null, "1");
target.decayMe(); target.broadcastInfo();
target.spawnMe(target.getX(), target.getY(), target.getZ());
activeChar.sendMessage("Unpolymorph succeed"); activeChar.sendMessage("Unpolymorph succeed");
} }
else else
@@ -504,7 +504,7 @@ public class AdminSpawn implements IAdminCommandHandler
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level); final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level);
final int mobsCount = mobs.size(); final int mobsCount = mobs.size();
final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80)); final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80));
tb.append("<html><title>Spawn Monster:</title><body><p> Level : " + level + "<br>Total Npc's : " + mobsCount + "<br>"); tb.append("<html><title>Spawn Monster:</title><body><p> Level : " + level + "<br>Total NPCs : " + mobsCount + "<br>");
// Loop // Loop
int i = from; int i = from;
@@ -350,7 +350,7 @@ public final class Kamaloka extends AbstractInstance
*/ */
private static final int TELEPORTER = 32496; private static final int TELEPORTER = 32496;
/** Kamaloka captains (start npc's) npcIds. */ /** Kamaloka captains (start NPCs) npcIds. */
private static final int[] CAPTAINS = private static final int[] CAPTAINS =
{ {
30332, 30332,
@@ -47,7 +47,7 @@ import quests.Q10331_StartOfFate.Q10331_StartOfFate;
*/ */
public final class LabyrinthOfBelis extends AbstractInstance public final class LabyrinthOfBelis extends AbstractInstance
{ {
// NPC's // NPCs
private static final int SEBION = 32972; private static final int SEBION = 32972;
private static final int INFILTRATION_OFFICER = 19155; private static final int INFILTRATION_OFFICER = 19155;
private static final int BELIS_VERITIFICATION_SYSTEM = 33215; private static final int BELIS_VERITIFICATION_SYSTEM = 33215;
@@ -30,7 +30,7 @@ import quests.Q00184_ArtOfPersuasion.Q00184_ArtOfPersuasion;
*/ */
public final class Q00185_NikolasCooperation extends Quest public final class Q00185_NikolasCooperation extends Quest
{ {
// NPC's // NPCs
private static final int MAESTRO_NIKOLA = 30621; private static final int MAESTRO_NIKOLA = 30621;
private static final int RESEARCHER_LORAIN = 30673; private static final int RESEARCHER_LORAIN = 30673;
private static final int DESTROYED_DEVICE = 32366; private static final int DESTROYED_DEVICE = 32366;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public class Q00776_SlayDarkLordEkimus extends Quest public class Q00776_SlayDarkLordEkimus extends Quest
{ {
// NPC's // NPCs
private static final int TEPIOS = 32603; private static final int TEPIOS = 32603;
// Boss // Boss
private static final int EKIMUS = 29150; private static final int EKIMUS = 29150;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public class Q00777_SlayDarkLordTiat extends Quest public class Q00777_SlayDarkLordTiat extends Quest
{ {
// NPC's // NPCs
private static final int ALLENOS = 32526; private static final int ALLENOS = 32526;
// Boss // Boss
private static final int TIAT = 29163; private static final int TIAT = 29163;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public final class Q10353_CertificationOfValue extends Quest public final class Q10353_CertificationOfValue extends Quest
{ {
// Npc's // NPCs
public static final int RIEYI = 33155; public static final int RIEYI = 33155;
public static final int KYUORI = 33358; public static final int KYUORI = 33358;
private static final int DUMMY_MONSTER = 33349; private static final int DUMMY_MONSTER = 33349;
@@ -33,7 +33,7 @@ import com.l2jmobius.gameserver.util.Util;
*/ */
public final class Q10378_WeedingWork extends Quest public final class Q10378_WeedingWork extends Quest
{ {
// NPC's // NPCs
private static final int DADFPHYNA = 33697; private static final int DADFPHYNA = 33697;
// Monster's // Monster's
private static final int MANDRAGORA_OF_JOY_AND_SORROW = 23210; private static final int MANDRAGORA_OF_JOY_AND_SORROW = 23210;
@@ -36,7 +36,7 @@ import quests.Q10379_AnUninvitedGuest.Q10379_AnUninvitedGuest;
*/ */
public final class Q10380_TheExecutionersExecution extends Quest public final class Q10380_TheExecutionersExecution extends Quest
{ {
// NPC's // NPCs
private static final int ENDRIGO = 30632; private static final int ENDRIGO = 30632;
private static final int GUILLOTINE_OF_DEATH = 25892; private static final int GUILLOTINE_OF_DEATH = 25892;
private static final int NAGDU_THE_DEFORMED = 23201; private static final int NAGDU_THE_DEFORMED = 23201;
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.quest.QuestState;
*/ */
public final class Q10452_IsItEdible extends Quest public final class Q10452_IsItEdible extends Quest
{ {
// Npc's // NPCs
private static final int SALLY = 32743; private static final int SALLY = 32743;
// Monster's // Monster's
private static final int FANTASY_MUSHROM = 18864; private static final int FANTASY_MUSHROM = 18864;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.network.serverpackets.TutorialShowHtml;
*/ */
public final class Q10732_AForeignLand extends Quest public final class Q10732_AForeignLand extends Quest
{ {
// NPC's // NPCs
private static final int NAVARI = 33931; private static final int NAVARI = 33931;
private static final int GERETH = 33932; private static final int GERETH = 33932;
// Misc // Misc
@@ -30,7 +30,7 @@ import quests.Q10732_AForeignLand.Q10732_AForeignLand;
*/ */
public final class Q10733_TheTestForSurvival extends Quest public final class Q10733_TheTestForSurvival extends Quest
{ {
// NPC's // NPCs
private static final int GERETH = 33932; private static final int GERETH = 33932;
private static final int DIA = 34005; private static final int DIA = 34005;
private static final int KATALIN = 33943; private static final int KATALIN = 33943;
@@ -35,7 +35,7 @@ import quests.Q10733_TheTestForSurvival.Q10733_TheTestForSurvival;
*/ */
public final class Q10734_DoOrDie extends Quest public final class Q10734_DoOrDie extends Quest
{ {
// NPC's // NPCs
private static final int KATALIN = 33943; private static final int KATALIN = 33943;
private static final int AYANTHE = 33942; private static final int AYANTHE = 33942;
private static final int ADVENTURER_S_GUIDE_APPRENTICE = 33950; private static final int ADVENTURER_S_GUIDE_APPRENTICE = 33950;
@@ -35,7 +35,7 @@ import quests.Q10736_ASpecialPower.Q10736_ASpecialPower;
*/ */
public final class Q10737_GrakonsWarehouse extends Quest public final class Q10737_GrakonsWarehouse extends Quest
{ {
// NPC's // NPCs
private static final int KATALIN = 33943; private static final int KATALIN = 33943;
private static final int AYANTHE = 33942; private static final int AYANTHE = 33942;
private static final int GRAKON = 33947; private static final int GRAKON = 33947;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public final class Q10741_ADraughtForTheCold extends Quest public final class Q10741_ADraughtForTheCold extends Quest
{ {
// NPC's // NPCs
private static final int SIVANTHE = 33951; private static final int SIVANTHE = 33951;
private static final int LEIRA = 33952; private static final int LEIRA = 33952;
// Items // Items
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
*/ */
public final class Q10745_TheSecretIngredients extends Quest public final class Q10745_TheSecretIngredients extends Quest
{ {
// Npc's // NPCs
private static final int DOLKIN = 33954; private static final int DOLKIN = 33954;
private static final int KARLA = 33933; private static final int KARLA = 33933;
private static final int DOLKIN_INSTANCE = 34002; private static final int DOLKIN_INSTANCE = 34002;
@@ -761,9 +761,11 @@ public class L2CharacterAI extends AbstractAI
// Stop an AI Follow Task // Stop an AI Follow Task
stopFollow(); stopFollow();
} }
// Stop any intention that has target we want to forget. // Stop any intention that has target we want to forget.
setIntention(AI_INTENTION_ACTIVE); if (getIntention() != AI_INTENTION_MOVE_TO)
{
setIntention(AI_INTENTION_ACTIVE);
}
} }
// Check if the targeted object was the actor // Check if the targeted object was the actor
@@ -235,7 +235,7 @@ public class ItemTable
} }
// Add the L2ItemInstance object to _allObjects of L2world // Add the L2ItemInstance object to _allObjects of L2world
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// Set Item parameters // Set Item parameters
if (item.isStackable() && (count > 1)) if (item.isStackable() && (count > 1))
@@ -103,7 +103,7 @@ public final class ItemsOnGroundManager implements Runnable
while (rs.next()) while (rs.next())
{ {
item = new L2ItemInstance(rs.getInt(1), rs.getInt(2)); item = new L2ItemInstance(rs.getInt(1), rs.getInt(2));
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// this check and.. // this check and..
if (item.isStackable() && (rs.getInt(3) > 1)) if (item.isStackable() && (rs.getInt(3) > 1))
{ {
@@ -80,7 +80,7 @@ public final class SiegeGuardManager
final L2ItemInstance dropticket = new L2ItemInstance(holder.getItemId()); final L2ItemInstance dropticket = new L2ItemInstance(holder.getItemId());
dropticket.setItemLocation(ItemLocation.VOID); dropticket.setItemLocation(ItemLocation.VOID);
dropticket.dropMe(null, x, y, z); dropticket.dropMe(null, x, y, z);
L2World.getInstance().storeObject(dropticket); L2World.getInstance().addObject(dropticket);
_droppedTickets.add(dropticket); _droppedTickets.add(dropticket);
} }
} }
@@ -180,7 +180,7 @@ public final class SiegeGuardManager
final L2ItemInstance dropticket = new L2ItemInstance(itemId); final L2ItemInstance dropticket = new L2ItemInstance(itemId);
dropticket.setItemLocation(ItemLocation.VOID); dropticket.setItemLocation(ItemLocation.VOID);
dropticket.dropMe(null, player.getX(), player.getY(), player.getZ()); dropticket.dropMe(null, player.getX(), player.getY(), player.getZ());
L2World.getInstance().storeObject(dropticket); L2World.getInstance().addObject(dropticket);
_droppedTickets.add(dropticket); _droppedTickets.add(dropticket);
} }
} }
@@ -760,7 +760,15 @@ public final class ZoneManager implements IGameXmlReader
public ZoneRegion getRegion(int x, int y) public ZoneRegion getRegion(int x, int y)
{ {
return _zoneRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y]; try
{
return _zoneRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y];
}
catch (ArrayIndexOutOfBoundsException e)
{
// LOGGER.warning(getClass().getSimpleName() + ": Incorrect zone region X: " + ((x >> SHIFT_BY) + OFFSET_X) + " Y: " + ((y >> SHIFT_BY) + OFFSET_Y) + " for coordinates x: " + x + " y: " + y);
return null;
}
} }
public ZoneRegion getRegion(ILocational point) public ZoneRegion getRegion(ILocational point)
@@ -196,7 +196,6 @@ public class CursedWeapon implements INamable
else if (_item != null) else if (_item != null)
{ {
_item.decayMe(); _item.decayMe();
L2World.getInstance().removeObject(_item);
_log.info(_name + " item has been removed from World."); _log.info(_name + " item has been removed from World.");
} }
} }
@@ -177,7 +177,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
setWorldRegion(L2World.getInstance().getRegion(getLocation())); setWorldRegion(L2World.getInstance().getRegion(getLocation()));
// Add the L2Object spawn in the _allobjects of L2World // Add the L2Object spawn in the _allobjects of L2World
L2World.getInstance().storeObject(this); L2World.getInstance().addObject(this);
// Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
getWorldRegion().addVisibleObject(this); getWorldRegion().addVisibleObject(this);
@@ -519,19 +519,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
} }
protected void badCoords()
{
if (isCharacter())
{
decayMe();
}
else if (isPlayer())
{
((L2Character) this).teleToLocation(new Location(0, 0, 0), false);
((L2Character) this).sendMessage("Error with your coords, Please ask a GM for help!");
}
}
public final void setXYZInvisible(int x, int y, int z) public final void setXYZInvisible(int x, int y, int z)
{ {
if (x > L2World.MAP_MAX_X) if (x > L2World.MAP_MAX_X)
@@ -691,28 +678,21 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
setY(newY); setY(newY);
setZ(newZ); setZ(newZ);
try if (_isSpawned)
{ {
if (_isSpawned) final L2WorldRegion oldRegion = getWorldRegion();
final L2WorldRegion newRegion = L2World.getInstance().getRegion(this);
if (newRegion != oldRegion)
{ {
final L2WorldRegion oldRegion = getWorldRegion(); if (oldRegion != null)
final L2WorldRegion newRegion = L2World.getInstance().getRegion(this);
if (newRegion != oldRegion)
{ {
if (oldRegion != null) oldRegion.removeVisibleObject(this);
{
oldRegion.removeVisibleObject(this);
}
newRegion.addVisibleObject(this);
L2World.getInstance().switchRegion(this, newRegion);
setWorldRegion(newRegion);
} }
newRegion.addVisibleObject(this);
L2World.getInstance().switchRegion(this, newRegion);
setWorldRegion(newRegion);
} }
} }
catch (Exception e)
{
badCoords();
}
} }
/** /**
@@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable; import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.INamable;
@@ -81,11 +80,8 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
/** The task launching the function doSpawn() */ /** The task launching the function doSpawn() */
class SpawnTask implements Runnable class SpawnTask implements Runnable
{ {
private final L2Npc _oldNpc; public SpawnTask()
public SpawnTask(L2Npc pOldNpc)
{ {
_oldNpc = pOldNpc;
} }
@Override @Override
@@ -93,8 +89,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
{ {
try try
{ {
// doSpawn(); doSpawn();
respawnNpc(_oldNpc);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -401,8 +396,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
_scheduledCount++; _scheduledCount++;
// Create a new SpawnTask to launch after the respawn Delay // Create a new SpawnTask to launch after the respawn Delay
// ClientScheduler.getInstance().scheduleLow(new SpawnTask(npcId), _respawnDelay); ThreadPoolManager.schedule(new SpawnTask(), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
ThreadPoolManager.schedule(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
} }
} }
@@ -489,7 +483,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
if (_template.isType("L2Pet") || _template.isType("L2Decoy") || _template.isType("L2Trap")) if (_template.isType("L2Pet") || _template.isType("L2Decoy") || _template.isType("L2Trap"))
{ {
_currentCount++; _currentCount++;
return null; return null;
} }
@@ -558,7 +551,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
} }
// DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings
// don't correct z of flying npc's // don't correct z of flying NPCs
// if (!npc.isFlying()) // if (!npc.isFlying())
// { // {
// newlocz = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); // newlocz = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz);
@@ -669,25 +662,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
return _spawnedNpcs; return _spawnedNpcs;
} }
/**
* @param oldNpc
*/
public void respawnNpc(L2Npc oldNpc)
{
if (_doRespawn)
{
oldNpc.refreshID();
initializeNpcInstance(oldNpc);
// Register NPC back to instance world
final Instance instance = oldNpc.getInstanceWorld();
if (instance != null)
{
instance.addNpc(oldNpc);
}
}
}
public L2NpcTemplate getTemplate() public L2NpcTemplate getTemplate()
{ {
return _template; return _template;
@@ -27,6 +27,7 @@ import java.util.function.Predicate;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.ai.L2CharacterAI; import com.l2jmobius.gameserver.ai.L2CharacterAI;
@@ -43,7 +44,7 @@ import com.l2jmobius.gameserver.util.Util;
public final class L2World public final class L2World
{ {
private static final Logger _log = Logger.getLogger(L2World.class.getName()); private static final Logger LOGGER = Logger.getLogger(L2World.class.getName());
/** Gracia border Flying objects not allowed to the east of it. */ /** Gracia border Flying objects not allowed to the east of it. */
public static final int GRACIA_MAX_X = -166168; public static final int GRACIA_MAX_X = -166168;
public static final int GRACIA_MAX_Z = 6105; public static final int GRACIA_MAX_Z = 6105;
@@ -90,8 +91,6 @@ public final class L2World
private static final Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>(); private static final Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>();
/** Map containing all visible objects. */ /** Map containing all visible objects. */
private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>(); private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>();
/** Map used for debug. */
// private final Map<Integer, String> _allObjectsDebug = new ConcurrentHashMap<>();
/** Map with the pets instances and their owner ID. */ /** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>(); private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
@@ -114,7 +113,7 @@ public final class L2World
} }
} }
_log.info(getClass().getSimpleName() + ": (" + REGIONS_X + " by " + REGIONS_Y + " by " + REGIONS_Z + ") World Region Grid set up."); LOGGER.info(getClass().getSimpleName() + ": (" + REGIONS_X + " by " + REGIONS_Y + " by " + REGIONS_Z + ") World Region Grid set up.");
} }
/** /**
@@ -126,20 +125,33 @@ public final class L2World
* </ul> * </ul>
* @param object * @param object
*/ */
public void storeObject(L2Object object) public void addObject(L2Object object)
{ {
if (_allObjects.containsKey(object.getObjectId())) if (_allObjects.putIfAbsent(object.getObjectId(), object) != null)
{ {
// _log.warning(getClass().getSimpleName() + ": Current object: " + object + " already exist in OID map!"); LOGGER.warning(getClass().getSimpleName() + ": Object " + object + " already exists in the world. Stack Trace: " + CommonUtil.getTraceString(Thread.currentThread().getStackTrace()));
// _log.warning(CommonUtil.getTraceString(Thread.currentThread().getStackTrace()));
// _log.warning(getClass().getSimpleName() + ": Previous object: " + _allObjects.get(object.getObjectId()) + " already exist in OID map!");
// _log.warning(_allObjectsDebug.get(object.getObjectId()));
// _log.warning("---------------------- End ---------------------");
return;
} }
_allObjects.put(object.getObjectId(), object); if (object.isPlayer())
// _allObjectsDebug.put(object.getObjectId(), CommonUtil.getTraceString(Thread.currentThread().getStackTrace())); {
final L2PcInstance newPlayer = (L2PcInstance) object;
if (newPlayer.isTeleporting()) // TODO: drop when we stop removing player from the world while teleporting.
{
return;
}
final L2PcInstance existingPlayer = _allPlayers.putIfAbsent(object.getObjectId(), newPlayer);
if (existingPlayer != null)
{
existingPlayer.logout();
newPlayer.logout();
LOGGER.warning(getClass().getSimpleName() + ": Duplicate character!? Disconnected both characters (" + newPlayer.getName() + ")");
}
else if (Config.FACTION_SYSTEM_ENABLED)
{
addFactionPlayerToWorld(existingPlayer);
}
}
} }
/** /**
@@ -155,7 +167,27 @@ public final class L2World
public void removeObject(L2Object object) public void removeObject(L2Object object)
{ {
_allObjects.remove(object.getObjectId()); _allObjects.remove(object.getObjectId());
// _allObjectsDebug.remove(object.getObjectId()); if (object.isPlayer())
{
final L2PcInstance player = (L2PcInstance) object;
if (player.isTeleporting()) // TODO: drop when we stop removing player from the world while teleportingq.
{
return;
}
_allPlayers.remove(object.getObjectId());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
} }
/** /**
@@ -248,15 +280,6 @@ public final class L2World
_petsInstance.remove(ownerId); _petsInstance.remove(ownerId);
} }
/**
* Remove the given pet instance.
* @param pet the pet to remove
*/
public void removePet(L2PetInstance pet)
{
_petsInstance.remove(pet.getOwner().getObjectId());
}
/** /**
* Add a L2Object in the world. <B><U> Concept</U> :</B> L2Object (including PlayerInstance) are identified in <B>_visibleObjects</B> of his current WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR> * Add a L2Object in the world. <B><U> Concept</U> :</B> L2Object (including PlayerInstance) are identified in <B>_visibleObjects</B> of his current WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
* PlayerInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B> * PlayerInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
@@ -275,24 +298,6 @@ public final class L2World
*/ */
public void addVisibleObject(L2Object object, L2WorldRegion newRegion) public void addVisibleObject(L2Object object, L2WorldRegion newRegion)
{ {
// TODO: this code should be obsoleted by protection in putObject func...
if (object.isPlayer())
{
final L2PcInstance player = object.getActingPlayer();
if (!player.isTeleporting())
{
final L2PcInstance old = getPlayer(player.getObjectId());
if (old != null)
{
_log.warning(getClass().getSimpleName() + ": Duplicate character!? Closing both characters (" + player.getName() + ")");
player.logout();
old.logout();
return;
}
addPlayerToWorld(player);
}
}
if (!newRegion.isActive()) if (!newRegion.isActive())
{ {
return; return;
@@ -352,41 +357,6 @@ public final class L2World
}); });
} }
/**
* Adds the player to the world.
* @param player the player to add
*/
public void addPlayerToWorld(L2PcInstance player)
{
_allPlayers.put(player.getObjectId(), player);
if (Config.FACTION_SYSTEM_ENABLED)
{
addFactionPlayerToWorld(player);
}
}
/**
* Remove the player from the world.
* @param player the player to remove
*/
public void removeFromAllPlayers(L2PcInstance player)
{
_allPlayers.remove(player.getObjectId());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
public static void addFactionPlayerToWorld(L2PcInstance player) public static void addFactionPlayerToWorld(L2PcInstance player)
{ {
if (player.isGood()) if (player.isGood())
@@ -476,15 +446,6 @@ public final class L2World
} }
return true; return true;
}); });
if (object.isPlayer())
{
final L2PcInstance player = object.getActingPlayer();
if (!player.isTeleporting())
{
removeFromAllPlayers(player);
}
}
} }
} }
@@ -804,7 +765,7 @@ public final class L2World
*/ */
public void deleteVisibleNpcSpawns() public void deleteVisibleNpcSpawns()
{ {
_log.info(getClass().getSimpleName() + ": Deleting all visible NPC's."); LOGGER.info(getClass().getSimpleName() + ": Deleting all visible NPCs.");
for (int x = 0; x <= REGIONS_X; x++) for (int x = 0; x <= REGIONS_X; x++)
{ {
for (int y = 0; y <= REGIONS_Y; y++) for (int y = 0; y <= REGIONS_Y; y++)
@@ -815,7 +776,7 @@ public final class L2World
} }
} }
} }
_log.info(getClass().getSimpleName() + ": All visible NPC's deleted."); LOGGER.info(getClass().getSimpleName() + ": All visible NPCs deleted.");
} }
public void incrementParty() public void incrementParty()
@@ -16,7 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model; package com.l2jmobius.gameserver.model;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -33,7 +32,7 @@ import com.l2jmobius.gameserver.model.actor.L2Vehicle;
public final class L2WorldRegion public final class L2WorldRegion
{ {
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName()); private static final Logger LOGGER = Logger.getLogger(L2WorldRegion.class.getName());
/** Map containing visible objects in this world region. */ /** Map containing visible objects in this world region. */
private volatile Map<Integer, L2Object> _visibleObjects; private volatile Map<Integer, L2Object> _visibleObjects;
@@ -66,33 +65,14 @@ public final class L2WorldRegion
@Override @Override
public void run() public void run()
{ {
if (_isActivating) forEachSurroundingRegion(w ->
{ {
// for each neighbor, if it's not active, activate. if (_isActivating || w.areNeighborsEmpty())
forEachSurroundingRegion(w ->
{ {
w.setActive(true); w.setActive(_isActivating);
return true;
});
}
else
{
if (areNeighborsEmpty())
{
setActive(false);
} }
return true;
// check and deactivate });
forEachSurroundingRegion(w ->
{
if (w.areNeighborsEmpty())
{
w.setActive(false);
}
return true;
});
}
} }
} }
@@ -106,8 +86,7 @@ public final class L2WorldRegion
int c = 0; int c = 0;
if (!isOn) if (!isOn)
{ {
final Collection<L2Object> vObj = _visibleObjects.values(); for (L2Object o : _visibleObjects.values())
for (L2Object o : vObj)
{ {
if (o instanceof L2Attackable) if (o instanceof L2Attackable)
{ {
@@ -138,14 +117,11 @@ public final class L2WorldRegion
c++; c++;
} }
} }
LOGGER.finer(c + " mobs were turned off");
_log.finer(c + " mobs were turned off");
} }
else else
{ {
final Collection<L2Object> vObj = _visibleObjects.values(); for (L2Object o : _visibleObjects.values())
for (L2Object o : vObj)
{ {
if (o instanceof L2Attackable) if (o instanceof L2Attackable)
{ {
@@ -158,9 +134,7 @@ public final class L2WorldRegion
((L2Npc) o).startRandomAnimationTask(); ((L2Npc) o).startRandomAnimationTask();
} }
} }
LOGGER.finer(c + " mobs were turned on");
_log.finer(c + " mobs were turned on");
} }
} }
@@ -172,10 +146,7 @@ public final class L2WorldRegion
public boolean areNeighborsEmpty() public boolean areNeighborsEmpty()
{ {
return forEachSurroundingRegion(w -> return forEachSurroundingRegion(w -> !(w.isActive() && w.getVisibleObjects().values().stream().anyMatch(L2Object::isPlayable)));
{
return !(w.isActive() && w.getVisibleObjects().values().stream().anyMatch(L2Object::isPlayable));
});
} }
/** /**
@@ -194,7 +165,7 @@ public final class L2WorldRegion
// turn the AI on or off to match the region's activation. // turn the AI on or off to match the region's activation.
switchAI(value); switchAI(value);
_log.finer((value ? "Starting" : "Stoping") + " Grid " + getName()); LOGGER.finer((value ? "Starting" : "Stopping") + " Grid " + this);
} }
/** /**
@@ -308,11 +279,6 @@ public final class L2WorldRegion
return _visibleObjects != null ? _visibleObjects : Collections.emptyMap(); return _visibleObjects != null ? _visibleObjects : Collections.emptyMap();
} }
public String getName()
{
return "(" + _regionX + ", " + _regionY + ", " + _regionZ + ")";
}
/** /**
* Deleted all spawns in the world. * Deleted all spawns in the world.
*/ */
@@ -323,10 +289,8 @@ public final class L2WorldRegion
return; return;
} }
_log.finer("Deleting all visible NPC's in Region: " + getName()); LOGGER.info("Deleting all visible NPCs in Region: " + this);
for (L2Object obj : _visibleObjects.values())
final Collection<L2Object> vNPC = _visibleObjects.values();
for (L2Object obj : vNPC)
{ {
if (obj instanceof L2Npc) if (obj instanceof L2Npc)
{ {
@@ -338,10 +302,10 @@ public final class L2WorldRegion
spawn.stopRespawn(); spawn.stopRespawn();
SpawnTable.getInstance().deleteSpawn(spawn, false); SpawnTable.getInstance().deleteSpawn(spawn, false);
} }
_log.finest("Removed NPC " + target.getObjectId()); LOGGER.finest("Removed NPC " + target.getObjectId());
} }
} }
_log.info("All visible NPC's deleted in Region: " + getName()); LOGGER.info("All visible NPCs deleted in Region: " + this);
} }
public boolean forEachSurroundingRegion(Predicate<L2WorldRegion> p) public boolean forEachSurroundingRegion(Predicate<L2WorldRegion> p)
@@ -385,4 +349,10 @@ public final class L2WorldRegion
{ {
return (region != null) && (getRegionX() >= (region.getRegionX() - 1)) && (getRegionX() <= (region.getRegionX() + 1)) && (getRegionY() >= (region.getRegionY() - 1)) && (getRegionY() <= (region.getRegionY() + 1)) && (getRegionZ() >= (region.getRegionZ() - 1)) && (getRegionZ() <= (region.getRegionZ() + 1)); return (region != null) && (getRegionX() >= (region.getRegionX() - 1)) && (getRegionX() <= (region.getRegionX() + 1)) && (getRegionY() >= (region.getRegionY() - 1)) && (getRegionY() <= (region.getRegionY() + 1)) && (getRegionZ() >= (region.getRegionZ() - 1)) && (getRegionZ() <= (region.getRegionZ() + 1));
} }
@Override
public String toString()
{
return "(" + _regionX + ", " + _regionY + ", " + _regionZ + ")";
}
} }
@@ -5110,19 +5110,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
@Override @Override
public final void setXYZ(int newX, int newY, int newZ) public final void setXYZ(int newX, int newY, int newZ)
{ {
try final ZoneRegion oldZoneRegion = ZoneManager.getInstance().getRegion(this);
final ZoneRegion newZoneRegion = ZoneManager.getInstance().getRegion(newX, newY);
if (oldZoneRegion != newZoneRegion)
{ {
final ZoneRegion oldZoneRegion = ZoneManager.getInstance().getRegion(this); oldZoneRegion.removeFromZones(this);
final ZoneRegion newZoneRegion = ZoneManager.getInstance().getRegion(newX, newY); newZoneRegion.revalidateZones(this);
if (oldZoneRegion != newZoneRegion)
{
oldZoneRegion.removeFromZones(this);
newZoneRegion.revalidateZones(this);
}
}
catch (Exception e)
{
badCoords();
} }
super.setXYZ(newX, newY, newZ); super.setXYZ(newX, newY, newZ);
@@ -1199,8 +1199,6 @@ public class L2Npc extends L2Character
ZoneManager.getInstance().getRegion(this).removeFromZones(this); ZoneManager.getInstance().getRegion(this).removeFromZones(this);
// Remove L2Object object from _allObjects of L2World
L2World.getInstance().removeObject(this);
return super.deleteMe(); return super.deleteMe();
} }
@@ -1497,7 +1495,7 @@ public class L2Npc extends L2Character
} }
/** /**
* Send an "event" to all NPC's within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event
* @param radius - radius to send event * @param radius - radius to send event
* @param reference - L2Object to pass, if needed * @param reference - L2Object to pass, if needed
@@ -420,9 +420,6 @@ public abstract class L2Vehicle extends L2Character
oldZoneRegion.removeFromZones(this); oldZoneRegion.removeFromZones(this);
// Remove L2Object object from _allObjects of World
L2World.getInstance().removeObject(this);
return super.deleteMe(); return super.deleteMe();
} }
@@ -11093,10 +11093,6 @@ public final class L2PcInstance extends L2Playable
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerMentorStatus(this, false), this); EventDispatcher.getInstance().notifyEventAsync(new OnPlayerMentorStatus(this, false), this);
} }
// Remove L2Object object from _allObjects of L2World
L2World.getInstance().removeObject(this);
L2World.getInstance().removeFromAllPlayers(this); // force remove in case of crash during teleport
try try
{ {
notifyFriends(L2FriendStatus.MODE_OFFLINE); notifyFriends(L2FriendStatus.MODE_OFFLINE);
@@ -12304,10 +12300,6 @@ public final class L2PcInstance extends L2Playable
public void stopMovie() public void stopMovie()
{ {
setIsTeleporting(true, false); // avoid to get player removed from L2World
decayMe();
spawnMe(getX(), getY(), getZ());
setIsTeleporting(false, false);
sendPacket(new ExStopScenePlayer(getMovieHolder().getMovie())); sendPacket(new ExStopScenePlayer(getMovieHolder().getMovie()));
setMovieHolder(null); setMovieHolder(null);
} }
@@ -780,8 +780,6 @@ public class L2PetInstance extends L2Summon
owner.sendInventoryUpdate(iu); owner.sendInventoryUpdate(iu);
owner.broadcastUserInfo(); owner.broadcastUserInfo();
L2World.getInstance().removeObject(removedItem);
} }
} }
catch (Exception e) catch (Exception e)
@@ -33,7 +33,6 @@ import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager; import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jmobius.gameserver.model.ArenaParticipantsHolder; import com.l2jmobius.gameserver.model.ArenaParticipantsHolder;
import com.l2jmobius.gameserver.model.L2Spawn; import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance; import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -613,7 +612,6 @@ public final class BlockCheckerEngine
} }
item.decayMe(); item.decayMe();
L2World.getInstance().removeObject(item);
} }
_drops.clear(); _drops.clear();
} }
@@ -24,7 +24,7 @@ import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.ILocational;
/** /**
* Holds depending between NPC's spawn point and route * Holds depending between NPCs spawn point and route
* @author GKR * @author GKR
*/ */
public final class NpcRoutesHolder public final class NpcRoutesHolder
@@ -80,7 +80,7 @@ public final class AuctionItem
public final L2ItemInstance createNewItemInstance() public final L2ItemInstance createNewItemInstance()
{ {
final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), _itemId); final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), _itemId);
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
item.setCount(_itemCount); item.setCount(_itemCount);
item.setEnchantLevel(item.getItem().getDefaultEnchantLevel()); item.setEnchantLevel(item.getItem().getDefaultEnchantLevel());
return item; return item;
@@ -1804,7 +1804,7 @@ public abstract class Inventory extends ItemContainer
} }
} }
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// If stackable item is found in inventory just add to current quantity // If stackable item is found in inventory just add to current quantity
if (item.isStackable() && (getItemByItemId(item.getId()) != null)) if (item.isStackable() && (getItemByItemId(item.getId()) != null))
@@ -525,8 +525,9 @@ public abstract class ItemContainer
item.updateDatabase(); item.updateDatabase();
refreshWeight(); refreshWeight();
item.deleteMe();
} }
item.deleteMe();
} }
return item; return item;
} }
@@ -682,7 +683,7 @@ public abstract class ItemContainer
while (rs.next()) while (rs.next())
{ {
final L2ItemInstance item = new L2ItemInstance(rs); final L2ItemInstance item = new L2ItemInstance(rs);
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
final L2PcInstance owner = getOwner() != null ? getOwner().getActingPlayer() : null; final L2PcInstance owner = getOwner() != null ? getOwner().getActingPlayer() : null;
@@ -123,7 +123,7 @@ public class Mail extends ItemContainer
while (inv.next()) while (inv.next())
{ {
final L2ItemInstance item = new L2ItemInstance(inv); final L2ItemInstance item = new L2ItemInstance(inv);
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// If stackable item is found just add to current quantity // If stackable item is found just add to current quantity
if (item.isStackable() && (getItemByItemId(item.getId()) != null)) if (item.isStackable() && (getItemByItemId(item.getId()) != null))
@@ -1419,9 +1419,6 @@ public final class L2ItemInstance extends L2Object
{ {
player.getWarehouse().destroyItem("L2ItemInstance", this, player, null); player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
} }
// delete from world
L2World.getInstance().removeObject(this);
} }
else else
{ {
@@ -1846,8 +1843,6 @@ public final class L2ItemInstance extends L2Object
player.getWarehouse().destroyItem("L2ItemInstance", this, player, null); player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
} }
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_EXPIRED).addItemName(getId())); player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_EXPIRED).addItemName(getId()));
// delete from world
L2World.getInstance().removeObject(this);
} }
} }
@@ -42,7 +42,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
/** /**
* Parent class for long time events.<br> * Parent class for long time events.<br>
* Maintains config reading, spawn of NPC's, adding of event's drop. * Maintains config reading, spawn of NPCs, adding of event's drop.
* @author GKR * @author GKR
*/ */
public class LongTimeEvent extends Quest public class LongTimeEvent extends Quest
@@ -58,7 +58,7 @@ public class LongTimeEvent extends Quest
protected DateRange _eventPeriod = null; protected DateRange _eventPeriod = null;
protected DateRange _dropPeriod; protected DateRange _dropPeriod;
// NPC's to spawm and their spawn points // NPCs to spawm and their spawn points
protected final List<NpcSpawn> _spawnList = new ArrayList<>(); protected final List<NpcSpawn> _spawnList = new ArrayList<>();
// Drop data for event // Drop data for event
@@ -265,7 +265,7 @@ public class LongTimeEvent extends Quest
} }
/** /**
* Maintenance event start - adds global drop, spawns event NPC's, shows start announcement. * Maintenance event start - adds global drop, spawns event NPCs, shows start announcement.
*/ */
protected void startEvent() protected void startEvent()
{ {
@@ -261,7 +261,7 @@ public final class CharacterCreate implements IClientIncomingPacket
private void initNewChar(L2GameClient client, L2PcInstance newChar) private void initNewChar(L2GameClient client, L2PcInstance newChar)
{ {
L2World.getInstance().storeObject(newChar); L2World.getInstance().addObject(newChar);
if (Config.STARTING_ADENA > 0) if (Config.STARTING_ADENA > 0)
{ {
@@ -24,7 +24,6 @@ import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData; import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType; import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race; import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder; import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory; import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
@@ -262,8 +261,6 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
L2World.getInstance().removeObject(removedItem);
activeChar.setInCrystallize(false); activeChar.setInCrystallize(false);
} }
} }
@@ -27,7 +27,6 @@ import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
import com.l2jmobius.gameserver.model.L2PetData; import com.l2jmobius.gameserver.model.L2PetData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -139,7 +138,6 @@ public final class Evolve
player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000)); player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000));
player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET); player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET);
// L2World.getInstance().storeObject(petSummon);
petSummon.spawnMe(oldX, oldY, oldZ); petSummon.spawnMe(oldX, oldY, oldZ);
petSummon.startFeed(); petSummon.startFeed();
item.setEnchantLevel(petSummon.getLevel()); item.setEnchantLevel(petSummon.getLevel());
@@ -227,7 +225,6 @@ public final class Evolve
player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000)); player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000));
player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET); player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET);
// L2World.getInstance().storeObject(petSummon);
petSummon.spawnMe(player.getX(), player.getY(), player.getZ()); petSummon.spawnMe(player.getX(), player.getY(), player.getZ());
petSummon.startFeed(); petSummon.startFeed();
addedItem.setEnchantLevel(petSummon.getLevel()); addedItem.setEnchantLevel(petSummon.getLevel());
@@ -239,9 +236,6 @@ public final class Evolve
player.broadcastUserInfo(); player.broadcastUserInfo();
final L2World world = L2World.getInstance();
world.removeObject(removedItem);
ThreadPoolManager.schedule(new EvolveFinalizer(player, petSummon), 900); ThreadPoolManager.schedule(new EvolveFinalizer(player, petSummon), 900);
if (petSummon.getCurrentFed() <= 0) if (petSummon.getCurrentFed() <= 0)
@@ -37,7 +37,7 @@ import ai.AbstractNpcAI;
*/ */
public final class SelMahumSquad extends AbstractNpcAI public final class SelMahumSquad extends AbstractNpcAI
{ {
// NPC's // NPCs
private static final int CHEF = 18908; private static final int CHEF = 18908;
private static final int FIRE = 18927; private static final int FIRE = 18927;
private static final int STOVE = 18933; private static final int STOVE = 18933;
@@ -32,7 +32,7 @@ import ai.AbstractNpcAI;
*/ */
public final class ClassTransferTalk extends AbstractNpcAI public final class ClassTransferTalk extends AbstractNpcAI
{ {
// NPC's // NPCs
// Talking Island Village (Administrative office) // Talking Island Village (Administrative office)
private static final int FRANCO = 32153; private static final int FRANCO = 32153;
private static final int RIVIAN = 32147; private static final int RIVIAN = 32147;
@@ -85,7 +85,7 @@ public final class Elpies extends Event
return false; return false;
} }
// Check Custom Table - we use custom NPC's // Check Custom Table - we use custom NPCs
if (!Config.CUSTOM_NPC_DATA) if (!Config.CUSTOM_NPC_DATA)
{ {
_log.info(getName() + ": Event can't be started because custom NPC table is disabled!"); _log.info(getName() + ": Event can't be started because custom NPC table is disabled!");
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
*/ */
public final class Race extends Event public final class Race extends Event
{ {
// Event NPC's list // Event NPCs list
private List<L2Npc> _npclist; private List<L2Npc> _npclist;
// Npc // Npc
private L2Npc _npc; private L2Npc _npc;
@@ -56,7 +56,7 @@ public final class Race extends Event
private static final int _time_register = 5; private static final int _time_register = 5;
// 5 min for race // 5 min for race
private static final int _time_race = 10; private static final int _time_race = 10;
// NPC's // NPCs
private static final int _start_npc = 900103; private static final int _start_npc = 900103;
private static final int _stop_npc = 900104; private static final int _stop_npc = 900104;
// Skills (Frog by default) // Skills (Frog by default)
@@ -118,7 +118,7 @@ public final class Race extends Event
{ {
return false; return false;
} }
// Check Custom Table - we use custom NPC's // Check Custom Table - we use custom NPCs
if (!Config.CUSTOM_NPC_DATA) if (!Config.CUSTOM_NPC_DATA)
{ {
_log.info(getName() + ": Event can't be started, because custom npc table is disabled!"); _log.info(getName() + ": Event can't be started, because custom npc table is disabled!");
@@ -128,8 +128,6 @@ public class AdminEffects implements IAdminCommandHandler
activeChar.setInvisible(true); activeChar.setInvisible(true);
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar)); activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar));
activeChar.decayMe();
activeChar.spawnMe();
activeChar.sendMessage("You are now invisible."); activeChar.sendMessage("You are now invisible.");
} }
else else
@@ -149,8 +147,6 @@ public class AdminEffects implements IAdminCommandHandler
activeChar.setInvisible(true); activeChar.setInvisible(true);
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar)); activeChar.sendPacket(new ExUserInfoAbnormalVisualEffect(activeChar));
activeChar.decayMe();
activeChar.spawnMe();
activeChar.sendMessage("You are now invisible."); activeChar.sendMessage("You are now invisible.");
} }
else if (command.startsWith("admin_vis")) else if (command.startsWith("admin_vis"))
@@ -401,8 +397,6 @@ public class AdminEffects implements IAdminCommandHandler
else if (command.startsWith("admin_unpolyself")) else if (command.startsWith("admin_unpolyself"))
{ {
activeChar.getPoly().setPolyInfo(null, "1"); activeChar.getPoly().setPolyInfo(null, "1");
activeChar.decayMe();
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
} }
else if (command.equals("admin_clearteams")) else if (command.equals("admin_clearteams"))
@@ -167,8 +167,7 @@ public class AdminPolymorph implements IAdminCommandHandler
Char.sendPacket(sg); Char.sendPacket(sg);
} }
// end of animation // end of animation
obj.decayMe(); obj.broadcastInfo();
obj.spawnMe(obj.getX(), obj.getY(), obj.getZ());
activeChar.sendMessage("Polymorph succeed"); activeChar.sendMessage("Polymorph succeed");
} }
else else
@@ -187,8 +186,7 @@ public class AdminPolymorph implements IAdminCommandHandler
if (target != null) if (target != null)
{ {
target.getPoly().setPolyInfo(null, "1"); target.getPoly().setPolyInfo(null, "1");
target.decayMe(); target.broadcastInfo();
target.spawnMe(target.getX(), target.getY(), target.getZ());
activeChar.sendMessage("Unpolymorph succeed"); activeChar.sendMessage("Unpolymorph succeed");
} }
else else
@@ -504,7 +504,7 @@ public class AdminSpawn implements IAdminCommandHandler
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level); final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level);
final int mobsCount = mobs.size(); final int mobsCount = mobs.size();
final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80)); final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80));
tb.append("<html><title>Spawn Monster:</title><body><p> Level : " + level + "<br>Total Npc's : " + mobsCount + "<br>"); tb.append("<html><title>Spawn Monster:</title><body><p> Level : " + level + "<br>Total NPCs : " + mobsCount + "<br>");
// Loop // Loop
int i = from; int i = from;
@@ -350,7 +350,7 @@ public final class Kamaloka extends AbstractInstance
*/ */
private static final int TELEPORTER = 32496; private static final int TELEPORTER = 32496;
/** Kamaloka captains (start npc's) npcIds. */ /** Kamaloka captains (start NPCs) npcIds. */
private static final int[] CAPTAINS = private static final int[] CAPTAINS =
{ {
30332, 30332,
@@ -47,7 +47,7 @@ import quests.Q10331_StartOfFate.Q10331_StartOfFate;
*/ */
public final class LabyrinthOfBelis extends AbstractInstance public final class LabyrinthOfBelis extends AbstractInstance
{ {
// NPC's // NPCs
private static final int SEBION = 32972; private static final int SEBION = 32972;
private static final int INFILTRATION_OFFICER = 19155; private static final int INFILTRATION_OFFICER = 19155;
private static final int BELIS_VERITIFICATION_SYSTEM = 33215; private static final int BELIS_VERITIFICATION_SYSTEM = 33215;
@@ -30,7 +30,7 @@ import quests.Q00184_ArtOfPersuasion.Q00184_ArtOfPersuasion;
*/ */
public final class Q00185_NikolasCooperation extends Quest public final class Q00185_NikolasCooperation extends Quest
{ {
// NPC's // NPCs
private static final int MAESTRO_NIKOLA = 30621; private static final int MAESTRO_NIKOLA = 30621;
private static final int RESEARCHER_LORAIN = 30673; private static final int RESEARCHER_LORAIN = 30673;
private static final int DESTROYED_DEVICE = 32366; private static final int DESTROYED_DEVICE = 32366;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public class Q00776_SlayDarkLordEkimus extends Quest public class Q00776_SlayDarkLordEkimus extends Quest
{ {
// NPC's // NPCs
private static final int TEPIOS = 32603; private static final int TEPIOS = 32603;
// Boss // Boss
private static final int EKIMUS = 29150; private static final int EKIMUS = 29150;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public class Q00777_SlayDarkLordTiat extends Quest public class Q00777_SlayDarkLordTiat extends Quest
{ {
// NPC's // NPCs
private static final int ALLENOS = 32526; private static final int ALLENOS = 32526;
// Boss // Boss
private static final int TIAT = 29163; private static final int TIAT = 29163;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public final class Q10353_CertificationOfValue extends Quest public final class Q10353_CertificationOfValue extends Quest
{ {
// Npc's // NPCs
public static final int RIEYI = 33155; public static final int RIEYI = 33155;
public static final int KYUORI = 33358; public static final int KYUORI = 33358;
private static final int DUMMY_MONSTER = 33349; private static final int DUMMY_MONSTER = 33349;
@@ -33,7 +33,7 @@ import com.l2jmobius.gameserver.util.Util;
*/ */
public final class Q10378_WeedingWork extends Quest public final class Q10378_WeedingWork extends Quest
{ {
// NPC's // NPCs
private static final int DADFPHYNA = 33697; private static final int DADFPHYNA = 33697;
// Monster's // Monster's
private static final int MANDRAGORA_OF_JOY_AND_SORROW = 23210; private static final int MANDRAGORA_OF_JOY_AND_SORROW = 23210;
@@ -36,7 +36,7 @@ import quests.Q10379_AnUninvitedGuest.Q10379_AnUninvitedGuest;
*/ */
public final class Q10380_TheExecutionersExecution extends Quest public final class Q10380_TheExecutionersExecution extends Quest
{ {
// NPC's // NPCs
private static final int ENDRIGO = 30632; private static final int ENDRIGO = 30632;
private static final int GUILLOTINE_OF_DEATH = 25892; private static final int GUILLOTINE_OF_DEATH = 25892;
private static final int NAGDU_THE_DEFORMED = 23201; private static final int NAGDU_THE_DEFORMED = 23201;
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.quest.QuestState;
*/ */
public final class Q10452_IsItEdible extends Quest public final class Q10452_IsItEdible extends Quest
{ {
// Npc's // NPCs
private static final int SALLY = 32743; private static final int SALLY = 32743;
// Monster's // Monster's
private static final int FANTASY_MUSHROM = 18864; private static final int FANTASY_MUSHROM = 18864;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.network.serverpackets.TutorialShowHtml;
*/ */
public final class Q10732_AForeignLand extends Quest public final class Q10732_AForeignLand extends Quest
{ {
// NPC's // NPCs
private static final int NAVARI = 33931; private static final int NAVARI = 33931;
private static final int GERETH = 33932; private static final int GERETH = 33932;
// Misc // Misc
@@ -30,7 +30,7 @@ import quests.Q10732_AForeignLand.Q10732_AForeignLand;
*/ */
public final class Q10733_TheTestForSurvival extends Quest public final class Q10733_TheTestForSurvival extends Quest
{ {
// NPC's // NPCs
private static final int GERETH = 33932; private static final int GERETH = 33932;
private static final int DIA = 34005; private static final int DIA = 34005;
private static final int KATALIN = 33943; private static final int KATALIN = 33943;
@@ -35,7 +35,7 @@ import quests.Q10733_TheTestForSurvival.Q10733_TheTestForSurvival;
*/ */
public final class Q10734_DoOrDie extends Quest public final class Q10734_DoOrDie extends Quest
{ {
// NPC's // NPCs
private static final int KATALIN = 33943; private static final int KATALIN = 33943;
private static final int AYANTHE = 33942; private static final int AYANTHE = 33942;
private static final int ADVENTURER_S_GUIDE_APPRENTICE = 33950; private static final int ADVENTURER_S_GUIDE_APPRENTICE = 33950;
@@ -35,7 +35,7 @@ import quests.Q10736_ASpecialPower.Q10736_ASpecialPower;
*/ */
public final class Q10737_GrakonsWarehouse extends Quest public final class Q10737_GrakonsWarehouse extends Quest
{ {
// NPC's // NPCs
private static final int KATALIN = 33943; private static final int KATALIN = 33943;
private static final int AYANTHE = 33942; private static final int AYANTHE = 33942;
private static final int GRAKON = 33947; private static final int GRAKON = 33947;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.quest.State;
*/ */
public final class Q10741_ADraughtForTheCold extends Quest public final class Q10741_ADraughtForTheCold extends Quest
{ {
// NPC's // NPCs
private static final int SIVANTHE = 33951; private static final int SIVANTHE = 33951;
private static final int LEIRA = 33952; private static final int LEIRA = 33952;
// Items // Items
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
*/ */
public final class Q10745_TheSecretIngredients extends Quest public final class Q10745_TheSecretIngredients extends Quest
{ {
// Npc's // NPCs
private static final int DOLKIN = 33954; private static final int DOLKIN = 33954;
private static final int KARLA = 33933; private static final int KARLA = 33933;
private static final int DOLKIN_INSTANCE = 34002; private static final int DOLKIN_INSTANCE = 34002;
@@ -761,9 +761,11 @@ public class L2CharacterAI extends AbstractAI
// Stop an AI Follow Task // Stop an AI Follow Task
stopFollow(); stopFollow();
} }
// Stop any intention that has target we want to forget. // Stop any intention that has target we want to forget.
setIntention(AI_INTENTION_ACTIVE); if (getIntention() != AI_INTENTION_MOVE_TO)
{
setIntention(AI_INTENTION_ACTIVE);
}
} }
// Check if the targeted object was the actor // Check if the targeted object was the actor
@@ -235,7 +235,7 @@ public class ItemTable
} }
// Add the L2ItemInstance object to _allObjects of L2world // Add the L2ItemInstance object to _allObjects of L2world
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// Set Item parameters // Set Item parameters
if (item.isStackable() && (count > 1)) if (item.isStackable() && (count > 1))
@@ -103,7 +103,7 @@ public final class ItemsOnGroundManager implements Runnable
while (rs.next()) while (rs.next())
{ {
item = new L2ItemInstance(rs.getInt(1), rs.getInt(2)); item = new L2ItemInstance(rs.getInt(1), rs.getInt(2));
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// this check and.. // this check and..
if (item.isStackable() && (rs.getInt(3) > 1)) if (item.isStackable() && (rs.getInt(3) > 1))
{ {
@@ -80,7 +80,7 @@ public final class SiegeGuardManager
final L2ItemInstance dropticket = new L2ItemInstance(holder.getItemId()); final L2ItemInstance dropticket = new L2ItemInstance(holder.getItemId());
dropticket.setItemLocation(ItemLocation.VOID); dropticket.setItemLocation(ItemLocation.VOID);
dropticket.dropMe(null, x, y, z); dropticket.dropMe(null, x, y, z);
L2World.getInstance().storeObject(dropticket); L2World.getInstance().addObject(dropticket);
_droppedTickets.add(dropticket); _droppedTickets.add(dropticket);
} }
} }
@@ -180,7 +180,7 @@ public final class SiegeGuardManager
final L2ItemInstance dropticket = new L2ItemInstance(itemId); final L2ItemInstance dropticket = new L2ItemInstance(itemId);
dropticket.setItemLocation(ItemLocation.VOID); dropticket.setItemLocation(ItemLocation.VOID);
dropticket.dropMe(null, player.getX(), player.getY(), player.getZ()); dropticket.dropMe(null, player.getX(), player.getY(), player.getZ());
L2World.getInstance().storeObject(dropticket); L2World.getInstance().addObject(dropticket);
_droppedTickets.add(dropticket); _droppedTickets.add(dropticket);
} }
} }
@@ -760,7 +760,15 @@ public final class ZoneManager implements IGameXmlReader
public ZoneRegion getRegion(int x, int y) public ZoneRegion getRegion(int x, int y)
{ {
return _zoneRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y]; try
{
return _zoneRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y];
}
catch (ArrayIndexOutOfBoundsException e)
{
// LOGGER.warning(getClass().getSimpleName() + ": Incorrect zone region X: " + ((x >> SHIFT_BY) + OFFSET_X) + " Y: " + ((y >> SHIFT_BY) + OFFSET_Y) + " for coordinates x: " + x + " y: " + y);
return null;
}
} }
public ZoneRegion getRegion(ILocational point) public ZoneRegion getRegion(ILocational point)
@@ -196,7 +196,6 @@ public class CursedWeapon implements INamable
else if (_item != null) else if (_item != null)
{ {
_item.decayMe(); _item.decayMe();
L2World.getInstance().removeObject(_item);
_log.info(_name + " item has been removed from World."); _log.info(_name + " item has been removed from World.");
} }
} }
@@ -177,7 +177,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
setWorldRegion(L2World.getInstance().getRegion(getLocation())); setWorldRegion(L2World.getInstance().getRegion(getLocation()));
// Add the L2Object spawn in the _allobjects of L2World // Add the L2Object spawn in the _allobjects of L2World
L2World.getInstance().storeObject(this); L2World.getInstance().addObject(this);
// Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
getWorldRegion().addVisibleObject(this); getWorldRegion().addVisibleObject(this);
@@ -519,19 +519,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
} }
protected void badCoords()
{
if (isCharacter())
{
decayMe();
}
else if (isPlayer())
{
((L2Character) this).teleToLocation(new Location(0, 0, 0), false);
((L2Character) this).sendMessage("Error with your coords, Please ask a GM for help!");
}
}
public final void setXYZInvisible(int x, int y, int z) public final void setXYZInvisible(int x, int y, int z)
{ {
if (x > L2World.MAP_MAX_X) if (x > L2World.MAP_MAX_X)
@@ -691,28 +678,21 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
setY(newY); setY(newY);
setZ(newZ); setZ(newZ);
try if (_isSpawned)
{ {
if (_isSpawned) final L2WorldRegion oldRegion = getWorldRegion();
final L2WorldRegion newRegion = L2World.getInstance().getRegion(this);
if (newRegion != oldRegion)
{ {
final L2WorldRegion oldRegion = getWorldRegion(); if (oldRegion != null)
final L2WorldRegion newRegion = L2World.getInstance().getRegion(this);
if (newRegion != oldRegion)
{ {
if (oldRegion != null) oldRegion.removeVisibleObject(this);
{
oldRegion.removeVisibleObject(this);
}
newRegion.addVisibleObject(this);
L2World.getInstance().switchRegion(this, newRegion);
setWorldRegion(newRegion);
} }
newRegion.addVisibleObject(this);
L2World.getInstance().switchRegion(this, newRegion);
setWorldRegion(newRegion);
} }
} }
catch (Exception e)
{
badCoords();
}
} }
/** /**
@@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable; import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.INamable;
@@ -81,11 +80,8 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
/** The task launching the function doSpawn() */ /** The task launching the function doSpawn() */
class SpawnTask implements Runnable class SpawnTask implements Runnable
{ {
private final L2Npc _oldNpc; public SpawnTask()
public SpawnTask(L2Npc pOldNpc)
{ {
_oldNpc = pOldNpc;
} }
@Override @Override
@@ -93,8 +89,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
{ {
try try
{ {
// doSpawn(); doSpawn();
respawnNpc(_oldNpc);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -401,8 +396,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
_scheduledCount++; _scheduledCount++;
// Create a new SpawnTask to launch after the respawn Delay // Create a new SpawnTask to launch after the respawn Delay
// ClientScheduler.getInstance().scheduleLow(new SpawnTask(npcId), _respawnDelay); ThreadPoolManager.schedule(new SpawnTask(), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
ThreadPoolManager.schedule(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
} }
} }
@@ -489,7 +483,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
if (_template.isType("L2Pet") || _template.isType("L2Decoy") || _template.isType("L2Trap")) if (_template.isType("L2Pet") || _template.isType("L2Decoy") || _template.isType("L2Trap"))
{ {
_currentCount++; _currentCount++;
return null; return null;
} }
@@ -558,7 +551,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
} }
// DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings
// don't correct z of flying npc's // don't correct z of flying NPCs
// if (!npc.isFlying()) // if (!npc.isFlying())
// { // {
// newlocz = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); // newlocz = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz);
@@ -669,25 +662,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
return _spawnedNpcs; return _spawnedNpcs;
} }
/**
* @param oldNpc
*/
public void respawnNpc(L2Npc oldNpc)
{
if (_doRespawn)
{
oldNpc.refreshID();
initializeNpcInstance(oldNpc);
// Register NPC back to instance world
final Instance instance = oldNpc.getInstanceWorld();
if (instance != null)
{
instance.addNpc(oldNpc);
}
}
}
public L2NpcTemplate getTemplate() public L2NpcTemplate getTemplate()
{ {
return _template; return _template;
@@ -27,6 +27,7 @@ import java.util.function.Predicate;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.ai.CtrlEvent; import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.ai.L2CharacterAI; import com.l2jmobius.gameserver.ai.L2CharacterAI;
@@ -43,7 +44,7 @@ import com.l2jmobius.gameserver.util.Util;
public final class L2World public final class L2World
{ {
private static final Logger _log = Logger.getLogger(L2World.class.getName()); private static final Logger LOGGER = Logger.getLogger(L2World.class.getName());
/** Gracia border Flying objects not allowed to the east of it. */ /** Gracia border Flying objects not allowed to the east of it. */
public static final int GRACIA_MAX_X = -166168; public static final int GRACIA_MAX_X = -166168;
public static final int GRACIA_MAX_Z = 6105; public static final int GRACIA_MAX_Z = 6105;
@@ -90,8 +91,6 @@ public final class L2World
private static final Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>(); private static final Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>();
/** Map containing all visible objects. */ /** Map containing all visible objects. */
private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>(); private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>();
/** Map used for debug. */
// private final Map<Integer, String> _allObjectsDebug = new ConcurrentHashMap<>();
/** Map with the pets instances and their owner ID. */ /** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>(); private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
@@ -114,7 +113,7 @@ public final class L2World
} }
} }
_log.info(getClass().getSimpleName() + ": (" + REGIONS_X + " by " + REGIONS_Y + " by " + REGIONS_Z + ") World Region Grid set up."); LOGGER.info(getClass().getSimpleName() + ": (" + REGIONS_X + " by " + REGIONS_Y + " by " + REGIONS_Z + ") World Region Grid set up.");
} }
/** /**
@@ -126,20 +125,33 @@ public final class L2World
* </ul> * </ul>
* @param object * @param object
*/ */
public void storeObject(L2Object object) public void addObject(L2Object object)
{ {
if (_allObjects.containsKey(object.getObjectId())) if (_allObjects.putIfAbsent(object.getObjectId(), object) != null)
{ {
// _log.warning(getClass().getSimpleName() + ": Current object: " + object + " already exist in OID map!"); LOGGER.warning(getClass().getSimpleName() + ": Object " + object + " already exists in the world. Stack Trace: " + CommonUtil.getTraceString(Thread.currentThread().getStackTrace()));
// _log.warning(CommonUtil.getTraceString(Thread.currentThread().getStackTrace()));
// _log.warning(getClass().getSimpleName() + ": Previous object: " + _allObjects.get(object.getObjectId()) + " already exist in OID map!");
// _log.warning(_allObjectsDebug.get(object.getObjectId()));
// _log.warning("---------------------- End ---------------------");
return;
} }
_allObjects.put(object.getObjectId(), object); if (object.isPlayer())
// _allObjectsDebug.put(object.getObjectId(), CommonUtil.getTraceString(Thread.currentThread().getStackTrace())); {
final L2PcInstance newPlayer = (L2PcInstance) object;
if (newPlayer.isTeleporting()) // TODO: drop when we stop removing player from the world while teleporting.
{
return;
}
final L2PcInstance existingPlayer = _allPlayers.putIfAbsent(object.getObjectId(), newPlayer);
if (existingPlayer != null)
{
existingPlayer.logout();
newPlayer.logout();
LOGGER.warning(getClass().getSimpleName() + ": Duplicate character!? Disconnected both characters (" + newPlayer.getName() + ")");
}
else if (Config.FACTION_SYSTEM_ENABLED)
{
addFactionPlayerToWorld(existingPlayer);
}
}
} }
/** /**
@@ -155,7 +167,27 @@ public final class L2World
public void removeObject(L2Object object) public void removeObject(L2Object object)
{ {
_allObjects.remove(object.getObjectId()); _allObjects.remove(object.getObjectId());
// _allObjectsDebug.remove(object.getObjectId()); if (object.isPlayer())
{
final L2PcInstance player = (L2PcInstance) object;
if (player.isTeleporting()) // TODO: drop when we stop removing player from the world while teleportingq.
{
return;
}
_allPlayers.remove(object.getObjectId());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
} }
/** /**
@@ -248,15 +280,6 @@ public final class L2World
_petsInstance.remove(ownerId); _petsInstance.remove(ownerId);
} }
/**
* Remove the given pet instance.
* @param pet the pet to remove
*/
public void removePet(L2PetInstance pet)
{
_petsInstance.remove(pet.getOwner().getObjectId());
}
/** /**
* Add a L2Object in the world. <B><U> Concept</U> :</B> L2Object (including PlayerInstance) are identified in <B>_visibleObjects</B> of his current WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR> * Add a L2Object in the world. <B><U> Concept</U> :</B> L2Object (including PlayerInstance) are identified in <B>_visibleObjects</B> of his current WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
* PlayerInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B> * PlayerInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
@@ -275,24 +298,6 @@ public final class L2World
*/ */
public void addVisibleObject(L2Object object, L2WorldRegion newRegion) public void addVisibleObject(L2Object object, L2WorldRegion newRegion)
{ {
// TODO: this code should be obsoleted by protection in putObject func...
if (object.isPlayer())
{
final L2PcInstance player = object.getActingPlayer();
if (!player.isTeleporting())
{
final L2PcInstance old = getPlayer(player.getObjectId());
if (old != null)
{
_log.warning(getClass().getSimpleName() + ": Duplicate character!? Closing both characters (" + player.getName() + ")");
player.logout();
old.logout();
return;
}
addPlayerToWorld(player);
}
}
if (!newRegion.isActive()) if (!newRegion.isActive())
{ {
return; return;
@@ -352,41 +357,6 @@ public final class L2World
}); });
} }
/**
* Adds the player to the world.
* @param player the player to add
*/
public void addPlayerToWorld(L2PcInstance player)
{
_allPlayers.put(player.getObjectId(), player);
if (Config.FACTION_SYSTEM_ENABLED)
{
addFactionPlayerToWorld(player);
}
}
/**
* Remove the player from the world.
* @param player the player to remove
*/
public void removeFromAllPlayers(L2PcInstance player)
{
_allPlayers.remove(player.getObjectId());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
public static void addFactionPlayerToWorld(L2PcInstance player) public static void addFactionPlayerToWorld(L2PcInstance player)
{ {
if (player.isGood()) if (player.isGood())
@@ -476,15 +446,6 @@ public final class L2World
} }
return true; return true;
}); });
if (object.isPlayer())
{
final L2PcInstance player = object.getActingPlayer();
if (!player.isTeleporting())
{
removeFromAllPlayers(player);
}
}
} }
} }
@@ -804,7 +765,7 @@ public final class L2World
*/ */
public void deleteVisibleNpcSpawns() public void deleteVisibleNpcSpawns()
{ {
_log.info(getClass().getSimpleName() + ": Deleting all visible NPC's."); LOGGER.info(getClass().getSimpleName() + ": Deleting all visible NPCs.");
for (int x = 0; x <= REGIONS_X; x++) for (int x = 0; x <= REGIONS_X; x++)
{ {
for (int y = 0; y <= REGIONS_Y; y++) for (int y = 0; y <= REGIONS_Y; y++)
@@ -815,7 +776,7 @@ public final class L2World
} }
} }
} }
_log.info(getClass().getSimpleName() + ": All visible NPC's deleted."); LOGGER.info(getClass().getSimpleName() + ": All visible NPCs deleted.");
} }
public void incrementParty() public void incrementParty()
@@ -16,7 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model; package com.l2jmobius.gameserver.model;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -33,7 +32,7 @@ import com.l2jmobius.gameserver.model.actor.L2Vehicle;
public final class L2WorldRegion public final class L2WorldRegion
{ {
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName()); private static final Logger LOGGER = Logger.getLogger(L2WorldRegion.class.getName());
/** Map containing visible objects in this world region. */ /** Map containing visible objects in this world region. */
private volatile Map<Integer, L2Object> _visibleObjects; private volatile Map<Integer, L2Object> _visibleObjects;
@@ -66,33 +65,14 @@ public final class L2WorldRegion
@Override @Override
public void run() public void run()
{ {
if (_isActivating) forEachSurroundingRegion(w ->
{ {
// for each neighbor, if it's not active, activate. if (_isActivating || w.areNeighborsEmpty())
forEachSurroundingRegion(w ->
{ {
w.setActive(true); w.setActive(_isActivating);
return true;
});
}
else
{
if (areNeighborsEmpty())
{
setActive(false);
} }
return true;
// check and deactivate });
forEachSurroundingRegion(w ->
{
if (w.areNeighborsEmpty())
{
w.setActive(false);
}
return true;
});
}
} }
} }
@@ -106,8 +86,7 @@ public final class L2WorldRegion
int c = 0; int c = 0;
if (!isOn) if (!isOn)
{ {
final Collection<L2Object> vObj = _visibleObjects.values(); for (L2Object o : _visibleObjects.values())
for (L2Object o : vObj)
{ {
if (o instanceof L2Attackable) if (o instanceof L2Attackable)
{ {
@@ -138,14 +117,11 @@ public final class L2WorldRegion
c++; c++;
} }
} }
LOGGER.finer(c + " mobs were turned off");
_log.finer(c + " mobs were turned off");
} }
else else
{ {
final Collection<L2Object> vObj = _visibleObjects.values(); for (L2Object o : _visibleObjects.values())
for (L2Object o : vObj)
{ {
if (o instanceof L2Attackable) if (o instanceof L2Attackable)
{ {
@@ -158,9 +134,7 @@ public final class L2WorldRegion
((L2Npc) o).startRandomAnimationTask(); ((L2Npc) o).startRandomAnimationTask();
} }
} }
LOGGER.finer(c + " mobs were turned on");
_log.finer(c + " mobs were turned on");
} }
} }
@@ -172,10 +146,7 @@ public final class L2WorldRegion
public boolean areNeighborsEmpty() public boolean areNeighborsEmpty()
{ {
return forEachSurroundingRegion(w -> return forEachSurroundingRegion(w -> !(w.isActive() && w.getVisibleObjects().values().stream().anyMatch(L2Object::isPlayable)));
{
return !(w.isActive() && w.getVisibleObjects().values().stream().anyMatch(L2Object::isPlayable));
});
} }
/** /**
@@ -194,7 +165,7 @@ public final class L2WorldRegion
// turn the AI on or off to match the region's activation. // turn the AI on or off to match the region's activation.
switchAI(value); switchAI(value);
_log.finer((value ? "Starting" : "Stoping") + " Grid " + getName()); LOGGER.finer((value ? "Starting" : "Stopping") + " Grid " + this);
} }
/** /**
@@ -308,11 +279,6 @@ public final class L2WorldRegion
return _visibleObjects != null ? _visibleObjects : Collections.emptyMap(); return _visibleObjects != null ? _visibleObjects : Collections.emptyMap();
} }
public String getName()
{
return "(" + _regionX + ", " + _regionY + ", " + _regionZ + ")";
}
/** /**
* Deleted all spawns in the world. * Deleted all spawns in the world.
*/ */
@@ -323,10 +289,8 @@ public final class L2WorldRegion
return; return;
} }
_log.finer("Deleting all visible NPC's in Region: " + getName()); LOGGER.info("Deleting all visible NPCs in Region: " + this);
for (L2Object obj : _visibleObjects.values())
final Collection<L2Object> vNPC = _visibleObjects.values();
for (L2Object obj : vNPC)
{ {
if (obj instanceof L2Npc) if (obj instanceof L2Npc)
{ {
@@ -338,10 +302,10 @@ public final class L2WorldRegion
spawn.stopRespawn(); spawn.stopRespawn();
SpawnTable.getInstance().deleteSpawn(spawn, false); SpawnTable.getInstance().deleteSpawn(spawn, false);
} }
_log.finest("Removed NPC " + target.getObjectId()); LOGGER.finest("Removed NPC " + target.getObjectId());
} }
} }
_log.info("All visible NPC's deleted in Region: " + getName()); LOGGER.info("All visible NPCs deleted in Region: " + this);
} }
public boolean forEachSurroundingRegion(Predicate<L2WorldRegion> p) public boolean forEachSurroundingRegion(Predicate<L2WorldRegion> p)
@@ -385,4 +349,10 @@ public final class L2WorldRegion
{ {
return (region != null) && (getRegionX() >= (region.getRegionX() - 1)) && (getRegionX() <= (region.getRegionX() + 1)) && (getRegionY() >= (region.getRegionY() - 1)) && (getRegionY() <= (region.getRegionY() + 1)) && (getRegionZ() >= (region.getRegionZ() - 1)) && (getRegionZ() <= (region.getRegionZ() + 1)); return (region != null) && (getRegionX() >= (region.getRegionX() - 1)) && (getRegionX() <= (region.getRegionX() + 1)) && (getRegionY() >= (region.getRegionY() - 1)) && (getRegionY() <= (region.getRegionY() + 1)) && (getRegionZ() >= (region.getRegionZ() - 1)) && (getRegionZ() <= (region.getRegionZ() + 1));
} }
@Override
public String toString()
{
return "(" + _regionX + ", " + _regionY + ", " + _regionZ + ")";
}
} }
@@ -5110,19 +5110,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
@Override @Override
public final void setXYZ(int newX, int newY, int newZ) public final void setXYZ(int newX, int newY, int newZ)
{ {
try final ZoneRegion oldZoneRegion = ZoneManager.getInstance().getRegion(this);
final ZoneRegion newZoneRegion = ZoneManager.getInstance().getRegion(newX, newY);
if (oldZoneRegion != newZoneRegion)
{ {
final ZoneRegion oldZoneRegion = ZoneManager.getInstance().getRegion(this); oldZoneRegion.removeFromZones(this);
final ZoneRegion newZoneRegion = ZoneManager.getInstance().getRegion(newX, newY); newZoneRegion.revalidateZones(this);
if (oldZoneRegion != newZoneRegion)
{
oldZoneRegion.removeFromZones(this);
newZoneRegion.revalidateZones(this);
}
}
catch (Exception e)
{
badCoords();
} }
super.setXYZ(newX, newY, newZ); super.setXYZ(newX, newY, newZ);
@@ -1199,8 +1199,6 @@ public class L2Npc extends L2Character
ZoneManager.getInstance().getRegion(this).removeFromZones(this); ZoneManager.getInstance().getRegion(this).removeFromZones(this);
// Remove L2Object object from _allObjects of L2World
L2World.getInstance().removeObject(this);
return super.deleteMe(); return super.deleteMe();
} }
@@ -1497,7 +1495,7 @@ public class L2Npc extends L2Character
} }
/** /**
* Send an "event" to all NPC's within given radius * Send an "event" to all NPCs within given radius
* @param eventName - name of event * @param eventName - name of event
* @param radius - radius to send event * @param radius - radius to send event
* @param reference - L2Object to pass, if needed * @param reference - L2Object to pass, if needed
@@ -420,9 +420,6 @@ public abstract class L2Vehicle extends L2Character
oldZoneRegion.removeFromZones(this); oldZoneRegion.removeFromZones(this);
// Remove L2Object object from _allObjects of World
L2World.getInstance().removeObject(this);
return super.deleteMe(); return super.deleteMe();
} }
@@ -11100,10 +11100,6 @@ public final class L2PcInstance extends L2Playable
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerMentorStatus(this, false), this); EventDispatcher.getInstance().notifyEventAsync(new OnPlayerMentorStatus(this, false), this);
} }
// Remove L2Object object from _allObjects of L2World
L2World.getInstance().removeObject(this);
L2World.getInstance().removeFromAllPlayers(this); // force remove in case of crash during teleport
try try
{ {
notifyFriends(L2FriendStatus.MODE_OFFLINE); notifyFriends(L2FriendStatus.MODE_OFFLINE);
@@ -12311,10 +12307,6 @@ public final class L2PcInstance extends L2Playable
public void stopMovie() public void stopMovie()
{ {
setIsTeleporting(true, false); // avoid to get player removed from L2World
decayMe();
spawnMe(getX(), getY(), getZ());
setIsTeleporting(false, false);
sendPacket(new ExStopScenePlayer(getMovieHolder().getMovie())); sendPacket(new ExStopScenePlayer(getMovieHolder().getMovie()));
setMovieHolder(null); setMovieHolder(null);
} }
@@ -780,8 +780,6 @@ public class L2PetInstance extends L2Summon
owner.sendInventoryUpdate(iu); owner.sendInventoryUpdate(iu);
owner.broadcastUserInfo(); owner.broadcastUserInfo();
L2World.getInstance().removeObject(removedItem);
} }
} }
catch (Exception e) catch (Exception e)
@@ -33,7 +33,6 @@ import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager; import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jmobius.gameserver.model.ArenaParticipantsHolder; import com.l2jmobius.gameserver.model.ArenaParticipantsHolder;
import com.l2jmobius.gameserver.model.L2Spawn; import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance; import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -613,7 +612,6 @@ public final class BlockCheckerEngine
} }
item.decayMe(); item.decayMe();
L2World.getInstance().removeObject(item);
} }
_drops.clear(); _drops.clear();
} }
@@ -24,7 +24,7 @@ import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.ILocational;
/** /**
* Holds depending between NPC's spawn point and route * Holds depending between NPCs spawn point and route
* @author GKR * @author GKR
*/ */
public final class NpcRoutesHolder public final class NpcRoutesHolder
@@ -80,7 +80,7 @@ public final class AuctionItem
public final L2ItemInstance createNewItemInstance() public final L2ItemInstance createNewItemInstance()
{ {
final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), _itemId); final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), _itemId);
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
item.setCount(_itemCount); item.setCount(_itemCount);
item.setEnchantLevel(item.getItem().getDefaultEnchantLevel()); item.setEnchantLevel(item.getItem().getDefaultEnchantLevel());
return item; return item;
@@ -1834,7 +1834,7 @@ public abstract class Inventory extends ItemContainer
} }
} }
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// If stackable item is found in inventory just add to current quantity // If stackable item is found in inventory just add to current quantity
if (item.isStackable() && (getItemByItemId(item.getId()) != null)) if (item.isStackable() && (getItemByItemId(item.getId()) != null))
@@ -525,8 +525,9 @@ public abstract class ItemContainer
item.updateDatabase(); item.updateDatabase();
refreshWeight(); refreshWeight();
item.deleteMe();
} }
item.deleteMe();
} }
return item; return item;
} }
@@ -682,7 +683,7 @@ public abstract class ItemContainer
while (rs.next()) while (rs.next())
{ {
final L2ItemInstance item = new L2ItemInstance(rs); final L2ItemInstance item = new L2ItemInstance(rs);
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
final L2PcInstance owner = getOwner() != null ? getOwner().getActingPlayer() : null; final L2PcInstance owner = getOwner() != null ? getOwner().getActingPlayer() : null;
@@ -123,7 +123,7 @@ public class Mail extends ItemContainer
while (inv.next()) while (inv.next())
{ {
final L2ItemInstance item = new L2ItemInstance(inv); final L2ItemInstance item = new L2ItemInstance(inv);
L2World.getInstance().storeObject(item); L2World.getInstance().addObject(item);
// If stackable item is found just add to current quantity // If stackable item is found just add to current quantity
if (item.isStackable() && (getItemByItemId(item.getId()) != null)) if (item.isStackable() && (getItemByItemId(item.getId()) != null))
@@ -1426,9 +1426,6 @@ public final class L2ItemInstance extends L2Object
{ {
player.getWarehouse().destroyItem("L2ItemInstance", this, player, null); player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
} }
// delete from world
L2World.getInstance().removeObject(this);
} }
else else
{ {
@@ -1857,8 +1854,6 @@ public final class L2ItemInstance extends L2Object
player.getWarehouse().destroyItem("L2ItemInstance", this, player, null); player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
} }
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_EXPIRED).addItemName(getId())); player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_EXPIRED).addItemName(getId()));
// delete from world
L2World.getInstance().removeObject(this);
} }
} }
@@ -42,7 +42,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
/** /**
* Parent class for long time events.<br> * Parent class for long time events.<br>
* Maintains config reading, spawn of NPC's, adding of event's drop. * Maintains config reading, spawn of NPCs, adding of event's drop.
* @author GKR * @author GKR
*/ */
public class LongTimeEvent extends Quest public class LongTimeEvent extends Quest
@@ -58,7 +58,7 @@ public class LongTimeEvent extends Quest
protected DateRange _eventPeriod = null; protected DateRange _eventPeriod = null;
protected DateRange _dropPeriod; protected DateRange _dropPeriod;
// NPC's to spawm and their spawn points // NPCs to spawm and their spawn points
protected final List<NpcSpawn> _spawnList = new ArrayList<>(); protected final List<NpcSpawn> _spawnList = new ArrayList<>();
// Drop data for event // Drop data for event
@@ -265,7 +265,7 @@ public class LongTimeEvent extends Quest
} }
/** /**
* Maintenance event start - adds global drop, spawns event NPC's, shows start announcement. * Maintenance event start - adds global drop, spawns event NPCs, shows start announcement.
*/ */
protected void startEvent() protected void startEvent()
{ {
@@ -261,7 +261,7 @@ public final class CharacterCreate implements IClientIncomingPacket
private void initNewChar(L2GameClient client, L2PcInstance newChar) private void initNewChar(L2GameClient client, L2PcInstance newChar)
{ {
L2World.getInstance().storeObject(newChar); L2World.getInstance().addObject(newChar);
if (Config.STARTING_ADENA > 0) if (Config.STARTING_ADENA > 0)
{ {
@@ -24,7 +24,6 @@ import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData; import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType; import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race; import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder; import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory; import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
@@ -262,8 +261,6 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
activeChar.broadcastUserInfo(); activeChar.broadcastUserInfo();
L2World.getInstance().removeObject(removedItem);
activeChar.setInCrystallize(false); activeChar.setInCrystallize(false);
} }
} }
@@ -27,7 +27,6 @@ import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
import com.l2jmobius.gameserver.model.L2PetData; import com.l2jmobius.gameserver.model.L2PetData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -139,7 +138,6 @@ public final class Evolve
player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000)); player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000));
player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET); player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET);
// L2World.getInstance().storeObject(petSummon);
petSummon.spawnMe(oldX, oldY, oldZ); petSummon.spawnMe(oldX, oldY, oldZ);
petSummon.startFeed(); petSummon.startFeed();
item.setEnchantLevel(petSummon.getLevel()); item.setEnchantLevel(petSummon.getLevel());
@@ -227,7 +225,6 @@ public final class Evolve
player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000)); player.sendPacket(new MagicSkillUse(npc, 2046, 1, 1000, 600000));
player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET); player.sendPacket(SystemMessageId.SUMMONING_YOUR_PET);
// L2World.getInstance().storeObject(petSummon);
petSummon.spawnMe(player.getX(), player.getY(), player.getZ()); petSummon.spawnMe(player.getX(), player.getY(), player.getZ());
petSummon.startFeed(); petSummon.startFeed();
addedItem.setEnchantLevel(petSummon.getLevel()); addedItem.setEnchantLevel(petSummon.getLevel());
@@ -239,9 +236,6 @@ public final class Evolve
player.broadcastUserInfo(); player.broadcastUserInfo();
final L2World world = L2World.getInstance();
world.removeObject(removedItem);
ThreadPoolManager.schedule(new EvolveFinalizer(player, petSummon), 900); ThreadPoolManager.schedule(new EvolveFinalizer(player, petSummon), 900);
if (petSummon.getCurrentFed() <= 0) if (petSummon.getCurrentFed() <= 0)
@@ -37,7 +37,7 @@ import ai.AbstractNpcAI;
*/ */
public final class SelMahumSquad extends AbstractNpcAI public final class SelMahumSquad extends AbstractNpcAI
{ {
// NPC's // NPCs
private static final int CHEF = 18908; private static final int CHEF = 18908;
private static final int FIRE = 18927; private static final int FIRE = 18927;
private static final int STOVE = 18933; private static final int STOVE = 18933;
@@ -32,7 +32,7 @@ import ai.AbstractNpcAI;
*/ */
public final class ClassTransferTalk extends AbstractNpcAI public final class ClassTransferTalk extends AbstractNpcAI
{ {
// NPC's // NPCs
// Talking Island Village (Administrative office) // Talking Island Village (Administrative office)
private static final int FRANCO = 32153; private static final int FRANCO = 32153;
private static final int RIVIAN = 32147; private static final int RIVIAN = 32147;
@@ -85,7 +85,7 @@ public final class Elpies extends Event
return false; return false;
} }
// Check Custom Table - we use custom NPC's // Check Custom Table - we use custom NPCs
if (!Config.CUSTOM_NPC_DATA) if (!Config.CUSTOM_NPC_DATA)
{ {
_log.info(getName() + ": Event can't be started because custom NPC table is disabled!"); _log.info(getName() + ": Event can't be started because custom NPC table is disabled!");
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
*/ */
public final class Race extends Event public final class Race extends Event
{ {
// Event NPC's list // Event NPCs list
private List<L2Npc> _npclist; private List<L2Npc> _npclist;
// Npc // Npc
private L2Npc _npc; private L2Npc _npc;
@@ -56,7 +56,7 @@ public final class Race extends Event
private static final int _time_register = 5; private static final int _time_register = 5;
// 5 min for race // 5 min for race
private static final int _time_race = 10; private static final int _time_race = 10;
// NPC's // NPCs
private static final int _start_npc = 900103; private static final int _start_npc = 900103;
private static final int _stop_npc = 900104; private static final int _stop_npc = 900104;
// Skills (Frog by default) // Skills (Frog by default)
@@ -118,7 +118,7 @@ public final class Race extends Event
{ {
return false; return false;
} }
// Check Custom Table - we use custom NPC's // Check Custom Table - we use custom NPCs
if (!Config.CUSTOM_NPC_DATA) if (!Config.CUSTOM_NPC_DATA)
{ {
_log.info(getName() + ": Event can't be started, because custom npc table is disabled!"); _log.info(getName() + ": Event can't be started, because custom npc table is disabled!");

Some files were not shown because too many files have changed in this diff Show More