Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (revision 1850)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (working copy)
@@ -1965,39 +1965,7 @@
{
_spawn = spawn;
}
-
-
- /**
- * Remove the L2NpcInstance from the world and update its spawn object (for a complete removal use the deleteMe method).<BR><BR>
- *
- * <B><U> Actions</U> :</B><BR><BR>
- * <li>Remove the L2NpcInstance from the world when the decay task is launched </li>
- * <li>Decrease its spawn counter </li>
- * <li>Manage Siege task (killFlag, killCT) </li><BR><BR>
- *
- * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR>
- * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to players</B></FONT><BR><BR>
- *
- */
- public void onDecay()
- {
- // Manage Life Control Tower
- if (this instanceof L2ControlTowerInstance)
- ((L2ControlTowerInstance)this).onDeath();
- // Remove the L2NpcInstance from the world when the decay task is launched
- super.onDecay();
-
- // Decrease its spawn counter
- if (_spawn != null)
- _spawn.decreaseCount(this);
-
- // Reset the _decayTask for this L2NpcInstance
- if (_decayTask != null)
- _decayTask.cancel(false);
- _decayTask = null;
- }
-
/**
* Remove PROPERLY the L2NpcInstance from the world.<BR><BR>
*
@@ -2035,13 +2003,45 @@
return this.getTemplate().name;
}
+ /**
+ * Remove the L2NpcInstance from the world and update its spawn object (for a complete removal use the deleteMe method).<BR><BR>
+ *
+ * <B><U> Actions</U> :</B><BR><BR>
+ * <li>Remove the L2NpcInstance from the world when the decay task is launched </li>
+ * <li>Decrease its spawn counter </li>
+ * <li>Manage Siege task (killFlag, killCT) </li><BR><BR>
+ *
+ * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR>
+ * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to players</B></FONT><BR><BR>
+ *
+ */
public void endDecayTask()
{
- if (_decayTask == null)
- return;
-
- _decayTask.cancel(true);
- _decayTask = null;
- this.onDecay();
+ // Manage Life Control Tower
+ if (this instanceof L2ControlTowerInstance)
+ ((L2ControlTowerInstance)this).onDeath();
+
+ // Remove the L2NpcInstance from the world when the decay task is launched
+ super.onDecay();
+
+ // Decrease its spawn counter
+ if (_spawn != null)
+ _spawn.decreaseCount(this);
+
+ synchronized(_decayTask)
+ {
+ // Reset the _decayTask for this L2NpcInstance
+ while (!_decayTask.isDone())
+ {
+ try
+ {
+ wait();
+ }
+ catch (InterruptedException e) {}
+ }
+ _decayTask.cancel(false);
+ _decayTask = null;
+ DecayTaskManager.getInstance().cancelDecayTask(this);
+ }
}
}